Trigonometry Basics
Pillar: SHAPE — "Trigonometry translates shapes into numbers."
What Is Trigonometry?
Trigonometry studies the relationships between angles and side lengths in triangles. It gives us functions — sine, cosine, tangent — that convert angles into ratios and ratios into angles.
In competitive programming, trigonometry appears in: - Computational geometry (rotations, angle calculations) - Complex number arguments (FFT, roots of unity) - Physics simulations and optimization problems
Right-Triangle Definitions: SOH-CAH-TOA
In a right triangle with an acute angle \(\theta\):
The mnemonic SOH-CAH-TOA helps: - Sine = Opposite / Hypotenuse - Cosine = Adjacent / Hypotenuse - Tangent = Opposite / Adjacent
Example
In a right triangle with legs \(3\) and \(4\) and hypotenuse \(5\):
| Opposite to \(\theta\) | Adjacent to \(\theta\) | Hypotenuse | |
|---|---|---|---|
| If \(\theta\) is opposite the side of length 3 | 3 | 4 | 5 |
Finding Missing Sides
If you know one side and one acute angle, you can find all other sides.
Example. In a right triangle, the hypotenuse is \(10\) and one angle is \(30°\). Find the legs.
The Unit Circle
The unit circle is a circle of radius \(1\) centered at the origin. For any angle \(\theta\) measured counterclockwise from the positive \(x\)-axis, the point on the unit circle is:
This definition extends sine and cosine to all angles, not just acute ones.
Key Properties from the Unit Circle
- \(\cos\theta\) is the \(x\)-coordinate
- \(\sin\theta\) is the \(y\)-coordinate
- \(\tan\theta = \frac{\sin\theta}{\cos\theta}\) (slope of the radius)
Quadrant Signs
| Quadrant | Angle Range | \(\sin\) | \(\cos\) | \(\tan\) |
|---|---|---|---|---|
| I | \(0° < \theta < 90°\) | \(+\) | \(+\) | \(+\) |
| II | \(90° < \theta < 180°\) | \(+\) | \(-\) | \(-\) |
| III | \(180° < \theta < 270°\) | \(-\) | \(-\) | \(+\) |
| IV | \(270° < \theta < 360°\) | \(-\) | \(+\) | \(-\) |
Mnemonic: All Students Take Calculus (which functions are positive in each quadrant: All, Sin, Tan, Cos).
Common Angle Values
These values appear constantly. Memorize them.
| Angle | \(\sin\) | \(\cos\) | \(\tan\) |
|---|---|---|---|
| \(0°\) | \(0\) | \(1\) | \(0\) |
| \(30°\) | \(\frac{1}{2}\) | \(\frac{\sqrt{3}}{2}\) | \(\frac{1}{\sqrt{3}}\) |
| \(45°\) | \(\frac{\sqrt{2}}{2}\) | \(\frac{\sqrt{2}}{2}\) | \(1\) |
| \(60°\) | \(\frac{\sqrt{3}}{2}\) | \(\frac{1}{2}\) | \(\sqrt{3}\) |
| \(90°\) | \(1\) | \(0\) | undefined |
Pattern
Reading down the \(\sin\) column: \(\frac{\sqrt{0}}{2}, \frac{\sqrt{1}}{2}, \frac{\sqrt{2}}{2}, \frac{\sqrt{3}}{2}, \frac{\sqrt{4}}{2}\).
The \(\cos\) column is the same values in reverse order.
Degrees vs Radians
Angles can be measured in degrees or radians. Radians are the natural unit for mathematics:
| Degrees | Radians |
|---|---|
| \(0°\) | \(0\) |
| \(30°\) | \(\frac{\pi}{6}\) |
| \(45°\) | \(\frac{\pi}{4}\) |
| \(60°\) | \(\frac{\pi}{3}\) |
| \(90°\) | \(\frac{\pi}{2}\) |
| \(180°\) | \(\pi\) |
| \(360°\) | \(2\pi\) |
In C++, all trig functions (sin, cos, tan, acos, etc.) use radians. Always convert if your input is in degrees.
Fundamental Identities
Pythagorean Identity
This follows directly from the unit circle: the point \((\cos\theta, \sin\theta)\) lies on \(x^2 + y^2 = 1\).
Derived forms:
Quotient Identity
Reciprocal Functions (Brief)
These appear less frequently in CP but are good to know.
Sum and Difference Formulas
These are essential for combining or splitting angles:
Example
\(\sin 75° = \sin(45° + 30°) = \sin 45° \cos 30° + \cos 45° \sin 30°\)
Double Angle Formulas
Set \(B = A\) in the sum formulas:
The three forms of \(\cos 2A\) are all useful — pick whichever simplifies your expression.
Half-Angle (Derived from Double Angle)
From \(\cos 2A = 2\cos^2 A - 1\):
From \(\cos 2A = 1 - 2\sin^2 A\):
Law of Sines
In any triangle with sides \(a, b, c\) opposite angles \(A, B, C\):
where \(R\) is the circumradius (radius of the circumscribed circle).
When to Use
- You know two angles and one side (AAS or ASA)
- You know two sides and an angle opposite one of them (SSA — ambiguous case)
Example
In \(\triangle ABC\), \(A = 30°\), \(B = 45°\), \(a = 10\). Find \(b\).
\(C = 180° - 30° - 45° = 105°\)
Law of Cosines
In any triangle:
This generalizes the Pythagorean theorem (when \(C = 90°\), \(\cos C = 0\), and you get \(c^2 = a^2 + b^2\)).
When to Use
- You know two sides and the included angle (SAS)
- You know all three sides and want an angle (SSS)
Example: Finding an Angle
In \(\triangle ABC\), \(a = 7\), \(b = 8\), \(c = 9\). Find angle \(C\).
Area via Trigonometry
The area of a triangle with two sides \(a, b\) and included angle \(C\):
This is extremely useful when you know two sides and the angle between them.
Example. Sides \(a = 7\), \(b = 8\), included angle \(C \approx 73.4°\):
Practice Problems
Problem 1. In a right triangle, the hypotenuse is \(13\) and one leg is \(5\). Find \(\sin\theta\), \(\cos\theta\), \(\tan\theta\) for the angle opposite the side of length \(5\).
Solution
Other leg: \(\sqrt{169 - 25} = 12\).
\(\sin\theta = \frac{5}{13}\), \(\cos\theta = \frac{12}{13}\), \(\tan\theta = \frac{5}{12}\).
Problem 2. Evaluate \(\cos(120°)\) without a calculator.
Solution
\(\cos(120°) = \cos(180° - 60°) = -\cos(60°) = -\frac{1}{2}\).
Problem 3. Simplify \(\sin^2(3x) + \cos^2(3x)\).
Solution
By the Pythagorean identity, this equals \(1\) for any value of \(x\).
Problem 4. In \(\triangle ABC\), \(a = 5\), \(b = 7\), \(C = 60°\). Find side \(c\).
Solution
\(c^2 = 25 + 49 - 2(5)(7)\cos 60° = 74 - 70 \cdot \frac{1}{2} = 74 - 35 = 39\).
\(c = \sqrt{39} \approx 6.24\).
Problem 5. Find the area of \(\triangle ABC\) with \(a = 10\), \(b = 12\), \(C = 30°\).
Solution
Area \(= \frac{1}{2}(10)(12)\sin 30° = 60 \cdot \frac{1}{2} = 30\).
Problem 6. Use the double angle formula to find \(\sin(60°)\) from \(\sin(30°)\) and \(\cos(30°)\).
Solution
\(\sin(60°) = 2\sin(30°)\cos(30°) = 2 \cdot \frac{1}{2} \cdot \frac{\sqrt{3}}{2} = \frac{\sqrt{3}}{2}\) ✓.