---
title: Area between curves and net change
heading: Total, net and in-between
eyebrow: A5 · Lesson 48 · Area and net change
xp: 40
---

::: hook
A battery is charged with a current that sometimes reverses: regenerative braking pushes charge in, acceleration pulls it out. The integral of the current gives the net change in stored charge. The integral of its absolute value gives the total charge that moved, which is what wears the battery. And the area *between* two curves, like a supply's ripple between its upper and lower envelopes or the gap between a signal and its filtered version, is the integral of their difference.
:::

::: play
- The curves are $f(x) = 2\sin x$ and $g(x) = \sin(2x)$ on $[0, \pi]$.
- The readouts show $\int f$, $\int g$, and the area between them. Why is $\int_0^\pi g = 0$ even though $g$ is far from zero?
:::
:::

```sim plot
view: graph
x: x = 0..3.1416
y: y = -1.5..2.5
plot: 2*sin(x) | label: f = 2 sin x
plot: sin(2*x) | color: ch2 | label: g = sin 2x
plot: 2*sin(x) | fill: 0..3.1416 | color: ch3
readout: ∫ f = 4 | digits: 4
readout: ∫ g = 0 | digits: 4
readout: ∫ |g| = 2 | digits: 4
```

::: predict
## A current is $+3$ A for 2 s, then $-1$ A for 4 s. What net charge was delivered, and how much charge moved in total?

- [ ] Net 10 C, total 10 C
- [x] Net 2 C, total 10 C
- [ ] Net 2 C, total 2 C
- [ ] Net 6 C, total 4 C

::: reveal
Net 2 C ($6 - 4$), total 10 C ($6 + 4$). The integral of $i$ counts the reverse flow as negative; the integral of $|i|$ counts it all. Which one you want depends on the question: the stored charge changed by 2 C, but 10 C passed through the wires.
:::
:::

::: nameit
## Net change

The integral of a rate is the net change of the quantity:

$$\int_a^b F'(t)\,dt = F(b) - F(a)$$

- current integrates to net charge: $\int i\,dt = \Delta q$;
- power integrates to energy: $\int p\,dt = \Delta E$;
- velocity integrates to displacement (not distance).

## Total, not net

To count every bit regardless of direction, integrate the absolute value. In practice: find where the integrand changes sign, split the interval there, and add the sizes:

$$\int_0^{2\pi}|\sin t|\,dt = \int_0^{\pi}\sin t\,dt - \int_{\pi}^{2\pi}\sin t\,dt = 2 + 2 = 4$$

## Area between curves

If $f \ge g$ on $[a, b]$, the area between them is

$$\int_a^b \big(f(x) - g(x)\big)\,dx$$

If they cross, split at the crossings and use $|f - g|$. To find the crossings, solve $f(x) = g(x)$.

## Average value

The average of $f$ over $[a, b]$ is the height of the rectangle with the same area:

$$\bar f = \frac{1}{b - a}\int_a^b f(x)\,dx$$

Lesson 51 uses this for the DC and RMS values of waveforms.
:::

::: example
## Find the area between $y = x$ and $y = x^2$.

::: solution
1. **Find the crossings.** $x = x^2$ at $x = 0$ and $x = 1$.
2. **See which is on top.** Between them, $x \ge x^2$.
3. **Integrate.**
   $$\begin{aligned} \int_0^1 (x - x^2)\,dx &= \frac{1}{2} - \frac{1}{3} \\ &= \frac{1}{6} \end{aligned}$$

**Answer:** the area is $\tfrac16$.
:::
:::

::: example
## A capacitor's current is $i(t) = 2\cos(t)$ mA for $0 \le t \le \pi$ (time in ms). Find the net charge and the total charge moved.

::: solution
1. **Net charge.**
   $$\begin{aligned} \int_0^\pi 2\cos t\,dt &= 2\sin t\Big|_0^\pi \\ &= 0\ \mu\text{C} \end{aligned}$$
   (mA × ms = µC). The capacitor ends where it started.
2. **Split where the current changes sign.** It changes sign at $t = \pi/2$:
   $$\int_0^{\pi/2}2\cos t\,dt = 2$$
   $$\int_{\pi/2}^{\pi}2\cos t\,dt = -2$$
3. **Total charge.** Add the sizes of the two pieces: the total is 4 µC.

**Answer:** the net charge is 0, and the total charge moved is 4 µC.
:::
:::

::: example
## Find the area between $y = \sin x$ and $y = \cos x$ from 0 to $\pi/2$.

::: solution
1. **Find the crossing.** They cross at $\pi/4$. Before it, $\cos x$ is on top; after it, $\sin x$ is.
2. **Split the integral.**
   $$\begin{aligned} A &= \int_0^{\pi/4}(\cos x - \sin x)\,dx \\ &\quad + \int_{\pi/4}^{\pi/2}(\sin x - \cos x)\,dx \\ &= (\sqrt{2} - 1) + (\sqrt{2} - 1) \\ &= 0.828 \end{aligned}$$
3. **Why split.** Integrating $\cos x - \sin x$ straight across would give 0, since the two pieces cancel. Area needs the top curve minus the bottom one on each piece.

**Answer:** the area is 0.828.
:::
:::

::: check
given: I1 = 2 | 3 | 5; T1 = 2 | 4; I2 = 1 | 2; T2 = 3 | 6
answer: I1*T1 - I2*T2
unit: C

## A current is $+\given{I1}$ A for {T1} s, then $-\given{I2}$ A for {T2} s. What net charge, in coulombs, was delivered?

::: right
Right. $\given{I1} \times \given{T1} - \given{I2} \times \given{T2}$ = {answer} C.
:::

::: misses
- [I1*T1 + I2*T2] That's the total charge moved. Net counts the reverse flow as negative.
- [any] Not yet. Integrate the current, signs included.
:::
:::

::: check
given: I1 = 2 | 3 | 5; T1 = 2 | 4; I2 = 1 | 2; T2 = 3 | 6
answer: I1*T1 + I2*T2

## Same current: $+\given{I1}$ A for {T1} s, then $-\given{I2}$ A for {T2} s. How much charge moved in total?

::: right
Right. $\int |i|\,dt$ = {answer} C.
:::

::: misses
- [I1*T1 - I2*T2] That's the net charge. Total counts both directions as positive.
- [any] Not yet. Integrate the absolute value.
:::
:::

::: check
given: n = 1 | 2 | 3
answer: 1/2 - 1/(n + 2)
tolerance: 0.5%

## Find the area between $y = x$ and $y = x^{\given{n}+1}$ on $[0, 1]$.

::: right
Right. $\int_0^1 (x - x^{n+1})\,dx = \frac{1}{2} - \frac{1}{n + 2}$ = {answer}.
:::

::: misses
- [1/2 + 1/(n + 2)] Subtract: $x$ is on top.
- [any] Not yet. Integrate top minus bottom.
:::
:::

::: check
given: A = 1 | 3 | 5
answer: 4*A

## What is $\int_0^{2\pi}|\given{A}\sin t|\,dt$?

::: right
Right. Each half-cycle contributes $2 \times \given{A}$: {answer}.
:::

::: misses
- [0] That's the net integral. With the absolute value, nothing cancels.
- [2*A] That's one half-cycle. There are two.
- [any] Not yet. Split at $\pi$ and add the sizes.
:::
:::

::: check
given: a = 2 | 4; b = 1 | 3
answer: a/2 + b
tolerance: 0.5%

## What is the average value of $f(x) = \given{a}x + \given{b}$ over $[0, 1]$?

::: right
Right. $\int_0^1 (ax + b)\,dx = \frac{a}{2} + b$, divided by the length 1.
:::

::: misses
- [a + b] That's the value at $x = 1$.
- [b] That's the value at $x = 0$.
- [any] Not yet. Integrate and divide by the interval's length.
:::
:::

::: check
kind: parts
given: a = 1 | 2 | 3

## Compare $y = \given{a}x$ and $y = x^2$.

::: part
answer: a^3/6
tolerance: 0.5%

### What is the area between them on $[0, \given{a}]$, where the line is on top?

::: misses
- [a^3/2] Subtract the parabola: $\int_0^a(ax - x^2)\,dx$.
- [any] Top minus bottom, integrated between the crossings.
:::
:::

::: part
answer: -2*a^3/3
tolerance: 0.5%

### What is $\int_0^{2\given{a}}(\given{a}x - x^2)\,dx$?

::: misses
- [any] Past $x = a$ the parabola is on top, so this piece is negative.
:::
:::

::: part
answer: a^3
tolerance: 0.5%

### What is the total area between the curves on $[0, 2\given{a}]$?

::: misses
- [2*a^3/3] Areas don't cancel: add the absolute values of the two pieces.
- [any] $\frac{a^3}{6} + \frac{5a^3}{6}$.
:::
:::
:::

::: check
kind: derivation
vars: k = 0.5..4

## Find the area between $y = kx$ and $y = x^2$.

::: step
answer: k

### Where do they cross, other than 0?
:::

::: step
answer: k^3/6

### Integrate the top minus the bottom between the crossings.
:::

::: right
Right. The area is $k^3/6$: doubling the slope multiplies it by 8.
:::
:::

::: explain
## A battery's charging current reverses direction at times. Why might an engineer want both $\int i\,dt$ and $\int |i|\,dt$?

::: model
$\int i\,dt$ is the net change in stored charge, which tells you how full the battery ends up. $\int |i|\,dt$ is the total charge that flowed in either direction, which matters for losses and wear: every coulomb that goes in and out again heats the battery's resistance and contributes to aging, even though it doesn't change the final state of charge. The two answers to "how much charge?" serve different purposes.
:::
:::

::: practice

::: check
given: k = 2..8 int
answer: 1/2 - 1/(k + 1)
tolerance: 0.5%

## What is the area between $y = x$ and $y = x^{\given{k}}$ on $[0, 1]$?

::: misses
- [any] $\int_0^1 (x - x^k)\,dx = \frac{1}{2} - \frac{1}{k + 1}$.
:::
:::

::: check
given: A = 2 | 5; w = 2 | 4
answer: 2*A/w

## What is $\int_0^{\pi/\given{w}}\given{A}\sin(\given{w}t)\,dt$?

::: misses
- [2*A] The chain rule brings a $1/\omega$.
- [any] $\frac{A}{\omega}(1 - \cos\pi)$.
:::
:::

::: check
given: v1 = 3 | 5; v2 = 1 | 2
answer: v1 - v2
unit: V·s

## Two signals: $v_1$ = {v1} V and $v_2$ = {v2} V, both constant for 1 s. What is the area between them, in V·s?

::: misses
- [v1 + v2] Subtract the lower from the upper.
- [any] $\int (v_1 - v_2)\,dt$.
:::
:::
:::
