This is the Mathematica integration lab. You will be doing some elementary calculations and graphs. Follow the directions below.
Open Mathematica by double clicking the Mathematica icon on the desktop. The notebook opens. This is your palette-you are the artist.
You will be using the NIntegrate function in mathematica to estimate various integrals and, at times, comparing the result to the actual value of the integral. Let's begin with a simple example. For our numerical approximation, type:
NIntegrate[x^5,{x,0,1}] and hit shift-enter.
Now for the exact value type:
Integrate[x^5,{x,0,1}]
and hit shift-enter.
This was a relatively simple integrand over a small interval. Let's now look at something more challenging. Type:
NIntegrate[Exp[-x^2/2],{x,-1,1}] and hit shift-enter.
Now for the exact value type:
Integrate[Exp[-x^2/2],{x,-1,1}]
and hit shift-enter.
(We'll interpret what Erf means in the next class). To see a graph of the above function type:
Plot[Exp[-x^2/2],{x,-3,3}]
Let's now try a numerical approximation over a larger interval. Type:
NIntegrate[Exp[-x^2/2],{x,-10,10}]
(Note: Mathematica should say nasty things to you at this point). This error is generated because the integral does not seem to converge quickly enough for mathematica as it begins the calculation on a part of the function that is very close to zero. To account for this try:
NIntegrate[Exp[-x^2/2], {x, -10, -1, 1, 10}]
This should produce a valid approximation. This has mathematica look at 3 subintervals: [-10,-1), (-1,1), (1,10].
Finally, let's consider some improper integrals. Type
NIntegrate[1/Sqrt[x], {x, 0, 2}]
then
NIntegrate[1/x, {x, 0, 2}] We'll explain what these are in our next class.