Random values of x can be used to compute an approximation of a definite integral according to the following formula.
$\mathrm{Area}equals;{\int}_{a}^{b}f\left(x\right)DifferentialD;xequals;\underset{N\to \mathrm{infinity}}{lim}\frac{1}{N}\sum _{iequals;1}^{N}f\left(r\right)\left(ba\right)$
This procedure efficiently calculates a onevariable integral using the above formula where r is a random input to $f$.
A sample run using 1000 data points shows how this works:
$\mathrm{approxint}\left({x}^{2}comma;xequals;1..3\right)semi;$
${8.63278051029565}$
 (1.1) 
This can be computed exactly in Maple to show the above approximation is rough, but close enough for some applications.
${\int}_{1}^{3}{x}^{2}DifferentialD;x$
$\stackrel{\text{at 10 digits}}{\to}$
A parallel implementation adds the following code to split the problem over all available nodes and send the partial results back to node 0. Note that here the head node, 0, performs the calculation and then accumulates the results from the other nodes.
Integrate over the range, lim, using N samples. Use as many nodes as are available in your cluster.
Note: In the following command, replace "MyGridServer" with the name of the head node of your Grid Cluster.
$\mathrm{Grid}:\mathrm{Setup}\left(''hpc''\,\'\mathrm{host}\'\=''MyGridServer''\right)\;$
$\mathrm{Grid}:\mathrm{Launch}\left(\mathrm{parallelApproxint}\,{x}^{2}\,xequals;1..3comma;\mathrm{numSamples}equals;{10}^{7}comma;\mathrm{imports}equals;\left[apos;\mathrm{approxint}apos;\right]comma;\mathrm{numnodes}equals;16\right)semi;$
${8.66806767157001}$
 (1.4) 
Execution times are summarized as follows. Computations were executed on a 3blade cluster with 6 quadcore AMD Opteron 2378/2.4GHz processors and 8GB of memory per pair of CPUs, running Windows HPC Server 2008.
Number of Compute Nodes

Real Time to Compute Solution

Performance

1 (using serialized code)

356.25 s

The speedup is a measure of $\frac{{T}_{1}}{{T}_{p}}$
where ${T}_{1}$ is the execution time of the sequential algorithm and ${T}_{p}$ is the execution time of the parallel algorithm using p processes.

1 (using Grid)

$369.18$

2

$194.63$

3

$123.12$

$4$

$93.57$

$5$

$72.67$

$6$

$57.22$

7

$48.80$

$8$

$43.15$

9

$37.96$

$10$

$34.60$

$11$

$31.58$

12

$28.83$

13

$26.66$

14

24.90

15

23.38

16

21.93

17

20.92

$18$

$19.41$

19

18.41

20

17.85

21

16.71

$22$

$16.02$

23

$15.30s$



The compute time in Maple without using MapleGrid is the first number in the table  ~6 minutes. The rest of the times were using MapleGrid with a varying number of cores. The graph shows that adding cores scales linearly. When 23 cores are dedicated to the same example, it takes only 15.3 seconds to complete.