ENع
←Matrix solve
Lesson 12 · Systematic analysis

Solving circuit equations with matrices

14 min11 steps5 questionsIntermediate
About this lesson

Nodal analysis gives one KCL equation per node, and a matrix solves them all at once. Follow one circuit, current sources of 6 mA and 1 mA with R1 = 1 kΩ, R2 = 1 kΩ and R3 = 2 kΩ, from two KCL equations to G v = i. Read the conductance matrix straight off the circuit, see each row as a line, and solve it three ways: Cramer's rule, Gaussian elimination and the inverse. Then check the answer, v1 = 5 V and v2 = 4 V, with KCL and a power balance. It follows Nodal analysis, Mesh analysis and Supermeshes and choosing a method, and builds on the Hardware lessons on Ohm's law and series and parallel circuits.

You'll learn to

Tick what you feel confident about. These self-checks do not affect your lesson score.

Fig 12 · Interactive
01 / 11

Two unknown node voltages

Nodal analysis turns a circuit into equations. Pick a reference node, ground, at 0 V. The other two nodes have unknown voltages, v1 and v2, measured from ground. Two unknowns need two equations.

reference node   ground, 0 V by choice
node 1           voltage v1 (unknown)
node 2           voltage v2 (unknown)

n non-reference nodes → n unknowns
                      → n KCL equations

Once v1 and v2 are known, Ohm's law
gives every branch current.
Loading figure…
or ← →
Read the lesson step by step
  1. Two unknown node voltages

    Nodal analysis turns a circuit into equations. Pick a reference node, ground, at 0 V. The other two nodes have unknown voltages, v1 and v2, measured from ground. Two unknowns need two equations.

    reference node   ground, 0 V by choice
    node 1           voltage v1 (unknown)
    node 2           voltage v2 (unknown)
    
    n non-reference nodes → n unknowns
                          → n KCL equations
    
    Once v1 and v2 are known, Ohm's law
    gives every branch current.
  2. KCL at node 1

    KCL at node 1: current leaving through resistors equals source current entering. Leaving through R1 is v1/R1; through R2 it is (v1 − v2)/R2. So v1/1k + (v1 − v2)/1k = 6 mA.

    KCL at node 1  (out through resistors = in)
    
      v1/R1 + (v1 − v2)/R2 = I1
      v1/1k + (v1 − v2)/1k = 6 mA
    
    Ohm's law: a resistor's current is the
    voltage across it divided by R. Each
    current here is counted leaving node 1.
  3. KCL at node 2

    Same rule at node 2. Leaving through R2 back toward node 1 is (v2 − v1)/R2; leaving through R3 is v2/R3. Source I2 brings 1 mA in. So (v2 − v1)/1k + v2/2k = 1 mA.

    KCL at node 2
    
      (v2 − v1)/R2 + v2/R3 = I2
      (v2 − v1)/1k + v2/2k = 1 mA
    
    R2 appears in both equations: it is the
    only part joining node 1 to node 2.
  4. Use conductance G = 1/R

    Conductance is G = 1/R, measured in siemens (S). Here G1 = 1 mS, G2 = 1 mS, G3 = 0.5 mS. Collect the v1 and v2 terms: 2v1 − v2 = 6 and −v1 + 1.5v2 = 1. Millisiemens times volts gives milliamps.

    G = 1/R   (1 kΩ ↔ 1 mS, 2 kΩ ↔ 0.5 mS)
    
    node 1: (G1 + G2)v1 − G2·v2 = I1
            2v1 − 1v2 = 6
    node 2: −G2·v1 + (G2 + G3)v2 = I2
            −1v1 + 1.5v2 = 1
    
    units: mS × V = mA
  5. Write it as G v = i

    Stack the two equations as a matrix: G v = i. Read G straight off the circuit. Each diagonal entry is the total conductance touching that node. Each off-diagonal entry is minus the conductance joining the two nodes, so G is symmetric.

    G v = i
    
      [ 2   −1 ] [v1]   [6]
      [−1   1.5 ] [v2] = [1]
    
    G11 = G1 + G2 = 2 mS   (all at node 1)
    G22 = G2 + G3 = 1.5 mS (all at node 2)
    G12 = G21 = −G2 = −1 mS  (joins them)
    i = source currents into each node (mA)
  6. Each row is a line

    Each row is a straight line in the v1–v2 plane: every point on it satisfies one node's KCL. Only where the two lines cross are both nodes balanced. That crossing, v1 = 5 V and v2 = 4 V, is the answer.

    row 1:  2v1 − v2 = 6    →  v2 = 2v1 − 6
    row 2:  −v1 + 1.5v2 = 1  →  v2 = (v1 + 1)/1.5
    
    cross at (5, 4)
    
    Parallel lines (no crossing) would mean
    no single solution: Δ = 0.
  7. The determinant

    The determinant Δ tells whether a single answer exists. For a 2×2 matrix, multiply the diagonal and subtract the other product: Δ = 2×1.5 − (−1)(−1) = 2 mS². Not zero, so the lines cross exactly once.

    Δ = G11·G22 − G12·G21
      = 2·1.5 − (−1)(−1)
      = 3 − 1 = 2 mS²
    
    Δ ≠ 0   one solution (lines cross)
    Δ = 0   none or infinitely many
            (parallel lines): the circuit
            is badly posed, e.g. a floating node
  8. Cramer's rule

    Cramer's rule: replace column k of G with i, take that determinant, divide by Δ. Δ1 = 6×1.5 − (−1)(1) = 10, so v1 = 10/2 = 5 V. Δ2 = 2×1 − (6)(−1) = 8, so v2 = 4 V.

    Δ1 = | 6  −1 |  = 6·1.5 − (−1)(1) = 10
         | 1  1.5 |
    
    Δ2 = | 2  6 |  = 2·1 − (6)(−1) = 8
         |−1  1 |
    
    v1 = Δ1/Δ = 10/2 = 5 V
    v2 = Δ2/Δ = 8/2 = 4 V
  9. Gaussian elimination

    Gaussian elimination: add 0.5 × row 1 to row 2. The v1 term cancels, leaving 1·v2 = 4, so v2 = 4 V. The new row is a level line through the same crossing. Back-substitute: v1 = (6 + 4)/2 = 5 V.

    row 2 ← row 2 + 0.5·row 1
    
      [ 2  −1 ] [v1]   [6]
      [ 0   1 ] [v2] = [4]
    
    back substitution
      v2 = 4/1 = 4 V
      v1 = (6 + v2)/2 = 5 V
    
    This is how computers solve thousands
    of nodes (LU factorisation).
  10. Check: KCL and power

    Put the answer back. R1 carries 5 mA, R2 1 mA, R3 2 mA. Node 1: 6 in = 5 + 1 out. Node 2: 1 + 1 = 2. Sources supply 34 mW; resistors absorb 25 + 1 + 8 = 34 mW.

    branch currents (Ohm's law)
      R1  v1/R1        = 5 mA
      R2  (v1 − v2)/R2 = 1 mA
      R3  v2/R3        = 2 mA
    
    residual G v − i = (0, 0) mA
    
    power (passive sign convention)
      I1 supplies 30 mW, I2 supplies 4 mW
      R1 25 + R2 1 + R3 8 = 34 mW absorbed
  11. The inverse: new sources, same G

    G depends only on the resistors. Invert it once and any source values give v = G⁻¹i at once. Raise I2 to 3 mA: v1 = 6 V, v2 = 6 V. Circuit simulators such as SPICE solve these matrix equations for thousands of nodes.

    G⁻¹ = (1/Δ)[ G22  −G12 ]
                [ −G21  G11 ]
        = [ 0.75  0.5 ]  kΩ
          [ 0.5   1  ]
    
    I2 = 3 mA:
      v1 = 0.75·6 + 0.5·3 = 6 V
      v2 = 0.5·6 + 1·3   = 6 V

Quiz Unlocks after the last step.