5
$\begingroup$

After some computations I end up with the following expression:

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

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.

$\endgroup$
5
  • 1
    $\begingroup$ You can try FullSimplify[Sqrt[Exp[-z/(4*Sqrt[2])]] Sqrt[Exp[z/(4*Sqrt[2])]], Assumptions -> {-Pi <= Im[z] <= Pi}]. $\endgroup$ Apr 13, 2018 at 14:43
  • $\begingroup$ @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... $\endgroup$
    – Edu
    Apr 13, 2018 at 14:55
  • 1
    $\begingroup$ 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. $\endgroup$
    – m_goldberg
    Apr 13, 2018 at 15:22
  • 1
    $\begingroup$ @m_goldberg Could you at least point out the mistake(s), please? $\endgroup$
    – Edu
    Apr 13, 2018 at 15:31
  • $\begingroup$ I think that b.gatessucks comment already does that. $\endgroup$
    – m_goldberg
    Apr 13, 2018 at 16:01

4 Answers 4

10
$\begingroup$

(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[2])]] Sqrt[Exp[z/(4*Sqrt[2])]];

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

-1

Next, using PowerExpand as @Ulrich did:

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

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

$\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}]

enter image description here

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}]

enter image description here

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$.

$\endgroup$
7
$\begingroup$

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[2])]] Sqrt[Exp[z/(4*Sqrt[2])]], 
         Assumptions -> {-4 Sqrt[2] Pi < Im[z] < 4 Sqrt[2] Pi}]

which does simplify to 1. But this should also simplify to one if {4 Sqrt[2] Pi < Im[z] < 12 Sqrt[2] 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.

$\endgroup$
1
$\begingroup$

PowerExpand only shows one solution

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

Complex simplification Substituting the complex number z=(a+I b)/(4*Sqrt[2])]] 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.

$\endgroup$
3
  • $\begingroup$ $\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? $\endgroup$
    – Edu
    Apr 13, 2018 at 15:27
  • $\begingroup$ The square root of a complex number has two solutions! $\endgroup$ Apr 13, 2018 at 15:42
  • $\begingroup$ The square root of any number has two solutions. My earlier comment addresses how to solve the ambiguity. $\endgroup$
    – Edu
    Apr 13, 2018 at 15:46
0
$\begingroup$
ComplexPlot3D[
 Sqrt[Exp[-z/(4*Sqrt[2])]] Sqrt[Exp[z/(4*Sqrt[2])]], {z, -2 \[Pi] - 
   2 \[Pi] I, 2 \[Pi] + 2 \[Pi] I}, PlotLegends -> Automatic]

ComplexPlot3D

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[2])]] Sqrt[Exp[(x + I y)/(4*Sqrt[2])]],
    TargetFunctions -> {Abs, Arg}]], Element[{x, y}, Reals]]

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

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

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

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

Plot[{Cos[1/2 ArcTan[Cos[y/(4 Sqrt[2])], Sin[y/(4 Sqrt[2])]]] Sin[
     1/2 ArcTan[Cos[y/(4 Sqrt[2])], -Sin[y/(4 Sqrt[2])]]] + 
   Cos[1/2 ArcTan[Cos[y/(4 Sqrt[2])], -Sin[y/(4 Sqrt[2])]]] Sin[
     1/2 ArcTan[Cos[y/(4 Sqrt[2])], Sin[y/(4 Sqrt[2])]]], 
  Cos[1/2 ArcTan[Cos[y/(4 Sqrt[2])], -Sin[y/(4 Sqrt[2])]]] Cos[
     1/2 ArcTan[Cos[y/(4 Sqrt[2])], Sin[y/(4 Sqrt[2])]]] - 
   Sin[1/2 ArcTan[Cos[y/(4 Sqrt[2])], -Sin[y/(4 Sqrt[2])]]] Sin[
     1/2 ArcTan[Cos[y/(4 Sqrt[2])], 
       Sin[y/(4 Sqrt[2])]]]}, {y, -6 \[Pi], 6 \[Pi]}]

Plot of the Im and the Re part of the Re part of the term

Since the solution of the others this must be the solution.

Plot[{Cos[1/2 ArcTan[Cos[y/(4 Sqrt[2])], -Sin[y/(4 Sqrt[2])]]] Cos[
     1/2 ArcTan[Cos[y/(4 Sqrt[2])], Sin[y/(4 Sqrt[2])]]] - 
   Sin[1/2 ArcTan[Cos[y/(4 Sqrt[2])], -Sin[y/(4 Sqrt[2])]]] Sin[
     1/2 ArcTan[Cos[y/(4 Sqrt[2])], Sin[y/(4 Sqrt[2])]]], 
  Cos[1/2 ArcTan[Cos[y/(4 Sqrt[2])], Sin[y/(4 Sqrt[2])]]] Sin[
     1/2 ArcTan[Cos[y/(4 Sqrt[2])], -Sin[y/(4 Sqrt[2])]]] + 
   Cos[1/2 ArcTan[Cos[y/(4 Sqrt[2])], -Sin[y/(4 Sqrt[2])]]] Sin[
     1/2 ArcTan[Cos[y/(4 Sqrt[2])], 
       Sin[y/(4 Sqrt[2])]]]}, {y, -6 \[Pi], 6 \[Pi]}]

Plotting the Im part

This shows the same plot with swapped coloring.

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

ReImPlot of Im

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

ReImPlot

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[2])]] Sqrt[Exp[(x + I y)/(4*Sqrt[2])]], 
     Assumptions -> True]

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

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

(* 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[2] \[Pi]) - Re[y]/(8 Sqrt[2] \[Pi])] + 
  Floor[1/2 + Im[x]/(8 Sqrt[2] \[Pi]) + Re[y]/(
    8 Sqrt[2] \[Pi])], {x, -1, 1}, {y, -1, 1}]

Plot3D of the Floor function in the expansion of PowerExpand over 2D Reals

PowerExpand[
  Sqrt[Exp[-(x + I y)/(4*Sqrt[2])]] Sqrt[Exp[(x + I y)/(4*Sqrt[2])]], 
  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. .

$\endgroup$

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.