Hi Julien,

On Sun, 06 Feb 2011 09:30:16 +0100
Julien PUYDT <julien.pu...@laposte.net> wrote:

> Le 05/02/2011 11:44, Francois Bissey a écrit :
> > So gamma could be called from C, Cython, possibly mpmath, pynac or
> > maxima. I guess you could tests the results calling from mpmath or
> > maxima. I am guessing that SR(10.0r).gamma() will end up being a
> > call to maxima to compute gamma but I could be completely off
> > track. But since it is also a gamma computation it could be related
> > to the previous computation of gamma(6).

On most platforms, we use the tgammal() function provided by the C
library to evaluate gamma when the input is a float. See lines
1032-1039 of sage/symbolic/pynac.pyx and 21-28 of
sage/symbolic/pynac_cc.h for the relevant code.

> Here are a few computations :
> 
> sage: gamma(6.)
> 120.000000000000

Here 6. is a RealLiteral. This gets converted to a RealNumber with the
default precision. Then the evaluation is done with the .gamma() method
of real numbers, which uses MPFR.

sage: type(6.)
<type 'sage.rings.real_mpfr.RealLiteral'>

> sage: gamma(float(6))
> 119.99999999999997
> sage: SR(6.0r).gamma()
> 119.99999999999997

Both these examples call the same code in sage/symbolic/pynac.pyx I
mentioned above and pass the evaluation to the C library.

The cephes library was included in the standard Sage distribution
recently to prevent these problems, but some symbolic functions still
need to switch to using that when the C library is unreliable. The file
sage/symbolic/pynac_cc.h is there to facilitate this switch.

> Launching, from my sage directory :
> LD_LIBRARY_PATH=./local/lib ./local/bin/maxima
> 
> I can write :
> (%i1) gamma(6.);
> (%o1)                                 120
> (%i2) gamma(6.0000000000000000000000);
> (%o2)                                120.0

Using maxima for such things would be incredibly slow. We avoid that
when possible. But, as you can see from the comments in
sage/symbolic/pynac.pyx, the special functions in Sage, especially
those provided by GiNaC/pynac need a lot of work.


Thank you.

Burcin

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to