Quartic Equation Solver: problem with FindNumRoots();

I am trying to solve a quartic polynomial in root in the following fashion:


#include<TMath.h>
#include<Math/Polynomial.h>
#include<complex.h>
#include<vector.h>

ROOT::Math::Polynomial poly(4);
cout<<Gamma[i]<<endl;
double coeffs[5] = {1,4,6,4,1};
poly.SetParameters(coeffs);
vector<complex<double> > roots;
roots = poly.FindNumRoots();

However, I’m getting the following error when the last line runs:

[quote]Error: Symbol G__exception is not defined in current scope AbsorptionCoefficientTran.C:57:
Error: type G__exception not defined FILE:/Users/karstenheeger/Desktop/Work/06-03-08_Optical_Measurements/./AbsorptionCoefficientTran.C LINE:57
[/quote]

I am running 5.19/04 version of root on Mac OS 10.4, and I have GSL 1.11, with gsl-config in my $PATH, which I understand is important form previous threads.

Any help would be greatly appreciated.

Regards,
Bryce Littlejohn
UW-Madison

Hi,

you are getting some CINT error, maybe due to the fact you are including wrong header files. (complex.h instead of complex)
Attached is a code working in compiled mode. To run do:

root> .x testQuartic.C+

Best Regards

Lorenzo
testQuartic.C (498 Bytes)

Thanks for the help, Lorenzo,

Is it possible to run this command with .L?

this root-finding is a part of a larger script, which I’ve attached, which doesn’t behave well with .x.

If not, how would you recommend implementing the root-finding into this script?
AbsorptionCoefficientTran.C (2.03 KB)

Yes, of course you can do with .L but you should add a “+” at the end to compile the code.