Do anybody have a program which shows a computer graphing a function pointwise in stages? For example:

At stage 1, it graphs all the integer x values

Stage 2, all the multiples of 1/2

Stage 3, all the multiples of 1/4

and so on until we have a full picture of a continuous function.

A single continuous animation of random points being plotted until it fills in a continuous graph would be just as good.

Comment if you are interested in this. I might try my hand at making one if nobody has already.


3 Answers 3


This is pretty straightforward in Mathematica:

f[x_] := x^2;
xrangeleft = -2;
xrangeright = 2;
yrange = {0, 4};
xrange = {xrangeleft,xrangeright};
frames = Table[ListPlot[Table[{x, f[x]}, {x, xrangeleft, xrangeright, 1/2^i}], 
         PlotRange -> {xrange, yrange}], {i, 0, 10, 1}]
Export["FunctionPlot.gif", frames]

(You might need to use Directory[] to find out where it exported your file.)

This creates the following:

enter image description here


Here is the code in Matlab for the sine function:

for k = 0:6
n=2^k          % stage number, k=0: integer values, k=1: stage 2, ...
y = sin(x);    % sine function
pause(1);      % pause duration 
axis ([0 3*pi -1.5 1.5])
grid on

If I may suggest a tiny variation on Aeryk's nice code, to slow it down, and join the dots:


f[x_] := x^3;
xrangeleft = -2;
xrangeright = 2;
yrange = {-8, 8};
xrange = {xrangeleft, xrangeright};
frames = Table[
   ListPlot[Table[{x, f[x]}, {x, xrangeleft, xrangeright, 1/2^i}]
    , Joined -> True
    , Mesh -> Full
    , PlotRange -> {xrange, yrange}]
   , {i, 0, 3, 1}];
Export["FunctionPlot.gif", frames, "DisplayDurations" -> 3.0]

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.