Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have the cells:

In[1]:= l = 2 + 2;

In[2]:= l >= 5

After evaluating them:

Out[2]:= False

Is there a way to evaluate all related cells, so if I change In[1] to l = 2 + 5, Out[2] would become True without evaluating the whole notebook?

share|improve this question
up vote 3 down vote accepted

Perhaps something along these lines could help?

$PrePrint= # /. 
         Except[Null] :> With[{line = $Line}, DynamicSetting@Dynamic@In[line]] /. 
    DownValues[In] &;

After running this, everything you evaluate is automatically wrapped in Dynamic so its value is updated automatically. I haven't tested it much so there may be issues.

(Be careful with endless dynamic updating loops)

share|improve this answer

You can try Dynamic(by the way, l = 2 + 5 won't make l >= 5 to be False…):

In[20]:= l = 1 + 3

Out[20]= 4

In[19]:= Dynamic[l >= 5]

Out[19]= False
share|improve this answer
I've fixed about comparison, and is their a way to do this for all cell, without wrapping in Dynamic explicitly? – m0nhawk May 5 '13 at 8:39
@m0nhawk No other easy way. You either tell each related cell to listen to a dynamic value by wrapping their contents in Dynamic OR you re-evaluate these cells. You can play with cell options, but Mathematica will never figure out on its own which cells it should update and which cells it shouldn't. – István Zachar May 5 '13 at 8:49
@m0nhawk Just as what István Zachar has pointed out. (At least I failed to find one 囧. ) – xzczd May 5 '13 at 9:01

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.