Solving systems of linear equations: resistor networks
Developed by E. Ayars
These exercises are designed to get you started on using computers to solve systems of linear equations. The systems of equations we'll be using come from resistor networks typical of what you might see in a secondsemester physics course, but the same techniques can be used for any system of linear equations regardless of their source.
We can of course solve these systems of equations using algebra, but for larger systems of equations it's a lot easier to use a computer.
Subject Area  Electricity & Magnetism 

Levels  First Year and Beyond the First Year 
Available Implementations  Python and Mathematica 
Learning Objectives 
Students who complete these exercises will
* Be able to convert from a system of equations to a matrix equation.
* Be able to use a computational package to solve the matrix equation.

Time to Complete  30 min 
## Exercise 1: Introductory Problem
Consider the network of resistors and batteries shown in the first figure below.
![twoloop circuit](images/linearEquations/2_loop.png)
There are three unknowns in that circuit, $I_1$, $I_2$, and $I_3$. We can solve for these unknowns by building a system of equations using Kirchhoff's Laws:
1. The sum of voltages around any loop is zero.
2. The sum of currents at any junction is zero.
Applying the voltage law to the lefthand loop, we get
$$ V_1  I_1R_1  I_3R_3 = 0 $$
From the righthand loop, we get
$$ V_2 + I_2R_2  I_3R_3 = 0 $$
We need one more equation, for which we can use the junction at top center and the current law:
$$ I_1  I_2  I_3 = 0 $$
We now have the requisite three independent equations, which we can solve using methods learned in highschool algebra.
There's another way of solving this, using matrix methods.
First, rewrite the equations just a bit.
$$ \begin{align} R_1 I_1 + 0 I_3 + R_3 I_3 &=& V_1 \\\
0 I_1  R_2 I_2 + R_3 I_3 &=& V_2 \\\
I_1  I_2  I_3 &=& 0
\end{align} $$
And now we can see that this can be written as a matrix equation!
$$ \begin{bmatrix}
R_1 & 0 & R_3 \\\
0 & R_2 & R_3 \\\
1 & 1 & 1 \end{bmatrix}
\begin{bmatrix}
I_1 \\\
I_2 \\\
I_3
\end{bmatrix} =
\begin{bmatrix}
V_1 \\\
V_2 \\\
0
\end{bmatrix} $$
This matrix equation,
$$ \mathbf{M}\mathbf{x} = \mathbf{b} $$
has solution
$$ \mathbf{x} = \mathbf{M}^{1}\mathbf{b} $$
where $\mathbf{M}^{1}$ is the _inverse_ of $\mathbf{M}$.
Most computational packages have builtin capability for inverting matrices.
### Assignment
1. By carrying out the matrix multiplication explicitly, show that the matrix equation above reduces to the system of equations from which it is derived.
2. Use a matrixsolving package to find the currents.
3. Check your answers by substituting the currents into the equations and verifying that they are solutions.
## Exercise 2: More complicated problem
The resistor network below is perhaps a bit more challenging.
![Fiveloop circuit](images/linearEquations/5_loop.png)
### Assignment
1. Write a system of equations that can be used to solve for the currents in the circuit above.
2. Rewrite the system of equations from part 1 of this assignment as a matrix equation.
3. Use a matrixsolving package to find the currents.
4. Check your answers: do the values of currents you found solve the equations with which you started?
5. You may notice something interesting if you compare your solution here to your solution for exercise 1. (Assuming the same values of $R$ and $V$ were used in both exercises.) Explain why this happened.
Unless your instructor provides you with other values, assume each voltage source and each resistor has a value $10\times$ its identifying number. (i.e. $V_2 = 20$ V, $R_3 = 30 \Omega$.)
Download Options
Share a Variation
Did you have to edit this material to fit your needs? Share your changes by
Creating a Variation
Credits and Licensing
E. Ayars, "Solving systems of linear equations: resistor networks," Published in the PICUP Collection, August 2016.
The instructor materials are ©2016 E. Ayars.
The exercises are released under a Creative Commons AttributionNonCommercialShareAlike 4.0 license