Numerical integration sample

I am just learning ROOT and I wanna do some multidimensional integration. Where can I find sample simple codes to study?

Thanks again for your help,
Jaybee

ROOT -> Mathematical Libraries -> Numerical Algorithms -> Function Integration

I tried it… thanks :slight_smile: I am figuring it out…

// Kindly bear my ignorance and help me learn the syntax.
// Please correct me with my comments and questions in the following ROOT code:

//=======
#include “TF1.h”
// to ensure that a 1-dimensional formula can be defined

#include “Math/WrappedTF1.h”
// to wrap the defined formula
// why and for what reasons is the “wrapping”?

#include “Math/GaussIntegrator.h”
// is this the choice of integrator with a “Gaussian measure”?

int GaussIntegratorOneDim()
// should this be the same name at the filename?
{
TF1 f(“f”, “exp(x)”, 0, TMath::Pi());
// f - is the name of the formula
// exp(x) - is the defined formula
// 0, TMath::Pi() - is the range of the variable x
// -> is it really necessary to set the range?
// -> what happens when you integrate beyond the set range?

ROOT::Math::WrappedTF1 wf1(f);
// why does the function have to be wrapped?

ROOT::Math::GaussIntegrator ig;
// defining the integrator

ig.SetFunction(wf1);
// setting of the function
// “ig.SetFunction(wf1, false);” - i do not know why this does not work
// but why does it work without the “false” parameter?

ig.SetRelTolerance(0.001);
// what is this function?
// can it be set arbitrarily?

cout << ig.Integral(0, TMath::PiOver2()) << endl;
cout << ig.Integral(1, 0) << endl;

return 0;
// what does this mean?
// what happens when I put “return 1;” instead?
}
//=======
// Thanks always for your help - Jaybee

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.