---
title: Antiderivatives and initial values
heading: Running a derivative backwards
eyebrow: A5 · Lesson 36 · Antiderivatives
xp: 40
---

::: hook
You know the voltage across an inductor, and the inductor's law tells you the rate of change of its current: $di/dt = v/L$. To get the current itself, you have to run the derivative backwards. That's finding an **antiderivative**. And since adding any constant leaves a derivative unchanged, the answer isn't fixed until you know one value, usually the current at $t = 0$. Charge from current, velocity from acceleration, angle from angular speed: all the same problem.
:::

::: play
- The curves are antiderivatives of $f(x) = 2x$: the family $x^2 + C$.
- Change $C$. Do the slopes at any $x$ change?
- Pick the curve that passes through the marked point $(1, 3)$.
:::
:::

```sim plot
view: graph
x: x = -2.5..2.5
y: y = -3..8
slider: C = -2..4 step 0.5 = 0
plot: x^2 + C | label: x² + C
plot: x^2 - 2 | dashed | color: ch3
plot: x^2 + 4 | dashed | color: ch3
point: 1, 3 | label: must pass here
readout: y(1) = 1 + C | digits: 3
```

::: predict
## The current in a 2 H inductor is 1 A at $t = 0$, and a constant 6 V is applied. What is the current at $t = 2$ s?

- [ ] 6 A
- [ ] 3 A
- [x] 7 A
- [ ] 12 A

::: reveal
7 A. $\frac{di}{dt} = \frac{v}{L} = 3$ A/s, so $i = 3t + C$. The starting value fixes $C = 1$, and at $t = 2$, $i = 7$ A. Without the initial current you'd only know the current *changed* by 6 A.
:::
:::

::: nameit
## Antiderivatives

$F$ is an **antiderivative** of $f$ if $F' = f$. Since constants differentiate to zero, all antiderivatives of $f$ are $F + C$ (lesson 28 proved there are no others). The family is written

$$\int f(x)\,dx = F(x) + C$$

the **indefinite integral**.

## A table to know

Read each line of the derivative table backwards:

| $f(x)$ | $\int f\,dx$ |
|---|---|
| $x^n$ ($n \ne -1$) | $\frac{x^{n+1}}{n + 1} + C$ |
| $\frac{1}{x}$ | $\ln\lvert x\rvert + C$ |
| $e^{kx}$ | $\frac{1}{k}e^{kx} + C$ |
| $\sin kx$ | $-\frac{1}{k}\cos kx + C$ |
| $\cos kx$ | $\frac{1}{k}\sin kx + C$ |

and integrals of sums and constant multiples work term by term. Check any antiderivative by differentiating it.

## Initial value problems

Given $\frac{dy}{dt} = f(t)$ and $y(0) = y_0$: integrate to get $y = F(t) + C$, then choose $C$ so that $y(0) = y_0$. In circuits:

$$q(t) = q(0) + \int_0^t i\,dt \qquad i_L(t) = i_L(0) + \frac{1}{L}\int_0^t v_L\,dt \qquad v_C(t) = v_C(0) + \frac{1}{C}\int_0^t i_C\,dt$$

The initial values are the continuous quantities from lesson 6: a capacitor's voltage and an inductor's current, which carry over from before a switch.

## Constant inputs give ramps

A constant voltage across an inductor makes its current ramp linearly; a constant current into a capacitor makes its voltage ramp. Integrating a constant gives a straight line, which is how integrator circuits and ramp generators work.
:::

::: example
## Find $y$ if $y' = 3x^2 - 4x + 1$ and $y(1) = 5$.

::: solution
1. **Antidifferentiate.**
   $$y = x^3 - 2x^2 + x + C$$
2. **Use $y(1) = 5$.**
   $$1 - 2 + 1 + C = 5$$
   so $C = 5$, and $y = x^3 - 2x^2 + x + 5$.
3. **Check.** $y' = 3x^2 - 4x + 1$ ✓ and $y(1) = 5$ ✓.

**Answer:** $y = x^3 - 2x^2 + x + 5$.
:::
:::

::: example
## A 10 µF capacitor starts at 2 V. A current $i = 5\cos(100t)$ mA flows into it. Find its voltage.

::: solution
1. **Rate of change of the voltage.**
   $$\begin{aligned} \frac{dv}{dt} &= \frac{i}{C} \\ &= \frac{0.005}{10^{-5}}\cos(100t) \\ &= 500\cos(100t)\ \text{V/s} \end{aligned}$$
2. **Integrate.**
   $$v = 5\sin(100t) + C$$
3. **Use the starting voltage.** At $t = 0$, $v = 2$, so $C = 2$:
   $$v(t) = 2 + 5\sin(100t)\ \text{volts}$$
4. **What it means.** The capacitor's voltage swings ±5 V around its starting 2 V, lagging the current by a quarter cycle, as A3 said it should.

**Answer:** $v(t) = 2 + 5\sin(100t)$ volts.
:::
:::

::: example
## A 2 mH inductor has $v = 5\sin(1000t)$ V across it, and its current starts at zero. Find the current.

::: solution
1. **Integrate the voltage.**
   $$\begin{aligned} i &= \frac{1}{L}\int v\,dt \\ &= \frac{5}{0.002}\int\sin(1000t)\,dt \\ &= -\frac{5}{0.002 \times 1000}\cos(1000t) + C \\ &= -2.5\cos(1000t) + C \end{aligned}$$
2. **Use the starting current.** $i(0) = 0$ gives $C = 2.5$, so
   $$i = 2.5(1 - \cos 1000t)\ \text{A}$$
3. **What it means.** The current swings between 0 and 5 A, never negative: the starting condition sets a DC offset.

**Answer:** $i = 2.5(1 - \cos 1000t)$ A, swinging between 0 and 5 A.
:::
:::

::: check
kind: expression
given: a = 2 | 3; b = 4 | 5; c = 1 | 7
answer: a*x^3/3 + b*x^2/2 + c*x
vars: x = -2..2

## Find the antiderivative of $\given{a}x^2 + \given{b}x + \given{c}$ that is zero at $x = 0$.

::: right
Right. Raise each power by one and divide by the new power.
:::

::: misses
- [2*a*x + b] That's the derivative. Go the other way.
- [a*x^3 + b*x^2 + c*x] Divide each term by its new power: $x^3/3$, $x^2/2$.
- [any] Not yet. $\int x^n dx = \frac{x^{n+1}}{n + 1}$, term by term.
:::
:::

::: check
given: L = 0.5 | 2; V = 3 | 10; I0 = 0.5 | 1; t = 0.5 | 2
answer: I0 + V/L*t
unit: A

## A constant {V} V is applied across a {L} H inductor carrying {I0} A at $t = 0$. What is its current at $t$ = {t} s?

::: right
Right. $i = i(0) + \frac{V}{L}t$ = {answer}.
:::

::: misses
- [V/L*t] Add the starting current, {I0} A.
- [I0 + V*L*t] The rate is $V/L$, not $VL$.
- [any] Not yet. $di/dt = V/L$, then use $i(0)$.
:::
:::

::: check
given: C = 10 | 47; I = 1 | 5; w = 100 | 1000; V0 = 2 | 3
answer: V0 + I*1e-3/(C*1e-6*w)
unit: V

## A {C} µF capacitor starts at {V0} V, and $i = \given{I}\cos(\given{w}t)$ mA flows into it. What is the largest voltage it reaches?

::: right
Right. $v = V_0 + \frac{I}{C\omega}\sin\omega t$, peaking at $V_0 + \frac{I}{C\omega}$ = {answer}.
:::

::: misses
- [I*1e-3/(C*1e-6*w)] Add the starting voltage.
- [V0 + I*1e-3*w/(C*1e-6)] Integrating $\cos\omega t$ divides by $\omega$.
- [any] Not yet. Integrate $i/C$, then add $V_0$.
:::
:::

::: check
given: k = 2 | 3 | 5
answer: 1/k
tolerance: 0.5%

## Find $C$ so that $y = \frac{1}{\given{k}}e^{\given{k}x} + C$ has $y(0) = \frac{2}{\given{k}}$.

::: right
Right. $y(0) = \frac{1}{k} + C = \frac{2}{k}$, so $C = \frac{1}{k}$ = {answer}.
:::

::: misses
- [2/k] Subtract the $\frac{1}{k}e^0$ part.
- [any] Not yet. Substitute $x = 0$ and solve for $C$.
:::
:::

::: check
kind: expression
given: k = 2..9 int
answer: -cos(k*x)/k
vars: x = -2..2

## Find the antiderivative of $\sin(\given{k}x)$ with constant zero.

::: right
Right. $-\frac{1}{k}\cos kx$; differentiate to check.
:::

::: misses
- [cos(k*x)/k] Differentiating $\cos$ gives $-\sin$, so you need a minus sign.
- [-k*cos(k*x)] Divide by {k}, don't multiply.
- [any] Not yet. Which function has $\sin \given{k}x$ as its derivative?
:::
:::

::: check
kind: parts
given: a = 2 | 3; b = 1 | 4; y0 = 1 | 5

## $y' = \given{a}x^2 - \given{b}$ with $y(0) = \given{y0}$.

::: part
answer: a/3 - b + y0
tolerance: 0.5%

### What is $y(1)$?

::: misses
- [a/3 - b] Add the starting value.
- [any] $y = \frac{a}{3}x^3 - bx + y_0$.
:::
:::

::: part
answer: 8*a/3 - 2*b + y0
tolerance: 0.5%

### What is $y(2)$?

::: misses
- [any] Put $x = 2$ into the same antiderivative.
:::
:::

::: part
answer: (1 - cos(a))/a
tolerance: 0.5%

### Separately, what is $\int_0^1 \sin(\given{a}t)\,dt$?

::: misses
- [-cos(a)/a] Subtract the value at 0, $-\cos(0)/a$.
- [any] An antiderivative is $-\cos(at)/a$.
:::
:::
:::

::: check
kind: derivation
vars: V = 1..10, L = 0.001..0.01, w = 100..1000, t = 0..0.01

## An inductor has $v = V\sin\omega t$ across it and $i(0) = 0$. Find $i(t)$ from $i = \frac{1}{L}\int v\,dt$.

::: step
answer: -V*cos(w*t)/(L*w)

### Write an antiderivative of $\frac{V}{L}\sin\omega t$ (with no constant).
:::

::: step
answer: V/(L*w)

### What constant makes $i(0) = 0$?
:::

::: step
answer: V/(L*w)*(1 - cos(w*t))

### Write $i(t)$.
:::

::: right
Right. $i = \frac{V}{\omega L}(1 - \cos\omega t)$: a sinusoid riding on a DC offset set by when the switch closed.
:::
:::

::: explain
## Why does every indefinite integral carry a "+ C", and what fixes C in a circuit problem?

::: model
Differentiating kills constants, so a function and that function plus any constant have the same derivative; running the derivative backwards can't tell them apart. The "+ C" says the antiderivative is only known up to a constant. In a circuit, C is fixed by a known value at one moment, usually the starting condition: the capacitor's voltage or the inductor's current just after a switch, which equals its value just before.
:::
:::

::: practice

::: check
kind: expression
given: n = 3 | 4 | 5
answer: x^(n + 1)/(n + 1)
vars: x = 0..2

## Find the antiderivative of $x^{\given{n}}$ that is zero at 0.

::: misses
- [n*x^(n - 1)] That's the derivative.
- [any] $\frac{x^{n+1}}{n + 1}$.
:::
:::

::: check
given: I = 2 | 5; t = 3 | 10; q0 = 1 | 4
answer: q0 + I*t

## A constant {I} mA flows into a capacitor that started with {q0} mC of charge. How many mC does it hold after {t} s?

::: misses
- [I*t] Add the starting charge.
- [any] $q = q_0 + It$.
:::
:::

::: check
given: a = 1 | 3; y0 = 2 | 5
answer: y0 + a*(exp(1) - 1)
tolerance: 0.5%

## $y' = \given{a}e^x$ and $y(0) = \given{y0}$. What is $y(1)$?

::: misses
- [a*exp(1)] Use the initial value: $C = y_0 - a$.
- [any] $y = ae^x + (y_0 - a)$.
:::
:::
:::
