roots_legendre

mpsci.fun.roots_legendre(n)

Compute the roots of the Legendre polynomial, and quadrature weights.

Warning: not tested beyond n=21.

Examples

>>> from mpmath import mp
>>> mp.dps = 40
>>> from mpsci.fun import roots_legendre
>>> roots, weights = roots_legendre(7)
>>> roots
[mpf('-0.9491079123427585245261896840478512624007709'),
mpf('-0.7415311855993944398638647732807884070741476'),
mpf('-0.405845151377397166906606412076961463347382'),
mpf('0.0'),
mpf('0.405845151377397166906606412076961463347382'),
mpf('0.7415311855993944398638647732807884070741476'),
mpf('0.9491079123427585245261896840478512624007709')]
>>> weights
[mpf('0.1294849661688696932706114326790820183285874'),
mpf('0.2797053914892766679014677714237795824869251'),
mpf('0.3818300505051189449503697754889751338783651'),
mpf('0.4179591836734693877551020408163265306122449'),
mpf('0.3818300505051189449503697754889751338783651'),
mpf('0.2797053914892766679014677714237795824869251'),
mpf('0.1294849661688696932706114326790820183285874')]