down

Exercise 5: Integration

This exercise requires a little independent work; figuring out how to write a function in Maple, and how to implement a function in Fortran. The actual time required, once you know how to do it, is quite small. Spend the rest of the time wisely; ie, have fun!

To help you if you get stuck, there are hints, as usual. If you can do without them, the exercise is more useful, but don't be afraid to use ...

... your bonus points!   Credits: 4/4

NOTE:
The next lecture covers material that will be part of the first project, so it is a good idea to come to the lecture.

Subsections
approx time
Getting the exercise files

1 min

Using IDL to explore the problem
45 min
Integrals with Maple
30 min
Substitution of variables in Maple
45 min
Fortran exercises
60 min
Home Work
2 hours


down up  Getting the exercise files

[about 1 minute]

To extract the exercise files for this weeks exercise, do

    cd ~/ComputerPhysics
    cvs update -d

In case of problems, see the CVS update help page.


down top  Using IDL to explore the problem

[about 45 minutes]

The integrand from the Lecture Notes is available as the function prof.pro in your 5_Integration directory. In this section, the point is to first look at the shape of the integrand and consider what happens with the integrand under the substitution of variables discussed in the Lecture Notes, and then explore how the integration error depends on the number of points.

Check that you can see the error.png in the web browser or an image viewer program before submitting it.

Please upload the error.png file Locate and upload your error.png file: Credits: 2/0
OK

down top  Integrals with Maple

[about 30 minutes]

Starting Maple

To start maple give the shell command "xmaple".  If it is the first time you run xmaple you get a choice btw "worksheet" or "document" -- choose "document".

Evaluating integrals with Maple

To evaluate an indefinite integral, click on "expressions" in the menu list on the left, and then on the first integral symbol.  Fill in an expression instead of f, and hit RETURN. Try this with the expression 1/(1+x2) (use the hat (caret) sign to make the exponent), which should give you arctan(x).

To evaluate a definite integral, choose instead the next integral symbol in the "expressions" menu, and enter values for the limits.  Try for example the interval -100 to 100.

To evaluate a definite integral numerically, just enter the limits in the form of floating point numbers (a number that includes a period), or enclose the expression in evalf(..).

The fact that the integral of 1/(1+x2) is arctan(x) is precisely the reason for the choice of transformation in the example we are looking at in this exercise. The actual (test) profile is similar to 1/(1+x^2) (as a real spectral line profile would also be). Hence the transformation of variables u=arctan(x), or x=tan(u), turns the integrand into a nearly constant function.

What is the value of the integral? Credits: 2/-2
OK


down top  Substitution of variables in Maple

[about 45 minutes]

In this section, we go through the substitution steps in Maple. This is NOT just a repetition of the IDL and Fortran parts; Maple is able to perform analytical differentiation as well as integration, and in a real situation you might use Maple to try to find a function that is sufficiently "similar" to your complicated integrand, and yet is analytically integrable.