Monday, October 24, 2005

Physics 20 Reading List #5

Since this week you're taking your midterms, the next assignment will be due Friday November 4th. I am also giving you some (light) reading.

1. On the floating-point representation of numerical values

When you use numerical tools, it is important that you have a good understanding of the basic representation of numbers within computers, and on the effect that arithmetic operations have on the precision of this representation. Start by reading the discussion in Numerical Recipes, take a detour to contemplate a few catastrophic instances of roundoff error, then go on to read about the dangers of computer arithmetic.

As a handout, you're getting an excerpt from Donald Knuth about the history of the representation of numbers using base-n notation. The base-10 system we all know and love is not quite as 'obvious' as one might think.

2. On good programming practice

Now that your programs are getting more and more complicated, it is a good idea to step back and contemplate how you program. You may have noticed that the less understandable (or we might say, the less beautiful) your program is, the easier it is to make mistakes. A solution is to strive for clarity and understandability. Two extremely useful guidelines are by Michael Richmond, already cited above, who teaches the Computational Methods of Physics at the Rochester Institute of Technology.

1. As you write a program, imagine yourself coming back to work on it again three years from now. Make sure that your future self will understand it.

2. In most cases, efficiency is much less important than clarity. Computers get faster every year, but people don't get any smarter.


Another guideline that you should follow:

3. Program defensively, like you are supposed to drive. Remember, you will make mistakes in your programs (everyone does); the challenge is to program so that your mistakes are easy to find, and so that they remain as localized as possible (think 'quarantine'). One example of applying this principle is dividing your program into smaller subroutines, each of which can be tested independently.

0 Comments:

Post a Comment

<< Home