Seminar 4 Optimisation

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 25

Foundations in Calculus

and Probability
YU SHENG LOH
Optimisation
Optimisation
Maximising or minimising a given function
◦ Unconstrained
◦ Constrained

Unconstrained
◦ Maximisation is about finding the largest possible value of the function
◦ Minimisation about finding the smallest possible value
◦ And the input of the function that is associated with this value

Constrained
◦ Finding the maximum or minimum value of the function
◦ Subject to a given set of constraints on the inputs
Unconstrained Optimisation
Finding the maximum or minimum of a function 𝑦 = 𝑓(𝑥)

!"
To do so, we set =0
!#

At the maximum or minimum, there is no rate of change


to the function
Tangent can be found at any point of the curve
At maximum or minimum point, slope of tangent = 0
𝑥
Unconstrained Optimisation
Checking for a maximum or minimum point 𝑦 = 𝑓(𝑥)

!' "
To do so, we find !#'

!' " !' "


If < 0, then it is a maximum point and if > 0,
!#' !#'
then it is a minimum
Slope of the tangent decreases as it approaches the
maximum => rate of change of the first derivative is
decreasing
𝑥

Vice versa for minimum point


Unconstrained Optimisation
Find the maximum and/or minimum points of the function 𝑓 𝑥 = 𝑥 $ − 2𝑥 %

!&
= 4𝑥 ' − 4𝑥
!#
= 4𝑥(𝑥 % − 1)
= 4𝑥(𝑥 + 1)(𝑥 − 1)
=0

𝑥 = 0, 1, 𝑜𝑟 − 1
Unconstrained Optimisation
To check if it is a maximum or minimum point, we check the second derivative of the function
!' &
!#'
= 12𝑥 % − 4

When 𝑥 = 0 𝑥=1 𝑥 = −1
!' & !' & !' &
= −4 < 0 =8>0 =8>0
!#' !#' !#'
It is a maximum point minimum point minimum point
𝑓 0 =0 𝑓 1 = −1 𝑓 −1 = −1
Constrained Optimisation
Optimisation with one or more constraints included
◦ Typically involving two or more variables

Find the maximum and/or minimum points of the function 𝑓 𝑥, 𝑦 = 𝑥 % 𝑦 − 2𝑥𝑦 % , subject to
the constraint 𝑥 + 𝑦 = 0.6

(& (&
= 2𝑥𝑦 − 2𝑦 % = 0, = 𝑥 % − 4𝑥𝑦 = 0
(# ("
Constrained Optimisation
Rewriting the expressions
(& (&
+2 = 𝑥 % − 4𝑥𝑦 + 4𝑥𝑦 − 4𝑦 % = 0
(" (#

𝑥 % − 4𝑦 % = 0
𝑥 + 2𝑦 𝑥 − 2𝑦 = 0
𝑥 = 2𝑦 𝑜𝑟 − 2𝑦
Constrained Optimisation
Subject to constraint 𝑥 + 𝑦 = 0.6

When 𝑥 = 2𝑦 when 𝑥 = −2𝑦


2𝑦 + 𝑦 = 0.6 −2𝑦 + 𝑦 = 0.6
3𝑦 = 0.6 −𝑦 = 0.6
𝑦 = 0.2 𝑦 = −0.6
𝑥 = 0.4 𝑥 = 1.2
𝑓 𝑥, 𝑦 = 0 𝑓 𝑥, 𝑦 = −1.728
Example in Finance
Minimising the variance of a portfolio of two risky assets
Consider the following two assets:
Asset A that has a return of 5% and a standard deviation of returns of 4%
Asset B that has a return of 8% and a standard deviation of returns of 6%
The two assets have a correlation of 0.4

Suppose that an investor has to invest all his money into these two assets and he only cares
about returns and the standard deviation of returns. What should be the allocation between the
two assets?
Example in Finance
Let 𝑥) be the proportion of wealth invested in Asset A and 𝑥* be the proportion of wealth
invested in Asset B

Variance of portfolio containing assets A and B


𝜎+% = 𝑥)% 𝜎)% + 𝑥*% 𝜎*% + 2𝑥) 𝑥* 𝜎)*

To suit this investor’s needs, we need to minimise the variance of the portfolio, subject to the
constraint 𝑥) + 𝑥* = 1
Example in Finance
𝜎+% = 0.04% 𝑥)% + 0.06% 𝑥*% + 2(0.4)(0.04)(0.06)𝑥) 𝑥*
= 0.0016𝑥)% + 0.0036𝑥*% + 0.00192𝑥) 𝑥*

Expressing 𝑥* in terms of 𝑥)
𝜎+% = 0.0016𝑥)% + 0.0036 1 − 𝑥) % + 0.00192𝑥) (1 − 𝑥) )
= 0.0016𝑥)% + 0.0036 1 − 𝑥) % + 0.00192(𝑥) − 𝑥)% )
Example in Finance
To minimise the variance, we first differentiate it with respect to 𝑥)
!,('
= 2 ∗ 0.0016𝑥) + 2 ∗ (−1)0.0036(1 − 𝑥) ) + 0.00192 (1 − 2𝑥) )
!#)

= 0.0032𝑥) − 0.0072 1 − 𝑥) + 0.00192 − 0.00384𝑥)


= 0.0032𝑥) − 0.0072 + 0.0072𝑥) + 0.00192 − 0.00384𝑥)
= 0.00656𝑥) − 0.00528
=0
Example in Finance
Solving for 𝑥)
0.00656𝑥) − 0.00528 = 0
0.00656𝑥) = 0.00528
𝑥) = 0.804878
𝑥* = 0.195122

The investor should invest 80.4878% of his wealth in Asset A and 19.5122% in Asset B
This gives a portfolio return of 5.5854% and standard deviation of 4.6527%
Lagrange Multiplier
Method of finding local maxima and/or local minima of a function subject to a set of constraints
◦ Particularly useful in constrained optimisation that are more challenging

To find the optimal point of a function 𝑓(𝑥- , 𝑥% , … , 𝑥. ) subject to a set of 𝑚 constraints


𝑔- 𝑥- , 𝑥% , … , 𝑥. , … , 𝑔/ 𝑥- , 𝑥% , … , 𝑥. = 0, first set up the Lagrangian function ℒ as follows

ℒ 𝑥- , 𝑥% , … , 𝑥. , 𝜆- , … , 𝜆/ = 𝑓 𝑥- , 𝑥% , … , 𝑥. − 𝜆- 𝑔- 𝑥- , 𝑥% , … , 𝑥. − ⋯ − 𝜆/ 𝑔/ 𝑥- , 𝑥% , … , 𝑥.

Next, find the partial derivatives of the Lagrangian function with respect to all the variables and
set them equal to 0
Solve for the variables
Lagrange Multiplier
Optimise 𝑓 𝑥, 𝑦 = 𝑥 % + 𝑦 % subject to the constraint 𝑥𝑦 = 4

Formulate the Lagrangian function


ℒ = 𝑥 % + 𝑦 % − 𝜆(𝑥𝑦 − 4)

Find the partial derivatives


(ℒ (ℒ (ℒ
= 2𝑥 − 𝜆𝑦 = 0 = 2𝑦 − 𝜆𝑥 = 0 = 𝑥𝑦 − 4 = 0
(# (" (1
Lagrange Multiplier
Using the first two partial derivatives
2𝑥 = 𝜆𝑦 2𝑦 = 𝜆𝑥

%# 1"
= Substituting the values back into the constraint
%" 1#
# "
"
=# 𝑥 𝑥 =4

𝑥% = 𝑦% 𝑥% = 4
𝑥=𝑦 𝑥 = ±2, 𝑦 = ±2
𝑓 𝑥, 𝑦 = 8
Example in Finance
Back to the example of an investor that requires a proportion of wealth 𝑥) to be invested in
Asset A and 𝑥* in Asset B
Minimise the variance of portfolio containing assets A and B
𝜎+% = 𝑥)% 𝜎)% + 𝑥*% 𝜎*% + 2𝑥) 𝑥* 𝜎)*
Subject to the constraint 𝑥) + 𝑥* = 1

Formulate the Lagrangian function


ℒ 𝑥) , 𝑥* , 𝜆 = 𝑥)% 𝜎)% + 𝑥*% 𝜎*% + 2𝑥) 𝑥* 𝜎)* − 𝜆(𝑥) + 𝑥* − 1)
Example in Finance
Find the partial derivatives with respect to all variables of the Lagrangian function and set them
equal to 0

(ℒ
= 2𝑥) 𝜎)% + 2𝑥* 𝜎)* − 𝜆
(#)
(ℒ
= 2𝑥* 𝜎*% + 2𝑥) 𝜎)* − 𝜆 =0
(#*
(ℒ
= 𝑥) + 𝑥* − 1
(1
Example in Finance
Subbing in the values of standard deviations and correlations given in the example, we have the
following equations

2 0.04 % 𝑥) + 2(0.4) 0.04 0.06 𝑥* − 𝜆 = 0.0032𝑥) + 0.00192𝑥* − 𝜆 = 0


2 0.06 % 𝑥* + 2(0.4) 0.04 0.06 𝑥) − 𝜆 = 0.0072𝑥* + 0.00192𝑥) − 𝜆 = 0
𝑥) + 𝑥* = 1
Example in Finance
Subtracting equation 1 from equation 2, eliminates 𝜆, giving us

0.0072𝑥* + 0.00192𝑥) − 𝜆 − 0.0032𝑥) − 0.00192𝑥* + 𝜆 = 0


0.00528𝑥* − 0.00128𝑥) = 0
Example in Finance
Using the relationship between 𝑥) and 𝑥* given in the constraint

0.00528𝑥* − 0.00128𝑥) = 0
0.00528(1 − 𝑥) ) − 0.00128𝑥) = 0
0.00528 − 0.00528𝑥) − 0.00128𝑥) = 0
0.00528 − 0.00656𝑥) = 0
0.00656𝑥) = 0.00528

𝑥) = 0.804878
Example in Finance
Minimum Variance Portfolio
-
𝑚𝑖𝑛 𝒘2 𝚺𝐰
%
Subject to 𝒘2 𝟏̇ = 1

𝜎-% 𝜎-% 𝜎-.


⋯ 𝜎%.
where 𝑤 = 𝑤- 𝑤% 𝑤' ⋯ 𝑤. 2 , Σ = 𝜎-% 𝜎%% , and 𝟏̇ = 1 ⋯ 1 2
⋮ ⋱ ⋮
𝜎-. 𝜎%. ⋯ 𝜎.%
Practice Questions
1. Find the optimal points of 𝑓 𝑥, 𝑦 = 𝑥 % + 𝑦 % − 2𝑥 − 6𝑦 subject to the constraint 𝑥 % + 𝑦 % =
10

2. Using the method of Lagrange multiplier, find the optimal points of 𝑓 𝑥, 𝑦 = 𝑥 % 𝑦 − 2𝑥𝑦 % ,
subject to the constraints 𝑥 + 𝑦 = 0.6 and 𝑥 % + 𝑦 = 2.6

You might also like