我试图在Python中提取一个平移的Chebyshev多项式的系数,但我找不到这样做的函数。
这里有一个函数:
scipy.special.eval_sh_chebyt
scipy.special.eval_sh_chebyt(n, x, out=None) = <ufunc 'eval_sh_chebyt'>
但我不能只提取系数。
移位的切比雪夫多项式为: T^{*}_n(x) = T_n (2x -1)
然后:
T_1^{*}(x) = 2x -1
T_2^{*}(x) = 8x^2 - 8x -1
我只想提取一个包含系数的矩阵,比如2和1或8,8和1。
发布于 2019-10-17 10:22:43
scipy.special.eval_sh_chebyt
在给定的点x处计算函数T*。除非你在选择参数时非常聪明,否则这不是获得系数的合适方法。
相反,您可以直接从递归公式T0 = 1,T1 = x,T{n} = 2xT{n-1} - T{n-2}计算系数。然后从_T*{n} = T{n}(2x - 1)计算移位多项式。
degree = 10
coeffs = []
# for T_0
coeffLine = [1]
coeffs.append(coeffLine)
# for T_1
coeffLine = [0, 1]
coeffs.append(coeffLine)
for i in range(2, degree + 1):
coeffLine = [0] * (1 + i)
coeffLine[0] = -coeffs[i - 2][0]
for j in range(1, i - 1):
coeffLine[j] = 2 * coeffs[i - 1][j - 1] - coeffs[i - 2][j]
coeffLine[-2] = 2 * coeffs[i - 1][-2]
coeffLine[-1] = 2 * coeffs[i - 1][-1]
coeffs.append(coeffLine)
print("T_%d" % degree, coeffs[-1])
shiftedCoeffs = [0] * (degree + 1);
for i in range(degree + 1):
binom = 1
for j in range(i + 1):
shiftedCoeffs[i - j] += coeffs[-1][i] * 2 ** (i - j) * (-1) ** j * binom
binom *= (i - j) / (j + 1)
print("T*_%d" % degree, shiftedCoeffs)
编辑:我最初将T*{n}的公式误读为_T{n}(x) * (2x - 1)。然而,它是T*{n} = T{n}(2x - 1)。因此,我们需要计算二项式系数,根据x的顺序将它们相加。
https://stackoverflow.com/questions/58425772
复制