Differentiating with respect to a vector: gravitational potentials and fields I realise there are a great number of questions to do with 'differentiating with respect to a vector', and I have had a look at the ones that came up when I did a search, however none of them seemed to answer my question.
I am considering gravitational fields (although I think my question is more about the mathematics, so put it here rather than physics SE. Please let me know if it would be better suited there.); suppose I start off with the definition of the gravitational field $\textbf{g(r)}$ as being the force on a unit mass when placed at a point in the field.
Then I define $\Phi(\textbf{r})$ as the work done by an external force to move a unit mass from a point $\textbf{r}_0$ which is assigned a value $\Phi(\textbf{r}_0)=0$, to a point $\textbf{r}$. Then from this definition we get the relation
$\Phi(\textbf{r})=\int_{\textbf{r}_0}^{\textbf{r}}-\textbf{g(r')} \cdot d\textbf{r'}$
Now I am trying to get at $\nabla \Phi =-\textbf{g}$, but I am not sure how to go from the integral form to this.
If I had an ordinary integral involving only scalars, I would say
$F=\int_a^xf(x')dx' \implies \frac{dF}{dx}=f$.
The only thing I seem to be able to do here is
$\Phi(\textbf{r})=\int_{\textbf{r}_0}^{\textbf{r}}-\textbf{g(r')} \cdot d\textbf{r'} \implies d\Phi=-\textbf{g(r)} \cdot d\textbf{r}$
or
$\nabla \Phi  \cdot d\textbf{r} =-\textbf{g(r)} \cdot d\textbf{r}$
But this of course leaves one degree of freedom in the direction perpendicular to $d\textbf{r}$ and I cannot draw equality...
I was wondering if the way out of this is simply that it is explicitly stated/assumed that $\textbf{g(r)}$ acts exactly in the direction of $\nabla \Phi$, or whether I have perhaps lost information in any of my steps.
Thank you in advance.
 A: You have defined $\Phi(\mathbf{r})$ as the work done by an external force to move a unit mass from $\mathbf{r}_0$ to $\mathbf{r}$. This is actually ill defined unless you know in advance that the work done by such a force does not depend on the path taken from $\mathbf{r}_0$ to $\mathbf{r}$. Assuming this is the case, you can calculate the work along any path you want from $\mathbf{r}_0$ to $\mathbf{r}$. 
Let's write 
$$\mathbf{g} = g_1 \mathbf{e}_1 + g_2 \mathbf{e}_2 + g_3 \mathbf{e}_3, \\
 \mathbf{r_0} = x_0 \mathbf{e}_1 + y_0 \mathbf{e}_2 + z_0 \mathbf{e}_3, \\ \mathbf{r} = x \mathbf{e}_1 + y \mathbf{e}_2 + z \mathbf{e}_z. \\$$
In order to show that $\frac{\partial \Phi}{\partial x} = -g_1$ we can choose to calculate the work along the path 
$$\mathbf{r}'(t) := t \mathbf{e}_1 + y \mathbf{e}_2 + z \mathbf{e}_3, \\
\dot{\mathbf{r}}'(t) = \mathbf{e}_1 $$
which starts when $t = x_0$ at $\mathbf{r}_0$ and ends when $t = x$ at $\mathbf{r}$ traveling only along $\mathbf{e}_1$ at constant velocity (so that the $y-z$ coordinates are fixed). Then we have
$$ \Phi(\mathbf{r}) = -\int_{\mathbf{r'}} \mathbf{g} = \int_{x_0}^x \mathbf{g}(\mathbf{r'(t)}) \, \cdot \mathbf{r'(t)} \, dt = -\int_{x_0}^{x} \mathbf{g}(t,y,z) \cdot \mathbf{e}_1 \, dt = -\int_{x_0}^{x} g_1(t,y,z) \, dt. $$
Now we can use the fundamental theorem of calculus to differentiate $\Phi(\mathbf{r})$ in the direction $\frac{\partial}{\partial x}$ leaving $yz$ fixed to get
$$ \frac{\partial \Phi}{\partial x}(x,y,z) = -g_1(x,y,z). $$
Similarly, you can choose a path that travels only along $\mathbf{e}_2$ and use it together with the fundamental theorem of calculus to calculate $\frac{\partial \Phi}{\partial y}$ and so on.
A: The definition of the gradient is most helpfully written as
$$ f(\mathbf{r}+\mathbf{h}) = f(\mathbf{r}) + \mathbf{h} \cdot \nabla f(\mathbf{r}) + o(\lVert \mathbf{h} \rVert) . $$
Let's apply this to the integral
$$ f(\mathbf{r}) = \int_{\mathbf{a}}^{\mathbf{r}} \mathbf{F}(\mathbf{s}) \cdot d\mathbf{s} $$
(making all the variables have more distinct names for clarity). By the usual rules about additivity for line integrals,
$$ f(\mathbf{r}+\mathbf{h})-f(\mathbf{r}) = \int_{\mathbf{r}}^{\mathbf{r}+\mathbf{h}} \mathbf{F}(\mathbf{s}) \cdot d\mathbf{s}. $$
Now, approximate the path of integration by a line segment joining $\mathbf{r}$ to $\mathbf{r}+\mathbf{h}$ (we must be able to do this because part of the definition of the line integral requires that the integral over the curve is the integral over the line segment ${}+o(\lVert \mathbf{h} \rVert)$ as $\mathbf{h} \to 0$ (otherwise the integral would not be well-defined)). But this path can be parametrised by $ \mathbf{r}+\mathbf{h}t $ where $0<t<1$, so we find
$$ \int_{\mathbf{r}}^{\mathbf{r}+\mathbf{h}} \mathbf{F}(\mathbf{s}) \cdot d\mathbf{s} = \int_0^1 \mathbf{F}(\mathbf{r}+\mathbf{h}t) \cdot \mathbf{h} \, dt + o(\lVert \mathbf{h} \rVert) $$
The first integral is just an ordinary scalar integral. Taylor's theorem says that
$$ \mathbf{F}(\mathbf{r}+\mathbf{h}t) = \mathbf{F}(\mathbf{r}) + o(1) $$
as $\mathbf{h} \to 0$, and so
\begin{align}
f(\mathbf{r}+\mathbf{h})-f(\mathbf{r}) &= \int_0^1 \mathbf{F}(\mathbf{r}+\mathbf{h}t) \cdot \mathbf{h} \, dt + o(\lVert \mathbf{h} \rVert) \\
&= \int_0^1 (\mathbf{F}(\mathbf{r}) + o(1)) \cdot \mathbf{h} \, dt + o(\lVert \mathbf{h} \rVert) \\
&= \mathbf{h} \cdot \mathbf{F}(\mathbf{r}) \int_0^1 \, dt + o(\lVert \mathbf{h} \rVert) \\
&= \mathbf{h} \cdot \mathbf{F}(\mathbf{r}) + o(\lVert \mathbf{h} \rVert)
\end{align}
This holds for arbitrary $\mathbf{h} \to 0$, and hence we must have $\nabla f(\mathbf{r}) = \mathbf{F}(\mathbf{r})$.
