I write such a line in Mathematica:

{Slider[Dynamic[s]], Dynamic[f[x_] := s*x]}

After evaluation, the CPU immediately runs at full power. And if you scroll the page, it turns out that as soon as this line appear on the screen, the CPU begin to work. This really confused me a lot. Can anyone help?

  • $\begingroup$ Honestly, I believe this is a bug which probably never got detected because what you do doesn't make much sense. Slight variations which make more sense (e.g. { Slider[Dynamic[y]], Slider[Dynamic[s]], Dynamic[f[x_] := s*x; f[y]]}) show the same behavior, so you might want to report it as a possible bug... $\endgroup$ Jan 6, 2013 at 11:46

1 Answer 1


The spot where Dynamic[x] is on the screen only gets to do anything when this spot itself is actually visible on the screen. i.e. x gets tracked and all dependent expressions on it are updated, when the spot on the screen itself where the evaluated output of Dynamic[x] is visible. If you hide the Mathematica window with another window for example, Dynamic will not update any more.

So, when you scroll down or up, the front-end does not bother any more updating that spot on the screen.

Now why it runs at full speed. First, I really do not understand what you mean by Dynamic[f[x_] := s*x]. What exactly are you trying to do with this? One applies Dynamic on symbols and expressions, not on a delayed function definition as you are doing.

My guess on why FE goes to a loop, is that it is evaluating this expression over and over since it depends on s which is dynamic since you set the whole expression as Dynamic.

But all what you have to do is

{Slider[Dynamic[s]], Dynamic[s]}
f[x_] := s*x

and now if you type f[6] then change the slider, and retype f[6] again, then you'll see that you get a new value returned, since it used the updated value of s.

And if you type

Dynamic[y = s] 

in another place, and then move the slider, you'll see that this spot on the screen update on its own, since you marked this spot as Dynamic, then FE will now refresh y automatically when s changes.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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