Ryerson Crest Ryerson Header

MTH 207 Lab Lesson 7

Standard Functions I
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.

Grouping Things Together

In general Maple groups unordered elements together using braces: { ... }
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.

Color Information

Colors for plot may be one of the following names:
aquamarineblackbluenavycoral cyanbrowngoldgreengray
greykhakimagentamaroonorange pinkplumredsiennatan

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


Polynomial functions are those of the form
f(x) = an xn + an-1 xn-1 + ... + a1 x + a0
for some constants a0 to an
The number n is called the degree of the polynomial.

Linear Functions

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.

Quadratic Functions

If f(x) is a quadratic, f(x) = ax2 + 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) = x2. We now investigate the effect of the transformations x -> x + d and y -> y + r on the graph of f.

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 = x2, possibly shifted.

Even Powers

If we compare the graphs of x2 and x4:
> plot(x^2, x=-10..10);
> plot(x^4, x=-10..10);
we see that they are very similar. x4 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 x2 term induces a kink if a is negative. This is because for small x the x2 term becomes significant and bows the shape of the graph near 0. Away from 0 the x4 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 x3 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);

x4 + 4*x3 + 6*x2 + 4*x + 1

This shows that the existance of odd powers, x3 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).

Odd Powers

Consider the graph of x3.
> plot(x^3, x = -3..3);

As x -> infinity x3 goes to infinity, as x -> -infinity, x3 goes to -infinity. This will be the limiting behaviour of any cubic.

We now consider the effect of introducing an x term. Consider x3 + ax = x(x2 + 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, x2 + a never goes negative and this can only add to the cubic. If a is negative x2 + a goes negative and introduces a kink in the cubic, giving the classic three roots.

Now consider the effect of an x2 term. x3 - ax2 = x2(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 x3 - ax2 - 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).

Rational Functions

A Rational function is a function of the form f(x) = p(x)/q(x), where p(x) and q(x) are both polynomials. Rational functions are defined and continuous if and only if q(x) <> 0. At points where q(x) = 0, f(x) has either a vertical asymptote or a removable discontinuity. The latter will only happen at a if p and q have common linear factors (x - a).

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 xn, 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/x2.
> 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/x2 is positive, thus as x -> -infinity 1/x2 -> 0+.

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

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/x2 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 < 1x > 1
x - 1-++
x + 1--+

> 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.

Products of Functions

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))

Algebraic Functions

Algebraic functions are functions which can be constructed by algebraic operations (addition, subtraction, division and taking arbitrary roots).

Thus x1/2, x-1/3, x + x-1 - 3x-3/2, (x2 + 1)1/2 are all algebraic functions.

> plot(x^(1/2), x = -5..5);
Since x1/2 is not defined for x < 0 we don't need the negative range.
> plot(x^(1/2), x = -1..10);
Note that x1/n is not defined if n is even and x is negative, whereas if n is odd it is defined everywhere.

Plot the following:

Sums of Functions

One of the important relations for constructing algebraic functions is taking the sum of two functions. When we add functions together they add pointwise. Thus if both f and g are positive f + g will grow, whereas if one is negative it will pull f + g down. Consider the following algebraic sum:
> 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.

Transcendental Functions

The transcendental functions are basically all functions which are not algebraic. This includes the trigonometric functions, which we will consider in the next lab, exponential and logarithmic functions, which we will also look at in detail later.

Piecewise Functions - Absolute Value

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
abs(x) is not differentiable at x = 0, where it has a 'corner'. We can move this around using shifts f(x) -> f(x - a).
> 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 < 2x > 2
x - 2-++
x + 1--+

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:

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

Maintained by: P. Danziger, Febuary 1998