Lagrange插值, 三次样条插值和最小二乘拟合
看 paper 看烦了来贴点代码玩. Lagrange插值就是一个多项式乘. void genLagrangePoly(int n) { double *x = new double[n + 1]; double *y = new double[n + 1]; double *a = new double[n + 1]; double *tmp = new double[n + 1]; for (int i = 0; i <= n; ++ i) { x[i] = -5. + 10. / n * i; y[i] = f(x[i]); a[i] = 0; } for (int i = 0; i <= n; ++ i) { memset(tmp, 0, sizeof(double) * (n + 1)); tmp[0] = 1....