Hello - I started having errors in notebooks making use of RecurrenceTables. I am running Mathmatica Version - “11.3.0 for Mac OS X x86 (64-bit) (March 7, 2018)”,
I have several notebooks making use of RecurrenceTable. These have been working for many months. All of a sudden they stopped working maybe after an update?
I have replicated the error by copy/pasting a RecurrenceTable example from the online help into a new and empty Notebook
I resolved the issue but I cannot say I understand what happened. Bottom line I had to close all workbooks and then kill the running instance of Mathmatica. Just closing all notebooks did not work.
I will chalk this one up to “who the heck knows why just be happy it’s working again”
I have found an interesting (yet unexplained) pattern. Maybe someone will have some insight.
I have two notebooks call them HAS-RT and NO-RT. HAS-RT has RecurrenceTables
Steps to create errors
1- Open and run HAS-RT all is ok. HAS-RT works as expected. Keep window open
2- Open and run NO-RT and all is ok. NO-RT works as expected.
3 - Immediately after running NO-RT the errors appear in HAS-RT
At this point I can no longer run HAS-RT unless I close all notebooks and kill the kernel
This only happens with these two notebooks. Other notebooks opened along with HAS_RT does not cause this issue.
I do not see any common components between these two workbooks. But somehow NO-RT is stepping on HAS-RT
I also have a ticket open with technical support on this. But if anyone has any idea I would love to hear them
I suppose that this is not really a matter of “who the heck knows why just be happy it’s working again”. If you open two notebooks they will use the same kernel unless you explicitly specify using another kernel. That means that variable assignments in one notebook affect the definitions in the second notebook. As Gianluca says, RecurrenceTable does not protect its variable names.
In your case the n was probably somewhere defined to be 1. If you then want to use it as an iterator, it will (before the evaluation) be substituted by the value 1. Then the recurrence table does not have a valid iterator variable and does not work. Once you kill the kernel or clear the variables it will work again.
Cheers,
Marco
PS: If you post the two notebooks we can probably trace the problem down more directly.
Thank you to Marco and Gianluca for pointing me at the root cause and solution. But I will plead ignorance on how Mathematica is working under the covers. Maybe you can enlighten me or point me to documentation?
I added the Clear[n] to the offending notebook and presto! the problem resolved itself. And yes ‘n’ was in common between the two notebooks.
Question - I have “ClearAll;” as the first line of all my notebooks. Wouldn’t that clear ‘n’ also?
Question - Where can I read more about how the kernels interact? Specifically how variables are shared across notebooks?
But again thank you both for helping someone still earning.