You are on page 1of 21

Foundations in Calculus

and Probability
YU SHENG LOH
Functions and
Introduction to Calculus
What is a Function
A function is a mapping of one element of a set to another
If X is mapped to Y then for each X, there can only be one Y
◦ E.g. 𝑦 = 𝑥 + 1

There can, however, be multiple Xs for each Y


◦ E.g. 𝑦 = 𝑥 2

Notations of functions of 𝑥
◦ Normally written as 𝑓 𝑥 , 𝑔 𝑥 , ℎ 𝑥
◦ 𝑓 𝑥 = 𝑥, 𝑔 𝑥 = 𝑥 2 , ℎ 𝑥 = 𝑥 2 + 𝑥
Types of Functions
Linear
◦ 𝑓 𝑥 = 3𝑥 + 4

Exponential
◦ 𝑓 𝑥 = 2𝑥 3 , 𝑔 𝑥 = 𝑒 𝑥

Logarithmic
◦ 𝑓 𝑥 = ln(𝑥), ℎ 𝑥 = log(𝑥)

Trigonometric
◦ 𝑓 𝑥 = sin(𝑥), 𝑔 𝑥 = cos(𝑥), ℎ 𝑥 = tan(𝑥)

Polynomial
◦ 𝑓 𝑥 = 2𝑥 2 + 3𝑥 + 4, g 𝑥 = 𝑥 3 + 3𝑥 2 + 𝑥 − 2
Function of a Function
Written as 𝑓 𝑓 𝑥 = 𝑓 2 (𝑥)
◦ Not to be confused with 𝑓(𝑥) 2

𝑓 𝑥 =𝑥+2
𝑔 𝑥 = 2𝑥 2 + 3𝑥 + 4

𝑓2 𝑥 = 𝑓 𝑥 + 2 𝑔 𝑓 𝑥 = 𝑔(𝑥 + 2)
= 𝑥+2 +2=𝑥+4 = 2(𝑥 + 2)2 + 3 𝑥 + 2 + 4
𝑓(𝑥) 2 = (𝑥 + 2)2 = 2 𝑥 2 + 4𝑥 + 4 + 3𝑥 + 6 + 4
= 𝑥 2 +4𝑥 + 4 = 2𝑥 2 + 8𝑥 + 8 + 3𝑥 + 10
= 2𝑥 2 + 11𝑥 + 18
Inverse of a Function
Written as 𝑓 −1 (𝑥)
1
◦ Not to be confused with 𝑓(𝑥)

For 𝑓 𝑥 = 3𝑥 + 2 𝑓 −1 𝑓 𝑥 = 𝑓 𝑓 −1 𝑥 =𝑥

𝑥−2 3𝑥+2 −2
𝑦 = 3𝑥 + 2 𝑓 𝑓 −1 𝑥 =3 +2 𝑓 −1 𝑓 𝑥 =
3 3
3𝑥
𝑦 − 2 = 3𝑥 =𝑥−2+2 =
3
𝑦−2
=𝑥 =𝑥 =𝑥
3
𝑥−2
𝑓 −1 𝑥 =
3
Linear Interpolation
Approximation of 𝑓(𝑥 + ℎ1 ), given values of 𝑥, ℎ1 , ℎ2 , 𝑓(𝑥), and 𝑓(𝑥 + ℎ2 ), where ℎ1 < ℎ2
Assumes linear relationship
𝑦 = 𝑓(𝑥)
𝑓 𝑥 + ℎ1 − 𝑓(𝑥) 𝑓 𝑥 + ℎ2 − 𝑓(𝑥)
=
𝑥 + ℎ1 − 𝑥 𝑥 + ℎ2 − 𝑥
𝑓 𝑥 + ℎ1 − 𝑓(𝑥) 𝑓 𝑥 + ℎ2 − 𝑓(𝑥)
=
ℎ1 ℎ2
ℎ2 𝑓 𝑥 + ℎ1 − 𝑓 𝑥 = ℎ1 (𝑓 𝑥 + ℎ2 − 𝑓(𝑥))
ℎ2 𝑓 𝑥 + ℎ1 = ℎ1 𝑓 𝑥 + ℎ2 + ℎ2 − ℎ1 𝑓(𝑥)

ℎ1 𝑓 𝑥+ℎ2 + ℎ2 −ℎ1 𝑓(𝑥)


𝑓 𝑥 + ℎ1 = ℎ2

𝑥 𝑥 + ℎ1 𝑥 + ℎ2
Linear interpolation
Given 𝑓 𝑥 = 𝑥 2 + 2𝑥, 𝑓 2 = 8, and 𝑓 2.5 = 11.25, find 𝑓(2.2)
h1 = cherche-petit
h2 = Grand - petit
ℎ1 𝑓 𝑥+ℎ2 + ℎ2 −ℎ1 𝑓(𝑥)
𝑓 𝑥 + ℎ1 = 𝑓 2.2 = 2.22 + 2(2.2)
ℎ2
0.2 11.25 +0.3(8)
𝑓 2.2 = = 9.24
0.5

= 9.3
Example in Finance
Bond
◦ Financial instrument that provides
◦ Stream of regular payments
◦ Final payment upon maturity
◦ For an initial investment

+𝑃𝑎𝑟
Example in Finance
Time value of money
◦ $1 in the future is not worth the same as $1 worth today
◦ We have to take into account interest rates
◦ To do so, we discount a future cash flow by an interest rate
121
◦ E.g. if interest rates are 10% per annum, then $121 in two years would be worth $100 today 1.1 2

Price of a bond is the sum of its discounted future cash flows

𝐶𝐹1 𝐶𝐹2 𝐶𝐹3 𝐶𝐹𝑇 +𝑃𝑎𝑟


𝑃= + + + ⋯+
1+𝑟 (1+𝑟)2 (1+𝑟)3 (1+𝑟)𝑇
Example in Finance
3 year 5% coupon bond with $1,000 par value priced at $960
◦ Time to maturity of 3 years
◦ $1,000 paid at the end of 3 years
◦ $50 of interest payments at the end of every year
◦ Present value of $960

What is the return of this investment?

𝑓(𝑟) = 50(1 + 𝑟)−1 +50(1 + 𝑟)−2 +1050(1 + 𝑟)−3

Find 𝑟 ∗ such that 𝑓 𝑟 ∗ = 960


Example in Finance
At 6% At 7%
𝑓 0.06 = 973.27 𝑓 0.07 = 947.51

ℎ1 𝑓 𝑥+ℎ2 + ℎ2 −ℎ1 𝑓(𝑥)


𝑓 𝑥 + ℎ1 =
ℎ2
ℎ1 (947.51)+ 0.01−ℎ1 973.27
960 = 𝑟 ∗ = 0.06 + 0.005151
0.01

9.6 = ℎ1 947.51 − 973.27 + 9.7327 = 6.5151%


0.1327 = 25.76ℎ1
ℎ1 = 0.005151 Actual answer: 6.5106%
Example in Finance
At 5% At 8%
𝑓 0.05 = 1000 𝑓 0.08 = 922.69

ℎ1 𝑓 𝑥+ℎ2 + ℎ2 −ℎ1 𝑓(𝑥)


𝑓 𝑥 + ℎ1 =
ℎ2
ℎ1 (922.69)+ 0.03−ℎ1 1000
960 = 𝑟 ∗ = 0.05 + 0.015522
0.03

28.8 = ℎ1 922.69 − 1000 + 30 = 6.5522%


1.2 = 77.31ℎ1
ℎ1 = 0.015522 Actual answer: 6.5106%
Example in Finance
At 2% At 11%
𝑓 0.02 = 1086.52 𝑓 0.11 = 853.38

ℎ1 𝑓 𝑥+ℎ2 + ℎ2 −ℎ1 𝑓(𝑥)


𝑓 𝑥 + ℎ1 =
ℎ2
ℎ1 (853.38)+ 0.09−ℎ1 1086.52
960 = 𝑟 ∗ = 0.02 + 0.04885
0.09

86.4 = ℎ1 853.38 − 1086.52 + 97.79 = 6.885%


11.39 = 233.14ℎ1
ℎ1 = 0.04885 Actual answer: 6.5106%
Linear Interpolation
The greater the difference between the start and end guesses, the less accurate the interpolated
value
𝑦 = 𝑓(𝑥)
In the example, function has a convex nature
◦ Overestimates the value over a larger difference

Conversely, for a concave function


◦ Underestimates the value over large differences

𝑥 𝑥 + ℎ1 𝑥 + ℎ2
Introduction to Calculus
Differentiation
◦ Rate of change of a function 𝑦 = 𝑓(𝑥)
◦ What is the change from 𝑓(𝑥) to 𝑓 𝑥 + ℎ1
◦ Where ℎ1 is infinitesimally small
◦ Finding the slope of the curve at one point
𝑑𝑓(𝑥) 𝑑𝑦
◦ Written as , ,
𝑑𝑥 𝑑𝑥
or 𝑓 ′ (𝑥)

E.g.
◦ Rate at which distance changes over time is speed
◦ Rate at which speed changes over time is acceleration 𝑥

◦ Change in the price of a bond given a change in interest rates


Introduction to Calculus
Integration
◦ Inverse of differentiation
◦ What is the total change from 𝑓(𝑎) to 𝑓 𝑏 𝑦 = 𝑓(𝑥)

◦ Finding the area under the curve between two points


◦ E.g. speed tells us the distance travelled in a given amount of time
◦ 𝐹(𝑥), where 𝐹 ′ 𝑥 = 𝑓(𝑥)

Indefinite integral
◦ ‫𝑥𝑑 𝑥 𝑓 ׬‬

Definite integral 𝑥
𝑏
◦ ‫𝑥𝑑 𝑥 𝑓 𝑎׬‬
Taylor Series
Provides an approximation of a function 𝑓(𝑥) around a given point 𝑎
′ 𝑓′′ 𝑎 2 𝑓′′′ 𝑎
𝑓 𝑥 =𝑓 𝑎 +𝑓 𝑎 𝑥−𝑎 + (𝑥 − 𝑎) + (𝑥 − 𝑎)3 + ⋯
2! 3!

∞ 𝑓 𝑛 (𝑎)
= σ𝑛=0 (𝑥 − 𝑎)𝑛
𝑛!

When 𝑎 = 0 it is a Maclaurin series


𝑓′′ 𝑎 𝑓′′′ 𝑎
𝑓 𝑥 =𝑓 0 + 𝑓′ 0 𝑥+ 𝑥2 + 𝑥3 + ⋯
2! 3!

∞ 𝑓 𝑛 (0) 𝑛
= σ𝑛=0 𝑥
𝑛!
Taylor Series
Calculate 𝑒 0.1
𝑑𝑒 𝑥
= 𝑒 𝑥 , 𝑒0 = 1
𝑑𝑥

Using a Maclaurin series


0.1 𝑒0 2 𝑒
0
𝑒 = 𝑒 + 𝑒 0.1 + (0.1) + (0.1)3 + ⋯
0 0
2! 3!
0.12 0.13 0.14
= 1 + 0.1 + 2 + 6 + 24 + ⋯ Actual answer: 1.10517091808
= 1.1 + 0.005 + 0.00016667 + 0.00000416667
= 1.105 + 0.00016667 + 0.00000416667
= 1.105170833
Example in Finance
Bond pricing changes with interest rates
Investors are often interested in how the value of their investment will change given a change in
interest rates
Instead of calculating a range of values, investors can estimate the change based on
◦ First derivative of bond price with respect to interest rates is Modified Duration
◦ Second derivative of bond price with respect to interest rates is Convexity

1
%∆𝑃 = −𝑀𝑜𝑑𝑖𝑓𝑖𝑒𝑑 𝐷𝑢𝑟𝑎𝑡𝑖𝑜𝑛 ∗ ∆𝑟 + 𝐶𝑜𝑛𝑣𝑒𝑥𝑖𝑡𝑦 ∗ (∆𝑟)2
2
Practice Questions
1
1. Find the inverse of 𝑓 𝑥 =
(𝑥+3)

2. Find the inverse of 𝑔 𝑥 = 𝑥 2 − 2𝑥 + 1

3. What is the rate of return of a 3 year 7% coupon bond with $1,000 par value priced at $955?

You might also like