TExcelTAD
Home › Linear Algebra & Matrix Theory › Application: Resistor Networks

Application: Resistor Networks

An electric circuit made of batteries and resistors obeys three simple rules, and each one is a linear equation. Writing them all down gives a linear system whose solution is every current and voltage in the circuit. This is how circuit simulators work, and it is a great example of a system you could not solve by staring at it.

The three laws

Law Statement Equation
Ohm's law the voltage across a resistor is proportional to the current through it V=R⋅IV = R \cdot I
Kirchhoff's current law (KCL) the currents flowing into a junction equal those flowing out ∑Iin=∑Iout\sum I_{\text{in}} = \sum I_{\text{out}}
Kirchhoff's voltage law (KVL) around any closed loop, voltage rises equal voltage drops ∑(battery voltages)=∑R⋅I\sum (\text{battery voltages}) = \sum R \cdot I

Units: volts (V), amperes (A), ohms (Ω\Omega).

Example 1: currents in a simple circuit

A 12 V battery drives current I1I_1 through a 2 Ω2\ \Omega resistor; then the current splits into I2I_2 through 3 Ω3\ \Omega and I3I_3 through 6 Ω6\ \Omega, which rejoin and return to the battery.

text
          I₁      2 Ω                  KCL (junction):   I₁ − I₂ − I₃ = 0
   ┌────→────/\/\/\────┬────────┐      KVL (outer loop via 3 Ω):  2I₁ + 3I₂ = 12
   │                   │        │      KVL (loop 3 Ω vs 6 Ω):     3I₂ − 6I₃ = 0
 + │ 12 V          3 Ω ▯ I₂  6 Ω ▯ I₃
 − │                   │        │
   └───────────────────┴────────┘
python · try it yourself
from sympy import Matrix

A = Matrix([[1, -1, -1],
            [2,  3,  0],
            [0,  3, -6]])
b = Matrix([0, 12, 0])
I = A.solve(b)
print("I1, I2, I3 =", list(I), "amperes")
print("power from the battery:", 12 * I[0], "watts")
I1, I2, I3 = [3, 2, 1] amperes
power from the battery: 36 watts

Check with the shortcut you may know: 3 Ω3\ \Omega and 6 Ω6\ \Omega in parallel give 3⋅63+6=2 Ω\frac{3 \cdot 6}{3 + 6} = 2\ \Omega, plus 2 Ω2\ \Omega in series is 4 Ω4\ \Omega, so I1=124=3 AI_1 = \frac{12}{4} = 3\ \text{A}. ✓ The linear system needs no shortcuts, and that matters for circuits that are neither series nor parallel.

Example 2: a bridge circuit (node voltages)

The bridge below cannot be reduced with series and parallel rules. Instead we use nodal analysis: unknowns are the voltages at the nodes, and KCL at each node, with Ohm's law I=(Vfrom−Vto)/RI = (V_{\text{from}} - V_{\text{to}})/R, gives one equation per unknown node.

Node A is held at 10 V by a battery, the ground node G is at 0 V. Resistors: A–B 1 Ω1\ \Omega, A–C 2 Ω2\ \Omega, B–C 1 Ω1\ \Omega (the bridge), B–G 2 Ω2\ \Omega, C–G 1 Ω1\ \Omega.

KCL at B: VB−101+VB−VC1+VB2=0→2.5⋅VB−VC=10KCL at C: VC−102+VC−VB1+VC1=0→−VB+2.5⋅VC=5\begin{aligned} &\text{KCL at B: } \frac{V_B - 10}{1} + \frac{V_B - V_C}{1} + \frac{V_B}{2} = 0 &&\to 2.5 \cdot V_B - V_C = 10 \\ &\text{KCL at C: } \frac{V_C - 10}{2} + \frac{V_C - V_B}{1} + \frac{V_C}{1} = 0 &&\to -V_B + 2.5 \cdot V_C = 5 \end{aligned}
python · try it yourself
from sympy import Matrix, Rational

half = Rational(1, 2)
G = Matrix([[1 + 1 + half, -1],
            [-1, half + 1 + 1]])
rhs = Matrix([10, 10 * half])
VB, VC = G.solve(rhs)
print("V_B =", VB, " V_C =", VC)
print("bridge current B->C:", VB - VC, "A")
I_total = (10 - VB) / 1 + (10 - VC) / 2
print("current from battery:", I_total, "A")
print("equivalent resistance:", 10 / I_total, "ohm")
V_B = 40/7  V_C = 30/7
bridge current B->C: 10/7 A
current from battery: 50/7 A
equivalent resistance: 7/5 ohm

The matrix GG is the conductance matrix: on the diagonal, the sum of conductances 1/R1/R at each node; off the diagonal, minus the conductance between two nodes. It is symmetric, a weighted version of the graph Laplacian of the circuit.

Example 3: a long ladder in NumPy

Real circuits have thousands of nodes, so simulators build the conductance matrix automatically and solve it numerically. Here is a ladder of nn identical 1 Ω1\ \Omega sections (a series resistor followed by a resistor to ground):

python · try it yourself
import numpy as np

def ladder_resistance(n, R=1.0):
    # unknown voltages at nodes 1..n; node 0 is held at 1 V, ground at 0 V
    G = np.zeros((n, n)); rhs = np.zeros(n)
    g = 1.0 / R
    for k in range(1, n + 1):
        i = k - 1
        G[i, i] += g            # series resistor to node k-1
        if k == 1:
            rhs[i] += g * 1.0   # node 0 is the 1 V source
        else:
            G[i, i - 1] -= g; G[i - 1, i] -= g; G[i - 1, i - 1] += g
        G[i, i] += g            # shunt resistor to ground
    V = np.linalg.solve(G, rhs)
    current_in = (1.0 - V[0]) * g
    return 1.0 / current_in

for n in [1, 2, 3, 5, 10, 30]:
    print(f"n = {n:2d}: R_eq = {ladder_resistance(n):.10f}")
print("golden ratio:", (1 + 5 ** 0.5) / 2)
n =  1: R_eq = 2.0000000000
n =  2: R_eq = 1.6666666667
n =  3: R_eq = 1.6250000000
n =  5: R_eq = 1.6181818182
n = 10: R_eq = 1.6180339985
n = 30: R_eq = 1.6180339887
golden ratio: 1.618033988749895

As the ladder grows, its resistance approaches the golden ratio 1+52≈1.618 Ω\frac{1 + \sqrt{5}}{2} \approx 1.618\ \Omega, a classic result that the linear system confirms numerically. The exact values 2,53,138,3421,8955,…2, \frac{5}{3}, \frac{13}{8}, \frac{34}{21}, \frac{89}{55}, \ldots are ratios of Fibonacci numbers.

In software

  • SPICE and every circuit simulator use modified nodal analysis: one row per node, assembled automatically from a netlist, solved with sparse LU factorization.
  • The same Laplacian matrix appears in graph algorithms: spectral clustering, random walks and "effective resistance" between nodes, which measures how well connected two vertices of a network are.
  • Physics engines and mesh smoothing in graphics solve Laplacian systems of exactly this form, with springs or mesh edges instead of resistors.

Exercises

Exercise 1: Series and parallel check

A 9 V battery is connected to a 1 Ω1\ \Omega resistor in series with a parallel pair of 4 Ω4\ \Omega and 4 Ω4\ \Omega. Find all currents.

Answer

3 A from the battery, 1.5 A through each 4 Ω4\ \Omega resistor.

Solution
KCL: I1=I2+I3KVL: 1⋅I1+4I2=9KVL: 4I2−4I3=0→I2=I3, I1=2I2, 2I2+4I2=9→I2=1.5, I1=3(Shortcut: 4∥4=2 Ω, total 3 Ω, 9/3=3 A.)\begin{aligned} &\text{KCL: } I_1 = I_2 + I_3 \qquad \text{KVL: } 1 \cdot I_1 + 4I_2 = 9 \qquad \text{KVL: } 4I_2 - 4I_3 = 0 \\ &\to I_2 = I_3,\ I_1 = 2I_2,\ 2I_2 + 4I_2 = 9 \to I_2 = 1.5,\ I_1 = 3 \\ &(\text{Shortcut: } 4 \parallel 4 = 2\ \Omega, \text{ total } 3\ \Omega,\ 9/3 = 3\ \text{A.}) \end{aligned}

Exercise 2: Two batteries

Two batteries share a 2 Ω2\ \Omega resistor: battery 1 (10 V) with a 1 Ω1\ \Omega resistor and battery 2 (4 V) with a 1 Ω1\ \Omega resistor, both feeding the junction above the 2 Ω2\ \Omega resistor. With the node-voltage method, find the junction voltage VV.

Answer

V=5.6 VV = 5.6\ \text{V}.

Solution
KCL at the junction: V−101+V−41+V2=02.5⋅V=14→V=5.6 VCurrents: from battery 1: 4.4 A in, from battery 2: −1.6 A (it is being charged), through 2 Ω: 2.8 A4.4−1.6=2.8✓\begin{aligned} &\text{KCL at the junction: } \frac{V - 10}{1} + \frac{V - 4}{1} + \frac{V}{2} = 0 \\ &2.5 \cdot V = 14 \to V = 5.6\ \text{V} \\ &\text{Currents: from battery 1: } 4.4\ \text{A in, from battery 2: } -1.6\ \text{A (it is being charged), through } 2\ \Omega\text{: } 2.8\ \text{A} \\ &4.4 - 1.6 = 2.8 \checkmark \end{aligned}

Exercise 3: Change the bridge (code)

In Example 2, change the bridge resistor B–C from 1 Ω1\ \Omega to 3 Ω3\ \Omega. What is the new equivalent resistance?

Answer

Req=139 Ω≈1.44 ΩR_{\text{eq}} = \frac{13}{9}\ \Omega \approx 1.44\ \Omega (VB=8013 VV_B = \frac{80}{13}\ \text{V}, VC=5013 VV_C = \frac{50}{13}\ \text{V}).

Solution

The B–C conductance becomes 13\frac{1}{3}, which changes both diagonal entries and the off-diagonal entries.

python · try it yourself
from sympy import Matrix, Rational

g_bc = Rational(1, 3)
G = Matrix([[1 + g_bc + Rational(1, 2), -g_bc],
            [-g_bc, Rational(1, 2) + g_bc + 1]])
VB, VC = G.solve(Matrix([10, 5]))
I = (10 - VB) + (10 - VC) / 2
print(VB, VC, 10 / I)
80/13 50/13 13/9

Exercise 4: Balanced bridge

For which value of the C–G resistor RR (other resistors as in Example 2: A–B 1 Ω1\ \Omega, A–C 2 Ω2\ \Omega, B–G 2 Ω2\ \Omega) does no current flow through the bridge?

Answer

R=4 ΩR = 4\ \Omega.

Solution

No bridge current means VB=VCV_B = V_C, so the two sides act as separate voltage dividers with equal ratios:

left: VB=10⋅21+2=203right: VC=10⋅R2+R203=10R2+R→20(2+R)=30R→R=4(the classic balance condition 12=2R)\begin{aligned} \text{left: } & V_B = 10 \cdot \frac{2}{1 + 2} = \frac{20}{3} \\ \text{right: } & V_C = 10 \cdot \frac{R}{2 + R} \\ & \frac{20}{3} = \frac{10R}{2 + R} \to 20(2 + R) = 30R \to R = 4 \\ & (\text{the classic balance condition } \tfrac{1}{2} = \tfrac{2}{R}) \end{aligned}

Test yourself

Kirchhoff's current law at a junction gives which kind of equation?

  1. A quadratic equation
  2. A linear equation in the currents
  3. An inequality
  4. A differential equation

In nodal analysis, what are the unknowns?

  1. The resistances
  2. The battery voltages
  3. The loop areas
  4. The node voltages

What is on the diagonal of a circuit's conductance matrix?

  1. Zeros
  2. The node voltages
  3. The sum of conductances 1/R1/R connected to each node
  4. The resistances themselves