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] == 0.4, x[1] == 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:


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$.

xValue[t_] :=
  h[1]=h[2] = Z0;
  h[i_]:=h[i] = x /. FindRoot[0==xFun[x,h[i-1],h[i-2]],{x, Z00}];

where Z0 is the initial value and Z00 is the starting value for searching a root. Then, xValue[3] 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.

|improve this answer|||||

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.

|improve this answer|||||
  • $\begingroup$ Thanks for your comment. I added above what I came up with, given the constraint of my creativity. $\endgroup$ – T_T Nov 14 '14 at 14:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.