# Manipulation of initial value of recurrence table

I am studying the behaviour of the recursive function defined by

$x_{n+1}=x_n-\frac{1}{x_n}$, $x_0=2$

To get a better understanding of it, I would like to be able to see the "transition" between plots for different values of $x_0$, while I can move $x_0$ freely between some values. My initial idea on how to achieve this, is to use the following code:

Manipulate[ListPlot[RecurrenceTable[
{a[n + 1] == a[n] - 1/a[n], a == t}, a, {n, 1000}]], {t, -3, 3}]


However, this code just makes Mathematica freeze a bit and then display \$Aborted in the manipulate window, not doing what I want it to do. Why does this not work? How could I approach this problem using different code?

I am using Mathematica 11.0.

Try this. The problem is that you initial setting takes toooo long to evaluate. There is a 5 seconds limit build in.

But may be you should also limit n to something lower than 1000 like 25 or so? (Updated it to use N@t in code below, instead of just t to make it load faster initially)

Manipulate[
ListPlot[f[t]],
{t, -3, 3},
SynchronousInitialization -> False,
TrackedSymbols :> {t},
Initialization :> (
f[t_] :=
RecurrenceTable[{a[n + 1] == a[n] - 1/a[n], a == N@t},
a, {n, 50}]
)
]  So before you had the default True and that is why it aborted • Hey thanks for your answer. You make a good point about the evaluation time, when using the integer 2, the eval time increases significantly for larger n. Somewhere between 25 and 30 it becomes uncomfortably large. That's why I put a 2. instead of a 2 in my original plot, which evaluated much, much quicker. Can something similar be done here to decrease the loading time? Oct 28, 2017 at 15:41
• @Tyron yes you can. Just changed the t to be numerical. Updated my answer. So you have to decide if you want t to by real or integer. With integer it is much slower to load initially and so you have to use SynchronousInitialization->False Oct 28, 2017 at 15:51
• @Nasser: In your answer above, you have a single difference equation: RecurrenceTable[{a[n + 1] == a[n] - 1/a[n], a == N@t}, a, {n, 50}]. Can you tell me how your code needs to be changed if you have, say, 10 recurrence equations. How would you replicate your code for this extended problem? Thanks.  Oct 29, 2018 at 3:24

Somehow the recursion poses a problem, but the iterative counterpart is rather straightforward. You can do

f[u_] := u - 1/u;
Manipulate[
a = {N@t};
Do[AppendTo[a, f[Last[a]]], 1000];
ListPlot[a, PlotRange -> {-50, 50}],
{t, -3, 3}]
` 