【问题标题】:Difference between Chebyshev polynomial implementation in scipy and numpyscipy和numpy中切比雪夫多项式实现之间的区别
【发布时间】:2017-05-04 00:15:08
【问题描述】:

谁能告诉我numpy中Chebyshev的区别-

numpy.polynomial.Chebyshev.basis(deg) 

和切比雪夫的scipy解释-

scipy.special.chebyt(deg)

这会很有帮助。 提前致谢!

【问题讨论】:

    标签: python python-3.x numpy scipy


    【解决方案1】:

    scipy.special 多项式函数利用np.poly1dwhich is outdated and error prone - 特别是,它将x0 的索引存储在poly.coeffs[-1]

    numpy.polynomial.Chebyshev 不仅以更合理的顺序存储系数,而且保持它们的基础,从而提高精度。您可以使用cast 方法进行转换:

    >>> from numpy.polynomial import Chebyshev, Polynomial
    
    # note loss of precision
    >>> sc_che = scipy.special.chebyt(4); sc_che
    poly1d([  8.000000e+00,   0.000000e+00,  -8.000000e+00, 8.881784e-16,   1.000000e+00])
    
    # using the numpy functions - note that the result is just in terms of basis 4
    >>> np_che = Chebyshev.basis(4); np_che
    Chebyshev([ 0.,  0.,  0.,  0.,  1.], [-1.,  1.], [-1.,  1.])
    
    # converting to a standard polynomial - note that these store the
    # coefficient of x^i in .coeffs[i] - so are reversed when compared to above
    >>> Polynomial.cast(np_che)
    Polynomial([ 1.,  0., -8.,  0.,  8.], [-1.,  1.], [-1.,  1.])
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-05
      • 1970-01-01
      • 2020-07-22
      • 2012-08-13
      • 2023-03-03
      • 1970-01-01
      相关资源
      最近更新 更多