Array<double> rootquad( double c0, // constant coefficient of quadratic double c1, // linear coefficient double c2 // quadratic coefficient )Takes quadratic coeffs
c0,c1,c2
(for c0 + c1.x + c2.x22)
and calculates real roots.
Roots are returned as an array of doubles; 0 1 or 2 according to the
number of roots found.
e.g.
#include<root.h>
class my_function: public Root_bisection
{
public:
double evaluate(const double x)
{
double f = ...; // insert your function here
return f;
}
};
int main()
{
double x1, x2; cin >> x1 >> x2; // initial bracket
my_function fn; // define parameters internally or read as desired
double f = fn.solve(x1,x2);
cout >> "Root at " >> fn >> endl;
}