Kirchhoff’s current and voltage laws form linear equations for an ideal resistor network. Nodes and branches become graph data; unknown node voltages or branch currents become a vector solve. The important implementation work is not memorizing a diagram-specific equation—it is producing the same signed constraints from any valid graph.
Think like a programmer
Choose one representation, usually node voltages with one pinned reference node. Assemble a matrix from topology and element conductances, solve it with pivoting, then independently calculate every equation residual. Avoid hand-coding a different equation for every drawing; a changed branch should change graph data and generated matrix entries, not a string of unrelated formulas.
Model checklist
Inputs
Circuit graph with node/branch identifiers, sources, positive resistance values, branch orientations, reference node, and unit convention.
Write current conservation at each non-reference node, substitute each linear element law, pin the reference potential, solve the resulting system, then re-evaluate constraints.
Each KCL residual is near zero under a declared tolerance; every resistor satisfies I = ΔV/R; total supplied and absorbed power agree within numerical tolerance; changing the chosen reference shifts absolute voltages but not voltage differences or currents.
For a resistor joining nodes a and b, define current positive from a to b as
\[I_{a o b}=rac{V_a-V_b}{R},qquad sum_{binmathrm{neighbors}(a)}rac{V_a-V_b}{R_{ab}}=I_{mathrm{injected},a}\]
The reference node has voltage zero by convention, not because it contains no charge or is physically special. Without that one constraint, a uniform voltage offset creates a singular node-voltage system: only differences matter. A pivoted linear solver detects singularity, but the circuit builder should also report the graph cause, such as a floating subnetwork or a missing ground reference.
After a solve, recompute A x − b; small residuals are evidence that the code solved the equations it assembled. They are not proof that the equations represented the intended circuit. Use fixtures with known answers: one resistor and one ideal source, a two-resistor divider, and a deliberately disconnected node. Also compare the power ledger: ideal source delivery should balance resistor absorption under the sign convention.
Try this experiment
Prediction: Adding a branch changes matrix connectivity while conservation remains the same; shifting the reference changes absolute node values but leaves currents unchanged.
Create a divider with a 12 V source, 3 Ω and 3 Ω resistors, and ground at the negative terminal. Predict the middle voltage and both currents. Write the two matrix rows, solve them, and calculate A x − b. Then move the reference convention and identify which derived values must remain invariant.
Where this model breaks
Ideal DC linear algebra excludes switching, inductance, capacitance, nonlinear devices, thermal drift, frequency dependence, electromagnetic radiation, and measurement loading. Real sources have internal resistance and compliance limits. A small algebraic residual can coexist with a wrong schematic, wrong units, or an invalid idealization.
Summary
Generate circuit equations from graph data, pin one reference, solve with numerical safeguards, and inspect residual plus power ledgers after every solve. A correct-looking voltage display is not enough evidence without these independently calculated checks.
Glossary
Node: connected equipotential point in an ideal circuit.
Reference node: chosen zero-voltage node.
Residual: constraint mismatch after solving.
Conductance: reciprocal of resistance, used in node-matrix entries.
Floating subnetwork: connected circuit region without a fixed reference constraint.
Power ledger: signed source and element power totals used as a consistency check.
Self-check
What does graph topology generate?
Why is a reference node required?
What residual verifies a solution?
Which quantities stay invariant if the voltage reference convention shifts?
Sources
C. K. Alexander and M. N. O. Sadiku, Fundamentals of Electric Circuits, nodal analysis and Kirchhoff laws.
Treat the lesson as a small function before treating it as a fact to memorize. Give every value a unit, keep only the state needed for the next step, and make the output easy to inspect.
Quantities you set or measure, with units and useful bounds.
State
Values the program must retain to reproduce the next result.
Rule
The relationship or update that turns inputs and state into a result.
Check
A known limit, unit check, invariant, or measured result that can expose a bad model.
Implement the idea as a model
For Kirchhoff’s Laws as Linear Algebra, write down the quantities you can control, the values your program must retain, and the result a reader could inspect. In Currents and Circuits, the useful program is not the drawing: it is the smallest explicit model that makes a prediction you can test.
Guided experiment
Prediction: changing one declared input while holding the others fixed should change only the outputs that the model connects to that input. Choose one input, predict the direction of change, then check a limiting case such as zero, a symmetric arrangement, or a familiar low-speed or small-change approximation.
Where this model breaks
This lesson is a teaching model, not a complete simulator. Before using it outside the stated question, check which interactions, scales, uncertainties, boundary conditions, and measurement limits it leaves out.
Summary
Treat Kirchhoff’s Laws as Linear Algebra as a contract: named inputs and units enter a rule, the rule produces an observable result, and a known limit or invariant checks whether the implementation deserves trust.
Glossary
Input: a measured value or chosen parameter supplied to a model.
State: the smallest set of values needed to continue or reproduce a model.
Validation: comparing an output with a known result, limit, invariant, or measurement.
Self-check
Which values are inputs, and which values must remain state?
What observable result would tell you the model is behaving as expected?
Which assumption would you test first before applying the model to a real system?
Model review: turn Kirchhoff’s Laws as Linear Algebra into a test
Assemble circuit-graph constraints into a linear solve and verify node conservation residuals.
Name the inputs and units that the currents and circuits model needs.
Separate the state you must keep from values you can calculate when needed.
Write one rule that maps the current state and inputs to an observable result.
Choose a limiting case, unit check, invariant, or known result before trusting an output.
State one assumption you would change before using this simplified model for a real decision.