# derivative of a projection matrix

The projection onto a parametrised vector $v(\lambda)$ is $P_v = \frac{vv^{T}}{v^{T}v}.$ Its complement is $$P = I-\frac{vv^T}{v^{T}v}.$$ I've got an expression containing this complementary projection and I need its derivative. How do I calculate

$$\frac{\partial P(v(\lambda))}{\partial \lambda} \text{ ?}$$

I started with $$\cfrac{\partial P(v(\lambda))}{\partial \lambda} = \cfrac{\partial P(v(\lambda))}{\partial v} \cfrac{\partial v(\lambda))}{\partial \lambda}$$ where only the expression $\cfrac{\partial vv^{T}}{\partial v}$ I can't handle. How can I find this derivative of a matrix with respect to a vector, or the original derivative with respect to the scalar parameter $\lambda$?

• I think it is simpler to compute the derivative in coordinates. Since $vv^T=[v_iv_j]$ one differentiates with respect to $\lambda$ and finds $\partial_\lambda P = v' v^T + v(v')^T$. Jan 30, 2016 at 19:43
• (It may also help to remember that transposition commutes with differentiation.)
– Neal
Jan 30, 2016 at 20:26
• Which makes it: $$\frac{\partial P(v(\lambda))}{\partial \lambda} = - \frac{(v^{T}v)(v'v^{T}+v(v')^{T}) -vv^{T} ((v')^{T}v+v^{T}v') }{||v||^{4}}$$, correct?
– mike
Jan 30, 2016 at 20:38
• @mike Giuseppe's answer is correct. I'm not sure what your comment is all about Jan 31, 2016 at 2:15
• @mike oh! You're applying the quotient rule to your normalized version. Yes, you did so correctly. Note that what you've written only makes sense if you treat $v^Tv$ as a scalar (in other words, the matrices are not conformable if you regroup that product). Jan 31, 2016 at 2:19

Thanks to Giuseppe Negro I found the answer to be:

$$\frac{\partial P(v(\lambda))}{\partial \lambda} = - \frac{(v^{T}v)(v'v^{T}+v(v')^{T}) -vv^{T} ((v')^{T}v+v^{T}v') }{||v||^{4}}$$

after using the quotient rule. Remark: I used the general case here, where $v$ is not necessarily of unit length, so it needs to be normalised by its norm.

Multiply to clear the fraction \eqalign{ (v^Tv)\,P &= (v^Tv)\,I - (vv^T) \cr } Differentiate (using $d=\frac{d}{d\lambda}$ for ease of typing) \eqalign{ d(v^Tv)\,P + (v^Tv)\,dP &= d(v^Tv)\,I - d(vv^T) \cr (dv^T\,v+v^Tdv)\,P + (v^Tv)\,dP &= (dv^T\,v+v^Tdv)\,I - (dv\,v^T+v\,dv^T) \cr (v^Tv)\,dP &= (dv^T\,v+v^Tdv)\,(I-P) - (dv\,v^T+v\,dv^T) \cr } Solve for $dP$ \eqalign{ dP &= \frac{(dv^T\,v+v^Tdv)\,(I-P) - (dv\,v^T+v\,dv^T)}{v^Tv} \cr &= \frac{(dv^T\,v+v^Tdv)\,(vv^T) - (v^Tv)(dv\,v^T+v\,dv^T)}{(v^Tv)^2} \cr }