# Solve with Reals gives different answer

I'm very new to Mathematica (started using ver 10.4) and I was just verifying my calculations.

I have the following equation:

Simplify[Solve[Tan[π/4] + Tan[kx L + π/4] == 0, {kx}]]


That yields the same answer from pen and paper (all real values, i.e. L ∈ Reals):

{{kx -> ConditionalExpression[(π (-1 + 2 C[1]))/(2 L), C[1] ∈ Integers]}}


But when I try it with Reals:

Simplify[Solve[Tan[π/4] + Tan[kx L + π/4] == 0, {kx}, Reals]]


I get:

{{kx -> ConditionalExpression[-((π - 8 ArcTan[1 - Sqrt[2]] - 8 π C[1])/(4 L)), C[1] ∈ Integers]},
{kx ->ConditionalExpression[-((π - 8 ArcTan[1 + Sqrt[2]] - 8 π C[1])/(4 L)), C[1] ∈ Integers]}}


Which I don't know where he got it from. Reading Solve[] help page, it seems Reals restricts all constants and functions to be real which is true for the initial case.

What is going on in the Reals case?

It seems that

8 ArcTan[1 - Sqrt[2]] = 3*π


So the final solution is different in the Reals case (C[1] becomes 2*C[1] which misses some solutions compared to the first Solve answer).

• It appears to me 8 ArcTan[1 - Sqrt[2]] is equal to -π, and 8 ArcTan[1 + Sqrt[2]] is equal to 3*π. In that case, I think that the two solutions with Reals combine to be the same as the one solution without Reals. – march May 17 '16 at 20:46

The solutions are actually the same. Note that

8 ArcTan[1 - Sqrt[2]] + π // N // Chop
8 ArcTan[1 + Sqrt[2]] - 3 π // N // Chop
(* 0 *)
(* 0 *)


Therefore, the second set of solutions reduces to

sols = Simplify[Solve[Tan[π/4] + Tan[kx L + π/4] == 0, {kx}, Reals]]
sols = sols/. {ArcTan[1 - Sqrt[2]] -> -π/8, ArcTan[1 + Sqrt[2]] -> (3 π)/8} // Expand
(* {{kx -> ConditionalExpression[-(π/(2 L)) + (2 π C[1])/L, C[1] ∈ Integers]},
{kx -> ConditionalExpression[π/(2 L) + (2 π C[1])/L, C[1] ∈ Integers]}} *)


These two solutions can be rewritten as

(π (-1 + 4 C[1]))/(2 L)
(π (1 + 4 C[1]))/(2 L)


and it is relatively straight-forward to show that these two combined yield the same solutions as

(π (-1 + 2 C[1]))/(2 L)


if C[1] is allowed to be any integer. For instance,

Table[-(π/(2 L)) + (π x)/L, {x, -2, 3}] === Flatten@Table[{-(π/(2 L)) + (2 π x)/L, π/(2 L) + (2 π x)/L}, {x, -1, 1}]
(* True *)