The MultiRootFinder is based on GSL and it requires the MathMore library installed
Usage:
>.x exampleMultiRoot.C()
or
>.x exampleMultiRoot(algoname,printlevel)
where algoname is for an algorithm not using the derivatives: hybridS (default) , hybrid, dnewton, broyden
Author: Lorenzo Moneta
This notebook tutorial was automatically generated with ROOTBOOK-izer (Beta) from the macro found in the ROOT repository on Thursday, January 19, 2017 at 04:32 PM.
In [1]:
%%cpp -d
#include "RConfigure.h"
#ifdef R__HAS_MATHMORE
#include "Math/MultiRootFinder.h"
#endif
#include "Math/WrappedMultiTF1.h"
#include "TF2.h"
#include "TError.h"
Example of using multi root finder based on gsl need to use an algorithm not requiring the derivative like hybrids (default), hybrid, dnewton, broyden
In [2]:
%%cpp -d
// This is a workaround to make sure the namespace is used inside functions
using namespace ROOT::Math;
Arguments are defined.
In [3]:
const char * algo = 0;
int printlevel = 1;
In [4]:
#ifndef R__HAS_MATHMORE
Error("exampleMultiRoot","libMathMore is not available - cannot run this tutorial");
return;
#endif
ROOT::Math::MultiRootFinder r(algo);
Defining the function use Rosenbrock functions
In [5]:
TF2 * f1 = new TF2("f1","[0]*(1-x)+[1]*y");
TF2 * f2 = new TF2("f2","[0]*(y-x*x)");
f1->SetParameters(1,0);
f2->SetParameter(0,10);
Wrap the functions
In [6]:
ROOT::Math::WrappedMultiTF1 g1(*f1,2);
ROOT::Math::WrappedMultiTF1 g2(*f2,2);
r.AddFunction(g1);
r.AddFunction(g2);
r.SetPrintLevel(printlevel);
Starting point
In [7]:
double x0[2]={-1,-1};
r.Solve(x0);