WOLFRAM|DEMONSTRATIONS PROJECT

Mean Value Theorem for Integrals and Monte Carlo Integration

​
function
3
x
-5
2
x
-8x+3
a
-1.69
b
2.55
n
563
random seed
263
The mean value theorem for integrals states that if
f(x)
is continuous over
[a,b]
, then there exists a real number
c
with
a<c<b
such that
1
b-a
b
∫
a
f(x)dx=f(c)
. Writing this as
b
∫
a
f(x)dx=(b-a)f(c)
shows that the area under the curve is the base
(b-a)
times the "average height"
f(c)
. To estimate this integral by the Monte Carlo method, use the following steps:
(1) Pick
n
uniformly distributed numbers
x
1
,
x
2
,…,
x
n
in the interval [
a
,
b
].
(2) Evaluate the function
f
at each point and calculate the average function value:
-
f
=
1
n
n
∑
i=1
f(
x
i
)
.
(3) Compute the approximate value of the integral:
(b-a)×
-
f
.