The Trigonometric Functions
Trigonometry starts with one observation: in a right triangle, the ratios between the sides depend only on the angles, not on the size of the triangle. Those ratios are the six trigonometric functions, and they let you turn an angle into lengths and lengths into an angle.
Ratios in a right triangle
Take a right triangle and pick one of its acute angles, . Name the sides relative to :
- the hypotenuse is the longest side, opposite the right angle;
- the opposite side is across from ;
- the adjacent side touches and is not the hypotenuse.
/|
hypotenuse / |
/ | opposite
/ θ |
---------
adjacentThe three main functions are:
The memory aid SOH-CAH-TOA packs all three into one word. Their reciprocals complete the set of six:
| Function | Definition | Reciprocal of |
|---|---|---|
| cosecant, | ||
| secant, | ||
| cotangent, |
Why do these ratios depend only on ? Two right triangles with the same acute angle have all three angles equal, so they are similar (see Congruence and Similarity). Similar triangles are scaled copies, and scaling multiplies every side by the same factor, which cancels in a ratio.
A first computation
A 5-12-13 triangle () with opposite the side 5:
import math
from fractions import Fraction
opp, adj, hyp = 5, 12, 13
print("sin θ =", Fraction(opp, hyp), " cos θ =", Fraction(adj, hyp), " tan θ =", Fraction(opp, adj))
print("csc θ =", Fraction(hyp, opp), " sec θ =", Fraction(hyp, adj), " cot θ =", Fraction(adj, opp))
theta = math.atan2(opp, adj) # recover the angle from the sides
print("θ ≈", round(math.degrees(theta), 4), "degrees")
print("check sin:", round(math.sin(theta), 6), "=", round(5 / 13, 6))
# scaling the triangle changes nothing
print("50-120-130 triangle: sin θ =", Fraction(50, 130))sin θ = 5/13 cos θ = 12/13 tan θ = 5/12
csc θ = 13/5 sec θ = 13/12 cot θ = 12/5
θ ≈ 22.6199 degrees
check sin: 0.384615 = 0.384615
50-120-130 triangle: sin θ = 5/13
Two relations follow straight from the definitions and hold for every :
The second is why the name is cosine: the sine of the complementary angle. The same goes for cotangent and cosecant.
Special angles you should know by heart
Two triangles give exact values. Half of a square (45-45-90) has legs 1, 1 and hypotenuse . Half of an equilateral triangle with side 2 (30-60-90) has sides .
Tip: Read the sine column top to bottom as . Cosine is the same column upside down.
SymPy knows these exact values:
import sympy as sp
for deg in [30, 45, 60]:
t = sp.rad(deg)
print(f"{deg}°: sin = {sp.sin(t)}, cos = {sp.cos(t)}, tan = {sp.tan(t)}, sec = {sp.sec(t)}")30°: sin = 1/2, cos = sqrt(3)/2, tan = sqrt(3)/3, sec = 2*sqrt(3)/3
45°: sin = sqrt(2)/2, cos = sqrt(2)/2, tan = 1, sec = sqrt(2)
60°: sin = sqrt(3)/2, cos = 1/2, tan = sqrt(3), sec = 2
Solving right triangles
"Solving" a triangle means finding all its unknown sides and angles. With one side and one acute angle, or with two sides, a right triangle is fully determined.
- From an angle and a side, use the ratio that contains the side you know and the side you want.
- From two sides, use an inverse function (
asin,acos,atan, see Inverse Trigonometric Functions) to get an angle, and Pythagoras for the third side.
Example: a ladder 6 m long leans against a wall at 70° to the ground. How high does it reach, and how far is its foot from the wall?
import math
L, angle = 6.0, math.radians(70)
height = L * math.sin(angle) # opposite = hyp · sin
foot = L * math.cos(angle) # adjacent = hyp · cos
print(f"height = {height:.3f} m, foot = {foot:.3f} m")
print(f"check Pythagoras: {math.hypot(height, foot):.3f} m")
# A ramp rises 0.5 m over 6 m of horizontal run. What is its angle?
print(f"ramp angle = {math.degrees(math.atan(0.5 / 6)):.2f}°")height = 5.638 m, foot = 2.052 m
check Pythagoras: 6.000 m
ramp angle = 4.76°
In software
- Splitting a vector into components. A projectile fired at speed and angle has velocity . Every game that moves something "in the direction it faces" does this each frame.
- Slopes and grades. A road grade of 8% means . Map software, ramps in games and CSS
skewall go through . - Heights from distances. Line-of-sight, camera field of view () and shadow lengths are right-triangle problems.
The game math trig lesson shows the same ideas in game code, and the unit circle extends these functions beyond 90°.
Exercises
Exercise 1: All six ratios
A right triangle has legs 8 and 15. For the angle opposite the side 8, give all six trig ratios as fractions.
Answer
Hypotenuse 17. , , , , , .
Solution
Exercise 2: Find a side
In a right triangle, the angle and the hypotenuse is 20. Find the opposite and adjacent sides to 2 decimals.
Answer
, .
Solution
import math
t = math.radians(35)
print(round(20 * math.sin(t), 2), round(20 * math.cos(t), 2))11.47 16.38
Exercise 3: From one ratio to the rest
is acute and . Find and exactly.
Answer
, .
Solution
Draw a triangle with opposite 7 and adjacent 24. Then , so and . Check: .
Exercise 4: Tree height
You stand 30 m from the base of a tree and look up at its top at an angle of elevation of 28°. Your eyes are 1.6 m above the ground. How tall is the tree?
Answer
About 17.55 m.
Solution
The height above eye level is the opposite side of a right triangle with adjacent 30 m:
import math
print(round(30 * math.tan(math.radians(28)) + 1.6, 2))17.55
Exercise 5: Velocity components
Write components(speed, angle_deg) that returns (vx, vy) rounded to 3 decimals, and print it for a ball kicked at 20 m/s and 40°.
Answer
(15.321, 12.856).
Solution
import math
def components(speed, angle_deg):
a = math.radians(angle_deg)
return round(speed * math.cos(a), 3), round(speed * math.sin(a), 3)
print(components(20, 40))(15.321, 12.856)
Test yourself
In a right triangle with opposite 3, adjacent 4 and hypotenuse 5, what is ?
Why is the same for every right triangle with the same angle ?
- Because the hypotenuse is always 1
- Because such triangles are similar, so side ratios are equal
- Because of the Pythagorean theorem
- It is not: it depends on the size
Which value is ?
- 1