Mathematics is a small set of ideas that build on each other. This post goes in order. Part 1 covers the basics that everything else rests on. Part 2 covers the topics usually called advanced: functions, logarithms, trigonometry, calculus, vectors and matrices, probability and counting.
Each topic has the same shape: the idea in a sentence or two, something to look at or try, and the mistake people most often make. The pictures and the "Try it" boxes work with the keyboard as well as the mouse.
To read this post in a handwritten style, use the Reading font switch above the article. Code, formulas in the boxes and the interactive parts keep their normal font.
Part 1: The basics
1. Numbers
Numbers come in layers. Each layer contains the one before it and adds something.
Two ideas to keep from this:
- Negative numbers are on the other side of zero. Subtracting a negative is the same as adding: 5 − (−3) = 8. Think of removing a debt of 3.
- Absolute value is the distance from zero, so |−4| = 4 and |4| = 4.
2. Fractions
A fraction is parts of a whole. The bottom number says how many equal parts there are, and the top number says how many you have.
Try it: fractions
A fraction is parts of a whole. The bottom number says how many equal parts, the top says how many you have.
Make the bottoms equal. The smallest common bottom is 6. 1/2 = 3/6 and 1/3 = 2/6. Now add the tops: 3 + 2 = 5, so 5/6.
result, simplified
5/6
as a decimal
0.8333
The three rules:
- Add or subtract: make the bottoms equal first, then add or subtract the tops.
- Multiply: top times top, bottom times bottom.
- Divide: flip the second fraction and multiply.
The usual mistake: adding tops and bottoms. 1/2 + 1/3 is 5/6, not 2/5.
Check yourself
What is 1/2 + 1/3?
3. Percentages
Percent means per hundred, so 25% is 25/100, or 0.25. To find a percentage of a number, multiply by that decimal: 25% of 80 is 0.25 × 80 = 20. You use this for discounts, tax, tips and interest.
Try it: percentages
Percent means per hundred, so 25% is 25/100 = 0.25.
- 25% of 80 = 20
- 80 increased by 25% = 100
- 80 decreased by 25% = 60
The common trap: to get from 100 back to 80 you must decrease by 20%, not 25%. Increase by 25% and then decrease by 25% and you end at 75, not 80.
A quick trick: 10% is the number with the decimal point moved one place, and 5% is half of that. So a 15% tip on 40 is 4 + 2 = 6.
The usual mistake: treating an increase and a decrease of the same percentage as cancelling out. They do not, because the second percentage is taken of a different number.
4. Ratios and proportion
A ratio compares amounts. A ratio of 3:2 means for every 3 of one thing there are 2 of another. A proportion says two ratios are equal, which lets you scale.
If 3 pens cost 12, one pen costs 12 ÷ 3 = 4, so 5 pens cost 5 × 4 = 20. A recipe that uses 2 cups of flour for 4 people needs 2 × 6/4 = 3 cups for 6 people.
Check yourself
3 pens cost 12. How much do 5 pens cost?
5. Order of operations
When an expression has several operations, the order decides the answer. Work in this order: brackets, powers, multiplication and division (left to right), then addition and subtraction (left to right). You may see it called BODMAS or PEMDAS. It is the same rule.
Try it: order of operations
Work in this order: brackets, powers, multiply and divide (left to right), add and subtract (left to right). Pick an expression and step through it.
3 + 4 × 2
Multiplication comes before addition, so do 4 × 2 first.
The usual mistake: thinking multiplication always beats division. They have equal rank, so you go left to right.
6. Exponents and roots
An exponent says how many times to multiply a number by itself: 2³ = 2 × 2 × 2 = 8. A root undoes it: √9 = 3 because 3² = 9.
| Rule | Example |
|---|---|
| Same base, multiply: add the exponents | 2³ × 2² = 2⁵ = 32 |
| Power of a power: multiply the exponents | (2³)² = 2⁶ = 64 |
| Anything to the power 0 is 1 | 7⁰ = 1 |
| A negative exponent is a reciprocal | 2⁻¹ = 1/2 |
Powers of 2 show up everywhere in computing: 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024 are 2¹ to 2¹⁰.
The usual mistake: −3² is −9, because the power is done first and the minus is applied after. (−3)² is 9.
7. Algebra
Algebra uses letters for unknown numbers. An equation is a balance: whatever you do to one side, you must do to the other.
Solve 3x + 5 = 20:
- Subtract 5 from both sides: 3x = 15.
- Divide both sides by 3: x = 5.
- Check: 3 × 5 + 5 = 20.
To multiply out brackets, multiply every term in one by every term in the other: (x + 2)(x + 3) = x² + 3x + 2x + 6 = x² + 5x + 6.
The usual mistake: changing only one side of the equation.
8. Geometry
| Shape | Area | Around the edge |
|---|---|---|
| Rectangle | length × width | 2 × (length + width) |
| Triangle | ½ × base × height | add the three sides |
| Circle | π × r² | 2 × π × r |
π is about 3.14159. A circle with radius 5 has area 25π ≈ 78.54 and circumference 10π ≈ 31.42.
The most useful fact in basic geometry is Pythagoras. In a right-angled triangle, the square on the longest side equals the sum of the squares on the other two.
A 5 m ladder with its foot 3 m from a wall reaches 4 m up, because 3² + 4² = 5².
The usual mistake: using the diameter where a formula wants the radius. The radius is half the diameter.
9. Averages
- Mean: add everything and divide by how many there are.
- Median: the middle value when the numbers are in order.
- Mode: the value that appears most often.
Take the salaries 20, 22, 23, 25 and 200 (in thousands). The mean is 290 ÷ 5 = 58. The median is 23. One very large value drags the mean up but barely moves the median.
Check yourself
Most salaries in a company are similar, but one person earns far more. Which average best describes a typical salary?
Part 2: Advanced topics
10. Functions and graphs
A function takes an input x and gives one output y. A graph plots every pair. Two shapes cover most of school and everyday work:
- A line, y = mx + b. The slope m is how much y changes for each step in x. The number b is where the line crosses the y axis.
- A parabola, y = ax² + bx + c. It has a turning point and opens upward when a is positive.
Try it: graphs
A function turns an input x into an output y. The graph shows every pair. Move the sliders and watch the shape change.
y = x + 2
Slope 1: for every 1 step right, the line goes up 1. It crosses the y axis at 2 and the x axis at -2.
11. Logarithms
A logarithm answers the question "what power gives this number?". Since 2³ = 8, log₂(8) = 3. Since 10³ = 1000, log₁₀(1000) = 3. It is the undo button for exponents.
The rule that makes logarithms useful: they turn multiplying into adding. log₂(8 × 4) = log₂(32) = 5, which is 3 + 2.
Logarithms count how many times you can double or halve. Binary search on 1,000,000 sorted items needs about 20 steps, because log₂(1,000,000) is just under 20. Doubling the number of items adds just one more step.
The usual mistake: log(a + b) is not log(a) + log(b). Only multiplication turns into addition.
Check yourself
What is log₂(64)?
12. Trigonometry
For a right-angled triangle, with an angle marked, the three ratios are:
- sine = opposite ÷ hypotenuse
- cosine = adjacent ÷ hypotenuse
- tangent = opposite ÷ adjacent
The unit circle shows them as positions. Walk around a circle of radius 1 and the point's horizontal position is cos, and its vertical position is sin.
Try it: sine and cosine on the unit circle
Walk a point around a circle of radius 1. Its horizontal position is the cosine of the angle and its vertical position is the sine.
- angle = 40° = 0.698 radians
- cos = 0.766 (horizontal) sin = 0.643 (vertical)
- tan = sin / cos = 0.839
Angles are measured in degrees or radians. A half turn is 180° or π radians. Programming languages, including JavaScript and Java, expect radians in Math.sin and Math.cos.
The usual mistake: feeding degrees to a function that expects radians.
13. Calculus
Calculus has two halves.
The derivative is the rate of change: the slope of a curve at one point. If position is a function of time, its derivative is speed.
Try it: the derivative as a slope
The derivative is the slope of a curve at one point. Take two points on y = x², draw the line through them, and move the second point closer. The slope settles on one number.
- slope of the secant line = (f(2) − f(1)) / 1 = 3
- true slope at x = 1, from the rule d/dx x² = 2x: 2
The secant slope is always 2x + h. As h shrinks to 0, it becomes 2x. That limit is the derivative.
A few rules cover most cases:
| Function | Derivative |
|---|---|
| a constant, such as 7 | 0 |
| 5x | 5 |
| x² | 2x |
| x³ | 3x² |
| sin x | cos x |
The pattern for powers is to bring the exponent down and subtract 1 from it.
The integral is the area under a curve. If speed is a function of time, its integral is distance. Driving at a steady 60 km/h for 2 hours gives a rectangle of area 120, which is 120 km.
Try it: the integral as area
The integral is the area under a curve. Estimate it with thin rectangles. More rectangles mean a better estimate.
- sum of 3 rectangles = 5
- exact area under y = x² from 0 to 3 = 9 (the antiderivative x³/3 gives 27/3)
The two halves undo each other: the derivative of the area function gives back the original curve. That is why the exact area under x² from 0 to 3 is found with x³/3, which gives 27/3 = 9.
Check yourself
What is the derivative of x³?
14. Vectors and matrices
A vector is a list of numbers that you can picture as an arrow, with a length and a direction. Add vectors by adding their parts.
The length of (3, 4) is 5, by Pythagoras. The dot product multiplies matching parts and adds them: (3, 1) · (1, 2) = 3 × 1 + 1 × 2 = 5.
A matrix is a grid of numbers. A 2 × 2 matrix transforms every point on a plane: it can rotate, stretch, shear or mirror a shape. Try it.
Try it: a matrix moves every point
A 2 × 2 matrix turns each point (x, y) into a new point: x′ = a·x + b·y and y′ = c·x + d·y. Pick one, or type your own numbers, and watch the letter F move.
Determinant a·d − b·c = 1. Areas are multiplied by 1.
The determinant says how much areas are scaled. A determinant of 0 means the shape is flattened and cannot be recovered.
This is the maths behind 2D and 3D graphics, and machine learning stores its data as vectors and matrices.
The usual mistake: assuming the order of multiplication does not matter. It does. With A = [[1, 1], [0, 1]] and B = [[1, 0], [1, 1]], the product AB is [[2, 1], [1, 1]] but BA is [[1, 1], [1, 2]].
15. Probability and statistics
Probability is a number from 0 to 1: favourable outcomes divided by all outcomes. A fair coin gives heads with probability 1/2. Independent events multiply: two heads in a row is 1/2 × 1/2 = 1/4.
Try it: flip a fair coin
Probability is favourable outcomes divided by all outcomes: 1 head out of 2 sides is 1/2. A short run can be far off. A long run settles near 1/2.
heads 0 of 0 flips = 0 (dashed line: 0.5)
The expected value is the average result over many tries. For a fair die it is (1 + 2 + 3 + 4 + 5 + 6) ÷ 6 = 3.5, a value you can never roll but which the average approaches.
The standard deviation measures how spread out values are around the mean. For data shaped like a bell curve, about 68% of values fall within one standard deviation of the mean and about 95% within two.
Probability often surprises people. Try the classic example.
Try it: the birthday problem
How likely is it that two people in a group share a birthday? It is easier to find the chance that nobody does (multiply 365/365 × 364/365 × 363/365 ...) and subtract from 1.
Chance of a shared birthday: 50.7%
With only 23 people it already passes 50%, which surprises most people.
The usual mistake: thinking a streak changes the next outcome. A fair coin that has landed heads five times still lands heads with probability 1/2 next time.
Check yourself
A fair coin has landed heads 5 times in a row. What is the probability of heads on the next flip?
16. Counting
Counting methods tell you how many arrangements exist without listing them. If a task has several independent steps, multiply the number of choices: a 4-digit PIN has 10 × 10 × 10 × 10 = 10,000 possibilities.
For picking k things out of n, the question is whether order matters:
- Permutations (order matters, like gold, silver and bronze): n! ÷ (n − k)!
- Combinations (order does not matter, like a team): n! ÷ (k! × (n − k)!)
Here n! means n × (n − 1) × ... × 1, so 5! = 120.
Try it: counting arrangements
Pick k things from n. If the order matters (gold, silver, bronze) it is a permutation. If it does not (a team) it is a combination.
order matters: n! / (n − k)!
720
order does not matter: n! / (k! (n − k)!)
120
Choosing a team of 3 from 10 people has 120 combinations. Giving out three ranked prizes among the same 10 has 720 permutations. The same idea explains passwords: 8 characters from the 62 letters and digits give 62⁸, about 2.2 × 10¹⁴ possibilities.
The mistakes in one table
| Mistake | What is true |
|---|---|
| 1/2 + 1/3 = 2/5 | It is 5/6: make the bottoms equal first |
| +20% then −20% returns to the start | It ends lower, at 96% of the start |
| −3² = 9 | It is −9. Only (−3)² is 9 |
| log(a + b) = log a + log b | Only log(a × b) = log a + log b |
| AB = BA for matrices | Order matters |
| After five heads, tails is due | Each flip is independent |
| Degrees into a radians function | Convert: radians = degrees × π ÷ 180 |
| The mean always shows the typical value | Outliers move it. Check the median too |
Where to go next
| If you want | Look at |
|---|---|
| Logic, proofs and algorithms | Discrete mathematics |
| More on matrices | Linear algebra: eigenvalues, solving systems |
| Calculus with several variables | Multivariable calculus |
| Drawing conclusions from data | Statistics: sampling, confidence, hypothesis tests |
Sources and further reading
- Khan Academy, free courses from arithmetic through calculus and statistics.
- 3Blue1Brown, the video series "Essence of calculus" and "Essence of linear algebra": the best visual introductions to those two topics.
- Gilbert Strang, Introduction to Linear Algebra.
- James Stewart, Calculus, a standard textbook.
- Graham, Knuth and Patashnik, Concrete Mathematics, for counting and discrete mathematics.
- George Pólya, How to Solve It (1945), on how to approach a problem you cannot see through yet.
