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:

Assignments25%
Lab test15%
Midterm exam   20%
Final exam40%

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 (35–38) 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

  1. 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 ]
  2. 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.

  1. Monday, January 5
  2. Wednesday, January 7 + more on two's complement here and here
  3. Friday, January 9
  4. Monday, January 12
  5. Wednesday, January 14
  6. Friday, January 16
  7. Monday, January 19
  8. Wednesday, January 21
  9. Friday, January 23: (Jeff Gu) Monte Carlo methods
  10. Monday, January 26: (Frank Marsiglio) Buffon's needle problem, numerical integration
  11. Wednesday, January 28: (Craig Heinke) C arrays and pointers, C strings, C++ strings
  12. Friday, January 30: (Kyle Murphy) In-class practice test
  13. Monday, February 2
  14. Wednesday, February 4
  15. Friday, February 6
  16. Monday, February 9
  17. Wednesday, February 11: midterm exam
  18. Friday, February 13 + more on floating point representations here and here
  19. Monday, February 23
  20. Wednesday, February 25 + more on floating point errors here and here
  21. Friday, February 27
  22. Monday, March 2 + more on Newton's method here
  23. Wednesday, March 4
  24. Friday, March 6
  25. Monday, March 9
  26. Wednesday, March 11: MathWorld articles on linear, nonlinear, and polynomial least squares fitting, and the matrix pseudo-inverse
  27. Friday, March 13 + more on splines here, here, and here
  28. Monday, March 16 + more on resampling methods here
  29. Wednesday, March 18
  30. Friday, March 20: articles on ordinary differential equations here, here, here and on Euler's method here and here
  31. Monday, March 23: simulating Newtonian mechanics, preserving conservation laws; articles on Euler-Cromer updates here and here.
  32. Wednesday, March 25: articles on sequence transformations (series acceleration) here, here, here, and on Richardson extrapolation here and here
  33. Friday, March 27
  34. Monday, March 30: review for the upcoming lab test
  35. Wednesday, April 1
  36. Friday, April 3
  37. Monday, April 6: final exam review
  38. 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.

  1. Introduction to UNIX, BASH, and C++
    instructions [ pdf ], solutions [ pdf ]
  2. Working with columnar data files in gnuplot
    instructions [ pdf ], source code [ tar.gz ], solutions [ tar.gz ]
  3. C++ streams, convergence of series expansions, numerical estimates of π
    instructions [ pdf ], source code [ tar.gz ], solutions [ tar.gz ]
  4. Pseudo-random numbers, Monte Carlo integration
    instructions [ pdf ], source code [ tar.gz ], solutions [ tar.gz ]
  5. Practice with C arrays: histograms and linear algebra
    instructions [ pdf ], source code [ tar.gz ], solutions [ tar.gz ]
  6. Floating-point arithmetic
    instructions [ pdf ], source code [ tar.gz ], solutions [ tar.gz ]
  7. Summation techniques, root finding
    instructions [ pdf ], source code [ tar.gz ], solutions [ tar.gz ]
  8. Steepest descent optimization, least squares fitting
    instructions [ pdf ], source code [ tar.gz ], solutions [ tar.gz ]
  9. Interpolation and extrapolation
    instructions [ pdf ], source code [ tar.gz ], solutions [ tar.gz ]
  10. 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