---
title: Lines and linear functions
heading: A battery's voltage is a straight line in its current
eyebrow: A2 · Lesson 3 · Lines and linear functions
xp: 40
---

::: hook
Measure a battery with nothing connected and you read its full voltage. Connect a load and the reading drops, and the more current you draw, the more it drops, by the same amount for every extra ampere. Plot terminal voltage against current and you get a straight line. Its two numbers, where it starts and how steeply it falls, are the battery's open-circuit voltage and its internal resistance. A great deal of engineering is reading lines like this one.

::: play
- The falling line is the battery: $V = E - rI$. The rising line is the load resistor: $V = RI$.
- Raise the internal resistance $r$. What happens to the line's slope, and to the point where it meets the horizontal axis?
- Change the load $R$. Where the two lines cross is what the circuit actually does. Read its current and voltage.
:::
:::

```sim plot
view: graph
x: I = 0..10 A
y: V = 0..14 V
slider: E = 6..13 = 12 V
slider: r = 0.2..3 = 1 Ω
slider: R = 0.5..10 = 3 Ω
plot: E - r*I | label: battery, V = E − rI
plot: R*I | color: ch2 | label: load, V = RI
point: E/(R + r), R*E/(R + r) | label: operating point
readout: current = E/(R + r) A | digits: 3
readout: terminal voltage = R*E/(R + r) V | digits: 3
readout: short-circuit current = E/r A | digits: 3
```

::: predict
## A battery's line starts at 12 V and falls 1 V for every ampere drawn. What current would make its terminal voltage zero?

- [ ] 1 A
- [x] 12 A
- [ ] 6 A
- [ ] It never reaches zero

::: reveal
12 A. The voltage falls 1 V per ampere from 12 V, so it reaches zero at 12 A, where the line meets the horizontal axis. That's the short-circuit current, $E/r$: what the battery would push through a dead short (and why shorting a battery is dangerous when $r$ is small).
:::
:::

::: nameit
## Slope and intercept

A **linear function** changes by the same amount for every unit step in its input:

$$y = mx + b$$

- $m$ is the **slope**: the change in $y$ for each unit increase in $x$. Positive slopes rise to the right, negative ones fall.
- $b$ is the **$y$-intercept**: the value at $x = 0$, where the line crosses the vertical axis.
- The **$x$-intercept** is where $y = 0$: $x = -b/m$.

**From two points.** The slope is the rise over the run:

$$m = \frac{y_2 - y_1}{x_2 - x_1}$$

Then the intercept is $b = y_1 - m x_1$. Or skip $b$ and write the line straight from one point and the slope, the **point-slope form**:

$$y = y_1 + m(x - x_1)$$

**Lines that never meet, and lines at right angles.** Parallel lines have the same slope. Perpendicular lines have slopes whose product is −1: a line of slope 2 is at right angles to one of slope $-\frac{1}{2}$.

## Lines in circuits

A battery (or any real source) is an ideal voltage $E$ in series with an internal resistance $r$:

$$V = E - rI$$

The intercept is $E$, the open-circuit voltage, and the slope is $-r$. A load resistor obeys $V = RI$, a line through the origin with slope $R$. The circuit has to satisfy both at once, so it sits where the lines cross. You'll solve for crossing points algebraically in lesson 7.

**Two-point calibration.** A sensor whose output is linear in what it measures is calibrated with two known points, say its reading at 0 °C and at 100 °C. Every other reading follows from the line through them.
:::

::: example
## Find the line through $(2, 5)$ and $(6, 13)$, and where it crosses each axis.

::: solution
1. **Slope.**
   $$\begin{aligned} m &= \frac{13 - 5}{6 - 2} \\ &= \frac{8}{4} \\ &= 2 \end{aligned}$$
2. **Intercept.**
   $$\begin{aligned} b &= y_1 - m x_1 \\ &= 5 - 2 \times 2 \\ &= 1 \end{aligned}$$
   So $y = 2x + 1$.
3. **Axis crossings.** It crosses the vertical axis at $y = 1$, and the horizontal axis where $2x + 1 = 0$, at $x = -\frac{1}{2}$.
4. **Check with the second point.**
   $$2 \times 6 + 1 = 13$$

**Answer:** the line is $y = 2x + 1$. It crosses the vertical axis at $y = 1$ and the horizontal axis at $x = -\frac{1}{2}$.
:::
:::

::: example
## A car battery reads 12.6 V with nothing connected and 12.1 V while delivering 10 A. What are its internal resistance and its short-circuit current?

::: solution
1. **Slope.** The voltage fell by $12.6 - 12.1 = 0.5$ V for 10 A, so the slope is $-0.05$ V/A.
2. **Internal resistance.**
   $$\begin{aligned} r &= \frac{0.5\ \text{V}}{10\ \text{A}} \\ &= 0.05\ \Omega \end{aligned}$$
3. **Short-circuit current.** It's where the line reaches zero volts:
   $$\begin{aligned} I &= \frac{E}{r} \\ &= \frac{12.6}{0.05}\ \text{A} \\ &= 252\ \text{A} \end{aligned}$$
4. **Reality check.** A real battery's resistance rises at such currents, but the estimate shows why a dropped wrench across car battery terminals glows red.

**Answer:** the internal resistance is 0.05 Ω, and the short-circuit current is about 252 A.
:::
:::

::: example
## Near its operating point, a diode's current runs along a straight line through (0.65 V, 2 mA) and (0.70 V, 12 mA). Find the slope, its reciprocal, and where the line crosses the voltage axis.

::: solution
1. **Slope.**
   $$\begin{aligned} m &= \frac{(12 - 2)\ \text{mA}}{(0.70 - 0.65)\ \text{V}} \\ &= \frac{10\ \text{mA}}{0.05\ \text{V}} \\ &= 0.2\ \text{A/V} \end{aligned}$$
   or 0.2 S.
2. **Its reciprocal.** This is the diode's small-signal resistance at this current:
   $$\frac{1}{0.2\ \text{S}} = 5\ \Omega$$
   A small wiggle in voltage moves the current as a 5 Ω resistor would.
3. **Voltage-axis crossing.** The line reaches zero current at
   $$\begin{aligned} V &= 0.65 - \frac{2\ \text{mA}}{0.2\ \text{S}} \\ &= 0.65 - 0.01 \\ &= 0.64\ \text{V} \end{aligned}$$
4. **Where the line holds.** The real diode is curved, so this straight line only describes it near the two points it was drawn through.

**Answer:** the slope is 0.2 S, its reciprocal is 5 Ω, and the line crosses the voltage axis at 0.64 V.
:::
:::

::: check
given: m = 2 | 3 | -2 | 0.5 | -4; x1 = -1 | 1 | 2; dx = 2 | 4 | 5; b = -3 | 1 | 4; let x2 = x1 + dx; let y1 = m*x1 + b; let y2 = m*x2 + b
answer: m
tolerance: 0.5%

## A line passes through $(\given{x1}, \given{y1})$ and $(\given{x2}, \given{y2})$. What is its slope?

::: right
Right. Rise over run: $(\given{y2} - \given{y1}) / (\given{x2} - \given{x1})$ = {answer}.
:::

::: misses
- [1/m] That's run over rise. Slope is the change in $y$ divided by the change in $x$.
- [-m] Check the signs: subtract the coordinates in the same order, top and bottom.
- [any] Not yet. Divide the change in $y$ by the change in $x$.
:::
:::

::: check
given: m = 2 | -3 | 0.5 | 4; x1 = 1 | 2 | 3; y1 = 4 | 7 | -2
answer: y1 - m*x1
tolerance: 0.5%

## A line has slope {m} and passes through $(\given{x1}, \given{y1})$. Where does it cross the vertical axis?

::: right
Right. $b = y_1 - m x_1 = \given{y1} - (\given{m})(\given{x1})$ = {answer}.
:::

::: misses
- [y1 + m*x1] Going back from $x = \given{x1}$ to $x = 0$ changes $y$ by $-m x_1$. Subtract.
- [y1] That's the height at $x = \given{x1}$. The intercept is at $x = 0$.
- [any] Not yet. Use $b = y_1 - m x_1$.
:::
:::

::: check
given: E = 3.7 | 9 | 12; I1 = 0.5 | 1 | 2; r = 0.05 | 0.1 | 0.4; let V1 = E - r*I1
answer: r
unit: Ω

## A battery reads {E} V with no load and {V1} V while delivering {I1} A. What is its internal resistance?

::: right
Right. It lost $\given{E} - \given{V1}$ V at {I1} A, so $r$ = {answer}.
:::

::: misses
- [V1/I1] That's the load's resistance, $V/I$ at the terminals. The internal resistance comes from how much the voltage dropped.
- [any] Not yet. Internal resistance is the voltage drop divided by the current.
:::
:::

::: check
given: E = 1.5 | 3.7 | 9 | 12; r = 0.02 | 0.1 | 0.5 | 2
answer: E/r
unit: A

## A source has an open-circuit voltage of {E} V and an internal resistance of {r} Ω. What current would it drive into a short circuit?

::: right
Right. The line $V = E - rI$ reaches 0 at $I = E/r$ = {answer}.
:::

::: misses
- [E*r] Set $V = 0$ in $V = E - rI$ and solve for $I$.
- [any] Not yet. Find where the line reaches zero volts.
:::
:::

::: check
given: v1 = 0.4 | 0.5; s = 0.01 | 0.02; T0 = 25 | 37 | 60 | 85; let v2 = v1 + 100*s; let v = v1 + s*T0
answer: T0
unit: °C

## A temperature sensor reads {v1} V at 0 °C and {v2} V at 100 °C, and its output is linear in between. What temperature gives a reading of {v} V?

::: right
Right. It rises $(\given{v2} - \given{v1})/100$ V per degree, and {v} V is $\given{v} - \given{v1}$ V above the 0 °C reading: {answer}.
:::

::: misses
- [v/s] That leaves out the {v1} V the sensor reads at 0 °C. Subtract it first.
- [v/v2*100] That assumes the line goes through zero. It starts at {v1} V.
- [any] Not yet. Find the slope in volts per degree, then how many degrees above 0 °C the reading is.
:::
:::

::: check
given: m = 2 | 3 | -4 | 0.25 | -0.5
answer: -1/m
tolerance: 0.5%

## A line has slope {m}. What is the slope of a line at right angles to it?

::: right
Right. Perpendicular slopes multiply to −1, so the answer is $-1/\given{m}$ = {answer}.
:::

::: misses
- [-m] Flip the slope over as well as changing its sign.
- [1/m] Change the sign too: one line rises where the other falls.
- [any] Not yet. Perpendicular slopes multiply to −1.
:::
:::

::: check
kind: expression
given: m = 2 | 3 | 5; x1 = 1 | 2 | 4; y1 = 3 | 6 | -1
answer: y1 + m*(x - x1)
vars: x = -5..5

## Write the line with slope {m} through $(\given{x1}, \given{y1})$ as a formula in $x$.

::: right
Right. Point-slope form: start at {y1} and add {m} for each unit $x$ moves beyond {x1}.
:::

::: misses
- [m*x + y1] That line goes through $(0, \given{y1})$. Measure the run from $x = \given{x1}$: use $x - \given{x1}$.
- [y1 + m*(x + x1)] The run from $x_1$ is $x - x_1$, with a minus.
- [any] Not yet. Use $y = y_1 + m(x - x_1)$.
:::
:::

::: check
kind: parts
given: p1 = 20 | 30; p2 = 100 | 150; v1 = 0.5 | 0.8; s = 0.02 | 0.03; vx = 2 | 2.5; let v2 = v1 + s*(p2 - p1)

## A pressure sensor is calibrated at two points: it reads {v1} V at {p1} kPa and {v2} V at {p2} kPa. Its output is a straight line in the pressure.

::: part
answer: s
unit: V
tolerance: 0.5%

### What is its slope, in volts per kPa?

::: misses
- [1/s] That's kPa per volt. Divide the change in voltage by the change in pressure.
- [any] Rise over run: $(\given{v2} - \given{v1})/(\given{p2} - \given{p1})$.
:::
:::

::: part
answer: v1 - s*p1
unit: V
tolerance: 0.5%

### What would it read at 0 kPa?

::: misses
- [v1 + s*p1] Going down to 0 kPa lowers the reading.
- [any] Start at {v1} V and go back {p1} kPa along the line.
:::
:::

::: part
answer: p1 + (vx - v1)/s
unit: kPa
tolerance: 0.5%

### What pressure, in kPa, makes it read {vx} V?

::: misses
- [(vx - v1)/s] That's the change from {p1} kPa. Add it on.
- [any] Solve the line's equation for the pressure.
:::
:::
:::

::: check
kind: derivation
vars: x1 = 0..1, y1 = -2..2, x2 = 2..3, y2 = 3..5

## Derive the line through $(x_1, y_1)$ and $(x_2, y_2)$.

::: step
answer: (y2 - y1)/(x2 - x1)

### Write its slope $m$.

::: misses
- [(x2 - x1)/(y2 - y1)] Upside down: rise over run.
:::
:::

::: step
answer: y1 - x1*(y2 - y1)/(x2 - x1)

### Write its intercept $c$, using the first point.
:::

::: step
answer: (x1*y2 - x2*y1)/(y2 - y1)

### Where does it cross the $x$ axis? Simplify to a single fraction.
:::

::: right
Right. The crossing is at $x = -c/m = \frac{x_1y_2 - x_2y_1}{y_2 - y_1}$.
:::
:::

::: explain
## A battery's terminal voltage falls along a straight line as you draw more current. What do the line's two intercepts tell you about the battery?

::: model
The battery acts like an ideal voltage in series with a small internal resistance, so its terminal voltage is $E - rI$, a straight line in $I$. Where the line crosses the voltage axis, at zero current, is the open-circuit voltage $E$. Where it crosses the current axis, at zero volts, is the short-circuit current $E/r$. The slope between them is $-r$, so a battery with a steep line has a large internal resistance and sags a lot under load.
:::
:::

::: practice

::: check
given: m = 3 | -2 | 1.5 | -0.5; x1 = 0 | 2 | -3; dx = 1 | 3 | 4; b = 2 | -1 | 5; let x2 = x1 + dx; let y1 = m*x1 + b; let y2 = m*x2 + b
answer: m
tolerance: 0.5%

## What is the slope of the line through $(\given{x1}, \given{y1})$ and $(\given{x2}, \given{y2})$?

::: misses
- [1/m] Rise over run: change in $y$ on top.
- [-m] Subtract in the same order top and bottom.
- [any] $(y_2 - y_1)/(x_2 - x_1)$.
:::
:::

::: check
given: m = 2 | 4 | -1.5; b = 3 | -6 | 9
answer: -b/m
tolerance: 0.5%

## Where does $y = \given{m}x + \given{b}$ cross the horizontal axis?

::: misses
- [b/m] Set $y = 0$: $\given{m}x = -\given{b}$. Mind the sign.
- [b] That's where it crosses the vertical axis.
- [any] Solve $\given{m}x + \given{b} = 0$.
:::
:::

::: check
given: E = 3 | 6 | 12; I1 = 0.2 | 1 | 2.5; r = 0.1 | 0.3 | 1; let V1 = E - r*I1
answer: r
unit: Ω

## A source reads {E} V open and {V1} V at {I1} A. What is its internal resistance?

::: misses
- [V1/I1] That's the load. Use the drop, $E - V$.
- [any] Drop in voltage divided by current.
:::
:::

::: check
given: E = 5 | 12; r = 0.5 | 1 | 2; R = 2 | 5 | 10
answer: E/(R + r)
unit: A

## A source of {E} V with {r} Ω inside drives a {R} Ω load. What current flows?

::: misses
- [E/R] The internal resistance is in series with the load. Add it.
- [E/r] That's the short-circuit current.
- [any] The lines cross where $E - rI = RI$, so $I = E/(R + r)$.
:::
:::

::: check
given: C = -10 | 0 | 25 | 37 | 100
answer: 1.8*C + 32
unit: °F

## Fahrenheit is a linear function of Celsius: $F = 1.8C + 32$. What is {C} °C in °F?

::: misses
- [(C - 32)/1.8] That converts the other way.
- [1.8*C] Add the 32 °F offset.
- [any] Multiply by 1.8, then add 32.
:::
:::

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

## What slope is perpendicular to a slope of {m}?

::: misses
- [-m] Flip it over too.
- [1/m] Change the sign too.
- [any] The two slopes multiply to −1.
:::
:::
:::
