MATLAB Answers

Dealing with numbers bigger than Realmax

13 views (last 30 days)
Raed Marabeh
Raed Marabeh on 20 Jan 2021
Answered: John D'Errico on 20 Jan 2021
I have a code in Matlab, and in one step it calculates Gamma function for different values. But when I try to find Gamma(172.5) I get inf as it is greatter than realmax. My question: is there a away that I can get and calculate big numbera like Gamma (172.5) in Matlab without getting inf?


Sign in to comment.

Answers (1)

John D'Errico
John D'Errico on 20 Jan 2021
No. Not using double precision numbers. That does not say you can do nothing.
You can use the symbolic toolbox to compute the result. This will be slow if you are doing many computations. But it will work.
Or you can learn about how to work with logs in your computations. Then you can learn about the function gammaln. This computes the natural log of the gamma function.
That does not mean you can then simply exponentiate the result, since it will still overflow. But if you learn about how to do these computations, you can almost always suceed.


Sign in to comment.


Community Treasure Hunt

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

Start Hunting!

Translated by