Next: Integration, Differential equations
Up: Module NTools
Previous: Fitting
  Contents
  Index
Polynomial
Polynomials of 1 or 2 variables are supported ( Poly and Poly2).
Various operations are supported :
- elementary operations between polynomials

- setting or getting coefficients
- computing the value of the polynomial for a given value
of the variable(s),
- derivating
- computing roots (degre 1 or 2)
- fitting the polynomial to vectors of data.
Here is an example of polynomial fitting :
#include "poly.h"
// ...
Poly pol(2);
pol[0] = 100.; pol[1] = 0.; pol[2] = 0.01; // Setting coefficients
TVector<r_8> x(100);
TVector<r_8> y(100);
TVector<r_8> ey(100);
for(int i=0;i<100;i++) {
x(i) = i;
ey(i) = 10.;
y(i) = pol((double) i) + ey(i)*NorRand();
ey(i) *= ey(i)
}
TVector<r_8> errcoef;
Poly polfit;
polfit.Fit(x,y,ey,2,errcoef);
cout<<"Fit Result"<<polfit<<endl;
cout<<"Errors :"<<errcoef;
Similar operations can be done on polynomials with 2 variables.
Reza Ansari
2001-03-07