Trigonometric Functions

Single-variable calculus from first principles

Trigonometry sounds like triangles, but the version you need for ML is cleaner: it's about going round a circle. Picture a point traveling around a circle of radius 1 centered at the origin — the unit circle. As it moves, its shadow on each axis traces out the two functions that matter.

Let θ (theta) be the angle the point has swept from the positive x-axis. Then by definition the point sits at (cos θ, sin θ). That's it — cos is the x-coordinate, sin is the y-coordinate. Drag the point around the circle below and watch both readouts change.

From these two, tangent is just their ratio, tan θ = sin θ / cos θ — the slope of the radius line.

Where this lives in MLPeriodic functions are how models represent position and time. Transformer positional encodings are built from sines and cosines at many frequencies, so the network can tell tokens apart by where they sit in a sequence. Rotations — which power everything from data augmentation to attention's rotary embeddings (RoPE) — are expressed with exactly the cos θ and sin θ on this circle.
▶ Trigonometric Functions
← Exponential & LogarithmBrief: Vector Spaces of Functions →