# std::sph_legendre, std::sph_legendref, std::sph_legendrel

 Defined in header  (1) float       sph_legendre ( unsigned l, unsigned m, float theta ); double      sph_legendre ( unsigned l, unsigned m, double theta ); long double sph_legendre ( unsigned l, unsigned m, long double theta ); (since C++17) (until C++23) /* floating-point-type */ sph_legendre( unsigned l, unsigned m,                                         /* floating-point-type */ theta ); (since C++23) float       sph_legendref( unsigned l, unsigned m, float theta ); (2) (since C++17) long double sph_legendrel( unsigned l, unsigned m, long double theta ); (3) (since C++17) Additional overloads Defined in header  template< class Integer > double      sph_legendre ( unsigned l, unsigned m, Integer theta ); (A) (since C++17)
1-3) Computes the spherical associated Legendre function of degree l, order m, and polar angle theta. The library provides overloads of std::sph_legendre for all cv-unqualified floating-point types as the type of the parameter theta.(since C++23)
A) Additional overloads are provided for all integer types, which are treated as double.

## Contents

### Parameters

 l - degree m - order theta - polar angle, measured in radians

### Return value

If no errors occur, returns the value of the spherical associated Legendre function (that is, spherical harmonic with ϕ = 0) of l, m, and theta, where the spherical harmonic function is defined as Ym
l
(theta,ϕ) = (-1)m
[
 (2l+1)(l-m)! 4π(l+m)!
]1/2
Pm
l
(cos(theta))eimϕ
where Pm
l
(x)
is std::assoc_legendre(l, m, x)) and |m|≤l.

Note that the Condon-Shortley phase term (-1)m
is included in this definition because it is omitted from the definition of Pm
l
in std::assoc_legendre.

### Error handling

Errors may be reported as specified in math_errhandling.

• If the argument is NaN, NaN is returned and domain error is not reported.
• If l≥128, the behavior is implementation-defined.