How to write the codes for this gamma function?

조회 수: 6 (최근 30일)
MD. Rokibujjaman sovon
MD. Rokibujjaman sovon 2020년 10월 23일
댓글: MD. Rokibujjaman sovon 2020년 10월 25일
I am trying to find the value for alpha and beta. the answer should be alpha=395.2359 and beta=2.0698
But i am not getting this answer.
I used this code.
syms a b
[a,b]=solve(a.*gamma((1/b) + 1) - 350.1 == 0, a.^2.*gamma((2/b) + 1) - 154056.7 == 0)
Can someone tell me where is the problem in my codes and what should be the right codes?
Thanks.

채택된 답변

John D'Errico
John D'Errico 2020년 10월 23일
편집: John D'Errico 2020년 10월 23일
Easy, peasy. Although since you are using gamma as a FUNCTION, it is a REALLY bad idea to use beta, another closely related special function as a variable.
For the changed problem, I now have:
First, eliminate a. Square the first equation, then divide one into the other. This is valid as long as we create no zero divides.
We get
gamma(2/beta + 1)/gamma(1/beta + 1)^2 = 154056.7/350.1^2
Solve for beta. But before we bother to try that, plot the function. Does it EVER cross zero? Certainly, does it cross zero near 2? (NO.)
bfun = @(bet) gamma(2./bet + 1)./gamma(1./bet + 1).^2 - 154056.7/350.1^2;
fplot(bfun,[1,3])
yline(0);
So now, we see a solution bet beta, roughly near 2.
format long g
bet = fzero(bfun,2)
bet =
2.06980749988105
Solving for alpha is now easy. (Again, alpha is ALSO a function in MATLAB.
alph = 350.1/gamma(1/bet + 1)
alph =
395.23590882898
Could you have used the symbolic toolbox? Trivially easy too. But since an analytical solution will not exist, you will use vpasolve. Since vpasolve is a numerical solver, you will do best if you provide initial estimates of the unknowns as multiple solutions can exist.
syms a b real positive
[a,b] = vpasolve(a.*gamma((1/b) + 1) - 350.1 == 0, a.^2.*gamma((2/b) + 1) - 154056.7 == 0,[a,b],[300,2])
a = 
395.23590882898036747077460275278
b = 
2.0698074998810479469634339822283
  댓글 수: 7
Walter Roberson
Walter Roberson 2020년 10월 24일
vpasolve does not demand initial estimates. But it might happen to find a different solution, possibly even one that involves complex values.
Also, in general some equations are nonlinear enough that vpasolve does a poor job of finding any solution at all. Sometimes it is necessary to provide a guess that is pretty close. A couple of weeks ago, one user had a system that vpasolve failed on unless the initial guess was within 0.1 on one of the values. Just "wanting" not to use initial values is not always enough to get a solution in practice.
MD. Rokibujjaman sovon
MD. Rokibujjaman sovon 2020년 10월 25일
Thanks

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Alan Stevens
Alan Stevens 2020년 10월 23일
Compare your coded value of 154056.7 with the equation's value of 154.056.

카테고리

Help CenterFile Exchange에서 Numeric Solvers에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by