#18210: numerical bug in incomplete gamma function
-------------------------------------------------+-------------------------
       Reporter:  VivianePons                    |        Owner:
           Type:  defect                         |       Status:  new
       Priority:  major                          |    Milestone:  sage-6.7
      Component:  symbolics                      |   Resolution:
       Keywords:  sd67                           |    Merged in:
        Authors:                                 |    Reviewers:
Report Upstream:  Reported upstream. Developers  |  Work issues:
  acknowledge bug.                               |
         Branch:                                 |       Commit:
   Dependencies:                                 |     Stopgaps:
-------------------------------------------------+-------------------------

Comment (by slelievre):

 This ticket seems to be solved now in Sage 7.3.beta9.

 Trying the code from the ticket description...
 {{{
 $ ./sage -v
 SageMath version 7.3.beta9, Release Date: 2016-07-22
 $ ./sage -q
 sage: gamma(60, 30).numerical_approx()
 1.38682990237888e80
 }}}
 {{{
 sage: %gp

   --> Switching to PARI/GP interpreter <--

 pari: \p 50
 realprecision = 57 significant digits (50 digits displayed)
 pari: incgam(60,30)
 1.3868299023788801161747839921239559320835799009004 E80
 pari: \p 30
 realprecision = 38 significant digits (30 digits displayed)
 pari: incgam(60,30)
 1.38682990237888011617478399212 E80
 pari: <ctrl-D>

   --> Exiting back to Sage <--

 }}}
 {{{
 sage: _ = var('R k')
 sage: integrated = -(gamma(1/2*k, 1/2*R*k) - gamma(1/2*k))/gamma(1/2*k)
 sage: plot(integrated.subs(k=41), (R,0,6))
 Launched png viewer for Graphics object consisting of 1 graphics primitive
 sage: integrated = -(gamma(1/2*k, 1/2*R*k) - gamma(1/2*k))/gamma(1/2*k)
 sage: plot(integrated.subs(k=41.), (R,0,6))
 Launched png viewer for Graphics object consisting of 2 graphics
 primitives
 }}}
 {{{
 sage: from sage.libs.mpmath import utils as mpmath_utils
 sage: import mpmath
 sage: mpmath_utils.call(mpmath.gammainc, 60, 0, 30)
 1.28307801824120e74
 }}}

 Replying to [comment:37 buck]:
 > I was finally able to integrate pari master-branch with sage, and while
 the problem is much improved, it's not fixed.
 > Here's the graph from the original bug report, using newest pari:

 Trying that now seems to work for me, I get nice graphs with no spikes.
 {{{
 sage: sum(
 ....:     plot(
 ....:         integrated(k=k),
 ....:         (x, 0, 2.5),
 ....:         ymax=1.6,
 ....:         color=color,
 ....:         legend_label='k=%i' % k,
 ....:         figsize=6,
 ....:         aspect_ratio=1.0,
 ....:     )
 ....:     for k, color in zip(
 ....:         [21, 22, 23, 26, 31, 41],
 ....:         ['blue', 'brown', 'red', 'green', 'black', 'yellow',
 'orange'],
 ....:     )
 ....: )
 Launched png viewer for Graphics object consisting of 6 graphics
 primitives
 }}}

 > Those discontinuities are false. An example bad value:
 > {{{
 > sage: gamma(100, 7.01)
 > -2.71843697211100e151
 > }}}
 > I will report this upstream, and attach a worksheet showing more detail.

 What is the correct value? I get the following in Sage 7.3.beta9.
 {{{
 sage: gamma(100, 7.01)
 9.33262154439442e155
 }}}

--
Ticket URL: <https://trac.sagemath.org/ticket/18210#comment:38>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to