# Differential calculus as plumbing

When talking about quantum or classical physics the word **mechanics** often comes up.

With fields it's more useful to talk about **plumbing**.

### Differential calculus

in multiple dimensions

- The
**gradient**, $\myv \grad$, operator:*Which way does water flow?* **Divergence**, $\myv \grad \cdot$:*Where are the leaks (and sources)?***curl**, $\myv \grad \times$:*How are things swirling?*- Higher order derivatives.

### Slope of a function

For a function $f(x)$ of one variable, the **derivative** $\frac{df}{dx}$ is the slope.

$f(x)$ vs $x$

Another way of putting this is... $$df = \left(\frac{df}{dx}\right) dx$$

"As you move a small amount $dx$ to the right, the function changes by an amount $df$ equal to that change in $x$ times (the rate of change of $f$ w.r.t. $x$)."

## Slope of a function of several variables

Consider the height, $h$, of Earth's surface (say, height=altitude above sea level) as a function of east ($x$) and north ($y$) position. The height $h(x,y)$ is a function of more than one variable, and is often depicted as a **contour map**: points of equal height are connected
by contour lines.

$\del
h/ \del x$ is the slope (rate of change of height) as you move east (no
change in north/south direction). In the picture it's a **positive** slope as
you move east.

$\del h / \del y$ is the slope as you move north.
In the picture, a **negative** slope in this direction.

Height is literally, one spatial dimension. But we will more often be concerned with a more abstract situation, Some additional quantity, say the temperature, which is a function of all three spatial coordinates.

#### Rate of change of a function of many variables

A mathematical theorem tells us that a function of many variables, $T(u,v,w,...)$, changes by an amount that depends on the change of each of the variables ...

$$dT = \frac{\del T}{\del u} du + \frac{\del T}{\del v} dv +\frac{\del T}{\del w} dw + ...$$

In particular, the change in height as we move around the landscape is $$dh = \left(\frac{\del h}{\del x}\right) dx + \left(\frac{\del h}{\del y}\right) dy$$

- The meaning of the
*partial derivative*$\frac{\del T}{\del u}$ is...

the rate of change of $T$ as you change $u$, while holding all the other variables ($v,w,...$) constant. - This is a property of
*any*function of several variables--they don't have to be spatial variables.

The universal gas law $PV=nRT$: Imagine that we have a piston in which we can control $V,n,T$. These three variables determine the pressure of the gas. Solve for $P(V,n,T)$ and find $\frac{\del P}{\del V}$.

Here, $T$ is not some function of position, but rather it is the equilibrium temperature throughout the piston volume, which depends on the pressure, etc.

#### The gradient

If the function $T$ depends on, say, the three cartesian coordinates, then you can schematically write the change $dT$ as a dot product... $$\begineq dT &=& \frac{\del T}{\del x} dx + \frac{\del T}{\del y} dy +\frac{\del T}{\del z} dz\\ &=&\left(\frac{\del T}{\del x}\uv{x} + \frac{\del T}{\del y}\uv{y} + \frac{\del T}{\del z}\uv{z}\right) \cdot \left(dx\,\uv{x} + dy\,\uv{y} +dz\,\uv{z}\right)\\ dT&=& \myv \grad T \cdot d\myv{l}.\endeq$$

The second vector is our "change in position" vector,
$$d\myv l\equiv dx\,\uv x +dy\,\uv y+dz\,\uv z,$$ and the first vector is called the **gradient**:

$$\myv \grad T \equiv \frac{\del T}{\del x}\uv{x} + \frac{\del T}{\del y}\uv{y} + \frac{\del T}{\del z}\uv{z}.$$

The gradient is a multi-dimension generalization of the "derivative".

Using the coordinate-independent form for the dot product, $$dT = |\myv \grad T| |d\myv{l}| \cos(\theta)$$

So, if we fix the magnitude of $d\myv{l}$, but let it change directions, the change $dT$ will be the greatest when the angle between $d\myv l$ and $\myv \grad T$ is zero. This implies...

- The maximum possible slope away from the point we're considering is $|\myv \grad T|$,
- $\myv \grad T$ is pointing "uphill" towards the direction of greatest change in $T$,
- In the directions $\theta=\pm \pi/2$, the function is not changing ($dT=0$): these are the directions along "contour lines" of constant $T$.

What direction does water flow on a landscape specified by $h(x,y)$? Apparently in the direction $-\myv \grad h$: exactly opposite to the gradient. That is to say...

Downhill!!

See also Paul's treatment of the gradient in Analytical Mechanics, using topo maps.

### The *nabla* operator

In the Cartesian expression for the gradient $\myv \grad T$: it looks like there's a vector, "$\myv \grad$" in some sort of relationship with a scalar $T$. $$\myv \grad T \equiv \frac{\del T}{\del x}\uv{x} + \frac{\del T}{\del y}\uv{y} + \frac{\del T}{\del z}\uv{z}.$$

- We could pretend that there's a thing $\myv \grad$ (called "nabla")...
$$\myv \grad \equiv \uv{x}\frac{\del}{\del x} +\uv{y} \frac{\del}{\del y} + \uv{z} \frac{\del}{\del z}.$$

- ...and that "thing" is operating on $T$ in such a way as to produce a vector from the scalar field $T$...
- We call $\myv \grad$ a
*vector operator*. - When it operates on a
*scalar field*$T(x,y,z)$ the result is a vector.

Hmmm, doesn't it kinda make you wonder if there is something like a dot product or a cross product involving $\myv \grad$.??

- $\myv \grad T$: A vector known as the
**gradient**of a scalar field $T$, - $\myv \grad \cdot \myv V$: A scalar known as the
**divergence**of a vector field $\myv V$, and - $\myv \grad \times \myv V$: A vector known as the
**curl**of a vector field $\myv V$.

### The Divergence

*Where are the leaks?*

The dot product of the $\myv \grad$ operator with a vector function $\myv v$ should result in a scalar: a single number, at a particular location in space. $$\begineq \myv \grad \cdot \myv v &=& \uv{x} \frac{\del}{\del x} +\uv{y} \frac{\del}{\del y} +\uv{z} \frac{\del}{\del z} \cdot \left(v_x\uv{x} + v_y\uv{y} + v_z\uv{z}\right)\\ &=&\frac{\del v_x}{\del x} + \frac{\del v_y}{\del y} + \frac{\del v_z}{\del z}.\endeq$$

For the following sketches of 2-dimensional vector fields, $\myv V(x,y)$, what [pos, neg or 0] is the 2-d divergence, $\frac{\del V_x}{\del x}+\frac{\del V_y}{\del y}$ at the positions marked in purple?

One useful intuitive way to think about the divergence for a 2-d vector field, is to imagine that the arrows represent the 2-d flow of an incompressible fluid (water!). Imagine injecting a "cloud" of purple dye at a location you'd like to investigate for "leaks" in your system.

A place where the cloud gets smaller corresponds to a location of a **negative divergence**: a "leak" (or sink, or drain) where water is leaving your 2-d system

...leaving your 2d system **into another dimension**!

Places where the cloud gets bigger have **positive
divergence**. There must be a "source" (or faucet) of water **from another dimension**(!).

### The Curl

*How are things swirling?*

The cross-product-like object involving $\myv \grad$ is the **curl**:

$$\begineq\myv \grad \times \myv V &=& \begincv \uv{x}& \uv{y}& \uv{z}\\ \frac{\del}{\del x} & \frac{\del}{\del y} & \frac{\del}{\del z}\\ V_x& V_y& V_z\endcv \\ &=& \uv{x}\left(\frac{\del V_z}{\del y}-\frac{\del V_y}{\del z}\right) + \uv{y}\left(\frac{\del V_x}{\del z}-\frac{\del V_z}{\del x}\right) +\uv{z}\left(\frac{\del V_y}{\del x}-\frac{\del V_x}{\del y}\right)\endeq.$$

For $\myv V(\myv r) = -y \uv{x} +x \uv{y}$, sketch $\myv V$ in the $x-$, $y-$ plane ($z=0$)...

$$\myv \grad \times \myv V = \begincv \uv{x}& \uv{y}& \uv{z}\\ \frac{\del}{\del x}&\frac{\del}{\del y}&\frac{\del}{\del z}\\ -y& +x& 0\endcv = 2\uv{z}.$$

Notice that this has the same value *everywhere*, not just at the origin.

Extending our water flow metaphor: You can think of placing a paddle-wheel with axis oriented in the $\uv{z}$ direction in the water flow represented by the vector function $\myv V$ and seeing whether the paddle-wheel turns counter-clockwise (positive curl) or clockwise (negative curl).

In a 3-d water flow field, we could also try orienting the paddle wheel towards $\uv{y}$ and
$\uv{x}$ to check for components of the *curl* in all possible directions.

This function has equation: $\myv V = x\uv{y}$:

What about these two? Assume that they are not changing as you change $z$.
Does the curl of each field have a $z$- component or not?

Note the product rules--discussed in section 1.2.6 and noted on the inside front cover of your text.

### Second derivatives involving $\myv \grad$

Of all the possible combinations of second derivatives, the two most useful will be...

- $\myv \grad \cdot \myv \grad $, and
- $\myv \grad \times \myv \grad $.

### The Laplacian

$$\begineq \grad^2 T\equiv \myv \grad \cdot \myv \grad T = \frac{\del^2T}{\del x^2} + \frac{\del^2T}{\del y^2} + \frac{\del^2T}{\del z^2}.\endeq$$

### The curl of the gradient

$$\myv \grad \times \myv \grad U(x,y,z) = 0.$$

It's always zero... A fact we used in Analytical Mechanics to test whether a force field, $\myv T (x,y,z)$, is "conservative" (that is, can be expressed as the gradient of a potential energy) or not.

Now, prove it! (Problem 1.28)