// Simple main program for the polynomial example. // #include using namespace std; #include "polynomial.h" void main( ) { Polynomial f(2.2); f.assign_coefficient( 2.5, 2 ); f.assign_coefficient( 5.0, 1 ); f.assign_coefficient( 1.1, 3 ); f.assign_coefficient( -2, 6 ); f.assign_coefficient( 0.4, 8 ); cout << "\nHere's f: " << f << endl; cout << "Degree of f = " << f.max_degree() << endl; cout << "Coefficent for x^1 = " << f.get_coefficient( 1 ) << endl; cout << "Coefficent for x^5 = " << f.get_coefficient( 5 ) << endl; cout << "Coefficent for x^12 = " << f.get_coefficient( 12 ) << endl; cout << "Evaluating: f(0) = " << f(0) << ", f(1) = " << f(1) << ", f(2) = " << f(2) << endl; cout << "Scaling: 10*f = " << 10*f << endl; cout << "Scaling: f*5 = " << f*5 << endl; Polynomial f2( f ); f2.assign_coefficient( 0.2, 10 ); f2.assign_coefficient( 1, 0 ); cout << "\n\nHere's f2: " << f2 << endl; Polynomial g; g.assign_coefficient( 1.25, 5 ); g.assign_coefficient( 1, 11 ); g.assign_coefficient( 1.5, 3 ); cout << "\n\nHere's g: " << g << endl; cout << "Evaluating: g(2) = " << g(2) << endl; cout << "f+g = " << f+g << endl; cout << "g+f = " << g+f << endl; cout << "f*g = " << f*g << endl; cout << "g*f = " << g*f << endl; cout << "f-g = " << f-g << endl; cout << "g-f = " << g-f << endl; }