4
$\begingroup$

The output of RecurrenceTable seems to lose a level when there are more than 250 points and one variable. Easiest to explain with an example:

Good:

RecurrenceTable[{n[t + 1] == 2 (1 - n[t]) n[t], n[0] == 0.1}, {n}, {t, 0, 249}]

(* {{0.1}, {0.18}, {0.2952}, {0.416114}, {0.485926}, {0.499604}, {0.5}, {0.5}, ... {0.5}} *)

Bad:

RecurrenceTable[{n[t + 1] == 2 (1 - n[t]) n[t], n[0] == 0.1}, {n}, {t, 0, 250}]

(* {{0.1}, 0.18, 0.2952, 0.416114, 0.485926, 0.499604, 0.5, 0.5, ... 0.5} *)

Having more than one variable works as expected:

RecurrenceTable[{n[t + 1] == 2 (1 - n[t]) n[t], m[t + 1] == 2 (1 - m[t]) m[t], n[0] == 0.1, m[0] == 0.1}, {n, m}, {t, 0, 250}]

(* {{0.1, 0.1}, {0.18, 0.18}, {0.2952, 0.2952}, {0.416114, 0.416114}, {0.485926, 0.485926}, {0.499604, 0.499604}, {0.5, 0.5}, {0.5, 0.5}, ... {0.5, 0.5}} *)

I've found a couple easy workarounds for this minimal example (e.g. use n instead of {n}, use NestList instead of RecurrenceTable), but I've got RecurrenceTable embedded in a general function that requires both a list of dependent variables and doesn't play well with NestList. I just wanted to see if others have this same issue, which I'll report to WRI. I'm using Mathematica 11.0.1 on MacOS 10.12.

$\endgroup$
  • 6
    $\begingroup$ It's a bug. For a workaround, try Method -> {Compiled -> False}. $\endgroup$ – ilian Oct 10 '16 at 15:53
  • $\begingroup$ @ilian Brilliant, thanks! $\endgroup$ – Chris K Oct 10 '16 at 16:05
0
$\begingroup$

@ilian's fix in comments above works fine: add Method -> {Compiled -> False}. I've also reported to WRI.

$\endgroup$

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.