#include #include using namespace std; #include "Newton_polynomial.h" using namespace Data_structures; /* * 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() { Newton_polynomial<4> p; cout.precision( 20 ); cout << p << endl; p.insert( 2.0, std::sin(2.0) ); p.insert( 3.0, std::sin(3.0) ); p.insert( 4.0, std::sin(4.0) ); p.insert( 5.0, std::sin(5.0) ); cout << p << endl; cout << p.evaluate( 4.2, OPTIMAL ) << endl; return 0; }