Application Center - Maplesoft

App Preview:

Algebra module 5: graphs - seeing & believing

You can switch back to the summary page by clicking here.

Learn about Maple
Download Application


 

0105.mws

Module 1 : Algebra

105 : Graphs - Seeing & Believing

O B J E C T I V E

The objective of this module is to learn to create graphs in Maple, learn some of the options which can make graphs more interesting and informative, and how to create graphs of multiple functions at once. We will also learn about lines and slope, and how parameters in a function can affect the placement of the graph, that will be helpful later when you need to graph on your own without using Maple.

S E T U P

In this project we will use the following command packages. Type and execute this line before beginning the project below. If you re-enter the worksheet for this project, be sure to re-execute this statement before jumping to any point in the worksheet.

> restart; with(plots):

___________________________________________________________________________________

A. Basic Graphs

___________________________________________________________________________________

The plot command will graph a function.You must specify a function (no y, just a formula in x) and a domain (the range of values to use for x). Maple will automatically compute the range (y range) to fit the graph.

> plot(x^2, x=-3..3);

[Maple Plot]

You can also define a function first, then plot it.

> f:=x-> 9-x^2;

f := proc (x) options operator, arrow; 9-x^2 end pr...

> plot(f(x), x=-3..3);

[Maple Plot]

A1. Graph y = 2x + 3 using a domain of x = -5..5

A2. Graph the following using domains of your own choice
A.
4-(x-3)^2 B. sqrt ( x- 1) C. x^3-12*x^2+30*x-10 (Domain = [-4,11])

A3. A. Define the function f(x) = 25*x+8*x^2-x^3
B. Experiment with different domains until you can create a graph with the smallest domain that shows all three of this functions x intercepts. Hint start with x = -20..20, then shorten the interval on both sides using integer values until you can't shorten the interval any more without losing sight of an x-intercept.

___________________________________________________________________________________

B. Graphing Options

___________________________________________________________________________________

There are a number of options which can be used to enhance your graphs and make them more sophisticated.

STYLISTIC OPTIONS

There are a number of options which can be used to enhance your graphs. These options can be supplied in any order after the domain (and range) are specified.

Line Thickness
The default thickness is 1 which sometimes results in a graph that is somewhat thin and hard to see for lighter colors. Larger numbers make thicker graphs.

Color of the Curve
Maple chooses colors for the graph on its own unless we specify a color. The 25 colors available are aquamarine, black, blue, navy, coral, cyan, brown, gold, green, gray, grey, khaki, magenta, maroon, orange, pink, plum, red, sienna, tan, turquoise, violet, wheat, white, yellow

Line Style
Line styles create dashed and dotted graphs. The default value is 1 if you dont specify a linestyle and creates a standard connected graph.

> plot( 9- x^2, x = -3..3, thickness = 2, color = blue, linestyle = 2);

[Maple Plot]

> plot( x^3 - 2*x, x = -3..3, thickness = 3, color = gold, linestyle = 3);

>

[Maple Plot]

VERTICAL RANGE

Maple computes the range of y values to use in a graph automatically. However sometimes the results are not what we expect.

The problem here is that the values of the function get very large near x = 1 and so Maple needs to make the y range very large.

> plot( 1/(x-1), x = -5..5);

[Maple Plot]

At such a large range, we lose the finer detail. We can fix this problem by defining the y-range for ourselves.

The y range is given, after the x range, as two numbers separated by 2 dots - just as the plot domains is defined for x.

> plot( 1/(x-1), x = -5..5, y = -5..5);

[Maple Plot]

DISCONTINUOUS GRAPHS

The graph above has a flaw. There appears to be a vertical line at x = 1 when really the function is not defined at x = 1. This happens because Maple assumes graphs are continuous, which means there are no breaks or gaps in a smooth curve. So it tries to keep the graph connected by drawing that extra line. We can fix this problem by telling Maple to expect discontinuities.

> plot( 1/(x-1), x = -5..5, y = -5..5, discont = true);

[Maple Plot]

Another example of a function which has breaks is the greatest integer function, which Maple calls the floor function.

Note the difference in the graphs when you alert Maple that the function has discontinuities.

> plot( floor(x), x = -5..5, thickness = 3);

[Maple Plot]

> plot( floor(x), x = -5..5, thickness = 3, discont =true);

[Maple Plot]

MULTIPLE GRAPHS

You can plot several graphs on the same set of axes by enclosing the functions in set braces.

> plot( {x^2 - 9, 9 - x^2 }, x= -5..5, thickness = 2, color = [blue,green]);

[Maple Plot]

Here is a way of graphing a family of functioins all at once.

B1. Graph the functions x^3, x^3 - 2*x, x^3 + 2*x on the same axes using domain x =-2..2

This single command prints the functions x, x^2, x^3, ..., x^20 on the same set of axes.

Prototype using parameter k.......$ : separates prototype from range....... 1..20 : range of values for the parameter

> plot( { x^k $ k = 1..20 }, x = 0..1);

[Maple Plot]

> f := x -> x^2;

f := proc (x) options operator, arrow; x^2 end proc...

> plot( {f(x - k) $ k = -5..5}, x = -10..10, y = -15..15 );

[Maple Plot]

> plot( {f(x) - k $ k = -5..5 } , x= -10..10, y = -15..15 );

[Maple Plot]

B2. Copy and paste the three commands above, change f(x) as follows, and re-execute. What can you conclude by these examples?
A. f(x) = | x | (hint : abs) B. f(x) =
x^3 C. f(x) = sqrt(x) D. f(x) = x^2(x^2+1)

OTHER GRAPH OPTIONS

There are quite a few options available. You can see them all by typing this

> ?plot[options]

Also you can click on any graph and buttons will appear on the toolbar which alter the graph. By clicking on these buttons you can affect the appearance of the graph in some ways.

___________________________________________________________________________________

C. Slope

___________________________________________________________________________________

Every non-vertical line has a slope. What exactly do lines with large and small positive and negative slopes look like? Using the powerful graphing capabilities of Maple, we can see at a glance what lines with different slopes look like. Here are the lines y = x, y = 2x, y = 3x, ..., y = 20x

> plot({ k*x $ k = 1..20 }, x = -5..5, y = -5..5);

[Maple Plot]

Here is a more sophisticated plot. To create additional lines without executing use shift return (Windows) and return (Macintosh).

> plots[display]( plot( { k*x $ k = 1..15 }, x = -5..5, y = -5..5, color = blue),
plot( { (1/k)*x $ k = 1..15 }, x = -5..5, y = -5..5, color = green),
plot( { (-1/k)*x $ k = 1..15 }, x = -5..5, y = -5..5, color = gold),
plot( { -k*x $ k = 1..15 }, x = -5..5, y = -5..5, color = red) );

[Maple Plot]

The blue lines have positive integer slopes 1,2,3, ...,15. The green lines have positive fractional slopes of 1/2, 1/3, 1/4, ..., 1/15. The gold lines have negative fractional slopes of -1/2, -1/3, -1/4, ..., -1/15. The blue lines have negative integer slopes -1,-2,-3, ...,-15.

___________________________________________________________________________________

D. Graphing Lines

___________________________________________________________________________________

The equations for lines come in various formats such as the slope-intercept form, the point-slope form, and the standard form. When use the plot command, we need to write the function as a formula in x. For a line, this means we need to express the line in slope-intercept form (y = mx + b) without the y.

> plot( 3*x + 7, x= -5..5);

[Maple Plot]

There are other ways to express the formulae for lines which do not fit this format such as the point slope form ( y - y1 = m(x- x1) ) or the standard form (Ax + By = C). One option is to use the solve command to convert other forms to slope-intercept form, as we saw in an earlier project.

> 14*x - 7*y = 18;

14*x-7*y = 18

> solve( %, y);

2*x-18/7

However, we can plot these lines directly using a different command.

Note that you must specifiy both an X range and Y range when using this command.

> plots[implicitplot]( 14*x - 7*y = 18, x = -5..5, y = -5..5);

[Maple Plot]

D1. Graph the following lines using the implicitplot command as shown above.

A. 7*x + 20*y = -13 B. (y-1) = .3*(x + 2) C. 10 - 3x - 4y = 0

___________________________________________________________________________________

E. Shifting Up / Down & Left / Right

___________________________________________________________________________________

Its interesting to see at a glance how changing a function, changes its graph. Here we look at a basic parabola y = x^2. Then consider what happens when we change it to y = (x-k)^2 and y = x^2 + k. To type multiple lines at the same prompt use shift-return on Windows, and return (not enter) on Macintosh.

> restart; with(plots):

Warning, the name changecoords has been redefined

> f := x -> x^2;

f := proc (x) options operator, arrow; x^2 end proc...

> display( plot( f(x) , x = -6..6, y = 0..4, color = green, thickness = 2),
plot( { f(x-k) $ k = 1..4 }, x = -6..6, y = 0..4, color = blue ),
plot( { f(x+k) $ k = 1..4 }, x = -6..6, y = 0..4, color = red),
scaling = constrained );

[Maple Plot]

The original function is in green. The blue curves indicate what happens when k is positive, and the red ones indicate what happens when k is negative.

Now we consider what effect adding or subtracting k from f(x) has on the graph.

> display( plot( f(x) , x = -6..6, y = 0..4, color = green, thickness = 2 ),
plot( { f(x) - k $ k = 1..4 }, x = -6..6, y = -4..7, color = blue ),
plot( { f(x) + k $ k = 1..4 }, x = -6..6, y = -4..7, color = red),
scaling = constrained );

[Maple Plot]

Again, the original function is in green. You can see that when k is added, the blue graphs result, and when k is subtracted the red curves result.

E1. . Copy and paste the commands above, change the function, and execute the commands
A. f:= x -> abs(x); B. f:= x -> -x^2; C. f := x -> x^3 ; D. f:= x -> (x^2)/(1 + x^2);

___________________________________________________________________________________

F. Parabolas

___________________________________________________________________________________

Every parabola has a vertex and axis of symmetry. With these commands you will see these features on the graph with the parabola.

> a := 2; b := 3;
display( plot( (x-a)^2 + b, x = -7..7,y = -10..10,thickness = 2, color = green),
plot( [[a,-10],[a,10]], x = -7..7, y = -10..10, color = navy, linestyle = 3),
plot( b, x=-7..7, color = gold, linestyle= 3),
plot( {[a,b]}, x=-7..7, color = red, style=point));

a := 2

b := 3

[Maple Plot]

The graph of the parabola is green. The axis of symmetry is the dark blue vertical line. The vertex of the parabola is identified by a small red diamond where the horizontal and vertical lines cross.

F1. Copy and paste the block of commands above. Change the values of a and b and execute the block.

A. a := -2, b := 3 B. a := 2, b := -3 C. a := -4, b := -4

F2. Use the fact that the vertex of y-b = (x-a)^2 is (a,b) and the commands above to graph the parabola along with its vertex and axis of symmetry.

A. y-7 = (x-11)^2 B. y+8 = (x+2)^2

>