# Does Wolfram Alpha solve this equation incorrectly?

I would like to solve $\left\lvert 1+e^{ix}+e^{iy} \right\rvert=z$ as a function of $y$

For $z \in [0,3]$ this equation has real solutions $x,y$. The level sets are closed curves (if $z \neq 0,1,3$), see for example $z=2$:

the contour plot for $z=2$

However, if I let wolframalpha solve this equation

it calculates the solutions

$$y(x,z)= -i \log(-e^{ix} \pm 1-1).$$ If I enter this function in Mathematica and plot it, the Imaginary part is even for admissible values of $x,z$ non-zero. So something is wrong here.

By the implicit function theorem I should be able to solve this equation for example $z=2$ locally w.r.t. $y$ as a function of $x$. Why does this fail here?

Edit: Apparently, the question boils down to the question. How do I have to interpret the solution $y(x,z)$ so that this makes sense in my context?

• There are two issues arising from how the question is asked, which is what probably leads to the different answers. First, you implicitly assume that $x,y$ are real, but the way you plugged the question in WA is asking WA (I think)for the complex solutions....Which explains why the answer can be different. The second issue is the log. WA probably means the multivalued log, the real solutions are most likely coming from 1 or 2 branches of it (I suspect 2 because of the shape of the curve). Mathematica might plot a different branch... – N. S. Mar 17 '17 at 19:51
• @N.S. is there a way to fix this, so that the solutions are correct? – J.Doe Mar 17 '17 at 20:48
• See the Edit I have placed in my answer where I gave an explicit cartesian form of the curves. – Jean Marie Mar 18 '17 at 7:23

My answer does not address the issue with WA, but shows how to obtain $y$ as a function of $x$ and parameter $z$.

• Firstly, your question in $\mathbb{C}$ can be transformed into a question in $\mathbb{R^2}$.

Here is how: using $|z|^2=z \bar z$, your constraint can be made equivalent to:

$$(1+e^{ix}+e^{iy})(1+e^{-ix}+e^{-iy})=z^2$$

By expanding it and using Euler formula for $cosine$, we obtain:

$$3+2\cos(x)+2\cos(y)+2\cos(x-y)=z^2$$

i.e., an implicit equation:

$$\tag{1}\cos(x)+\cos(y)+\cos(x-y)=k \ \ \text{with} \ \ k:=\dfrac{z^2-3}{2}$$

thus with $0 \leq k \leq 3.$

I have plotted with Matlab the curves corresponding to different values of $k$ (see below).

• In a second step, from implicit equation (1), one can obtain the explicit (cartesian) form:

$$\tag{2}y=2 \tan^{-1}\left[A\left(\sin(x)\pm \sqrt{\sin(x)^2-(1+k)(k-1-2\cos(x))}\right)\right] \ \ \text{where} \ A:=\dfrac{1}{1+k}.$$

Proof of (2): Using addition formula $\cos(x-y)=\cos(x)\cos(y)+\sin(x)\sin(y)$, (1) can be written under the form

$$\tag{3}\cos(y)(1+\cos(x))+\sin(y)\sin(x)=k-\cos(x)$$

Thanks to classical formulas :

$$\tag{4} \cos(y)=\dfrac{1-t^2}{1+t^2}, \sin(y)=\dfrac{2t}{1+t^2}$$

with

$$\tag{5} t=\tan \dfrac{y}{2},$$

(3) can be transformed into a quadratic equation with variable $t$:

$$t^2(1+k)-2t \sin(x)+(k-1-2\cos(x))=0$$

whose solutions are $t=A\left(\sin(x)\pm \sqrt{\sin(x)^2-(1+k)(k-1-2\cos(x))}\right)$

($A$ has been defined by (2)). Taking (5) into account, we obtain formulas (1).

(One should consider this picture as drawn on a torus).

• I have had à closer look at the solution that WA has given. It looks as if you had given the equation without the "absolute value" (modulus) symbols. – Jean Marie Mar 18 '17 at 11:40
• Slightly connected:(math.stackexchange.com/q/1419019) – Jean Marie Mar 18 '17 at 20:16
• Very connected: a question that I have asked some time ago (math.stackexchange.com/q/1982170) – Jean Marie Mar 23 '17 at 20:05