The Cosine Difference Identity

A supplementary explainer for Exhibit 6 of Natural Language Processing: Foundations and Applications without Hallucination from Generative AI.

The cosine difference identity says that for any two angles β and α:

cos(β)cos(α) + sin(β)sin(α) = cos(β − α)

This page proves it using nothing but a circle of radius 1, the distance between two points, and the Pythagorean theorem — the same building blocks used throughout the research note. This proof is also explained, step by step, in a 6-minute Chinese-language video: watch it on YouTube.

Setting up the picture

Draw a circle of radius 1 centered at C, and mark four points on it (Exhibit E): B at angle 0, Q at angle α, A at angle β − α, and P at angle β — all measured from B, going counterclockwise.

Exhibit E A unit circle centered at C with four points on it: B at angle 0, Q at angle alpha, A at angle beta minus alpha, and P at angle beta. The angle from Q to P equals the angle from B to A, both equal to beta minus alpha. The angle from A to P also equals alpha, the same as the angle from B to Q. α β−α β−α α C B Q A P
Exhibit E — Two equal central angles. The angle from Q to P (blue arc) and the angle from B to A (purple arc) are both β − α. C, B, Q, P, and A all sit on the unit circle.

Angle BCQ = α and angle BCP = β, so angle QCP = β − α. Similarly, angle ACP = α and angle BCP = β, so angle BCA = β − α. Hence, the chord PQ and the chord AB must be equal:

PQ = AB

Computing PQ²

Q = (cosα, sinα) and P = (cosβ, sinβ), both measured from C. Dropping each point straight down to the baseline gives cosα and cosβ (how far right of C), and straight up from the baseline gives sinα and sinβ (how high above C). PQ is then the hypotenuse of a small right triangle whose legs are the gaps between those coordinates: cosα − cosβ and sinβ − sinα (Exhibit F).

Exhibit F Points C, Q at angle alpha, and P at angle beta, with cos alpha, cos beta marked along the baseline and sin alpha, sin beta marked as heights. A small right triangle at top has horizontal leg cos alpha minus cos beta, vertical leg sin beta minus sin alpha, and hypotenuse PQ. α cos β cos α sin α sin β PQ C Q P
Exhibit F. Q sits at angle α and P at angle β. The green segments (cosα, sinα) are Q’s coordinates; the blue segments (cosβ, sinβ) are P’s. The red triangle’s legs are the gaps between them, with hypotenuse PQ.

By the Pythagorean theorem:

PQ² = (cosα − cosβ)² + (sinβ − sinα)²
= (cosα)² + (cosβ)² − 2cosαcosβ + (sinβ)² + (sinα)² − 2sinβsinα
= [(cosα)² + (sinα)²] + [(cosβ)² + (sinβ)²] − 2cosαcosβ − 2sinβsinα
= 1 + 1 − 2cosαcosβ − 2sinβsinα
= 2 − 2cosαcosβ − 2sinβsinα

(The two bracketed terms each equal 1, since every point on the circle satisfies cos² + sin² = 1 — see Exhibit D on the Law of Cosines page.)

Computing AB²

B = (1, 0) and A = (cos(β−α), sin(β−α)), both measured from C. Dropping A straight down to the baseline gives cos(β−α), so the gap between that foot and B is 1 − cos(β−α); A’s height above the baseline is sin(β−α). AB is the hypotenuse of the small right triangle those two gaps form (Exhibit G).

Exhibit G Points C, B at distance 1, and A at angle beta minus alpha. A small right triangle has horizontal leg 1 minus cosine of beta minus alpha, vertical leg sine of beta minus alpha, and hypotenuse AB. β−α 1 1 − cos(β−α) sin(β−α) AB C B A
Exhibit G. C to B is 1, and C to A is also 1, at angle β − α. The green segment (1 − cos(β−α)) and blue segment (sin(β−α)) are the legs of the right triangle whose hypotenuse is AB.

AB² = (1 − cos(β−α))² + sin²(β−α)
= 1 + cos²(β−α) − 2cos(β−α) + sin²(β−α)
= 1 + [cos²(β−α) + sin²(β−α)] − 2cos(β−α)
= 1 + 1 − 2cos(β−α)
= 2 − 2cos(β−α)

Putting it together

Since PQ = AB, squaring both sides gives PQ² = AB²:

2 − 2cosαcosβ − 2sinβsinα = 2 − 2cos(β−α)

Cancel the 2 on each side:

−2cosαcosβ − 2sinβsinα = −2cos(β−α)

Then divide both sides by −2:

cosαcosβ + sinβsinα = cos(β − α) = cosθ

That’s the cosine difference identity used in the research note’s Exhibit 6 — proved from a circle, a rotation, and the Pythagorean theorem, without assuming the identity itself anywhere along the way.

Endnotes

  1. This proof (restricted to angles under 90° for simplicity) is adapted from “Sum and Difference Identities,” in Precalculus (OpenStax), LibreTexts. math.libretexts.org.

← Back to the research note