Sei sulla pagina 1di 2

Differentiation with vectors and matrices

Erik Kole
September 6, 2010

In the course Asset Pricing we will often differentiate functions of vectors and matrices.
Typically these functions have a linear or a quadratic form. An example of a linear function
is the return of a portfolio of n assets. For the portfolio return we write rp , while we use r
to denote the vector with the returns of the n assets and w for the portfolio weights. This
yields
n
X
p 0
r =wr= w i ri , (1)
i=1

which is a linear function. If we want to calculate the portfolio variance σ p , we end up


with a quadratic expression
n X
X n
σ p = w0 Bw = wi bij wj , (2)
i=1 j=1

where B is the variance-covariance matrix of the assets with elements bij .


In both cases, we can interpret the functions as functions of multiple, in this case n,
variables. For these functions, the concept of a partial derivative has been constructed.
Suppose we have a function f that depends on x and y, i.e., f (x, y). The partial derivative
of f (x, y) with respect to x is derived by differentiating f with respect to x, treating y
as a constant. It is denoted by ∂f /∂x. For the sum function f (x, y) = x + y, we have
∂f /∂x = ∂f /∂y = 1. For the product function f (x, y) = x · y, we find ∂f /∂x = y and
∂f /∂y = x. The normal differentiation rules (product rule, chain rule) apply to partial
differentiation, too.
Using partial differentiation, we can find the derivatives of rp and σ p with respect to
wk . In the linear case of rp this is relatively easy
∂rp
= rk . (3)
∂wk

For the quadratic case of σ p differentiation is bit more advanced, as we need the product

1
rule:
n n
∂σ p X X
= bkj wj + wi bik
∂wk j=1 i=1
n n n
X X X (4)
= bkj wj + bki wi = 2 bkj wj
j=1 i=1 j=1

=2Bk w.

In the second step, I used the fact that a variance matrix is symmetric (so bik = bki ). In
the third step I used vector notation again, with Bk being the k th row of B.
Finally, we need to find the derivative of a whole vector instead of one of its elements.
The derivative of a function g(w) is defined as
 ∂ g(w) 
1 ∂w
 ∂ g(w) 
∂g(w)  ∂w

≡ . 
 2 
(5)
∂w  .. 
∂ g(w)
∂wn

When we apply this to rp , we find


 p  
∂r
∂w1 r
 ∂ rp   1 
∂r p  ∂w   r2 
 ..  = 
= 2
..  = r (6)
∂w  .  .
∂ rp rn
∂w n

For σ p this yields


 p
∂σ 
  
∂w1 B1 w B1
 ∂ σp 
∂σ p
 B2 w   B2 
 ∂w     
=  .  =  ..  =  ..  w = Bw.
 2 (7)
∂w  ..   .   . 
∂ σp Bn w Bn
∂w n

Potrebbero piacerti anche