intrpf.cpp

来自「c++的数学物理方程数值算法源程序。这是"Numerical Methods f」· C++ 代码 · 共 17 行

CPP
17
字号
double intrpf( double xi, double x[], double y[]) {// Function to interpolate between data points// using Lagrange polynomial (quadratic)// Inputs//   xi   The x value where interpolation is computed//   x    Vector of x coordinates of data points (3 values)//   y    Vector of y coordinates of data points (3 values)// Output//   yi   The interpolation polynomial evaluated at xi  //* Calculate yi = p(xi) using Lagrange polynomial  double yi = (xi-x[2])*(xi-x[3])/((x[1]-x[2])*(x[1]-x[3]))*y[1]     + (xi-x[1])*(xi-x[3])/((x[2]-x[1])*(x[2]-x[3]))*y[2]     + (xi-x[1])*(xi-x[2])/((x[3]-x[1])*(x[3]-x[2]))*y[3];  return (yi);};

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?