Clearing symbol values, removing symbols from memory and general garbage collection.

learn more… | top users | synonyms

40
votes
2answers
2k views

Is there a way to separate variables between multiple notebooks?

I often correct homework by checking the calculations in Mathematica. Sometimes you would like to have two solutions open at once. However often defined symbols such as ...
25
votes
5answers
11k views

How do I clear all user defined symbols?

Is there some way to do this other than going to Evaluation -> Quit kernel and firing a new one up?
24
votes
5answers
2k views

Clear complains that a subscripted variable is not a symbol or a string?

Here's a small listing where I've used EscqEsc to typeset θ in the notebook: ...
17
votes
3answers
707 views

How to clear parts of a memoized function?

I have a function of two variables, e.g.: f[a_, b_] := f[a, b] = something f[a - 1, b - 1] etc With the above code I used the concept of memoization to speed up ...
14
votes
6answers
1k views

How to clear all variables except one?

I have a lot of variables: $a,b,c,d, \ldots $ I want to clear the values of all of them except $b$. It's really lengthy to write Clear[a]; Clear[c]; ... Is ...
12
votes
1answer
263 views

Is it possible to Clear all variables (but not functions)?

I have written a Mathematica script in which I define functions and variables. Here is a vastly simplified example: ...
11
votes
3answers
1k views

Elegant manipulation of the variables list

I have a list of global variables (some of them are indexed variables), for example: varsH = Hold[U0[1], U0[2], B0, V0[1], V0[2]] Or (if it is easier to handle) ...
11
votes
2answers
927 views

How to unload automatically loaded packages?

I know that this has been discussed here (How do I clear all user defined symbols?), but my case is somewhat different. How does one unload packages during runtime that were loaded with the start of ...
7
votes
2answers
745 views

How to clear just variables defined in one notebook?

I'm trying to set up some notebooks so that I have one "seed" notebook that defines all my values globally when I run it. I have three other notebooks that take these values and run with them to do ...
7
votes
1answer
194 views

ClearAll just for current notebook

So in my search to fine tune Mathematica to what works for me, I found a nice setting that helps separate variable declaration between notebooks. Under Global Preferences, searching for CellContext ...
7
votes
1answer
120 views

ClearAll[“Global`*”] stops working with Context set to 'unique to this Notebook'

I just changed my default notebook context to 'unique to this Notebook' so that variables don't roll across numerous open notebooks. Doing this, however, made the command ClearAll["Global*"] stop ...
6
votes
1answer
115 views

Garbage collection for memoized functions on subkernels

I have a top-level function which operates on some data: findBestIntegers[data_]:=ParallelMap[optimize,data] which makes parallelized calls to an optimization ...
5
votes
1answer
127 views

Remove Removed From Output

How might I remove Removed[..] symbols from the output of an expression? For example Clear[b]; b := Sin[a + a]; Remove[a]; b ...
5
votes
1answer
498 views

Clear and Unset doesn't free memory

Example: Try this example only if you have > 4G ram d = 2000; f[x_, y_, d_] = Sum[Subscript[a, i, j]*x^i*y^j, {i, 0, d - 1}, {j, 0, d - i}]; Then ...
4
votes
2answers
542 views

Error entering equation in DSolve

I entered a command incorrectly as follows: DSolve[{y'[x]=y[x]},y[x],x] I am now experiencing: ...
3
votes
2answers
137 views

Unset while running recursion

I am trying to run a recursive definition while at the same time clearing previously found values, so my memory is not completely consumed. I found this: How to clear parts of a memoized function? ...
1
vote
1answer
265 views

Why my differential equations become True?

I've been trying to solve a system of nonlinear differential equation, but the conditions are a bit weird. Two of the differentials equate to the same equation, but have different boundary ...
1
vote
1answer
75 views

Do I need to clear all definitions whenever I experiment with new parameter values?

Do I have to clear all my definitions whenever I experiment with different parameter values for my model? For example, I have a simple model as follows: ...
1
vote
1answer
55 views

How to be sure I've cleaned up all prior definitions and assignments [duplicate]

Is there any general way besides restarting the kernel to make sure that nothing I've done earlier in a session will affect code I want to run now? One book suggested running ...
0
votes
2answers
2k views

How do I clear all variables with subscripts? [duplicate]

Possible Duplicate: Clear complains that a variable is not a symbol or a string? Clear["Global*"]` Works for most variables, however if i do something ...
0
votes
0answers
24 views

Accidentally used assigned a value to a string, cannot unassign it [duplicate]

I am using Mathematica for typesetting a homework assignment, and I accidentally assigned a value to a sort of complex variable (I typed = instead of ==). Here's what happens when I type it: Now I ...
0
votes
0answers
60 views

Using NSolve in a function, selecting one indexed result and using it to plot another function containing a function containing the indexed result

I have a problem using the result pcvar[g] g e (0,1) in the plot cvar1. In the plot cvar I can use it. It must be somehow connected to clearing p in the definition of pcvar[g]. I am gratefull for any ...