# Derivative of Matrix-Vector Product

Assume $S_1$ and $S_2$ are two $n \times n$ (positive definite if that helps) matrices, $c_1$ and $c_2$ are two variables taking scalar form, and $u_1$ and $u_2$ are two $n \times 1$ vectors. In addition, $c_1+c_2=1$, but in the more general case of $m$ $S$'s, $u$'s, and $c$'s, the $c$'s also sum to 1.

What is the derivative of $(c_1 S_1+c_2 S_2)^{-1}(c_1 u_1+c_2 u_2)$ with respect to both $c_1$ and $c_2$?

-
Have you tried using the formula for the derivative of the inverse of a matrix? en.wikipedia.org/wiki/… – Rahul Jan 14 '11 at 6:09
I am familiar with that formula. I am not sure how to proceed afterward. I do know that if S=S1=S2, then the answer should be S^-1*u1 for c1 and S^-1*u2 for c2. When I tried to apply the inverse rule for the more general problem, I could not find a similar result. – John Jan 14 '11 at 6:16
@John: If that's what you get when $S=S_1=S_2$, then perhaps I misunderstood your problem. The way I am interpreting it, you cannot replace $c_1+c_2$ with $1$ when finding the derivative with respect to each of $c_1$ and $c_2$, because each will vary independently of the other in the computation of the separate derivatives. I get $S^{-1}(u_1-c_1u_1-c_2u_2)$ for $c_1$. Am I missing something? – Jonas Meyer Jan 14 '11 at 7:31

The condition that $S_1$ and $S_2$ are positive definite is relevant to the existence of the inverse in the definition of the function. I assume that it is taken as given that the inverse exists at the relevant values of $c_1$ and $c_2$. This would be true in particular if $c_1$ and $c_2$ were positive.

By symmetry, the same method will apply for $c_1$ and $c_2$, and we're basically differentiating the function $f(t)=(tA+B)^{-1}(tu+v)$, where $A$ and $B$ are matrices and $u$ and $v$ are column vectors. You can write this as $f(t)=g(t)h(t)$, where $g$ is a matrix valued function and $h$ is a vector valued function. By the product rule, $f'(t)=g'(t)h(t)+g(t)h'(t)$. So you just need to be able to determine $g'$ and $h'$. It is straightforward that $h'(t)=u$. You can also show that $g'(t)=-(tA+B)^{-1}A(tA+B)^{-1}$.

-

Since I did this initially unregistered, I can't seem to figure out how to get back in and add a comment instead of an answer. This is a bit long, but I am still having trouble resolving this problem satisfactorily. Also, I apologize for the formatting.

@Jonas Meyer I got similar answers to you the first time I had tried it. The problem I'm actually dealing with is more general and contains perhaps a c3, c4, or any higher number. However, one of these cs will always be defined as c=1-sum(other cs).

In the simpler problem, S^-1*(c1*u1+c2*u2), if you assume c1 and c2 are independent, then the derivative wrt c1 is S^-1*u1 as I said above. This answer makes quite a lot of sense with regards to my current problem. If S=c1*S1+c2*S2 and S1=S2, I also found the answer that you have in the reply, S^-1*(u1-c1*u1-c2*u2). The problem is that this isn't consistent with what is above. This is a portfolio management problem. The first answer will give the equivalent of a portfolio with confidence c1=100% in the u1 view, while the second will give the difference between that view and the blended final portfolio. I am trying to address how much the confidences c1 and c2 are responsible for the final portfolio weights. In the first case, it is obvious: Multiply S^-1*u1 by c1 since it is homogeneous and divide by S^-1*(c1*u1+c2*u2). It is not obvious in the case of S^-1*(u1-c1*u1-c2*u2). For instance, if c1=100% and c2=0%, then the first case will show 100% of the weights are driven by c1 and 0% are driven by c2. The second case will say the contribution is 0% for c1. Something is mistaken here.

If c2=1-c1, then the derivative wrt c1 is S^-1*(u1-u2). For the more complicated case, where S=c1*S1+c2*S2=S2+c1*(S1-S2), the derivative wrt c1 can be calculated using what is in the answer and there will a term in one part so that if S1=S2 then it falls out and the answer becomes S^-1*(u1-u2). So if you assume c2=1-c1, I think you can get consistent answers between the case with 1 S and the case with 2 Ss. However, it still doesn't resolve my problems when you multiply the derivative wrt c1 by c1 and divide by S^-1*(c1*u1+c2*u2). This number will not provide the relative contributions from c1 to the portfolio weights.

-
Unfortunately, I do not understand your model, which hinders my ability to see what mathematics will help answer your question. But I also don't understand the mathematical reasoning behind ending up with $S^{-1}u_1$. If you assume that $c_1$ and $c_2$ are independent, then it is inconsistent to replace $c_2$ with $1-c_1$. Assuming independence leads to $S^{-1}(u_1-c_1u_1-c_2u_2)$, while fixing $c_2=1-c_1$ leads as you said to $S^{-1}(u_1-u_2)$. – Jonas Meyer Jan 14 '11 at 18:54
for the time being I've merged your two accounts (that appears here on this post). JFYI you are still not registered, so the same problem may occur again in the future. – Willie Wong Jan 14 '11 at 19:25
Let me also rephrase Jonas's complaint: in your problem you have a constraint $\sum c_i = 1$. You can choose to either impose it or not, but it is illegal (mathematically) to at one step impose the constraint and at another ignore it. That is, you cannot simply an expression using the constraint in one step and then assume the variables are independent in a later step. – Willie Wong Jan 14 '11 at 19:29