Using a library for matrix algebra

What really distinguishes C ++ from standard C is the ability to extend the language by creating classes and collecting these classes into libraries. A library is a collection of classes and routines for one particular purpose. We have already seen this idea when creating the date and term_structure classes. However, one should not necessarily always go ahead and create such classes from scratch. It is just as well to use somebody else class, as long as it is correct and well documented and fulfills a particular purpose.

An example matrix class

Use Newmat as an example matrix class. [reference to www]. Discuss alternatives.

Finite Differences

We use the case of implicit finite difference calculations to illustrate matrix calculations in action.

The method of choice for any engineer given a differential equation to solve is to numerically approximate it using a finite difference scheme, which is to approximate the continous differential equation with a discrete difference equation, and solve this difference equation.

In the following we implement the implicit finite differences.

Explicit finite differences was discussed earlier, we postponed the implicit case to now because it is much simplified by a matrix library.

European Options

For European options we do not need to use the finite difference scheme, but we show how one would find the european price for comparison purposes.

% latex2html id marker 4303\caption{}

American Options

We now compare the American versions of the same algoritms, the only difference being the check for exercise at each point.

% latex2html id marker 4308\caption{}