I am running Mathematica 11.

There is a wonderful 27 year old book called Exploring Mathematics with Mathematica, which does a lot of interesting mathematical stuff with version 2 of Mathematica.

One of the things it demonstrates is that as you nest Sin more and more deeply you get a nearly square wave. For example, here's what happens if you nest to a level of 1000

nested sine

It is then claimed that if you use Do to make a sequence of plots you will get an animation of the changes from the sine wave to the nearly square wave. However, when I copy the book's code to do this absolutely nothing happens. I don't even get a sequence of plots, let alone an animation.


So something must have changed between version 2 and version 11 so that Do no longer can be used to make animations. Moreover, apparently Mathematica does not guarantee backward compatibility.

Can someone explain why Do no longer works the way it apparently did?

  • $\begingroup$ try MapAt[ListAnimate, #, {2, 1}] &@Reap@Do[ Sow@Plot[Nest[Sin, x, n], {x, -2 Pi, 2 Pi}, PlotRange -> {-1, 1}, PlotLabel -> n], {n, 1, 50}] $\endgroup$
    – user42582
    Commented May 26, 2018 at 19:31
  • 1
    $\begingroup$ To make this work in version 6.0 and later, either change Do to ListAnimate@Table or change Do to Animate and change {n,1,50} to {n,1,50,1}. $\endgroup$
    – Szabolcs
    Commented May 26, 2018 at 20:42

3 Answers 3


There was a major overhaul of graphics in 2007 for V6, one aspect of which was that Mathematica switched from displaying graphics as a side-effect, to rendering directly in the notebook.

Since graphics are no longer a side effect, Do doesn't display the individual plots anymore.

Additionally, the interface to run the animation has been removed, at least on some platforms, since it's not really needed anymore and the maintenance cost for a rarely used feature was too high. On macOS, the keyboard shortcut, cmd-Y, worked through V9, even though there was no longer a menu item for it. In V10 the shortcut doesn't do anything anymore.

The current approach for this is either to use Manipulate, Animate, or ListAnimate.

  • 4
    $\begingroup$ "A rarely used feature" -- for the record, I used it all the time. I miss cmd-Y! $\endgroup$
    – Chris K
    Commented May 26, 2018 at 19:22
  • $\begingroup$ @ChrisK, "all the time", including in V6, 7, 8, ...? (Just curious.) $\endgroup$ Commented May 27, 2018 at 0:53
  • $\begingroup$ I can't say for sure, but I suppose I used it until the point when it quit working. I do remember thinking, "huh, what happened to cmd-Y?" $\endgroup$
    – Chris K
    Commented May 27, 2018 at 13:34
  • 2
    $\begingroup$ I miss it too. Its one of the reasons M8 is still my favorite $\endgroup$
    – Bill Watts
    Commented Jun 2, 2018 at 7:23

Need to add Print, then it works, as far as plotting all the graphics, but the option to animate those graphics has been removed.

Do[Print[Plot[Nest[Sin, x, n], {x, -2 Pi, 2 Pi}, PlotRange -> {-1, 1},
    PlotLabel -> n]], {n, 1, 50}]

We can easily animate with almost the same syntax this way.

Table[Plot[Nest[Sin, x, n], {x, -2 Pi, 2 Pi}, PlotRange -> {-1, 1},  PlotLabel -> n], {n, 1, 50}];

As a supplement to Brett's answer, here is how things looked like in version 5.2, which was the last version to use the old Graphics[] system:


One could then collapse the set of pictures produced by Do[] (or Table[]), and then double-click the collapsed cell group to see the animation. This is due, as already mentioned, to graphics output being a side-effect (akin to Print[]) in the old days, while in current versions, the actual images themselves are now the output.


Your Answer

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

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