#include #include using namespace std; #include "Newton_polynomial.h" /* * This function prints out Maple code which plots * the function sin(x), the polynomial interpolating * sin(x) at up to five points, and the Newton * polynomial evaluated at various points on the * interpolated range: [low, high]. * * The output can be cut-and-pasted directly into Maple. */ int main() { Data_structures::Newton_polynomial<5> p; cout.precision( 20 ); for ( double x = 1; x <= 5; ++x ) { p.insert( x, std::sin(x) ); } double sum = 0; double const delta = 0.2384185791015625000e-6*0.25; for ( double xi = 0.5; xi <= 5.5; xi += delta ) { sum += p.evaluate( xi, Data_structures::BACKWARD )*delta; } cout << sum << endl; return 0; }