简体   繁体   English

勒让德多项式 Python

[英]Legendre Polynomials Python

I am trying to calculate the 720th Legendre polynomial with scipy:我正在尝试用 scipy 计算第 720 个勒让德多项式:

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

it prints the powers correctly but returns NAN for the coefficients how can I fix this?它正确打印功率,但返回 NAN 作为系数我该如何解决这个问题?

It's probably a float overflow error .这可能是一个float溢出错误 If you use the monic keyword of the legendre function you get non- nan coefficients:如果您使用legendre function 的monic关键字,您将获得非nan系数:

>>> 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. 720 听起来是一个很高的数字,也许使用eval_legendre function 更稳定。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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