We already know (see trig identities) that
cos x+y = cos x cos y - sin x sin y
sin x+y = sin x cos y + cos x sin y
So tan x + y = (sin x+y) / (cos x+y)
= (sin x cos y + cos x sin y) / (cos x cos y - sin x sin y)
Dividing both numerator and denominator by (cos x)(cos y), we get:
= ( sin x / cos x + sin y / cos y) / (1 - sin x sin y/(cos x cos y))
= (tan x + tan y) / (1 - tan x tan y)
That was too easy, wasn't it? Now let's have some fun with this.
You may run into a problem in your math career that goes something like this:
Evaluate the following sum exactly:
Tan-1(1/2) + Tan-1(1/5) + Tan-1(1/8)
The way you solve such a problem is this:
Let x = Tan-1(1/2), so tan x = 1/2
Let y = Tan-1(1/5), so tan y = 1/5, and
Let z = Tan-1(1/8), so tan z = 1/8
Now if you can find w = tan x+y+z, the answer will be tan-1 w.
We start by finding tan x+y = (tan x + tan y) / (1 - tan x tan y)
= (1/2 + 1/5) / (1 - (1/2)(1/5))
= (7/10) / (9/10)
Now we apply the formula again to find tan (x+y)+z = (tan(x+y) + tan z) / (1 - tan(x+y)tan z)
= (7/9 + 1/8) / (1 - (7/9)(1/8))
= (56/72 + 7/72) / (1 - 7/72)
= (63/72) / (63/72)
So w = tan x+y+z = 1, so tan-1 w = tan-1 1 = pi/4
Isn't that cute? Tan-1(1/2) + Tan-1(1/5) + Tan-1(1/8) = pi/4
What's so magical about these numbers, 1/2, 1/5, and 1/8 that make their arctans add up to such a "round" number? Let's investigate...
In general, the formula for combining three angles, a=Tan-1(x), b=Tan-1(y), and c=Tan-1(z) can be derived by repeating the formula one more time:
Combining another angle, d,
=(a+b+c+d-bcd-acd-abd-abc) / (1-ab-ac-ad-bc-bd-cd+abcd)
Coming up with magical formulas -- like combining the arctans of 1/8, 1/5, and 1/2 to get the arctan of 1 -- is really fairly easy. Just set the four-angle combination, above, equal to 1 and solve for d
1=(a+b+c+d-bcd-acd-abd-abc) / (1-ab-ac-ad-bc-bd-cd+abcd)
Using this formula, we can see, for example, that for the sums of 2/7, 1/8, 1/5 and d to be equal to the arctan of 1, then d must be equal to 3/16.
You can see that if a, b, and c are rational numbers then d will be rational, too. It is surprising and fun to see that d is not only rational, but fairly simple in most cases, because a lot of canceling happens when you add calculate this fraction.
Mathworld: Tangent -- Equation 20 is the generalized tangent sum formula
Relationship between cos 2x and tan²x -- cos(2x) = (1-tan²(x))/(1+tan²(x))
The webmaster and author of this Math Help site is Graeme McRae.