I want to graph R vs. g for n=0,1 and 2.
2 次查看(过去 30 天)
显示 更早的评论
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1338964/image.png)
I want to graph R vs g for g=[0, 0.5]
Y axis is restricted (0 to 0.25)
7 个评论
John D'Errico
2023-4-3
As a hint, I would compute each term as the sum of the logs of each part of those elements. Only at the end do you exponentiate the result. If not, expect to rapidly see underflows or overflows, or maybe both at once.
As a second hint, how do you compute the log of a factorial? The simplest way is to use the relationship of the factorial to the gamma function, and to then realize that MATLAB provides the function gammaln, which computes the natural log of the gamma function.
Alternatively, you would find that Stirling's approximation is actually quite accurate for the factorial, and it is easily logged. Or, you could compute the log of a factorial as the sum of the logs of the integers in the necessary product. Even so, just use gammaln.
Finally, Torsten gave you a relation for the double factorial
In the end though, you need to put it together as this is your assignment, not ours. At the very least, you need to make a credible effort.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Log Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!