---
title: Two equations in two unknowns
heading: Where two lines cross
eyebrow: A2 · Lesson 7 · Two equations in two unknowns
xp: 40
---

::: hook
A circuit with two unknown currents gives you two equations, one for each loop, and each equation alone allows infinitely many answers. Only one pair of currents satisfies both. On a graph, each equation is a line and the answer is where they cross. Solving pairs of equations by hand is the step before matrices (A7) and circuit analysis (C1), which do the same thing with more unknowns.

::: play
- The two lines are $y = m_1x + b_1$ and $y = m_2x + b_2$. The dot is where they cross.
- Make the slopes nearly equal. What happens to the crossing point?
- Make them exactly equal. Is there still an answer?
:::
:::

```sim plot
view: graph
x: x = -10..10
y: y = -10..10
aspect: free
slider: m1 = -3..3 step 0.1 = 1
slider: b1 = -5..5 step 0.5 = 1
slider: m2 = -3..3 step 0.1 = -0.5
slider: b2 = -5..5 step 0.5 = 4
plot: m1*x + b1 | label: line 1
plot: m2*x + b2 | color: ch2 | label: line 2
point: (b2 - b1)/(m1 - m2), m1*(b2 - b1)/(m1 - m2) + b1 | label: both hold here
readout: x = (b2 - b1)/(m1 - m2) | digits: 3
readout: y = m1*(b2 - b1)/(m1 - m2) + b1 | digits: 3
```

::: predict
## Two lines have the same slope but different intercepts. How many points satisfy both equations?

- [x] None
- [ ] Exactly one
- [ ] Two
- [ ] Infinitely many

::: reveal
None. Lines with the same slope are parallel, so they never cross, and no pair $(x, y)$ satisfies both. If they had the same intercept too, they'd be the same line, and every point on it would work. A pair of linear equations has one solution, none, or infinitely many, and the slopes tell you which.
:::
:::

::: nameit
## Two ways to solve

Take

$$3x + 2y = 12 \qquad x - y = -1$$

**Substitution.** Solve one equation for one unknown and put it into the other. From the second, $x = y - 1$. Then $3(y - 1) + 2y = 12$, so $5y = 15$, $y = 3$, and $x = 2$.

**Elimination.** Scale the equations so that adding them cancels an unknown. Doubling the second gives $2x - 2y = -2$; adding it to the first cancels $y$: $5x = 10$, so $x = 2$. Then $y = x + 1 = 3$.

Always check by putting the answer back into both: $3(2) + 2(3) = 12$ and $2 - 3 = -1$.

## When there's exactly one answer

For the general pair

$$ax + by = e \qquad cx + dy = f$$

elimination gives

$$x = \frac{ed - bf}{ad - bc} \qquad y = \frac{af - ec}{ad - bc}$$

This is **Cramer's rule**, and the shared bottom, $ad - bc$, is the **determinant**. If it's zero, the two lines have the same slope: either parallel (no solution) or the same line (infinitely many). Otherwise there's exactly one answer.

## In circuits

Loop analysis of a two-loop circuit (in C1) produces equations like

$$(R_1 + R_2)I_1 - R_2 I_2 = V_1 \qquad -R_2 I_1 + (R_2 + R_3) I_2 = V_2$$

The $R_2$ terms couple the loops: it's the resistor they share. Solving the pair gives both currents at once.
:::

::: example
## Solve $5I_1 - 2I_2 = 10$ and $-2I_1 + 6I_2 = 4$, with the currents in amperes.

::: solution
1. **Scale the first equation.** Multiply it by 3 to eliminate $I_2$:
   $$15I_1 - 6I_2 = 30$$
2. **Add the second equation.**
   $$\begin{aligned} 13 I_1 &= 34 \\ I_1 &= \frac{34}{13} \\ &= 2.615\ \text{A} \end{aligned}$$
3. **Back-substitute.** Put $I_1$ into the second equation:
   $$\begin{aligned} 6I_2 &= 4 + 2(2.615) \\ &= 9.231 \end{aligned}$$
   so $I_2 = 1.538$ A.
4. **Check with Cramer's rule.** The determinant is $5 \times 6 - (-2)(-2) = 26$, so
   $$\begin{aligned} I_1 &= \frac{10 \times 6 - (-2)(4)}{26} \\ &= \frac{68}{26} \\ &= 2.615\ \text{A} \end{aligned}$$

**Answer:** $I_1 = 2.615$ A and $I_2 = 1.538$ A.
:::
:::

::: example
## A battery with $E$ = 9 V and $r$ = 0.5 Ω drives a 4 Ω load. Find the current by solving the battery's line and the load's line together.

::: solution
1. **Write both lines.** The battery gives $V = 9 - 0.5I$, and the load gives $V = 4I$.
2. **Set them equal.** Both hold, so
   $$\begin{aligned} 4I &= 9 - 0.5I \\ 4.5I &= 9 \\ I &= 2\ \text{A} \end{aligned}$$
3. **Voltage.**
   $$\begin{aligned} V &= 4 \times 2 \\ &= 8\ \text{V} \end{aligned}$$
   That's the crossing point of the two lines from lesson 3, found with algebra in place of a graph.

**Answer:** 2 A flows, with 8 V across the load.
:::
:::

::: example
## Solve $2x + 4y = 8$ and $x + 2y = 5$. What does the answer mean if these are two ideal voltage sources tied together?

::: solution
1. **Double the second equation.**
   $$2x + 4y = 10$$
2. **Subtract the first.** That leaves
   $$0 = 2$$
   which can't be true, so there's no solution.
3. **See it on the graph.** The lines have the same slope, $-\tfrac12$, and different intercepts, so they're parallel and never meet.
4. **Read it as a circuit.** Two ideal sources of different voltages connected in parallel give exactly this: each insists on its own voltage, and no current satisfies both.
5. **Real sources.** They have internal resistance, which tilts their lines so they cross, and the current that flows at the crossing can be large.

**Answer:** there's no solution, because the lines are parallel. For two ideal sources tied together, that means no current satisfies both; real sources settle at a crossing, where the current can be large.
:::
:::

::: check
given: x0 = 1..4 int; y0 = 5..8 int; a1 = 2 | 3; b1 = 1 | 4; a2 = 1 | 5; b2 = 2 | 3; let c1 = a1*x0 + b1*y0; let c2 = a2*x0 - b2*y0
answer: x0
tolerance: 0.01

## Solve $\given{a1}x + \given{b1}y = \given{c1}$ and $\given{a2}x - \given{b2}y = \given{c2}$. What is $x$?

::: right
Right. $x$ = {x0} and $y$ = {y0}. Check them in both equations.
:::

::: misses
- [y0] That's $y$.
- [c1/a1] That ignores the $y$ term in the first equation. Eliminate $y$ first.
- [any] Not yet. Scale the equations so the $y$ terms cancel when you add them.
:::
:::

::: check
given: x0 = -3..-1 int; y0 = 2..5 int; a1 = 1 | 2; b1 = 3 | 5; a2 = 4 | 3; b2 = 1 | 2; let c1 = a1*x0 + b1*y0; let c2 = a2*x0 + b2*y0
answer: y0
tolerance: 0.01

## Solve $\given{a1}x + \given{b1}y = \given{c1}$ and $\given{a2}x + \given{b2}y = \given{c2}$. What is $y$?

::: right
Right. $x$ = {x0} and $y$ = {y0}.
:::

::: misses
- [x0] That's $x$.
- [c1/b1] That ignores the $x$ term. Eliminate $x$ first.
- [any] Not yet. Eliminate $x$ by scaling and subtracting.
:::
:::

::: check
given: a = 2 | 3 | 5; b = 1 | 4 | -2; c = 6 | -1 | 2; d = 3 | 7
answer: a*d - b*c
tolerance: 0.01

## What is the determinant $ad - bc$ of $\given{a}x + (\given{b})y = 1$ and $(\given{c})x + \given{d}y = 2$?

::: right
Right. $(\given{a})(\given{d}) - (\given{b})(\given{c})$ = {answer}.
:::

::: misses
- [a*d + b*c] Subtract the second product.
- [a*b - c*d] Multiply across the diagonals: $a$ with $d$, $b$ with $c$.
- [any] Not yet. $ad - bc$, with $a, b$ from the first equation and $c, d$ from the second.
:::
:::

::: check
kind: choice

## Which pair has no solution?

- [ ] $x + y = 4$ and $x - y = 2$
- [x] $2x + 4y = 6$ and $x + 2y = 5$
- [ ] $2x + 4y = 6$ and $x + 2y = 3$
- [ ] $3x - y = 1$ and $x + y = 3$

::: right
Right. Halving the first gives $x + 2y = 3$, which can't also equal 5. The lines are parallel.
:::

::: misses
- [3] Halve the first equation: it's the same line as the second, so every point on it works. Infinitely many solutions.
- [any] Look for two equations whose left sides are multiples of each other.
:::
:::

::: check
given: a = 5 | 6 | 8; b = 1 | 2 | 3; c = 4 | 7 | 9; V1 = 10 | 12; V2 = 3 | 5
answer: (V1*c + b*V2)/(a*c - b^2)
unit: A

## Loop analysis of a circuit gives $\given{a}I_1 - \given{b}I_2 = \given{V1}$ and $-\given{b}I_1 + \given{c}I_2 = \given{V2}$ (resistances in ohms, voltages in volts). What is $I_1$?

::: right
Right. By Cramer's rule, $I_1 = (\given{V1} \cdot \given{c} + \given{b} \cdot \given{V2})/(\given{a} \cdot \given{c} - \given{b}^2)$ = {answer}.
:::

::: misses
- [V1/a] That ignores $I_2$ in the first equation. The loops share a resistor, so both currents matter.
- [(V1*c - b*V2)/(a*c - b^2)] Check a sign: the $I_2$ coefficient in the first equation is $-\given{b}$.
- [any] Not yet. Eliminate $I_2$: multiply the first by {c}, the second by {b}, and add.
:::
:::

::: check
given: m1 = 2 | 3; b1 = 1 | -2; m2 = -1 | -4; b2 = 4 | 7
answer: (b2 - b1)/(m1 - m2)
tolerance: 0.5%

## Where do $y = \given{m1}x + (\given{b1})$ and $y = \given{m2}x + \given{b2}$ cross? Give $x$.

::: right
Right. Setting them equal, $(\given{m1} - (\given{m2}))x = \given{b2} - (\given{b1})$, so $x$ = {answer}.
:::

::: misses
- [(b1 - b2)/(m1 - m2)] Check the sign: move the $x$ terms to one side and the constants to the other.
- [(b2 - b1)/(m1 + m2)] Subtract the slopes.
- [any] Not yet. Set the two right-hand sides equal and solve for $x$.
:::
:::

::: check
kind: parts
given: E1 = 12 | 12.6; E2 = 11.8 | 12.2; r1 = 0.05 | 0.1; r2 = 0.08 | 0.2; R = 1 | 2

## Two batteries are wired in parallel across a {R} Ω load. One has EMF {E1} V and internal resistance {r1} Ω, the other {E2} V and {r2} Ω. With $V$ the shared voltage, the battery currents satisfy $V = \given{E1} - \given{r1}I_1 = \given{E2} - \given{r2}I_2$ and the load takes $I_1 + I_2 = V/\given{R}$.

::: part
answer: (E1/r1 + E2/r2)/(1/r1 + 1/r2 + 1/R)
unit: V
tolerance: 0.2%

### What is the shared voltage $V$?

::: misses
- [any] Write $I_1 = (E_1 - V)/r_1$ and $I_2 = (E_2 - V)/r_2$, and put both into $I_1 + I_2 = V/R$.
:::
:::

::: part
answer: (E1 - (E1/r1 + E2/r2)/(1/r1 + 1/r2 + 1/R))/r1
unit: A
tolerance: 0.5%

### What current does the first battery deliver?

::: misses
- [any] $I_1 = (E_1 - V)/r_1$, with the $V$ you found.
:::
:::

::: part
answer: (E2 - (E1/r1 + E2/r2)/(1/r1 + 1/r2 + 1/R))/r2
unit: A
tolerance: 0.5%

### What current does the second battery deliver? (A negative answer means it's being charged.)

::: misses
- [-(E2 - (E1/r1 + E2/r2)/(1/r1 + 1/r2 + 1/R))/r2] Check the sign: is $V$ above or below {E2} V?
- [any] $I_2 = (E_2 - V)/r_2$.
:::
:::
:::

::: check
kind: derivation
vars: a = 2..4, b = -1..1, c = -1..1, d = 2..4, p = -5..5, q = -5..5

## Solve $ax + by = p$ and $cx + dy = q$ in general, by elimination.

::: step
answer: (p*d - b*q)/(a*d - b*c)

### Multiply the first equation by $d$ and the second by $b$, subtract, and solve for $x$.

::: misses
- [(p*d - b*q)/(a*d + b*c)] Check the sign in the denominator: it's $ad - bc$.
:::
:::

::: step
answer: (a*q - c*p)/(a*d - b*c)

### Eliminate $x$ the same way and solve for $y$.
:::

::: right
Right. Both share the denominator $ad - bc$. When it's zero the lines are parallel and there's no single solution.
:::
:::

::: explain
## What does a determinant of zero mean for two linear equations, in terms of their lines?

::: model
The determinant $ad - bc$ is zero exactly when the two equations' $x$ and $y$ coefficients are in the same ratio, which means the two lines have the same slope. Lines with the same slope are either parallel, so they never meet and there's no solution, or they're the same line, so every point on it is a solution. Either way there isn't a single answer.
:::
:::

::: practice

::: check
given: x0 = 2..6 int; y0 = -3..-1 int; a1 = 1 | 3; b1 = 2 | 5; a2 = 2 | 4; b2 = 1 | 3; let c1 = a1*x0 + b1*y0; let c2 = a2*x0 - b2*y0
answer: x0
tolerance: 0.01

## Solve $\given{a1}x + \given{b1}y = \given{c1}$ and $\given{a2}x - \given{b2}y = \given{c2}$ for $x$.

::: misses
- [y0] That's $y$.
- [any] Eliminate $y$.
:::
:::

::: check
given: x0 = 1..5 int; y0 = 6..9 int; a1 = 2 | 5; b1 = 1 | 3; a2 = 1 | 3; b2 = 4 | 2; let c1 = a1*x0 + b1*y0; let c2 = a2*x0 + b2*y0
answer: y0
tolerance: 0.01

## Solve $\given{a1}x + \given{b1}y = \given{c1}$ and $\given{a2}x + \given{b2}y = \given{c2}$ for $y$.

::: misses
- [x0] That's $x$.
- [any] Eliminate $x$.
:::
:::

::: check
given: a = 4 | 6; b = 2 | -3; c = 1 | 5; d = -2 | 8
answer: a*d - b*c
tolerance: 0.01

## What is the determinant of $\given{a}x + (\given{b})y = 0$, $\given{c}x + (\given{d})y = 0$?

::: misses
- [a*d + b*c] It's $ad$ minus $bc$.
- [any] $ad - bc$.
:::
:::

::: check
given: a = 4 | 7; b = 1 | 2; c = 5 | 6; V1 = 6 | 9; V2 = 2 | 8
answer: (a*V2 + b*V1)/(a*c - b^2)
unit: A

## $\given{a}I_1 - \given{b}I_2 = \given{V1}$ and $-\given{b}I_1 + \given{c}I_2 = \given{V2}$. What is $I_2$?

::: misses
- [V2/c] The loops share a resistor. Eliminate $I_1$ first.
- [any] Cramer's rule, or eliminate $I_1$.
:::
:::

::: check
given: E = 6 | 9 | 12; r = 0.5 | 1; R = 2 | 3 | 5
answer: R*E/(R + r)
unit: V

## A battery's line is $V = \given{E} - \given{r}I$ and its load's is $V = \given{R}I$. What voltage does the circuit settle at?

::: misses
- [E] That's the open-circuit voltage. Under load it's lower.
- [E/(R + r)] That's the current. Multiply by {R} for the voltage.
- [any] Solve the two lines together for $I$, then find $V$.
:::
:::
:::
