You are on page 1of 38

MATH 472: Numerical Methods with Financial Applications

Lecture 1

Course Basics
Chapter 0 Fundamentals

Prakash Chakraborty

University of Michigan

1 / 18
Course basics

Please read the syllabus on Canvas (https://umich.instructure.com/).

2 / 18
Course basics

Please read the syllabus on Canvas (https://umich.instructure.com/).

Homework Rules
I Show your work neatly.
I Ensure your homework is in the correct order (the order in which the problems
were assigned) before uploading to Canvas. Make sure that your name, section
# as well as assignment # is written on the first page.
I If you feel that some parts of a graded assignment should be regraded, please
come to me within 2 weeks of getting back your assignment.

2 / 18
Course basics

Please read the syllabus on Canvas (https://umich.instructure.com/).

Homework Rules
I Show your work neatly.
I Ensure your homework is in the correct order (the order in which the problems
were assigned) before uploading to Canvas. Make sure that your name, section
# as well as assignment # is written on the first page.
I If you feel that some parts of a graded assignment should be regraded, please
come to me within 2 weeks of getting back your assignment.

Admin
I All questions regarding course registration and waitlist should be asked to the
Student Services Office in 2082 East Hall. We will do our best to get you into a
section of the course which has space.

2 / 18
Course basics

Please read the syllabus on Canvas (https://umich.instructure.com/).

Homework Rules
I Show your work neatly.
I Ensure your homework is in the correct order (the order in which the problems
were assigned) before uploading to Canvas. Make sure that your name, section
# as well as assignment # is written on the first page.
I If you feel that some parts of a graded assignment should be regraded, please
come to me within 2 weeks of getting back your assignment.

Admin
I All questions regarding course registration and waitlist should be asked to the
Student Services Office in 2082 East Hall. We will do our best to get you into a
section of the course which has space.

2 / 18
Course basics

Matlab
I There will be homework assignments that need the help of Matlab, such as
running or writing codes.
I Instructions on getting Matlab at no cost could be found at http://caenfaq.
engin.umich.edu/software-for-students/Matlab-for-students.

3 / 18
Course basics

Matlab
I There will be homework assignments that need the help of Matlab, such as
running or writing codes.
I Instructions on getting Matlab at no cost could be found at http://caenfaq.
engin.umich.edu/software-for-students/Matlab-for-students.
I There are also alternative online analogues of Matlab, by simply searching
“Matlab online”, such as
https://www.tutorialspoint.com/execute_matlab_online.php. However,
these online analogues may not be as powerful as Matlab. For example, if you
want to round a number 1.3456 to the first decimal place, you may run the code
“round(1.3456,1)”. Matlab will give you the answer 1.3, while the above online
tool will give you an error, which means you have to run the code
“round(1.3456*10)/10” instead.

3 / 18
Course basics

Matlab
I There will be homework assignments that need the help of Matlab, such as
running or writing codes.
I Instructions on getting Matlab at no cost could be found at http://caenfaq.
engin.umich.edu/software-for-students/Matlab-for-students.
I There are also alternative online analogues of Matlab, by simply searching
“Matlab online”, such as
https://www.tutorialspoint.com/execute_matlab_online.php. However,
these online analogues may not be as powerful as Matlab. For example, if you
want to round a number 1.3456 to the first decimal place, you may run the code
“round(1.3456,1)”. Matlab will give you the answer 1.3, while the above online
tool will give you an error, which means you have to run the code
“round(1.3456*10)/10” instead.
I Appendix B in the textbook gives a brief introduction to Matlab’s commands and
features.
I Matlab has a very powerful and friendly user help system. You could either
search your question online or type “help XYZ” in Matlab, where XYZ is any
function name that you want to get help on.

3 / 18
Before we start
Why do we have to take this course and learn the required topics on Numerical
Methods with Financial Applications?

4 / 18
Before we start
Why do we have to take this course and learn the required topics on Numerical
Methods with Financial Applications?
I I will do research on theories, instead of working on numerical analysis, in and
after the graduate school.

4 / 18
Before we start
Why do we have to take this course and learn the required topics on Numerical
Methods with Financial Applications?
I I will do research on theories, instead of working on numerical analysis, in and
after the graduate school.
I I will find a job in banks, factories, insurance/IT/... companies, etc.

4 / 18
Before we start
Why do we have to take this course and learn the required topics on Numerical
Methods with Financial Applications?
I I will do research on theories, instead of working on numerical analysis, in and
after the graduate school.
I I will find a job in banks, factories, insurance/IT/... companies, etc.
I People have already got many software products and function packages. I could
just use them.

4 / 18
Before we start
Why do we have to take this course and learn the required topics on Numerical
Methods with Financial Applications?
I I will do research on theories, instead of working on numerical analysis, in and
after the graduate school.
I I will find a job in banks, factories, insurance/IT/... companies, etc.
I People have already got many software products and function packages. I could
just use them.

Example 1: Integral calculation


Consider a Black-Scholes model with a risk-free asset and a stock. Assume that the
stock price is S = $51, the interest rate is r = 11% compounded continuously, and
the stock volatility is = 25%. What is the price of a European call option on the
stock with the strike price X = $49 and maturity of 3 months (T = 0.25 years)?

4 / 18
Before we start
Why do we have to take this course and learn the required topics on Numerical
Methods with Financial Applications?
I I will do research on theories, instead of working on numerical analysis, in and
after the graduate school.
I I will find a job in banks, factories, insurance/IT/... companies, etc.
I People have already got many software products and function packages. I could
just use them.

Example 1: Integral calculation


Consider a Black-Scholes model with a risk-free asset and a stock. Assume that the
stock price is S = $51, the interest rate is r = 11% compounded continuously, and
the stock volatility is = 25%. What is the price of a European call option on the
stock with the strike price X = $49 and maturity of 3 months (T = 0.25 years)?

In Math 423, we learnt the formula C E = SN (d1 ) Xe rT N (d2 ). Here


Z y
1 2
N (y) = p e x /2 dx for any real number y.
1 2⇡

4 / 18
Before we start
Why do we have to take this course and learn the required topics on Numerical
Methods with Financial Applications?
I I will do research on theories, instead of working on numerical analysis, in and
after the graduate school.
I I will find a job in banks, factories, insurance/IT/... companies, etc.
I People have already got many software products and function packages. I could
just use them.

Example 1: Integral calculation


Consider a Black-Scholes model with a risk-free asset and a stock. Assume that the
stock price is S = $51, the interest rate is r = 11% compounded continuously, and
the stock volatility is = 25%. What is the price of a European call option on the
stock with the strike price X = $49 and maturity of 3 months (T = 0.25 years)?

In Math 423, we learnt the formula C E = SN (d1 ) Xe rT N (d2 ). Here


Z y
1 2
N (y) = p e x /2 dx for any real number y.
1 2⇡
R 2
Integrals of the form ab e x dx are required for given a and b in many problems of
probability, math finance and statistics. The technique of finding the antiderivative
2
F (x) of e x , and then computing F (b) F (a) does not work here. F (x) cannot be
expressed in terms of any combinations of trigonometric, exponential, logarithmic or
algebraic functions.
4 / 18
Before we start

Example 2: Solving systems of equations


A classic interview topic for bank, hedge fund, or IT positions is the Markov Chain.
Suppose Ruoyu and Ingrid are betting on tossing a fair coin until certain outcomes
appear. The following are some possible rules. Who has the advantage under each
rule?
(1) Ruoyu wins if a head (H) comes first, while Ingrid wins if a tail (T) comes first.

5 / 18
Before we start

Example 2: Solving systems of equations


A classic interview topic for bank, hedge fund, or IT positions is the Markov Chain.
Suppose Ruoyu and Ingrid are betting on tossing a fair coin until certain outcomes
appear. The following are some possible rules. Who has the advantage under each
rule?
(1) Ruoyu wins if a head (H) comes first, while Ingrid wins if a tail (T) comes first.
(2) Ruoyu wins if HH comes first, while Ingrid wins if TH comes first.

5 / 18
Before we start

Example 2: Solving systems of equations


A classic interview topic for bank, hedge fund, or IT positions is the Markov Chain.
Suppose Ruoyu and Ingrid are betting on tossing a fair coin until certain outcomes
appear. The following are some possible rules. Who has the advantage under each
rule?
(1) Ruoyu wins if a head (H) comes first, while Ingrid wins if a tail (T) comes first.
(2) Ruoyu wins if HH comes first, while Ingrid wins if TH comes first.
(3) Ruoyu wins if HHT comes first, while Ingrid wins if THT comes first.

5 / 18
Before we start

Example 2: Solving systems of equations


A classic interview topic for bank, hedge fund, or IT positions is the Markov Chain.
Suppose Ruoyu and Ingrid are betting on tossing a fair coin until certain outcomes
appear. The following are some possible rules. Who has the advantage under each
rule?
(1) Ruoyu wins if a head (H) comes first, while Ingrid wins if a tail (T) comes first.
(2) Ruoyu wins if HH comes first, while Ingrid wins if TH comes first.
(3) Ruoyu wins if HHT comes first, while Ingrid wins if THT comes first.
(4) Ruoyu wins if HHHTHTTT comes first, while Ingrid wins if TTHHTTHH comes
first.

5 / 18
Before we start

Example 2 continued: .

6 / 18
Before we start

Example 2 continued: .

Even though you know algorithms...


Well, even simple algorithms, such as methods for solving di↵erential equations, can
magnify microscopic errors to macroscopic size. It will be important to recognize when
a calculation is at risk of being unreliable due to magnification of the small errors
made by digital computers and to know how to avoid or minimize the risk.

6 / 18
Let us get started

Chapter 0 Fundamentals

7 / 18
0.1 Evaluating a polynomial

Question: What is the best way to evaluate

P (x) = 2x4 + 3x3 3x2 + 5x 1


1
at x = 2
in the computer?
This might look simple, but serves as a good starting point and illustration.

8 / 18
0.1 Evaluating a polynomial

Question: What is the best way to evaluate

P (x) = 2x4 + 3x3 3x2 + 5x 1


1
at x = 2
in the computer?
This might look simple, but serves as a good starting point and illustration.
Assume that the coefficients of the polynomial and the number 12 are stored in
memory, and try to minimize the number of additions and multiplications
required to get P ( 12 ). To simplify matters, we will not count time spent storing
and fetching numbers to and from memory.

8 / 18
0.1 Evaluating a polynomial

Question: What is the best way to evaluate

P (x) = 2x4 + 3x3 3x2 + 5x 1


1
at x = 2
in the computer?
This might look simple, but serves as a good starting point and illustration.
Assume that the coefficients of the polynomial and the number 12 are stored in
memory, and try to minimize the number of additions and multiplications
required to get P ( 12 ). To simplify matters, we will not count time spent storing
and fetching numbers to and from memory.
Method 1:
1 1 1 1 1 1 1 1 1 1 1 5
P( ) = 2 ⇤ ⇤ ⇤ ⇤ + 3 ⇤ ⇤ ⇤ 3⇤ ⇤ +5⇤ 1= .
2 2 2 2 2 2 2 2 2 2 2 4
There are 10 multiplications and 4 additions (or subtractions, viewed as adding
a negative stored number).

8 / 18
0.1 Evaluating a polynomial

Question: What is the best way to evaluate

P (x) = 2x4 + 3x3 3x2 + 5x 1


1
at x = 2
in the computer?
Method 2: Find the powers of the input number x = 12 first, and store them for
future use:
✓ ◆2 ✓ ◆2 ✓ ◆3 ✓ ◆3 ✓ ◆4
1 1 1 1 1 1 1 1 1
⇤ = , ⇤ = , ⇤ = .
2 2 2 2 2 2 2 2 2

9 / 18
0.1 Evaluating a polynomial

Question: What is the best way to evaluate

P (x) = 2x4 + 3x3 3x2 + 5x 1


1
at x = 2
in the computer?
Method 2: Find the powers of the input number x = 12 first, and store them for
future use:
✓ ◆2 ✓ ◆2 ✓ ◆3 ✓ ◆3 ✓ ◆4
1 1 1 1 1 1 1 1 1
⇤ = , ⇤ = , ⇤ = .
2 2 2 2 2 2 2 2 2
Then we add up the terms:
✓ ◆4 ✓ ◆3 ✓ ◆2
1 1 1 1 1 5
P( ) = 2 ⇤ +3⇤ 3⇤ +5⇤ 1= .
2 2 2 2 2 4
There are 7 multiplications and 4 additions.

9 / 18
0.1 Evaluating a polynomial
Question: What is the best way to evaluate
P (x) = 2x4 + 3x3 3x2 + 5x 1
1
at x = 2
in the computer?
Method 3: (Nested Multiplication or Horner’s method) Rewrite the polynomial
backwards and factor out x successively, so that it can be evaluated from the
inside out:
P (x) = 1 + 5x 3x2 + 3x3 + 2x4
= 1 + x(5 3x + 3x2 + 2x3 )
= 1 + x(5 + x( 3 + 3x + 2x2 ))
= 1 + x(5 + x( 3 + x(3 + 2x)))
= 1 + x ⇤ (5 + x ⇤ ( 3 + x ⇤ (3 + 2 ⇤ x))).

10 / 18
0.1 Evaluating a polynomial
Question: What is the best way to evaluate
P (x) = 2x4 + 3x3 3x2 + 5x 1
1
at x = 2
in the computer?
Method 3: (Nested Multiplication or Horner’s method) Rewrite the polynomial
backwards and factor out x successively, so that it can be evaluated from the
inside out:
P (x) = 1 + 5x 3x2 + 3x3 + 2x4
= 1 + x(5 3x + 3x2 + 2x3 )
= 1 + x(5 + x( 3 + 3x + 2x2 ))
= 1 + x(5 + x( 3 + x(3 + 2x)))
= 1 + x ⇤ (5 + x ⇤ ( 3 + x ⇤ (3 + 2 ⇤ x))).
Now evaluate from the inside out:
1 1
⇤ 2, add + 3 ! 4,
multiply multiply ⇤ 4, add 3! 1,
2 2
1 9 1 9 5
multiply ⇤ ( 1), add + 5 ! , multiply ⇤ , add 1! .
2 2 2 2 4
There are 4 multiplications and 4 additions.
10 / 18
0.1 Evaluating a polynomial

A degree d polynomial can be evaluated in d multiplications and d additions:

c1 + c2 x + c3 x2 + c4 x3 + c5 x4 = c1 + x(c2 + x(c3 + x(c4 + x(c5 )))).

11 / 18
0.1 Evaluating a polynomial

A degree d polynomial can be evaluated in d multiplications and d additions:

c1 + c2 x + c3 x2 + c4 x3 + c5 x4 = c1 + x(c2 + x(c3 + x(c4 + x(c5 )))).

Some applications may require a more general form, e.g., the interpolation
calculations in Chapter 3 requires the form

c1 + (x r1 )(c2 + (x r2 )(c3 + (x r3 )(c4 + (x r4 )(c5 )))),

where r1 , r2 , r3 , r4 are called the base points.


The Matlab file nest.m implements the general form of nested multiplication.

11 / 18
0.1 Evaluating a polynomial

Example 0.1
Find an efficient method for evaluating the polynomial

P (x) = 4x5 + 7x8 3x11 + 2x14 .

12 / 18
0.2 Binary numbers

Binary (base 2) numbers are expressed as

. . . b2 b1 b0 .b 1 b 2 ...,

where each binary digit, or bit, is 0 or 1.

13 / 18
0.2 Binary numbers

Binary (base 2) numbers are expressed as

. . . b2 b1 b0 .b 1 b 2 ...,

where each binary digit, or bit, is 0 or 1.


The base 10 (decimal numbers) equivalent to the number is

. . . b2 2 2 + b 1 2 1 + b 0 2 0 + b 12
1
+b 22
2
... .

For example, the decimal number 4 is expressed as (100.)2 in base 2, and 3/4
is represented as (0.11)2 .

13 / 18
0.2 Binary numbers

Binary (base 2) numbers are expressed as

. . . b2 b1 b0 .b 1 b 2 ...,

where each binary digit, or bit, is 0 or 1.


The base 10 (decimal numbers) equivalent to the number is

. . . b2 2 2 + b 1 2 1 + b 0 2 0 + b 12
1
+b 22
2
... .

For example, the decimal number 4 is expressed as (100.)2 in base 2, and 3/4
is represented as (0.11)2 .
Question: How to convert decimal to binary? E.g. (53.7)10 = (?)2

13 / 18
0.2.1 Decimal to binary

It is simplest to break the decimal number into integer and fractional parts and
then convert each part separately. Write (53.7)10 = (53)10 + (0.7)10 .

14 / 18
0.2.1 Decimal to binary

It is simplest to break the decimal number into integer and fractional parts and
then convert each part separately. Write (53.7)10 = (53)10 + (0.7)10 .
Integer part: Convert decimal integers to binary by dividing by 2 successively
and recording the remainders. The remainders, 0 or 1, are recorded by starting
at the decimal point (or more accurately, radix) and moving away (to the left).
For (53)10 , we would have
.

14 / 18

You might also like