# RecurrenceTable - does it have a solution search option like FindRoot?

I have a second-order non-linear difference equation like $$0=f(x_{t+2},x_{t+1},x_t)$$ where $x_{t+2}$ is implicitly determined. I have tried the code like

RecurrenceTable[{0 == f(x[t+2],x[t+1],x[t]), x == 0.4, x == 0.4}, x, {t, 0, 2}]


where t=0,1,2 and the two initial values are given. But, Mathematica 10 does not stop calculating for more than 10min, and I gave up.

So, I wonder if there is an option for RecurrenceTalbe which specifies the initial value for searching a root and stop searching once it gets outside a given range (I know there is a unique solution for $x_{2}>0$). A similar option exists for FindRoot:

FindRoot[lhs==rhs,{x,x_{start},x_{min},x_{max}}]


I am a newbie. Your help would be greatly appreciated.

What I came up is basically the following:

Assume that $f(x_{t+2},x_{t+1},x_t)$ is explicitly specified and that $x_{t+2}$ is uniquely (and implicitly) determined, given $x_{t+1}$ and $x_t$.

xFun[x2_,x1_,x0_]=f(x2,x1,x0);
xValue[t_] :=
Module[{h},
h=h = Z0;
h[i_]:=h[i] = x /. FindRoot[0==xFun[x,h[i-1],h[i-2]],{x, Z00}];
h[t]
]


where Z0 is the initial value and Z00 is the starting value for searching a root. Then, xValue gives me the result I was looking for in the main question. What I really want is the sequence of $x_t$, which I can recover using

 Table[xValue[i], {i, 1, iEnd}]


I am not sure if the above code is efficient. But at least it serves my purpose at the moment.

As far as I con see, the eqns must be given in a more explicit form. See the documentation: "The eqns must be recurrence equations whose solutions over the range specified can be determined completely from the initial or boundary values given." In your first attempt you only gave the equation implicitly, this won´t work. Can you give us information about the function "f"? Maybe first solving the equation (f(...)==0) and then input the solutions to RecurrenceTable will work. But to give a detailed answer information about f is needed.

• Thanks for your comment. I added above what I came up with, given the constraint of my creativity. – T_T Nov 14 '14 at 14:03