Lite / Independent Engineering Research / Week 1
Writing engineering problems as Ax = b
A resistor network, a loaded frame and a cross-talking sensor pair look nothing alike. Why does one line of code solve all three?
Why should I care?
Modelling is usually harder than solving. Once a problem is written as Ax = b, decades of reliable numerical software can take over. The skill is choosing unknowns, writing one equation per physical law, and checking the answer makes physical sense.
- Set up mesh-current equations for a two-loop resistor circuit as Ax = b.
- Set up force-balance equations for a joint and a cross-talk calibration as linear systems.
- Check a computed solution by substituting it back (residual b − Ax).
Predict
Two resistor loops share a 1 Ω resistor. Will the matrix A for the mesh currents be symmetric?
- Yes: the shared resistor appears equally in both off-diagonal entries
- No: circuit matrices are never symmetric
- Only if all resistors are equal
Guess first, then reveal
For a passive resistor network with mesh currents, entry (i, j) is minus the resistance shared by loops i and j, which is the same either way round. Symmetry is a free consistency check on your set-up.
Discover
Open the Code Lab. Write a function solve2(A, b) using elimination, then use it on the circuit below. Print the residual b − A·x: it should be (almost exactly) zero.
What the interactive shows (text version)
This lesson's activity is code-based: write a small elimination solver, apply it to the two-loop circuit A = [[3, −1], [−1, 2]], b = (2, 3), and print the solution (1.4, 2.2) and the residual, which should be near zero.
Understand
A recipe for modelling
- Choose unknowns (loop currents, member tensions, true quantities). 2. Write one equation per physical law: Kirchhoff's voltage law per loop, ΣF = 0 per direction per joint, one sensor model per reading. 3. Collect coefficients into A, knowns into b. 4. Count: as many independent equations as unknowns for a unique answer.
Example: two-loop circuit
A 2 V source drives loop 1 through 2 Ω, and loop 2 contains a 3 V source and 1 Ω. A 1 Ω resistor is shared. KVL in loop 1: 2I₁ + 1(I₁ − I₂) = 2, so 3I₁ − I₂ = 2. Loop 2: 1(I₂ − I₁) + 1·I₂ = 3, so −I₁ + 2I₂ = 3. So A = [[3, −1], [−1, 2]], b = (2, 3), and I = (1.4, 2.2) A.
Always check the residual
Compute r = b − A·x. A tiny residual says you solved the equations you wrote; it does not say they were the right equations. So also sanity-check physics: are currents in a sensible direction, do tensions in a hanging cable come out positive, does the answer change sensibly when you double a source?
Explain it another way
Intuitive
Each equation is one rule the world obeys. Stack all the rules, and the solution is the one set of unknowns that obeys every rule at once.
Technical
Nodal and mesh analysis produce A = G or R matrices that are symmetric and, for connected passive networks, positive definite, which guarantees a unique solution.
Applied
SPICE-style circuit simulators assemble exactly such a matrix from component 'stamps' and solve it at every operating point; structural finite-element codes do the same with stiffness matrices.
Worked example 1
Two sensors read r₁ = q₁ + 0.5q₂ and r₂ = 0.25q₁ + q₂. Readings are r = (3, 2.5). Find the true quantities q.
A = [[1, 0.5], [0.25, 1]]. From the first equation q₁ = 3 − 0.5q₂. Substituting: 0.75 − 0.125q₂ + q₂ = 2.5, so q₂ = 2 and q₁ = 2. Residual: (3 − 2 − 1, 2.5 − 0.5 − 2) = (0, 0).
Common mix-ups
If the residual is zero, the model is right.
✓ A zero residual only verifies the solve. Validation needs physics checks and data.More equations always means a better model.
✓ Dependent equations add nothing; inconsistent ones make the system unsolvable. Count independent equations.
Practice
Practice, not a test. Answers are checked on our server; a wrong answer gets a hint and another try. Nothing is saved.
Apply it
Model a three-loop resistor ladder of your own design as a 3×3 system. Solve it in the Code Lab, report the residual, and check one current by hand with KVL.
Reflect
Which step of the modelling recipe do you find hardest, and how could you check it?
Write your answer on paper or in your own notes. Lite never stores what you write.
Go further
Research mode: limits and open questions
Large sparse systems (millions of unknowns) are solved with sparse LU or iterative methods such as conjugate gradients, but the modelling step is identical to this 2×2 one.