Math 33A Week 0: Solving Systems of Linear Equations

Linear equations

Let's start super basic with a single linear equation.

Linear Equations

Two variables: ax+by=cax+by=c
Three variables: ax+by+cz=dax+by+cz=d
nn variables: a1x1+⋯anxn=ba_1x_1 + \cdots a_nx_n = b

In two variables, the equation represents a line, that is solutions to the equation form a line. It is equivalent to the y=mx+by=mx+b form.

In three variables, the equation represents a plane. This is where the physical imagery ends, but the geometric intuition can extend to arbitrary number of variables.

The number on the right hand side (RHS) of these equations contain information about the displacement of the line/plane. For example, if the RHS is zero, then the line/plane contains the origin.

Linear Systems

We can combine linear equations to form a systems of linear equations.

Linear System

A linear system in nn variables and mm equations is a collection of mm linear equations, each with nn variables:
a11x1+⋯+a1nxn=b1      ⋮am1x1+⋯+amnxn=bm\begin{align*}a_{11}x_1 + &\cdots + a_{1n}x_n = b_1\\ &\;\;\;\vdots \\ a_{m1}x_1 + &\cdots + a_{mn}x_n = b_m \end{align*}
It is convenient to call such a system an m×nm\times n system.

The solution to a linear system in nn variables is a point (x1,…,xn)(x_1,\dots, x_n) which satisfies every equation in the system.

Example in 2 variables

(1,2)(1,2) is a solution to 6x−3y=0x+y=3\begin{align*}6x-3y=0 \\ x+y =3\end{align*}

The geometric interpretation is that a system of mm equations is the intersection of mm different lines/planes. Depending on how these lines/planes intersect, we can have different number of solutions.

Example: Linear Systems in Chemistry

Linear systems are not just for solving geometric questions. They can also arise in many scientific contexts. For example, suppose we want to balance a chemical reaction like the combustion of methane:
X‾CH4+X‾O2→X‾CO2+X‾H2O.\underline{\phantom{X}}\text{CH}_4 + \underline{\phantom{X}}\text{O}_2 \rightarrow \underline{\phantom{X}}\text{CO}_2 + \underline{\phantom{X}}\text{H}_2\text{O}.
In particular, we want to find values x,y,z,wx,y,z,w such that the atoms (in both number and type) contained in
xCH4+yO2x\text{CH}_4 + y\text{O}_2
are exactly the same (in both number and type) as the atoms contained in
zCO2+wH2O.z\text{CO}_2 +w\text{H}_2\text{O}.
Equivalently, we have the following equations we want to solve
C:x=zH:4x=2wO:2y=2z+w\begin{align*}&C: x = z\\ &H:4x=2w\\ &O: 2y =2z+w \end{align*}
We can rewrite these three equations as a 3×43\times 4 system:
x+0y−z+0w=04x+0y+0z−2w=00x+2y−2z−w=0\begin{align*}x+0y-z+0w=0\\ 4x+0y+0z-2w=0\\ 0x+2y-2z-w=0\end{align*}

Number of solutions to a linear system

Why can't we have many solutions but not infinitely many?

We will learn through the study of linear algebra why this is the case. For a direct answer, think about how we can get new solutions from existing ones, which will contradict finiteness of solutions. Hint: is the average of two solutions a solution?

Solving linear systems

Example: 2×22\times2 System

Find solutions to:
x−2y=42x+3y=7\begin{align*}x-2y=4\\ 2x+3y=7\end{align*}
Solution: An approach many students learn first is to "isolate" a variable in one of the equations. For example, x=2y+4.x=2y+4.
Then, we "plug" that variable into the other equation. Using x=2y+4x=2y+4, we get 2(2y+4)+3y=7.2(2y+4)+3y=7.
This allows us to first determine that 7y=−17y=-1 or rather y=−17y=-\frac{1}{7}. This can be plugged into either of the original equations to get x=267x= \frac{26}{7}. So the solution is (267,−17)(\frac{26}{7}, -\frac{1}{7}).

The process we used in the previous example can be extremely tedious and inefficient when we have a large number of equations and unknowns. Instead, we want to be able to systematically solve these linear systems. Two observations will give us a nice way of doing this.

Observation 1: Replacing an equation by a multiple of itself doesn't change the solutions.

Note that if c≠0c\neq 0, then a1x1+⋯+anxn=ba_1x_1+\cdots+a_nx_n= b and c(a1x1+⋯+anxn)=cbc(a_1x_1+\cdots+a_nx_n)= cb have the same solutions because we can multiply/divide by cc as needed to show that a solution to one equation is a solution to the other. Geometrically, the two equations represent the same exact "plane".

Observation 2: Replacing an equation with the sum of itself and another equation does not change the solutions.

The system
a11x1+⋯+a1nxn=b1a21x1+⋯+a2nxn=b2\begin{align*}a_{11}x_1+\cdots+a_{1n}x_n= b_1\\a_{21}x_1+\cdots+a_{2n}x_n= b_2\end{align*}
has the same solutions as
a11x1+⋯+a1nxn=b1(a11+a21)x1+⋯+(a1n+a2n)xn=b1+b2\begin{align*}a_{11}x_1+\cdots+a_{1n}x_n&= b_1\\(a_{11}+a_{21})x_1+\cdots+(a_{1n+}a_{2n})x_n&= b_1+b_2\end{align*}
because we can add/subtract the first equation as needed to show that a solution to one system is a solution to the other system. Geometrically, the second plane is being rotated about the intersection.

The fact that these two "operations" of scaling and adding equations are reversible or "invertible" is what makes them preserve the solutions. We can use these two operations to simplyify our systems into equivalent systems whose solution is very easy to determine.

Revisiting the 2×22\times 2 system

Find solutions to
x−2y=42x+3y=7\begin{align*}x-2y=4\\ 2x+3y=7\end{align*}
Solution: If we multiply the first equation by −2-2 and add it to the second equation we can get a new equation 0x+7y=−10x+7y=-1.
By the two observations, the original system has the same solutions as the new system
x−2y=47y=−1\begin{align*}x-2y&=4\\ 7y&=-1\end{align*}
Then we can immediate solve for y=−17y=-\frac{1}{7} and then plug this into the first equation to get x=267x=\frac{26}{7}.

While the solution method isn't much different from the first method, it is generalizable to arbitrary linear systems. To be more specific, what we did was use multiples of the first equation to reduce the number of variables in the remaining equations. We can do this for each equation to get an equivalent system where the last equation has 1 variable and is thus easy to solve. Then by repeatedly plugging in our results, we can solve the remaining equations in reverse order.

3×33\times 3 System

Find solutions to
x+y+z=62x−y+3x=9x+2y−z=2\begin{align*}x+y+z=6 \\ 2x-y+3x= 9 \\ x+2y-z=2\end{align*}
Solution: Using the above method, we can replace 2x−y+3z=92x-y+3z=9 with
[2x−y+3z=9]−2[x+y+z=6]=[−3y+z=−3][2x-y+3z=9 ] -2[x+y+z=6] = [-3y+z=-3]
and x+2y−z=2x+2y-z=2 with
[x+2y−z=2]−[x+y+z=6]=[y−2z=−4][x+2y-z =2] -[x+y+z=6] = [y-2z=-4]
This gives us an equivalent system
x+y+z=6−3y+z=−3y−2z=−4\begin{align*}x+y+z&=6 \\ -3y+z&=-3 \\ y-2z&=-4\end{align*}
where the last two equations form an easier to solve 2×22\times 2 system. In particular, we can add 13×\frac{1}{3}\times the second equation to the third equation to get another equivalent system
x+y+z=6−3y+z=−3−53z=−5\begin{align*}x+y+z&=6 \\ -3y+z&=-3 \\ -\frac{5}{3}z&=-5\end{align*}
Then we can easily solve the equations in reverse order to get z=3z= 3, y=2y= 2 and then x=1x=1 so the solution is (1,2,3)(1,2,3).

Augmented matrices

When solving linear systems, as long as each equation has the same order of variables, we can declutter our arithmetic by only working with the coefficients. More specifically, we can represent a linear system
{a11x1+⋯+a1nxn=b1⋮am1x1+⋯+amnxn=bm\begin{cases}a_{11}x_1+\cdots&+ a_{1n}x_n = b_1\\&\vdots\\ a_{m1}x_1+\cdots&+ a_{mn}x_n=b_m \end{cases}
by its so-called augmented matrix:
(a11⋯a1nb1⋮⋱⋮⋮am1⋯amnbm)\left(\begin{array}{ccc|c}a_{11} & \cdots & a_{1n} &b_1\\ \vdots & \ddots & \vdots &\vdots \\ a_{m1} & \cdots & a_{mn} & b_m\end{array}\right)
Then any operations that we perform on the linear system (adding equations, scaling equations, etc.) can be done on the rows of the augmented matrix.

Another 3×33\times3 system

Find solutions to
x+y+z=32x+2y+2z=6x+y+z=5\begin{align*}x+y+z&=3 \\ 2x+2y+2z&=6\\ x+y+z&=5\end{align*}
Solution: Using the method above, we will end up adding −1×-1\times the first equation to the third equation which will result in 0=20=2,
which is not true. Thus the system has no solutions. We can also recognize that the first and third equations give 3=53=5 before we try the method. Such a linear system where some equations are "inconsistent" with each other is called an inconsistent system.

One more 3×33\times 3 system

Find solutions to
x+y+z=3x−y+z=1\begin{align*}x+y+z&=3 \\ x-y+z&=1\end{align*}
Solution: Note that geoemtrically, we are looking for the intersection of two planes in three-dimensional space. Since the two planes are not parallel, this intersection will be a line. So we should expect infinitely many solutions. Indeed, if we proceed with the method and add −1×-1\times the first equation to the second equation, we get an equivalent system
x+y+z=3−2y=−2\begin{align*}x+y+z&=3 \\ -2y&=-2\end{align*}
So we have any solution will have y=1y=1. Moreover, as long as we have x=2−zx=2-z, then we have a solution. Thus a formula for the solution is (2−z,1,z)(2-z,1,z)
where zz is any number. Alternatively, we have that (x,1,2−x)(x,1,2-x)
is a solution for any xx.

Classifying systems

A system that has no solution is called inconsistent.
A system with more variables/unknowns than equations (like in the last example) is called underdetermined.
A system with more equations than unknowns/variables is called overdetermined.