Many scientific problems involve computations of integrals. If *f* is a scalar function of one variable and integratable, we can write the integral as:

where *F(x)* is the anti-derivative of *f*. Calculating the integral of most functions analytically can be a daunting and often impossible task, which is why we turn to the numerical alternative.

There are different ways to compute the integral numerically. Here we will write a function that uses the Monte Carlo method
. Later we discuss the other integration methods that come with Octave. Now, assume that *f* is positive in the interval *x* ∈ ...

Start Free Trial

No credit card required