我想用Python求任意阶Chebysev多项式的根。我看过勒让德多项式的similar threads。但是,我已经使用定义为here的方法构造了多项式
import numpy as np
import sympy as sp
f0 = lambda x: chebyt(0,x)
f1 = lambda x: chebyt(1,x)
f2 = lambda x: chebyt(2,x)
f3 = lambda x: chebyt(3,x)
f4 = lambda x: chebyt(4,x)
plot([f0,f1,f2,f3,f4],[-1,1])
我尝试使用np.roots(f4)
,但收到以下错误:TypeError: float() argument must be a string or a number, not 'function'
。另外,it seems that即使我可以,它也不适用于高阶多项式。你知道吗
您可以通过使用标题为“基本求值”here下的方法来查找切比雪夫多项式的系数,然后使用反向列表上的^{} 来生成多项式的根。你知道吗
使用
np.roots(f4)
无效,因为roots
函数只接受多项式系数列表,而不是lambda函数。你知道吗代码:
输出:
希望有帮助。你知道吗
相关问题 更多 >
编程相关推荐