choclo.legendre.associated_function

choclo.legendre.associated_function#

choclo.legendre.associated_function(x, max_degree, p)[source]#

Associated Legendre functions up to a maximum degree.

The associated Legendre functions \(P_n^m(x)\) are solutions to Legendre’s equation, with \(n\) (the degree) and \(m\) (the order) being integers and \(0 \le m \le n\). We calculate their values using the recursive relations defined in [Alken2022]. Being recursive, it’s not possible to calculate only the values for a specific degree and order. All values up to the desired degree are always calculated.

The output is filled in place in the parameter p so that the users can control the memory allocation. In spherical harmonics, this function if often called in a loop and so reusing memory can save computation time.

Warning

This function does not implement normalization and should not be used beyond degree 13 because they will overflow 64-bit float range. Use choclo.legendre.associated_function_schmidt and choclo.legendre.associated_function_fully instead.

Parameters:
xfloat

The argument of \(P_n^m(x)\). Must be in the range [-1, 1].

max_degreeint

The maximum degree \(n\) for the calculation.

pnumpy.array

A 2D array with shape (max_degree + 1, max_degree + 1) that will be filled in place with the output values. The rows of the array correspond to the degree \(n\) and the columns to the order \(m\). Thus, p[n, m] corresponds to \(P_n^m(x)\). Elements where m > n are not filled out and will retain their original values.

Notes

The functions \(P_n^m(x)\) are solutions to Legendre’s differential equation

\[\frac{d}{d x} \left[ \left(1 - x^2\right) \frac{d}{d x} P_n^m(x) \right] + \left[ n (n + 1) - \frac{m^2}{1 - x^2} \right] P_n^m(x) = 0,\]

which has non-trivial and non-singular solutions in the [-1, 1] range when \(n\) and \(m\) are integers and \(0 \le m \le n\).

Note

Does not implement the Condon-Shortly phase element.

References

[Alken2022]