Example of using multiroot finder based on GSL algorithm.
Find the root of Rosenbrock system of equations:
\[ f1(x,y) = a(1-x)
\]
\[ f2(x,y) = b(y-x^2)
\]
with:
\[ a = 1, b=10
\]
The MultiRootFinder is based on GSL and it requires the MathMore library installed.
Usage:
or
>.x exampleMultiRoot(algoname,printlevel)
where algoname is for an algorithm not using the derivatives: hybridS (default) , hybrid, dnewton, broyden
GSLMultiRootFinder::Solve:hybrids max iterations 100 and tolerance 1e-06
GSL Algorithm used is : hybrids
Number of iterations = 19
Root values = x[0] = 1 x[1] = 1
Function values = f[0] = 0 f[1] = 2.61797e-10
#include "RConfigure.h"
#ifdef R__HAS_MATHMORE
#else
#error libMathMore is not available - cannot run this tutorial
#endif
void exampleMultiRoot(const char * algo = nullptr, int printlevel = 1) {
TF2 *
f1 =
new TF2(
"f1",
"[0]*(1-x)+[1]*y");
TF2 * f2 =
new TF2(
"f2",
"[0]*(y-x*x)");
r.SetPrintLevel(printlevel);
double x0[2]={-1,-1};
}
virtual void SetParameter(Int_t param, Double_t value)
WrappedMultiTF1Templ< double > WrappedMultiTF1
GSLMultiRootFinder MultiRootFinder
- Author
- Lorenzo Moneta
Definition in file exampleMultiRoot.C.