Polynomials and Rational Functions

Up to Main Lab Page | Next Lesson - Trig Functions | Previous Lesson - Program Control |

Topics for this Lab: | Groupings [...] {...} | Colors | Polynomials | Rational Functions | |
---|---|---|---|---|---|

Products | Algebraic Functions | Sums of Functions | Transcendental Functions | Absolute Value |

In this lesson we will use Maple to investigate the behaviour of some standard Calculus functions.

Maple groups ordered elements together using square brackets: [ ... ]

Thus {f, g} represents the unordered pair of functions f and g.
So

> f := x-> x;

> g := x -> x^2;

> plot({f(x), g(x)}, x = -1..1.5);

will plot both f and g on the same graph. We don't care wich order it does them
in so we can give f and g as an unordered pair.

Suppose now though that we wish to assign specific colors to f and g on the plot.
We can do this by using the optional **color=***name*
argument to the plot function.

> plot({f(x), g(x)}, x = -1..1.5, color=magenta);

If we want to assign different colors to f and g we could try

> plot({f(x), g(x)}, x = -1..1.5, color={magenta, blue}); #WRONG

But this doesn't work since **plot** needs to know which order to
apply the colors in. Thus we should use the following.

> plot({f(x), g(x)}, x = -1..1.5, color=[magenta, blue]);

Strictly speaking, since we now care which order we want f and g to be plotted
(and hence which color each gets), we should put them as an ordered list as well.

> plot([f(x), g(x)], x = -1..1.5, color=[magenta, blue]);

This tells Maple unequiviqually that the first function, f, gets magenta while
the second function, g, gets blue.

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 |

Color values can also be set by giving the RGB (Red, Green, Blue) values for
the color, through the **COLOR** function. For Example

> plot(g(x), x = -1..1.5, color=COLOR(RGB, .5607, .7372, .5607));

f(x) = a

for some constants a

The number n is called the

We presume you are familiar with the *linear* polynomial f(x) = mx + b,
which has slope m and intercept b. We can actually use the iteration operator
($) to generate a sequence of functions to
plot.

> f := x -> m*x;

> functions := [f(x) $ m = -5 .. 5];

> plot(functions, x = -5..5);

The second line creates an ordered list of functions, one for each m value.

On the same graph plot x + b for b from -3 to 3, in the range -5 to 5.

If f(x) is a quadratic, f(x) = ax^{2} + bx + c, we can *complete the
square* to get
f(x) = a((x + b/(2a))^{2} + (c/a - (b/2a)^{2}).
Since a, b and c are constants this has the form
(x + d)^{2} + r = g(x + d) + r, where g(x) = x^{2}.
We now investigate the effect of the transformations x -> x + d and y -> y + r on the
graph of f.

- On the same graph plot x^2 + b * x + b^2/4 for b from -3 to 3, in the range -5 to 5.
- On the same graph plot x^2 + c for c from -3 to 3, in the range -5 to 5.

If we make the transformation x -> x + d in a graph, the effect is to shift the
graph to the left by d units. This is because what was the origin is now the
point -d.

> plot([(x + 3)^2, x^2], x=-5..5, color=[red, blue]);

Of course if d is negative the graph shifts to the right.

If we make the transformation y -> y + r, (i.e. f(x) -> f(x) + r) this has the
effect of shifting the graph up by r units, since if y = f(x), then y + r =
f(x) + r.

> plot([x^2 + 20, x^2], x=-5..5, color=[red, blue]);

Of course if r is negative the graph shifts down.

These two rules are generally true, that is:

**
f(x) -> f(x + a) shifts the graph of f left by a.
f(x) -> f(x) + a shifts the graph of f up by a.
**

From this we see that any quadratic must look essentially like y =
x^{2}, possibly shifted.

If we compare the graphs of x^{2} and x^{4}:

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

> plot(x^4, x=-10..10);

we see that they are very similar. x^{4} has a slightly flatter bottom,
and rises more quickly, but the basic form is the same. We can see the
differences more clearly by plotting both functions on the same graph:

> plot([x^2, x^4], x=-1.5..1.5, color=[red,blue]);

For a generalised polynomial , as x tends to either + or - infinity the highest power of x will take over. For even degree polynomials this means that f(x) -> infinity as x -> +- infinity.

To see what other terms do consider the following:

> f := x -> x^4 + 20*a*x^2;

> fns := [f(x) $ a = -3..3];

> plot(fns, x = -9..9);

The x^{2} term induces a kink if a is negative. This is because for
small x the x^{2} term becomes significant and bows the shape of the
graph near 0. Away from 0 the x^{4} term takes over.
We can see this more clearly by plotting:

> plot(x^4-60*x^2+200,x=-10..10);

From this we can see how a quartic could have four roots. Notice that the
derivative of a quartic is a cubic and has three roots, the three turning
points on the graph.

**
In general an n degree polynomial may have up to n real
roots and n-1 turning points.
**

To investigate the effect of an x^{3} term consider

> plot(x^4 + 2*x^3 - 60*x^2 , x = -9 .. 9);

Notice how the right hand minima is raised, and the left hand one is lowered.

On the same graph plot x^4 + a*x^3 - 60*x^2, for a from -2 to 3, on the range - 9 to 9.

Care must be taken when using this interpretation. Consider
(x + 1)^{4}, in particular try

> expand((x+1)^4);

This shows that the existance of odd powers, x^{3} and x in a quartic,
may just be the result of a linear shift x -> x + c.

Use the methods above to investigate sextics (degree six polynomials).

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

As x -> infinity x^{3} goes to infinity, as x -> -infinity,
x^{3} goes to -infinity. This will be the limiting behaviour of any
cubic.

We now consider the effect of introducing an x term. Consider
x^{3} + ax = x(x^{2} + a).

> f := x -> x^3 - a*x;

> fns := [ f(x) $ a=-2..2];

> plot(fns, x = -2..2);

Try plotting a couple of these individually to get a better idea of the effect of
each a.

If a is positive, x^{2} + a never goes negative and this can only add
to the cubic. If a is negative x^{2} + a goes negative and introduces a
kink in the cubic, giving the classic three roots.

Now consider the effect of an x^{2} term.
x^{3} - ax^{2} = x^{2}(x - a) which has two roots, one at
x = 0 and one at x = a. This suggests a skewed graph.

> f := x -> x^3 - a*x^2;

> fns := [ f(x) $ a=0..3];

> plot(fns, x = -1..3);

Putting these together would indicate that x^{3} - ax^{2} - bx
has a skewed cubic look.

> f:=x->x^3-a*x^2-5*x;

> fns := [ f(x) $ a=0..3];

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

Use the methods above to investigate quintics (degree five polynomials).

The **order** of a rational function is (the degree of p) - (the degree of
q).

The order of a rational function determines its behaviour as x tends to +-
infinity.

In general f will behave like x^{n}, where n is the order of f
(possibly negative), as x tends to +-infinity.

We start by considering 1/x.

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

Oops, since 1/x has a discontinuity at x = 0 we must limit the y range.

> plot(1/x, x=-5..5, -10..10, discont=true, color=red);

As x -> infinity 1/x -> 0^{+}, as x -> -infinity 1/x -> 0^{-}.
We say that 1/x has a horizontal asymptote of 0.

Now consider 1/x^{2}.

> plot(1/x^2, x=-5..5, -10..10, discont=true, color=red);

This has a very similar form to 1/x, except that when x is negative
1/x^{2} is positive, thus as x -> -infinity 1/x^{2} -> 0+.

The graphs of 1/x^{n} look similar to one of these two, depending
whether x is odd or even.

- On the same graph plot 1/x^n for n = 1, 3, 5.
- On the same graph plot 1/x^n for n = 2, 4, 6.

Now consider f(x) = 1/((x-1)(x+1)).

> plot(1/((x-1)*(x+1)), x=-5..5, -10..10, discont=true, color=red);

Since the order of f is -2 f(x) has the behaviour of 1/x^{2} as x tends to
infinity. It also has two asymptotes, one at -1 and one at 1.
We can understand the behaviour of the function near these asymptotes by considering the
signs of (x-1) and (x+1) near the asymptotes.

x < -1 | -1 < x < 1 | x > 1 | |
---|---|---|---|

x - 1 | - | + | + |

x + 1 | - | - | + |

f(x) | + | - | + |

Consider:

> f:=(x-a)/((x-1)*(x+1));

> fns := [f $ a = -2..2];

> plot(fns, x=-4..4, -10..10, discont=true);

The order of all of these functions is 1, and so thay behave like 1/x as x
tends to +-infinity.

See if you can explain why each of the lines goes where it does by considering the signs of the various factors. It may help to plot the functions on seperate graphs.

The form of these graphs can be understood in terms of multiples of functions, f(x)g(x). In this case f(x) is a linear function, so we have h(x) = (x - a)g(x).

If x > a then x - a > 0 and the sign of h will be the same as that of g.

If x = a then x - a = 0 and the h will have a root at a.

If x < a then x - a < 0 and the sign of h will be opposite to that of g.

Another common form is cf(x), where c is a constant. This *stretches* the graph
of f(x) vertically by a factor of c.

> f:= x^2;

> plot([f(x),2*f(x), 3*f(x)], x = -3..3, -10..10, color=[red, blue, cyan]);

Try the above plot with f(x) = 1/((x-1)(x+1))

Thus x^{1/2}, x^{-1/3}, x + x^{-1} - 3x^{-3/2},
(x^{2} + 1)^{1/2} are all algebraic functions.

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

Since x^{1/2} is not defined for x < 0 we don't need the negative
range.

> plot(x^(1/2), x = -1..10);

Note that x^{1/n} is not defined if n is even and x is negative,
whereas if n is odd it is defined everywhere.

Plot the following:

- x*sqrt(x+3)
- (x^2 - 25)^(1/4)
- x^(2/3)
- x^(2/3)*(x-2)^2

> f := x -> x^2;

> g := x -> 1/x;

> plot([f(x), g(x), f(x) + g(x)], x = -2 .. 2, -10..10, color=[red,blue,cyan]);

We have already effectively considered sums when considering polynomials.

> f := x -> x^4;

> g := x -> x^3;

> plot([f(x), g(x), f(x) + g(x)], x = -2 .. 2);

Go back to the polynomial section and consider the problem as an algebraic sum.

One simple type of function which is not algebraic are the piecewise functions. Of particular interest is if absolute value function, abs(x) or |x|.

abs(x) = | x | if x >= 0 |

-x | if x < 0 |

> plot(abs(x), x = -5..5);

> plot(abs(x - 2), x = -5..5);

> plot(abs(x - 2) + 2, x = -5..5, 0..9);

We can sum absolute value functions:

> plot(abs(x - 2) + abs(x + 1), x = -5..5, 0..10);

> plot([abs(x - 2),abs(x + 1),abs(x - 2) + abs(x+1)], x = -5..5, 0..11, color=[red,blue,cyan]);

The constant part between -1 and 2 is a feature of this type of graph. We can see how this arises by arguing from the definition of abs.

x < -1 | -1 < x < 2 | x > 2 | |
---|---|---|---|

x - 2 | - | + | + |

x + 1 | - | - | + |

Thus

abs(x + 1) + abs(x - 2) = | -(x + 1) -(x - 2) | if x < -1 | = | -2x + 1 | if x < -1 |

(x + 1) - (x - 2) | if -1 < x < 2 | 3 | if -1 < x < 2 | ||

(x + 1) + (x + 2) | if x > 2 | 2x + 3 | if x > 2 |

Plot The following:

- |x - 1| - |x + 2|
- |x^2|
- |x|^2
- 2|x|
- |2x|

Up to Main Lab Page | Next Lesson - Trig Functions | Previous Lesson - Program Control | Top of this Lesson |