Sub topic 11
Checking Your Answer
A nodal solution can be wrong in several ways: a misread schematic, a sign slip, or a typo in the matrix. This chapter covers checks that catch these errors before you rely on the numbers. You should be comfortable writing KCL equations, building G v = i, and handling grounded voltage sources, as in the earlier chapters.
Why a solver's output is not proof
A linear solver returns numbers for any matrix you give it. If you wrote the wrong conductance matrix, it solves the wrong circuit without complaint. A useful check therefore compares the answer with the original schematic, not with your own equations.
Checking against your own equations only proves that you solved them correctly. Checking against the schematic proves that you wrote the right equations. Both matter, and they catch different mistakes.
Quick sanity checks
Do these first because they take seconds.
- Units and magnitude. A 10 V source feeding kilohm resistors should give milliamps, not amps.
- Bounds. If a circuit has only resistors and voltage sources, every node voltage lies between the lowest and highest source voltage. A node at 14 V in a 10 V circuit is wrong. This bound does not hold when current sources are present.
- Signs. Current flows from higher to lower voltage through a resistor. If you expect current into a node and your numbers say otherwise, look for a sign error.
- Limiting cases. Set a resistor to a very large or very small value in your head. A very large
R3should pushV2towardV1, because almost no current flows inR2.
Check 1: KCL at every node using branch currents
Compute each branch current from the answer using Ohm's law, then add up the currents at each node. The currents leaving a node, plus any source currents leaving it, must sum to zero.
Use the circuit from the matrix chapter. A 2 A source feeds node 1. R1 = 4 Ω connects node 1 to ground, R2 = 2 Ω connects node 1 to node 2, and R3 = 6 Ω connects node 2 to ground. The solution is V1 = 16/3 V and V2 = 4 V.
| Branch | Current (from higher to lower node) | Value |
|---|---|---|
| R1, node 1 to ground | (16/3 − 0) / 4 | 4/3 A |
| R2, node 1 to node 2 | (16/3 − 4) / 2 | 2/3 A |
| R3, node 2 to ground | (4 − 0) / 6 | 2/3 A |
At node 1, the source supplies 2 A, and the resistors carry away 4/3 + 2/3 = 2 A. The balance holds. At node 2, 2/3 A arrives through R2 and 2/3 A leaves through R3. The balance holds again.
This check is strong because you compute the branch currents from the schematic's resistor values. If you had put R2 in the matrix as 3 Ω by mistake, the solver would still return numbers that satisfy your matrix. The branch currents computed with the true 2 Ω would then fail KCL.
Check 2: Power balance
Energy is conserved. The power that sources deliver must equal the power that resistors absorb.
For each resistor, the absorbed power is V²/R, or equivalently I²R, or V·I. For a source, the power delivered is the voltage across it times the current it pushes out of its positive terminal.
For the same circuit:
- R1 absorbs (16/3)² / 4 = 64/9 ≈ 7.111 W.
- R2 absorbs (2/3)² × 2 = 8/9 ≈ 0.889 W.
- R3 absorbs (2/3)² × 6 = 24/9 ≈ 2.667 W.
- The total absorbed is 96/9 = 32/3 ≈ 10.667 W.
- The current source delivers 2 A × 16/3 V = 32/3 ≈ 10.667 W.
The two totals match. The current source's voltage is the voltage of the node it feeds, relative to the node it draws from.
Power balance catches errors that KCL at a single node can miss. It also covers dependent sources, since a dependent source delivers or absorbs power like any other source. If a dependent source ends up absorbing power, that is legitimate. Just include its term with the correct sign.
Recovering a voltage source's current
A grounded voltage source adds no equation for its own current, so the solution does not give you that current directly. You recover it from KCL at the node it touches.
Take the example from the grounded-source chapter. A 10 V source feeds node 1, R1 = 1 kΩ joins node 1 to node 2, and R2 = 2 kΩ joins node 2 to ground. The solution is V2 = 6.667 V.
- The current through
R1is (10 − 6.667) / 1000 = 3.333 mA. By KCL at node 1, this is also the source current. - The source delivers 10 V × 3.333 mA = 33.33 mW.
- R1 absorbs (3.333 mA)² × 1000 = 11.11 mW.
- R2 absorbs 6.667² / 2000 = 22.22 mW.
- The total absorbed is 33.33 mW, which matches the source.
A repeatable verification workflow
Automating the check
The script below solves the example circuit and runs both checks against the resistor list, not against the matrix. It uses the same node numbering as before, with node 0 as ground.
import numpy as np
# Schematic data: node 0 is ground.
resistors = [(1, 0, 4.0), (1, 2, 2.0), (2, 0, 6.0)] # (node_a, node_b, ohms)
current_sources = [(0, 1, 2.0)] # (from_node, to_node, amps)
# Matrix written by hand for this circuit.
G = np.array([[1/4 + 1/2, -1/2],
[-1/2, 1/2 + 1/6]])
i = np.array([2.0, 0.0])
v = np.concatenate(([0.0], np.linalg.solve(G, i))) # prepend ground voltage
# Check 1: KCL using branch currents computed from the resistor list.
net_leaving = np.zeros(3)
absorbed = 0.0
for a, b, r in resistors:
current = (v[a] - v[b]) / r # current from a to b
net_leaving[a] += current
net_leaving[b] -= current
absorbed += current**2 * r
delivered = 0.0
for frm, to, amps in current_sources:
net_leaving[to] -= amps # source brings current into 'to'
net_leaving[frm] += amps # and takes it out of 'frm'
delivered += amps * (v[to] - v[frm])
print("Node voltages:", v)
print("KCL residuals:", net_leaving)
print("Absorbed W:", absorbed, "Delivered W:", delivered)
assert np.allclose(net_leaving, 0.0, atol=1e-9)
assert np.isclose(absorbed, delivered)
print("All checks passed")The residual for the ground node is also zero. This is a useful extra check, because the currents at all nodes must sum to zero. The ground node's equation is the one you never wrote, so a nonzero value there means one of the other equations is wrong.
What each check catches
| Error | Sanity check | KCL on schematic | Power balance |
|---|---|---|---|
| Wrong resistor value in the matrix | Often misses it | Catches it | Catches it |
| Sign error in a source term | Sometimes catches it | Catches it | Catches it |
| Arithmetic slip while solving by hand | Sometimes catches it | Catches it | Catches it |
| Missed a branch when building the matrix | Often misses it | Catches it | Catches it |
| A dependent-source gain applied with the wrong sign | Often misses it | Catches it | Catches it |
No check is complete on its own. KCL at all nodes is the strongest, because it tests every equation. Power balance adds a separate global test that does not depend on the way you assigned current directions.
Common failure patterns
- KCL fails at one node only. The equation for that node has a mistake, such as a missing branch or a wrong sign.
- KCL passes but power balance fails. The currents are consistent, but a power term is wrong. Check the source power sign, and check that every source appears in the total.
- Everything is off by the same factor. A unit error is likely, such as kilohms entered as ohms.
- The answers are consistent but the node voltages look flipped. A source polarity or a current-source direction was reversed when reading the schematic.
Exercise
A student solves the example circuit from this chapter and reports V1 = 4 V and V2 = 3 V. Use KCL at node 1 to show that the answer is wrong.
Show answer
The branch currents leaving node 1 are 4/4 = 1 A through R1 and (4 − 3)/2 = 0.5 A through R2, a total of 1.5 A. The current source supplies 2 A, so the node has 0.5 A that goes nowhere. KCL fails, so the answer is wrong.
Exercise
A 10 V source feeds node 1. R1 = 1 kΩ joins node 1 to node 2, and R2 = 2 kΩ joins node 2 to ground. With V2 = 6.667 V, compute the power each resistor absorbs and confirm that it equals the power the source delivers.
Show answer
The current is (10 − 6.667)/1000 = 3.333 mA. R1 absorbs 3.333 mA squared times 1000 Ω = 11.11 mW. R2 absorbs 6.667 V squared divided by 2000 Ω = 22.22 mW. The total is 33.33 mW. The source delivers 10 V × 3.333 mA = 33.33 mW, so the balance holds.