PHYS 252

Always hand in:
  1. written solutions to any questions
  2. a paper print-out of well-commented code. Include a multiline comment at the top of your code with (i) the assignment name, (ii) your name, and (iii) the date you handed in all elements of the assignment
  3. paper print-out of output (graph or text)
  4. also, e-mail me (y-lithwick@northwestern.edu) the code with your name and the exercise number in the subject line

Assignment #4
[5 pts, due 2pm, April 10]

  1. Here is the skeleton of a general purpose integrator of ordinary differential equations: integ.c. Fill in the code only where I marked XXX. The final code should run and reproduce question 2 from assignment 3. Note that 'step' calls 'derivs', and I've coded in the 'derivs' for you. You will hopefully be able to use this code in future assignments for solving many different ODE's with different methods.
  2. Use your general purpose integrator from question 1 to integrate equations 1.12 in the book (see problem 1.5 [pdf]), with initially NA=100, NB=0, tau=1. Note: you should only have to modify the functions 'initialize' and 'derivs'.
  3. For this question, you have two options. Either finish working through the square-bracketed sections of the Online C tutorial below, or do problem 1.6 in the book with your general purpose integrator. If you are doing the Online C tutorial, write on your solution the sections of the Online C Tutorial you've done.

Following is a list of chapters in the Online C Tutorial. I recommend you do the pages enclosed in square brackets, because these are the most important pages for this course. The remaining sections are not necessary, but are still worth doing for learning C.