2
$\begingroup$

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?

$\endgroup$
2
  • 4
    $\begingroup$ 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 $\endgroup$
    – Bob Hanlon
    Feb 1, 2020 at 20:54
  • $\begingroup$ @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... $\endgroup$
    – Chris K
    Feb 1, 2020 at 22:17

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.