Sage: Ticket #18141: special values of transcendental functions
https://trac.sagemath.org/ticket/18141
<p>
The functions in <code>transcentental.py</code> could return special values:
</p>
<ul><li><code>zetaderiv(0,1)=-1/2*log(2*pi)</code>, <a class="ext-link" href="http://dlmf.nist.gov/25.6#E11"><span class="icon"></span>http://dlmf.nist.gov/25.6#E11</a>
</li><li><code>zetaderiv(0,2)=-1/2*log(2*pi)^2+...</code>, <a class="ext-link" href="http://dlmf.nist.gov/25.6#E12"><span class="icon"></span>http://dlmf.nist.gov/25.6#E12</a>, needs Euler constants
</li><li><code>hurwitz_zeta</code>, we already have:
<pre class="wiki">sage: hurwitz_zeta(5,1/2)
31*zeta(5)
sage: hurwitz_zeta(x,1/2)
hurwitz_zeta(x, 1/2)
</pre>The latter should be <code>(2^x-1)*zeta(x)</code>. Also <code>hurwitz_zeta(0,...)</code> is missing, <a class="ext-link" href="http://dlmf.nist.gov/25.11#v"><span class="icon"></span>http://dlmf.nist.gov/25.11#v</a>
</li></ul><p>
This ticket may also discuss: are there closed forms without <code>zeta</code> for
</p>
<ul><li><code>zeta</code> with odd positive argument: <a class="ext-link" href="http://dlmf.nist.gov/25.6#E6"><span class="icon"></span>http://dlmf.nist.gov/25.6#E6</a> ?
</li></ul><p>
</p>
en-usSagehttps://trac.sagemath.org/chrome/site/logo_sagemath_trac.png
https://trac.sagemath.org/ticket/18141
Trac 1.1.6behacklWed, 08 Apr 2015 09:54:29 GMTcc set
https://trac.sagemath.org/ticket/18141#comment:1
https://trac.sagemath.org/ticket/18141#comment:1
<ul>
<li><strong>cc</strong>
<em>behackl</em> added
</li>
</ul>
TicketbehacklTue, 05 Jan 2016 12:52:18 GMT
https://trac.sagemath.org/ticket/18141#comment:2
https://trac.sagemath.org/ticket/18141#comment:2
<p>
Hi!
</p>
<p>
I'm rather motivated to implement some of the special values mentioned above; and I guess the "correct" place would be <code>src/functions/transcendental.py</code>, wouldn't it?
</p>
<p>
However, I'm not quite sure of how to tackle the implementation of the <a class="ext-link" href="https://en.wikipedia.org/wiki/Stieltjes_constants"><span class="icon"></span>Stieltjes constants</a>. I think that it would be elegant if the constants were also available in pynac (such that <code>zeta(s).series(s==1)</code> could yield the appropriate series expansion directly).
</p>
<p>
The problem with this approach is, that I'm not sure of how to implement a familiy of constants in pynac---or even just in sage.
</p>
<p>
What do you think about moving the part with the Stieltjes constants to a separate ticket?
</p>
TicketrwsTue, 05 Jan 2016 14:19:47 GMT
https://trac.sagemath.org/ticket/18141#comment:3
https://trac.sagemath.org/ticket/18141#comment:3
<p>
Replying to <a class="ticket" href="https://trac.sagemath.org/ticket/18141#comment:2" title="Comment 2">behackl</a>:
</p>
<blockquote class="citation">
<p>
I'm rather motivated to implement some of the special values mentioned above; and I guess the "correct" place would be <code>src/functions/transcendental.py</code>, wouldn't it?
</p>
</blockquote>
<p>
Yes, where the functions are.
</p>
<blockquote class="citation">
<p>
However, I'm not quite sure of how to tackle the implementation of the <a class="ext-link" href="https://en.wikipedia.org/wiki/Stieltjes_constants"><span class="icon"></span>Stieltjes constants</a>. I think that it would be elegant if the constants were also available in pynac (such that <code>zeta(s).series(s==1)</code> could yield the appropriate series expansion directly).
</p>
</blockquote>
<p>
To recap GiNaC/Pynac by default implements series by differentiation so a naive way to get a nice expansion would be to implement special values of the derivatives like in <a class="closed ticket" href="https://trac.sagemath.org/ticket/17678" title="enhancement: special values of Bessel functions (closed: fixed)">#17678</a> with the Bessel functions. With <code>zetaderiv</code> this doesn't look like resulting in something usable:
</p>
<pre class="wiki">sage: zeta(x).series(x==1,2)
1*(x - 1)^(-1) + (euler_gamma + log(2) + log(pi) + 2*zetaderiv(1, 0)) + (1/2*euler_gamma^2 - 1/24*pi^2 + (euler_gamma + log(pi) + 2*zetaderiv(1, 0))*log(2) + 1/2*log(2)^2 + (euler_gamma + 2*zetaderiv(1, 0))*log(pi) + 1/2*log(pi)^2 + 2*euler_gamma*zetaderiv(1, 0) - zetaderiv(2, 0))*(x - 1) + Order((x - 1)^2)
</pre><p>
I haven't fiddled with Pynac series yet so I'm naive on how to get a different output for this. I'm also not exactly at home with complex analysis.
</p>
<blockquote class="citation">
<p>
The problem with this approach is, that I'm not sure of how to implement a familiy of constants in pynac---or even just in sage.
</p>
</blockquote>
<p>
In Sage there is <code>symbolic/constants*</code> with three source files. Earlier I had started written about the Pynac side in <a class="ext-link" href="https://github.com/pynac/pynac/wiki/%7C-constants"><span class="icon"></span>https://github.com/pynac/pynac/wiki/%7C-constants</a>
</p>
<p>
To implement a family of symbolic constants (i.e. indexed) would be a first.
</p>
<p>
However, at first glance I see no reason why <code>Stieltjes</code> could not be another function taking only arguments from NN.
</p>
<blockquote class="citation">
<p>
What do you think about moving the part with the Stieltjes constants to a separate ticket?
</p>
</blockquote>
<p>
It looks like this is a sensible approach.
</p>
TicketrwsTue, 05 Jan 2016 14:32:02 GMT
https://trac.sagemath.org/ticket/18141#comment:4
https://trac.sagemath.org/ticket/18141#comment:4
<p>
See <a class="closed ticket" href="https://trac.sagemath.org/ticket/19834" title="enhancement: implement symbolic Stieltjes constants (closed: fixed)">#19834</a>.
</p>
<p>
Please open a ticket showing which result you would expect from a zeta expansion using the <code>Stieltjes</code> "function" from <a class="closed ticket" href="https://trac.sagemath.org/ticket/19834" title="enhancement: implement symbolic Stieltjes constants (closed: fixed)">#19834</a> so that I know what I should do in Pynac for the series expansion.
</p>
TicketbehacklTue, 05 Jan 2016 18:45:23 GMT
https://trac.sagemath.org/ticket/18141#comment:5
https://trac.sagemath.org/ticket/18141#comment:5
<p>
Replying to <a class="ticket" href="https://trac.sagemath.org/ticket/18141#comment:3" title="Comment 3">rws</a>:
</p>
<blockquote class="citation">
<p>
However, at first glance I see no reason why <code>Stieltjes</code> could not be another function taking only arguments from NN.
</p>
<blockquote class="citation">
<p>
What do you think about moving the part with the Stieltjes constants to a separate ticket?
</p>
</blockquote>
<p>
It looks like this is a sensible approach.
</p>
</blockquote>
<p>
This is a good idea; I'll open a ticket for the zeta-expansion. Should I also open an issue for pynac?
</p>
<p>
Also, the numerical evaluation of the Stieltjes constants would be implemented in Sage (by some sort of <code>_evalf_</code> or <code>_eval_</code> I guess)---or would you need to add some sort of method in pynac as well?
</p>
TicketrwsWed, 06 Jan 2016 07:54:36 GMT
https://trac.sagemath.org/ticket/18141#comment:6
https://trac.sagemath.org/ticket/18141#comment:6
<p>
Replying to <a class="ticket" href="https://trac.sagemath.org/ticket/18141#comment:5" title="Comment 5">behackl</a>:
</p>
<blockquote class="citation">
<p>
This is a good idea; I'll open a ticket for the zeta-expansion. Should I also open an issue for pynac?
</p>
</blockquote>
<p>
Done.
</p>
<blockquote class="citation">
<p>
Also, the numerical evaluation of the Stieltjes constants would be implemented in Sage (by some sort of <code>_evalf_</code> or <code>_eval_</code> I guess)---or would you need to add some sort of method in pynac as well?
</p>
</blockquote>
<p>
No. This could be a Cython function using arb.
</p>
TicketrwsWed, 06 Jan 2016 08:02:02 GMT
https://trac.sagemath.org/ticket/18141#comment:7
https://trac.sagemath.org/ticket/18141#comment:7
<p>
No, Python suffices: <a class="ext-link" href="http://docs.sympy.org/dev/modules/mpmath/functions/zeta.html#stieltjes"><span class="icon"></span>http://docs.sympy.org/dev/modules/mpmath/functions/zeta.html#stieltjes</a>
</p>
TicketrwsWed, 06 Jan 2016 08:09:31 GMT
https://trac.sagemath.org/ticket/18141#comment:8
https://trac.sagemath.org/ticket/18141#comment:8
<p>
This means we can have generalized Stieltjes constants and Hurwitz zeta expansion with only minor additional work, right?
</p>
TicketbehacklWed, 06 Jan 2016 12:30:03 GMT
https://trac.sagemath.org/ticket/18141#comment:9
https://trac.sagemath.org/ticket/18141#comment:9
<p>
Replying to <a class="ticket" href="https://trac.sagemath.org/ticket/18141#comment:8" title="Comment 8">rws</a>:
</p>
<blockquote class="citation">
<p>
This means we can have generalized Stieltjes constants and Hurwitz zeta expansion with only minor additional work, right?
</p>
</blockquote>
<p>
For the Zeta-function: yes, that is my impression. Regarding the expansion of the Hurwitz-Zeta, I'm not quite sure: <code>Function_HurwitzZeta</code> is not a <code>Ginac</code>-function, but a <code>BuiltinFunction</code>---and I don't know whether the series expansion of this function can be influenced. Currently:
</p>
<pre class="wiki">sage: hurwitz_zeta(s, x).series(s==1)
Traceback (most recent call last):
...
NotImplementedError: derivative with respect to first argument
</pre><p>
But yes, of course: if it is possible to set the expansion in some place, then we get the respective expansion of <code>hurwitz_zeta</code> for free, given that we have the generalized Stiltjes-constants.
</p>
TicketbehacklWed, 06 Jan 2016 19:45:00 GMT
https://trac.sagemath.org/ticket/18141#comment:10
https://trac.sagemath.org/ticket/18141#comment:10
<p>
It seems that adapting the expansion from <code>.series()</code> is possible by implementing a <code>_series_</code>-method (this is somehow mentioned <a class="ext-link" href="https://github.com/sagemath/sage/blob/master/src/sage/symbolic/function.pyx#L34-L37"><span class="icon"></span>here</a> in <code>symbolic/function.pyx</code>.
</p>
TicketrwsFri, 08 Jan 2016 07:43:55 GMT
https://trac.sagemath.org/ticket/18141#comment:11
https://trac.sagemath.org/ticket/18141#comment:11
<p>
Replying to <a class="ticket" href="https://trac.sagemath.org/ticket/18141#comment:10" title="Comment 10">behackl</a>:
</p>
<blockquote class="citation">
<p>
It seems that adapting the expansion from <code>.series()</code> is possible by implementing a <code>_series_</code>-method (this is somehow mentioned <a class="ext-link" href="https://github.com/sagemath/sage/blob/master/src/sage/symbolic/function.pyx#L34-L37"><span class="icon"></span>here</a> in <code>symbolic/function.pyx</code>.
</p>
</blockquote>
<p>
Yes, setting any of these functions in Python will override Pynac's implementation (and slow down its calls). In case of <code>_series_</code> it's dispatched to in <code>function::series</code>, see <a class="ext-link" href="https://github.com/pynac/pynac/blob/master/ginac/function.cpp#L943"><span class="icon"></span>https://github.com/pynac/pynac/blob/master/ginac/function.cpp#L943</a>.
</p>
<p>
From experimentation I can say that if you define a <code>Function_zeta::_series_()</code> method it will be called with 6 arguments, e.g. <code>zeta(y).series(x==1,5)</code> will call the Python function <code>Function_zeta::_series_(self, (y,), {'var': x, 'options': 0, 'at': 1, 'order': 5})</code> so you need to define it as <code>_series_(self, varlist, var=..., options=... , at=..., order=...)</code> and return an expression.
</p>
TicketbehacklTue, 19 Jan 2016 10:30:15 GMT
https://trac.sagemath.org/ticket/18141#comment:12
https://trac.sagemath.org/ticket/18141#comment:12
<p>
Regarding this ticket: as it turns out, there are closed-form formulae for <code>zetaderiv(k, 0)</code> in general, cf. <a class="ext-link" href="http://www.ams.org/journals/mcom/1985-44-169/S0025-5718-1985-0771044-5/S0025-5718-1985-0771044-5.pdf"><span class="icon"></span>this paper, Theorem 3 and (14)</a>.
</p>
<p>
The question is, whether we want that kind of expansion to happen for all k, or just for reasonably small k (as far as I can tell, these expansions really blow up fast in terms of summands).
</p>
Ticket