The most powerful equation in all of mathematics*

$$\frac{\partial F}{\partial g}-\frac{d}{dx}\frac{\partial F}{\partial g'}=0$$
*Probably not, but "One of many very cool and useful equations" makes for a bad title.

The basics of optimisation.

  • There is some quantity you care about. We call it the metric.
  • You can influence its value through your choices.
  • You want this value to be as big as possible.*
  • Optimisation is choosing in a way that makes the value you care about as big as possible.
*If you want it to be as small as possible, just multiply it by -1. Suddenly you want it to be as big as possible.

Examples for optimisation

  • Maximising your average speed on a run.
  • Minimising time spent in queues at Disneyland.
  • Maximising area / price when buying pizza.
  • Maximising profit when selling ice cream.
  • Minimising travel time to get somewhere.

Different metric. Same principle.

Optimising a value from a discrete spectrum

ABC
Movie A poster Movie B poster Movie C poster
Runtime178 min180 min96 min
IMDb8.98.29.0
Price9.99€14.99€7.99€

Optimising a value from a discrete spectrum.

  • Which one would you choose? It depends on the metric.
  • Maximise watch time?
  • Maximise IMDb rating?
  • Minimise price?
  • Minimise price per minute?

Looking for more exercises?

Choice optimization. Ex. 1.

  • Find a pizzeria in your area. Which pizza has the best area-to-price ratio?

Choice optimization. Ex. 2.

  • Find a car with the lowest fuel consumption per 100 km.
    • Take current fuel prices into account. Which car is cheapest to drive?
    • Include the purchase price, assuming you'll drive it for 100,000 km.
    • Include insurance costs.
    • What else could you take into account?

Optimising a value from a continuous spectrum

  • You are a farmer.
  • You have 100 m of fence.
  • You want your sheep to have as much space as possible.
  • The fence must form a rectangle.
  • What is the optimal shape?
a b

Solution

$$2a + 2b = 100\,\mathrm{m}$$
$$b = 50\,\mathrm{m} - a$$
$$A = ab$$
$$A(a) = a(50\,\mathrm{m} - a)$$
$$A'(a) = -2a + 50\,\mathrm{m}$$
$$A'(a)=0 \quad \Rightarrow \quad a=25\,\mathrm{m}$$
a b

Solution

$$2a + 2b = 100\,\mathrm{m}$$
$$b = 50\,\mathrm{m} - a$$
$$A = ab$$
$$A(a) = a(50\,\mathrm{m} - a)$$
$$A'(a) = -2a + 50\,\mathrm{m}$$
$$A'(a)=0 \quad \Rightarrow \quad a=25\,\mathrm{m}$$
$$a=b=25\,\mathrm{m}$$
25m 25m
The optimum is a square.

Looking for more exercises?

Optimising Functions. Ex. 3.

  • The number of sales as a function of price is:
    $$S(\text{price})=1000\cdot e^{-\frac{\text{price}}{\text{€}}}$$
  • What price maximises revenue?

Optimising Functions. Ex. 4.

  • Fuel consumption per hour as a function of speed is:
    $$C(v)=0.005\frac{h^2L}{km^3}\left(v-10\frac{km}{h}\right)^3+5\frac{L}{h}$$
  • What speed minimises the fuel consumed over a fixed-distance trip?

Optimising a functional.

  • You want to get from A to B.
  • You can choose any path connecting them.
  • You want to minimise the length of the path.
  • What is the optimal path?
Several possible paths from A to B

Optimising a functional.

  • You can express most paths with a function y(x).
  • How would you compute the length l of a path described by f(x)?
A path described by a function y(x)

Optimising a functional.

  • Since $ds=\sqrt{dx^2+dy^2}$ and $\frac{dy}{dx}=y'(x)$, the path length $S$ of $y(x)$ can be expressed as: $$\int_A^B\sqrt{dx^2+y'(x)^2dx^2}$$
  • Factoring out $dx$ gets us: $$S=\int_A^B\sqrt{1+y'(x)^2}dx$$

Optimising a functional.

  • $S$ is not dependent on a variable. It depends on a function ($y(x)$).
  • This means that the classical differentiate-and-set-to-0 approach doesn't work.
  • There's an intuitive, but very long derivation for the solution to the problem, but we'll settle for learning how to use it.

The most powerful equation in all of mathematics*

$$\underbrace{\frac{\partial F}{\partial g}}_{\text{effect of }g(x)}-\underbrace{\frac{d}{dx}}_{\text{change along }x}\;\;\underbrace{\frac{\partial F}{\partial g'}}_{\text{effect of }g'(x)}=0$$
*Still probably not, but "One of many very cool and useful equations" makes for a bad title.

Using it: the shortest path.

  • Here $g=y$ and $F=\sqrt{1+y'^2}$, so $\frac{\partial F}{\partial y}=0$ and $\frac{\partial F}{\partial y'}=\frac{y'}{\sqrt{1+y'^2}}$.
  • The equation becomes $\frac{d}{dx}\frac{y'}{\sqrt{1+y'^2}}=0$, so $\frac{y'}{\sqrt{1+y'^2}}$ is constant.
  • That is only possible if $y'$ is constant, so $y(x)=mx+c$.
  • The shortest path between two points is a straight line. Wow...

How to use the magic box.

  1. Write what you want to optimise as $\int F(x,g,g')\,dx$.
  2. Compute $\frac{\partial F}{\partial g}$ and $\frac{\partial F}{\partial g'}$.
  3. Plug them into the equation.
  4. Solve the resulting differential equation for $g(x)$.
  5. Use the start and end point to fix the constants.

Where we'll use it.

  • Water in a pipe: the speed profile with the least viscous loss.
  • A rolling ball: the path with the shortest travel time.
  • A hanging chain: the shape with the lowest potential energy.
  • Spinning water: the surface with the lowest potential energy.

Why is water fastest in the middle of a pipe?

The problem.

  • Water flows through a pipe of radius $R$ at a fixed flow rate $D_0$.
  • It sticks to the wall: $u(R)=0$.
  • We want the speed profile $u(r)$, where $r$ is the distance from the centre.

Setting it up.

  • Assume nature picks the profile with the least viscous loss:
$$E=\int_0^R \pi\mu\left(\frac{du}{dr}\right)^2 r\,dr$$
  • But the flow rate is fixed. The total flow has to be $D_0$:
$$\int_0^R u(r)\,r\,dr=\frac{D_0}{2\pi}$$

A multiplier for the flow rate.

  • We cannot pick any $u(r)$, so we add the condition to the functional with a multiplier $\lambda$:
$$F=\pi\mu\,u'^2\,r+\lambda\,u\,r$$
$$\frac{\partial F}{\partial u}-\frac{d}{dr}\frac{\partial F}{\partial u'}=0 \;\Rightarrow\; \frac{d}{dr}\left(u'\,r\right)=\frac{\lambda r}{2\pi\mu}$$

Solving it.

$$u'\,r=\frac{\lambda}{4\pi\mu}r^2+C_1$$
$$u'(0)=0 \;\Rightarrow\; C_1=0 \;\Rightarrow\; u'=\frac{\lambda}{4\pi\mu}r$$
$$u(r)=\frac{\lambda}{8\pi\mu}r^2+C_2$$
$$u(R)=0 \;\Rightarrow\; u(r)=\frac{\lambda}{8\pi\mu}\left(r^2-R^2\right)$$

Fixing the multiplier.

$$\int_0^R \frac{\lambda}{8\pi\mu}\left(r^2-R^2\right)r\,dr=-\frac{\lambda R^4}{32\pi\mu}=\frac{D_0}{2\pi}$$
$$\lambda=-\frac{16\,D_0\,\mu}{R^4}$$
$$u(r)=\frac{2D_0}{\pi R^4}\left(R^2-r^2\right)$$

A parabola.

What is the fastest way for a ball to roll down?

The problem.

  • A ball rolls from A down to B. No friction, only gravity.
  • The straight line is the shortest path. Is it also the fastest?
  • We want the best path $y(x)$.

Setting it up.

  • Measure $y$ downward from A. Energy conservation gives the speed: $v=\sqrt{2gy}$.
  • Time is path length divided by speed:
$$T=\int \frac{\sqrt{1+y'^2}}{\sqrt{2gy}}\,dx$$
  • Dropping the constant: $F=\sqrt{\dfrac{1+y'^2}{y}}$.

A shortcut.

  • $F$ does not contain $x$. Then the equation can be integrated once:
$$F-y'\frac{\partial F}{\partial y'}=\text{const}$$
$$\frac{1}{\sqrt{y}\sqrt{1+y'^2}}=\text{const} \;\Rightarrow\; y\left(1+y'^2\right)=k$$

The fastest path.

$$x=\frac{k}{2}\left(\theta-\sin\theta\right)$$
$$y=\frac{k}{2}\left(1-\cos\theta\right)$$

A cycloid: the path of a point on a rolling wheel.

What shape does a hanging chain take?

The problem.

  • A chain of fixed length $L$ hangs between two nails.
  • It looks a bit like a parabola.
  • We want its shape $y(x)$.

Setting it up.

  • Nature picks the shape with the lowest potential energy, for a chain of fixed length $L$:
$$U=\rho g\int y\sqrt{1+y'^2}\,dx$$
$$\int \sqrt{1+y'^2}\,dx=L$$
$$F=(y+\lambda)\sqrt{1+y'^2}$$

Same shortcut.

  • Again $F$ does not contain $x$:
$$F-y'\frac{\partial F}{\partial y'}=\frac{y+\lambda}{\sqrt{1+y'^2}}=C$$
$$1+y'^2=\frac{(y+\lambda)^2}{C^2}$$

The catenary.

$$y'=\sqrt{\frac{(y+\lambda)^2}{C^2}-1}$$
$$y(x)=C\cosh\!\left(\frac{x}{C}\right)-\lambda$$

Not a parabola. It is a hyperbolic cosine.

What shape is the surface of water in a spinning bucket?

The problem.

  • A cylinder of radius $R$ is filled with water up to a height $H_0$.
  • Spin it with angular speed $\omega$. The water climbs up the wall.
  • We want the height $h(r)$ of the surface, where $r$ is the distance from the axis.

Setting it up.

  • Nature picks the lowest total potential energy: gravity plus centrifugal.
$$U=\rho g z-\frac{\rho\,\omega^2 r^2}{2}$$
  • Adding it up over all the water:
$$E=\pi\rho\int_0^R\left(g\,r\,h^2-\omega^2 r^3 h\right)dr$$
  • The amount of water is fixed:
$$\int_0^R h\,r\,dr=\frac{R^2H_0}{2}$$

A multiplier for the water.

  • Add the condition with a multiplier $\lambda$ (dropping the common factor $\pi\rho$):
$$F=g\,r\,h^2-\omega^2 r^3 h+\lambda\,r\,h$$
  • $F$ does not contain $h'$. So the equation shrinks to $\frac{\partial F}{\partial h}=0$:
$$2\,g\,r\,h-\omega^2 r^3+\lambda r=0 \;\Rightarrow\; h(r)=\frac{\omega^2 r^2-\lambda}{2g}$$

Fixing the multiplier.

$$\int_0^R\frac{\omega^2 r^2-\lambda}{2g}\,r\,dr=\frac{\omega^2R^4}{8g}-\frac{\lambda R^2}{4g}=\frac{R^2H_0}{2}$$
$$\lambda=\frac{\omega^2R^2}{2}-2gH_0$$
$$h(r)=H_0+\frac{\omega^2}{2g}\left(r^2-\frac{R^2}{2}\right)$$

A paraboloid.

A word of caution.

  • The equation finds stationary functions: maxima, minima or saddle points.
  • You still have to check which one you got.
  • You get a differential equation, not an answer. Solving it can be hard.

Inspired by...