#include <vector> // w_{n+1}(x) // x:变量x; n:插值多项式次数; xn:x_{n}数组(长度至少为n + 1) double w(double x, int n, std::vector<double> xn) { if (n > (int) xn.size() - 1) { n = (int) xn.size() - 1; } double result = 1.0; while (n >= 0) { result *= (x - xn[n--]); } return result; } // w'_{n+1}(x_{k}) // k:下标k; n:插值多项式次数; xn:x_{n}数组(长度至少为n + 1) double w1(int k, int n, std::vector<double> xn) { if (n > (int) xn.size() - 1) { n = (int) xn.size() - 1; } double result = 1.0; while (n > k) { result *= (xn[k] - xn[n--]); } while (n > 0) { result *= (xn[k] - xn[--n]); } return result; } // Ln(x) // x:变量x; n:插值多项式次数; // xn:x_{n}数组(长度至少为n + 1); yn:y_{n}数组(长度至少为n + 1) double lagrange(double x, int n, std::vector<double> &am