How can I compute the total derivative of a time-varying quadratic form?

80 Views Asked by At

Let $x : [0,\infty) \to \mathbb R^n$ be a time-varying vector and let $P : [0,\infty) \to \mathbb R^{n \times n}$ be a time-varying symmetric matrix, such that $P(t) = P^T(t)$ for every $t \in [0,\infty)$. Moreover, let $$ V(x(t),P(t)) = x^T(t)P(t)x(t) $$ How can I compute the following total derivative in terms of $\frac{dx}{dt}(t)$ and $\frac{dP}{dt}(t)$? $$ \frac{d}{dt}V(x(t),P(t)) = \frac{d}{dt}\{x^T(t)P(t)x(t)\} $$ Here is what I tried so far: \begin{align} \frac{d}{dt}\{x^T(t)P(t)x(t)\} &= \frac{\partial V}{\partial x}(x(t),P(t)) \frac{dx}{dt}(t) + \frac{\partial V}{\partial P}(x(t),P(t)) \frac{dP}{dt}(t) \end{align} I don't think this expression is correct, because the second summand is a matrix, while the first summand is a scalar. I can compute the first summand as \begin{align} \frac{\partial V}{\partial x}(x(t),P(t)) \frac{dx}{dt}(t) &= x^T(t)(P(t) + P^T(t))\frac{dx}{dt}(t) \\ &= 2x^T(t)P(t)\frac{dx}{dt}(t) \end{align} which makes sense, since $V(x(t),P(t))$ is a scalar. In a paper that I'm reading, I find that the second summand evaluates to $$x^T(t)\frac{dP}{dt}(t)x(t)$$ However, I'm not sure where this comes from.


UPDATE

Using @TrystwithFreedom's comments, we can obtain the answer as follows. However, I'm not sure why this works, and I would appreciate either an explanation for why this method works, or another more rigorous method. \begin{align} \frac{dV}{dt}(x(t),P(t))dt &\approx V(x(t+dt),P(t+dt)) - V(x(t),P(t)) \\ &\approx x^T(t+dt)P(t+dt)x(t+dt) - x^T(t)P(t)x(t) \\ &\approx \left(x(t) + \frac{dx}{dt}(t) dt\right)^T\left(P(t) + \frac{dP}{dt} dt\right)\left(x(t) + \frac{dx}{dt}(t) dt\right) - x^T(t)P(t)x(t) \\ &\approx x^T(t)P(t)x(t) + x^T(t)P(t)\frac{dx}{dt}(t)dt + \frac{dx^T}{dt}(t) P(t)x(t) dt + \frac{dx^T}{dt}(t) P(t) \frac{dx}{dt}(t) (dt)^2 \\ &+ x^T(t) \frac{dP}{dt} x(t) dt + x^T(t)\frac{dP}{dt}\frac{dx}{dt}(t) (dt)^2 + \frac{dx^T}{dt}(t) \frac{dP}{dt} x(t) (dt)^2 + \frac{dx^T}{dt}(t) \frac{dP}{dt} \frac{dx}{dt}(t) (dt)^3 \\ &- x^T(t)P(t)x(t) \end{align} We then remove any higher order terms such as $(dt)^2$ and $(dt)^3$ to get \begin{align} \frac{dV}{dt}(x(t),P(t))dt &= x^T(t)P(t)x(t) + x^T(t)P(t)\frac{dx}{dt}(t)dt + \frac{dx^T}{dt}(t) P(t)x(t) dt + x^T(t) \frac{dP}{dt} x(t) dt - x^T(t)P(t)x(t) \\ &= x^T(t)P(t)\frac{dx}{dt}(t)dt + \frac{dx^T}{dt}(t) P(t)x(t) dt + x^T(t) \frac{dP}{dt} x(t) dt \\ &= 2x^T(t)P(t)\frac{dx}{dt}(t)dt + x^T(t) \frac{dP}{dt} x(t) dt \end{align} This method is a bit "hand-wavy", as I'm not sure why it works, especially the part about removing any $(dt)^2$ and $(dt)^3$ terms.

1

There are 1 best solutions below

5
On BEST ANSWER

Since matrices in general do not commute, which makes the use of partial derivative and then multiplying by their time derivatives more error prone. Therefore, I would recommend to use the product rule, such that

$$ \frac{d}{dt}\left(x^\top\!(t)\,P(t)\,x(t)\right)= \frac{d\,x^\top\!(t)}{dt}\,P(t)\,x(t) + x^\top\!(t)\,\frac{d\,P(t)}{dt}\,x(t) + x^\top\!(t)\,P(t)\,\frac{d\,x(t)}{dt}. $$

Because $P(t)$ is symmetric, the first and and third term yields the same scalar value, so can also be combined. Thus the above is equivalent to

$$ \frac{d}{dt}\left(x^\top\!(t)\,P(t)\,x(t)\right)= x^\top\!(t)\,\frac{d\,P(t)}{dt}\,x(t) + 2\,x^\top\!(t)\,P(t)\,\frac{d\,x(t)}{dt}. $$