Calculus Online: Lab 6

Welcome to Lab 6 of Math 101, Sections 203, 204, 207 and 209




Instructions

Warning!

If you leave this page or reload it, your work will be lost. Always save your work before leaving or reloading.



Overview

You can't really do that many different kinds of numerical computations. In grade one, you learned how to add and subtract and in grade three how to multiply and divide. Since then, you really haven't learned much new. The reason why is that pretty much all numerical operations can be derived from these simple four. Even computers don't do much more than this. So how do we perform computations involving functions like sin, cos, and tan? In this lab we are going to investigate how to approximate functions like these using polynomial functions. Remember that polynomials are functions made by adding, subtracting, and multiplying numbers, all computations you could do by hand if you had to.

When Are Two Functions Alike?

Suppose we have a function f(x) that we want to approximate with some other function g(x) near x = 0. By approximate we mean that if x is close to 0, then g(x) is close to f(x). A good first step is to make sure that g(0) = f(0). But what more can we do?

To the right is a plot of the graph of two functions: f(x) in blue, and g(x) in red. Near the origin they are close to each other in value, but they look less alike further from the origin. So g(x) is an approximation for f(x). Naturally, g(0)=f(0). But by looking at the difference of these two functions we can see something else.

Question 1 (2 marks)

Which of the following graphs is a plot of the difference f(x) - g(x)?
a) b) c) d) e)

Notice that near the origin, the graph of the difference is "flat". This property is important because it tells us something about the derivative of the difference, namely that

f'(0) - g'(0)=0 .

In fact, it would be reasonable to think that the flatter the difference is at 0, the better the approximation is near 0.

Since we would like to make the difference as flat as possible, we should think about what makes a function flat. In the diagram to the left the functions xn are plotted. You can increase the value of n. Notice that when you do this, the function gets flatter at the origin.

The increasing flatness of these functions is related to their derivatives. The first derivative of x2 (at the orgin) is 0, but its second derivative is not. On, the other hand, x3 is flatter, and both its first and second derivatives are 0 at the orgin. The general idea is that a function with its first several derivatives equal to zero is pretty flat, and the more derivatives equal to zero, the flatter it gets.

Now suppose we wanted to approximate the function $ e^x $ with a polynomial p(x) at x=0. Then one way to do this would be to make the difference flat. That is, we would want $ p(0)=e^x|_0 $ , $ p'(0) 
=(e^x)'|_0 $ , and so on.

Question 2 (2 marks)

Which of the following quadratic polynomials provides the best approximation to $ e^x $ at x = 0 in the sense that the graph of $ e^x-p(x) $ is flattest at the origin?
a) x2 b) 1 + x + x2 c) 1 + x + x2/2 d) 1 - x - x2 e) 1 - x - x2/2

Coefficients and Derivatives

In the previous section we explored some ideas on how to make a polynomial p(x) approximate a smooth function f(x) near 0. The answer we found was to ensure that as many derivatives as possible of the two functions match at 0. How do the derivatives of a polynomial relate to the coefficients of a polynomial?

Remember that a polynomial of degree n can be written as a sum

\[ p(x)=c_0+c_1x+\cdot\cdot\cdot+c_nx^n=\sum_{m=0}^{n} c_m x^m  \] .

The derivative of p(x) is a polynomial of degree n - 1,

\[ p'(x)=c_1+2c_2x+\cdot\cdot\cdot+nc_nx^{n-1}=\sum_{m=0}^{n-1} (m+1) c_{m+1} x^m  \] .

Substituting x = 0 into p(x) we see that p(0) = c0. Substituting x = 0 into p'(x), we see that p'(0) = c1. Notice that p(0) is related to c0 and p'(0) is related to c1. This connection is true also for larger derivatives.

Question 3 (2 marks)

If p(x) is written as in the previous paragraph, what is p''(0)?
a) c2 b) c1 c) 2c2 d) c1+c2 e) c0

In general, the kth derivative of p(x) at x = 0 (which we will write as p(k)(0)) is given by

\[  1 \cdot 2 \cdot 3 \cdot\cdot\cdot k  c_k \] .

The factor at the front of ck appears so often that we give it a name

\[  1 \cdot 2 \cdot 3 \cdot\cdot\cdot k = \] k!,

which we pronounce "kay factorial". Suppose we want to approximate the function f(x) near x = 0 with a polynomial p(x). Then we want p(0) = f(0), p'(0) = f'(0), and so on. Since p(k)(0)= k!ck, if we want p(k)(0)= f(k)(0), then we get the formula k! ck = f(k)(0). In other words

\[  c_k=\frac{f^{(k)}(0)}{k!}  \] .

This is a pretty handy formula. A polynomial of degree n with these coefficients is called "the nth Taylor polynomial of f at 0". This polynomial can be written

\[  p(x) = \sum_{m=0}^{n} \frac{f^{(m)}(0)}{m!} x^m  \] .

In the diagram to the right you see the plot of $ e^x(x) $ and its Taylor polynomial of degree n at x = 0 (which we will call pn(x)). You can increase the value of n. As you do so, the graph of the polynomial looks more like the graph of $ e^x $ . For any fixed value of x, pn(x) gets closer and closer to $ e^x $ as n becomes large. We write the limit of pn(x) as

\[ \sum_{m=0}^{\infty} \frac{f^{(m)}}{m!}x^m \] ,

which we call the Taylor series of f at x = 0.

The remarkable fact is that for smooth functions, there is a region near 0 such that

\[ f(x)=\sum_{m=0}^{\infty} \frac{f^{(m)}}{m!}x^m \]

for all x in that region. Of course, since we can't add infinitely many terms, we never use a Taylor series for computations (we use Taylor polynomials instead). But it is useful to have the concept of this infinite series.

Using Differential Equations to Find Taylor Polynomials

Now that we know what a Taylor series is, we are going to look at a way to use differential equations to quickly find the coefficients of a Taylor polynomial.

Suppose we want to find a series for cos(x). We know that the derivative of cos(x) is -sin(x), and the second derivative is -cos(x). So, cos(x) is a solution of the differential equation

y''(x) = -y(x).

Now suppose that cos(x) has a Taylor series

\[ cos(x)=\sum_{m=0}^{\infty} c_m x^m \] .

What do you think the "derivative" of this series is? The natural guess is that you differentiate each term of the series, just like you do for polynomials. This intuition is mostly correct, although you have to approach the problem from another angle to show that this is true. Using this fact, however, we can show that

\[ cos(x)=-\frac{d^2}{dx^2}cos(x)=\sum_{m=0}^{\infty} -(m+1)(m+2)c_{m+2} x^m \] .

by "differentiating" the series twice. So now we have two series for cos(x):

\[ cos(x)=\sum_{m=0}^{\infty} c_m x^m = 
\sum_{m=0}^{\infty} -(m+1)(m+2)c_{m+2} x^m \] .

We would expect that the terms of these series are the same. This means cm= -(m+1)(m+2)cm+2, or better yet

\[  c_{m+2}=\frac{-c_m}{(m+1)(m+2)} \] .

We can use this formula to find the coefficients of the series. For example, since c0 = cos(0) = 1, we know c2 = -c0/(0+1)(0+2) = -1/2. And now that we know c2, we can easily find c4.

Question 4 (4 marks)

In the diagram below you see on the left a graph of cos(x). In the boxes above the graph you can enter the coefficients of a polynomial, which will also be plotted on the left. On the right you see the difference of the two functions.

Use the formula given above for cm+2 to find the coefficients of the Taylor polynomial of degree 8 of cos(x) at 0. Enter the coefficients into the appropriate boxes below. In each box you can enter a number, like 1.3, or a fraction of two numbers, such as -1/4. (The box will turn red if you have entered in something it doesn't understand, like 4*3).

Notice when you are done that the plot on the right is very flat near the origin, just as we discussed at the beginning of the lab.


You have now completed the lab and you may save your work. If technical problems prevent your answers from being saved, you will receive a message telling you so. In that case, you will either have to submit your work from the Math labs or try again from some other place. We will NOT accept your answers by e-mail.