Appearance
3.5 — Trigonometry
Ancient astronomers had a practical problem. They could measure angles — the elevation of a star above the horizon, the angle between two landmarks — with an instrument. They could not measure distances to things they could not walk to. They needed a bridge from angles to lengths.
Chapter 3.2 supplied the principle: similar triangles have proportional sides, so the ratio of two sides depends only on the angles. Trigonometry is what you get when you tabulate those ratios once and for all, give them names, and then use them forever.
Trigonometry carries more formulas than any other topic in this book, and that is intimidating until you notice that essentially all of them come from two facts. The first is Pythagoras, from Chapter 3.2. The second is that on a circle of radius 1, every point is at distance 1 from the centre — which is the same fact wearing a different hat, since the coordinates of that point are the two shorter sides of a right triangle whose hypotenuse is the radius. Every identity derived in this chapter is one of those two statements rearranged, and if you ever forget one you can rebuild it from the circle in about thirty seconds.
The word is Greek — trigonon (triangle) and metron (measure). It is the measurement of triangles, and it grew into the mathematics of everything that repeats.
1. The three ratios
Take a right-angled triangle and pick one of the non-right angles, call it \theta. The three sides now have roles:
- The hypotenuse is opposite the right angle, always the longest.
- The opposite side is across from \theta.
- The adjacent side is next to \theta and is not the hypotenuse.
Define:
\sin\theta = \frac{\text{opposite}}{\text{hypotenuse}}, \qquad \cos\theta = \frac{\text{adjacent}}{\text{hypotenuse}}, \qquad \tan\theta = \frac{\text{opposite}}{\text{adjacent}}
The school mnemonic is SOH-CAH-TOA, and it is fine as far as it goes. What matters more is why these are well-defined at all: because all right triangles with angle \theta are similar (Chapter 3.2), the ratio is the same whatever the triangle's size. The functions depend on the angle alone.
Three more names exist for the reciprocals, and you will meet them in calculus and engineering:
\csc\theta = \frac{1}{\sin\theta}, \qquad \sec\theta = \frac{1}{\cos\theta}, \qquad \cot\theta = \frac{1}{\tan\theta}
Note the mismatch that trips people up: secant is the reciprocal of cosine, not sine.
Also, immediately from the definitions:
\tan\theta = \frac{\text{opp}}{\text{adj}} = \frac{\text{opp}/\text{hyp}}{\text{adj}/\text{hyp}} = \frac{\sin\theta}{\cos\theta}
Where the names come from. Sine is a translation accident worth knowing. The Sanskrit jyā-ardha ("half-chord") was shortened to jyā, transliterated into Arabic as jiba, written without vowels as jb, and then misread by Latin translators as jaib, meaning a bay or fold — which they rendered as sinus, Latin for a bay or the fold of a garment. The English word "sine" therefore means "bay", by a chain of mistakes. Cosine is the "sine of the complement", since \cos\theta = \sin(90° - \theta). Tangent is from the Latin for "touching", after the tangent line of Chapter 3.3.
2. The unit circle: the definition that actually generalises
The triangle definition has a problem. It only works for angles between 0° and 90°, since a right triangle cannot contain a larger one. Yet we need \sin(135°) and \cos(200°) to describe rotation.
The fix is to redefine everything on a circle of radius 1 centred at the origin. Start at the point (1,0) and rotate anticlockwise by \theta. You land somewhere on the circle. Then:
\cos\theta = \text{the } x\text{-coordinate}, \qquad \sin\theta = \text{the } y\text{-coordinate}
That is the definition. For angles under 90° it agrees exactly with the triangle version, because the radius is 1 and the hypotenuse is therefore 1, so "opposite over hypotenuse" is just the height. For every other angle it keeps working, including negative angles (rotate clockwise) and angles beyond 360° (go round again).
Four consequences follow immediately and they are all things people otherwise memorise.
The Pythagorean identity. The point (\cos\theta, \sin\theta) is on a circle of radius 1, so by the circle equation of Chapter 3.4:
\cos^2\theta + \sin^2\theta = 1
This is Pythagoras' theorem in disguise, and it is the most-used identity in mathematics. The notation \sin^2\theta means (\sin\theta)^2, an unfortunate convention that has confused generations.
Signs by quadrant. Since the coordinates change sign as you go round, so do the functions. In the first quadrant both are positive; in the second, x is negative so cosine is negative; in the third both are negative; in the fourth, y is negative so sine is negative. The mnemonic "All Students Take Calculus" names which function is positive in each quadrant, but reading it off the circle takes less effort than remembering the mnemonic.
Periodicity. Going round 360° (2\pi radians) returns you to the same point:
\sin(\theta + 2\pi) = \sin\theta, \qquad \cos(\theta + 2\pi) = \cos\theta
Symmetry. Reflecting the circle vertically shows \cos(-\theta) = \cos\theta (cosine is even) and \sin(-\theta) = -\sin\theta (sine is odd).
The exact values worth knowing
Two triangles give every exact value, and both come from Chapter 3.2's geometry rather than a table.
The 45-45-90 triangle: half a square, cut along the diagonal. Legs 1 and 1, hypotenuse \sqrt2. So \sin 45° = \cos 45° = \frac{1}{\sqrt2} = \frac{\sqrt2}{2} and \tan 45° = 1.
The 30-60-90 triangle: half an equilateral triangle of side 2, cut down the middle. The short side is 1, the hypotenuse is 2, and the third side is \sqrt{4-1} = \sqrt3. So \sin 30° = \frac{1}{2}, \cos 30° = \frac{\sqrt3}{2}, \sin 60° = \frac{\sqrt3}{2}, \cos 60° = \frac{1}{2}.
\begin{array}{c|ccccc} \theta & 0° & 30° & 45° & 60° & 90° \\ \hline \sin & 0 & \frac{1}{2} & \frac{\sqrt2}{2} & \frac{\sqrt3}{2} & 1 \\[2pt] \cos & 1 & \frac{\sqrt3}{2} & \frac{\sqrt2}{2} & \frac{1}{2} & 0 \end{array}
A memory aid: write \sin as \frac{\sqrt0}{2}, \frac{\sqrt1}{2}, \frac{\sqrt2}{2}, \frac{\sqrt3}{2}, \frac{\sqrt4}{2} and the pattern is obvious. Cosine is the same list backwards, which is the complement relationship.
Rather than take the last four claims on trust, drag the angle round the circle yourself and watch the numbers change.
θ = 0.524 rad = 30°cos θ = 0.866sin θ = 0.5tan θ = 0.577sin²+cos² = 1
Three things are worth doing before you move on. Put the angle at 30° and read sin θ = 0.5 exactly. Push it towards 90° and watch tan θ pass 10, then 50, then vanish upwards. And take it all the way round past 360°, where every value repeats — the periodicity that section 6 turns into waves.
3. Solving triangles that are not right-angled
Real triangles rarely have a right angle. Two rules handle every case, and both are proved by dropping a perpendicular to make right triangles.
The sine rule:
\frac{a}{\sin A} = \frac{b}{\sin B} = \frac{c}{\sin C}
with each side lettered to match the angle opposite it. Use it when you know two angles and a side (AAS/ASA), or two sides and a non-included angle (SSA — the ambiguous case of Chapter 3.2, where you may get two valid triangles and must check both).
The cosine rule:
c^2 = a^2 + b^2 - 2ab\cos C
Use it when you know three sides (SSS, solving for an angle) or two sides and the angle between them (SAS).
The cosine rule is Pythagoras with a correction term. If C = 90° then \cos C = 0 and the last term vanishes, leaving c^2 = a^2 + b^2 exactly. The -2ab\cos C measures how far from a right angle you are: for an acute C the cosine is positive and c comes out shorter than Pythagoras would give; for an obtuse C it is negative and c comes out longer.
Worked example. Two roads leave a junction at 67° to each other. You walk 3 km along one and 5 km along the other. How far apart are the endpoints?
d^2 = 3^2 + 5^2 - 2(3)(5)\cos 67° = 9 + 25 - 30(0.3907) = 34 - 11.72 = 22.28
d = 4.72\ \text{km}
Area from two sides and the included angle:
\text{Area} = \tfrac{1}{2}ab\sin C
Because the perpendicular height from one side is b\sin C, and area is half base times height.
4. Inverse functions, and their catch
To go from a ratio back to an angle you need the inverse: \arcsin, \arccos, \arctan (written \sin^{-1} and so on, which is a genuinely bad notation because it looks like a reciprocal and is not).
\sin 30° = 0.5 \quad\Longleftrightarrow\quad \arcsin(0.5) = 30°
The catch: sine takes infinitely many angles to the same value, so the inverse must choose one. By convention \arcsin returns an angle between -90° and 90°, and \arccos between 0° and 180°.
This causes a real problem in programming. Math.atan(y/x) cannot tell the difference between the direction (1,1) and the direction (-1,-1), because the ratio is 1 in both cases. Every language therefore provides atan2(y, x), which takes the two coordinates separately, looks at their signs, and returns the correct angle in the full range. If you are computing a heading or a bearing, use atan2. Using atan is a bug that shows up only when the object moves into the wrong quadrant.
5. The identities you actually use
The Pythagorean identity and its two relatives, obtained by dividing it by \cos^2 or \sin^2:
\sin^2\theta + \cos^2\theta = 1, \qquad 1 + \tan^2\theta = \sec^2\theta, \qquad 1 + \cot^2\theta = \csc^2\theta
The angle addition formulas, the most useful in the subject:
\sin(A+B) = \sin A\cos B + \cos A\sin B
\cos(A+B) = \cos A\cos B - \sin A\sin B
The minus sign in the cosine formula is the detail everyone gets wrong. A memory hook: at A = B = 45°, the left side is \cos 90° = 0, and the right side is \frac{1}{2} - \frac{1}{2} = 0. With a plus it would be 1, which is wrong.
Where they come from, in one line. Chapter 2.5 showed that multiplying complex numbers adds their angles, and Euler's formula says e^{i\theta} = \cos\theta + i\sin\theta. So:
e^{i(A+B)} = e^{iA}e^{iB} = (\cos A + i\sin A)(\cos B + i\sin B)
Expand the right side and separate real from imaginary parts:
= (\cos A\cos B - \sin A \sin B) + i(\sin A\cos B + \cos A \sin B)
Matching real parts gives the cosine formula, matching imaginary parts gives the sine formula. Both identities in one multiplication, and the minus sign appears exactly where i \times i = -1 put it. This is the clearest example in the book of why complex numbers are worth having: they turn a pair of memorised formulas into a consequence of one exponent law.
Double angle, from setting B = A:
\sin 2A = 2\sin A\cos A, \qquad \cos 2A = \cos^2 A - \sin^2 A = 1 - 2\sin^2 A
The last rearrangement gives the half-angle formulas needed for integration in Chapter 5.6.
6. From circles to waves
Plot y = \sin\theta against \theta and you get the shape that describes almost everything periodic in nature.

The general wave is
y = A\sin(\omega t + \phi)
and each letter has a physical meaning:
- A is the amplitude — how far it swings. In sound, loudness. In electricity, peak voltage.
- \omega is the angular frequency — how fast the rotation goes, in radians per second. Related to ordinary frequency f (cycles per second, hertz) by \omega = 2\pi f, since one cycle is 2\pi radians.
- \phi is the phase — where in the cycle it starts. Two waves with the same shape but different phase are shifted in time relative to each other.
- The period is T = \frac{1}{f} = \frac{2\pi}{\omega} — the time for one full cycle.
Cosine is sine with a phase shift of 90°: \cos\theta = \sin(\theta + \frac{\pi}{2}). They are the same wave, started at a different moment.

Why this shape and not another. Chapter 6.2 gives the real answer: sine is the solution of the equation "acceleration is proportional to displacement, in the opposite direction", which is what any restoring force produces. Anything pulled back towards a resting position — a spring, a pendulum, air pressure in a sound wave, charge in a circuit, an atom in a crystal lattice — obeys that equation, and therefore all of them oscillate sinusoidally. It is not that nature likes sine waves; it is that a linear restoring force forces one.
And then the astonishing generalisation. Fourier's theorem, in Chapter 9.2, says that any repeating signal — a square wave, a violin note, your voice, a stock chart — is a sum of sine waves of different frequencies. That single result underlies audio compression, image compression, radio, mobile networks, medical imaging and noise cancellation.
Every formula above, built from scratch
None of the results in this chapter are worth memorising, because each one can be rebuilt in under a minute from something simpler. What follows is that rebuilding, one result at a time, so the formula and the reason for it sit on the same page as the explanation that needed them.
Trigonometry: the definitions and what follows immediately
\sin\theta = \frac{\text{opposite}}{\text{hypotenuse}}, \qquad \cos\theta = \frac{\text{adjacent}}{\text{hypotenuse}}, \qquad \tan\theta = \frac{\text{opposite}}{\text{adjacent}} = \frac{\sin\theta}{\cos\theta}
\csc\theta = \frac1{\sin\theta}, \qquad \sec\theta = \frac1{\cos\theta}, \qquad \cot\theta = \frac1{\tan\theta} = \frac{\cos\theta}{\sin\theta}
The definition that survives beyond right angles, and the one everything below uses, is the circle version: rotate anticlockwise from (1,0) by \theta on a circle of radius 1, and the point you land on is (\cos\theta, \sin\theta).
θ = 0.524 rad = 30°cos θ = 0.866sin θ = 0.5tan θ = 0.577sin²+cos² = 1
The Pythagorean identities
\sin^2\theta + \cos^2\theta = 1
Where it comes from. The point (\cos\theta,\sin\theta) lies on a circle of radius 1 centred at the origin, and the equation of that circle is x^2+y^2=1. Substitute. That is all: it is Pythagoras applied to the triangle with legs \cos\theta and \sin\theta and hypotenuse 1.
The other two come free. Divide the whole identity by \cos^2\theta:
\frac{\sin^2\theta}{\cos^2\theta} + 1 = \frac{1}{\cos^2\theta} \quad \Rightarrow \quad \tan^2\theta + 1 = \sec^2\theta
Divide instead by \sin^2\theta:
1 + \cot^2\theta = \csc^2\theta
Three identities, one circle, two divisions. Nothing here is worth memorising separately.
Symmetry: odd, even, and the shifts
\sin(-\theta) = -\sin\theta \quad\text{(odd)}, \qquad \cos(-\theta) = \cos\theta \quad\text{(even)}, \qquad \tan(-\theta) = -\tan\theta
Why. Rotating by -\theta instead of \theta reflects the point in the horizontal axis. Reflection flips the y-coordinate and leaves x alone, and those coordinates are \sin and \cos.
\sin(90° - \theta) = \cos\theta, \qquad \cos(90°-\theta) = \sin\theta, \qquad \tan(90°-\theta) = \cot\theta
Why. In a right triangle the two non-right angles add to 90°, so what is "opposite" for one is "adjacent" for the other. The prefix co- in cosine, cotangent and cosecant means exactly this: the function of the complementary angle.
\sin(\theta + 360°) = \sin\theta, \qquad \sin(\theta+180°) = -\sin\theta, \qquad \cos(\theta+180°) = -\cos\theta
A full turn returns you to the same point; a half turn sends the point to its opposite through the origin, flipping both coordinates.
The exact values, and why they are exact
| \theta | 0 | 30° = \frac\pi6 | 45°=\frac\pi4 | 60°=\frac\pi3 | 90°=\frac\pi2 |
|---|---|---|---|---|---|
| \sin | 0 | \frac12 | \frac{\sqrt2}2 | \frac{\sqrt3}2 | 1 |
| \cos | 1 | \frac{\sqrt3}2 | \frac{\sqrt2}2 | \frac12 | 0 |
| \tan | 0 | \frac{1}{\sqrt3} | 1 | \sqrt3 | undefined |
The 45° values come from a right triangle with two equal legs of length 1. Its hypotenuse is \sqrt{1^2+1^2} = \sqrt2, so both the sine and the cosine are \frac{1}{\sqrt2} = \frac{\sqrt2}{2}.
The 30° and 60° values come from cutting an equilateral triangle of side 2 in half. The half has hypotenuse 2, short side 1, and by Pythagoras a long side of \sqrt{4-1} = \sqrt3. The 30° angle sees the side of length 1 as opposite, giving \sin30° = \frac12; the 60° angle sees \sqrt3, giving \sin60° = \frac{\sqrt3}{2}.
These are not looked-up numbers. They are two triangles anyone can draw.
The addition formulas, and everything that follows from them
\sin(A+B) = \sin A\cos B + \cos A\sin B
\cos(A+B) = \cos A\cos B - \sin A\sin B
Read the second aloud. "Cosine of A plus B equals cos A cos B minus sin A sin B" — and note the minus, which is the single most-forgotten sign in trigonometry.
Where they come from — the rotation argument. Rotating by A and then by B is the same as rotating by A+B. Write the rotation as a complex multiplication using Euler's formula from 2.5 — complex numbers:
e^{i(A+B)} = e^{iA} \cdot e^{iB}
Expand each side into cosines and sines. The left:
e^{i(A+B)} = \cos(A+B) + i\sin(A+B)
The right:
(\cos A + i\sin A)(\cos B + i\sin B) = \cos A\cos B + i\cos A\sin B + i\sin A\cos B + i^2\sin A\sin B
Since i^2 = -1, gather the real and imaginary parts:
= \underbrace{\left(\cos A\cos B - \sin A\sin B\right)}_{\text{real}} + i\underbrace{\left(\sin A\cos B + \cos A\sin B\right)}_{\text{imaginary}}
Two complex numbers are equal only when their real parts match and their imaginary parts match. Comparing gives both formulas at once. The minus in the cosine formula is nothing more mysterious than i^2 = -1.
The subtraction versions come from replacing B with -B and using the odd/even rules:
\sin(A-B) = \sin A\cos B - \cos A\sin B, \qquad \cos(A-B) = \cos A\cos B + \sin A\sin B
The tangent versions. Divide the sine formula by the cosine formula, then divide top and bottom by \cos A\cos B:
\tan(A+B) = \frac{\tan A + \tan B}{1 - \tan A\tan B}, \qquad \tan(A-B) = \frac{\tan A - \tan B}{1+\tan A\tan B}
Double angles — just set B = A
\sin2\theta = 2\sin\theta\cos\theta
\cos2\theta = \cos^2\theta - \sin^2\theta = 2\cos^2\theta - 1 = 1 - 2\sin^2\theta
\tan2\theta = \frac{2\tan\theta}{1-\tan^2\theta}
Where the three versions of \cos2\theta come from. Start with \cos^2\theta - \sin^2\theta. Replace \sin^2\theta with 1-\cos^2\theta to get 2\cos^2\theta - 1; or replace \cos^2\theta with 1-\sin^2\theta to get 1-2\sin^2\theta. All three are the same statement; you pick whichever leaves you with the function you want.
Half angles — the double-angle formulas, run backwards
Rearrange \cos2\theta = 2\cos^2\theta - 1 to make \cos^2\theta the subject, then replace \theta with \frac\theta2:
\cos^2\frac\theta2 = \frac{1+\cos\theta}{2} \quad \Rightarrow \quad \cos\frac\theta2 = \pm\sqrt{\frac{1+\cos\theta}{2}}
Do the same with \cos2\theta = 1-2\sin^2\theta:
\sin\frac\theta2 = \pm\sqrt{\frac{1-\cos\theta}{2}}, \qquad \tan\frac\theta2 = \frac{1-\cos\theta}{\sin\theta} = \frac{\sin\theta}{1+\cos\theta}
The \pm is settled by which quadrant \frac\theta2 lands in; the formula cannot know that, so you must.
The power-reduction forms, which are what integration actually needs in 5.6:
\sin^2\theta = \frac{1-\cos2\theta}{2}, \qquad \cos^2\theta = \frac{1+\cos2\theta}{2}
Products into sums, and sums into products
\sin A\cos B = \tfrac12\left[\sin(A+B) + \sin(A-B)\right]
\cos A\cos B = \tfrac12\left[\cos(A-B) + \cos(A+B)\right]
\sin A\sin B = \tfrac12\left[\cos(A-B) - \cos(A+B)\right]
Where they come from. Add the formulas for \sin(A+B) and \sin(A-B). The \cos A\sin B terms have opposite signs and cancel, leaving 2\sin A\cos B. Divide by 2. The other two come from adding or subtracting the two cosine formulas in the same way.
Running the same identities backwards, with A+B = P and A-B = Q:
\sin P + \sin Q = 2\sin\frac{P+Q}{2}\cos\frac{P-Q}{2}, \qquad \cos P + \cos Q = 2\cos\frac{P+Q}{2}\cos\frac{P-Q}{2}
Why anyone cares. These are the formulas behind beats in music. Two notes at nearby frequencies f_1 and f_2 add to
\sin(2\pi f_1 t) + \sin(2\pi f_2 t) = 2\sin\left(2\pi\tfrac{f_1+f_2}{2}t\right)\cos\left(2\pi\tfrac{f_1-f_2}{2}t\right)
which is a tone at the average frequency, whose loudness is swelling and fading at the difference frequency. That slow throb is how a piano gets tuned, and it is a product-to-sum identity you can hear.
The single-wave form
a\sin\theta + b\cos\theta = R\sin(\theta+\alpha), \qquad R = \sqrt{a^2+b^2}, \quad \tan\alpha = \frac ba
Where it comes from. Expand the right side with the addition formula:
R\sin(\theta+\alpha) = R\cos\alpha\sin\theta + R\sin\alpha\cos\theta
Match it term by term against the left: R\cos\alpha = a and R\sin\alpha = b. Square and add those two:
R^2\cos^2\alpha + R^2\sin^2\alpha = a^2+b^2 \quad \Rightarrow \quad R^2 = a^2+b^2
Divide them instead: \tan\alpha = b/a.
This is the formula that says any two waves of the same frequency add up to a single wave of that frequency — different size, shifted along, but the same shape. It is why alternating current can be handled with one amplitude and one phase, and it is the reason Part 9 can treat a signal as a collection of independent frequencies.
Solving any triangle
The law of sines
\frac{a}{\sin A} = \frac{b}{\sin B} = \frac{c}{\sin C} = 2R
where R is the radius of the circle through all three corners.
Where it comes from. Drop a perpendicular of height h from vertex C down to side AB. Looking at the left right-triangle, h = b\sin A. Looking at the right one, h = a\sin B. The same height, two expressions:
b\sin A = a\sin B \quad \Rightarrow \quad \frac{a}{\sin A} = \frac{b}{\sin B}
Dropping the perpendicular from a different vertex gives the third ratio.
Use it when you know two angles and a side, or two sides and an angle not between them. That second case is the ambiguous one: \sin\theta = \sin(180° - \theta), so an obtuse answer may be just as valid as an acute one, and you must check whether both give a triangle whose angles still sum to 180°.
The law of cosines
c^2 = a^2 + b^2 - 2ab\cos C
Read it aloud. "c squared equals a squared plus b squared, minus two a b cos C" — Pythagoras with a correction term for the angle not being right.
Where it comes from. Put the triangle on coordinates: C at the origin, side b along the positive x-axis so that A sits at (b, 0), and B at distance a from the origin at angle C, which puts it at (a\cos C,\ a\sin C). Now apply the distance formula to find c = AB:
c^2 = (a\cos C - b)^2 + (a\sin C - 0)^2
Expand:
= a^2\cos^2 C - 2ab\cos C + b^2 + a^2\sin^2 C
Group the two a^2 terms and use \cos^2C + \sin^2C = 1:
= a^2\left(\cos^2C+\sin^2C\right) + b^2 - 2ab\cos C = a^2+b^2-2ab\cos C
The check that makes it memorable. Put C = 90°. Then \cos C = 0, the correction term vanishes, and the formula collapses to c^2 = a^2+b^2. Pythagoras is the special case, and the -2ab\cos C measures exactly how far from a right angle you are. If C is acute, \cos C > 0 and c comes out shorter than Pythagoras would give; if obtuse, longer.
Use it when you know all three sides (rearrange for the angle), or two sides and the angle between them.
\cos C = \frac{a^2+b^2-c^2}{2ab}
Inverse trigonometric functions
\arcsin: [-1,1] \to \left[-\tfrac\pi2, \tfrac\pi2\right], \qquad \arccos: [-1,1]\to[0,\pi], \qquad \arctan: \mathbb{R} \to \left(-\tfrac\pi2,\tfrac\pi2\right)
Why the restricted output ranges are not a technicality. \sin\theta = 0.5 has infinitely many solutions: 30°, 150°, 390°, and so on forever. A function must return one answer, so mathematics picks one — and the choice is the interval near zero where the function is increasing and hits every value exactly once. Your calculator's \sin^{-1} button returns 30° and silently discards 150°. In a physical problem the discarded one is often the answer you needed, which is why solving \sin\theta = k properly means writing
\theta = \arcsin k + 360°n \quad \text{or} \quad \theta = 180° - \arcsin k + 360°n
Why \operatorname{atan2} exists in every programming language. \arctan(y/x) cannot tell the point (1,1) from (-1,-1), because both give y/x = 1. The two-argument \operatorname{atan2}(y,x) keeps the signs separate and returns the correct angle in all four quadrants. Any code that computes a heading, a bearing or a phase uses it.
Hyperbolic functions
These look like trigonometry and behave like it, and they turn up wherever something hangs, spreads or decays. They are defined not by a circle but by the exponential function:
\cosh x = \frac{e^x + e^{-x}}{2}, \qquad \sinh x = \frac{e^x - e^{-x}}{2}, \qquad \tanh x = \frac{\sinh x}{\cosh x} = \frac{e^x-e^{-x}}{e^x+e^{-x}}
Read them aloud. "Cosh x" (rhymes with posh), "sinh x" (usually said "shine"), "tanh x" ("than" or "tanch").
Where the definitions come from. Any function at all can be split into an even part (one satisfying f(-x) = f(x)) and an odd part (f(-x) = -f(x)), by the trivially true statement
f(x) = \underbrace{\frac{f(x)+f(-x)}{2}}_{\text{even}} + \underbrace{\frac{f(x)-f(-x)}{2}}_{\text{odd}}
Do that to e^x and you have \cosh and \sinh exactly. They are not an invention; they are the two halves of the exponential.
The identity that mirrors Pythagoras
\cosh^2x - \sinh^2x = 1
Where it comes from. Multiply out both squares, from the definitions:
\cosh^2 x = \frac{\left(e^x+e^{-x}\right)^2}{4} = \frac{e^{2x} + 2 + e^{-2x}}{4}
\sinh^2 x = \frac{\left(e^x - e^{-x}\right)^2}{4} = \frac{e^{2x} - 2 + e^{-2x}}{4}
The middle terms are +2 and -2 because e^x \cdot e^{-x} = e^0 = 1. Subtract:
\cosh^2x - \sinh^2x = \frac{(e^{2x}+2+e^{-2x}) - (e^{2x}-2+e^{-2x})}{4} = \frac{4}{4} = 1
Why the minus sign, and where the name comes from. The point (\cos t, \sin t) traces the circle x^2+y^2=1. The point (\cosh t, \sinh t) traces x^2 - y^2 = 1, which is a hyperbola. Same construction, one sign different, and that sign is the entire difference between circular and hyperbolic. It is also the sign difference between ordinary geometry and the geometry of special relativity, where \tanh is how velocities actually add.
The rest of the hyperbolic identities
\sinh(x\pm y) = \sinh x\cosh y \pm \cosh x\sinh y
\cosh(x\pm y) = \cosh x\cosh y \pm \sinh x\sinh y
\sinh 2x = 2\sinh x\cosh x, \qquad \cosh2x = \cosh^2x+\sinh^2x
1 - \tanh^2 x = \operatorname{sech}^2 x
Every one matches its trigonometric twin except for some signs. The rule connecting them, called Osborn's rule, is: take the trigonometric identity and flip the sign of any term containing a product of two sines. The reason is \sinh x = -i\sin(ix), so each sine factor contributes a factor of i, and two of them give i^2 = -1.
Why \tanh is everywhere in machine learning
\tanh x = \frac{e^{2x}-1}{e^{2x}+1}, \qquad \tanh(-x) = -\tanh x, \qquad \lim_{x\to\pm\infty}\tanh x = \pm 1
Where the second form comes from. Multiply top and bottom of the definition by e^x: \frac{e^x-e^{-x}}{e^x+e^{-x}} \times \frac{e^x}{e^x} = \frac{e^{2x}-1}{e^{2x}+1}.
Where the limits come from. As x grows, e^{2x} becomes enormous and the \pm1 beside it stops mattering, so the ratio approaches \frac{e^{2x}}{e^{2x}} = 1. As x \to -\infty, e^{2x} \to 0 and the ratio approaches \frac{-1}{1} = -1.
So \tanh takes any number, however extreme, and returns something between -1 and 1, smoothly, symmetrically, with the steepest response near zero. That is exactly the behaviour wanted from a squashing function in a neural network, and it is why \tanh sits inside every recurrent network ever trained.
Its close relative the logistic function is the same curve rescaled to run from 0 to 1:
\sigma(x) = \frac{1}{1+e^{-x}} = \frac{1 + \tanh(x/2)}{2}
The catenary. A chain hanging under its own weight takes the shape
y = a\cosh\frac{x}{a}
not a parabola, though the two look almost identical near the bottom. Galileo guessed parabola; Johann Bernoulli, Huygens and Leibniz found the truth in 1691. Turn the curve upside down and it becomes the strongest possible arch, which is why the Gateway Arch in St Louis is a catenary and says so on its plaque.
The inverse hyperbolics, in closed form — unusual and worth seeing, because they are logarithms:
\operatorname{arsinh} x = \ln\left(x+\sqrt{x^2+1}\right), \qquad \operatorname{artanh} x = \tfrac12\ln\frac{1+x}{1-x}
Derivation of the first. Set y = \operatorname{arsinh} x, so x = \sinh y = \frac{e^y - e^{-y}}{2}. Multiply through by 2e^y:
2xe^y = e^{2y} - 1 \quad \Rightarrow \quad \left(e^y\right)^2 - 2x\left(e^y\right) - 1 = 0
That is a quadratic in e^y. Solve it with the quadratic formula:
e^y = \frac{2x \pm \sqrt{4x^2+4}}{2} = x \pm \sqrt{x^2+1}
Since e^y must be positive and \sqrt{x^2+1} > |x|, only the plus sign works. Take logarithms: y = \ln\left(x+\sqrt{x^2+1}\right).
Small angles
\sin\theta \approx \theta, \qquad \tan\theta \approx \theta, \qquad \cos\theta \approx 1 - \frac{\theta^2}{2} \qquad (\theta \text{ small, in radians})
Where they come from. On the unit circle, an angle \theta cuts an arc of length exactly \theta. For a small angle, the arc, its chord and the vertical drop \sin\theta all become indistinguishable — the curve has not had room to bend. The cosine one is the first correction to "the point has barely moved sideways", and all three come out precisely from the series in 5.8.
How good is it? At \theta = 0.1 rad (5.7°), \sin\theta = 0.0998334 against \theta = 0.1 — an error of 0.17%. At 1° it is under 0.005%.
Why it matters. This approximation is the reason a pendulum keeps time. The true equation of motion is \ddot\theta = -\frac gL\sin\theta, which has no clean solution. Replace \sin\theta by \theta and it becomes \ddot\theta = -\frac gL\theta, which is the harmonic oscillator of 6.2, whose period T = 2\pi\sqrt{L/g} does not depend on the swing size at all. Every pendulum clock ever built relies on that, and every one of them runs slow when the swing gets too wide, because the approximation is then no longer good.
7. Where this shows up in your life
Every distance measured without walking it. Surveying, rangefinders, the height of a mountain from its angle of elevation.
Every sound you hear. Pitch is frequency, loudness is amplitude, and a tuner app is computing a Fourier transform of sine waves.
Every AC socket. Mains voltage is 230\sin(2\pi \cdot 50 \cdot t) in India and much of the world — a sine wave at 50 hertz. The "230 volts" is not the peak but the root-mean-square average, which Chapter 5.5 explains.
Every phone signal. Data is encoded by varying the amplitude and phase of a carrier sine wave. Volume III, 7.3 covers modulation.
Every animation and game. Smooth bobbing, swinging, wave motion and easing curves are sines. A camera orbit is (\cos t, \sin t).
Every tide chart and daylight table. Both are close to sinusoidal, because both come from rotation.
Every heartbeat trace, seismograph and oscilloscope. All reading a wave and looking for what it is made of.
Trigonometry has given us a bridge from angles to lengths, and a wave that recurs everywhere in nature. The next chapter closes Part 3 with the geometry that does not fit anywhere else — the surprising results and the shapes that break the rules.