#10849: behaviour of gamma strangely sensitive
---------------------------------+------------------------------------------
Reporter: dsm | Owner: burcin
Type: defect | Status: needs_review
Priority: major | Milestone: sage-5.11
Component: symbolics | Resolution:
Keywords: | Work issues:
Report Upstream: N/A | Reviewers:
Authors: Burcin Erocal | Merged in:
Dependencies: #7160, #9880 | Stopgaps:
---------------------------------+------------------------------------------
Changes (by burcin):
* status: needs_work => needs_review
* dependencies: #7160 => #7160, #9880
* milestone: sage-pending => sage-5.11
Old description:
> Whether you get the correct result or a spurious ValueError in evaluating
> some gamma expressions depends upon things it shouldn't.
>
> This comes from [http://groups.google.com/group/sage-
> support/browse_thread/thread/3b7126c1a29db091# a sage-support thread]; I
> looked and couldn't find it here, but possibly it's a duplicate. (I have
> bad luck with trac.)
> See also [http://demo.sagenb.org/home/pub/66/ this worksheet].
>
> Here's a relatively simple test case, in 4.6.1 and 4.6.2.rc0:
>
> {{{
> sage: x = var("x")
> sage: f = exp(gamma(I*x-1/2).subs(x=I*x))
> sage: g=f.operands()[0]
> sage: g, type(g)
> (gamma(-x - 1/2), <type 'sage.symbolic.expression.Expression'>)
> sage: g(x=0)
> ---------------------------------------------------------------------------
> ValueError Traceback (most recent call
> last)
>
> /Applications/sage_devel/<ipython console> in <module>()
>
> /Applications/sage/local/lib/python2.6/site-
> packages/sage/symbolic/expression.so in
> sage.symbolic.expression.Expression.__call__
> (sage/symbolic/expression.cpp:15657)()
>
> /Applications/sage/local/lib/python2.6/site-
> packages/sage/symbolic/ring.so in
> sage.symbolic.ring.SymbolicRing._call_element_
> (sage/symbolic/ring.cpp:6537)()
>
> /Applications/sage/local/lib/python2.6/site-
> packages/sage/symbolic/expression.so in
> sage.symbolic.expression.Expression.substitute
> (sage/symbolic/expression.cpp:15036)()
>
> /Applications/sage/local/lib/python2.6/site-
> packages/sage/symbolic/pynac.so in sage.symbolic.pynac.py_doublefactorial
> (sage/symbolic/pynac.cpp:9463)()
>
> ValueError: argument must be >= -1
> sage: g(x=0)
> ---------------------------------------------------------------------------
> ValueError Traceback (most recent call
> last)
> [ ... duplicate removed; this is merely to show it's not only the first
> call which has problems ]
> ValueError: argument must be >= -1
> sage: gamma(-x-1/2)*g
> gamma(-x - 1/2)^2
> sage: g(x=0)
> -2*sqrt(pi)
> }}}
>
> That is, merely performing the should-be-irrelevant "gamma(-x-1/2)*g" op
> makes g(x=0) start working. Instrumenting it shows that that
> py_doublefactorial gets a -3 the first time instead of the 1 it does the
> second time, but I couldn't quite follow the calling order to isolate the
> error.
>
> Apply attachment:trac_10849-doctests.patch
New description:
Whether you get the correct result or a spurious ValueError in evaluating
some gamma expressions depends upon things it shouldn't.
This comes from [http://groups.google.com/group/sage-
support/browse_thread/thread/3b7126c1a29db091# a sage-support thread]; I
looked and couldn't find it here, but possibly it's a duplicate. (I have
bad luck with trac.)
See also [http://demo.sagenb.org/home/pub/66/ this worksheet].
Here's a relatively simple test case, in 4.6.1 and 4.6.2.rc0:
{{{
sage: x = var("x")
sage: f = exp(gamma(I*x-1/2).subs(x=I*x))
sage: g=f.operands()[0]
sage: g, type(g)
(gamma(-x - 1/2), <type 'sage.symbolic.expression.Expression'>)
sage: g(x=0)
---------------------------------------------------------------------------
ValueError Traceback (most recent call
last)
/Applications/sage_devel/<ipython console> in <module>()
/Applications/sage/local/lib/python2.6/site-
packages/sage/symbolic/expression.so in
sage.symbolic.expression.Expression.__call__
(sage/symbolic/expression.cpp:15657)()
/Applications/sage/local/lib/python2.6/site-packages/sage/symbolic/ring.so
in sage.symbolic.ring.SymbolicRing._call_element_
(sage/symbolic/ring.cpp:6537)()
/Applications/sage/local/lib/python2.6/site-
packages/sage/symbolic/expression.so in
sage.symbolic.expression.Expression.substitute
(sage/symbolic/expression.cpp:15036)()
/Applications/sage/local/lib/python2.6/site-
packages/sage/symbolic/pynac.so in sage.symbolic.pynac.py_doublefactorial
(sage/symbolic/pynac.cpp:9463)()
ValueError: argument must be >= -1
sage: g(x=0)
---------------------------------------------------------------------------
ValueError Traceback (most recent call
last)
[ ... duplicate removed; this is merely to show it's not only the first
call which has problems ]
ValueError: argument must be >= -1
sage: gamma(-x-1/2)*g
gamma(-x - 1/2)^2
sage: g(x=0)
-2*sqrt(pi)
}}}
That is, merely performing the should-be-irrelevant "gamma(-x-1/2)*g" op
makes g(x=0) start working. Instrumenting it shows that that
py_doublefactorial gets a -3 the first time instead of the 1 it does the
second time, but I couldn't quite follow the calling order to isolate the
error.
Apply [attachment:trac_10849-doctests-on_9880.patch]
--
Comment:
Now that #7160 is fixed, this can be reviewed. Patchbot says that the old
patch applies without problems on Sage 5.10.beta4 and passes tests. I am
attaching a new patch that is rebased on #9880, since both tickets add
doctests to the same function and I hope #9880 will go in before this one.
:)
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/10849#comment:10>
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 http://groups.google.com/group/sage-trac?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.