# Systems of Linear Equations

Computer Science I · Algebra · https://tryals.app/learn/computer-science-i/systems-of-linear-equations

## Many Equations at Once

A **linear equation** relates variables with addition and scalar multiples, like $2x + 3y = 6$. A **system** is several such equations that must hold simultaneously, foundational to computing, economics, and machine learning.

Geometrically, each equation is a **line**; a solution is a point lying on all lines at once. 

| Outcome | Geometry | Meaning |
| --- | --- | --- |
| **One solution** | Lines cross at a point | Consistent & independent |
| **No solution** | Lines are parallel | Inconsistent |
| **Infinite solutions** | Equations describe the same line | Dependent |

**Common pitfall:** Assuming every linear system has a unique solution. Parallel or duplicate equations create edge cases that change this entirely.

## Solving Systems

The systematic solving method is **Gaussian elimination**: use row operations to eliminate variables until the system is in triangular form, then **back-substitute**.

Allowed row operations:
- Scale a row by a non-zero constant
- Swap two rows
- Add a multiple of one row to another

The number of solutions connects to **independence**: a system with as many independent equations as unknowns has a unique solution. Fewer independent equations leave free variables for infinite solutions, while contradictions yield none.

## Practice questions

5 of this lesson's 10 practice questions, with answers. The full set is in the app.

### 1. Order the steps of solving 'x + y = 5, 2x + y = 8' by elimination.

**Answer:**

1. Subtract the first equation from the second to cancel y
2. This gives x = 3
3. Substitute x = 3 into x + y = 5
4. Solve to get y = 2

**Why:** Subtracting cancels y because both equations have +y: (2x+y)-(x+y) = x = 3. Then substitution recovers y = 2. Eliminate, then back-substitute.

Page: https://tryals.app/practice/computer-science-i/systems-of-linear-equations/order-the-steps-of-solving-x-y-5-2x-y-8-by-elimination

### 2. A system of two linear equations in two unknowns can have exactly two solutions.

**Answer:** False

**Why:** False. Two lines meet at one point, are parallel and never meet, or coincide and share infinitely many, there is no configuration giving exactly two. It generalises: a linear system always has one, none, or infinitely many solutions, which is a structural fact about linearity rather than about two dimensions.

Page: https://tryals.app/practice/computer-science-i/systems-of-linear-equations/a-system-of-two-linear-equations-in-two-unknowns-can-have-exactly-two

### 3. Sort each equation by whether it is linear in x and y.

**Answer:**

- Linear: 2x + 3y = 6, 5x - y = 0, x + 7 = 2y
- Not linear: x squared + y = 1, x times y = 4

**Why:** A linear equation uses only constant multiples of the variables and addition. Squaring a variable (e2) or multiplying two variables (e4) is nonlinear. e5 is linear even though it needs rearranging.

Page: https://tryals.app/practice/computer-science-i/systems-of-linear-equations/sort-each-equation-by-whether-it-is-linear-in-x-and-y

### 4. A neural network layer is a matrix multiply followed by a non-linear function. Why is the non-linearity essential rather than decorative?

A. Because a composition of linear maps is itself linear
B. Because matrix multiplication alone is too slow at scale
C. Because it makes the derivative computable for backpropagation
D. Because it keeps the values bounded, preventing numerical overflow

**Answer:** A. Because a composition of linear maps is itself linear

**Why:** AB is a matrix, so composing linear layers collapses to one, depth without non-linearity is a very expensive way to compute a single linear map. ReLU or similar breaks the collapse, and that is the whole reason deep networks can represent what shallow ones cannot.

Page: https://tryals.app/practice/computer-science-i/systems-of-linear-equations/a-neural-network-layer-is-a-matrix-multiply-followed-by-a-non-linear

### 5. The system 'x + y = 4, 2x + 2y = 8' has infinitely many solutions. Select every pair (x, y) that is a solution.

A. (0, 4)
B. (4, 0)
C. (1, 3)
D. (2, 3)
E. (-1, 5)

**Answer:** A. (0, 4); B. (4, 0); C. (1, 3); E. (-1, 5)

**Why:** The second equation is just twice the first, so every point with x + y = 4 solves the system. (0,4), (1,3), (4,0) and (-1,5) all sum to 4; (2,3) sums to 5 and fails.

Page: https://tryals.app/practice/computer-science-i/systems-of-linear-equations/the-system-x-y-4-2x-2y-8-has-infinitely-many-solutions
