简体   繁体   中英

Legendre Polynomials Python

I am trying to calculate the 720th Legendre polynomial with scipy:

>>>from scipy.special import legendre 
>>>print(legendre(720))

it prints the powers correctly but returns NAN for the coefficients how can I fix this?

It's probably a float overflow error . If you use the monic keyword of the legendre function you get non- nan coefficients:

>>> from scipy.special import legendre  
>>> print(legendre(720, monic=True))

720 sounds like a high number, maybe it's more stable to use the eval_legendre function.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM