Stieltjes constants and ARB

82 views
Skip to first unread message

harald....@gmail.com

unread,
Nov 9, 2021, 2:31:33 PM11/9/21
to sage-devel
Hi,

RBF(stieltjes(1)) no longer works. It now gives the error message

TypeError: unable to convert stieltjes(1) to a RealBall

I realize that this means it most likely wasn't working right before (the code must have worked because Sage fell back on SymbolicRing -> RealField -> RBF, which shouldn't happen). I also realize that I could type RBF(RIF(stieltjes(1)), but that's a stopgap measure that shouldn't be necessary, since stieltjes(1) is in fact implemented in ARB.

version: Sagemath 9.3 on an Intel Mac Mini (Mac OS Monterrey) 
or Sagemath 9.4 on cocalc.

Best
Harald

harald....@gmail.com

unread,
Nov 9, 2021, 2:34:34 PM11/9/21
to sage-devel
PS. I have the same issue with RBF(1/sqrt(2)).

William Stein

unread,
Nov 9, 2021, 2:41:10 PM11/9/21
to sage-devel
It does seem to work for me on sage-9.4 on cocalc, so can you provide
a complete log of what you're doing, etc.?

~$ sage
┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 9.4, Release Date: 2021-08-22 │
│ Using Python 3.9.5. Type "help()" for help. │
└────────────────────────────────────────────────────────────────────┘
sage: RBF(stieltjes(1))
[-0.07281584548367673 +/- 2.30e-18]
sage: RBF(1/sqrt(2))
[0.707106781186547 +/- 7.95e-16]
sage:
Exiting Sage (CPU time 0m0.24s, Wall time 0m39.76s).
~$ uname -a
Linux project-2cc650fd-1b95-467b-b748-75b421914dae 5.11.0-1020-gcp
#22~20.04.1-Ubuntu SMP Tue Sep 21 10:54:26 UTC 2021 x86_64 x86_64
x86_64 GNU/Linux
> --
> You received this message because you are subscribed to the Google Groups "sage-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/0500174a-66ab-4491-aad1-6727af69cbbbn%40googlegroups.com.



--
William (http://wstein.org)

harald....@gmail.com

unread,
Nov 9, 2021, 2:47:59 PM11/9/21
to sage-devel
... and the same with RBF(gamma(3/2,1)), except that

(a) The error message is now "TypeError: gamma() takes no arguments (1 given)"
(b) The situation is now more serious, since RIF(gamma(3/2,1)) doesn't work either.

Of course the incomplete gamma function was implemented in ARB a long time ago, so there is really no good reason for this to happen.

David Roe

unread,
Nov 9, 2021, 2:53:37 PM11/9/21
to sage-devel
For me, RBF(stieltjes(1)) succeeds on sage-9.4 on linux and fails on sage-9.4-beta4 on OS X with the following error:
TypeError                                 Traceback (most recent call last)
<ipython-input-10-bd365cacedf1> in <module>
----> 1 RBF(stieltjes(Integer(1)))

~/sage/sage-9.4.beta0/local/lib/python3.9/site-packages/sage/structure/parent.pyx in sage.structure.parent.Parent.__call__ (build/cythonized/sage/structure/parent.c:9338)()
    896         if mor is not None:
    897             if no_extra_args:
--> 898                 return mor._call_(x)
    899             else:
    900                 return mor._call_with_args(x, args, kwds)

~/sage/sage-9.4.beta0/local/lib/python3.9/site-packages/sage/structure/coerce_maps.pyx in sage.structure.coerce_maps.NamedConvertMap._call_ (build/cythonized/sage/structure/coerce_maps.c:6042)()
    285             raise TypeError("Cannot coerce {} to {}".format(x, C))
    286         cdef Map m
--> 287         cdef Element e = method(C)
    288         if e is None:
    289             raise RuntimeError("BUG in coercion model: {} method of {} returned None".format(self.method_name, type(x)))

~/sage/sage-9.4.beta0/local/lib/python3.9/site-packages/sage/symbolic/expression.pyx in sage.symbolic.expression.Expression._arb_ (build/cythonized/sage/symbolic/expression.cpp:11819)()
   1622         # Typically more informative and consistent than the exceptions that
   1623         # would propagate
-> 1624         raise TypeError("unable to convert {!r} to a {!s}".format(
   1625                 self, R.element_class.__name__))
   1626

TypeError: unable to convert stieltjes(1) to a RealBall

I'm not sure what's going on, but I wonder if it's OS dependent.
David

harald....@gmail.com

unread,
Nov 9, 2021, 3:13:42 PM11/9/21
to sage-devel
Ah, I meant RBF(erfi(1/sqrt(2)).

I hadn't noticed I was running cocalc on Sagemath 9.2 rather than Sagemath 9.4. Switching to Sagemath 9.4 fixes the issue with RBF(stieltjes(1)).

Now, however, I get a different error for RBF(erfi(1/sqrt(2)). See below.
I get the same errors as before for RBF(gamma(3/2,1)) and RIF(gamma(3/2,1)).

Harald
PS. Here is the output for RBF(erfi(1/sqrt(2))):

RecursionError Traceback (most recent call last) <ipython-input-2-dee2477a9f8d> in <module> ----> 1 RBF(erfi(Integer(1)/sqrt(Integer(2)))) /ext/sage/9.4/local/lib/python3.9/site-packages/sage/structure/parent.pyx in sage.structure.parent.Parent.__call__ (build/cythonized/sage/structure/parent.c:9338)() 896 if mor is not None: 897 if no_extra_args: --> 898 return mor._call_(x) 899 else: 900 return mor._call_with_args(x, args, kwds) /ext/sage/9.4/local/lib/python3.9/site-packages/sage/structure/coerce_maps.pyx in sage.structure.coerce_maps.NamedConvertMap._call_ (build/cythonized/sage/structure/coerce_maps.c:6042)() 285 raise TypeError("Cannot coerce {} to {}".format(x, C)) 286 cdef Map m --> 287 cdef Element e = method(C) 288 if e is None: 289 raise RuntimeError("BUG in coercion model: {} method of {} returned None".format(self.method_name, type(x))) /ext/sage/9.4/local/lib/python3.9/site-packages/sage/symbolic/expression.pyx in sage.symbolic.expression.Expression._arb_ (build/cythonized/sage/symbolic/expression.cpp:11830)() 1647 pass 1648 else: -> 1649 return R(res) 1650 # Typically more informative and consistent than the exceptions that 1651 # would propagate /ext/sage/9.4/local/lib/python3.9/site-packages/sage/structure/parent.pyx in sage.structure.parent.Parent.__call__ (build/cythonized/sage/structure/parent.c:9338)() 896 if mor is not None: 897 if no_extra_args: --> 898 return mor._call_(x) 899 else: 900 return mor._call_with_args(x, args, kwds) /ext/sage/9.4/local/lib/python3.9/site-packages/sage/structure/coerce_maps.pyx in sage.structure.coerce_maps.NamedConvertMap._call_ (build/cythonized/sage/structure/coerce_maps.c:6042)() 285 raise TypeError("Cannot coerce {} to {}".format(x, C)) 286 cdef Map m --> 287 cdef Element e = method(C) 288 if e is None: 289 raise RuntimeError("BUG in coercion model: {} method of {} returned None".format(self.method_name, type(x))) /ext/sage/9.4/local/lib/python3.9/site-packages/sage/symbolic/expression.pyx in sage.symbolic.expression.Expression._arb_ (build/cythonized/sage/symbolic/expression.cpp:11830)() 1647 pass 1648 else: -> 1649 return R(res) 1650 # Typically more informative and consistent than the exceptions that 1651 # would propagate /ext/sage/9.4/local/lib/python3.9/site-packages/sage/structure/parent.pyx in sage.structure.parent.Parent.__call__ (build/cythonized/sage/structure/parent.c:9338)() 896 if mor is not None: 897 if no_extra_args: --> 898 return mor._call_(x) 899 else: 900 return mor._call_with_args(x, args, kwds) /ext/sage/9.4/local/lib/python3.9/site-packages/sage/structure/coerce_maps.pyx in sage.structure.coerce_maps.NamedConvertMap._call_ (build/cythonized/sage/structure/coerce_maps.c:6042)() 285 raise TypeError("Cannot coerce {} to {}".format(x, C)) 286 cdef Map m --> 287 cdef Element e = method(C) 288 if e is None: 289 raise RuntimeError("BUG in coercion model: {} method of {} returned None".format(self.method_name, type(x))) /ext/sage/9.4/local/lib/python3.9/site-packages/sage/symbolic/expression.pyx in sage.symbolic.expression.Expression._arb_ (build/cythonized/sage/symbolic/expression.cpp:11830)() 1647 pass 1648 else: -> 1649 return R(res) 1650 # Typically more informative and consistent than the exceptions that 1651 # would propagate /ext/sage/9.4/local/lib/python3.9/site-packages/sage/structure/parent.pyx in sage.structure.parent.Parent.__call__ (build/cythonized/sage/structure/parent.c:9338)() 896 if mor is not None: 897 if no_extra_args: --> 898 return mor._call_(x) 899 else: 900 return mor._call_with_args(x, args, kwds) /ext/sage/9.4/local/lib/python3.9/site-packages/sage/structure/coerce_maps.pyx in sage.structure.coerce_maps.NamedConvertMap._call_ (build/cythonized/sage/structure/coerce_maps.c:6042)() 285 raise TypeError("Cannot coerce {} to {}".format(x, C)) 286 cdef Map m --> 287 cdef Element e = method(C) 288 if e is None: 289 raise RuntimeError("BUG in coercion model: {} method of {} returned None".format(self.method_name, type(x))) /ext/sage/9.4/local/lib/python3.9/site-packages/sage/symbolic/expression.pyx in sage.symbolic.expression.Expression._arb_ (build/cythonized/sage/symbolic/expression.cpp:11830)() 1647 pass 1648 else: -> 1649 return R(res) 1650 # Typically more informative and consistent than the exceptions that 1651 # would propagate /ext/sage/9.4/local/lib/python3.9/site-packages/sage/structure/parent.pyx in sage.structure.parent.Parent.__call__ (build/cythonized/sage/structure/parent.c:9338)() 896 if mor is not None: 897 if no_extra_args: --> 898 return mor._call_(x) 899 else: 900 return mor._call_with_args(x, args, kwds) /ext/sage/9.4/local/lib/python3.9/site-packages/sage/structure/coerce_maps.pyx in sage.structure.coerce_maps.NamedConvertMap._call_ (build/cythonized/sage/structure/coerce_maps.c:6042)() 285 raise TypeError("Cannot coerce {} to {}".format(x, C)) 286 cdef Map m --> 287 cdef Element e = method(C) 288 if e is None: 289 raise RuntimeError("BUG in coercion model: {} method of {} returned None".format(self.method_name, type(x))) ... last 14 frames repeated, from the frame below ... /ext/sage/9.4/local/lib/python3.9/site-packages/sage/symbolic/expression.pyx in sage.symbolic.expression.Expression._arb_ (build/cythonized/sage/symbolic/expression.cpp:11830)() 1647 pass 1648 else: -> 1649 return R(res) 1650 # Typically more informative and consistent than the exceptions that 1651 # would propagate RecursionError: maximum recursion depth exceeded while calling a Python object

Dima Pasechnik

unread,
Nov 9, 2021, 3:31:15 PM11/9/21
to sage-devel
On Tue, Nov 9, 2021 at 8:13 PM harald....@gmail.com
<harald....@gmail.com> wrote:
>
> Ah, I meant RBF(erfi(1/sqrt(2)).
>
> I hadn't noticed I was running cocalc on Sagemath 9.2 rather than Sagemath 9.4. Switching to Sagemath 9.4 fixes the issue with RBF(stieltjes(1)).
>
> Now, however, I get a different error for RBF(erfi(1/sqrt(2)). See below.

yes, this happens on Sage 9.5.beta5 as well.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/b4999cc4-89b2-4656-b43b-2319c4163a34n%40googlegroups.com.

Dima Pasechnik

unread,
Nov 10, 2021, 4:56:16 AM11/10/21
to sage-devel
On Tue, Nov 9, 2021 at 8:13 PM harald....@gmail.com
<harald....@gmail.com> wrote:
>
> Ah, I meant RBF(erfi(1/sqrt(2)).
>
> I hadn't noticed I was running cocalc on Sagemath 9.2 rather than Sagemath 9.4. Switching to Sagemath 9.4 fixes the issue with RBF(stieltjes(1)).
>
> Now, however, I get a different error for RBF(erfi(1/sqrt(2)). See below.
> I get the same errors as before for RBF(gamma(3/2,1)) and RIF(gamma(3/2,1)).
one needs to wrap
arb_hypgeom_gamma_upper(), see
https://arblib.org/arb_hypgeom.html?highlight=incomplete#incomplete-gamma-and-beta-functions
to get RBF(gamma(3/2,1)) to work

I've opened https://trac.sagemath.org/ticket/32851 to deal with this.
Probably RBF(erfi()) should be treated there too.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/b4999cc4-89b2-4656-b43b-2319c4163a34n%40googlegroups.com.

Dima Pasechnik

unread,
Nov 11, 2021, 4:28:51 AM11/11/21
to sage-devel


On Wed, 10 Nov 2021, 09:56 Dima Pasechnik, <dim...@gmail.com> wrote:
On Tue, Nov 9, 2021 at 8:13 PM harald....@gmail.com
<harald....@gmail.com> wrote:
>
> Ah, I meant RBF(erfi(1/sqrt(2)).
>
> I hadn't noticed I was running cocalc on Sagemath 9.2 rather than Sagemath 9.4. Switching to Sagemath 9.4 fixes the issue with RBF(stieltjes(1)).
>
> Now, however, I get a different error for RBF(erfi(1/sqrt(2)). See below.
> I get the same errors as before for RBF(gamma(3/2,1)) and RIF(gamma(3/2,1)).
one needs to wrap
arb_hypgeom_gamma_upper(), see
https://arblib.org/arb_hypgeom.html?highlight=incomplete#incomplete-gamma-and-beta-functions
to get RBF(gamma(3/2,1)) to work

I've opened https://trac.sagemath.org/ticket/32851 to deal with this.
Probably RBF(erfi()) should be treated there too.

needs review now (after an initial confusion on my side)
Reply all
Reply to author
Forward
0 new messages