Let's say I have scalar function $\phi$ that is function of some vectors $\vec{\bf{p}}$ and $\vec{\bf{r}}$ such that $\phi = \phi(\vec{\bf{p}}-\vec{\bf{r}})$, also vector $\bf{r}$ is function of time, so we have $\phi = \phi(\vec{\bf{p}}-\vec{\bf{r}}(t))$. Now I want to take derivative of $\phi$ in respect of time, and my logic goes (by using a chain rule):
$\frac{\partial\phi(\vec{\bf{p}}-\vec{\bf{r}}(t))}{\partial t} = \frac{\partial\phi(\vec{\bf{p}}-\vec{\bf{r}}(t))}{\partial(\vec{\bf{p}}-\vec{\bf{r}}(t))}\frac{\partial(\vec{\bf{p}}-\vec{\bf{r}}(t))}{\partial t} = \frac{\partial\phi(\vec{\bf{p}}-\vec{\bf{r}}(t))}{\partial(\vec{\bf{p}}-\vec{\bf{r}}(t))}\frac{d(-\vec{\bf{r}}(t))}{dt}$
And now I have a problem. First term is directional derivative which means that it is a scalar and with value of $[\nabla\phi(\vec{\bf{p}}-\vec{\bf{r}}(t))]\cdot (\vec{\bf{p}}-\vec{\bf{r}}(t))$. And second term $\frac{d(-\vec{\bf{r}}(t))}{dt}$ is vector. Which means that my time derivative is vector. On the other hand I expect this time derivative to be scalar.
Where did I go wrong?
I have a feeling that it would help if this directional derivative is multiplied with unit vector $\frac{\vec{\bf{p}}-\vec{\bf{r}}(t)}{||\vec{\bf{p}}-\vec{\bf{r}}(t)||}$ and if there is a dot product between fractions so I get scalar. Something like:
$[[\nabla\phi(\vec{\bf{p}}-\vec{\bf{r}}(t))]\cdot (\vec{\bf{p}}-\vec{\bf{r}}(t))\frac{\vec{\bf{p}}-\vec{\bf{r}}(t)}{||\vec{\bf{p}}-\vec{\bf{r}}(t)||}]\cdot\frac{d(-\vec{\bf{r}}(t))}{dt}$
But I cannot find any rules that would support this feeling. And since I am not literate enough to read tensor calculus I am asking for your help.
I checked Differentiation of a scalar function w.r.t. a vector but I still have a hard time with this. My question is how to write this down without using any components or coordinate systems. I will use this equation for things in many coordinate systems and I want it to be as general as possible.
Isn't.
Small simplification: I will write simply ${\bf v}(t) = \vec{\bf{p}}- \vec{\bf{r}}(t)$ and now we have: $$ \phi:{\Bbb R}^n\longrightarrow{\Bbb R},\qquad {\bf v}:{\Bbb R}\longrightarrow{\Bbb R}^n. $$ (vectors/elements of ${\Bbb R}^n$ are column vectors)
The composition will be $$ \phi\circ{\bf v}:{\Bbb R}\longrightarrow{\Bbb R}. $$ And by the chain rule $$D(\phi\circ{\bf v})(t) = (D\phi)({\bf v}(t))\cdot D{\bf v}(t),$$ where:
$\cdot$ is the matrix product,
$(D\phi)({\bf v}(t))$ is a row vector (the transpose of gradient vector),
$D{\bf v}(t) = {\bf v'}(t)$ is a column vector.
Can you continue?