Sub topic 13
Singular Matrices and Floating Sub-Circuits
This chapter assumes you can build G v = i from a circuit, and that you know what rank and determinant mean for a small matrix. Here you will learn why the conductance matrix is sometimes singular and how to fix it.
Why G becomes singular
A matrix is singular when it has no inverse. Then G v = i has either no solution or infinitely many. In nodal analysis this almost always means the circuit model is incomplete, not that the arithmetic failed.
The usual cause is a floating sub-circuit: a group of nodes with no connection to the reference node. Node voltages are only differences, so if nothing ties the group to ground, adding the same constant to every voltage in the group changes nothing. The equations cannot pin down that constant.
You can see this in the matrix. Each resistor adds +g to two diagonal entries and -g to two off-diagonal entries. For a group of nodes with no path to ground, every row sums to zero. The columns are then linearly dependent, so the determinant is zero.
Seeing it in code
Two nodes are joined by a 2 Ω resistor and have no connection to ground. A 1 A source feeds node 1 and returns through node 2.
import numpy as np
def solve_or_report(G, i):
rank = np.linalg.matrix_rank(G)
if rank < G.shape[0]:
print(f"Singular: rank {rank} of {G.shape[0]}")
return None
return np.linalg.solve(G, i)
g = 1 / 2
G_floating = np.array([[g, -g],
[-g, g]])
i = np.array([1.0, 0.0])
print(solve_or_report(G_floating, i)) # Singular: rank 1 of 2, then None
# Add a 4 ohm resistor from node 2 to ground.
G_grounded = np.array([[g, -g],
[-g, g + 1/4]])
print(solve_or_report(G_grounded, i)) # [6. 4.]The fixed result checks out by hand. The 1 A flows through the 4 Ω resistor, so V2 = 4 V. It also flows through the 2 Ω resistor, which drops 2 V, so V1 = 6 V.
Diagnosing the problem
Work through these checks in order:
- Trace a path of any elements from every node to ground. A node may reach ground through a voltage source. A current source does not count as a path, because it forces a current instead of providing a connection.
- Look for a node that touches only current sources. Its diagonal entry is zero, so its row is empty.
- Look for voltage sources in a loop, or in parallel with different values. These make the supernode equations contradictory or dependent.
- Check your node numbering. A resistor wired to the wrong node number is a common way to leave a node unconnected.
Real floating pieces
Some circuits are legitimately floating, such as a transformer-coupled or isolated stage. Treat each connected piece separately. Choose a reference node in each piece and solve each piece on its own. Voltages in different pieces cannot be compared, because nothing defines a relationship between them.
Near-singular matrices
Floating-point arithmetic does not always report an exactly singular matrix. A resistor of 1e12 Ω to ground gives a matrix that is not singular but is badly conditioned. The solution is then very sensitive to rounding. Use np.linalg.cond(G) as a warning. A value above about 1e10 means you should question the model or the component values.
Exercise
A circuit has nodes 1, 2 and 3. Node 3 connects to nodes 1 and 2 only through a 5 A current source from node 3 to node 1. Node 3 has no other element. Why is G singular, and what is the fix?
Show answer
Node 3 touches only a current source, so its row in G is all zeros and the matrix has rank at most 2. KCL at node 3 would require the 5 A to come from nowhere. The model is wrong. Add the missing element that returns the current, such as a resistor from node 3 to ground or to another node. Then the node has a nonzero conductance entry and G is invertible.