# exampleMultiRoot¶

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:

>.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 from the macro found in the ROOT repository on Wednesday, August 17, 2022 at 09:34 AM.

In :
%%cpp -d
#include "RConfigure.h"

#ifdef R__HAS_MATHMORE
#include "Math/MultiRootFinder.h"
#else
#error libMathMore is not available - cannot run this tutorial
#endif
#include "Math/WrappedMultiTF1.h"
#include "TF2.h"
#include "TError.h"

using namespace ROOT::Math;


Arguments are defined.

In :
const char * algo = 0;
int printlevel = 1;

In :
ROOT::Math::MultiRootFinder r(algo);


defining the function use Rosenbrock functions

In :
TF2 * f1 = new TF2("f1","*(1-x)+*y");
TF2 * f2 = new TF2("f2","*(y-x*x)");
f1->SetParameters(1,0);
f2->SetParameter(0,10);


wrap the functions

In :
ROOT::Math::WrappedMultiTF1 g1(*f1,2);
ROOT::Math::WrappedMultiTF1 g2(*f2,2);
r.SetPrintLevel(printlevel);


starting point

In :
double x0={-1,-1};
r.Solve(x0);

GSLMultiRootFinder::Solve:hybrids max iterations 100 and  tolerance 1e-06
GSL Algorithm used is :  hybrids
Number of iterations  =  19
Root values     = x =            1   x =            1
Function values = f =            0   f = -6.17162e-11

Info in <ROOT::Math::GSLMultiRootFinder::Solve>: The iteration converged