Skip to content

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\):

\[\sin\theta = \frac{\text{opposite}}{\text{hypotenuse}}, \quad \cos\theta = \frac{\text{adjacent}}{\text{hypotenuse}}, \quad \tan\theta = \frac{\text{opposite}}{\text{adjacent}}\]

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
\[\sin\theta = \frac{3}{5}, \quad \cos\theta = \frac{4}{5}, \quad \tan\theta = \frac{3}{4}\]

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.

\[\text{opposite} = 10 \sin 30° = 10 \cdot \frac{1}{2} = 5\]
\[\text{adjacent} = 10 \cos 30° = 10 \cdot \frac{\sqrt{3}}{2} = 5\sqrt{3}\]

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:

\[(\cos\theta, \sin\theta)\]

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:

\[360° = 2\pi \text{ radians}\]
\[1 \text{ radian} = \frac{180°}{\pi} \approx 57.3°\]
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

\[\sin^2\theta + \cos^2\theta = 1\]

This follows directly from the unit circle: the point \((\cos\theta, \sin\theta)\) lies on \(x^2 + y^2 = 1\).

Derived forms:

\[\sin^2\theta = 1 - \cos^2\theta\]
\[\cos^2\theta = 1 - \sin^2\theta\]

Quotient Identity

\[\tan\theta = \frac{\sin\theta}{\cos\theta}\]

Reciprocal Functions (Brief)

\[\csc\theta = \frac{1}{\sin\theta}, \quad \sec\theta = \frac{1}{\cos\theta}, \quad \cot\theta = \frac{1}{\tan\theta}\]

These appear less frequently in CP but are good to know.


Sum and Difference Formulas

These are essential for combining or splitting angles:

\[\sin(A \pm B) = \sin A \cos B \pm \cos A \sin B\]
\[\cos(A \pm B) = \cos A \cos B \mp \sin A \sin B\]
\[\tan(A \pm B) = \frac{\tan A \pm \tan B}{1 \mp \tan A \tan B}\]

Example

\(\sin 75° = \sin(45° + 30°) = \sin 45° \cos 30° + \cos 45° \sin 30°\)

\[= \frac{\sqrt{2}}{2} \cdot \frac{\sqrt{3}}{2} + \frac{\sqrt{2}}{2} \cdot \frac{1}{2} = \frac{\sqrt{6} + \sqrt{2}}{4}\]

Double Angle Formulas

Set \(B = A\) in the sum formulas:

\[\sin 2A = 2 \sin A \cos A\]
\[\cos 2A = \cos^2 A - \sin^2 A = 2\cos^2 A - 1 = 1 - 2\sin^2 A\]
\[\tan 2A = \frac{2 \tan A}{1 - \tan^2 A}\]

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\):

\[\cos^2 A = \frac{1 + \cos 2A}{2}\]

From \(\cos 2A = 1 - 2\sin^2 A\):

\[\sin^2 A = \frac{1 - \cos 2A}{2}\]

Law of Sines

In any triangle with sides \(a, b, c\) opposite angles \(A, B, C\):

\[\frac{a}{\sin A} = \frac{b}{\sin B} = \frac{c}{\sin C} = 2R\]

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°\)

\[\frac{10}{\sin 30°} = \frac{b}{\sin 45°} \implies b = \frac{10 \sin 45°}{\sin 30°} = \frac{10 \cdot \frac{\sqrt{2}}{2}}{\frac{1}{2}} = 10\sqrt{2} \approx 14.14\]

Law of Cosines

In any triangle:

\[c^2 = a^2 + b^2 - 2ab\cos C\]

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\).

\[\cos C = \frac{a^2 + b^2 - c^2}{2ab} = \frac{49 + 64 - 81}{2 \cdot 7 \cdot 8} = \frac{32}{112} = \frac{2}{7}\]
\[C = \arccos\left(\frac{2}{7}\right) \approx 73.4°\]

Area via Trigonometry

The area of a triangle with two sides \(a, b\) and included angle \(C\):

\[\text{Area} = \frac{1}{2}ab\sin 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°\):

\[\text{Area} = \frac{1}{2}(7)(8)\sin(73.4°) \approx 26.8\]

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}\) ✓.