On Mon, 14 Mar 2011 17:40:41 +0100
Julien PUYDT <julien.pu...@laposte.net> wrote:

> Le 14/03/2011 14:12, David Kirkby a écrit :
> >
> > On 14 March 2011 13:04, David Kirkby<david.kir...@onetel.net>
> > wrote:
> >> On 13 March 2011 15:34, Julien PUYDT<julien.pu...@laposte.net>
> >> wrote:
> >>> Hi,
> >>>
> >>> among the few failing tests with my ARM built, two are because of
> >>> accuracy reasons :
> >>>
> >>> File
> >>> "/home/jpuydt/sage-4.6.2/devel/sage/sage/functions/other.py",
> >>> line 497: sage: gamma1(float(6)) Expected:
> >>>     120.0
> >>> Got:
> >>>     119.99999999999997
<snip>
> >>> File
> >>> "/home/jpuydt/sage-4.6.2/devel/sage/sage/symbolic/expression.pyx",
> >>> line 6067: sage: SR(10.0r).gamma()
> >>> Expected:
> >>>     362880.0
> >>> Got:
> >>>     362880.00000000047
<snip>
> >
> > Perhaps you can find value of n, such that gamma(n) gives an exact
> > integer result. If that happens on other CPUs too, then I suggest
> > the argument to the doctest is changed.
> 
> The solution of finding a "good" integer is fragile : it will break 
> anytime wind will change direction.
> 
> Actually, the best solution is the one I gave : handle fuzzy results! 
> You have to keep in mind that floats can't seriously be used for 
> equality -- there is a margin of error (and the margin moves
> according to the floating comma which gave its name to the type).
>
> Are doctests pure string checks? Can't they allow things like
> "(result - expected) < 0.0000001" ?

The doctests are pure string checks. You can explicitly check that the
error is less than a certain value as John Palmieri wrote in another
response, but in this case, we should fix the real problem and make
sure our gamma() function returns correct results.

On many platforms, the tgammal() function from the c library gives
results with adequate precision. However, on some, like cygwin [1] or
ARM, this is not the case.  We should call a different function to
compute gamma for floating point input on these platforms. 

[1] http://trac.sagemath.org/sage_trac/ticket/9162

This can be done by changing the relevant lines in
sage/symbolic/pynac_cc.h. Perhaps the gsl_sf_gamma() from GSL [2] or
something from cephes [3] will do the job.

[2]
http://www.gnu.org/software/gsl/manual/html_node/Gamma-Functions.html

[3] http://www.netlib.org/cephes/


Cheers,
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