Lecture 3

How to report the homework

Rule 1!

  1. You are NOT!!! done with the homework when the code compiles. That is just the first 15% of the homework!
  2. Just because the code compiles, that does not mean it is bug free.
  3. Always make sure you have time to do computations that convince you and (more importantly) me and David (our TA) that the code works.
  4. Make sure you have time to do computations that are needed for the report.
  5. Make sure you have time to write the report. We will grade on correctness of the code, results and the exposition of the material.

How to debug

  1. Turn on the most agressive and strict warning flags on your compiler.
  2. In scientific computing we typically know how the method / code should behave in the sense of convergence / numerical approximation error. Make sure you check it and that you include those results in the report.
  3. For example if your code approximates a derivative with a forward difference f'(x) = (f(x+h)-f(x))/h then you would expect that the error e(h) = | f'(x) - (f(x+h)-f(x))/h | \approx
C\times h.
  4. How to display e(h) = C \times h^q?
  5. Recall log(e(h)) = log(C) + q \times log(h).

Reporting errors in a figure

_images/errors1.jpg

This figure is bad! Too much whitespace, uses plot(h,h,h,h.^2).

A bit better

_images/errors2.jpg

This uses loglog(h,h,h,h.^2)

Better still

_images/errors3.jpg

Added a legend and made lines wider.

Acceptable for a report

_images/errors4.jpg

Legend, wider lines, loglog, grid and labels on the axis.