https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83140
Bug ID: 83140 Summary: assoc_legendre returns negated value when m is odd Product: gcc Version: 7.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: kwsm.gcc at gmail dot com Target Milestone: --- In the standard, Legendre polynomials and associated Legendre functions are defined as P_l = (1 / 2^l l!) d^l/dx^l (x^2 - 1)^l, and P_l^m = (1 - x^2)^(m/2) d^m/dx^m P_l, respectively. Then, for example, P_1^1 should be √(1 - x^2), but GCC returns -√(1 - x^2): the return value of std::assoc_legendre(1, 1, 0.5) is -0.866. GCC's implementation uses recurrence of associated Legendre function P_m^m = (-1)^m (2m - 1)!! (1 - x^2)^(m/2), but this corresponds to P_l^m = (-1)^m (1 - x^2)^(m/2) d^m/dx^m P_l. Namely, std::assoc_legendre returns negated value when m is odd.