what is the difference between xq and xf
That difference is 999....
In the top half, you solve an ODE, resulting in a function y(x).
You plot that function for values of x ranging from 0 to x.f
where x.f is defined as being 1000.
In the bottom half, the following problem is solved :
For which value of x is it that y(x)=1000 ?
You start with a guess value x.g set to 1.
Once found it appears to be 29.734, as shown by find(x.q)=29.734
You did not assign the result of the find() to anything, so
x.q is still 1, and the difference between x.f and x.q is 1000-1=999.