<s>[INST] Can I perform the quadratic formula on polynomial with complex coefficient? 2 weeks ago, we had a Math test on complex number. One of the question was:

Let $z=x+iy$ be a non-zero complex number, where $x,y \in \mathbb{R}$.
Given that $z+\frac{1}{z} = k$, where $k$ is a real number, show that if $y \neq 0$, then $| k | \leq 2$.

My friend had tried solving it this way (as follows), but instead of proving the above, she had gotten a contradiction!
$z+\frac{1}{z} = x+iy + \frac{1}{x+iy} = \frac{x^2 + 2xyi - y^2 + 1}{x+ iy} = k$.
This is equivalent to saying that
$x^2 + 2xyi - y^2 + 1 = k(x + iy) = kx + kyi$
Then, $x^2 + (2yi-k)x + (1-y^2-kyi)=0 $
Since we know that $x \in \mathbb {R}$, then the discriminant of this polynomial will be greater or equal to 0. Hence,
Discriminant $= (2yi-k)^2 - 4(1-y^2-kyi) = -4y^2 - 4kyi + k^2 - 4 + 4y^2+4kyi = k^2 - 4 \geq 0$.
Thus, we can conclude from the above that $k^2 \geq 4, |k| \geq 2$, which is incorrect!
Can anyone help us explain why this is so? (we know the answer and correct solution but are just perplexed with why a contradiction occurs when performing the above. we have asked the class and the teacher but they too couldn't provide a convincing answer...)
 [/INST] $$x^2-y^2+1+2xy(i)=xk+i(yk)$$
Equating the imaginary parts, $$yk=2xy\implies x=\frac k2\text{ as }y\ne0$$
Equating the real parts, $$x^2-y^2+1=xk\iff\frac{k^2}4-y^2+1=\frac{k^2}2\iff k^2=4(1-y^2)\le4$$
</s>