Mathematicalmethods Lecture Slides Week7 1 LagrangesMethod
description
Transcript of Mathematicalmethods Lecture Slides Week7 1 LagrangesMethod
-
AMATH 460: Mathematical Methodsfor Quantitative Finance
7.1 Lagranges Method
Kjell KonisActing Assistant Professor, Applied Mathematics
University of Washington
Kjell Konis (Copyright 2013) 7.1 Lagranges Method 1 / 29
-
Outline
1 Optimal Investment Portfolios
2 Relative Extrema of Functions of Several Variables
3 Lagranges Method
4 Example
5 Minimum Variance Portfolio
Kjell Konis (Copyright 2013) 7.1 Lagranges Method 2 / 29
-
Outline
1 Optimal Investment Portfolios
2 Relative Extrema of Functions of Several Variables
3 Lagranges Method
4 Example
5 Minimum Variance Portfolio
Kjell Konis (Copyright 2013) 7.1 Lagranges Method 3 / 29
-
Investment Portfolios
Portfolio of n assetsLet wi be the proportion of the portfolio invested in asset iHave constraint n
i=1wi = 1
Can take long and short positions = no constraints on individual wiLet i be the expected rate of return on asset iLet 2i be the risk of asset iLet ij be the correlation between assets i and jExpected rate of return and risk of the portfolio:
Expected Return =n
i=1wii
Risk =n
i=1w2i 2i + 2
1i
-
Investment Portfolios: Matrix Notation
Let w = (w1, . . . ,wn) and = (1, . . . , n)The expected rate of return can be written in matrix notation as
Return =n
i=1wii = wT
The risk can be written as
Risk = wTw
is the covariance matrix of the n assets
=
21 1212 1n1n2121 22 2n
... ... . . . ...n1n1 n2n2 2n
Kjell Konis (Copyright 2013) 7.1 Lagranges Method 5 / 29
-
Optimal Investment Portfolios
Given , , and investor selected w , can computeportfolio returnportfolio risk
Two notions of optimality
For a target expected return, choose w to minimize portfolio riskFor a target level of risk, choose w to maximize expected return
Both notions are constrained optimization problems that can besolved using Lagrange multipliers
Kjell Konis (Copyright 2013) 7.1 Lagranges Method 6 / 29
-
Optimal Investment Portfolios
Minimum variance optimization
n asset case
minimize: wTwsubject to: eTw = 1
Tw = P
2 asset caseminimize: 21w21 + 212w1w2 + 22w22
subject to: w1 + w2 = 11w1 + 2w2 = P
Maximum expected return optimization
n asset case
maximize: Twsubject to: eTw = 1
wTw = 2P
2 asset casemaximize: 1w1 + 2w2
subject to: w1 + w2 = 121w21 + 212w1w2 + 22w22 = 2P
Kjell Konis (Copyright 2013) 7.1 Lagranges Method 7 / 29
-
Outline
1 Optimal Investment Portfolios
2 Relative Extrema of Functions of Several Variables
3 Lagranges Method
4 Example
5 Minimum Variance Portfolio
Kjell Konis (Copyright 2013) 7.1 Lagranges Method 8 / 29
-
Relative Extrema of Single Variable Functions
A local minimum (maximum) of a function f is a point x0 where
f (x0) () f (x) x (x0 , x0 + )
for some > 0
A local extrema is a point that is a local minimum or maximum
If f is twice differentiable and f is continuousAny local extremum is a critical point of f : f (x0) = 0Can classify critical points using second derivative testf (x0) < 0 local maximumf (x0) > 0 local minimumf (x0) = 0 anything possible
Kjell Konis (Copyright 2013) 7.1 Lagranges Method 9 / 29
-
Relative Extrema of Functions of n Variables
A local minimum (maximum) of a function f : Rn R is a pointx0 Rn where
f (x0) () f (x) x : x x0 <
Every local extremum is a critical point: Df (x0) = 0
If f is twice differentiable and has continuous second order partialderivatives
D2f (x0) is a symmetric matrix with real eigenvaluesSecond order conditions
All eigenvalues of D2f (x0) > 0 local minimumAll eigenvalues of D2f (x0) < 0 local maximumD2f (x0) has eigenvalues saddle pointD2f (x0) singular anything can happen
Kjell Konis (Copyright 2013) 7.1 Lagranges Method 10 / 29
-
Finding Extrema: Functions of 2 Variables
Find the local extrema of f (x , y) = x2 + xy + y2
Df (x , y) =[2x + y x + 2y
]Df (0, 0) =
[0 0
] (0, 0) is a critical point
D2f (x , y) =[
2 11 2
]
Can use R to compute the eigenvalues> A eigen(A)$values[1] 3 1
Since both eigenvalues are greater than 0 = (0, 0) a local minimumKjell Konis (Copyright 2013) 7.1 Lagranges Method 11 / 29
-
Finding Extrema: Functions of 2 Variables (Take 2)
Find the local extrema of f (x , y) = x2 xy y2
Df (x , y) =[ 2x y x 2y] Df (0, 0) = [0 0]
(0, 0) is a critical point
D2f (x , y) =[2 11 2
]
Can use R to compute the eigenvalues> A eigen(A)$values[1] -1 -3
Since both eigenvalues are less than 0 = (0, 0) a local maximumKjell Konis (Copyright 2013) 7.1 Lagranges Method 12 / 29
-
Finding Extrema: Functions of 2 Variables
Find the local extrema of f (x , y) = x2 + 3xy + y2
Df (x , y) =[2x + 3y 3x + 2y
]Df (0, 0) =
[0 0
] (0, 0) is a critical point
D2f (x , y) =[
2 33 2
]
Can use R to compute the eigenvalues> A eigen(A)$values[1] 5 -1
One positive and one negative eigenvalue = (0, 0) a saddle pointKjell Konis (Copyright 2013) 7.1 Lagranges Method 13 / 29
-
Finding Extrema: Functions of 2 Variables
Find the local extrema of f (x , y) = 2xy (1 y2) 32First order condition
Df (x , y) =[
2y 2x + 3y
1 y2]
Df (0, 0) =[0 0
]= (0, 0) is a critical point
Second order condition
D2f (x , y) =
0 22 36y2
1y2
D2f (0, 0) = 0 2
2 3
Compute the eigenvalues of the Hessian at the critical point> eigen(matrix(c(0, 3, 3, 2), 2, 2))$values[1] 4.162278 -2.162278One positive and one negative eigenvalue = (0, 0) a saddle point
Kjell Konis (Copyright 2013) 7.1 Lagranges Method 14 / 29
-
Outline
1 Optimal Investment Portfolios
2 Relative Extrema of Functions of Several Variables
3 Lagranges Method
4 Example
5 Minimum Variance Portfolio
Kjell Konis (Copyright 2013) 7.1 Lagranges Method 15 / 29
-
Lagranges Method
Problem:maximize: f (x1, x2, . . . , xn)
subject to: g1(x1, x2, . . . , xn) = 0g2(x1, x2, . . . , xn) = 0
...gm(x1, x2, . . . , xn) = 0
(1)
18th-century mathematician Joseph Louis Lagrange proposed thefollowing method for the solutionForm the function
F (x1, . . . , xn, 1, . . . , m) = f (x1, . . . , xn) +mi=1
igi(x1, x2, . . . , xn)
Optimal value for problem (1) occurs at one of the critical points of FKjell Konis (Copyright 2013) 7.1 Lagranges Method 16 / 29
-
Lagranges Method
Terminology:The function F (x1, . . . , xn, 1, . . . , m) is called the LagrangianThe column vector = (1, . . . , m) is called the Lagrangemultipliers vector
Necessary Condition:Let x = (x1, x2, . . . , xn)Let g(x) =
(g1(x), g2(x), . . . , gm(x)
)be a vector-valued function
of the constraintsThe gradient D
(g(x)
)must have full rank at any point where
the constraint g(x) = 0 is satisfied, that is
rank(Dg(x)
)= m x where g(x) = 0
Kjell Konis (Copyright 2013) 7.1 Lagranges Method 17 / 29
-
Partial Derivatives of the Lagrangian
D F (x , ) has n + m variables, compute gradient in 2 parts
D F (x , ) =[DxF (x , ) DF (x , )
]Recall Lagrangian:
F (x , ) = f (x1, . . . , xn) +mi=1
igi(x1, x2, . . . , xn)
The partial derivatives are
Fxj
=fxj
+mi=1
igixj
Fi
= gi(x)
Gradient of f : Df (x) =[fx1
. . .fxn
]Kjell Konis (Copyright 2013) 7.1 Lagranges Method 18 / 29
-
Partial Derivatives of the Lagrangian
Gradient of g(x):
Dg(x) =
g1x1
g1x2
g1xn
g2x1
g2x2
g2xn
... ... . . . ...gmx1
gmx2
gmxn
Can express sum in second term in matrix notationmi=1
igixj
= T[Dg(x)
]j
It follows that
D F (x , ) =[Df (x) + TDg(x)
(g(x)
)T]Kjell Konis (Copyright 2013) 7.1 Lagranges Method 19 / 29
-
Outline
1 Optimal Investment Portfolios
2 Relative Extrema of Functions of Several Variables
3 Lagranges Method
4 Example
5 Minimum Variance Portfolio
Kjell Konis (Copyright 2013) 7.1 Lagranges Method 20 / 29
-
Example
Want tomax/min: 4x2 2x3
subject to: 2x1 x2 x3 = 0x21 + x22 13 = 0
Start by writing down the Lagrangian
F (x , ) = f (x) + 1g1(x) + 2g2(x)
= 4x2 2x3 + 1(2x1 x2 x3) + 2(x21 + x22 13)
Check necessary condition:
Dg(x) =[
2 1 12x1 2x2 0
]
Kjell Konis (Copyright 2013) 7.1 Lagranges Method 21 / 29
-
Derivatives of the LagrangianThe Lagrangian
F (x , ) = 4x2 2x3 + 1(2x1 x2 x3) + 2(x21 + x22 13)
Gradient of the Lagrangian
D F (x , ) =
21 + 22x1
4 1 + 22x22 1
2x1 x2 x3x21 + x22 13
T
Set D F (x , ) = 0 and solve for x and get 1 = 2 for free
21 + 22x1 set= 04 1 + 22x2 set= 0
2x1 x2 x3 set= 0x21 + x22 13 set= 0
Kjell Konis (Copyright 2013) 7.1 Lagranges Method 22 / 29
-
Example (continued)
A little algebra gives
x1 =22
x2 =32
x3 =72
Also know that
x21 +x22 = 13 =( 22
)2+
(32
)2=
1322
= 13 = 2 = 1
The critical points are = (2,1), x = (2, 3,7), f (x) = 26 = (2, 1), x = (2,3, 7), f (x) = 26
Kjell Konis (Copyright 2013) 7.1 Lagranges Method 23 / 29
-
Outline
1 Optimal Investment Portfolios
2 Relative Extrema of Functions of Several Variables
3 Lagranges Method
4 Example
5 Minimum Variance Portfolio
Kjell Konis (Copyright 2013) 7.1 Lagranges Method 24 / 29
-
Minimum Variance Portfolio
Recall: minimum variance portfolio optimization
minimize: wTwsubject to: eTw = 1
Tw = PLagranges method setup
f (w) = wTw
g(w) =[g1(w)g2(w)
]=
[Tw P = 0eTw 1 = 0
]
First, check necessary condition
Dg(x) =[T
eT
]
Kjell Konis (Copyright 2013) 7.1 Lagranges Method 25 / 29
-
Derivative of a Quadratic Form
Let A =[a bb c
]
Let f (x) = xTAx = ax21 + 2bx1x2 + cx22Then Df (x) =
[2ax1 + 2bx2 2bx1 + 2cx2
]= 2xTA
In general, let A be an n n symmetric matrixThe derivative (gradient) of the quadratic form f (x) = xTAx is
Df (x) = 2xTA
Kjell Konis (Copyright 2013) 7.1 Lagranges Method 26 / 29
-
Minimum Variance Portfolio
The Lagrangian
F (y , ) = wTw + 1[eTw 1]+ 2[Tw P]
Gradient of the Lagrangian
D F (w , ) =[Df (w) + T
(Dg(w)
) (g(w)
)T]=
[2wT + 1eT + 2T eTw 1 Tw P
]Find the critical point by solving the linear system2 e eT 0 0
T 0 0
w12
= 01P
Kjell Konis (Copyright 2013) 7.1 Lagranges Method 27 / 29
-
Minimum Variance Portfolio
Further reading:Second order conditions, e.g., Theorem 9.2 and Corollary 9.1 inPFME
Kjell Konis (Copyright 2013) 7.1 Lagranges Method 28 / 29
-
http://computational-finance.uw.edu
Kjell Konis (Copyright 2013) 7.1 Lagranges Method 29 / 29
Optimal Investment PortfoliosRelative Extrema of Functions of Several VariablesLagrange's MethodExampleMinimum Variance Portfolio