/*
    Polynomial math:
 
    Mathematical operations involving polynomia
 
*/



#include <iostream>
using namespace std;

// This is the header defining DualNumber class.
#include "Polynomium.hpp"


int main()
{
   Polynomium P,R;
   double x=1.0;

   P[4]=3.0; P[1]=5.0;                // 3x^4 + 5x^1
   cout << "P=" << P << "\n";

   Polynomium Q;
   Q[4]=2.0;  Q[2]=1.0;  Q[0]=10.0;   // 2x^4 + 1x^2 + 10 
   cout << "Q=" << Q << "\n";

   cout << "\nPerforming mathematical operations with polynomia\n";
   R=P+Q;   
   cout << "P+Q=" << R << "\n";
   cout << "Value " << R(x) << "\n\n";

   R=P-Q;   
   cout << "P-Q=" << R << "\n";
   cout << "Value " << R(x) << "\n\n";

   R=Q*P;   
   cout << "P*Q=" << R << "\n";
   cout << "Value " << R(x) << "\n\n";

   cout << "\nCrazy mathematics!!\n";
   R=(Q*Q*P+P*2.0*P*Q-30.0*Q+P*50.0)/24;
   cout << "R=" << R << "\n\n";

   R=R*R*R*R*R;
   cout << "R^5 =" << R << "\n";

   return 0;
}
