- Introduction
- What is a linear equation?
- Solving one-variable equations
- Variables on both sides
- Special cases
- Slope and intercept
- Graphing a line
- Writing the equation of a line
- Parallel and perpendicular lines
- Systems of linear equations
- Real-world problems
- AI and machine learning
- Common mistakes
- Practice problems
- Conclusion
1. Introduction
Linear equations are among the most useful ideas in mathematics. They describe situations where one quantity changes at a steady rate: a taxi fare that grows with distance, a savings account that gains the same deposit each month, or a car travelling at constant speed. Whenever you can say "for every one more of this, there are always so many more of that," a linear equation is hiding in the sentence.
The word linear comes from line. Plot the solutions of a linear equation in two variables and you always get a straight line. This single fact connects algebra, which manipulates symbols, with geometry, which studies shapes, and it makes linear equations the natural next step after variables and expressions.
In this article we define linear equations, learn to solve them, interpret slope and intercept, graph lines, write equations from data, and solve systems of two equations. We finish with the role linear equations play in machine learning, where fitting a line to data is one of the oldest and still most widely used techniques.
2. What is a linear equation?
A linear equation is an equation in which every variable appears only to the first power and is never multiplied by another variable. So 3x + 2 = 11 and y = 2x + 1 are linear, while x² + 1 = 5, xy = 6 and y = √x are not. Unlike an expression, an equation contains an equals sign and states that two quantities are the same. Solving it means finding the values of the variable that make that statement true.
Linear equations come in several standard forms, and each is convenient for a different job.
| Name | Form | Best used for |
|---|---|---|
| One variable | ax + b = c | finding a single unknown |
| Slope-intercept | y = mx + b | graphing and reading slope |
| Standard | Ax + By = C | finding intercepts, systems |
| Point-slope | y − y₁ = m(x − x₁) | building a line from a point |
In one variable there is usually exactly one solution. In two variables there are infinitely many solutions, each an ordered pair (x, y), and together they form a line.
3. Solving one-variable equations
An equation is like a balance scale. If the two sides are equal and you do the same thing to both, they stay equal. That principle is the whole method: to isolate the variable, undo the operations applied to it, working in reverse order, using inverse operations. Addition is undone by subtraction, and multiplication is undone by division.
Take 3x + 2 = 11. The variable has been multiplied by 3 and then increased by 2, so we undo the addition first by subtracting 2 from both sides, giving 3x = 9. Then we divide both sides by 3 to get x = 3. Substituting back confirms it, since 3(3) + 2 = 11.
Fractions and brackets need one extra idea. For x/4 − 1 = 2, add 1 to get x/4 = 3, then multiply both sides by 4 to find x = 12. For 2(x − 3) = 10, you can either divide both sides by 2 first, giving x − 3 = 5 and x = 8, or distribute to get 2x − 6 = 10, then 2x = 16 and x = 8. Both routes agree. Whatever the route, finish with a check.
Equations with decimals work the same way. In 0.5x + 1.2 = 4.7, subtract 1.2 to get 0.5x = 3.5 and divide by 0.5 to find x = 7. If decimals feel awkward, multiply every term by 10 or 100 first to clear them, which turns the equation into one with whole numbers and does not change its solution.
4. Variables on both sides
When the variable appears on both sides, the goal is to gather all variable terms on one side and all constants on the other. Then it becomes an ordinary one-step-at-a-time problem. Consider 5x − 7 = 2x + 8.
| Step | Equation | What we did |
|---|---|---|
| 1 | 5x − 7 = 2x + 8 | start |
| 2 | 3x − 7 = 8 | subtract 2x from both sides |
| 3 | 3x = 15 | add 7 to both sides |
| 4 | x = 5 | divide both sides by 3 |
| Check | 5(5) − 7 = 18 = 2(5) + 8 | both sides equal 18 |
A handy habit is to move the smaller variable term so that the coefficient stays positive, but the answer is the same either way.
5. Special cases
Not every linear equation has exactly one solution. After simplifying, one of three things happens. If the variable survives, there is one solution. If the variable cancels and what remains is false, such as 3 = 5, no value works and there is no solution. If the variable cancels and what remains is always true, such as 2 = 2, every number works and there are infinitely many solutions.
| Equation | After simplifying | Result |
|---|---|---|
| 3x + 1 = 7 | x = 2 | one solution |
| 2x + 3 = 2x + 5 | 3 = 5 (false) | no solution |
| 2(x + 1) = 2x + 2 | 2 = 2 (true) | infinitely many solutions |
6. Slope and intercept
The slope-intercept form y = mx + b packs two facts into one line. The number m is the slope, which measures steepness: how much y changes for each one-unit step in x. The number b is the y-intercept, the height where the line crosses the y-axis, because setting x = 0 leaves y = b.
Slope is rise over run. Between two points (x₁, y₁) and (x₂, y₂) it equals m = (y₂ − y₁) / (x₂ − x₁). In the line y = 2x + 1, moving 2 units right raises the line by 4, so the slope is 4/2 = 2.
The sign of the slope tells you the direction of the line, and the special cases of zero and undefined slope are worth memorising.
| Slope | Direction | Example |
|---|---|---|
| positive | rises from left to right | y = 2x |
| negative | falls from left to right | y = −x + 3 |
| zero | horizontal | y = 4 |
| undefined | vertical | x = 3 |
Slope is also a rate of change, which is why it appears everywhere. A taxi that charges 1.5 dollars per kilometre has slope 1.5. A car travelling at 60 kilometres per hour has a distance-time graph with slope 60. A negative slope describes something shrinking, such as a phone battery that loses 5 percent of its charge every hour. Whenever you read a slope, attach units to it: dollars per kilometre, kilometres per hour, percent per hour.
7. Graphing a line
The most reliable way to graph a line is to build a table of values. Choose several values of x, substitute each into the equation to get y, and plot the pairs. Two points are enough to fix a straight line, but a third acts as a check. For y = −x + 3 the table below gives five points, and they all fall on one line.
| x | Calculation | y | Point |
|---|---|---|---|
| −1 | −(−1) + 3 | 4 | (−1, 4) |
| 0 | −(0) + 3 | 3 | (0, 3) |
| 1 | −(1) + 3 | 2 | (1, 2) |
| 2 | −(2) + 3 | 1 | (2, 1) |
| 3 | −(3) + 3 | 0 | (3, 0) |
A second method uses the intercepts. For 2x + 3y = 6, set x = 0 to get y = 2, and set y = 0 to get x = 3. Plot (0, 2) and (3, 0) and draw the line through them. A third method starts at the y-intercept and uses the slope: from (0, b), move right by the run and up by the rise.
8. Writing the equation of a line
Often you are given information about a line and must write its equation. If you know the slope m and one point (x₁, y₁), the point-slope form y − y₁ = m(x − x₁) gives the line directly. If you know two points, find the slope first and then use either point.
| Step | Work | Result |
|---|---|---|
| Slope | m = (7 − 3) / (3 − 1) | m = 2 |
| Intercept | 3 = 2(1) + b | b = 1 |
| Equation | substitute m and b | y = 2x + 1 |
| Check | 2(3) + 1 = 7 | the second point fits |
The equation y = 2x + 1 is the same line we graphed earlier. Notice the logic: slope comes from the difference between points, and the intercept comes from forcing the equation to pass through one of them.
Equations given in standard form can be converted. Starting from 2x + 3y = 6, subtract 2x from both sides to get 3y = −2x + 6, then divide everything by 3 to reach y = −(2/3)x + 2. Now the slope, −2/3, and the y-intercept, 2, can be read straight off. This agrees with the intercepts found earlier, since the line crosses the y-axis at 2.
9. Parallel and perpendicular lines
Two lines in a plane either cross, run side by side forever, or coincide. Lines with the same slope never meet, so they are parallel. Lines whose slopes multiply to −1 meet at a right angle and are perpendicular. The line y = 2x + 1 is parallel to y = 2x − 2, and perpendicular to any line with slope −1/2.
| Relationship | Rule | Example slopes |
|---|---|---|
| Parallel | m₁ = m₂ | 2 and 2 |
| Perpendicular | m₁ × m₂ = −1 | 2 and −1/2 |
Why do perpendicular slopes multiply to −1? Turn a line a quarter of a turn and its run and rise swap roles, with one of them changing sign. A line that rises 2 for every 1 across becomes a line that falls 1 for every 2 across, so the slope 2 becomes −1/2, and 2 × (−1/2) = −1. This rule is useful in geometry, for example when finding the shortest path from a point to a line.
10. Systems of linear equations
A system of linear equations is a set of two or more equations that must hold at the same time. For two variables, the solution is the pair (x, y) that satisfies both. Graphically it is the point where the two lines cross.
Substitution replaces one variable using the other equation. Here both equations give y, so set them equal: 2x − 1 = −x + 5. Then 3x = 6, so x = 2, and y = 2(2) − 1 = 3. Elimination adds or subtracts the equations to cancel a variable. For x + y = 7 and x − y = 1, adding gives 2x = 8, so x = 4, and then y = 3.
Sometimes the coefficients do not line up, and you must scale one equation first. For 2x + 3y = 12 and x − y = 1, multiply the second equation by 3 to get 3x − 3y = 3. Adding it to the first cancels y and gives 5x = 15, so x = 3. Then 3 − y = 1 gives y = 2. Check both: 2(3) + 3(2) = 12 and 3 − 2 = 1.
| Method | Idea | Handy when |
|---|---|---|
| Graphing | draw both lines, find the crossing | you want a picture |
| Substitution | replace one variable with an expression | one equation is already solved for a variable |
| Elimination | add or subtract to cancel a variable | coefficients line up or are easy to match |
As with single equations, a system can have one solution, none or infinitely many, depending on whether the lines cross, are parallel or are the same line.
11. Real-world problems
Linear equations model any situation with a fixed starting amount plus a constant rate. Suppose Plan A costs 10 dollars plus 2 dollars per gigabyte, so C = 10 + 2g, and Plan B costs 20 dollars plus 1 dollar per gigabyte, so C = 20 + g. Which is cheaper? Setting the costs equal gives 10 + 2g = 20 + g, so g = 10. At 10 gigabytes both cost 30 dollars. Below that Plan A wins, and above it Plan B wins.
| Data g (GB) | Plan A: 10 + 2g | Plan B: 20 + g | Cheaper |
|---|---|---|---|
| 0 | 10 | 20 | A |
| 5 | 20 | 25 | A |
| 10 | 30 | 30 | equal |
| 15 | 40 | 35 | B |
| 20 | 50 | 40 | B |
The break-even point is simply the solution of a system. Questions about when two options cost the same, when two moving objects meet, or when a business covers its costs all reduce to solving a linear system.
12. AI and machine learning
Linear equations sit at the foundation of machine learning. The simplest model, linear regression, predicts a target with ŷ = wx + b. This is exactly y = mx + b with new names: the slope is called the weight w, and the intercept is called the bias b. Training means choosing w and b so that the line passes as close as possible to the data, usually by making the sum of squared vertical errors small.
Where do the best values of w and b come from? With exactly two points there is exactly one line through them, and finding it means solving a system of two linear equations. With many noisy points no single line passes through all of them, so training searches for the line with the smallest total error. Either way the model is the same simple equation, and only the method of choosing its two numbers changes.
With several inputs the same idea becomes ŷ = w₁x₁ + w₂x₂ + … + b. Each layer of a neural network begins with a linear step z = Wx + b. A linear classifier separates two classes with the boundary w₁x₁ + w₂x₂ + b = 0, which is a straight line in two dimensions. Fitting these models also relies on solving linear systems, which is why efficient algorithms for them are so important.
Linear steps alone are limited. Stacking linear layers without anything else still gives one linear function, so neural networks insert non-linear activation functions between them. But every one of those layers still starts with the linear equation you have just studied.
| Algebra | Machine learning |
|---|---|
| slope m | weight w |
| y-intercept b | bias b |
| x | feature (input) |
| y | target or label (output) |
| the line | the model |
| finding m and b from points | training or fitting |
13. Common mistakes
| Mistake | Wrong | Right |
|---|---|---|
| Changing only one side | 3x + 2 = 11 → 3x = 11 | 3x = 9 |
| Sign error when moving a term | 3x − 5 = 10 → 3x = 5 | 3x = 15 |
| Not distributing to every term | 2(x + 3) = 2x + 3 | 2x + 6 |
| Inverting the slope | m = run / rise | m = rise / run |
| Confusing zero and undefined slope | vertical line has slope 0 | vertical is undefined; horizontal is 0 |
| Skipping the check | trusting the answer | substitute it back |
14. Practice problems
Try these before looking at the answers.
- Solve 4x − 9 = 15.
- Solve 3(x + 2) = 21.
- Solve 5x − 3 = 2x + 12.
- Find the slope of the line through (2, 1) and (6, 9).
- Write the equation of the line with slope −3 and y-intercept 4.
- Solve the system x + y = 10 and x − y = 2.
- Are y = 3x + 1 and y = 3x − 5 parallel, crossing or the same line?
Answers.
- 4x = 24, so x = 6.
- x + 2 = 7, so x = 5.
- 3x = 15, so x = 5.
- (9 − 1) / (6 − 2) = 2.
- y = −3x + 4.
- Adding gives 2x = 12, so x = 6 and y = 4.
- Same slope 3 but different intercepts, so they are parallel and the system has no solution.
15. Conclusion
A linear equation says that two quantities stay in step: change one by a fixed amount and the other changes by a fixed multiple of it. That simple idea has a dependable solving method, the balance principle, and a clean geometric picture, a straight line described by a slope and an intercept.
Once you can solve one equation, graph a line, write an equation from two points and handle a system of two equations, you are ready for quadratic equations, functions and the models used throughout data science. Practise with a check after every solution, and the habit will serve you in every later topic.