Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: special: change zeta signature to zeta(x, q=1) #6094

Merged
merged 3 commits into from
Apr 25, 2016
Merged

Conversation

pv
Copy link
Member

@pv pv commented Apr 23, 2016

Make the second argument of zeta(x,q) default to q=1. This makes the one-argument zeta(x) be the Riemann zeta function if the second argument is not given.

Previously, you had to write zeta(x,1) which is somewhat annoying since the Riemann zeta function is more often needed than the Hurwitz one.

@codecov-io
Copy link

@@            master   #6094   diff @@
======================================
  Files          238     238       
  Stmts        43865   43869     +4
  Branches      8218    8219     +1
  Methods          0       0       
======================================
+ Hit          34296   34298     +2
- Partial       2602    2603     +1
- Missed        6967    6968     +1

Review entire Coverage Diff as of 4881a38

Powered by Codecov. Updated on successful CI builds.

@person142
Copy link
Member

I've wondered whether it was worth introducing a new function called maybe rzeta for the Riemann zeta function, deprecating zeta and moving its functionality to a function called maybe hzeta. The reasoning is:

  • It's better to have a custom implementation of the Riemann zeta function as it will have better accuracy than a general algorithm for the Hurwitz zeta function. (The reflection formula is much nicer and extra care can be taken around the critical strip.)
  • You could just link zeta(x, 1) to the custom implementation, but I think it's generally nice for the regions on which functions work to be (roughly) continuous in the arguments.

Of course all this is moot without implementations of Riemann/Hurwitz zeta for complex arguments, which I'm still working on...

@pv
Copy link
Member Author

pv commented Apr 23, 2016

The continuous alternative would be to have something like zeta(x, q=None) to indicate the non-Hurwitz implementation. I'd like to have the name "zeta" reserved for the Riemann zeta function, because it's the most common one.

@pv
Copy link
Member Author

pv commented Apr 23, 2016

Updated --- maybe this is a better way to do the riemann/hurwitz switch

@person142
Copy link
Member

This seems like a nice solution to me. Perhaps worth adding a note in the documentation that Riemann zeta is Hurwitz zeta with q = 1?

Also, strictly speaking the domain in the documentation is incorrect; things like zeta(n, -x) (n > 1 an integer, x > 0 not an integer) work... however this domain is some kind of madness we might want to pretend doesn't exist.

pv added 3 commits April 24, 2016 15:54
This makes zeta(x) be the Riemann zeta function if the second argument
is not given, and the Hurwitz zeta if two arguments are given. The
change is backward-compatible.
@ev-br
Copy link
Member

ev-br commented Apr 25, 2016

Maybe even mention this in the release notes. Regardless, +1 and LGTM.

@pv pv merged commit f6ef3fd into scipy:master Apr 25, 2016
@pv pv added this to the 0.18.0 milestone Apr 25, 2016
@endolith
Copy link
Member

@pv So what's the rationale for def zeta(x, q=None, out=None) instead of the more informative def zeta(x, q=1, out=None)?

@pv
Copy link
Member Author

pv commented May 14, 2017

See the discussion above.

@endolith
Copy link
Member

@pv I did, but I don't see a reason for why it should default to q=None instead of q=1

@pv
Copy link
Member Author

pv commented May 14, 2017

Because we want to leave room to use different algorithms for hurwitz and plain zeta.
For example, complex values etc

@endolith
Copy link
Member

Support complex values and using different algorithms is great, but what does that have to do with the q argument? It can switch to a different algorithm for q==1 just as easily as q==None

@endolith
Copy link
Member

Ohh, in case the algorithms produce slightly different results, you don't want a discontinuity when sweeping across q? If that's why, I think it would make sense to have 2 different functions

@person142
Copy link
Member

Ohh, in case the algorithms produce slightly different results, you don't want a discontinuity when sweeping across q

Yes, that's the reasoning. Since Riemann zeta is so well-studied there are superior algorithms. Two different functions makes sense, but backwards compatibility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants