# How to take derivative about $V(x)=x^{T}Px$?

Consider the quadratic function $$V(x(t))=x(t)^{T}Px(t)$$, where $$P$$ is a positive symmetric matrix.

How do I calculate its time-derivative, that is, $$\frac{\mathrm{d}}{\mathrm{d} t}V(x(t))?$$

• what do you mean by $P$ is a "positive" matrix? – johnny09 May 26 '19 at 2:28

Using the product rule and abbreviating $\frac{d}{dt}$ with a dot, we have $$\dot V = \dot x^T P x + x^T P \dot x$$ Each of the terms on the right is a scalar, hence symmetric. So $$\dot x^T Px = (\dot x^T P x)^T = x^T P^T \dot x = x^T P \dot x$$ Therefore $\dot V = 2x^T P \dot x$.

If you prefer working in indices, write $x = (x^1,x^2,\dots,x^n)$ and $V = x^i p_{ij} x^j$ (we use the Einstein summation notation convention, so that the sigma is understood). Then \begin{align*} \dot V = \dot x^i p_{ij} x^j + x^i p_{ij} \dot x^j \end{align*} Swapping the names of the indices on the first term, and using the fact that $P$ is symmetric, we have $$\dot V = \dot x^j p_{ji} x^i + x^i p_{ij} \dot x^j = 2 x^i p_{ij} \dot x^j$$

To illustrate in the case $n=2$, try $P = \begin{bmatrix} 2 & 1 \\ 1 & 1\end{bmatrix}$. Then \begin{align*} V &= \begin{bmatrix} x & y \end{bmatrix}\begin{bmatrix} 2 & 1 \\ 1 & 1\end{bmatrix}\begin{bmatrix} x \\ y \end{bmatrix} = \begin{bmatrix} x & y \end{bmatrix}\begin{bmatrix} 2x+y \\ x+y \end{bmatrix} \\&= 2x^2 + xy + yx + y^2 = 2x^2 + 2xy + y^2 \end{align*} Therefore \begin{align*} \dot V &= 4x\dot x + 2(\dot x y + x \dot y) + 2 y\dot y \\&= 2(2x\dot x + x\dot y + y \dot x + y\dot y) \\&= 2 \begin{bmatrix} x & y \end{bmatrix}\begin{bmatrix} 2 & 1 \\ 1 & 1\end{bmatrix}\begin{bmatrix} \dot x \\ \dot y \end{bmatrix} \end{align*}

Commenter Aaron is right that the product rule works for just about any bilinear operation.

• It's worth commenting that the product rule holds for just about every kind of product. Scalar products, dot products, matrix multiplication (though you need to remember that order matters there), cross products, whatever. It is absolutely fundamental, and a lot of things follow directly from the product rule. In more advanced settings, the product rule gets used as the definition for a lot of things. So remember the product rule, the one part of calculus that will stick with you no matter where in mathematics you go. Probably. – Aaron Mar 10 '17 at 14:18

Noting $f'$ the derivative of the function $f$,

Let: $f = y \mapsto y^T P y$.

$P$ is symmetric, so we have: $f'(y) = 2 y^T P$ (see here).

So: $V = f \circ x$.

Using this formula: $(h \circ g)'(t) = h'(g(t)).g'(t)$,

$$V' = 2 x^T P x'$$