static void Main(string[] args) { double[] X = { 3631, 7292, 11454, 15824, 21126 }; double[] Y = { 25.5000, 22.5000, 19.5000, 16.5000, 13.5000 }; double[,] A = Tysaiphan(X, Y); double[] B = Da_thuc_Newton(A, X); double[,] C = SaiPhan_ThemMoc(A, X, 50, 1000); ExportData.ExportData2D(C); ExportData.ExportData1D(B); Console.WriteLine(HornerPn.Giatridathuc(B, 7222)); }
static double[] Da_thuc_Newton(double[,] Tysaiphan, double[] X) { int n = X.Length; double[] Pn = new double[n]; int k = 0; for (int i = n - 1; i >= 0; i--) { if (i == 0) { Pn[n - 1] += Tysaiphan[0, 0]; } if (i == 1) { Pn[n - 1] -= Tysaiphan[0, 1] * X[0]; Pn[n - 2] += Tysaiphan[0, 1]; } if (i > 1) { double[] Xi = new double[i]; for (int j = 0; j < i; j++) { Xi[j] = X[j]; } double[] Horner = HornerPn.Nhandathuc(Xi); for (int j = 0; j < Horner.Length; j++) { Horner[j] *= Tysaiphan[0, i]; Pn[j + k] += Horner[j]; } k++; } } return(Pn); }