Physics 234 – Winter 2009
Course outline
Introductory Computational Physics
Lecture: V 103 MWF 12:00-12:50
Lab (section H31): CEB 324 T 14:00-16:50
Lab (section H71): CEB 324 R 14:00-16:50
Syllabus: pdf
An old version of Numerical Recipes, the recommended text, is available online. The newest version makes the jump from C to C++.
Class discussion area
Students are encouraged to leave questions or comments here. I will try to respond quickly if there are any points of confusion about the lectures or labs.
Grades
Your final grade will be determined using the weights listing in the course syllabus:
| Assignments | 25% |
| Lab test | 15% |
| Midterm exam | 20% |
| Final exam | 40% |
Please check here to see your your individual marks. As usual, the results are tabulated according to the last three digits of your student ID number. A tentative letter grade has been assigned. This should not be construed as an official grade report.
Midterm exam
Just a reminder that we have an in-class midterm scheduled
for Wednesday, February 11. You will be evaluated only on your
knowledge of basic C++ syntax. An excellent study resource is this
online tutorial.
I suggest you also review the solutions to the labs and be
sure you can answer all of these sample questions:
practice exam 1 [ pdf ],
practice exam 2 [ pdf ],
solutions [ pdf ]
Update:
Your test papers have been graded and will be handed back in class (cue scary
music) on Friday, February 13. Individual results are also available
here, indexed by the last three
digits of your student ID.
There was a very broad distribution of scores,
but the performance of the class as a whole was quite good.
midterm exam [ pdf ],
solutions [ pdf ]

Class average: 12.7/20 (63%)
Approximate letter grade ranges (based on the standard UofA distribution for 2nd year classes):
A+ (> 17), A (17), A- (15.5–16.5),
B+ (14–15), B (13–13.5), B- (11.5–12.5),
C+ (10.5–11), C (9–10), C- (8–8.5),
D (6.5–6)
Lab test
The lab test will take place on Tuesday, March 31 and Thursday, April 2 during the regularly scheduled lab periods. You will be given 2½ hours to solve several simple numerical problems using C++ (in combination with any BASH or UNIX command-line tools you like). The expectation is that you are capable of writing small programs from scratch under reasonable time constraints without the coaching of your peers or the teaching assistants.
The problems you'll have to solve are not particularly challenging.
The purpose of this test is to evaluate your acquisition of basic scientific
programming skills. If you have taken the time to work through the labs
(independently and carefully), you should do well. It may also be helpful
to try your hand at solving these sample questions:
practice lab test [ pdf ],
solutions [ tar.gz ]
To attempt the lab test, you will need a valid userID (of the form p234u1xx) and password for the computer lab in CEB 324. You should also be familiar enough with the environment on those machines to launch a BASH shell, to edit .cpp files using your favourite text editor, and to and compile them with g++.
Update:
Test papers were handed back in class on Monday, April 6.
Individual results are also available
here, indexed by the last three
digits of your student ID. The second column represents the number of questions
that were judged correct. The third column is the finally tally, including
partial credit awarded for your submitted code.
My solutions are posted below.
lab test [ pdf ],
solutions [ tar.gz ]

Final exam
The final exam is scheduled for Friday April 17 during the hours 14:00-17:00 in our usual lecture room, V 103. It will cover all the material from Lecture 18 on: floating-point representations, root finding (bisection, Newton-Raphson, and secant methods) and extremization (steepest-descent), function evaluation (Horner's scheme), curve fitting via least squares (using polynomial, spline, rational function, and continued fraction forms), uncertainty analysis (jackknife and bootstrap), ordinary differential equations (Euler and Euler-Cromer), sequences and series (rates of convergence, acceleration, Richardson extrapolation).
The exam is closed book. You may bring to the exam one 8.5"×11" cheat sheet, written on both sides. Calculators are not permitted.
The last four lectures (3538) were a recapitulation of the major topics
we've covered since the midterm exam. As preparation for the final, I
suggest that students go through all the worked examples and practice
questions from those classes. But don't just focus on reproducing the calculations:
be sure that you understand the concepts involved.
practice exam questions [ pdf ],
partial solutions [ pdf ]
Update: Your exam papers have been graded as of April 19. Results are
available above [ ▲ ]. Of the 49 students
enrolled, 46 attempted the exam. Five more or less aced it. The remaining
scores were rather evenly distrubuted all the way down to the single
digits. Overall the performance of the class was a little below my expectations.
For my part, I may have misjudged the level of difficulty of some of the
questions. (Kudos if you solved question 10. But I'm confused that so many
people choked on the “sketch-a-diagram” questions, which I had intended
as a give-away.) The class average
is about 10–15% lower than where it ideally should be.
final exam [ pdf ]

Class average: 24.8/20 (50%)
Approximate letter grade ranges (based on the standard UofA distribution for 2nd year classes):
A+ (> 45), A (40–44.5), A- (32.5–39.5),
B+ (29–32), B (22.5–28.5), B- (20–22),
C+ (16.5–19.5), C (13–16), C- (10.5–12.5),
D+ (9–10), D (8–8.5), D- (7–7.5)
F (< 7)
Assigned reading
- An introduction to the BASH shell (§1.1), the GNU Compiler Collection (§1.2), the graphing program gnuplot (§1.5), and basic C++ concepts (§2.1 – §2.6). [ pdf ]
- David Goldberg, “What Every Computer Scientist Schould Know Abount Floating-Point Arithmetic,” ACM Computing Surveys 23, 5 (1991). [ pdf ], [ html ]
Lectures
Class starts on Monday, January 5. Hope to see you there.
- Monday, January 5
- Wednesday, January 7 + more on two's complement here and here
- Friday, January 9
- Monday, January 12
- Wednesday, January 14
- Friday, January 16
- Monday, January 19
- Wednesday, January 21
- Friday, January 23: (Jeff Gu) Monte Carlo methods
- Monday, January 26: (Frank Marsiglio) Buffon's needle problem, numerical integration
- Wednesday, January 28: (Craig Heinke) C arrays and pointers, C strings, C++ strings
- Friday, January 30: (Kyle Murphy) In-class practice test
- Monday, February 2
- Wednesday, February 4
- Friday, February 6
- Monday, February 9
- Wednesday, February 11: midterm exam
- Friday, February 13 + more on floating point representations here and here
- Monday, February 23
- Wednesday, February 25 + more on floating point errors here and here
- Friday, February 27
- Monday, March 2 + more on Newton's method here
- Wednesday, March 4
- Friday, March 6
- Monday, March 9
- Wednesday, March 11: MathWorld articles on linear, nonlinear, and polynomial least squares fitting, and the matrix pseudo-inverse
- Friday, March 13 + more on splines here, here, and here
- Monday, March 16 + more on resampling methods here
- Wednesday, March 18
- Friday, March 20: articles on ordinary differential equations here, here, here and on Euler's method here and here
- Monday, March 23: simulating Newtonian mechanics, preserving conservation laws; articles on Euler-Cromer updates here and here.
- Wednesday, March 25: articles on sequence transformations (series acceleration) here, here, here, and on Richardson extrapolation here and here
- Friday, March 27
- Monday, March 30: review for the upcoming lab test
- Wednesday, April 1
- Friday, April 3
- Monday, April 6: final exam review
- Wednesday, April 8: final exam review
Labs
Labs start either Tuesday, January 13 or Thursday, January 15, depending on your section. Detailed instructions on accessing the lab are provided here.
- Introduction to UNIX, BASH, and C++
instructions [ pdf ], solutions [ pdf ] - Working with columnar data files in gnuplot
instructions [ pdf ], source code [ tar.gz ], solutions [ tar.gz ] - C++ streams, convergence of series expansions, numerical estimates of π
instructions [ pdf ], source code [ tar.gz ], solutions [ tar.gz ] - Pseudo-random numbers, Monte Carlo integration
instructions [ pdf ], source code [ tar.gz ], solutions [ tar.gz ] - Practice with C arrays: histograms and linear algebra
instructions [ pdf ], source code [ tar.gz ], solutions [ tar.gz ] - Floating-point arithmetic
instructions [ pdf ], source code [ tar.gz ], solutions [ tar.gz ] - Summation techniques, root finding
instructions [ pdf ], source code [ tar.gz ], solutions [ tar.gz ] - Steepest descent optimization, least squares fitting
instructions [ pdf ], source code [ tar.gz ], solutions [ tar.gz ] - Interpolation and extrapolation
instructions [ pdf ], source code [ tar.gz ], solutions [ tar.gz ] - ODE solving, Newtonian mechanics
instructions [ pdf ], source code [ tar.gz ], solutions [ tar.gz ]
The fifth assignment (from Lab 8) is due March 23 or 25, depending on your lab section. To submit your work, use the submit234 script. You are free to resubmit as many times as you like up until the deadline. As a courtesy, please include your name and lab section as a comment at the top of the file. Be aware that the submission script may fail if any of the directories in your current path contain spaces.
$ cd Lab8 $ ls string_fit.cpp string_fit.cpp $ head -n2 string_fit.cpp // Assignment 5 (Lab 8) // Student Name (Tuesday/Thursday section) $ submit234 string_fit.cpp