Limits of using vpa
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi,
I need to evaluate the gamma function in MATLAB for some very large values, and have so far been using 'vpa' to do this.
However, this now seems to be hitting a limit around gamma(1e8), as shown below.
Is it posible to extend this somehow to calculate gamma(1e8)?
Thank you!
gamma(vpa(1e7))
ans =
1.2024234005159034561401534879443e+65657052
>> gamma(vpa(1e8))
ans =
Inf
1 commentaire
David Goodmanson
le 23 Juin 2020
Hi John,
at some point it make a lot more sense to use the logarithm.
vpa(gammaln(1e100),100)
ans = 2.292585092994046058293551528706245869611598545401159566538932922285195947207408619737372157648583e+102
Réponses (1)
Pratheek Punchathody
le 24 Nov 2020
Modifié(e) : Pratheek Punchathody
le 24 Nov 2020
Hi John
Logarithm of gamma function command avoids the underflow and overflow that may occur.
By using the command
y=gammaln(1e8);
Output obtained is y= 1.7421e+09
If the number of digits that has to be displayed is known (say 25) then
By using the command
z= vpa(gammaln(1e8),25);
Output obtained is z = 1742068066.103834867477417
Refer to the documentation on vpa(x,d) for more information. Here d must be greater than 1 and lesser than 2^29+1.
0 commentaires
Voir également
Catégories
En savoir plus sur Gamma Functions dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!