A graph on the Cartesian plane represents the set of all the ordered pairs of x and y that satisfy an equation. To draw the graph of an equation, we can plot points and sketch a curve through the points. First, create a table of ordered pairs by choosing values of either x or y and computing the corresponding values of the other variable from the equation. Then plot the points given by these ordered pairs.
For example, sketch the graph of: y = (x + 3)/2
x y -3 0 -1 1 1 2 3 3
Figure 9-2: Plotting points
x + 1
y = ———————
x - 1
First note that at x = 1, the denominator on the right side is equal to zero. We can
write a simple program in the Zeno programming
language to compute y for several values of x except x = 1 as follows:
program
var x : int
var y : real
put " x", tab(10), " y"
put "-------------------"
for x := -5...5 do
if x = 1 then
put x:2, tab(10), "undefined"
else
y := (x + 1)/(x - 1)
put x:2, tab(10), y:9:6
end if
end for
end program
This will print out the list:
x y ------------------- -5 0.666667 -4 0.600000 -3 0.500000 -2 0.333333 -1 0.000000 0 -1.000000 1 undefined 2 3.000000 3 2.000000 4 1.666667 5 1.500000
Example, find the intercepts for: y = x2 - x - 2
Set y = 0: 0 = x2 - x - 2 = (x + 1)(x - 2) The x-intercepts are -1, 2. Set x = 0: y = 02 - 0 - 2 = -2 The y-intercept is -2.