Linear algebra
Key takeaways
- A linear equation relates unknowns to constants through addition, subtraction and multiplication only, and a straight line can be written in general, slope-intercept, point-slope, intercept or two-point form.
- In slope-intercept form, y = mx + c, m is the slope and c is the y-intercept.
- A system of two linear equations in two unknowns is solved by substitution or elimination, and the answer is checked by substituting it back.
- Vectors are added, subtracted and multiplied by a scalar component by component.
- A unit vector has magnitude 1: divide a vector by its own magnitude and it keeps the same direction.
Linear algebra is the mathematical foundation most data science techniques are built on, from a simple trend line to the vector operations behind machine learning models.
A linear equation in one variable relates a single unknown to constants through addition, subtraction and multiplication only, e.g. 2x + 3 = 11. The equation of a line generalises this to two variables, describing every point that lies on a straight line.
Forms of a linear equation, each useful in a different situation:
Solving a linear equation in one variable means isolating the unknown through inverse operations, applied to both sides equally. Solving in two variables usually means a system of two linear equations in two unknowns, solved by substitution or elimination.
Solving a system of two linear equations
2x + y = 10
x - y = 2
Add the two equations to eliminate y
so x = 4
Substitute back, so y = 2
Check in the first equation
Vector operations, the building blocks of the multi-dimensional data structures most data science tools use internally:
Vector addition, subtraction, scalar multiplication and unit vector
a = (3, 4), b = (1, 2)
a + b = (3+1, 4+2) = (4, 6)
a - b = (3-1, 4-2) = (2, 2)
2a = (2×3, 2×4) = (6, 8)
Magnitude of a: |a| = √(3² + 4²) = √25 = 5
Unit vector of a: (3/5, 4/5) = (0.6, 0.8)
Exam tip
Practise converting between the linear-equation forms (slope-intercept, point-slope, two-point, intercept), a question often gives you information in one form and asks for the equation in another.