The function e -x^2 does not have an antiderivative that can be expressed in ter
ID: 3556505 • Letter: T
Question
The function e-x^2 does not have an antiderivative that can be expressed in terms of elementary functions (ex, sin x, etc), so the integral of this function must be estimated by some numerical technique.
Approximate the integral:
by using the Monte Carlo method. (remember that integral is the areaunderneath the line )
Hint: You need to include <math.h> to calculate theby using exp(-(x*x)).
Sample Input/Output:
(Input is in bold)
Run again(1=yes,0=no)? 1
How many trials? 100
Integral = 0.720000
Run again(1=yes,0=no)? 1
How many trials? 10000
Integral = 0.746400
Run again(1=yes,0=no)? 1
How many trials? 1000000
Integral = 0.746515