---
title: Optimization
heading: Finding the best value where the slope is zero
eyebrow: A5 · Lesson 30 · Optimization
xp: 40
---

::: hook
A source with some internal resistance drives a load. Make the load resistance tiny and lots of current flows, but almost no voltage is left across the load. Make it huge and the voltage is all there, but hardly any current flows. Somewhere in between, the load gets the most power it possibly can. Where?

::: play
- The source is 10 V with internal resistance $R_s$. The curve is the power delivered to the load at each load resistance $R_L$ (on a log axis).
- Slide $R_L$ to find the top of the curve. Compare $R_L$ there with $R_s$.
- Change $R_s$. Does the peak follow it? Watch the efficiency in the strip at the peak.
:::
:::

```sim plot
view: graph
x: RL = 1..1k Ω log
y: P = 0..1.5 W
slider: Rs = 10..100 step 5 = 50 Ω
slider: R = 1..1000 = 20 Ω log
plot: 100*RL/(Rs + RL)^2 | label: power in the load
point: R, 100*R/(Rs + R)^2
marker: x = Rs | label: R_L = R_s
readout: P = 100*R/(Rs + R)^2 W
readout: efficiency = 100*R/(Rs + R) %
```

::: predict
## At the load resistance that gets the most power, what share of the source's power reaches the load?

- [ ] Nearly all of it
- [ ] 75%
- [x] Half
- [ ] 25%

::: reveal
Half. At the peak $R_L = R_s$, so the same current flows through two equal resistances and they split the power equally: half heats the load, half heats the source. Maximum power transfer and maximum efficiency are different goals. A radio receiver's antenna input wants the first; the power grid, which can't afford to waste half its output, wants the second and runs with loads far larger than the source resistance.
:::
:::

::: nameit
## Maxima and minima are where the slope is zero

A smooth function reaches a peak or a dip only where its graph is momentarily flat, so its derivative is zero. To optimize:

1. Write the quantity you care about as a function of the thing you can choose.
2. Differentiate and solve $f'(x) = 0$. These are the **critical points**.
3. Check what kind each is: if $f'$ goes from positive to negative it's a maximum (or $f'' < 0$ there); negative to positive, a minimum. Also check the ends of the allowed range, where the best value can sit with a nonzero slope.

**Maximum power transfer.** With source voltage $V_s$ and resistances $R_s$ and $R_L$ in series, the current is $V_s/(R_s + R_L)$ and the load's power is

$$P = \frac{V_s^2 R_L}{(R_s + R_L)^2}$$

By the quotient rule,

$$\frac{dP}{dR_L} = V_s^2\,\frac{(R_s + R_L)^2 - 2R_L(R_s + R_L)}{(R_s + R_L)^4} = V_s^2\,\frac{R_s - R_L}{(R_s + R_L)^3}$$

This is zero only at $R_L = R_s$, positive below it and negative above it, so that's the maximum, and the most power the source can deliver is

$$P_\text{max} = \frac{V_s^2}{4R_s}$$

In AC circuits the same argument gives the rule for matching an antenna or a speaker: the load should be the complex conjugate of the source impedance.
:::

::: example
## A source's load power is $P = 12I - 2I^2$ watts. What current maximizes it?

::: solution
1. **Set the derivative to zero.**
   $$P' = 12 - 4I$$
   which is zero at $I = 3$ A.
2. **Check it's a maximum.** $P'' = -4 < 0$.
3. **The maximum power.**
   $$\begin{aligned} P &= 36 - 18 \\ &= 18\ \text{W} \end{aligned}$$

**Answer:** 3 A, which gives the maximum power of 18 W.
:::
:::

::: example
## An open box is made from a 30 cm square sheet by cutting squares of side $x$ from the corners and folding up. What $x$ gives the largest volume?

::: solution
1. **Volume.**
   $$V = x(30 - 2x)^2$$
2. **Differentiate.**
   $$\begin{aligned} V' &= (30 - 2x)^2 - 4x(30 - 2x) \\ &= (30 - 2x)(30 - 6x) \end{aligned}$$
   zero at $x = 5$ (and at 15, where the box has no base).
3. **Largest volume.**
   $$\begin{aligned} V(5) &= 5 \times 20^2 \\ &= 2000\ \text{cm}^3 \end{aligned}$$

**Answer:** cut squares with $x = 5$ cm, for a volume of 2000 cm³.
:::
:::

::: example
## A cylindrical can must hold 1 liter. What radius and height use the least metal?

::: solution
1. **Height from the volume.** With $V = \pi r^2h = 1000$ cm³,
   $$h = \frac{1000}{\pi r^2}$$
2. **Surface area.**
   $$\begin{aligned} A(r) &= 2\pi r^2 + 2\pi rh \\ &= 2\pi r^2 + \frac{2000}{r} \end{aligned}$$
3. **Minimize.**
   $$A'(r) = 4\pi r - \frac{2000}{r^2}$$
   is zero when $r^3 = 500/\pi$, so $r = 5.42$ cm.
4. **Height and area.** $h = 10.84$ cm, so the height equals the diameter. The area is 554 cm².
5. **Real cans.** Real cans are taller than this because the metal for the ends costs more than for the side.

**Answer:** a radius of 5.42 cm and a height of 10.84 cm (equal to the diameter), using 554 cm² of metal.
:::
:::

::: check
given: Vs = 5 | 10 | 12 | 24 V; Rs = 4..100 sig 2 Ω
answer: Vs^2/(4*Rs)
unit: W
tolerance: 1%

## A {Vs} source has an internal resistance of {Rs}. What is the most power it can deliver to a load resistor?

::: right
Right. At $R_L = R_s$ the load gets $V_s^2/4R_s$ = {answer}.
:::

::: misses
- [Vs^2/Rs] That's the power if the full voltage were across $R_s$ alone. At the best load, the current is $V_s/2R_s$.
- [Vs^2/(2*Rs)] That's the total power drawn from the source at the best load. Only half of it reaches the load.
- [any] Not yet. Set $R_L = R_s$ and work out $V_s^2R_L/(R_s + R_L)^2$.
:::
:::

::: check
given: a = 2..9 int; b = 10..40 int
answer: b/(2*a)
tolerance: 0.5%

## At what $x$ does $f(x) = \given{b}x - \given{a}x^2$ reach its maximum?

::: right
Right. $f'(x) = \given{b} - 2\cdot\given{a}x$, which is zero at $x = \given{b}/(2\cdot\given{a})$.
:::

::: misses
- [b/a] That's where $f$ crosses zero again. The peak is halfway there.
- [any] Not yet. Set $f'(x) = \given{b} - 2\given{a}x$ to zero.
:::
:::

::: check
given: a = 2..9 int
answer: -sqrt(a/3)
tolerance: 0.5%

## $f(x) = x^3 - \given{a}x$ has a local maximum and a local minimum. At what $x$ is the maximum?

::: right
Right. $f'(x) = 3x^2 - \given{a} = 0$ at $x = \pm\sqrt{\given{a}/3}$; $f''(x) = 6x$ is negative at the negative root, so that's the maximum.
:::

::: misses
- [sqrt(a/3)] That's the local minimum: there $f'' = 6x > 0$, so the curve bends upward like a cup.
- [any] Not yet. Solve $3x^2 - \given{a} = 0$, then use the sign of $f''$ to tell which is which.
:::
:::

::: check
kind: choice

## A power station feeds a city through transmission lines. Should the city's load resistance be matched to the source's for maximum power transfer?

- [ ] Yes, to get the most power to the city
- [x] No: matching wastes half the power; the grid runs with loads much larger than its source resistance, for high efficiency
- [ ] It makes no difference
- [ ] Only at night

::: right
Right. Matching maximizes the power delivered for a given source, at 50% efficiency. A power system can always build more generation, but can't afford to burn half its output in its own resistance.
:::

::: misses
- [1] It would deliver the most power from that source, but heat the source and lines with an equal amount. Efficiency matters more here.
- [3] Efficiency depends strongly on the ratio: it's $R_L/(R_s + R_L)$.
- [any] Think about where the other half of the power goes at the matched point.
:::
:::

::: check
kind: parts
given: V = 500 | 1000 | 2000

## A closed cylindrical can must hold {V} cm³ with the least surface area.

::: part
answer: (V/(2*pi))^(1/3)
unit: cm
tolerance: 0.5%

### What radius, in cm?

::: misses
- [(V/pi)^(1/3)] Setting $A' = 4\pi r - 2V/r^2 = 0$ gives $r^3 = V/(2\pi)$.
- [any] Write the area in terms of $r$ alone, then set its derivative to zero.
:::
:::

::: part
answer: 2*(V/(2*pi))^(1/3)
tolerance: 0.5%

### What height?

::: misses
- [(V/(2*pi))^(1/3)] The height is the diameter, $2r$.
- [any] $h = V/(\pi r^2)$.
:::
:::

::: part
answer: 6*pi*(V/(2*pi))^(2/3)
unit: cm²
tolerance: 0.5%

### What is the least area, in cm²?

::: misses
- [any] $2\pi r^2 + 2\pi rh$ with $h = 2r$.
:::
:::
:::

::: check
kind: derivation
vars: p = 1..20, x = 0..5

## A rectangle has perimeter $p$. Find the largest area it can have.

::: step
answer: x*(p/2 - x)

### With one side $x$, write the area.
:::

::: step
answer: p/4

### Where is $dA/dx = 0$?
:::

::: step
answer: p^2/16

### What is the largest area?
:::

::: right
Right. The square, side $p/4$, encloses the most: $p^2/16$.
:::
:::

::: explain
## Why must a smooth function's slope be zero at a peak in the middle of its range?

::: model
Just before a peak the function is rising, so its slope is positive; just after, it's falling, so its slope is negative. A smooth slope can't jump from positive to negative without passing through zero, and that happens exactly at the top. If the slope weren't zero there, the function would still be rising (or falling) at that point, so a nearby point would be higher, and it wouldn't be the peak.
:::
:::

::: practice

::: check
given: P = 10..100 int
answer: P/4
tolerance: 0.5%

## A fence of total length {P} m encloses a rectangle. What side length gives the largest area?

::: misses
- [P/2] That's the sum of two neighboring sides. Write the area as $x(P/2 - x)$ and maximize.
- [any] Area $= x(\tfrac{P}{2} - x)$; set its derivative to zero.
:::
:::

::: check
given: Vs = 5..24 int; Rs = 1..50 int
answer: Vs^2/(4*Rs)
unit: W
tolerance: 1%

## A {Vs} V source with {Rs} Ω inside it: what is the most power it can deliver to a load?

::: misses
- [Vs^2/Rs] At the best load, the current is $V_s/2R_s$.
- [any] $P_\text{max} = V_s^2/4R_s$.
:::
:::

::: check
given: a = 3 | 5 | 7 | 9; b = 1..9 int
answer: b - a^2/4
tolerance: 0.5%

## What is the minimum value of $x^2 + \given{a}x + \given{b}$?

::: misses
- [-a/2] That's where the minimum is. The question asks for its value.
- [b] That's the value at $x = 0$, which isn't the lowest point.
- [any] Find where the slope is zero, $x = -\given{a}/2$, and put it back in.
:::
:::
:::
