These exercises develop techniques for numerical integration
and also in class and interface development.
- The midpoint approximation method uses as the height of the
rectangle the value of the function between the upper and lower range
of the slice interval. Create a class for the midpoint method. Use it
to integrate three functions of your choice and compare its results
to those obtained from the 3 methods discussed here. Use one of the
text format techniques from Chapter
5: Tech for the print output.
- Investigate round-off errors by replacing the double precision variables
used in the integration methods with single (float) precision values.
Compare the integrated values of three or more functions of your choice
to analytically calculated values. Show that the error difference between
the computed and calculated values decreases as the number of slices
increases. Determine if this difference begins to increase, however,
when the number of slices continues to grow to extremely large values.
- Create a set of classes and interfaces for the ODE solving techniques
of Chapters 2 and 4. For example, an abstract class or interface could
be created for ODEs. Subclasses of these then provide concrete instances
of particular ODE problems.
An instance of an ODE type can then be passed to an ODE_Solver type,
of which subclasses implement particular ODE solving methods.
The classes can be specific to a particular type of problem, e.g. projectile
motion, or more general.