Physics 410/609---Computational Physics
Assignment #3---Due Thursday, October 9
For this assignment it is necessary to write code in a compiled, not
an interpreted, langauge. Examples of a compiled language are C, C++,
Fortran, Java. Interpreted languages include Matlab and Mathematica.
You may use python, if you compile your code. If in doubt, contact me.
Your future employers will expect you to be
able to write and debug code to be compiled, so it is good practice to do
so now. We will be considering an interpreted language later in the course.
You will be able to contrast the two approaches.
You are welcome to use my fall_euler_ansi.c program as a starting point
for your Euler-Richardson program, if you like. The program can be found
in ~sg/chap3. In any case, your homework should contain a copy of your codes.
NOTE: At the end of each problem, please indicate how long it took
to solve the problem.
1) Complete Problem 3.9 on pages 63-64 of CSM. You should use the
Euler-Richardson algorithm and include a copy of your code.
2) a) Compute the period of the anharmonic oscillator for initial amplitude
1 for various strengths of the potential and determine the relation
between the period and k/m, where the potential is k*x**4/4 .
Use the fourth order Runge-Kutta method for this problem. This
method is explained in Numerical Recipes (see below) and the appendix
of CSM Chapter 3. Please note that in class I pointed out errors in
Eqs. (3.61g) and (3.61h).
To get an accurate value for the period, it may be useful to run
several oscillation periods and then divide the time by the number
of periods.
The best way to see the relationship between the period and k/m is
to use a log-log plot.
b) Read sections 17.0-17.4 of Numerical Recipes (NR) in the chapter on
Integration of Ordinary Differential Equations. If you are looking at
an edition of NR other than the 3rd, it could be a different chapter
number, but the chapter title should be the same.
3) Using Mathematica, find the value of the integral of the function sin(x)/x
over the interval [0,5].