# What does $\textbf{f} = -\boldsymbol{\nabla} u$ mean in practice and how is it computed?

In classical computer simulations such as molecular dynamics (MD) simulations, one integrates Newton's equations of motion to determine particle trajectories. If we think of Newton's Second Law as simply $$\textbf{f}_i = \frac{d \textbf{p}_i}{dt}$$ where $\textbf{f}_i$ is the net force acting on a particle $i$ and $\textbf{p}_i$ is the momentum of the particle, then it is clear that to ultimately integrate this and propagate the trajectory, we will need to calculate the force on every particle in the system.

However, in practice, I think that the potential energy $u$, rather than the force, is initially calculated (a force field specifies the form of the potential energy $V$). Now, I know that there is a relationship between potential energy $u$ and force $f$: $$\textbf{f} = -\boldsymbol{\nabla} u$$

In other words, force is the negative gradient of the potiental energy.

I am reading Understanding Molecular Simulation by Frenkel and Smit (Second Edition), and on page 69 (Google Books has some pages here), I see this paragraph:

Suppose that we wish to compute the $x$-component of the force: $$f_x(r) = -\frac{\partial u(r)}{\partial x} = -\left(\frac{x}{r}\right)\left(\frac{\partial u(r)}{\partial r}\right)$$

I am a little afraid this is a silly question, but how do the authors go from $-\frac{\partial u(r)}{\partial x}$ to $-\left(\frac{x}{r}\right)\left(\frac{\partial u(r)}{\partial r}\right)$? Is this the chain rule? Could you please help me see the step that the authors are making?

-

You are right that the result you see is due to the chain rule. The author uses either spherical or cylindrical coordinates, so

$$r = \sqrt{x^2 + y^2 + z^2}$$

or

$$r = \sqrt{x^2 + y^2}$$

which you can differentiate to obtain

$$\frac{\partial{r}}{\partial{x}} = \frac{x}{r}$$

Hence

$$f_x(r) = -\frac{\partial{u(r)}}{\partial{x}} = -\frac{\partial{u(r)}}{\partial{r}}\frac{\partial{r}}{\partial{x}} = -\frac{x}{r} \frac{\partial{u(r)}}{\partial{r}}$$

-

The previous answer is fine, but you should not piddle around doing the chain rule. It comes from a differential relation you learn once, and forever make second nature:

$$r dr = x dx + y dy + z dz$$

This is the differential form of the pythagorean law:

$$r^2 = x^2 + y^2 + z^2$$

and it tells you the size of the relative size of the x,y,z increments, when you make an increment of r. The x increment is ${x\over r} dr$, so that the change in the function is

$$u(x + dx,y,z) = u(r+dr) = u(r) + u'(r) dr = u(r) + u'(r) {x\over r} dx$$

it is important to do it this way, so that it goes into your head and stays there.

-