# EZ Math Movie, Tutorials, Drawing Functions, Point by Point

### Lots of points, one point at a time

Probably the easiest way to draw a function with EZ Math Movie is to plot dozens of points on the function, and space these points close together so that the shape of the function becomes clear. That will be our approach in this tutorial example. Here are our steps:

• We will plot the popular linear function y = mx + b.
• Code: y = (m * x) + b;
• We will use a for loop to sweep across the x-axis from its minimum to its maximum.
• Code: for(x = worldXMin; x <= worldXMax; x += deltaX)
• As we move across the x-axis, for every x we land on, we calculate a y using y = mx + b.
• Code: y = (m * x) + b;
• For an x we now have a y, so we will plot a point at (x, y).
• Code: drawPoint(x, y);
• If we move across the x-axis in small steps, we will have a lot of points, and the shape of the function will be clear.
• Code: deltaX = 0.25; or deltaX = 0.1;

### The example program

0ptions

Go on input

Bounds:
Sorry, apparently this browser does not support HTML 5 canvas tag graphics.
Printer

Edit: Runtime          View: Starter Suggestion

To runtime:

Storage:

Editor width: Normal Wide

### Experiments

Change the value of deltaX and see how the number of points changes. An example:

```deltaX = 1;  // few points
deltaX = 0.1 // many points
```

Change the values for the slope, m, and the y-intercept, b, and see how the line changes. For example:

```m = -2;
b = -5;
```

### Another experiment

Try graphing a parabola.

• An equation for a simple parabola could be stated as y = x2.
• Code: y = x * x;
• Replace the y-coordinate calculation with the new function definition.
• Delete code: y = (m * x) + b;
• Replace with code: y = x * x;
• You do not need the variables m nor b anymore.

### And....

Next tutorial: With line segments

### Other sites you may find interesting

Like Math and Physics?

Zona Land Education offers explanations, diagrams, and animations on these topics.
And it is all presented in a clear and casual manner.

Want to learn about programing computers?

EZ Programing Demos has an animated, slow motion, interactive programing language demonstrator.
The site presents basic ideas at a beginner's level.

Custom Search

Name:
Domain:

Name
0

Name:
Name
0