# Total Derivative of Vector Function of Time

I'm reading Baraff's '98 paper: http://run.usc.edu/cs599-s10/cloth/baraff-witkin98.pdf

He defines condition vector functions that equal zero $C(x(t))=0$. An energy function is defined using a vector function:

$$E_c(x)=\frac{1}{2}k*C(x(t))^TC(x(t))$$

The confusion comes from equation (7). (7) comes from computing the partial derivative of $\frac{\partial E_c(x)}{\partial x}$. Applying the chain rule, I imagine it would look something like:

$$\frac{\partial E_c(x)}{\partial x}=k*C(x(t))*\frac{dx}{dt}$$

Could anyone clear up how to obtain the correct result in equation (7)? I must be miss-applying the chain rule, but am still a bit new to vector calculus (especially in regards to total vs partial derivatives).

For convenience, here's equation (7):

$$f_i=-\partial \frac{E_c}{\partial x_i}=-k\frac{\partial C(x)}{\partial x_i}C(x)$$

Here's a screenshot of the relevant section from the above paper:

• If the derivative is being taken with respect to $x_i$, $t$ is not considered an independent variable, thus no $dx/dt$ Aug 25 '17 at 4:48
• Where are you getting the $t$ dependence from? Aug 25 '17 at 4:49
• Pretty sure the condition functions are passed position vectors that change over time. My understanding was that conceptually $C(x)$ was $C(x(t))$. But maybe I misinterpreted the paper. Nonetheless I'm still baffled how to reach equation (7). Specifically, where does the $C(x)$ come from at the end of (7)? Aug 25 '17 at 4:52
• @DavidPeterson Did you mean $t$ is not considered dependent? Aug 25 '17 at 4:54
• You are treating $x$ as dependent on $t$, but should not be, as the notation $\partial/\partial x$ is telling you $x$ is independent. $C(x)$ and $C(x(t))$ are the same function (albeit with possible restrictions on the range of $x$). However $\partial/\partial x C$ and $\partial/\partial t C$ mean different things. Aug 25 '17 at 5:13

If $E(x) = { 1\over 2} \|C(x)\|^2$ then $DE(x) = C^T(x) DC(x)$, or ${\partial E(x)\over \partial x} = C^T(x) {\partial C(x)\over \partial x}$.
Hence ${\partial E(x)\over \partial x_i} = {\partial E(x)\over \partial x} e_i = C^T(x) {\partial C(x)\over \partial x}e_i = C^T(x) {\partial C(x)\over \partial x_i} = \sum_k [C(x)]_k [{\partial C(x)\over \partial x_i}]_k$.
• So then $DE(x) = D({1\over 2} \|C(x)\|^2)*DC(x)=C^T(x)*DC(x)=C^T(x)*{\partial C(x)\over \partial x}$ ? But the answer in the paper has the order reversed to: ${\partial C(x)\over \partial x}C(x)$, where ${\partial C(x)\over \partial x}$ is a matrix and $C(x)$ is a vector. Aug 25 '17 at 5:17
• @Cecil: Not quite. If we let $s(y) = \|y^2\|$ then $E = {1 \over 2} s \circ C$ and so $DE(x) = {1 \over 2} Ds(C(x)) D C(x) = C^T(x) DC(x)$. Aug 25 '17 at 5:22
• OK gotcha! I think I was getting a little confused with your answer since you had $vector^T * Matrix$, though I suppose it's computationally the same as the paper's answer with reversed notation $Matrix * vector$. Aug 25 '17 at 5:32
• It is because $a^T b = b^T a$. Aug 25 '17 at 5:34
If you write $\mathbf C(\mathbf x)$ as a vector $$\mathbf C(\mathbf x)=\begin{pmatrix}C_1(\mathbf x)\\\vdots\\C_p(\mathbf x)\end{pmatrix}$$ the energy is given by $E_{C}=\frac k2\sum_{j=1}^pC_j(\mathbf x)^2$. From there, this is pretty straightforward. $$f_i=-\frac{\partial E_C}{\partial x_i}=-k\sum_{j=1}^p\frac{\partial C_j}{\partial x_i}C_j.$$