MA400: Financial Mathematics: Introductory Course
MA400: Financial Mathematics: Introductory Course
Introductory Course
Preliminaries
A brief introduction
Beginning to program
That is, you will see the C of C++. However, this is not a software programming course.
Recommended reading
Find one that suits your learning requirements.
Introducing C++ for Scientists, Engineers and Mathematicians, 2nd Ed. D.M.Capper. The C++ Programming Language, Special Edition. Bjarne Stroustrup. Online C++ language tutorial at http://www.cplusplus.com/doc/tutorial/ Thinking in C++ Vols 1 & 2. Bruce Eckel. http://www.mindview.net/Books/TICPP/ThinkingInCPP2e.html
This is a 11 hour course, of which 2 hour (supervised) lab session [worksheet] 9 hours of lectures
Week 1 (3 hours):
Introduction to the course Fundamental types and operators Control structure
Week 2 (6 hours):
Functions Pointers and arrays Summary and tips. A look forwards.
What is C++?
C++ is a general purpose programming language that is itself a superset of the C programming language.
It is a compiled language, so that source les are used to generate executables, rather than executed themselves.
It is a general-purpose programming language that is designed to support: data abstraction object-oriented programming, generic programming.
Data abstraction
User-dened types which allow the user to model a particular entity in their system, together with various operations on it. This is done through classes
For example: matrices, complex numbers, even the term structure of interest rates!
Note that the term structure of interest rates can be equivalently specied in terms of either discount factors, spot interest rates, or forward interest rates.
complex operator+(complex a1, complex a2) { return complex ( a1.re + a2.re, a1.im + a2.im ); }
Object-oriented programming
Consider the following situations Suppose we have dened a Shape class, and alongside this we also had a Disc class, a Triangle class and a Square class. Consider a Matrix class, and a class representing all invertible matrices. Consider a Vector class, and a class representing all 3-vectors.
In all these cases, the latter classes clearly inherit, or derive, properties from the former, parent, class. Languages which allow such class hierarchies to be expressed and used support object-oriented programming.
Generic programming
Using templates, or parameterised types, C++ allows us to implement algorithms that are independent of the data types they are used on.
E.g. arrays, lists and vectors are all data structures which are amenable to sorting, copying and searching functions.
Integers and oating numbers are also amenable to the same sorts of functions and operators, such as nding the maximum of two numbers.
Programming experience
C/C++
Java
Maple/Mathematica/Matlab/etc
Learning to program
int main() {}
Hello, world!
// Print "Hello, world!" to the standard output stream #include <iostream> // I/O stream facilities
int main() { /* Use "put to" operator >> to print "Hello, world!" to standard output stream */ std::cout << "Hello, world!\n"; // Note the newline // Return 0 to indicate successful execution return(0); }
Compile (Ctrl + F9) Run (Ctrl + F10) Compile & Run (F9)
05:24 PM <DIR> . 05:24 PM <DIR> .. 05:23 PM 576 hello.cpp 05:24 PM 475,852 hello.exe 2 File(s) 476,238 bytes 2 Dir(s) 37,365,292,800 bytes free
H:\>quadratic.exe H:\>