# Simplification of Sqrt[Exp[u]] Sqrt[Exp[-u]]

After some computations I end up with the following expression:

Sqrt[Exp[-z/(4*Sqrt)]] Sqrt[Exp[z/(4*Sqrt)]]


where $z$ is actually complex.

For reasons I don't understand, Mathematica won't simplify this to $1$.

According to the documentation, Mathematica chooses the branch cut for $\sqrt{z}$ to lie along the negative real axis.

Am I missing something or getting something wrong?

Any help is much appreciated.

• You can try FullSimplify[Sqrt[Exp[-z/(4*Sqrt)]] Sqrt[Exp[z/(4*Sqrt)]], Assumptions -> {-Pi <= Im[z] <= Pi}]. – b.gates.you.know.what Apr 13 '18 at 14:43
• @b.gatessucks Thanks, that certainly gives $1$ as output but I shouldn't need to do assumptions, right? As far as I can see, the only condition you have for this simplification to be true is that the sum of the argument of both numbers is between -pi and pi, which is always true in this case... – Edu Apr 13 '18 at 14:55
• I'm voting to close this question as off-topic because the issue it raises is not really a Mathematica issue but a matter of the OP not having grasped the mathematics involved. – m_goldberg Apr 13 '18 at 15:22
• @m_goldberg Could you at least point out the mistake(s), please? – Edu Apr 13 '18 at 15:31
• I think that b.gatessucks comment already does that. – m_goldberg Apr 13 '18 at 16:01

(Michael already gave a good answer, but I'll leave mine here as it includes a few extra observations)

This is a tricky question. First, here's a counterexample:

expr = Sqrt[Exp[-z/(4*Sqrt)]] Sqrt[Exp[z/(4*Sqrt)]];

FullSimplify[expr /. z->4 Sqrt Pi I]


-1

Next, using PowerExpand as @Ulrich did:

PowerExpand[expr, Assumptions->True]
% //TeXForm


E^(I π (Floor[1/2 - Im[z]/(8 Sqrt π)] + Floor[1/2 + Im[z]/(8 Sqrt π)]))

$\exp \left(i \pi \left(\left\lfloor \frac{1}{2}-\frac{\Im(z)}{8 \sqrt{2} \pi }\right\rfloor +\left\lfloor \frac{\Im(z)}{8 \sqrt{2} \pi }+\frac{1}{2}\right\rfloor \right)\right)$

The arguments of the Floor expressions are always real. Here is a plot of them:

Plot[{Floor[1/2 - x], Floor[1/2 + x]}, {x, -3, 3}] It would seem that the sum of the two Floor expressions should be 0. However, it turns out that the endpoints are not consistent. For example:

Reduce[Floor[1/2 - x] == 1, x, Reals]
Reduce[Floor[1/2 + x] == -1, x, Reals]


-(3/2) < x <= -(1/2)

-(3/2) <= x < -(1/2)

So, at the points n+1/2 the sum is not 0. Another way to see this is to use NumberLinePlot:

NumberLinePlot[Floor[1/2-x] + Floor[1/2+x] == 0, {x, -3, 3}] Summarizing, your expression is almost always equal to 1, except when the imaginary part of z is $8 \sqrt{2} \pi \left(n+\frac{1}{2}\right)$ for integer $n$.

For $z = 4 \sqrt{2} \pi i$, we have $$\sqrt{e^{-z/4 \sqrt{2}}} = \sqrt{e^{-i\pi}} = \sqrt{-1} = i,$$ and $$\sqrt{e^{z/4 \sqrt{2}}} = \sqrt{e^{i\pi}} = \sqrt{-1} = i.$$ So the product of the two square roots is $-1$ in this one case. Note that in this case, $$\arg e^{-z/4 \sqrt{2}} \neq -\frac{\Im(z)}{4 \sqrt{2}},$$ since $\arg (e^{-i \pi}) = \arg (-1) = \pi$, not $-\pi$.

In general, your desired simplification is true so long as $$\frac{\Im(z)}{4 \sqrt{2} \pi} \neq 1 \mod 2.$$ Unfortunately, I haven't been able to find a way to use Assumptions to tell Mathematica to assume this. As b.gatessucks notes in the comments, we can write

Simplify[Sqrt[Exp[-z/(4*Sqrt)]] Sqrt[Exp[z/(4*Sqrt)]],
Assumptions -> {-4 Sqrt Pi < Im[z] < 4 Sqrt Pi}]


which does simplify to 1. But this should also simplify to one if {4 Sqrt Pi < Im[z] < 12 Sqrt Pi}, and using this for our Assumptions doesn't lead to a simplification. It may be that Mathematica isn't programmed to accept such a condition.

PowerExpand only shows one solution

PowerExpand[Sqrt[Exp[-z/(4*Sqrt)]] Sqrt[Exp[z/(4*Sqrt)]],Assumptions -> Element[z, Reals]]
(* 1*)
PowerExpand[Sqrt[Exp[-z/(4*Sqrt)]] Sqrt[Exp[z/(4*Sqrt)]],Assumptions -> Element[z, Complexes]]
(*E^(I \[Pi] (Floor[1/2 - Im[z]/(8 Sqrt \[Pi])] +Floor[1/2 + Im[z]/(8 Sqrt \[Pi])])) *)


Complex simplification Substituting the complex number z=(a+I b)/(4*Sqrt)]] the question is how to simplify the expression

expr=Sqrt[Exp[-a-I b]]Sqrt[Exp[a+I b]]


The roots can be written as

Sqrt[Exp[a+I b]]==\[PlusMinus] Exp[a/2]Exp[I b/2]
Sqrt[Exp[-a-I b]]==\[PlusMinus] Exp[-a/2]Exp[-I b/2]


and the product evaluates to

expr=Sqrt[Exp[a+I b]]Sqrt[Exp[-a-I b]]==\[PlusMinus]1


two possible values +1and -1.

• $\sqrt{zw} = \sqrt{z} \sqrt{w}$ is true only when $-\pi<Arg(z)+Arg(w)\le\pi$. Considering $z$ and $w$ the two exponentials of my example, their arguments are respectively ${Im(z)\over 4\sqrt{2}}$ and ${-Im(z)\over 4\sqrt{2}}$, so the condition holds, doesn't it? – Edu Apr 13 '18 at 15:27
• The square root of a complex number has two solutions! – Ulrich Neumann Apr 13 '18 at 15:42
• The square root of any number has two solutions. My earlier comment addresses how to solve the ambiguity. – Edu Apr 13 '18 at 15:46
ComplexPlot3D[
Sqrt[Exp[-z/(4*Sqrt)]] Sqrt[Exp[z/(4*Sqrt)]], {z, -2 \[Pi] -
2 \[Pi] I, 2 \[Pi] + 2 \[Pi] I}, PlotLegends -> Automatic] Mathematica chooses the branch cut for 𝑧√ to lie along the negative real axis and the first value is {0,0} and this is 1.

This asks whether to trust PowerExpand or ComlexExpand.

Refine[Re[
ComplexExpand[
Sqrt[Exp[-(x + I y)/(4*Sqrt)]] Sqrt[Exp[(x + I y)/(4*Sqrt)]],
TargetFunctions -> {Abs, Arg}]], Element[{x, y}, Reals]]


-Im[Cos[1/2 ArcTan[Cos[y/(4 Sqrt)], Sin[y/(4 Sqrt)]]] Sin[
1/2 ArcTan[Cos[y/(4 Sqrt)], -Sin[y/(4 Sqrt)]]] +
Cos[1/2 ArcTan[Cos[y/(4 Sqrt)], -Sin[y/(4 Sqrt)]]] Sin[
1/2 ArcTan[Cos[y/(4 Sqrt)], Sin[y/(4 Sqrt)]]]] +
Re[Cos[1/2 ArcTan[Cos[y/(4 Sqrt)], -Sin[y/(4 Sqrt)]]] Cos[
1/2 ArcTan[Cos[y/(4 Sqrt)], Sin[y/(4 Sqrt)]]] -
Sin[1/2 ArcTan[Cos[y/(4 Sqrt)], -Sin[y/(4 Sqrt)]]] Sin[
1/2 ArcTan[Cos[y/(4 Sqrt)], Sin[y/(4 Sqrt)]]]]


Refine[Im[
ComplexExpand[
Sqrt[Exp[-(x + I y)/(4*Sqrt)]] Sqrt[Exp[(x + I y)/(4*Sqrt)]],
TargetFunctions -> {Abs, Arg}]], Element[{x, y}, Reals]]


Im[Cos[1/2 ArcTan[Cos[y/(4 Sqrt)], -Sin[y/(4 Sqrt)]]] Cos[
1/2 ArcTan[Cos[y/(4 Sqrt)], Sin[y/(4 Sqrt)]]] -
Sin[1/2 ArcTan[Cos[y/(4 Sqrt)], -Sin[y/(4 Sqrt)]]] Sin[
1/2 ArcTan[Cos[y/(4 Sqrt)], Sin[y/(4 Sqrt)]]]] +
Re[Cos[1/2 ArcTan[Cos[y/(4 Sqrt)], Sin[y/(4 Sqrt)]]] Sin[
1/2 ArcTan[Cos[y/(4 Sqrt)], -Sin[y/(4 Sqrt)]]] +
Cos[1/2 ArcTan[Cos[y/(4 Sqrt)], -Sin[y/(4 Sqrt)]]] Sin[
1/2 ArcTan[Cos[y/(4 Sqrt)], Sin[y/(4 Sqrt)]]]]


So the product does only depend on y or Im[z].

Plot[{Cos[1/2 ArcTan[Cos[y/(4 Sqrt)], Sin[y/(4 Sqrt)]]] Sin[
1/2 ArcTan[Cos[y/(4 Sqrt)], -Sin[y/(4 Sqrt)]]] +
Cos[1/2 ArcTan[Cos[y/(4 Sqrt)], -Sin[y/(4 Sqrt)]]] Sin[
1/2 ArcTan[Cos[y/(4 Sqrt)], Sin[y/(4 Sqrt)]]],
Cos[1/2 ArcTan[Cos[y/(4 Sqrt)], -Sin[y/(4 Sqrt)]]] Cos[
1/2 ArcTan[Cos[y/(4 Sqrt)], Sin[y/(4 Sqrt)]]] -
Sin[1/2 ArcTan[Cos[y/(4 Sqrt)], -Sin[y/(4 Sqrt)]]] Sin[
1/2 ArcTan[Cos[y/(4 Sqrt)],
Sin[y/(4 Sqrt)]]]}, {y, -6 \[Pi], 6 \[Pi]}] Since the solution of the others this must be the solution.

Plot[{Cos[1/2 ArcTan[Cos[y/(4 Sqrt)], -Sin[y/(4 Sqrt)]]] Cos[
1/2 ArcTan[Cos[y/(4 Sqrt)], Sin[y/(4 Sqrt)]]] -
Sin[1/2 ArcTan[Cos[y/(4 Sqrt)], -Sin[y/(4 Sqrt)]]] Sin[
1/2 ArcTan[Cos[y/(4 Sqrt)], Sin[y/(4 Sqrt)]]],
Cos[1/2 ArcTan[Cos[y/(4 Sqrt)], Sin[y/(4 Sqrt)]]] Sin[
1/2 ArcTan[Cos[y/(4 Sqrt)], -Sin[y/(4 Sqrt)]]] +
Cos[1/2 ArcTan[Cos[y/(4 Sqrt)], -Sin[y/(4 Sqrt)]]] Sin[
1/2 ArcTan[Cos[y/(4 Sqrt)],
Sin[y/(4 Sqrt)]]]}, {y, -6 \[Pi], 6 \[Pi]}] This shows the same plot with swapped coloring.

ReImPlot[Refine[
Im[ComplexExpand[
Sqrt[Exp[-(x + I y)/(4*Sqrt)]] Sqrt[
Exp[(x + I y)/(4*Sqrt)]], TargetFunctions -> {Abs, Arg}]],
Element[x, Reals] && Element[y, Reals]], {y, -6 \[Pi], 6 \[Pi]}] ReImPlot[Refine[
Re[ComplexExpand[
Sqrt[Exp[-(x + I y)/(4*Sqrt)]] Sqrt[
Exp[(x + I y)/(4*Sqrt)]], TargetFunctions -> {Abs, Arg}]],
Element[x, Reals] && Element[y, Reals]], {y, -6 \[Pi], 6 \[Pi]}] separates the situation for the Im and the Re part.

So Mathematica makes a mistake in doing the branch cut. The term is indeed still an identity as if the argument were pure Reals. The last ReImPlot shows the term more complicated and delicate. The plot does not change must if the interval is taken smaller. So the value can be both 0 and 1 at the same time.

Why does Mathematica draw the graph for the solution 1 as a single line and the solution 0 as dotted? It separated the Re part a line and the Im as dotted by the default style. Mathematica did make the y out of the Complexes again as in the result of the Refine. But y is Reals.

    PowerExpand[
Sqrt[Exp[-(x + I y)/(4*Sqrt)]] Sqrt[Exp[(x + I y)/(4*Sqrt)]],
Assumptions -> True]

(*E^((-x - I y)/(8 Sqrt) + (x + I y)/(8 Sqrt) +
I \[Pi] (Floor[
1/2 - Im[x]/(8 Sqrt \[Pi]) - Re[y]/(8 Sqrt \[Pi])] +
Floor[1/2 + Im[x]/(8 Sqrt \[Pi]) + Re[y]/(8 Sqrt \[Pi])]))*)

PowerExpand[
Sqrt[Exp[-(x + I y)/(4*Sqrt)]] Sqrt[Exp[(x + I y)/(4*Sqrt)]]]


(* E^((-x - I y)/(8 Sqrt2) + (x + I y)/(8 Sqrt2)) *)

Do this assumption treat the parameters correct as Reals each? My judgement is Yes it does and the ComplexPlot3D is correct.

Plot3D[Floor[
1/2 - Im[x]/(8 Sqrt \[Pi]) - Re[y]/(8 Sqrt \[Pi])] +
Floor[1/2 + Im[x]/(8 Sqrt \[Pi]) + Re[y]/(
8 Sqrt \[Pi])], {x, -1, 1}, {y, -1, 1}] PowerExpand[
Sqrt[Exp[-(x + I y)/(4*Sqrt)]] Sqrt[Exp[(x + I y)/(4*Sqrt)]],
Assumptions -> True] // FullSimplify


(* (-1)^(Floor[1/2 - (Im[x] + Re[y])/(8 Sqrt2 [Pi])] + Floor[1/16 (8 + (Sqrt2 (Im[x] + Re[y]))/[Pi])]) *)

and not to much simplified.

There are question for simplifying trigonometrics on mathematica.stackexchange.com. .