Next: D. Histograms
Up: C. Trapezium rule for
Previous: Programming
Contents
Subsections
Here are some (but not all) of the common problems associated with
the exercise.
- Data types -- make sure your choice of int or double
is appropriate for the variable. Remember the effects of integer
division!
- Loop counters should be integers to avoid rounding errors.
- Don't forget to initialise variables where necessary.
- Limit the scope of variable declarations to the minimum required.
- Beware of limitations of the Trapezium rule.
- Understand the behaviour of the function before trying to integrate it.
- Choose N to reach a reasonably accurate result.
Vary N to understand the accuracy.
- The function must not be sharply concentrated in peak(s)
-- this implies f'' is large.
- The function must be characterised by a single length scale
(i.e. y range does not cover several orders of magnitude) -- again,
this implies f'' is large.
RHUL Dept. of Physics