Calculus I with Maple: Wednesday, October 21, 1998

Polynomial Approximations



Assignment: 1-5

Discussion and Examples

In class we have been working with the formula
f( x + delta x) is approximately equal to f(x) + f'(x)*(delta x)
which comes from approximating a curve near a point by its tangent line. To get the tangent line to the curve we need its slope or first derivative. In this lab we use higher order derivatives to construct better approximations.

Example: Find good polynomial approximations to the curve y = sin(x) near the point (0,0).

Solution: Since dy/dx = cos(x) in this case, we find that the tangent line at (0,0) has slope cos(0) = 1 and equation y = x. The polynomial function A1(x) = x is our first (linear) approximation to the curve y = sin(x) at (0,0).

Next, use the second and third derivative to construct a cubic approximation

        A3(x) = a + bx + cx^2 + dx^3
that is a good approximation to y = sin(x) near (0,0). The idea is to match as many of the derivatives of sin(x) at x = 0 as possible.
Match the 0th derivatives:   A3(0) = sin(0)  
                  that is,      a  =  0
Match the 1st derivative:    
      D( a + bx + cx^2 + dx^3 ) = b + 2cx + 3dx^2
  and D(sin(x)) = cos(x)
   so evaluating at x = 0 gives  b = cos(0) = 1.

Match the 2nd derivatives:
      D(b + 2cx + 3dx^2) = 2c + 6dx
      D(cos(x)) = -sin(x)
      Evaluating at x = 0:    2c = -sin(0) = 0   so c = 0.

Match the 3rd derivatives:
      D(2c + 6dx) = 6d
      D(-sin(x)) = -cos(x)
      Evaluating at x = 0:     6d = -cos(0) = -1  so d = -1/6.

Thus our cubic polynomial should be:

       A3(x) = x - x^3/6
Exercise 1: Plot the graphs of A1(x) = x, f(x) = sin(x), and A3(x) = x - x^3/6 together on the interval [-0.1, 0.1]. Then evaluate all three for x = 0.5, 0.4, 0.3, 0.2, 0.1 and 0.01. Replot on the interval [-2,2].

Exercise 2: Find the best degree 5 approximation

       A5(x) = a + bx + cx^2 + dx^3 + ex^4 + fx^5
to y = sin(x) at the point (0,0). Plot A5 and sin(x) together on the interval [-3,3]. Compare the value of A5 and sin for x = 0.5, 0.4, 0.3, 0.2, 0.1, 0.01.

Exercise 3: Find the best linear, quadratic, quartic (degree 4) approximation to y = cos(x) near the point (0,1). Compare their values for x = 0.5, 0.4, 0.3, 0.2, 0.1, 0.01. Graph the various approximations together with the cosine curve on the interval [-3,3].

Exercise 4: Although we have not yet learned to differentiate the exponential function y = e^x we can nonetheless think about polynomial approximations to this curve near the point (0,1) for example.

To find the best linear approximation to y = e^x we could compute its slope numerically or graphically. To compute the slope numerically we could use the definition of the derivative and compute a limit as h goes to zero. Do this to determine the slope of y = e^x accurately to 3 decimal places. Then graph the exponential function together with its tangent line at the point (0,1) on the interval [-1,1]. Note that in Maple, to plot the curve y = e^x on [-1,1] we would use

      [> plot( exp(x), x = -1..1 );
To find the best quadratic approximation to y = e^x we could try the following. Compute three points on the curve, say
  [> x1 := -0.1;  y1 := exp(x1);
     x2 :=  0.0;  y2 := exp(x2);
     x3 :=  0.1;  y3 := exp(x3);
and fit a parabola to these points. Define a quadratic function with unknown coefficients.
  [> A2 := x -> a1 + b1*x + c1*x^2;
Then solve the system of equations we get by requiring that A2(xi) = yi for i = 1, 2, 3.
  [> solve({ A2(x1) = y1, A2(x2) = y2, A2(x3) = y3});
  [> assign(");
The first line tells how to choose a1, b1, and c1 to solve the system. The second line tells Maple to go ahead and assign those values to the unknown coefficients a1, b1, and c1. Now
  [> plot({exp(x), A2(x)}, x = -1..1);
will produce the desired plot.

Exercise 5: Use the method outlined in the previous exercise to find a quartic approximation to y = e^x. That is, fit a quartic polynomial

     A4(x) = a2 + b2*x + c2*x^2 + d2*x^3 + e2*x^4
to the five points corresponding to
 
x1 = -0.02, x2 = -0.01, x3 = 0.00, x4 = 0.01, x5 = 0.02.
Plot A4(x) and exp(x) together on the interval [-3,3].