---
title: Exponential and logarithmic functions
heading: How long until the capacitor reaches 3.3 V?
eyebrow: A2 · Lesson 10 · Exponentials and logarithms
xp: 40
---

::: hook
A capacitor charging toward 5 V follows $v = 5(1 - e^{-t/\tau})$. Asking "what's the voltage at time $t$?" is easy: put $t$ in. Engineers usually ask the reverse: when does it reach 3.3 V, the threshold where a logic input flips? That's undoing an exponential, and the tool for it is the natural logarithm. Every timing circuit, from a reset delay to a 555 oscillator, is designed with it.

::: play
- The two curves are $e^x$ and $\ln x$. The dashed line is $y = x$.
- Move $a$. The dot on $e^x$ is at $(a, e^a)$, and its partner on $\ln x$ is at $(e^a, a)$. How are the two dots placed relative to the dashed line?
- What is $\ln x$ for $x$ between 0 and 1?
:::
:::

```sim plot
view: graph
x: x = -3..6
y: y = -3..6
slider: a = -2..1.7 step 0.1 = 1
plot: exp(x) | label: eˣ
plot: ln(x) | color: ch2 | label: ln x
plot: x | dashed | color: ch3 | label: y = x
point: a, exp(a) | label: (a, eᵃ)
point: exp(a), a | label: (eᵃ, a)
readout: eᵃ = exp(a) | digits: 4
```

::: predict
## $e^x$ and $\ln x$ undo each other. What is $\ln(e^{7})$?

- [ ] $e^{7}$
- [x] 7
- [ ] $\ln 7$
- [ ] 1

::: reveal
7. The natural log asks "what power of $e$ gives this?", and the answer for $e^7$ is 7. That's why their graphs are mirror images in the line $y = x$: swapping input and output is exactly what an inverse does.
:::
:::

::: nameit
## The number $e$

$e = 2.71828\ldots$ is the base that makes exponential growth simplest. It's the limit of compounding more and more often:

$$\left(1 + \frac{1}{n}\right)^n \to e \quad \text{as } n \to \infty$$

($n = 10$ gives 2.594, $n = 1000$ gives 2.717.) Its special property, which calculus (A5) shows, is that $e^x$ grows at a rate equal to its own value. That's why every RC and RL circuit, every radioactive decay and every population with a fixed growth rate is written with $e$.

## The natural logarithm

$\ln x$ is the inverse of $e^x$:

$$e^{\ln x} = x \quad (x > 0) \qquad \ln(e^{x}) = x$$

It obeys the same rules as $\log_{10}$:

$$\ln(ab) = \ln a + \ln b \qquad \ln\frac{a}{b} = \ln a - \ln b \qquad \ln(a^n) = n\ln a$$

Values worth knowing: $\ln 1 = 0$, $\ln e = 1$, $\ln 2 = 0.693$, $\ln 10 = 2.303$. Numbers below 1 have negative logs, and $\ln x$ isn't defined for $x \le 0$.

**Any other base** converts through $\ln$:

$$\log_b x = \frac{\ln x}{\ln b}$$

so $\log_2 1000 = 6.908 / 0.693 = 9.97$.

## Solving for time

To solve $A e^{kt} = B$: divide by $A$, take $\ln$ of both sides, divide by $k$:

$$t = \frac{1}{k}\ln\frac{B}{A}$$

For a capacitor charging toward $V$ with time constant $\tau$, the time to reach $v$ is

$$v = V(1 - e^{-t/\tau}) \quad\Rightarrow\quad t = \tau \ln\frac{V}{V - v}$$

A 555 timer charges its capacitor from $\frac{1}{3}V$ to $\frac{2}{3}V$ toward $V$. The remaining gap goes from $\frac{2}{3}V$ to $\frac{1}{3}V$, a factor of 2, so the time is $\tau \ln 2 = 0.693\,RC$.
:::

::: example
## Solve $3e^{2t} = 48$.

::: solution
1. **Divide by 3.**
   $$e^{2t} = 16$$
2. **Take ln of both sides.**
   $$\begin{aligned} 2t &= \ln 16 \\ &= 2.773 \end{aligned}$$
   So $t = 1.386$.
3. **Check.**
   $$\begin{aligned} 3e^{2.773} &= 3 \times 16.0 \\ &= 48 \end{aligned}$$
4. **Exact form.** Note that $\ln 16 = 4\ln 2$, so $t = 2\ln 2$ exactly.

**Answer:** $t = 2\ln 2$, about 1.386.
:::
:::

::: example
## A capacitor charges toward 5 V with $\tau$ = 10 ms. When does it reach 3.3 V?

::: solution
1. **Use the charging formula, solved for time.**
   $$\begin{aligned} t &= \tau \ln\frac{V}{V - v} \\ &= 10\ \text{ms} \times \ln\frac{5}{5 - 3.3} \\ &= 10\ \text{ms} \times \ln 2.941 \\ &= 10.8\ \text{ms} \end{aligned}$$
2. **Sanity check.** After one time constant (10 ms) a capacitor is at 63% of the way, 3.16 V, just short of 3.3 V. So a little over 10 ms is right.

**Answer:** it reaches 3.3 V after 10.8 ms.
:::
:::

::: example
## A thermistor follows $R = R_0 e^{B(1/T - 1/T_0)}$, with $R_0$ = 10 kΩ at $T_0$ = 298.15 K and $B$ = 3950 K. What temperature makes it read 5 kΩ?

::: solution
1. **Take the natural log.** Divide by $R_0$ and take the natural log of both sides:
   $$\ln\frac{R}{R_0} = B\left(\frac{1}{T} - \frac{1}{T_0}\right)$$
2. **Solve for 1/T.**
   $$\frac{1}{T} = \frac{1}{T_0} + \frac{\ln(R/R_0)}{B}$$
3. **Put in the numbers.** With $\ln 0.5 = -0.6931$:
   $$\begin{aligned} \frac{1}{T} &= 0.003\,354 - 0.000\,175\,5 \\ &= 0.003\,179 \end{aligned}$$
   per kelvin.
4. **Invert.**
   $$T = 314.6\ \text{K}$$
   or 41.5 °C.
5. **Check the direction.** The resistance halved, so the part warmed up: this kind of thermistor loses resistance as it heats.

**Answer:** it reads 5 kΩ at 314.6 K, or 41.5 °C.
:::
:::

::: check
given: A = 2 | 3 | 5; k = 0.5 | 2 | 3; m = 4 | 10 | 25; let B = A*m
answer: ln(B/A)/k
tolerance: 0.5%

## Solve $\given{A}e^{\given{k}t} = \given{B}$ for $t$.

::: right
Right. $e^{\given{k}t} = \given{m}$, so $t = \ln(\given{m})/\given{k}$ = {answer}.
:::

::: misses
- [ln(B)/k] Divide both sides by {A} before taking the logarithm.
- [ln(B/A)*k] Divide by {k} at the end, since $\ln(e^{kt}) = kt$.
- [B/A/k] Take the natural log of {m} first.
- [any] Not yet. Divide by {A}, take $\ln$, then divide by {k}.
:::
:::

::: check
given: b = 2 | 3 | 5 | 8; x = 50 | 100 | 1000 | 4096
answer: ln(x)/ln(b)
tolerance: 0.5%

## What is $\log_{\given{b}} \given{x}$?

::: right
Right. $\ln \given{x} / \ln \given{b}$ = {answer}.
:::

::: misses
- [ln(b)/ln(x)] That's upside down: the base goes on the bottom.
- [ln(x)/b] Divide by $\ln \given{b}$, the log of the base, not the base itself.
- [log10(x)] That's base 10. Convert with $\ln x / \ln b$.
- [any] Not yet. $\log_b x = \ln x / \ln b$.
:::
:::

::: check
given: V = 5 | 12; f = 0.4 | 0.8 | 0.9 | 0.99; tau = 1 | 4.7 | 22 | 100; let v = f*V
answer: tau*ln(V/(V - v))
tolerance: 0.5%

## A capacitor charges toward {V} V with $\tau$ = {tau} ms. How many milliseconds until it reaches {v} V?

::: right
Right. $t = \tau\ln\dfrac{V}{V - v}$ = {answer} ms.
:::

::: misses
- [tau*ln(V/v)] Use the gap that's left, $V - v$: it's the gap that shrinks exponentially.
- [tau*v/V] The voltage doesn't rise in a straight line. Solve the exponential with a logarithm.
- [tau*ln((V - v)/V)] That's negative. Flip the fraction: $\ln(V/(V - v))$.
- [any] Not yet. Solve $v = V(1 - e^{-t/\tau})$ for $t$.
:::
:::

::: check
given: R = 1k..100k E12 Ω; C = 1n..10u E6 F
answer: R*C*ln(2)
unit: s

## A 555 timer charges its capacitor from a third to two-thirds of the supply, through {R} into {C}. How long does that take?

::: right
Right. The gap to the supply halves, so it takes $RC\ln 2 = 0.693RC$ = {answer}.
:::

::: misses
- [R*C] That's one time constant. The gap only needs to halve, which takes $\ln 2$ of a time constant.
- [R*C*ln(3)] The gap goes from two-thirds of the supply to one-third: a factor of 2, not 3.
- [any] Not yet. The remaining gap halves. How long does $e^{-t/RC}$ take to halve?
:::
:::

::: check
kind: expression
answer: 3 + 2*ln(x)
vars: x = 0.5..5

## Simplify $\ln(e^{3}x^{2})$, writing ln(x) for $\ln x$.

::: right
Right. $\ln(e^3) + \ln(x^2) = 3 + 2\ln x$.
:::

::: misses
- [3*2*ln(x)] The log of a product is a sum.
- [3 + ln(x)^2] $\ln(x^2) = 2\ln x$. The power comes out in front.
- [any] Not yet. Split the product, then bring the power down.
:::
:::

::: check
given: a = 2 | 3 | 4 | 7; b = 5 | 6 | 9
answer: a*b

## What is $e^{\ln \given{a} + \ln \given{b}}$?

::: right
Right. $\ln \given{a} + \ln \given{b} = \ln(\given{a} \times \given{b})$, and $e$ undoes $\ln$.
:::

::: misses
- [a + b] Adding logs multiplies the numbers.
- [any] Not yet. Combine the logs first: a sum of logs is the log of a product.
:::
:::

::: check
kind: parts
given: R0 = 10 | 47; B = 3435 | 3950; R = 5 | 22 | 30

## A thermistor follows $R = R_0 e^{B(1/T - 1/T_0)}$ with $R_0$ = {R0} kΩ at $T_0$ = 298.15 K and $B$ = {B} K. It reads {R} kΩ.

::: part
answer: ln(R/R0)
tolerance: 0.5%

### What is $\ln(R/R_0)$?

::: misses
- [log(R/R0)] That's the base-10 log. The formula uses $e$, so take $\ln$.
- [any] Divide the reading by $R_0$ and take the natural log.
:::
:::

::: part
answer: 1/(1/298.15 + ln(R/R0)/B)
unit: K
tolerance: 0.2

### What is the temperature, in kelvin?

::: misses
- [1/(1/298.15 - ln(R/R0)/B)] Check the sign: $1/T = 1/T_0 + \ln(R/R_0)/B$.
- [any] Solve for $1/T$, then take the reciprocal.
:::
:::

::: part
answer: 1/(1/298.15 + ln(R/R0)/B) - 273.15
unit: °C
tolerance: 0.2

### What is that in degrees Celsius?

::: misses
- [any] Subtract 273.15.
:::
:::
:::

::: check
kind: derivation
vars: V = 2..10, tau = 0.1..10, v = 0.1..1.5

## A capacitor charges as $v(t) = V(1 - e^{-t/\tau})$. Derive when it reaches $v$.

::: step
answer: 1 - v/V

### Rearrange so the exponential is alone: $e^{-t/\tau} = \ ?$
:::

::: step
answer: -tau*ln(1 - v/V)

### Take the natural log and solve for $t$.
:::

::: step
answer: tau*ln(V/(V - v))
form: simplified

### Rewrite it without the minus sign, as $\tau\ln(\ldots)$.
:::

::: right
Right. $t = \tau\ln\frac{V}{V - v}$, which grows without limit as $v$ approaches $V$: the capacitor never quite gets there.
:::
:::

::: explain
## Why are the graphs of $e^x$ and $\ln x$ mirror images of each other in the line $y = x$?

::: model
They're inverse functions: if $e^a = b$, then $\ln b = a$. So every point $(a, b)$ on the graph of $e^x$ has a partner $(b, a)$ on the graph of $\ln x$, with the coordinates swapped. Swapping the coordinates of a point reflects it in the line $y = x$, so the whole curve reflects into the other.
:::
:::

::: practice

::: check
given: A = 2 | 4 | 10; k = 0.1 | 0.4 | 5; m = 3 | 8 | 50; let B = A*m
answer: ln(B/A)/k
tolerance: 0.5%

## Solve $\given{A}e^{\given{k}t} = \given{B}$.

::: misses
- [ln(B)/k] Divide by {A} first.
- [ln(B/A)*k] Divide by {k} at the end.
- [any] Divide, take $\ln$, divide.
:::
:::

::: check
given: b = 2 | 4 | 6; x = 20 | 300 | 5000
answer: ln(x)/ln(b)
tolerance: 0.5%

## What is $\log_{\given{b}} \given{x}$?

::: misses
- [ln(b)/ln(x)] The base's log goes on the bottom.
- [any] $\ln x / \ln b$.
:::
:::

::: check
given: V = 3.3 | 5 | 12; f = 0.25 | 0.7 | 0.95; tau = 2 | 10 | 47; let v = f*V
answer: tau*ln(V/(V - v))
tolerance: 0.5%

## How many milliseconds does a capacitor charging toward {V} V with $\tau$ = {tau} ms take to reach {v} V?

::: misses
- [tau*ln(V/v)] Use the gap that's left, $V - v$.
- [any] $t = \tau \ln(V/(V - v))$.
:::
:::

::: check
given: V0 = 5 | 10 | 24; f = 0.5 | 0.2 | 0.05; tau = 3 | 15 | 68; let v = f*V0
answer: tau*ln(V0/v)
unit: ms
tolerance: 0.5%

## A capacitor discharges from {V0} V with $\tau$ = {tau} ms. When is it at {v} V, in ms?

::: misses
- [tau*ln(v/V0)] That's negative. Flip the fraction.
- [tau*(V0 - v)/V0] The decay is exponential. Use a logarithm.
- [any] Solve $v = V_0 e^{-t/\tau}$ for $t$.
:::
:::

::: check
given: A = 2 | 5 | 8; m = 2 | 3 | 10; t1 = 2 | 5; let Y = A*m
answer: ln(m)/t1
tolerance: 0.5%

## $y = Ae^{kt}$ is {A} at $t = 0$ and {Y} at $t$ = {t1}. What is $k$?

::: misses
- [ln(Y)/t1] Divide by $A$ = {A} first.
- [(Y - A)/t1] That's the average rate of change. The growth constant comes from a logarithm.
- [any] $e^{k t_1} = \given{Y}/\given{A}$; take $\ln$.
:::
:::

::: check
given: R = 10k..1M E6 Ω; C = 10n..1u E3 F
answer: R*C*ln(2)
unit: s

## How long does a 555 timer take to charge {C} through {R} from a third to two-thirds of its supply?

::: misses
- [R*C] Only $\ln 2$ of a time constant.
- [any] $0.693RC$.
:::
:::
:::
