Calculus I with Maple

Wednesday, September 2, 1998


The Slope of a Curve

In the notes on polynomial calculus, we talk about finding the slope of a curve. The basic idea is that if we look at a sufficiently small piece of a curve like y = x^2, then that piece of curve will look very much like a straight line. For example, we saw that if we "zoom in" on the point (1,1), the parabola y = x^2 looks like a straight line of slope 2. To create pictures like those in the notes we could try the following:

[> plot( x^2, x = -2..2 );
[> h := 1.0;  plot(x^2, x = 1-h..1+h );
[> h := h/2;  plot(x^2, x = 1-h..1+h );
Notice that this second command plots the function y = x^2 on an interval centered at x=1 of width h. First we set h=1 and then in the third command we cut h in half and replot. In effect we are "zooming in" on the point (1,1).

If you type the three commands above and have Maple carry them out, you can continue the zooming in process very easily. Just move the cursor back into the third line and hit return. Maple will cut h in half again and replot. Repeat this until your graph looks like a straight line. When you have a graph that looks like a straight line, then click on any point of the graph. In the upper left corner of your Maple window you should find the coordinates of the point you clicked on. Record these values. Then click on another point and record these values as well. Using the two points you found by clicking, you can compute the approximate slope of y = x^2 near the point (1,1). This estimate will necessarily be rough, because of the inaccuracy in trying to click on a point that is exactly on the curve. For example, you might get something like the following:

[> a1 := 1.027;  b1 := 1.057;
[> a2 := 0.9794;  b2 := 0.9594;
[> slope := (b2-b1)/(a2-a1);
We get a value close to 2, as expected.

We can get better results if we actually compute points on the curve, like this:

[> f := x -> x^2;  h := 0.1;
[> h := h/2;  slope :=  (f(1+h) - f(1))/h;
By repeating the second line, we are letting h get closer and closer to zero, and the computed slope will get closer and closer to 2 in this case.

Problem 1: Using the method outlined above find the slope (accurate to two decimal places) of the curve y = sin x at the following points:

       (a)  (Pi/4, sqrt(2)/2)
       (b)  (Pi/6, 1/2)
       (c)  (Pi/3, sqrt(3)/2)
You might use commands that look like this:
[> f := x -> sin(x);
[> a := evalf(Pi/4);  h := 2.0;
[> h := h/2;  slope :=  (f(a+h) - f(a))/h;
Each time you repeat this second command, you are computing the slope of the line connecting the point (a,sin(a)) and the point (a+h, sin(a+h)) for smaller and smaller choices of h.

Accuracy: How can you tell if your results are accurate to two decimal places? At first the slopes you compute might change quite a bit at each step, but eventually they should stop changing in the first few decimal places. At that point, you can reasonably assume that the first few digits are accurate.

Problem 2: Use the graphical approach to find the slope of y = sin(x) at the points given in Problem 1. In other words, plot the function y = sin(x) on an interval of radius h centered at (a, sin(a)). Then replace h by h/2 and replot. Continue until your plot looks like a straight line. Estimate the slope by clicking on two points on the graph.