2

One of my functions automatically generates systems for RecurrenceTable. Usually works fine, but today I encountered a problem. If the right-hand side is a constant, it doesn't evaluate:

RecurrenceTable[{n[t + 1] == 2, n[0] == 1}, n, {t, 0, 10}]
(* RecurrenceTable[{n[t + 1] == 2, n[0] == 1}, n, {t, 0, 10}] *)

One workaround I discovered:

RecurrenceTable[{n[t + 1] == 2 + Unevaluated[0 n[t]], 
  n[0] == 1}, n, {t, 0, 10}]
(* {1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2} *)

Are there others? Should this be considered a bug?

Chris K
  • 20,207
  • 3
  • 39
  • 74
  • 4
    There must be a recurrence equation. You could use RecurrenceTable[{n[t + 1] == 2 + a*n[t], n[0] == 1}, n[t], {t, 0, 10}] /. a -> 0 – Bob Hanlon Feb 01 '20 at 20:54
  • @BobHanlon It kind of is a recurrence equation, just a degenerate one! It's exactly the case that this arose when there was a a*n[t] term but a happened to equal zero. I'd like to avoid those intermediate algebraic results and just have it run numerically. Anyhow, I've uncovered some other unexpected issues with RecurrenceTable that will require a rethink on my part to solve... – Chris K Feb 01 '20 at 22:17

0 Answers0