# FAQ overflow

## Great Answers to Questions About Everything

#### QUESTION

TrigExpand@Tan[x + y]



gives

$\frac{\sin (x) \cos (y)}{\cos (x) \cos (y)-\sin (x) \sin (y)}+\frac{\cos (x) \sin(y)}{\cos (x) \cos (y)-\sin (x) \sin (y)}$

but I expected

$\frac{\tan (x)+\tan (y)}{1-\tan (x) \tan (y)}$

Evaluating TrigExpand with arguments $\tan (x-y)$ or $\tan (3*x)$ also returns results in terms of sine and cosine. What should I do to get results in terms of the tangent?

#### ANSWER

One way to induce Mathematica to simplify to Tan functions is to introduce the arguments as inverse tangents, as in $x\equiv \arctan a$ and $y\equiv \arctan b$. Then you could write for example

Simplify[
TrigExpand@Tan[ArcTan[a] + ArcTan[b]]] /. {a -> Tan[x], b -> Tan[y]}

(* ==> (Tan[x] + Tan[y])/(1 - Tan[x] Tan[y]) *)



or more generally with an expression containing x and y:

expr = Tan[3 x];

Simplify[TrigExpand[
expr /. {x -> ArcTan[a], y -> ArcTan[b]}]] /. {a -> Tan[x],
b -> Tan[y]}

(* ==> (Tan[x] (-3 + Tan[x]^2))/(-1 + 3 Tan[x]^2) *)



Edit

Referring to the answer by @belisarius, I thought it's worth pointing out that you can achieve similar flexibility with my approach. For example, if you want the expression simplified in terms of Sin instead of Tan, just use inverse sines where I said to use inverse tangents above:

Simplify[TrigExpand[
expr /. {x -> ArcSin[a], y -> ArcSin[b]}]] /. {a -> Sin[x],
b -> Sin[y]}

(*
==> (Sin[x] (-3 + 4 Sin[x]^2))/(Sqrt[
1 - Sin[x]^2] (-1 + 4 Sin[x]^2))
*)



The insertion of the inverse function causes Simplify to see the expression as more complex until it reaches a form in terms of the inverse variables. When the simplification is done, we revert the variables back without invoking Simplify again.

You can try this with any target function that has an inverse.