@@ -1457,6 +1457,48 @@ cdef object py_cos(object x) except +:
1457
1457
except (TypeError , ValueError ):
1458
1458
return CC(x).cos()
1459
1459
1460
+ cdef object py_stieltjes(object x) except + :
1461
+ """
1462
+ Return the Stieltjes constant of the given index.
1463
+
1464
+ The value is expected to be a non-negative integer.
1465
+
1466
+ TESTS::
1467
+
1468
+ sage: from sage.symbolic.pynac import py_stieltjes_for_doctests as py_stieltjes
1469
+ sage: py_stieltjes(0)
1470
+ 0.577215664901533
1471
+ sage: py_stieltjes(1.0)
1472
+ -0.0728158454836767
1473
+ sage: py_stieltjes(RealField(100)(5))
1474
+ 0.00079332381730106270175333487744
1475
+ sage: py_stieltjes(-1)
1476
+ Traceback (most recent call last):
1477
+ ...
1478
+ ValueError: Stieltjes constant of negative index
1479
+ """
1480
+ n = ZZ(x)
1481
+ if n < 0 :
1482
+ raise ValueError (" Stieltjes constant of negative index" )
1483
+ import mpmath
1484
+ if isinstance (x, Element) and hasattr ((< Element> x)._parent, ' prec' ):
1485
+ prec = (< Element> x)._parent.prec()
1486
+ else :
1487
+ prec = 53
1488
+ return mpmath_utils.call(mpmath.stieltjes, n, prec = prec)
1489
+
1490
+ def py_stieltjes_for_doctests (x ):
1491
+ """
1492
+ This function is for testing py_stieltjes().
1493
+
1494
+ EXAMPLES::
1495
+
1496
+ sage: from sage.symbolic.pynac import py_stieltjes_for_doctests
1497
+ sage: py_stieltjes_for_doctests(0.0)
1498
+ 0.577215664901533
1499
+ """
1500
+ return py_stieltjes(x)
1501
+
1460
1502
cdef object py_zeta(object x) except + :
1461
1503
"""
1462
1504
Return the value of the zeta function at the given value.
@@ -2264,6 +2306,7 @@ def init_function_table():
2264
2306
py_funcs.py_bernoulli = & py_bernoulli
2265
2307
py_funcs.py_sin = & py_sin
2266
2308
py_funcs.py_cos = & py_cos
2309
+ py_funcs.py_stieltjes = & py_stieltjes
2267
2310
py_funcs.py_zeta = & py_zeta
2268
2311
py_funcs.py_exp = & py_exp
2269
2312
py_funcs.py_log = & py_log
0 commit comments