Ryerson Crest Ryerson Header

MTH 207 Lab Lesson 9

Plotting Points and Limits

Up to Main Lab Page Next Lesson - Derivatives Previous Lesson - Trig Functions

Plotting Points

Often data is given to us as a series of points rather than as a function. It would be useful to be able to plot sequences of points in Maple.

Maple uses square brackets [ .. ] to represent ordered information. Thus an ordered pair (i.e a point in R2) in Maple is represented by a pair of numbers in square brackets. So [1, 2] represents the point with x coordinate 1 and y coordinate 2.

We can plot a series of points by giving Maple and ordered set of points.
> plot([[0, 1], [1, 3], [2, 3],[4, 5]]);
Notice how this is an ordered list of ordered points.

We can of can of course use any of the plot features discussed already, to specify an x or y plot range, a color, etc.

By default plot joins the points up with straight lines. We can tell plot to just plot the points with the optional style=point argument to plot.
> plot([[0, 1], [1, 3], [2, 3],[4, 5]], style=point);
> plot([[0, 1], [1, 3], [2, 3],[4, 5]], -0.5..4, -0.5..5, style=point, color=magenta, axes=box);
The second example specifies an x and y range and a plot color.

The axes=box tells Maple to put the axes in a box on the left hand side and bottom of the plot, this together with extending the range makes the point at 0 easier to see.
Note that since we are dealing now with a series of points, there is no x, thus we can omit the 'x =' part of the range specification.

Plot the following sequence of points:


We have already seen how to use the sequence operator ($) to investigate the behviour of a function near a point. Note that in our previous investigation we only considered points approaching from the right. We can be a bit more creative in our definition of g and investigate both sides.
> f := x -> x^2;
> g := x -> ((-1)^x*10^(-x));
> evalf((f@g)(n)) $ n = 1..10;
The (-1)^n alternates the sign of g. Another alternative is to run the original g twice, the second time with a minus sign.
> f := x -> x^2;
> g := x -> (1/x);
> evalf((f@g)(n) $ n = 1..10);
> evalf((f@(-g))(n) $ n = 1..10);

It is useful to be able to plot these sequences, since this lets us see what is going on more clearly. We can use the $ operator to generate a sequence of ordered pairs:
> g := x -> 1/x;
> f := x -> 1/x^2;
> rightpoints := [g(n), f(g(n))] $ n = 1..10;
> leftpoints := [-g(n), f(-g(n))] $ n = 1..10;
> plot([leftpoints, rightpoints], style=point);
Try to plot this without the "style = point", what goes wrong? Why?

In fact this is more or less how Maple plots functions, in fact Maple avoids regularity in the space between points and peturbes each one by a random amount to avoid special 'bad' points.

This seems to indicate that 1/x2 tends to infinity as x tends to 0 (i.e. 1/x2 has a vertical asymptote at 0). Of course no amount of plotting will ever allow us to be sure, to do that we must use conventional (algebraic) limit techniques.

We can also use this type of technique to investigate what happens to a function as x approaches infinity.
> f := x -> 1/(-x^2);
> points := [n, f(n)] $ n = 5..100;
> plot( [points], style=point);
> points := [-n, f(-n)] $ n = 5..100;
> plot( [points], style=point);
This seems to indicate that f tends to 0 from above, as x tends to both +- infinity.

Once again we must be careful, and not rely too heavily on these plots. Consider the following:
> f := x -> sin(Pi*x);
> points := [n, f(n)] $ n = 5..100;
> plot( [points], style=point);
> points := [-n, f(-n)] $ n = 5..100;
> plot( [points], style=point);
This seems to indicate that sin(Pi*x) is identically 0. But we know lim x->infinit sin(x) does not exist.
What went wrong?

  1. Investigate the behaviour of x/(x - 1) as x -> 1, plot a graph of your points.
  2. Investigate the behaviour of x/(x + 1)2 as x -> -1, plot a graph of your points.
  3. Investigate the behaviour of the following functions as x -> infinity, plot a graph of your points.
    1. f(x) = (x + 1)/x.
    2. f(x) = exp(x).
    3. f(x) = exp(-x).


Maple has the capability to evaluate simple limits using the limit function. The syntax is
limit(expr, var = value)
expr is the expression whose limit is to be evaluated.
var = value is an equation,
var is the variable whose limit is to be found.
value is the value at which the limit is to be found.

For example:
> limit( x^2, x = 1);
> limit( y/y, y = 0);
> limit( a*y/y, y = 0);
In the last case the limit will depend on the value of a, which may depend on other variables or y.

  1. Try finding limit( a*y/y, y = 0) for each of the following a's.
    1. a = 2.
    2. a = y2+3y +4.
    3. a = y4 + 5y2 + 6y.
If the limit does not exist limit will report undefined.
If the limit is unbounded (infinite) Maple will report either +- infinity.
If Maple cannot find the limit but it is bounded Maple will report a range which bounds it.
> limit( 1/x, x = 0);
> limit( 1/x^2, x = 0);
> limit( sin(1/x), x = 0);

We also can tell Maple to take infinite limits
> limit( 1/x, x = infinity);
> limit( 1/x, x = -infinity);
Note though that Maple gives no information about how 1/x aproaches 0 as x approaches infinity, from above, 0+. On the other hand as x approaches -infinity, 1/x tends to zero from below 0-.
Try a plot of 1/x from -infinity to infinity.

We can also get Maple to compute left and right hand limits by using the optional left or right arguments to limit.
> limit( 1/x, x=0, left);
> limit( 1/x, x=0, right);
> limit( 1/x, x=0);

  1. Find the following limits:
    1. lim x -> 1+ (x2 - 1)/|x - 1|.
    2. lim x -> 1- (x2 - 1)/|x - 1|.
    3. lim x -> 1 (x2 - 1)/|x - 1|.
    4. lim x -> 1 (sqrt(6 - x) - 2)/sqrt(3 - x) - 1.
    5. lim x -> Pi/2 tan(x).
    6. lim x -> Pi/2+ tan(x).
    7. lim x -> 0 sin(1/x)^2.
    8. lim x -> 0 sin(1/x)^2 - sin(1/x).

Care must be taken when using the limit function in Maple as it often makes mistakes. This is usually because Maple assumes that any variable may be complex valued. Thus the following are incorrect: Why?
> limit(sqrt(x), x = 0);
> limit(sqrt(x), x = 0, left);

Despite an amazing ability Maple cannot do everything. Try
> f := x -> sin(1/x) - sin(1/x - x);
> limit(f(x), x = 0);

Maple tells us that this function must lie between -2 and 2 (the sum of two sine functions). But now try
> plot(f(x), x = -.1.. .1);

This graph seems to indicate that f(x) is quite close to 0 at x = 0, despite some serious wiggling! We could try to plot f on intervals closer and closer to 0.
Try to plot f on the intervals +-a for a = 0.01, 0.001 and 0.0001.

Notice how all of these plots look similar, even though each interval is contained in the previous one. In particular at the end points we seem to get f(x) = x. If this were true the squeeze theorem would tell us that the limit was zero, which is indeed the case.

Up to Main Lab Page Next Lesson - Derivatives Previous Lesson - Standard Functions II Top of this Lesson

Maintained by: P. Danziger, Febuary 1998