Mathematica Mathematica is remember variable values it shouldn't be

Click For Summary
In the discussion, a user experienced issues with variable assignments in Mathematica, noting that values defined later in the code were being applied to variables earlier in the notebook. This led to confusion about whether this behavior was a bug or a misunderstanding of the software's functionality. The user found that even with the Clear[] function used in the appropriate places, Mathematica still retained variable values. Ultimately, the user resolved the issue by correctly placing Clear[] commands for all relevant variables, realizing that once a variable is assigned a value, Mathematica retains that value unless explicitly cleared. The user concluded that the notebook interface does not follow a linear spatial logic, as it interacts with the kernel in a more complex manner.
rynlee
Messages
44
Reaction score
0
Hi There,

Once I put in values for variable farther down the code from when I first use them (I initially want them just in variable form, I don't want their values defined), every time I evaluate the cell mathematica puts the values in farther up.

Even more disturbing, however, is in other cells that are even above that cell, those variables get defined.

Even more disturbing, when I put the Clear[] function in the appropriate places, mathematica still assigns values to those variables!

Is this a bug? Or am I seriously misunderstanding something?

Thanks for any help or advice!
 
Physics news on Phys.org
Scratch that, I believe I got it working with appropriate Clear[]'s placed for all the variables of interest. It seems that once you put a value for a variable in and it is compiled, mathematica stores that value unless it is cleared?
 
That's right. The notebook is not spatially linear. In essence it's just a pretty interface to the kernel.
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 3 ·
Replies
3
Views
6K
  • · Replies 21 ·
Replies
21
Views
6K
  • · Replies 1 ·
Replies
1
Views
9K
  • · Replies 1 ·
Replies
1
Views
7K
  • · Replies 4 ·
Replies
4
Views
14K
  • · Replies 5 ·
Replies
5
Views
1K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 3 ·
Replies
3
Views
4K
  • · Replies 2 ·
Replies
2
Views
3K