First, you need to change while(fabs(E2-E1) <= 0.001)
to while(fabs(E2-E1) > 0.001)
as was pointed out by MicroAlex.
The reason it still doesn't work is that the term sqrt(X-Y)
restricts the domain of your function F(X,Y)
to the interval [0, X]
unless you are prepared to deal with complex numbers (which you are not, obviously). With your starting point Y0=0
, you immediately get a new Y1=F(X,Y0)
outside the domain of your function. This is why it breaks after one iteration. As a matter of fact you're lucky it breaks since the behaviour of the loop condition is essentially undefined.
So the real problem lies in your numerical approach. The problem doesn't seem to yield to fixed-point iteration. What are you trying to do, actually?
edit
The reason why fixed-point iteration doesn't work is probably that the function is not Lipschitz-continuous (due to the sqrt term, but I haven't checked). You might be better off with trying a different root solver, like bisection with a start interval [0, X]