---
title: Energy and work as integrals
heading: Where ½CV² comes from
eyebrow: A5 · Lesson 52 · Energy and work
xp: 40
---

::: hook
Every engineer knows a capacitor stores $\frac{1}{2}CV^2$. Where does the half come from? Charging the capacitor, the first bit of charge goes on at nearly zero voltage and costs almost no energy; the last bit goes on at the full voltage. The energy is the sum of every bit of charge times the voltage it faced, an integral, and the voltage rising in a straight line is what produces the half. The same integral gives the energy in an inductor, the heat in a resistor, and the work a varying force does.
:::

::: play
- The line is the capacitor's voltage against the charge on it, $v = q/C$. The shaded triangle's area is the work done to charge it.
- Change the final voltage. How does the area grow?
:::
:::

```sim plot
view: graph
x: q = 0..60 µC
y: v = 0..12 V
slider: C = 1..10 = 5 µF
slider: V = 1..12 step 0.5 = 10 V
plot: q/C | label: v = q/C | samples: 400
plot: q/C | fill: 0..C*V | color: ch2
marker: x = C*V | label: Q = CV
readout: energy = 0.5*C*1e-6*V^2*1e6 µJ | digits: 4
```

::: predict
## A 10 µF capacitor is charged from 0 to 100 V. How much energy does it store?

- [ ] 0.1 J
- [x] 0.05 J
- [ ] 1 mJ
- [ ] 10 J

::: reveal
0.05 J. $\frac{1}{2}CV^2 = \frac{1}{2} \times 10^{-5} \times 10^4 = 0.05$ J. If all the charge had been pushed on against the full 100 V the energy would be $QV = 0.1$ J; it's half that, because the voltage rose gradually as the charge built up.
:::
:::

::: nameit
## Energy is the integral of power

Power is the rate of energy flow, so the energy delivered between $t_1$ and $t_2$ is

$$E = \int_{t_1}^{t_2} p(t)\,dt = \int_{t_1}^{t_2} v(t)\,i(t)\,dt$$

## A capacitor

With $i = C\frac{dv}{dt}$, the power is $p = Cv\frac{dv}{dt}$, so charging from 0 to $V$ takes

$$E = \int Cv\,\frac{dv}{dt}\,dt = \int_0^V Cv\,dv = \frac{1}{2}CV^2$$

Seen in terms of charge: each small charge $dq$ is pushed on against the voltage $q/C$ already there, so $E = \int_0^Q \frac{q}{C}\,dq = \frac{Q^2}{2C}$, the triangle under the line in the sim.

## An inductor

With $v = L\frac{di}{dt}$, the same steps give

$$E = \int_0^I Li\,di = \frac{1}{2}LI^2$$

stored in the magnetic field, and released when the current falls.

## A resistor

A resistor stores nothing; it turns all its power into heat. Over time, $E = \int i^2R\,dt$. When a capacitor charged to $V_0$ discharges through a resistor, $i = \frac{V_0}{R}e^{-t/RC}$ and

$$\int_0^\infty \frac{V_0^2}{R}e^{-2t/RC}\,dt = \frac{V_0^2}{R}\cdot\frac{RC}{2} = \frac{1}{2}CV_0^2$$

every joule the capacitor held, whatever the resistance.

## Work by a varying force

In mechanics, $W = \int F\,dx$. Stretching a spring ($F = kx$) by $X$ takes $\frac{1}{2}kX^2$: the same half, for the same reason.
:::

::: example
## A 47 µF capacitor is charged from 5 V to 12 V. How much energy was added?

::: solution
1. **Integrate $Cv\,dv$.**
   $$\begin{aligned} W &= \int_5^{12} Cv\,dv \\ &= \frac{1}{2}C(12^2 - 5^2) \\ &= \frac{1}{2} \times 47 \times 10^{-6} \times 119 \\ &= 2.80\ \text{mJ} \end{aligned}$$
2. **A common slip.** Squaring the difference gives $\frac{1}{2}C(12 - 5)^2 = 1.15$ mJ, which is wrong: energy goes as the square of the voltage, so you subtract the squares.

**Answer:** 2.80 mJ was added.
:::
:::

::: example
## A current $i = 2e^{-t/0.01}$ A flows through a 5 Ω resistor from $t = 0$ onward. How much heat does it produce?

::: solution
1. **Integrate the power.**
   $$\begin{aligned} E &= \int_0^\infty i^2R\,dt \\ &= \int_0^\infty 4 \cdot 5\,e^{-t/0.005}\,dt \\ &= 20 \times 0.005 \\ &= 0.1\ \text{J} \end{aligned}$$
2. **Note the exponent.** Squaring the current halves the time constant, from 10 ms to 5 ms.

**Answer:** the resistor produces 0.1 J of heat.
:::
:::

::: example
## A 10 mH inductor carries 3 A. How much energy does it store, and where does it go if the current is switched into a 100 Ω resistor?

::: solution
1. **Stored energy.**
   $$\begin{aligned} W &= \tfrac12LI^2 \\ &= \tfrac12 \times 0.01 \times 9 \\ &= 45\ \text{mJ} \end{aligned}$$
2. **The decay.** Switched into the resistor, the current decays as $3e^{-t/\tau}$ with $\tau = L/R = 0.1$ ms.
3. **Heat in the resistor.**
   $$\begin{aligned} \int_0^\infty 9e^{-2t/\tau}\,100\,dt &= 900 \times \tau/2 \\ &= 45\ \text{mJ} \end{aligned}$$
4. **Check.** The resistor turns all 45 mJ into heat, so the energy is all accounted for.

**Answer:** the inductor stores 45 mJ, and all of it becomes heat in the resistor.
:::
:::

::: check
given: C = 10 | 47 | 220; V = 5 | 12 | 50
answer: 0.5*C*1e-6*V^2
unit: J

## How much energy does a {C} µF capacitor at {V} V store?

::: right
Right. $\frac{1}{2}CV^2$ = {answer}.
:::

::: misses
- [C*1e-6*V^2] Include the one half: the voltage rose gradually as the charge went on.
- [0.5*C*V^2] Put $C$ in farads.
- [0.5*C*1e-6*V] Square the voltage.
- [any] Not yet. $E = \frac{1}{2}CV^2$.
:::
:::

::: check
given: C = 22 | 100; V1 = 3 | 5; V2 = 9 | 15
answer: 0.5*C*1e-6*(V2^2 - V1^2)
unit: J

## A {C} µF capacitor is charged from {V1} V to {V2} V. How much energy was added?

::: right
Right. $\frac{1}{2}C(V_2^2 - V_1^2)$ = {answer}.
:::

::: misses
- [0.5*C*1e-6*(V2 - V1)^2] Subtract the squares; don't square the difference.
- [0.5*C*1e-6*V2^2] That's the total at {V2} V. Subtract what it already had.
- [any] Not yet. Integrate $Cv\,dv$ from {V1} to {V2}.
:::
:::

::: check
given: L = 1 | 10 | 100; I = 0.5 | 2 | 5
answer: 0.5*L*1e-3*I^2
unit: J

## How much energy does a {L} mH inductor carrying {I} A store?

::: right
Right. $\frac{1}{2}LI^2$ = {answer}.
:::

::: misses
- [L*1e-3*I^2] Include the one half.
- [0.5*L*I^2] Put $L$ in henries.
- [any] Not yet. $E = \frac{1}{2}LI^2$.
:::
:::

::: check
given: I0 = 2 | 3; R = 5 | 10; tau = 5 | 20
answer: I0^2*R*tau*1e-3/2
unit: J

## A current $\given{I0}e^{-t/\tau}$ A, with $\tau$ = {tau} ms, flows through {R} Ω from $t = 0$ on. How much heat does the resistor produce?

::: right
Right. $\int_0^\infty I_0^2R\,e^{-2t/\tau}dt = I_0^2R\frac{\tau}{2}$ = {answer}.
:::

::: misses
- [I0^2*R*tau*1e-3] Squaring the current halves the time constant: the integral gives $\tau/2$.
- [I0*R*tau*1e-3/2] Power is $i^2R$: square the current.
- [any] Not yet. Integrate $i^2R$ from 0 to ∞.
:::
:::

::: check
kind: choice

## A capacitor charged to $V_0$ discharges completely through resistor $R$. How much heat does $R$ produce?

- [x] $\frac{1}{2}CV_0^2$, whatever $R$ is
- [ ] More for a bigger $R$, since it takes longer
- [ ] Less for a bigger $R$, since the current is smaller
- [ ] $CV_0^2$

::: right
Right. All the stored energy ends up as heat. A bigger $R$ gives a smaller current for longer, and the two effects cancel exactly.
:::

::: misses
- [2] The current is smaller, but it flows longer. Do the integral: $R$ cancels.
- [any] Where can the stored energy go?
:::
:::

::: check
kind: parts
given: C = 10 | 100; V = 5 | 12; R = 10 | 1000

## A {C} µF capacitor is charged from 0 to {V} V through a {R} Ω resistor from a {V} V source.

::: part
answer: 0.5*C*1e-6*V^2
unit: J
tolerance: 0.5%

### How much energy does the capacitor end with?

::: misses
- [any] $\tfrac12CV^2$.
:::
:::

::: part
answer: C*1e-6*V^2
unit: J
tolerance: 0.5%

### How much energy did the source deliver? (It moved charge $Q = CV$ at a steady {V} V.)

::: misses
- [0.5*C*1e-6*V^2] The source supplied the charge at its full voltage the whole time: $QV$.
- [any] $W = QV = CV^2$.
:::
:::

::: part
answer: 0.5*C*1e-6*V^2
unit: J
tolerance: 0.5%

### How much did the resistor turn into heat?

::: misses
- [any] The difference: source minus capacitor.
:::
:::
:::

::: check
kind: derivation
vars: C = 0.000001..0.0001, Q = 0.00001..0.001, V = 1..20

## Derive the energy stored in a capacitor by adding up the work to move each bit of charge.

::: step
answer: Q^2/(2*C)

### Moving $dq$ across the voltage $q/C$ takes work $\frac{q}{C}dq$. Integrate from 0 to $Q$.
:::

::: step
answer: C*V^2/2

### Write it in terms of $V$, using $Q = CV$.
:::

::: right
Right. $W = \frac{Q^2}{2C} = \tfrac12CV^2$: the half comes from the voltage rising as the charge builds.
:::
:::

::: explain
## Explain where the factor of one half in $\frac{1}{2}CV^2$ comes from.

::: model
Charging a capacitor means pushing charge onto it against the voltage that's already there, and that voltage grows in proportion to the charge, $v = q/C$. The first bit of charge goes on at almost zero voltage and costs almost nothing; the last goes on at the full voltage $V$. The energy is the area under the voltage-against-charge line, a triangle with base $Q = CV$ and height $V$, whose area is $\frac{1}{2}QV = \frac{1}{2}CV^2$. The half is the average voltage the charge was pushed against.
:::
:::

::: practice

::: check
given: k = 100 | 500; X = 0.01 | 0.05
answer: 0.5*k*X^2
unit: J

## How much work does stretching a spring ($k$ = {k} N/m) by {X} m take?

::: misses
- [k*X^2] Include the half.
- [any] $\int_0^X kx\,dx$.
:::
:::

::: check
given: Q = 10 | 100; C = 1 | 10
answer: (Q*1e-6)^2/(2*C*1e-6)
unit: J

## A {C} µF capacitor holds {Q} µC. How much energy does it store?

::: misses
- [(Q*1e-6)^2/(C*1e-6)] Include the half: $Q^2/(2C)$.
- [any] $E = Q^2/(2C)$.
:::
:::

::: check
given: P = 5 | 20; T = 10 | 60
answer: P*T
unit: J

## A constant {P} W is delivered for {T} s. How much energy is that?

::: misses
- [any] $\int p\,dt$ with $p$ constant.
:::
:::
:::
