I know Mathematica is not omnipotent, but still can't help feeling surprised when I encountered this example, and I think it's worth starting a question for it.

The example is, Simplify etc. doesn't seem to know ArcTan[Cot[a]] equals Pi/2 - a assuming 0 < a < Pi/2:

FullSimplify[ArcTan[Cot[a]], 0 < a < Pi/2]
(* ArcTan[Cot[a]] *)

FullSimplify[ArcTan[Cot[a]] == Pi/2 - a, 0 < a < Pi/2]
(* 2 (a + ArcTan[Cot[a]]) == Pi *)

To make this post a question, I'd like to ask, is it possible to use Simplify and its friends to transform ArcTan[Cot[a]] to Pi/2 - a? Say in advance, I don't want to use Series:

Series[ArcTan[Cot[a]], {a, 0, 1}] // Normal
(* -a + Pi/2 *)

BTW, Maple can simplify it:

enter image description here

  • $\begingroup$ To the downvoter, I am interested in what's wrong with my question, would you please elaborate. I'm not trying to complain here, I just want improve my question if possible. $\endgroup$ – xzczd Feb 11 at 6:32

Similar to the answer here, we can use PowerExpand.

PowerExpand[ArcTan[Cot[a]], Assumptions -> 0 < a < π/2]
π/2 - a

In fact an almost identical example appears in the PowerExpand ref page here.

enter image description here

  • $\begingroup$ Oh… believe it or not, I read your answer yesterday and even scaned the document page of PowerExpand for a while, but simply didn't notice that's the solution for my question… $\endgroup$ – xzczd Feb 11 at 13:36
Reduce[{ArcTan[Cot[a]] - Pi/2 + a == 0, a > 0, a < Pi/2}, a, Reals]

0 < a < π/2

The answer means the inequalities a > 0, a < Pi/2 imply the relation ArcTan[Cot[a]] - Pi/2 + a == 0.

The second answer is as follows.

Simplify[D[ArcTan[Cot[x]] - Pi/2 + x, x], Assumptions -> x > 0 && x < Pi/2]


implies ArcTan[Cot[x]] - Pi/2 + x is a constant on the interval $(0,\pi/2)$. It remains

ArcTan[Cot[x]] - Pi/2 + x /. x -> Pi/4


to prove the identity.

  • $\begingroup$ @xzczd: Don't hesitate to ask for further explanation in need. $\endgroup$ – user64494 Feb 11 at 6:33
  • $\begingroup$ I believe I've fully understood your answer :) $\endgroup$ – xzczd Feb 11 at 6:40
  • $\begingroup$ @xzczd: So you may accept it. $\endgroup$ – user64494 Feb 11 at 6:56
  • $\begingroup$ Well, this answer is still a little away from the goal of my question, I'm afraid. Currently your answer show 2 ways to verify the identity (the second sample can be extended a bit of course e.g. DSolve[{y'[x] == D[ArcTan[Cot[x]], x], y[Pi/4] == ArcTan[Cot[Pi/4]]}, y[x], x]), but my goal is, as said above, "use Simplify and its friends to transform ArcTan[Cot[a]] to Pi/2 - a". Ideally I'd like to see an answer based on combination of Simplify, Expand, etc., together with some clever option settings e.g. TransformationFunctions. $\endgroup$ – xzczd Feb 11 at 7:12
  • $\begingroup$ @xzczd: I got your point. $\endgroup$ – user64494 Feb 11 at 7:29


The problem appears to be systemic

Assuming[0 < a < Pi/2, ArcTan[Cot[a]] == (Pi/2 - a) // FullSimplify]

(* 2 (a + ArcTan[Cot[a]]) == π *)

More troubling since PossibleZeroQ uses both "basic symbolic and numerical methods"

PossibleZeroQ[ArcTan[Cot[a]] - (Pi/2 - a), 
  Assumptions -> 0 < a < Pi/2]

(* False *)
  • $\begingroup$ Er… I think Assuming[assumption, FullSimplify[expr]] is just the same as FullSimplify[expr, assumption]? Is there any example in which these 2 approaches give differenct results? $\endgroup$ – xzczd Feb 11 at 4:27
  • 1
    $\begingroup$ @xzczd - The two forms are equivalent. The main point I was making is that PossibleZeroQ was unable to symbolically or numerically conclude that ArcTan[Cot[a]] - (Pi/2 - a) was zero on the interval {0, Pi/2} and even worse concluded that it was NOT zero. $\endgroup$ – Bob Hanlon Feb 11 at 4:36

I like very much the answer of @user64494 using Reduce. However, its use requires to apriori know the result. The latter is known in the present expression, but in more complex cases can be unknown. For this reason, I am giving now a more lengthy way, avoiding an in-advance knowing of the result.

The core problem here is that the functions Simplify and FullSimplify do not efficiently work on logarithms. I will first introduce two my own functions to work with the logarithms. One of them, called "collectLog" transforms the sum (or difference) of logarithms into the logarithm of the product (or ratio). The second "expandLog" acts in the opposite way.

expandLog[expr_] := Module[{rule1, rule2, a, b, x, g},
   rule1 = Log[a_*b_] -> Log[a] + Log[b];
   rule2 = Log[a_^x_] -> x*Log[a];
   g[x_] := (x /. rule1) /. rule2;
   FixedPoint[g, expr]

collectLog[expr_] := Module[{rule1a, rule1b, rule2, g, a, b, x},
   rule1a = Log[a_] + Log[b_] -> Log[a*b];
   rule1b = Log[a_] - Log[b_] -> Log[a/b];
   rule2 = x_*Log[a_] -> Log[a^x];
   g[x_] := x /. rule1a /. rule1b /. rule2;
   FixedPoint[g, expr]

With this let us first define the expression:

expr1 = ArcTan[Cot[a]];

and apply the the function TrigToExp to it:

expr2 = TrigToExp[expr1] // Factor
(*  1/2 I (Log[1 - (E^(-I a) + E^(I a))/(E^(-I a) - E^(I a))] - 
   Log[1 + (E^(-I a) + E^(I a))/(E^(-I a) - E^(I a))])  *)

The second part of the expr2 contains the difference of two logarithms and it is reasonable to apply collectLog to it:

expr3 = MapAt[Simplify[collectLog[#]] &, expr2, 2]

(* 1/2 I Log[-E^(2 I a)] *)

It is now reasonable to transform -1 into either Exp[I Pi], or Exp[-I Pi]. The second case will yield the answer you give in the question:

expr4 = expr3 /. -E^(2 I a) -> E^(2 I a - I \[Pi])

(* 1/2 I Log[E^(2 I a - I \[Pi])] *)

Now expanding the logarithm staying in the second position in the expr4 we obtain the answer:

MapAt[expandLog, expr4, 2] // Expand

(* -a + \[Pi]/2*)

Have fun!

  • 1
    $\begingroup$ Well, this solution is dangerous, isn't it? The condition 0 < a < Pi/2 is not used… $\endgroup$ – xzczd Feb 11 at 9:48
  • $\begingroup$ @xzczd It is implicitly used when the transformation -1->Exp[-I Pi] has been chosen. But I agree with you. $\endgroup$ – Alexei Boulbitch Feb 11 at 11:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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