What command makes Tan[A+B] expand to (Tan[A]+Tan[B])/(1-Tan[A]Tan[B])? TrigExpand does not give it directly.
- 124,525
- 11
- 401
- 574
- 1,678
- 8
- 13
5 Answers
It is in the Wolfram Knowledgebase
Clear["Global`*"]
Entity["MathematicalFunction", "Tan"]["AdditionFormulas"][[1]][
A, B] // Activate
(* Tan[A + B] == (Tan[A] + Tan[B])/(1 - Tan[A] Tan[B]) *)
Verifying,
% // Simplify
(* True *)
EDIT: Converting the equality into a rule
rule = Tan[A_ + B_] :> Evaluate[%%[[-1]]]
(* Tan[A_ + B_] :> (Tan[A] + Tan[B])/(1 - Tan[A] Tan[B]) *)
Handling multiple addends in argument to Tan,
Simplify[Tan[a + b + c + d] //. rule, ExcludedForms -> _Tan]
(* (Tan[b] + Tan[c] + Tan[d] - Tan[b] Tan[c] Tan[d] -
Tan[a] (-1 + Tan[c] Tan[d] + Tan[b] (Tan[c] + Tan[d])))/(1 -
Tan[c] Tan[d] - Tan[b] (Tan[c] + Tan[d]) +
Tan[a] (-Tan[c] - Tan[d] + Tan[b] (-1 + Tan[c] Tan[d]))) *)
Verifying,
% // Simplify
(* Tan[a + b + c + d] *)
- 157,611
- 7
- 77
- 198
I think the easiest way is the following:
tansum = Tan[a_ + b_] :> (Tan[a] + Tan[b])/(1 - Tan[a] Tan[b]);
Then we run
Tan[A + B] /. tansum
(Tan[A] + Tan[B])/(1 - Tan[A] Tan[B])
Likewise for other trigonometric identities
Edit: after the comment for generalization for $n$-angles.
If we try to do it like this for the case $n=3$ it seems to be working
Tan[a1 + a2 + a3] /. tansum /. tansum // Factor
(-Tan[a1] - Tan[a2] - Tan[a3] + Tan[a1] Tan[a2] Tan[a3])/(-1 + Tan[a1] Tan[a2] + Tan[a1] Tan[a3] + Tan[a2] Tan[a3])
-
Thanks. This is close to what I want. Can we write a code to express Tan[a1+a2+...+an] purely in terms of Tan[a1], Tan[a2], Tan[a3], .... – Quasar Supernova Mar 12 '22 at 06:15
-
@QuasarSupernova I don't know the formula in terms of sums of
Tan[a1],...,Tan[an]by heart. If you can post it, I am happy to give it a go. Otherwise I will try it tomorrow, as it's pretty late here – Mar 12 '22 at 06:18 -
@QuasarSupernova please see the edit I added to the answer, and let me know. If I remember there's a general formula in terms of sums of products in the numerator and denominator, but I am not quite sure what you are after :-) – Mar 12 '22 at 06:26
-
You can do a step-by-step derivation, suppressing the evaluation using a change of case.
expr0 = Tan[a + b]
$$\tan (a+b)$$
expr1 = TrigExpand[expr0] /. {Cos -> cos, Sin -> sin}
$$\frac{\sin (a) \cos (b)}{\cos (a) \cos (b)-\sin (a) \sin (b)}+\frac{\cos (a) \sin (b)}{\cos (a) \cos (b)-\sin (a) \sin (b)}$$
expr2 = expr1 /. {sin[a_] -> tan[a] cos[a] }
$$\frac{\cos (a) \tan (a) \cos (b)}{\cos (a) \cos (b)-\cos (a) \tan (a) \cos (b) \tan (b)}+\frac{\cos (a) \cos (b) \tan (b)}{\cos (a) \cos (b)-\cos (a) \tan (a) \cos (b) \tan (b)}$$
expr3 = Factor[expr2] /. tan -> Tan
$$-\frac{\tan (a)+\tan (b)}{\tan (a) \tan (b)-1}$$
expr3 // Simplify
Tan[a+b]
The same procedure for Tan[a+b+c+d] results in:
$$-\frac{\tan (a) \tan (b) \tan (c)+\tan (a) \tan (b) \tan (d)+\tan (a) \tan (c) \tan (d)-\tan (a)+\tan (b) \tan (c) \tan (d)-\tan (b)-\tan (c)-\tan (d)}{\tan (a) \tan (b) \tan (c) \tan (d)-\tan (a) \tan (b)-\tan (a) \tan (c)-\tan (a) \tan (d)-\tan (b) \tan (c)-\tan (b) \tan (d)-\tan (c) \tan (d)+1}$$
- 52,495
- 4
- 30
- 85
If the question concerns the derivation, not the application, of the "high school formula" one can derive it , similar to @Syed's answer, in a direct way :
((Tan[a + b] // TrigExpand) /. {a -> ArcTan[ua], b -> ArcTan[ub]} //TrigExpand // Simplify) /. {ua -> Tan[a ], ub -> Tan[b ]}
(*(Tan[a] + Tan[b])/(1 - Tan[a] Tan[b])*)
- 53,729
- 2
- 23
- 55
Lots of good answers, but here's a trick I think is worth knowing
TrigExpand[Tan[x + y]] /. Sin[u_] -> Cos[u] HoldForm[Tan[u]] //
Simplify // ReleaseHold
(* (Tan[x] + Tan[y])/(1 - Tan[x] Tan[y]) *)
This works by making the (obviously valid) replacement
Sin[u_] -> Cos[u] Tan[u]
In itself, this would achieve little as (I guess) that Mathematica would simplify the result back to the unwanted form. However, wrapping HoldForm round the tangents means that Mathematica will not change them. Consequently, the simplest form is the one that we seek.
ReleaseHold removes the HoldForm wrapper. In this case, this doesn't change the appearance of the result, but means that the Tan terms will behave as expected in subsequent processing.
- 16,741
- 2
- 20
- 54
ReplaceRepeatedwith the rule transforms the original expression into one with onlyTanof atomic arguments; however, it needs to be simplified. Simple application ofSimplifywould just return the original expression. Consequently, the optionExcludedFormsis used to prevent theTanterms from being recombined. – Bob Hanlon Mar 13 '22 at 00:46