Search code examples
pythonnumpypolynomials

How to calculate associated Legendre polynomials given m and l in Python


The general expression for associated legendre polynomial is given as :

for a given m and l

I have been looking for a python solution, where given m=0 , I can compute the expression for the polynomial of 'Pl' at the given angle theta. For better expressing my question, here's the screenshot from Wikipedia's page on Associated Legendre Polynomial enter image description here

and so I would need to calculate the values of those P's corresponding to superscript = 0 for a given theta.

I have extensively checked stackoverflow, but failed to find a proper answer, also I have found the python page with Numpy's Legendre module details but can't find the exact thing I am looking for.


Solution

  • Scipy has the associated legendre polynoms:

    https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.lpmv.html#scipy.special.lpmv