sagemath / sage

Main repository of SageMath. Now open for Issues and Pull Requests.
https://www.sagemath.org
Other
1.21k stars 421 forks source link

special values of transcendental functions #18141

Open rwst opened 9 years ago

rwst commented 9 years ago

The functions in transcentental.py could return special values:

This ticket may also discuss: are there closed forms without zeta for

CC: @behackl

Component: symbolics

Issue created by migration from https://trac.sagemath.org/ticket/18141

behackl commented 8 years ago
comment:2

Hi!

I'm rather motivated to implement some of the special values mentioned above; and I guess the "correct" place would be src/functions/transcendental.py, wouldn't it?

However, I'm not quite sure of how to tackle the implementation of the Stieltjes constants. I think that it would be elegant if the constants were also available in pynac (such that zeta(s).series(s==1) could yield the appropriate series expansion directly).

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.

What do you think about moving the part with the Stieltjes constants to a separate ticket?

rwst commented 8 years ago
comment:3

Replying to @behackl:

I'm rather motivated to implement some of the special values mentioned above; and I guess the "correct" place would be src/functions/transcendental.py, wouldn't it?

Yes, where the functions are.

However, I'm not quite sure of how to tackle the implementation of the Stieltjes constants. I think that it would be elegant if the constants were also available in pynac (such that zeta(s).series(s==1) could yield the appropriate series expansion directly).

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 #17678 with the Bessel functions. With zetaderiv this doesn't look like resulting in something usable:

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)

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.

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.

In Sage there is symbolic/constants* with three source files. Earlier I had started written about the Pynac side in https://github.com/pynac/pynac/wiki/%7C-constants

To implement a family of symbolic constants (i.e. indexed) would be a first.

However, at first glance I see no reason why Stieltjes could not be another function taking only arguments from NN.

What do you think about moving the part with the Stieltjes constants to a separate ticket?

It looks like this is a sensible approach.

rwst commented 8 years ago
comment:4

See #19834.

Please open a ticket showing which result you would expect from a zeta expansion using the Stieltjes "function" from #19834 so that I know what I should do in Pynac for the series expansion.

behackl commented 8 years ago
comment:5

Replying to @rwst:

However, at first glance I see no reason why Stieltjes could not be another function taking only arguments from NN.

What do you think about moving the part with the Stieltjes constants to a separate ticket?

It looks like this is a sensible approach.

This is a good idea; I'll open a ticket for the zeta-expansion. Should I also open an issue for pynac?

Also, the numerical evaluation of the Stieltjes constants would be implemented in Sage (by some sort of _evalf_ or _eval_ I guess)---or would you need to add some sort of method in pynac as well?

rwst commented 8 years ago
comment:6

Replying to @behackl:

This is a good idea; I'll open a ticket for the zeta-expansion. Should I also open an issue for pynac?

Done.

Also, the numerical evaluation of the Stieltjes constants would be implemented in Sage (by some sort of _evalf_ or _eval_ I guess)---or would you need to add some sort of method in pynac as well?

No. This could be a Cython function using arb.

rwst commented 8 years ago
comment:7

No, Python suffices: http://docs.sympy.org/dev/modules/mpmath/functions/zeta.html#stieltjes

rwst commented 8 years ago
comment:8

This means we can have generalized Stieltjes constants and Hurwitz zeta expansion with only minor additional work, right?

behackl commented 8 years ago
comment:9

Replying to @rwst:

This means we can have generalized Stieltjes constants and Hurwitz zeta expansion with only minor additional work, right?

For the Zeta-function: yes, that is my impression. Regarding the expansion of the Hurwitz-Zeta, I'm not quite sure: Function_HurwitzZeta is not a Ginac-function, but a BuiltinFunction---and I don't know whether the series expansion of this function can be influenced. Currently:

sage: hurwitz_zeta(s, x).series(s==1)
Traceback (most recent call last):
...
NotImplementedError: derivative with respect to first argument

But yes, of course: if it is possible to set the expansion in some place, then we get the respective expansion of hurwitz_zeta for free, given that we have the generalized Stiltjes-constants.

behackl commented 8 years ago
comment:10

It seems that adapting the expansion from .series() is possible by implementing a _series_-method (this is somehow mentioned here in symbolic/function.pyx.

rwst commented 8 years ago
comment:11

Replying to @behackl:

It seems that adapting the expansion from .series() is possible by implementing a _series_-method (this is somehow mentioned here in symbolic/function.pyx.

Yes, setting any of these functions in Python will override Pynac's implementation (and slow down its calls). In case of _series_ it's dispatched to in function::series, see https://github.com/pynac/pynac/blob/master/ginac/function.cpp#L943.

From experimentation I can say that if you define a Function_zeta::_series_() method it will be called with 6 arguments, e.g. zeta(y).series(x==1,5) will call the Python function Function_zeta::_series_(self, (y,), {'var': x, 'options': 0, 'at': 1, 'order': 5}) so you need to define it as _series_(self, varlist, var=..., options=... , at=..., order=...) and return an expression.

behackl commented 8 years ago
comment:12

Regarding this ticket: as it turns out, there are closed-form formulae for zetaderiv(k, 0) in general, cf. this paper, Theorem 3 and (14).

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).