The function and its integral (run this first)

For the purposes of this lab, I have chosen an integral that can be integrated exactly.  This allows us to actually compare the computed values to the true value of the definite integral.  (I did try to pick one that most of us would rather not try to actually integrate, however...)  

First, some preliminary commands to set things up.  The first one tells Mathematica to only use Real numbers (i.e., not complex numbers).

<<Miscellaneous`RealOnly`

This loads the basic graphics libraries (I generally load this one "just in case" I need it):

<<Graphics`

Now, we define our function.  If you want to try everything again with a different function, this is where you need to make that change.

f[x_] := (Sin[x^2] + 1)^(1/2)

We want to integrate ∫_a^bf(x) x, so let's define our limits of integration:

a = 0 ; b = π/2 ;

Let's graph it.  (Warning:  If you do change the function,you will probably want to change the PlotRange as well.)

RowBox[{Plot, [, RowBox[{f[x],  , ,, {x, a, b}, ,, RowBox[{PlotRange, , RowBox[{{, RowBox[{0, ,, 1.5}], }}]}]}], ]}]

[Graphics:../HTMLFiles/index_7.gif]

⁃Graphics⁃

Okay, now we want to see what the indefinite integral is (assuming it can actually be found).

indefIntegral = ∫f[x] x//FullSimplify

(π^(1/2) (FresnelC[x/π^(1/2)] + FresnelS[x/π^(1/2)]) (1 + Sin[x^2])^(1/2))/(Cos[x^2/2] + Sin[x^2/2])

So, the actual value of the definite integral can be found to 20 digits accuracy with the following command (note that we give this a name so we can refer back to it later).  Notice that I use the N[...,20] command repeatedly below to specify that I want Mathematica to compute everything with 20 digits of precision.

actualValue = N[∫_a^bf[x] x, 20]

1.9270350069596617241


Created by Mathematica  (April 22, 2004)