First try at implementing evaluation of legendrePolynomial
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
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.
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
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
What about using tabulated coefficients? The coefficients are defined by that series https://oeis.org/A008316 Should be a fast start for small orders ...
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.