Introduction.

In this document I am trying to show how some finance algorithms actually are
implemented in addition to describing them. The implementation will be in the
form of computer subroutines. The actual programming language is not
important, but we do need that the algorithms are testable, so I have chosen to
use `C++`as the programming language. `C++`has other advantages, but that is in a
larger setting. I have tried to make the algorithms as ``generic'' as
possible, without relying on particularities of any given language, but I have
found it necessary to use some algoritms and templates from the new `C++`library
standard. (The Standard Template Library)

Unfortunately, it turned out to be impossible to be completely ``generic,'' in
particular when using the term structure of interest rates. In many financial
algorithms we need to take present values using the term structure. The problem
is that there is a large numbers of ways to actually
calculate/approximate/model a term structure. I have therefore hidden this
complexity, by defining a `class` that is just an abstract
representation of a term structure, which the various algorithms use. To give a
full description of this class would take too long. Companion documents
describing various classes for data structuring is available from my homepage.

I will first document the algorithm, and then present code that implements it. Note that I do not make any guarantees about the correctness of the algorithms, these are meant for teaching.

As you will see, this document is by no means complete, but it is being gradually added to as I get time.

This is not a textbook in the underlying theory, for that there are many good alternatives. For most of the material the best textbook to refer to is Hull (1993), since I have used that as a reference, and the notation follows that.