I need to take the derivative of $f(x) = (x+c)⋅(x+c)$ with respect to time, where $x$ is a vector and $c$ is a constant vector. Is it correct to rewrite this as $f(x) = g(x)\cdot g(x)$ where $g(x)=x+c$ . And now using chain rule for dot product $f'(x) = 2g'(x)\cdot g(x) \frac{dx}{dt}$. Then we get $g'(x) = 1$. Resulting in $f'(x) = 2(x+c)x'$?
-
How are you defining the sum of a vector and a constant, i.e., $\mathbf{x} + 3$? – Sean Roberson Feb 27 '20 at 22:10
-
@SeanRoberson Yeah sorry I meant constant vector. I edited the post. – Lenny White Feb 27 '20 at 22:12
2 Answers
This is it. In fact, recall that for a vector $\mathbf{v}$, we have that $||\mathbf{v}||^2 = \mathbf{v} \cdot \mathbf{v}.$ Taking the derivative of this object is just using the chain rule.
Furthermore, the dot product obeys a product rule of differentiation similar to the scalar case: $(\mathbf{u}(t) \cdot \mathbf{v}(t))' = \mathbf{u}' \cdot \mathbf{v} + \mathbf{u} \cdot \mathbf{v}'.$
- 9,110
-
Can I also ask the second derivative of f(x) would then be
x′x′ + (x+c)x′′right? – Lenny White Feb 27 '20 at 22:27 -
You still need the factor of $2$ in the second derivative. So, $\ddot f(x)=2(\dot x\cdot\dot x+(x+c)\cdot\ddot x)$ (where I'm using dot notation for the derivative with respect to time, as in my answer). – Toby Bartels Feb 27 '20 at 22:45
-
Right I forgot the factor of 2! Also should have been clear to include dot notation. Thanks for the help! – Lenny White Feb 28 '20 at 00:21
Since $ x $ and $ g ( x ) $ are vectors, $ g ' ( x ) $ is a matrix, which in this case is the identity matrix. You can think of this as a dyadic, and then its dot product with $ g ( x ) $ is a vector, and the dot product of that with $ \mathrm d x / \mathrm d t $ is a scalar (which is multiplied by $ 2 $). But since $ g ' ( x ) $ is the identity matrix, $ 2 g ' ( x ) \cdot g ( x ) \cdot \mathrm d x / \mathrm d t $ simplifies to $ 2 g ( x ) \cdot \mathrm d x / \mathrm d t $.
Although this is what you're looking for, you shouldn't call this $ f ' ( x ) $, which means the derivative of $ f ( x ) $ with respect to $ x $ (the gradient vector), not with respect to $ t $. So it should be $$ \frac { \mathrm d \big ( f ( x ) \big ) } { \mathrm d t } = 2 ( x + c ) \cdot \frac { \mathrm d x } { \mathrm d t } \text . $$ Or you could introduce dot notation for the derivative with respect to time and write $$ \dot f ( x ) = 2 ( x + c ) \cdot \dot x \text . $$ (Since people don't usually use prime notation for functions of vectors, you could write the final answer the way you did and say that the prime means the derivative with respect to time. But this is not what you meant by the prime when you wrote $ g ' $ in your derivation!)
Another way to argue this, in line with the second half of Sean's answer is $$ \frac { \mathrm d \big ( ( x + c ) \cdot ( x + c ) \big ) } { \mathrm d t } = \frac { \mathrm d ( x + c ) } { \mathrm d t } \cdot ( x + c ) + ( x + c ) \cdot \frac { \mathrm d ( x + c ) } { \mathrm d t } = \frac { \mathrm d x } { \mathrm d t } \cdot ( x + c ) + ( x + c ) \cdot \frac { \mathrm d x } { \mathrm d t } \text . $$ Here we use the Product Rule in the first step and the Sum-Constant Rule in the second step, never the Chain Rule as such. (Then use commutativity of the dot product for the final answer.)
- 4,679