On this page
Right-Triangle Trigonometry
The three ratios
Pick an acute angle \(\theta\) in a right triangle. Name the sides relative to \(\theta\):
- Hypotenuse (H): opposite the right angle, always the longest side.
- Opposite (O): across from \(\theta\).
- Adjacent (A): next to \(\theta\), not the hypotenuse.
Then:
$$
\sin\theta = \frac{\text{opposite}}{\text{hypotenuse}}, \qquad
\cos\theta = \frac{\text{adjacent}}{\text{hypotenuse}}, \qquad
\tan\theta = \frac{\text{opposite}}{\text{adjacent}}
$$
Mnemonic: SOH-CAH-TOA (Sine = Opposite/Hypotenuse, Cosine = Adjacent/Hypotenuse, Tangent = Opposite/Adjacent).
Tangent is also the ratio of sine to cosine:
$$
\tan\theta = \frac{\sin\theta}{\cos\theta}
$$
Worked example 1: find a side
A ladder leans at 65° to the ground; its foot is 2 m from the wall. How long is the ladder?
The known side (2 m) is adjacent to 65°, the unknown (ladder) is the hypotenuse → use cosine:
$$
\cos 65^\circ = \frac{2}{H} \quad\Rightarrow\quad
H = \frac{2}{\cos 65^\circ} \approx \frac{2}{0.4226} \approx 4.73 \text{ m}
$$
import math
H = 2 / math.cos(math.radians(65))
print(round(H, 2)) # 4.73Worked example 2: find an angle
A 5 m ladder reaches 4 m up a wall. What angle does it make with the ground?
Opposite = 4, hypotenuse = 5 → use sine, then invert:
$$
\sin\theta = \frac{4}{5} = 0.8 \quad\Rightarrow\quad
\theta = \arcsin(0.8) \approx 53.13^\circ
$$
import math
theta = math.degrees(math.asin(4 / 5))
print(round(theta, 2)) # 53.13const theta = Math.asin(4 / 5) * 180 / Math.PI;
console.log(theta.toFixed(2)); // 53.13
Reciprocal functions
Three more functions are just reciprocals (less common, but you will see them in docs):
$$
\csc\theta = \frac{1}{\sin\theta}, \qquad
\sec\theta = \frac{1}{\cos\theta}, \qquad
\cot\theta = \frac{1}{\tan\theta} = \frac{\cos\theta}{\sin\theta}
$$
Solving checklist
- Draw the triangle, mark the right angle.
- Label O / A / H relative to your angle.
- Choose the ratio containing the known + unknown (SOH-CAH-TOA).
- Solve algebraically; convert degrees ↔ radians before calling
sin/cos/tan. - Sanity-check: hypotenuse must be longest; angles sum to 180°.
import math
def solve_missing_side(known, angle_deg, ratio="opp-hyp"):
"""Demo solver: given one side + acute angle, return another side."""
r = math.radians(angle_deg)
if ratio == "opp-hyp": # sin = opp/hyp -> hyp = opp/sin
return known / math.sin(r)
if ratio == "adj-hyp": # cos = adj/hyp -> hyp = adj/cos
return known / math.cos(r)
if ratio == "opp-adj": # tan = opp/adj -> opp = adj*tan
return known * math.tan(r)
raise ValueError("unknown ratio")
print(round(solve_missing_side(2, 65, "adj-hyp"), 2)) # 4.73 (ladder example)Practice
- Right triangle: angle 30°, hypotenuse 10. Find opposite and adjacent. (Answers: 5 and ≈ 8.66.)
- Opposite = 7, adjacent = 24. Find the hypotenuse and both acute angles. (Hint: Pythagoras first: \(h = 25\).)
- A ramp rises 1 m over 12 m horizontal. What is its angle? Why does
atan(1/12)give it directly? - Code it: write
height_from_shadow(shadow_len, sun_elevation_deg)using tangent.
Next: The Unit Circle — extending these ratios past 90°.