private static void test18() //****************************************************************************80 // // Purpose: // // TEST18 tests ROOTS_TO_DIF and DIF_TO_R8POLY. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 18 January 2007 // // Author: // // John Burkardt // { const int MAXROOTS = 4; double[] c = new double[MAXROOTS + 1]; double[] diftab = new double[MAXROOTS + 1]; int ntab = 0; double[] roots = new double[MAXROOTS]; double[] xtab = new double[MAXROOTS + 1]; Console.WriteLine(""); Console.WriteLine("TEST18"); Console.WriteLine(" ROOTS_TO_DIF computes a divided difference"); Console.WriteLine(" polynomial with the given roots;"); Console.WriteLine(" DIF_TO_R8POLY converts it to a standard form polynomial."); Console.WriteLine(""); int nroots = 1; roots[0] = 3.0; typeMethods.r8vec_print(nroots, roots, " The roots:"); Roots.roots_to_dif(nroots, roots, ref ntab, ref xtab, ref diftab); Dif.dif_to_r8poly(ntab, xtab, diftab, ref c); typeMethods.r8poly_print(ntab, c, " The polynomial:"); nroots = 2; roots[0] = 3.0; roots[1] = 1.0; typeMethods.r8vec_print(nroots, roots, " The roots:"); Roots.roots_to_dif(nroots, roots, ref ntab, ref xtab, ref diftab); Dif.dif_to_r8poly(ntab, xtab, diftab, ref c); typeMethods.r8poly_print(ntab, c, " The polynomial:"); nroots = 3; roots[0] = 3.0; roots[1] = 1.0; roots[2] = 2.0; typeMethods.r8vec_print(nroots, roots, " The roots:"); Roots.roots_to_dif(nroots, roots, ref ntab, ref xtab, ref diftab); Dif.dif_to_r8poly(ntab, xtab, diftab, ref c); typeMethods.r8poly_print(ntab, c, " The polynomial:"); nroots = 4; roots[0] = 3.0; roots[1] = 1.0; roots[2] = 2.0; roots[3] = 4.0; typeMethods.r8vec_print(nroots, roots, " The roots:"); Roots.roots_to_dif(nroots, roots, ref ntab, ref xtab, ref diftab); Dif.dif_to_r8poly(ntab, xtab, diftab, ref c); typeMethods.r8poly_print(ntab, c, " The polynomial:"); }