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

First try at implementing evaluation of legendrePolynomial #136

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ludoro
Copy link

@ludoro ludoro commented Dec 17, 2018

Hello everyone!

As I wrote in issue #124, I tried to implement an evaluation of Legendre Polynomials.
As there are derivatives, I used a closed form, as found here:
https://en.wikipedia.org/wiki/Legendre_polynomials

I am sure I should write some tests for this function, as well as some kind of documentation. However I wanted to put this out here so people can comment and give their opinions on things I should improve.

Let me know what you think!

Ludovico

@simonbyrne
Copy link
Member

This doesn't seem like it would be very efficient or numerically robust approach. I would suggest looking in the literature on how these are used and evaluated.

@ludoro
Copy link
Author

ludoro commented Dec 27, 2018

Thank you for your opinion. I tried again with a different approach using recursion. I took ispiration from here: http://people.sc.fsu.edu/~jburkardt/py_src/legendre_polynomial/legendre_polynomial.html
I hope it is better than before. Let me know what you think.

Happy holidays!

Ludovico

@MikaelSlevinsky
Copy link
Contributor

If you want pointwise evaluation of associated Legendre polynomials, you will definitely want to use Clenshaw-Smith recurrence. See here: https://github.com/MikaelSlevinsky/FastTransforms.jl/blob/master/src/SphericalHarmonics/sphfunctions.jl

@PaulXiCao
Copy link
Contributor

What about using tabulated coefficients? The coefficients are defined by that series
https://oeis.org/A008316
Should be a fast start for small orders ...

@MikaelSlevinsky
Copy link
Contributor

Definitely not. The coefficients of Legendre polynomials in the monomial basis grow geometrically, so any numerics based on this approach would be ill-conditioned.

The three-term recurrence relation is preferred. See also ApproxFun.jl for numerical computing with orthogonal polynomials.

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.

4 participants