The graph of the line y = 3x – 2 is shown above.  Notice that the line crosses the y-axis at y = -2, which is represented by “b” the y-intercept.  The slope of the line is 3, represented by “m”.  The slope of the line illustrates the steepness and direction in which the line is facing.  Since the slope is positive, the y-coordinates will increase as the x-coordinates increase (rise from left to right).  It also expresses how steep the line is since the y-coordinates will increase by 3 units for every increase of 1 unit in the x-coordinates (i.e. m = 3 = 3/1).

 

Very Important

 

One important aspect about the graph of a line (or any function really) is that the equation of the line allows us to substitute any x-value into the equation and obtain the corresponding y-value.


Examples for the line: y = 3x -2

 

When x = 0, y is equal to -2.  Thus, the point (0, -2) should be on the line above.

When x = 1, y is equal to 1.  Thus, the point (1, 1) should be on the line above.

When x = 2, y is equal to 4.  Thus, the point (2, 4) should be on the line above. 

 

Verify with the graph shown above that these three points are on the line. 

 

While these three statements are true, the same can be said for an infinite number of points on the line.

 

When x = 1.235243321, y is equal to 1.705729963 because 3(1.235243321) – 2 is 1.705729963.  Thus, the point (1.235243321, 1.705729963) is on the line above.


Project 10: Assume the following variables have been initialized (xMin, xMax, yMin, yMax, m, b).  There is also a working method called drawPoint

xMin is the lowest x-value on the graph (-10 in the example above)

xMax is the highest x-value on the graph (10 in the example above)

yMin is the lowest y-value on the graph (-10 in the example above)

yMax is the highest y-value on the graph (10 in the example above)

m is the slope of the line you are wanting to draw (3 in the example above)

b is the y-intercept of the line you are wanting to draw (-2 in the example above)

drawPoint accepts two values and draws a point at this coordinate on the graph.

example: drawPoint(1.0, 3.0) would draw a point at x = 1.0, y = 3.0.

Task: Implement code to correctly draw the line on the graph.

Note: there are a few hints offered below (try to do with as few or no hints if possible)

**If your code works for 5 test cases, you can enter your e-mail address

Universal Computational Math Methods:

pow(5,2) returns 25.0

abs(-3.0) returns 3

sqrt(49.0) returns 7.0