Gamma(n) = (n-1)!

Librairie C++ de calcul formel/ C++ symbolic computation library

Modérateur : xcasadmin

lukamar
Messages : 331
Inscription : ven. juin 30, 2017 9:55 am
Localisation : Zagreb, Croatia

Gamma(n) = (n-1)!

Message par lukamar » lun. juil. 08, 2019 10:47 am

Hello,

Giac does some simplifications of sin(n*pi) and cos(n*pi) after assume(n,integer). I propose a similar simplification for the gamma function, i.e. that Gamma(n) returns (n-1)! when n is a symbol assumed to be a positive integer. Something similar could also be done with the Beta function, as Beta(m,n)=(m-1)!*(n-1)!/(m+n-1)! for positive integers m and n.

parisse
Messages : 5731
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: Gamma(n) = (n-1)!

Message par parisse » lun. juil. 08, 2019 7:13 pm

The following change would do it:

Code : Tout sélectionner

diff usual.cc usual.cc~
7985,7986d7984
<     if (is_assumed_integer(x,contextptr))
<       return gammatofactorial(x,contextptr);
I don't know if this might have side effects.

lukamar
Messages : 331
Inscription : ven. juin 30, 2017 9:55 am
Localisation : Zagreb, Croatia

Re: Gamma(n) = (n-1)!

Message par lukamar » lun. juil. 08, 2019 8:20 pm

Thanks for the code, it's really a simple solution, but I do not know about possible side effects either. Perhaps it's better to leave the simplification to individual commands than doing it automatically.

parisse
Messages : 5731
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: Gamma(n) = (n-1)!

Message par parisse » mar. juil. 09, 2019 6:01 am

I think I will give it a try. If there are side effects, then I'll add a user command for gammatofactorial.

Répondre