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;**

- Code:
- 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)**

- Code:
- 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;**

- Code:
- For an x we now have a y, so we will plot a point at (x, y).
- Code:
**drawPoint(x, y);**

- Code:
- 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;**

- Code:

Bounds:

Printer

Edit:
Runtime
View:
Starter
Suggestion

To runtime:

Storage:

Editor width: Normal Wide

To runtime:

Storage:

Editor width: Normal Wide

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;

Try graphing a parabola.

- An equation for a simple parabola could be stated as y = x
^{2}.- Code:
**y = x * x**;

- Code:
- Replace the y-coordinate calculation with the new function
definition.
- Delete code:
**y = (m * x) + b;** - Replace with code:
**y = x * x;**

- Delete code:
- You do not need the variables
**m**nor**b**anymore.

Next tutorial: With line segments

Custom Search

Name:

Domain:

Name

0

Name:

Name

0