Systems of linear equations — guided practice with five shake problems, Rouché without solving and an exam-style parameter (and the equation I forgot to copy)

In the classroom worksheet on systems I solved a four-equation system by Gaussian elimination, got infinitely many solutions and called it done. When it was marked, the lecturer showed me that when writing the augmented matrix I had left one equation out: with three equations instead of four, of course I had a parameter to spare. Since then I count the rows of the augmented matrix before starting: as many as there are equations, not one fewer.

In this practice we do by hand what you saw in the theory of systems of linear equations, always with the shake: a snack by Gaussian elimination and by Cramer, the shake with ricotta by Gauss-Jordan (infinitely many solutions, and which ones work in the kitchen), three systems classified with Rouché without solving them, the homogeneous system that tells you which ingredients can be swapped and, at the end, a system with a parameter in the format of an exam question. Each problem is checked in MATLAB, as in the second MATLAB assignment.

Before you start

Make sure you are comfortable with:

  • How to write the augmented matrix (A∣B)(A \mid B) of a system.
  • The three elementary operations, and the fact that they do not change the solutions.
  • The Rouché-Frobenius theorem: p=rg(A)p = rg(A), q=rg(A∣B)q = rg(A \mid B) and nn unknowns.
  • How to compute the rank with the echelon form or with minors (topic 1).

If any of these feels shaky, go over the theory before carrying on.

The shake data are always the same. Per serving: oats (30 g) 4 g of protein, 18 of carbs and 2 of fat; milk (200 ml) 6, 10 and 3; banana 1, 24 and 0; ricotta (80 g) 8, 2 and 4. Each ingredient is a column of the matrix and each nutrient, a row.

How to solve a system on paper

  1. Data: write the augmented matrix and count its rows (as many as equations) and columns (unknowns plus one).
  2. Classify: row reduce and look at pp, qq and nn before solving for anything. If it is inconsistent, you are done.
  3. Solve: Gaussian elimination (and back substitution) or Gauss-Jordan (and read). If there are infinitely many solutions, take the unknowns without a pivot as parameters.
  4. Check: substitute the solution into all the original equations, not the transformed ones.

Problem 1: the snack, by Gaussian elimination and by Cramer

Statement. For my afternoon snack I want 12 g of protein, 76 g of carbs and 5 g of fat with oats (xx), milk (yy) and banana (zz):

4x+6y+z=1218x+10y+24z=762x+3y=5 \begin{array}{rcl} 4x + 6y + z & = & 12 \\ 18x + 10y + 24z & = & 76 \\ 2x + 3y & = & 5 \end{array}

a) Classify the system and solve it by Gaussian elimination. b) Check the value of zz with Cramer’s rule.

The idea

It is the same coefficient matrix as the shake in the theory, with other targets. Since AA has not changed, ∣A∣=34|A| = 34 still holds and we already know it will have a unique solution; even so, we classify it by row reducing, which is what is asked. I start with the fat equation because it has a 0 and small numbers.

Halve the carbs equation before starting: 9x+5y+12z=389x + 5y + 12z = 38. Less arithmetic, same solutions.

Step by step

a) I reorder the equations (fat, protein, halved carbs) and clear the first column:

(230546112951238)→f3→2f3−9f1f2→f2−2f1(230500120−172431)→f2↔f3(23050−1724310012) \left(\begin{array}{ccc|c} 2 & 3 & 0 & 5 \\ 4 & 6 & 1 & 12 \\ 9 & 5 & 12 & 38 \end{array}\right) \xrightarrow[f_3 \to 2f_3 – 9f_1]{f_2 \to f_2 – 2f_1} \left(\begin{array}{ccc|c} 2 & 3 & 0 & 5 \\ 0 & 0 & 1 & 2 \\ 0 & -17 & 24 & 31 \end{array}\right) \xrightarrow{f_2 \leftrightarrow f_3} \left(\begin{array}{ccc|c} 2 & 3 & 0 & 5 \\ 0 & -17 & 24 & 31 \\ 0 & 0 & 1 & 2 \end{array}\right)

Those two arrows, row by row. The rule: from the row you want to clear, subtract the multiple of the pivot row that turns its first number into 0.

StepOperationResulting rowWhy
1Reorder: fat, protein, halved carbs(2  3  0∣5) (2 \; 3 \; 0 \mid 5) on topThe 2 of the fat is the handiest pivot, and the row has no banana
2f2→f2−2f1 f_2 \to f_2 – 2f_1 (4−4    6−6    1−0∣12−10)=(0  0  1∣2) (4 – 4 \;\; 6 – 6 \;\; 1 – 0 \mid 12 – 10) = (0 \; 0 \; 1 \mid 2) The 4 is twice the pivot. As a bonus, the 6 also becomes 0
3f3→2f3−9f1 f_3 \to 2f_3 – 9f_1 (18−18    10−27    24−0∣76−45)=(0  −17  24∣31) (18 – 18 \;\; 10 – 27 \;\; 24 – 0 \mid 76 – 45) = (0 \; {-17} \; 24 \mid 31) 9 is not a multiple of 2: multiplying f3 f_3 by 2 before subtracting avoids fractions
4f2↔f3 f_2 \leftrightarrow f_3 (0  −17  24∣31) (0 \; {-17} \; 24 \mid 31) moves to the second rowRow 2 has lost its milk: moving the other one up leaves the staircase properly drawn
5Count steps3 in A A and 3 in the augmented matrixp=q=3=n p = q = 3 = n : unique solution

Step 2 is the one that surprises people: clearing the oats also clears the milk. It is no coincidence: in the protein, oats and milk give twice what they give in the fat (4 and 6 against 2 and 3), so the row that is left only talks about the banana.

The tricky calculation is row 3: 2⋅38−9⋅5=76−45=312 \cdot 38 – 9 \cdot 5 = 76 – 45 = 31. Three steps in AA and three in the augmented matrix: p=q=3=np = q = 3 = n, unique solution. Substituting from the bottom up:

  • z=2z = 2.
  • −17y+24⋅2=31⇒−17y=−17⇒y=1-17y + 24 \cdot 2 = 31 \Rightarrow -17y = -17 \Rightarrow y = 1.
  • 2x+3⋅1=5⇒x=12x + 3 \cdot 1 = 5 \Rightarrow x = 1.

One serving of oats, one glass of milk and two bananas.

b) For zz, I replace the third column of AA (the banana) with the targets:

z=∣4612181076235∣∣A∣=200+912+648−240−540−91234=6834=2 z = \frac{\begin{vmatrix} 4 & 6 & 12 \\ 18 & 10 & 76 \\ 2 & 3 & 5 \end{vmatrix}}{|A|} = \frac{200 + 912 + 648 – 240 – 540 – 912}{34} = \frac{68}{34} = 2

It matches. With Cramer you do not need xx or yy to get zz: that is why it is handy when you are only asked for one unknown.

Cramer’s numerator, product by product. By Sarrus, the main diagonal and its two parallels are added, and the other diagonal and its parallels are subtracted:

TermCalculationSignWhy
Main diagonal4⋅10⋅5=200 4 \cdot 10 \cdot 5 = 200 + + Goes down from left to right
First parallel6⋅76⋅2=912 6 \cdot 76 \cdot 2 = 912 + + Ends with the 2 in the bottom corner
Second parallel12⋅18⋅3=648 12 \cdot 18 \cdot 3 = 648 + + Starts in the top right corner
Other diagonal12⋅10⋅2=240 12 \cdot 10 \cdot 2 = 240 − – Goes down from right to left
Its first parallel4⋅76⋅3=912 4 \cdot 76 \cdot 3 = 912 − – Starts with the 4 in the corner
Its second parallel6⋅18⋅5=540 6 \cdot 18 \cdot 5 = 540 − – Ends with the 5 in the corner

The added terms give 1760 and the subtracted ones 1692: that leaves 68. The denominator, with the same calculation: ∣A∣=0+288+54−20−288−0=34 |A| = 0 + 288 + 54 – 20 – 288 – 0 = 34 .

The two 912s cancel out (and in ∣A∣ |A| , the two 288s). Before adding, cross out equal pairs with opposite signs: fewer calculations, fewer mistakes.

Check it in MATLAB

A = [4 6 1; 18 10 24; 2 3 0];
B = [12; 76; 5];
p = rank(A), q = rank([A B])     % 3 and 3, with n = 3: unique
rref([A B])                      % the solution in the last column
A3 = A;  A3(:, 3) = B;           % Cramer: column 3 replaced by B
det(A3) / det(A)                 % the value of z

Output:

p =

     3

q =

     3

ans =

    1.0000         0         0    1.0000
         0    1.0000         0    1.0000
         0         0    1.0000    2.0000

ans =

     2

A3(:, 3) = B replaces the whole of column 3 with BB: exactly Cramer’s matrix. The ratio of determinants gives 2 (MATLAB computes it with decimals, which is why it may show 2.0000).

Questions you might ask

Why reorder the equations? Because the order does not change the solutions and a good first row saves arithmetic. The fat equation has a 0 and the pivot 2 divides the other numbers in the column.

Isn’t multiplying f3f_3 by 2 “cheating”? In a system, no: multiplying an equation by a non-zero number gives one with the same solutions. What you cannot do without compensating is multiply rows when computing a determinant.

What if I had not swapped f2f_2 and f3f_3? The row (0  0  1∣2)(0 \; 0 \; 1 \mid 2) already gives z=2z = 2 directly, so you could solve it all the same. The swap just keeps the staircase tidy.

Cramer or Gaussian elimination? For the whole system, Gaussian elimination; for a single unknown of a 3×33 \times 3, Cramer can be quicker. With numbers this large, the determinants take some effort.

Checking the solution in the echelon system instead of the original one. If you made a mistake while row reducing, the solution will satisfy the wrong system. Substitute into the three original equations: 4+6+2=124 + 6 + 2 = 12, 18+10+48=7618 + 10 + 48 = 76, 2+3=52 + 3 = 5.

Try it yourself

  • Solve the shake with targets 17, 62 and 8 (protein, carbs and fat). You should get another combination of whole numbers.
  • Compute yy by Cramer in the snack and check that it is 1.

Problem 2: the shake with ricotta, by Gauss-Jordan

Statement. I add ricotta (tt servings) to the shake in the theory, with the same targets: 15 g of protein, 70 of carbs and 7 of fat.

4x+6y+z+8t=1518x+10y+24z+2t=702x+3y+4t=7 \begin{array}{rcl} 4x + 6y + z + 8t & = & 15 \\ 18x + 10y + 24z + 2t & = & 70 \\ 2x + 3y + 4t & = & 7 \end{array}

a) Classify the system and solve it by Gauss-Jordan. b) Which values of the parameter give a shake you can actually make (all amounts ≥0\ge 0)?

The idea

Three equations and four unknowns: it cannot have a unique solution (m<nm < n). Either it is inconsistent or it has infinitely many solutions. We row reduce, count and, if it is consistent, reach the reduced form to write the pivot unknowns in terms of the free one.

Do exactly the same operations as in problem 1. The new column, the ricotta, just comes along for the ride.

Step by step

a) Same order and same operations as before:

(230474618159512135)→f3→2f3−9f1f2→f2−2f1(23047001010−1724−347)→f2↔f3(230470−1724−34700101) \left(\begin{array}{cccc|c} 2 & 3 & 0 & 4 & 7 \\ 4 & 6 & 1 & 8 & 15 \\ 9 & 5 & 12 & 1 & 35 \end{array}\right) \xrightarrow[f_3 \to 2f_3 – 9f_1]{f_2 \to f_2 – 2f_1} \left(\begin{array}{cccc|c} 2 & 3 & 0 & 4 & 7 \\ 0 & 0 & 1 & 0 & 1 \\ 0 & -17 & 24 & -34 & 7 \end{array}\right) \xrightarrow{f_2 \leftrightarrow f_3} \left(\begin{array}{cccc|c} 2 & 3 & 0 & 4 & 7 \\ 0 & -17 & 24 & -34 & 7 \\ 0 & 0 & 1 & 0 & 1 \end{array}\right)

In the ricotta column: 8−2⋅4=08 – 2 \cdot 4 = 0 and 2⋅1−9⋅4=−342 \cdot 1 – 9 \cdot 4 = -34. Three steps in both matrices: p=q=3<n=4p = q = 3 < n = 4, infinitely many solutions with 4−3=14 – 3 = 1 degree of freedom. Now, Gauss-Jordan, from the bottom up:

→f2→f2−24f3(230470−170−34−1700101)→f2→−117f2(230470102100101) \xrightarrow{f_2 \to f_2 – 24f_3} \left(\begin{array}{cccc|c} 2 & 3 & 0 & 4 & 7 \\ 0 & -17 & 0 & -34 & -17 \\ 0 & 0 & 1 & 0 & 1 \end{array}\right) \xrightarrow{f_2 \to -\frac{1}{17} f_2} \left(\begin{array}{cccc|c} 2 & 3 & 0 & 4 & 7 \\ 0 & 1 & 0 & 2 & 1 \\ 0 & 0 & 1 & 0 & 1 \end{array}\right)
→f1→f1−3f2(200−240102100101)→f1→12f1(100−120102100101) \xrightarrow{f_1 \to f_1 – 3f_2} \left(\begin{array}{cccc|c} 2 & 0 & 0 & -2 & 4 \\ 0 & 1 & 0 & 2 & 1 \\ 0 & 0 & 1 & 0 & 1 \end{array}\right) \xrightarrow{f_1 \to \frac12 f_1} \left(\begin{array}{cccc|c} 1 & 0 & 0 & -1 & 2 \\ 0 & 1 & 0 & 2 & 1 \\ 0 & 0 & 1 & 0 & 1 \end{array}\right)

Those four arrows, one at a time. The Gauss-Jordan rule: you work from the bottom up, and each pivot first clears what is above it and then becomes a 1.

StepOperationWhat changesWhy
1f2→f2−24f3 f_2 \to f_2 – 24f_3 The 24 becomes 0 and the 7 on the right, 7−24=−17 7 – 24 = -17 The banana’s 1 clears its column upwards; row 1 already has a 0 there
2f2→−117f2 f_2 \to -\frac{1}{17} f_2 (0  −17  0  −34∣−17) (0 \; {-17} \; 0 \; {-34} \mid {-17}) becomes (0  1  0  2∣1) (0 \; 1 \; 0 \; 2 \mid 1) Every number in the row is a multiple of −17 -17 : dividing gives no fractions
3f1→f1−3f2 f_1 \to f_1 – 3f_2 3−3=0 3 – 3 = 0 , 4−3⋅2=−2 4 – 3 \cdot 2 = -2 and 7−3⋅1=4 7 – 3 \cdot 1 = 4 The milk’s pivot clears the 3 above it; the t t column is carried along
4f1→12f1 f_1 \to \frac12 f_1 (1  0  0  −1∣2) (1 \; 0 \; 0 \; {-1} \mid 2) The last pivot becomes a 1 and every row can now be read

Why from the bottom up? Because the bottom row has only one number in A A and does not dirty the other columns. If you start by using row 2 on row 1, the banana’s 24 would move into row 1 and you would have to clear it again.

The tt column has no pivot: tt is the free unknown. Each row is read by moving the tt term to the right:

x=2+t,y=1−2t,z=1,t∈R x = 2 + t, \qquad y = 1 – 2t, \qquad z = 1, \qquad t \in \mathbb{R}

b) In the kitchen, x≥0x \ge 0 (true if t≥−2t \ge -2), y≥0y \ge 0 (if t≤12t \le \tfrac12), z=1z = 1 always, and t≥0t \ge 0. Putting it together: 0≤t≤120 \le t \le \tfrac12. With t=14t = \tfrac14, for example: two and a quarter servings of oats, half a glass of milk, one banana and a quarter of a serving of ricotta.

Check it in MATLAB

format rat
A4 = [4 6 1 8; 18 10 24 2; 2 3 0 4];
B  = [15; 70; 7];
p = rank(A4), q = rank([A4 B]), n = size(A4, 2)
R = rref([A4 B])                 % the same reduced form as by hand
t = 1/4;
x = [2 + t; 1 - 2*t; 1; t];      % one particular solution
A4*x                             % must give 15, 70, 7

Output:

p =

       3       

q =

       3       

n =

       4       

R =

       1              0              0             -1              2       
       0              1              0              2              1       
       0              0              1              0              1       

ans =

      15       
      70       
       7       

A4*x with t=14t = \tfrac14 returns the exact targets: any tt works for the equations, and the condition 0≤t≤120 \le t \le \tfrac12 is imposed only by the kitchen.

Check you’ve got it: what would happen if you asked for 8 g of fat instead of 7?

The system would still have infinitely many solutions, but you could not make any of them. Step by step: A4 A_4 does not change, so its three steps are still there; and since the augmented matrix only has three rows, there is no room for a fourth step: p=q=3<n=4 p = q = 3 < n = 4 , infinitely many solutions again. With this matrix, whatever targets you choose, it is never inconsistent.

But look at the banana row. With the same operations, f2→f2−2f1 f_2 \to f_2 – 2f_1 now gives (0  0  1  0∣15−2⋅8) (0 \; 0 \; 1 \; 0 \mid 15 – 2 \cdot 8) , that is, z=−1 z = -1 in every solution. That is what the question about why z=1 z = 1 explained: “protein minus twice the fat” can only come from the banana, and here it is −1 -1 . You cannot add minus one banana: the maths says “infinitely many” and the kitchen says “none”.

Questions you might ask

Why tt and not another unknown as the parameter? Because it is the one whose column has no pivot. You could solve for another (for example, with yy free), but in the exam you use the echelon form: the unknowns without a pivot are the parameters.

Why is z=1z = 1 in every solution? Because oats, milk and ricotta all have protein equal to twice the fat; only the banana breaks that ratio. The difference “protein minus twice the fat” comes from the banana, and here it is 15−2⋅7=115 – 2 \cdot 7 = 1.

Do infinitely many solutions mean any shake works? No: it means infinitely many shakes with those exact macros, all on the same “line” of solutions. Any other combination does not give 15, 70 and 7.

What if I add a fourth equation, fibre? With four independent equations and four unknowns, the system would have a unique solution: the fibre would pick a single value of tt.

Writing the solution as x=2x = 2, y=1y = 1, z=1z = 1, t=0t = 0 and calling it “the” solution. It is one of them (t=0t = 0); for a system with infinitely many solutions you must give the general solution, with the parameter.

Try it yourself

  • Take yy as the free unknown (call it μ\mu) and write xx, zz and tt in terms of μ\mu. Check that it describes the same solutions.
  • Which value of tt gives a shake with exactly 1 glass of milk? And one without ricotta?

Problem 3: three systems classified without solving them

Statement. With only oats (xx) and milk (yy), classify these systems using ranks (with minors), without solving them:

a) Protein 14, carbs 46, fat 7. b) Protein 15, carbs 70, fat 7. c) The homogeneous version with protein and fat: 4x+6y=04x + 6y = 0, 2x+3y=02x + 3y = 0.

The idea

In a) and b) there are 3 equations and 2 unknowns, so AA is 3×23 \times 2 and the augmented matrix is 3×33 \times 3. The rank of AA is at most 2; if the determinant of the augmented matrix is non-zero, its rank is 3 and the system is inconsistent. If it is 0, rank 2 and a unique solution.

The minor ∣461810∣\begin{vmatrix} 4 & 6 \\ 18 & 10 \end{vmatrix} (protein and carbs) works for the first two systems: compute it once.

Step by step

The rank of AA is the same in a) and b), because AA does not change:

A=(46181023),∣461810∣=40−108=−68≠0⇒rg(A)=2 A = \begin{pmatrix} 4 & 6 \\ 18 & 10 \\ 2 & 3 \end{pmatrix}, \qquad \begin{vmatrix} 4 & 6 \\ 18 & 10 \end{vmatrix} = 40 – 108 = -68 \neq 0 \quad\Rightarrow\quad rg(A) = 2

a) The augmented matrix is square; by Sarrus:

∣4614181046237∣=280+552+756−280−756−552=0 \begin{vmatrix} 4 & 6 & 14 \\ 18 & 10 & 46 \\ 2 & 3 & 7 \end{vmatrix} = 280 + 552 + 756 – 280 – 756 – 552 = 0

rg(A∣B)=2=rg(A)=nrg(A \mid B) = 2 = rg(A) = n: unique solution, even though there are more equations than unknowns. The carbs equation is a combination of the other two and adds nothing new. (The solution is x=2x = 2, y=1y = 1.)

b) With the shake targets:

∣4615181070237∣=280+840+810−300−756−840=34≠0 \begin{vmatrix} 4 & 6 & 15 \\ 18 & 10 & 70 \\ 2 & 3 & 7 \end{vmatrix} = 280 + 840 + 810 – 300 – 756 – 840 = 34 \neq 0

rg(A∣B)=3>rg(A)=2rg(A \mid B) = 3 > rg(A) = 2: inconsistent. It is my impossible shake from the theory.

c) Homogeneous with two equations: ∣4623∣=12−12=0\begin{vmatrix} 4 & 6 \\ 2 & 3 \end{vmatrix} = 12 – 12 = 0, so rg(A)=1<n=2rg(A) = 1 < n = 2: infinitely many solutions, with x=−32yx = -\tfrac32 y. Mathematically there are infinitely many mixes “with no protein or fat”, but all except the trivial one have a negative amount: in the kitchen, the only one is putting nothing in.

Three systems, three answersThree cards: a) with target 14, 46, 7 the determinant of the augmented matrix is 0 and the system has a unique solution; b) with 15, 70, 7 it is 34 and there is no solution; c) the homogeneous system has rank 1 below 2 unknowns and has infinitely many solutions.a)target (14, 46, 7)|A|B| = 0rg(A) = 2, rg(A|B) = 2CDb)target (15, 70, 7)|A|B| = 34rg(A) = 2, rg(A|B) = 3Ic)target (0, 0)|A| = 0rg(A) = 1 < n = 2CIa) and b): 3 equations and 2 unknowns; ranks decide, not the size
The same matrix A gives three different classifications depending on what you ask for.

Check it in MATLAB

A  = [4 6; 18 10; 2 3];
rank(A)
rank([A [14; 46; 7]])     % a) 2: unique solution
rank([A [15; 70; 7]])     % b) 3: inconsistent
rank([4 6; 2 3])          % c) 1 < 2: infinitely many
null([4 6; 2 3], 'r')     % c) the direction of the solutions

Output:

ans =

       2       

ans =

       2       

ans =

       3       

ans =

       1       

ans =

      -3/2     
       1       

null(M, 'r') gives the solutions of the homogeneous system MX=0M X = 0 with “rational” numbers (the 'r'): here, the column (−32,1)(-\tfrac32, 1), which is x=−32yx = -\tfrac32 y with y=1y = 1.

Questions you might ask

Why don’t I need to check more minors in a)? Because the only order-3 minor of the augmented matrix is the matrix itself. If it is 0, its rank cannot be 3, and it contains the order-2 minor that was already non-zero.

Can an equation that is a “combination of others” be crossed out? Yes, once you have checked it: it does not change the solutions. But you must check it with ranks or by row reducing, not by eye.

Can a homogeneous system come out inconsistent? Never: (0,0)(0, 0) is always a solution. That is why in c) we only had to decide between a unique solution and infinitely many.

Saying in a) “three equations and two unknowns, so inconsistent”. That is exactly the trick question from the quiz: what matters is the rank.

Try it yourself

  • Find a fat target gg that makes the system with protein 15 and carbs 70 consistent (hint: the determinant of the augmented matrix must be 0).
  • Classify the system with oats, milk and banana for the target (0,0,0)(0, 0, 0).

Problem 4: the homogeneous system of swaps

Statement. With the four ingredients, solve the homogeneous system A4X=0A_4 X = 0 by Gauss-Jordan and interpret its solutions. Then write the solution of problem 2 as “one particular solution plus those of the homogeneous system”.

The idea

The solutions of the homogeneous system are changes in amounts that change none of the macros. If you add one of them to a shake that already meets the targets, it still meets them. That is why the general solution of a consistent system is always “one particular solution + all those of the homogeneous system”.

They are the same operations as in problem 2 without the last column (or with zeros in it, which never change).

Step by step

With the column of zeros, the reduced form is that of problem 2 with zeros on the right:

(100−100102000100)⇒x=s,y=−2s,z=0,t=s,s∈R \left(\begin{array}{cccc|c} 1 & 0 & 0 & -1 & 0 \\ 0 & 1 & 0 & 2 & 0 \\ 0 & 0 & 1 & 0 & 0 \end{array}\right) \quad\Rightarrow\quad x = s, \quad y = -2s, \quad z = 0, \quad t = s, \quad s \in \mathbb{R}

With s=1s = 1: one more serving of oats and one of ricotta, in exchange for two fewer glasses of milk. Check that nothing changes: protein 4−12+8=04 – 12 + 8 = 0, carbs 18−20+2=018 – 20 + 2 = 0, fat 2−6+4=02 – 6 + 4 = 0. The diagram shows it as a balance.

A swap that leaves the macros unchangedA balanced scale: on one side, one more serving of oats and one of ricotta; on the other, two glasses of milk. Both sides give 12 g of protein, 20 of carbs and 6 of fat.+1 oats, +1 ricottaP 4+8 · C 18+2 · F 2+4−2 milkP 12 · C 20 · F 6protein 12 = 12, carbs 20 = 20, fat 6 = 6s · (1, −2, 0, 1): the banana is left alone
Every solution of the homogeneous system is a swap like this, times a number.

And the solution of problem 2 can be written like this:

(xyzt)=(2110)+t(1−201) \begin{pmatrix} x \\ y \\ z \\ t \end{pmatrix} = \begin{pmatrix} 2 \\ 1 \\ 1 \\ 0 \end{pmatrix} + t \begin{pmatrix} 1 \\ -2 \\ 0 \\ 1 \end{pmatrix}

The first vector is the shake from the theory (the one with t=0t = 0) and the second, the swap: each solution is that shake plus tt swaps. Check the second component: 1+t⋅(−2)=1−2t1 + t \cdot (-2) = 1 – 2t, the yy of problem 2.

Check it in MATLAB

A4 = [4 6 1 8; 18 10 24 2; 2 3 0 4];
N  = null(A4, 'r')               % the direction of the swaps
A4*N                             % zeros: no macro changes
A4*([2; 1; 1; 0] + 3*N)          % the theory shake plus 3 swaps

Output:

N =

       1       
      -2       
       0       
       1       

ans =

       0       
       0       
       0       

ans =

      15       
      70       
       7       

null(A4, 'r') returns the column (1,−2,0,1)(1, -2, 0, 1): the same as by hand. And adding three swaps to the theory shake gives another solution of the system with targets (15,70,7)(15, 70, 7), although with negative milk: mathematically fine, in the kitchen not.

Questions you might ask

Why is the general solution “particular plus homogeneous”? If AX1=BA X_1 = B and AX0=0A X_0 = 0, then A(X1+X0)=B+0=BA(X_1 + X_0) = B + 0 = B. And conversely: the difference of two solutions of AX=BAX = B solves the homogeneous system.

How many parameters does the homogeneous system have? The same as the full system when it is consistent: n−rg(A)n – rg(A), here one.

What if the homogeneous system only had the trivial solution? Then the full system, if consistent, would have a unique solution: no swap would be possible.

Forgetting that z=0z = 0 is also part of the homogeneous solution. An unknown that is 0 does not “disappear”: you have to write it.

Try it yourself

  • Check by hand that (2,1,1,0)+12(1,−2,0,1)(2, 1, 1, 0) + \tfrac12 (1, -2, 0, 1) satisfies the three equations of problem 2.
  • Invent a fifth ingredient and say how many parameters the homogeneous system would have with five unknowns and three independent equations.

Problem 5: how the exam asks it

Exam-style question. Discuss the following system for the values of a∈Ra \in \mathbb{R} and solve it whenever it is consistent: x+y+az=1x + y + az = 1, x+ay+z=1x + ay + z = 1, ax+y+z=1ax + y + z = 1. [4 points] a) (1.5 points) Classification depending on aa. b) (1.5 points) Solution when it has a unique solution. c) (1 point) Solution when it has infinitely many.

The idea

First the determinant of AA: where it does not vanish, Rouché gives a unique solution straight away. The values that make it zero are studied one by one, substituting and row reducing. And the matrix will look familiar: it is the key with a parameter from the topic 1 exercises, with the parameter in other positions.

By Sarrus, ∣A∣=3a−a3−2=−(a−1)2(a+2)|A| = 3a – a^3 – 2 = -(a – 1)^2 (a + 2). The equations are “symmetric”: if you swap xx, yy and zz, the system does not change. That tells you what the solution looks like in the unique case.

Step by step

a) ∣A∣=−(a−1)2(a+2)|A| = -(a – 1)^2 (a + 2), which vanishes at a=1a = 1 and a=−2a = -2.

Where that determinant comes from, without skipping anything. By Sarrus, with A A written row by row as (1  1  a) (1 \; 1 \; a) , (1  a  1) (1 \; a \; 1) and (a  1  1) (a \; 1 \; 1) :

TermCalculationSignWhy
Main diagonal1⋅a⋅1=a 1 \cdot a \cdot 1 = a + + It only picks up the a a in the center
First parallel1⋅1⋅a=a 1 \cdot 1 \cdot a = a + + Ends with the a a at the bottom
Second parallela⋅1⋅1=a a \cdot 1 \cdot 1 = a + + Starts with the a a at the top
Other diagonala⋅a⋅a=a3 a \cdot a \cdot a = a^3 − – All three a a are here
Its first parallel1⋅1⋅1=1 1 \cdot 1 \cdot 1 = 1 − – It does not touch any a a
Its second parallel1⋅1⋅1=1 1 \cdot 1 \cdot 1 = 1 − – Neither does this one

Total: a+a+a−a3−1−1=3a−a3−2 a + a + a – a^3 – 1 – 1 = 3a – a^3 – 2 . To factorise it, look for a root among the divisors of 2: with a=1 a = 1 , 3−1−2=0 3 – 1 – 2 = 0 , so a−1 a – 1 is a factor, and synthetic division (Ruffini’s rule) gives −a3+3a−2=(a−1)(−a2−a+2) -a^3 + 3a – 2 = (a – 1)(-a^2 – a + 2) . The second bracket is −(a2+a−2)=−(a−1)(a+2) -(a^2 + a – 2) = -(a – 1)(a + 2) , because its roots, 1 and −2 -2 , add up to −1 -1 and multiply to −2 -2 . Putting it all together, ∣A∣=−(a−1)2(a+2) |A| = -(a – 1)^2 (a + 2) .

Always try a=1 a = 1 first: with it the three rows are equal, so the determinant has to be 0.

  • If a≠1a \neq 1 and a≠−2a \neq -2: ∣A∣≠0|A| \neq 0, so rg(A)=3=rg(A∣B)=nrg(A) = 3 = rg(A \mid B) = n: unique solution.
  • If a=1a = 1: all three equations are x+y+z=1x + y + z = 1. rg(A)=rg(A∣B)=1<3rg(A) = rg(A \mid B) = 1 < 3: infinitely many solutions with 2 degrees of freedom.
  • If a=−2a = -2: adding the three rows of the augmented matrix, f3→f3+f1+f2f_3 \to f_3 + f_1 + f_2:
(11−211−211−2111)→f3→f3+f1+f2(11−211−2110003) \left(\begin{array}{ccc|c} 1 & 1 & -2 & 1 \\ 1 & -2 & 1 & 1 \\ -2 & 1 & 1 & 1 \end{array}\right) \xrightarrow{f_3 \to f_3 + f_1 + f_2} \left(\begin{array}{ccc|c} 1 & 1 & -2 & 1 \\ 1 & -2 & 1 & 1 \\ 0 & 0 & 0 & 3 \end{array}\right)

The last row is 0=30 = 3: rg(A)=2<rg(A∣B)=3rg(A) = 2 < rg(A \mid B) = 3, inconsistent. (rg(A)=2rg(A) = 2 because ∣111−2∣=−3≠0\begin{vmatrix} 1 & 1 \\ 1 & -2 \end{vmatrix} = -3 \neq 0.)

b) By symmetry, if (x,y,z)(x, y, z) is the only solution, so is the one with its values swapped; since it is unique, x=y=zx = y = z. Substituting into the first equation: x+x+ax=1⇒x(2+a)=1x + x + ax = 1 \Rightarrow x(2 + a) = 1:

x=y=z=1a+2 x = y = z = \frac{1}{a + 2}

Cramer gives the same: ∣Ax∣=∣11a1a1111∣=−(a−1)2|A_x| = \begin{vmatrix} 1 & 1 & a \\ 1 & a & 1 \\ 1 & 1 & 1 \end{vmatrix} = -(a – 1)^2 and x=−(a−1)2−(a−1)2(a+2)=1a+2x = \frac{-(a – 1)^2}{-(a – 1)^2 (a + 2)} = \frac{1}{a + 2}.

c) With a=1a = 1, we are left with x+y+z=1x + y + z = 1. The free unknowns are yy and zz:

x=1−λ−μ,y=λ,z=μ,λ,μ∈R x = 1 – \lambda – \mu, \qquad y = \lambda, \qquad z = \mu, \qquad \lambda, \mu \in \mathbb{R}

The diagram places the three cases on the line of values of aa.

The discussion on the a lineNumber line of the parameter a in green, unique solution, with two special points: a = −2, no solution, and a = 1, infinitely many with two parameters.-4-3-2-10123aa = −2: Irow 0 = 3a = 1: CI2 parameterseverything else (green): unique, x = y = z = 1/(a + 2)
The special values are the roots of the determinant; each is studied separately.

Check it in MATLAB

syms a
A = [1 1 a; 1 a 1; a 1 1];
B = [1; 1; 1];
d = det(A)                                 % the determinant with a
rank(subs(A, a, -2)), rank(subs([A B], a, -2))   % 2 and 3: inconsistent
rank(subs(A, a, 1)),  rank(subs([A B], a, 1))    % 1 and 1: infinitely many
inv(subs(A, a, 3))*B                       % with a = 3, x = y = z = 1/5

Output:

 
d =
 
3*a - a^3 - 2
 

ans =

       2       

ans =

       3       

ans =

       1       

ans =

       1       

 
ans =
 
1/5
1/5
1/5
 

d comes out expanded (3a−a3−23a – a^3 – 2); substituting a=1a = 1 and a=−2a = -2 gives 0. The ranks confirm the classification and, with a=3a = 3, the solution is 15\tfrac15 in all three unknowns: 13+2\tfrac{1}{3 + 2}.

Check and how it is marked

Check b) in the second equation: 1a+2+aa+2+1a+2=a+2a+2=1\tfrac{1}{a+2} + \tfrac{a}{a+2} + \tfrac{1}{a+2} = \tfrac{a + 2}{a + 2} = 1. And c) with λ=μ=0\lambda = \mu = 0: (1,0,0)(1, 0, 0) satisfies x+y+z=1x + y + z = 1.

Indicative split of the 4 points (my own, not the official one):

PartWhat earns the marksPoints
a)∣A∣\lvert A \rvert correctly computed and factorised0.5
a)General case, unique, with Rouché0.25
a)a=1a = 1: infinitely many, with its ranks0.25
a)a=−2a = -2: inconsistent, with the row 0=30 = 3 or the ranks0.5
b)Solution in terms of aa, justified1.5
c)Solution with two parameters1

Questions you might ask

Can I do the discussion by row reducing with aa inside? Yes, but when you divide by something like a−1a – 1 you have to treat separately the case where it is 0. With the determinant, the special cases appear on their own.

Why did I add all three rows at a=−2a = -2? Because in each column of AA there is a 1, another 1 and a −2-2: they add up to 0. It is the shortest route to the zero row; row reducing step by step gives the same.

How many parameters are there at a=1a = 1? n−rg(A)=3−1=2n – rg(A) = 3 – 1 = 2: two free unknowns.

Giving x=y=z=1a+2x = y = z = \frac{1}{a + 2} also for a=−2a = -2 or a=1a = 1. For a=−2a = -2 it does not even exist (you would divide by 0), and for a=1a = 1 it would give 13\tfrac13, which is only one of infinitely many solutions.

Try it yourself

  • Discuss the same system with the constant terms changed to (1,a,a2)(1, a, a^2).
  • For a=0a = 0, solve the system by Gaussian elimination and check that you get 12\tfrac12 in all three unknowns.

Common mistakes in this practice

  • Copying the augmented matrix wrongly, leaving out an equation or a sign. Count rows and columns before you start.
  • Mistaking a row (0⋯0∣0)(0 \cdots 0 \mid 0) for an inconsistency. Only (0⋯0∣c)(0 \cdots 0 \mid c) with c≠0c \neq 0 is one.
  • Giving one particular solution for a system with infinitely many instead of the general one with parameters.
  • Classifying by the number of equations instead of by the ranks.
  • Applying Cramer with ∣A∣=0|A| = 0 or to a non-square system.
  • Forgetting the special cases when discussing a parameter.

Try it in the MATLAB playground

The MATLAB playground on the site runs this check of the five problems:

format rat
%% Problem 1: the snack
A = [4 6 1; 18 10 24; 2 3 0];
rref([A [12; 76; 5]])
%% Problems 2 and 4: ricotta
A4 = [A [8; 2; 4]];
rref([A4 [15; 70; 7]])
null(A4, 'r')
%% Problem 3: oats and milk
rank([4 6; 18 10; 2 3]), rank([4 6 15; 18 10 70; 2 3 7])

Things to look at:

  1. A4 = [A [8; 2; 4]] attaches the ricotta column on the right: that is how you build a block matrix.
  2. Compare the last column of each rref with your paper solutions.
  3. In problem 3, change the fat 7 to other values and see when the rank goes from 3 to 2.
  4. Remove format rat and see how the fractions in problem 2 change.

Summary

  • Before solving, classify with pp, qq and nn: it saves work and stops you solving the impossible.
  • Gaussian elimination leaves the staircase and you substitute from the bottom up; Gauss-Jordan reaches the reduced form and you read the solution.
  • With infinitely many solutions, the unknowns without a pivot are the parameters and the solution is given in general.
  • The general solution of a consistent system is a particular one plus those of the homogeneous system.
  • More equations than unknowns does not mean inconsistent; the ranks decide.
  • With a parameter: determinant, values that make it zero, the general case and each special case separately.

Checklist: have you practised it?

  • Have you solved the snack by Gaussian elimination and checked one unknown with Cramer?
  • Can you write the general solution of the shake with ricotta and say which values of the parameter work in the kitchen?
  • Can you classify a system with more equations than unknowns using only determinants?
  • Do you understand why the solutions of the homogeneous system are “swaps” that change nothing?
  • Have you run the MATLAB blocks and checked the outputs?
  • Have you tried the “Try it yourself” items without looking at the theory?

If you answered yes to almost everything, you are ready for the systems of linear equations exercises, where I no longer give you the step by step and there is a 20-question quiz like the Campus ones. See you there!

Next step: exercisesSystems of linear equations — exam-style exercises with the shake, a parameter that changes everything, the equations of a subspace and a 20-question quiz (and the row of zeros that scared me)

Did this article help you? Here is how you can support SergioLearns →