-
-
Notifications
You must be signed in to change notification settings - Fork 487
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
symbolic Legendre / associated Legendre functions / polynomials #16813
Comments
comment:1
Hi! Good to see that someone else is working on making the orthogonal polynomials symbolic, since my research interests shifted heavily in the past years. A good read on Legendre polynomials is also the bible for ortho polys: Abramowitz and Stegun http://people.math.sfu.ca/~cbm/aands/page_331.htm There you will find also much information on special values and other properties. |
comment:2
Fine! See also http://trac.sagemath.org/wiki/symbolics/functions |
comment:3
OK I have a question. What is the equivalent recursive algorithm to https://github.com/sagemath/sage-prod/blob/master/src/sage/functions/orthogonal_polys.py#L812-834 The link is valid as long #16812 is not merged. |
comment:4
Replying to @rwst:
Hi! You won't have luck to find an equivalent recursion algorithm for Legendre Polynomials, since the recursion algorithm for Chebyshev Polynomials uses the fact that cheby polynomials are cosines in disguise, and thus one is able to build Cheby polyis in O(log N) time. For Legendre polynomials you have to use the classic recursion formula given in https://en.wikipedia.org/wiki/Legendre_polynomials#Recursive_definition |
comment:5
Maybe this could help you: I already implemented all Orthopolys one time: https://github.com/sagemath/sage-prod/files/10650394/trac_9706_ortho_polys.patch.gz they only would need cleanup/restructuring. Maybe you can reuse some of the implemented methods (like recursions and derivatives) |
comment:6
Some timings for P(n,z):
while |
comment:7
With P(n,x) symbolics and algebra, Pari is much better than Maxima
|
Commit: |
comment:9
This is a proof of concept patch, and one can already use New commits:
|
comment:10
Replying to @sagetrac-maldun:
This appears outdated, it is replaced by http://dlmf.nist.gov/14 |
comment:11
Replying to @rwst:
You can't call a source outdated, which still covers information that the newer source doesn't. I checked your link, and some things from A&S are missign e.g. explicit representation of Legendre Polynomials with their polynomial coefficients. |
comment:12
Replying to @sagetrac-maldun:
I am not sure about the derivatives. For Update: what's your reference there? |
comment:13
Replying to @rwst:
It seems you are right. from Gradshteyn-Ryzhik p.1004 formula 8.731-1 we have the relation
The same relation holds for gen_legendre_Q I suppose that's an copy/paste/rewrite mistake from my side. |
comment:14
Also, your recursive functions for
The latter result from mpmath is supported by Wolfram. As to
Again, Wolfram supports the latter value from mpmath (symbolic as |
comment:15
OK, I resolved it by using Update: it however makes symbolic work tedious and differentiation impossible, at the moment. See also https://groups.google.com/forum/?hl=en#!topic/sage-support/bEMPMEYeZKU on derivatives of conjugates in Sage. |
comment:16
Thanks for resolving this issue! I suppose I wasn't careful enough with complex arguments. But in my defense: I hadn't time to test this codes well enough when I wrote them ... but hopefully they give some useful informations. concerning complex conjugation: I hope my answer on the mailing list give some clues: https://groups.google.com/forum/?hl=en#!topic/sage-support/bEMPMEYeZKU Replying to @rwst:
|
comment:17
Replying to @sagetrac-maldun:
Unfortunately, while it would be easy to resolve this numerically, the instances of |
comment:18
Hi! We have several possible ways out of this:
with
(Gradshteyn-Ryzhik p 1019f) Maybe we could find an recursion for W(n,z) Hope this could be of some use Edit there should be a recursion since W(n,z) is the convolution of aseries of holonomic functions, and if I remeber correctly there is an theorem saying that convolutions of holonomic functions are also holonomic, thus should have a recursion. Edit: The above mentioned relation can also be found here: http://people.math.sfu.ca/~cbm/aands/page_334.htm |
comment:19
|
comment:20
Nice! I didn't know that sage already supports Ore Algebras. |
comment:21
I always need some time to figure out the final form (that offset of |
comment:22
However, this will yield the same result unless the |
comment:23
I think there must be another different formula, because Wolfram has this for
which yields the correct value without use of The first few
which makes clear that instead of |
comment:24
Oh yeah it's again the non uniqueness of the representation of the complex logarithm
confusing as hell ... I think Wolfram uses the log(1+x)-log(1-x) representation simply by the fact that it is independent of the branch in the following sense:
I.e. if we have the same branch on the logarithm the module of 2kπi cancels out. That means the formula isn't exactly wrong, it uses simply a different branch of the logarithm. But the representation of log as difference saves us indeed a lot of trouble, and as showed above is independent of the branch we use. Nevertheless I think we should stick to the recursion with W(n,x), because from a computational view it is a lot better since:
|
comment:90
Review needed for the last two commits. |
Changed reviewer from Marc Mezzarobba to Marc Mezzarobba, Travis Scrimshaw |
comment:92
One failing doctest, see patchbot. |
comment:93
Does not fail here. Note the patchbot is running 7.5beta1 not 2, and there were |
comment:94
I ended up accidentally trying this on my beta1 as well. All is good. |
comment:95
The dependency is invalid/wontfix. What are you depending on? |
comment:96
Replying to @vbraun:
Actually I don't recall and couldn't find out how |
Changed dependencies from #19464 to none |
Changed branch from u/rws/16813-1 to |
Defect because there is no Sage binding for a result returned by Maxima:
Existing numeric functions are
legendre_P
,legendre_Q
,gen_legendre_P
, andgen_legendre_Q
which correspond to P(n,x) / Q(n,x) and associated Legendre P(n,m,x) / Q(n,m,x).They should be made symbolic. FLINT has fast code for P(n,x).
See also http://ask.sagemath.org/question/27230/problem-with-hypergeometric/
Component: symbolics
Keywords: orthogonal
Author: Ralf Stephan, Stefan Reiterer
Branch/Commit:
7238198
Reviewer: Marc Mezzarobba, Travis Scrimshaw
Issue created by migration from https://trac.sagemath.org/ticket/16813
The text was updated successfully, but these errors were encountered: