Sum, Difference and Double-Angle Formulas
What is ? It is not . This lesson proves the correct sum formulas twice, once with rotations and once with distances, and derives the double- and half-angle formulas from them.
The formulas
A quick sanity check shows that the naive guess fails: , but .
Proof 1: composing rotations
Rotating a point about the origin by an angle sends it to . (Check it on , which goes to , and on , which goes to , a quarter turn ahead.) As a matrix:
Rotating by and then by is the same as rotating once by , so . Multiply the left side out:
Matching the entries gives both sum formulas at once. Replacing by (and using , ) gives the difference formulas. SymPy does the matrix product for us:
python · try it yourselfimport sympy as sp
a, b = sp.symbols("alpha beta")
def R(t):
return sp.Matrix([[sp.cos(t), -sp.sin(t)], [sp.sin(t), sp.cos(t)]])
P = R(a) * R(b)
print("top-left :", P[0, 0])
print("bottom-left:", P[1, 0])
print("equal to R(a+b)?", sp.simplify(P - R(a + b)) == sp.zeros(2, 2))
top-left : -sin(alpha)*sin(beta) + cos(alpha)*cos(beta)
bottom-left: sin(alpha)*cos(beta) + sin(beta)*cos(alpha)
equal to R(a+b)? True
The top-left entry is and the bottom-left entry is , exactly as claimed. The rotation fact itself is shown in Translations, Reflections and Rotations, and the matrix view comes back in rotation in 2D.
Proof 2: equal chords
Here is a proof that uses only the distance formula. Put and on the unit circle. The angle between them is . Compute the squared distance in two ways.
Every other formula follows from this one: put for to get , and use to turn it into the sine formulas. Dividing the sine formula by the cosine formula, then dividing top and bottom by , gives the tangent formula.
Double- and half-angle formulas
Put in the sum formulas:
The last two forms of come from replacing or using . Solving them for and gives the power-reduction and half-angle formulas, much used in calculus:
The sign is chosen by the quadrant of . Example: exactly, and also :
python · try it yourselfimport sympy as sp
d = sp.pi / 180
via_difference = sp.cos(45*d)*sp.cos(30*d) + sp.sin(45*d)*sp.sin(30*d)
via_half_angle = sp.sqrt((1 + sp.cos(30*d)) / 2)
print("difference formula:", via_difference, "≈", sp.N(via_difference, 10))
print("half-angle formula:", via_half_angle, "≈", sp.N(via_half_angle, 10))
print("cos 15° numerically:", sp.N(sp.cos(15*d), 10))
print("expand_trig(sin(3x)):", sp.expand_trig(sp.sin(3*sp.Symbol('x'))))
difference formula: sqrt(2)/4 + sqrt(6)/4 ≈ 0.9659258263
half-angle formula: sqrt(sqrt(3)/4 + 1/2) ≈ 0.9659258263
cos 15° numerically: 0.9659258263
expand_trig(sin(3x)): -4*sin(x)**3 + 3*sin(x)
So , which equals even though the two look different.
In software
- Incremental rotation. To rotate a sprite by a small fixed step each frame, you do not need
sin and cos every frame. The sum formulas give and from the previous values with four multiplications. This is how cheap oscillators and old demo-scene effects generated circles.
- Audio oscillators. The identity (add the sum and difference formulas) produces a sine wave with one multiply and one subtract per sample.
- Graphics shaders use the double-angle formulas to get from without a second trig call.
python · try it yourselfimport math
delta = math.radians(1) # 1° per step
c, s = 1.0, 0.0 # cos 0, sin 0
cd, sd = math.cos(delta), math.sin(delta)
for step in range(360):
c, s = c * cd - s * sd, s * cd + c * sd # sum formulas
print("after 360 steps:", round(c, 12), round(s, 12) + 0.0)
# two-term recurrence for a sine wave
k = 2 * math.cos(delta)
prev, cur = math.sin(-delta), 0.0
for _ in range(30):
prev, cur = cur, k * cur - prev
print("recurrence sin 30°:", round(cur, 12), " math.sin:", round(math.sin(math.radians(30)), 12))
after 360 steps: 1.0 0.0
recurrence sin 30°: 0.5 math.sin: 0.5
Note: Rounding errors accumulate in such recurrences over millions of steps. Real code renormalises (divide by its length now and then) or recomputes from the true angle occasionally.
Exercises
Exercise 1: An exact value
Find exactly using a sum formula.
Answer
.
Solution
Exercise 2: Combine two angles
and are acute with and . Find and .
Answer
, .
Solution
python · try it yourselfimport math
a, b = math.asin(3/5), math.acos(5/13)
print(round(math.cos(a + b), 6), round(-16/65, 6), round(math.sin(a - b), 6), round(-33/65, 6))
-0.246154 -0.246154 -0.507692 -0.507692
Exercise 3: Double angle
If and is in quadrant II, find and .
Answer
, .
Solution
Exercise 4: Triple angle
Prove , then check it with SymPy.
Answer
The identity holds; SymPy's difference is 0.
Solution
python · try it yourselfimport sympy as sp
x = sp.Symbol("x")
print(sp.simplify(sp.expand_trig(sp.cos(3*x)) - (4*sp.cos(x)**3 - 3*sp.cos(x))))
0
Exercise 5: Rotate without trig calls
Starting from , apply the incremental rotation with for 30 steps. Print the final rounded to 6 decimals and compare with , .
Answer
, matching .
Solution
python · try it yourselfimport math
d = math.radians(3)
cd, sd = math.cos(d), math.sin(d)
c, s = 1.0, 0.0
for _ in range(30):
c, s = c * cd - s * sd, s * cd + c * sd
print(round(c, 6) + 0.0, round(s, 6))
0.0 1.0
Test yourself
Which formula is correct?
Which of these is NOT a correct form of ?
Why does prove the sum formulas?
- Because matrix multiplication is commutative
- Because rotating by then is one rotation by , so matching matrix entries gives the formulas
- Because the determinant of R is 1
- It only proves them for acute angles