Logo ROOT  
Reference Guide
exampleMultiRoot.C File Reference

Detailed Description

View in nbviewer Open in SWAN
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) \]


\[ a = 1, b=10 \]

The MultiRootFinder is based on GSL and it requires the MathMore library installed


>.x exampleMultiRoot.C()


>.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] = -6.17162e-11
#include "RConfigure.h"
#error libMathMore is not available - cannot run this tutorial
#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
using namespace ROOT::Math;
void exampleMultiRoot(const char * algo = 0, int printlevel = 1) {
//defining the function
// use Rosenbrock functions
TF2 * f1 = new TF2("f1","[0]*(1-x)+[1]*y");
TF2 * f2 = new TF2("f2","[0]*(y-x*x)");
// wrap the functions
// starting point
double x0[2]={-1,-1};
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Class for Multidimensional root finding algorithms bassed on GSL.
Class to Wrap a ROOT Function class (like TF1) in a IParamMultiFunction interface of multi-dimensions...
virtual void SetParameters(const Double_t *params)
Definition: TF1.h:649
virtual void SetParameter(Int_t param, Double_t value)
Definition: TF1.h:639
A 2-Dim function with parameters.
Definition: TF2.h:29
TF1 * f1
Definition: legend1.C:11
Lorenzo Moneta

Definition in file exampleMultiRoot.C.