头文件
gsl_poly.h
多项式计算
P ( x ) = c [ 0 ] + c [ 1 ] x + c [ 2 ] x 2 + ⋯ + c [ l e n − 1 ] x l e n − 1 P(x)=c[0]+c[1] x+c[2] x^{2}+\cdots+c[l e n-1] x^{l e n-1} P(x)=c[0]+c[1]x+c[2]x2+⋯+c[len−1]xlen−1
// gsl_poly.h
/* real polynomial, real x */
INLINE_DECL double gsl_poly_eval(const double c[], const int len, const double x);
/* real polynomial, complex x */
INLINE_DECL gsl_complex gsl_poly_complex_eval(const double c [], const int len, const gsl_complex z);
/* complex polynomial, complex x */
INLINE_DECL gsl_complex gsl_complex_poly_complex_eval(const gsl_complex c [], const int len, const gsl_complex z);
/* 计算多项式以及多项式的多阶导数,多阶导数的计算结果存在 res 数组中,从第 0 阶开始 */
int gsl_poly_eval_derivs(const double c[], const size_t lenc, const double x, double res[], const size_t lenres);
差商计算
差商基本介绍
-
差商如何计算?
给定 n + 1 n+1 n+1 个数据点(插值点), ( x 0 , y 0 ) , ( x 2 , y 2 ) ⋯ ( x n , y n ) (x_0, y_0),(x_2,y_2) \cdots(x_n,y_n) (x0,y0),(x2,y2)⋯(xn,yn),那么就可以计算差商了 1。 -
差商有什么用?
构建多项式比如构建牛顿多项式,其利用差商可以表示为:
N ( x ) = y 0 + ∑ j = 1 n [ y 0 , y 1 , ⋯ y j ] ( x − x 0 ) ( x − x 1 ) ⋯ ( x − x j − 1 ) N(x)=y_0+\sum_{j=1}^{n} [y_0,y_1,\cdots y_j] (x-x_0)(x-x_1)\cdots(x-x_{j-1}) N(x)=y0+