Evaluate the upper cell and BOTH cells show output with 60deg triangles.
Evaluate the lower cell and BOTH cells show output like a patchwork quilt.
The upper cell should show 60deg triangles;
The lower cell should show a patchwork quilt.
How do I correct this intolerable situation?
I get this type of instability often when using Manipulate and Dynamic Updating. It often occurs across
different open Notebooks, ie evaluating a cell destabilizes the output of another cell in a different Notebook. Yet I have not seen any reference to this problem in Mma textbooks or online.
I hope someone can help me avoid this crippling problem.
It often occurs across different open Notebooks, ie evaluating a cell
destabilizes the output of another cell in a different Notebook
This happens if the symbols are in the Global context and both notebooks are running against the same kernel. Changing a value in one notebook changes the value in the other notebook.
One way to avoid this is to use notebook specific contexts.
(* Set permanently *)
CurrentValue[$FrontEnd, CellContext] = Notebook
(* Set for current session only *)
CurrentValue[$FrontEndSession, CellContext] = Notebook
When I share notebooks with others I usually include the latter as an Initialization cell so any definitions in the notebook do not pollute the Global context.
In your attached notebook the problem is that the symbol fun, that appears in both Manipulates, is global. Each Manipulate assigns a different value to fun. So fun in both Manipulates will always have the same value, according to the last evaluation. Each change of value triggers an update of both Manipulates.
To get around it fun should be localized. Gianluca has shown one way by using DynamicModule. Here is another way: