Letters for numbers
Why this matters
A letter in math stands for a number you don't know yet, or for any number at all. With letters, a rule is said once and works for every number: area = length × width covers every rectangle. This lesson shows how to read and tidy expressions, and how to work one out by putting numbers in. Python does the same with a function. And a machine learning model is, at heart, an expression whose letters get tuned.
- Read an expression: its variables, terms and coefficients, and how 3x means 3 × x
- Combine like terms, and put numbers in for letters to work an expression out
- Write a formula as a Python function with def and return, and call it with inputs
- Read a model's formula, ŷ = w·x + b, and write it as a predict function
The math: letters that stand for numbers
Purpose. Say a rule once, for every number it could apply to.
A variable is a letter that stands for a number: x, n, or any other. An expression is numbers, letters and operations with no equals sign, like 2x + 7. It isn't a question; it's a recipe for a number, once you know x.
Two habits of writing:
- A number right before a letter multiplies it: 3x means 3 × x. The number is the coefficient.
- x² means x × x, just as 4² meant 4 × 4.
The parts joined by + or − are terms. 2x² + 3x − 1 has three terms: 2x², 3x and −1. The last one, with no letter, is a constant: it never changes.