5
$\begingroup$

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.

$\endgroup$
8
$\begingroup$

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

$\endgroup$
3
$\begingroup$

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, ...
x=0:1/n:3*pi;
y = sin(x);    % sine function
pause(1);      % pause duration 
plot(x,y,'b.')
axis ([0 3*pi -1.5 1.5])
grid on
end
$\endgroup$
2
$\begingroup$

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


                PlotGIF


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]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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