File Exchange

First derivative of (normalized) associated Legendre polynomials

version 1.1.0.0 (8.79 KB) by Rody Oldenhuis

Rody Oldenhuis (view profile)

First derivative of (normalized) associated Legendre polynomials

Updated 09 Jul 2018

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.

Jorg Woehl

Jorg Woehl (view profile)

Thanks for your work - is there an easy way that you would suggest to fix the edge cases (x = 1, -1)?

Rody Oldenhuis

Rody Oldenhuis (view profile)

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.

Marc Lalancette

Gard Matthew

Gard Matthew (view profile)

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?

matzl_m

matzl_m (view profile)

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?

Logan

kamal parvazi

kamal parvazi (view profile)

thank Rody Oldenhuis

siti bahari