0
$\begingroup$

I'm trying to simplify an expression with sums of ArcTan, for which I've written a transformation rule that works for simple sums, so that ArcTan[a] + ArcTan[b] -> ArcTan[(a+b)/(1-ab)]. However, it fails for terms of the type 5 ArcTan[a] + ArcTan[b]. One way to simplify this expression would be to expand the integer into a sum of units, then transform repeatedly until the expression consists of only one ArcTan, but I haven't been able so far to find the way.

I've tried Hold,Distribute, Sum,Fold with Plusto no avail.

$\endgroup$

2 Answers 2

2
$\begingroup$

How about this?

ArcTan[Simplify[TrigExpand[Tan[5 ArcTan[a] + ArcTan[b]]]]]

ArcTan Simplify

Could save yourself some work!

Explanation:

The trick here is to understand the identity you mentioned is about Tan, not ArcTan:

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

TrigExpand does the above type of expansion for trig functions. Replace x and y with ArcTan[a] and ArcTan[b], then take ArcTan of both sides and you have your identity. Simplify collects the terms of the expansion into one.

The same method works for any linear combination of x=Arctan[a] and y=Arctan[b].

$\endgroup$
2
  • $\begingroup$ Thanks. Simple and effective. Is there some reference for simplifications in Mathematica? $\endgroup$
    – auxsvr
    Jul 15, 2014 at 16:57
  • $\begingroup$ I just checked the help file for ArcTan. Look at ref/ArcTan->Applications->Addition theorem for tangent function. They use exactly the same technique, which is reassuring. There are various tutorials in the document centre. Look under "Algebraic Manipulation". However I simply search for a function e.g. TrigExpand and then use "See Also" at the bottom to find other related functions e.g. TrigReduce. $\endgroup$
    – Michael
    Jul 16, 2014 at 10:53
1
$\begingroup$

How about:

5 ArcTan[a] + ArcTan[b] /.
 {(m_Integer: 1) ArcTan[a_] + (n_Integer: 1) ArcTan[b_] /; Positive[m] && Positive[n] :>
   With[{min = Min[m, n]},
    (m - min) ArcTan[a] + (n - min) ArcTan[b] + 
     min ArcTan[(a + b)/(1 - ab)]]}

(* 4 ArcTan[a] + ArcTan[(a + b)/(1 - ab)] *)

Works on positive integral coefficients, which is how I read the question:

7 ArcTan[a] + 4 ArcTan[b] /.
 {(m_Integer: 1) ArcTan[a_] + (n_Integer: 1) ArcTan[b_] /; Positive[m] && Positive[n] :>
   With[{min = Min[m, n]},
    (m - min) ArcTan[a] + (n - min) ArcTan[b] + 
     min ArcTan[(a + b)/(1 - ab)]]}

(* 3 ArcTan[a] + 4 ArcTan[(a + b)/(1 - ab)] *)
$\endgroup$
5
  • $\begingroup$ Thanks. I had to change a to a_ and b to b_ for this to work with arbitrary arguments. Is there a way to do the expansion in the title? $\endgroup$
    – auxsvr
    Jul 15, 2014 at 10:57
  • $\begingroup$ Also, generalization to negative integers requires to write 2 more transformation rules or is there a simpler way? Mathematica automatically simplifies ArcTan[-x] to -ArcTan[x] and makes it harder, is there a way to stop automatic simplifications? $\endgroup$
    – auxsvr
    Jul 15, 2014 at 11:22
  • $\begingroup$ In order to incorporate negative integers, this seems to work: ArcTanSimplify = {(m_Integer: 1) ArcTan[a_] + (n_Integer: 1) ArcTan[ b_] :> With[{min = Min[Abs[{m, n}]]}, Sign[m] (Abs[m] - min) ArcTan[a] + Sign[n] (Abs[n] - min) ArcTan[b] + min ArcTan[(Sign[m] a + Sign[n] b)/(1 - Sign[m n] a b)]]}; $\endgroup$
    – auxsvr
    Jul 15, 2014 at 12:46
  • $\begingroup$ @auxsvr Yes, using Abs was my first thought. Fixed the a to a_ -- I had thought about it before, but it was late. Can't think why I went for the literal a in the first place. $\endgroup$
    – Michael E2
    Jul 15, 2014 at 13:30
  • $\begingroup$ @auxsvr You can clean up a bit via MinimalBy (v10): m_. ArcTan[a_] + n_. ArcTan[b_] :> With[{min = First@MinimalBy[{m, n}, Abs]}, (m - min) ArcTan[ a] + (n - min) ArcTan[b] + min ArcTan[(a + b)/(1 - a b)]] $\endgroup$
    – evanb
    Jul 15, 2014 at 17:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.