Updated 25 Sep 2019
Computing accurate derivatives of the associated Legendre polynomials can be tricky. Even in advanced texts, they are usually written as recurrence relations and/or with (normalization) factors involving factorials.
A naive software implementation will therefore quickly run into the limits of IEEE754 double-precision, resulting in NaN/inf or significant loss of precision, already at very low degree N.
LEGENDRE_DERIVATIVE is a fully vectorized, numerically stable and robustly validated implementation of the derivative computation. It allows fast and accurate computations of the derivatives for any degree N.
It works the same as MATLAB's own LEGENDRE, except it does not compute the polynomial values, but the values of the derivatives.
Rody Oldenhuis (2020). First derivative of (normal) associated Legendre polynomials (https://github.com/rodyo/FEX-legendre_derivative), GitHub. Retrieved .
@GardMatthew (and others): I just updated this submission—I added units tests with close to 100% coverage. These tests include the edge cases under all normalizations, and they all pass ?
Hi again Rody, hoping you can supply the updated code soon as I have yet to find a fix myself. Was hoping you uploaded to github alone but doesnt seem to have been updated either. Thanks!
Thanks for your work - is there an easy way that you would suggest to fix the edge cases (x = 1, -1)?
To all: YES! I plan to fix this! I am aware that the edge cases are inaccurate, and that the Schmitt semi-normalized values are computed inefficiently and inaccurately. I have actually already fixed these problems as part of a task in my daytime job, now it's "just" a matter of finding the time to copy those fixes over to this repository.
Hi this is great, but I have the same question as matzl_m -> whats causing the NaN's in the first columns? Do you plan on fixing this?
Thanks for the nice work. I noticed that derivatives at x = 1,-1 can't be calculated and just give NaNs for every Legendre-polynomial, even though they are finite for all |m| ~= 1. Did you plan to fix this?
thank Rody Oldenhuis
is this code same with from here? :
Added units tests