Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

4.1: Writing systems using matrices

In Chapter 2, we solved systems by looking for intersections of lines and planes. In Chapter 3, we learned how matrices describe linear transformations. Now we’ll put these ideas together: solving a linear system means finding a vector that a matrix sends to a specified output.

We’ll start with a small electrical network, then develop a method that also works for much larger systems.


From equations to a matrix

Consider the system

3x−y=15,−x+2y=0.\begin{aligned}3x-y&=15,\\-x+2y&=0.\end{aligned}

Put the coefficients of xx in the first column and the coefficients of yy in the second. Then matrix-vector multiplication gives

[3−1−12][xy]=[3x−y−x+2y].\begin{bmatrix}3&-1\\-1&2\end{bmatrix}\begin{bmatrix}x\\y\end{bmatrix} =\begin{bmatrix}3x-y\\-x+2y\end{bmatrix}.

So our two equations can be written as one matrix equation:

[3−1−12]⏟A[xy]⏟x⃗=[150]⏟b⃗.\underbrace{\begin{bmatrix}3&-1\\-1&2\end{bmatrix}}_A \underbrace{\begin{bmatrix}x\\y\end{bmatrix}}_{\vec x} =\underbrace{\begin{bmatrix}15\\0\end{bmatrix}}_{\vec b}.

Keep the variables in the same order in every equation, and use a zero when a variable is missing. For example,

2x−z=4,x+3y=7⟺[20−1130][xyz]=[47].\begin{aligned}2x-z&=4,\\x+3y&=7\end{aligned} \quad\Longleftrightarrow\quad \begin{bmatrix}2&0&-1\\1&3&0\end{bmatrix}\begin{bmatrix}x\\y\\z\end{bmatrix} =\begin{bmatrix}4\\7\end{bmatrix}.

The coefficient matrix need not be square! Here there are two equations and three unknowns.


A circuit with two unknown voltages

An engineer connects a 10-volt supply to a resistor network. There are two junctions with unknown voltages V1V_1 and V2V_2. The ground connection has voltage 0.

The connections are:

FromToResistance
10-volt supplyV1V_12 Ω2\,\Omega
V1V_1Ground6 Ω6\,\Omega
V1V_1V2V_23 Ω3\,\Omega
V2V_2Ground3 Ω3\,\Omega

We need two physical rules. Ohm’s law says that current from voltage VV toward voltage WW through resistance RR is (V−W)/R(V-W)/R. A negative value means the current flows in the opposite direction. Current balance says that total current entering a junction equals total current leaving it.

At V1V_1, current arrives from the supply and leaves toward ground and V2V_2:

10−V12=V16+V1−V23.\frac{10-V_1}{2}=\frac{V_1}{6}+\frac{V_1-V_2}{3}.

Multiplying by 6 gives 30−3V1=V1+2(V1−V2)30-3V_1=V_1+2(V_1-V_2). Collecting terms and dividing by 2 gives

3V1−V2=15.3V_1-V_2=15.

At V2V_2, current arriving from V1V_1 leaves toward ground:

V1−V23=V23⟹−V1+2V2=0.\frac{V_1-V_2}{3}=\frac{V_2}{3} \quad\Longrightarrow\quad -V_1+2V_2=0.

Together, these equations give

[3−1−12][V1V2]=[150].\boxed{\begin{bmatrix}3&-1\\-1&2\end{bmatrix}\begin{bmatrix}V_1\\V_2\end{bmatrix} =\begin{bmatrix}15\\0\end{bmatrix}.}

The resistances determine the coefficient matrix. Changing the supply voltage changes the right-hand side. We’ll return to this system in Chapter 4.3.


What does a solution mean?

A solution is one vector whose entries satisfy every equation at the same time. For our circuit,

[3−1−12][63]=[18−3−6+6]=[150],\begin{bmatrix}3&-1\\-1&2\end{bmatrix}\begin{bmatrix}6\\3\end{bmatrix} =\begin{bmatrix}18-3\\-6+6\end{bmatrix} =\begin{bmatrix}15\\0\end{bmatrix},

so V1=6V_1=6 and V2=3V_2=3 solve the system.

We can interpret this in three familiar ways:

  • Equations: the point (6,3)(6,3) lies on both lines 3x−y=153x-y=15 and −x+2y=0-x+2y=0.

  • Columns: 6[3−1]+3[−12]=[150]6\begin{bmatrix}3\\-1\end{bmatrix}+3\begin{bmatrix}-1\\2\end{bmatrix}=\begin{bmatrix}15\\0\end{bmatrix}.

  • Transformations: the map T(x⃗)=Ax⃗T(\vec x)=A\vec x sends [63]\begin{bmatrix}6\\3\end{bmatrix} to [150]\begin{bmatrix}15\\0\end{bmatrix}.

For a matrix of shape n×dn\times d, this transformation has domain Rd\mathbb R^d and codomain Rn\mathbb R^n.

If AA is invertible, Chapter 3.6 tells us that the unique solution is x⃗=A−1b⃗\vec x=A^{-1}\vec b. But we don’t need to compute the entire inverse to solve a system. Our goal is to find the solution by working with simpler matrices.


Another model: Temperatures in a metal bar

A metal bar is divided into three equal segments. Its endpoints are kept at 0∘C0^\circ\mathrm C and 60∘C60^\circ\mathrm C, and the interior temperatures are T1T_1 and T2T_2, in that order:

0∘C⟷T1⟷T2⟷60∘C.0^\circ\mathrm C\quad\longleftrightarrow\quad T_1\quad\longleftrightarrow\quad T_2\quad\longleftrightarrow\quad60^\circ\mathrm C.

No heat escapes through the sides. Assume each segment has thermal conductance 1 watt per degree Celsius, so the heat flow toward the left is the temperature at its right endpoint minus the temperature at its left endpoint, in watts.

The temperatures have stopped changing: at each interior point, heat arriving from the right equals heat leaving to the left. How can we use this balance to write a system for the two unknown temperatures?

Setting up the equations

At the point with temperature T1T_1, heat arrives from the right at a rate of T2−T1T_2-T_1 watts and leaves toward the left at a rate of T1−0T_1-0 watts. Setting these equal gives

T2−T1=T1−0⟹2T1−T2=0.T_2-T_1=T_1-0\quad\Longrightarrow\quad 2T_1-T_2=0.

At the point with temperature T2T_2, heat arrives from the right endpoint at a rate of 60−T260-T_2 watts and leaves toward T1T_1 at a rate of T2−T1T_2-T_1 watts. Thus,

60−T2=T2−T1⟹−T1+2T2=60.60-T_2=T_2-T_1\quad\Longrightarrow\quad -T_1+2T_2=60.

Our system is therefore

2T1−T2=0,−T1+2T2=60.\boxed{\begin{aligned}2T_1-T_2&=0,\\-T_1+2T_2&=60.\end{aligned}}

Writing the system using a matrix

Order the unknowns as T1,T2T_1,T_2. The coefficients of T1T_1 form the first column, and the coefficients of T2T_2 form the second:

[2−1−12]⏟A[T1T2]⏟T⃗=[060]⏟b⃗.\boxed{\underbrace{\begin{bmatrix}2&-1\\-1&2\end{bmatrix}}_A \underbrace{\begin{bmatrix}T_1\\T_2\end{bmatrix}}_{\vec T} =\underbrace{\begin{bmatrix}0\\60\end{bmatrix}}_{\vec b}.}

If the right endpoint changes to 90∘C90^\circ\mathrm C, the coefficient matrix stays the same, while the right-hand side becomes [090]\begin{bmatrix}0\\90\end{bmatrix}. Just as in the circuit example, changing a boundary value changes b⃗\vec b without changing AA.

We’ll revisit this system in Chapter 4.3, where we’ll use an LU factorization to find the two temperatures.