Solving for $k$: $\sqrt{k-\sqrt{k+x}}-x = 0$ 
$$\sqrt{k-\sqrt{k+x}}-x = 0$$
Solve for $k$ in terms of $x$

I got all the way to
$$x^{4}-2kx^{2}-x+k^{2}-x^{2}$$
but could not factor afterwards. My teacher mentioned that there was grouping involved
Thanks Guys!
Edit 1 : The exact problem was solve for $x$ given that $$\sqrt{4-\sqrt{4+x}}-x = 0$$ with a hint of substitute 4 with k
 A: As discovered $\sqrt{k - \sqrt{k+x}} = x$ leads to the equation $k^2 - (2 \, x^2 + 1) \, k + (x^4 - x) = 0$. Now,
\begin{align}
k &= \frac{1}{2} \, \left[(2 \, x^2 + 1) \pm \sqrt{ (2 \, x^2 + 1)^2 - 4 \, (x^4 - x) } \right] \\
&= \frac{1}{2} \, [(2 \, x^2 + 1) \pm (2 x + 1)] \\
&= \begin{cases}{ x^2 + x + 1 = \frac{1 - x^3}{1-x} \\ x(x-1) } \end{cases} 
\end{align} 
A: In this kind of problem, you have to be very careful about the domain of definition. Squaring the equation an find an equivalent polynomial equations is not enough, you need to verify if the solutions found are effective solutions of the original equation.
First two remarks : 


*

*$x=\sqrt{\cdots}\quad$ thus $x\ge 0$

*If $k<0$ then $k-\sqrt{k+x}<0$ and we cannot take the square root of this, so $k\ge 0$



In particular: with $x\ge 0$ and $k\ge 0$


*

*$\sqrt{x+k}$ is also well defined 

*$\sqrt{(x+a)^2}=x+a$ for any $a\ge 0$, we will use that property later.



The equation squared twice becomes $(x^2-k)^2=x+k$
$\iff k^2-k(2x^2+1)+(x^4-x)=0$ 
with $\Delta=(2x^2+1)^2-4(x^4-x)=(2x+1)^2$
So  $k=\frac 12(2x^2+1\pm(2x+1))=x(x-1)$ or $(x^2+x+1)$

Let's no substitute back in the original problem to eliminate superfluous solutions.


*

*$k=x(x-1)$


$\sqrt{k-\sqrt{k+x}}=\sqrt{x^2-x-\sqrt{x^2}}=\sqrt{x^2-x-x}=\sqrt{x^2-2x}$ 
This can be equal to $x$ if and only if $x=0\qquad$ [$x^2-2x=x^2\iff x=0$]


*

*$k=x^2+x+1$


$\sqrt{k-\sqrt{k+x}}=\sqrt{x^2+x+1-\sqrt{(x+1)^2}}=\sqrt{x^2+x+1-(x+1)}=\sqrt{x^2}=x$ 
So the equation is always verified

Finally the solutions are $(0,0)$ and $(x\ge 0,k=x^2+x+1)$

A: (Too long for a comment.)
As @Leucippus has shown, the solutions are
$$k \quad=\quad x^2 + x + 1 \qquad\text{or}\qquad x^2 - x$$
Thus,
$$k + x \quad=\quad (x+1)^2 \qquad\text{or}\qquad x^2$$
so that
$$\sqrt{k+x} \quad=\quad |x+1| \qquad\text{or}\qquad |x|$$
Further,
$$k - \sqrt{k+x} \quad=\quad x^2+x+1 - |x+1| \qquad\text{or}\qquad x^2-x-|x|$$
For us to get the perfect squares that we know we'll need, we require, in the first case, that $|x+1| = x+1$ (that is, $x \geq -1$); in the second case, $|x| = -x$ (that is, $x\leq 0$). These cause the above expressions to reduce to $x^2$. From there ...
$$\sqrt{k- \sqrt{k+x}}-x = \sqrt{x^2} - x = |x| - x$$
For this to vanish, we must have $x \geq 0$. So, the previous restrictions were not enough; rather, we have
$$k = \begin{cases} x^2 + x + 1 &, \text{for}\;x \geq 0 \\ 
x^2 - x &, \text{for}\; x = 0\end{cases}$$

Incidentally, the solutions tell us that we could have factored the expanded polynomial equation as
$$k^2 - 2 k x^2 + x^4 - k - x = 0 \qquad\to\qquad( k - x^2 - x - 1 )( k - x^2 + x ) = 0$$
I'm not seeing an "obvious" grouping that would've led me there. I believe I would've jumped right to the Quadratic Formula and allowed myself to be pleasantly surprised that the square root went away.
A: Let $\sqrt{k+x}=y$, where $y\geq0$.
Thus, $\sqrt{k-y}=x$, where $x\geq0$ and we got the following system.
$$k+x=y^2$$ and
$$k-y=x^2,$$
which gives
$$x+y=y^2-x^2$$ or
$$(x+y)(1+x-y)=0.$$
If $x+y=0$, then $x=y=k=0$ otherwise, $y=1+x$ and $k=x^2+x+1$.
Id est, we got the following answer.
If $x<0$ then our equation has no roots;
If $x=0$ then $\{0,1\}$;
If $x>0$ then $\{x^2+x+1\}$.
