Subject: When to simplify complete elliptic integrals?
From: Dieter Kaiser
Date: Thu, 5 Mar 2009 21:00:08 +0100
Hello Ray,
for the special functions I have implemented I had the problem too to decide
what simplifications should be done automatically and which should be triggered.
Some decisions might be not useful. All of the following simplifications take
place only if the flag gamma_expand is true:
(%i7) gamma_incomplete(1,z);
(%o7) gamma_incomplete(1,z)
(%i8) gamma_incomplete(1,z),gamma_expand:true;
(%o8) %e^-z
(%i9) gamma_incomplete(1/2,z);
(%o9) gamma_incomplete(1/2,z)
(%i10) gamma_incomplete(1/2,z),gamma_expand:true;
(%o10) sqrt(%pi)*erfc(sqrt(z))
(%i12) gamma(n+1)/gamma(n);
(%o12) gamma(n+1)/gamma(n)
(%i13) gamma(n+1)/gamma(n),gamma_expand:true;
(%o13) n
The following simplifications are done automatically
(%i29) beta_incomplete(1,b,z);
(%o29) (1-(1-z)^b)/b
(%i30) beta_incomplete(2,b,z);
(%o30) (1-(1-z)^b*(b*z+1))/(b*(b+1))
(%i31) beta_incomplete(a,2,z);
(%o31) (a*(1-z)+1)*z^a/(a*(a+1))
But the following simplification again depends on a flag:
(%i34) beta_incomplete(a+1,b,z),beta_expand:true;
(%o34) a*beta_incomplete(a,b,z)/(b+a)-(1-z)^b*z^a/(b+a)
Similar flags I have used for the Error functions or the Exponential Integrals
(the flags for the Exponential Integrals should be more consistent with the
other special functions. I think this should be corrected).
One benefit to do the simplification within the simplifier is that it works very
good recursivley. This was a problem with minfactorial.
The expansion using the flag factorial_expand:
(%i38) factorial(factorial(n+1)/factorial(n)),factorial_expand:true;
(%o38) (n+1)*n!
Minfactorial can not simplify nested factorials:
(%i39) minfactorial(factorial(factorial(n+1)/factorial(n)));
(%o39) ((n+1)!/n!)!
What I think could be interesting is to have a general flag like function_expand
which always enables some more possible simplifications and works like an
evflag. This flag could enable simplifications like beta(a,b) ->
gamma(a)*gamma(b)/gamma(a+b), or do the expansions like above. The further flags
like gamma_expand or beta_expand might than be useful to do some fine tuning of
the simplification process.
Dieter Kaiser
-----Urspr?ngliche Nachricht-----
Von: raymond.toy at stericsson.com [mailto:raymond.toy at stericsson.com]
Gesendet: Donnerstag, 5. M?rz 2009 17:26
An: Richard Fateman
Cc: Dieter Kaiser; Maxima
Betreff: Re: [Maxima] When to simplify complete elliptic integrals?
Richard Fateman wrote:
> It seems to me that some people might prefer elliptic functions over
> gamma functions, so making the transformation all the time may be
> unsatisfactory to some people.
> How to control this situation is analogous to lots of others, though.
>
I think that's why the simplification of elliptic functions is done via
makegamma. Well, plus the fact that that's how some other functions
were done, so I was copying that. But after several years, I had
forgotten about it, and was adding the simplification in the elliptic
function routines themselves.
Now I'm debating whether to continue with the old scheme of using
makegamma, or moving the simplification to the elliptic functions
themselves.
I agree with Dieter that it's easier to find and understand if it's in
the elliptic functions instead of being spread around in other
functions. But, as you say, sometimes elliptic_ec(1/2) is better than
the somewhat messy version in terms of gamma(1/4). At least it's
documented to use makegamma to convert some elliptic_ec to gamma
functions if possible. :-)
Can't decide what to do....
Ray