# Same output always from different cells?

**URL:** <https://community.wolfram.com/t/same-output-always-from-different-cells/19010>\
**Category:** Questions\
**Tags:** graphics-and-visualization, interface-construction\
**Created:** [October 22, 2021, 6:52pm UTC](https://community.wolfram.com/t/same-output-always-from-different-cells/19010 "2021-10-22T18:52:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![cormacburke92](https://avatars.discourse-cdn.com/v4/letter/c/45deac/32.png) [@cormacburke92](https://community.wolfram.com/u/cormacburke92)\
**Post date:** [October 22, 2021, 6:52pm UTC](https://community.wolfram.com/t/same-output-always-from-different-cells/19010/1 "2021-10-22T18:52:43Z")

</div>

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.

[3foldSymmetryWaves\_OP\_ problem \_CP\_.nb](https://community.wolfram.com/uploads/short-url/jZMZWp5dMO01B28P1yNBKxjuQCC.nb) (23.2 KB)

---

<div class="post-metadata">

**Author:** ![gianlucagorni](https://avatars.discourse-cdn.com/v4/letter/g/ec9cab/32.png) [@gianlucagorni](https://community.wolfram.com/u/gianlucagorni)\
**Post date:** [October 22, 2021, 7:12pm UTC](https://community.wolfram.com/t/same-output-always-from-different-cells/19010/2 "2021-10-22T19:12:34Z")

</div>

Try isolating each `Manipulate` inside `DynamicModule[{fun},]` so that there is no interference between the two panels.

---

<div class="post-metadata">

**Author:** ![rohitnamjoshi](https://avatars.discourse-cdn.com/v4/letter/r/f1d935/32.png) [@rohitnamjoshi](https://community.wolfram.com/u/rohitnamjoshi)\
**Post date:** [October 22, 2021, 8:45pm UTC](https://community.wolfram.com/t/same-output-always-from-different-cells/19010/3 "2021-10-22T20:45:32Z")

</div>

> 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.

---

<div class="post-metadata">

**Author:** ![hansmilton](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/hansmilton/32/8656_2.png) [@hansmilton](https://community.wolfram.com/u/hansmilton)\
**Post date:** [October 23, 2021, 11:24am UTC](https://community.wolfram.com/t/same-output-always-from-different-cells/19010/4 "2021-10-23T11:24:20Z")

</div>

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:

Before

![Before.PNG](https://global.discourse-cdn.com/wolfram/original/3X/d/8/d8e80e9fbc525ab6d0eaa4f1ff3902cb96208853.png)

After

 ![After.PNG](https://global.discourse-cdn.com/wolfram/original/3X/8/5/85ea7f49cef39e9b68c605a2d5981766ec190797.png)

---

<div class="post-metadata">

**Author:** ![cormacburke92](https://avatars.discourse-cdn.com/v4/letter/c/45deac/32.png) [@cormacburke92](https://community.wolfram.com/u/cormacburke92)\
**Post date:** [October 25, 2021, 10:57am UTC](https://community.wolfram.com/t/same-output-always-from-different-cells/19010/5 "2021-10-25T10:57:56Z")

</div>

My problem is solved. Many thanks to Gianluca, Rohit and Hans for taking the time to dig me out of a hole.
