<<

Seunghee Ye Ma 8: Week 7 Nov 10

Week 7 Summary

This week, we will learn how we can approximate using Taylor and numerical methods.

Topics

Page

1 Approximating Integrals using Taylor 1 1.1 Definitions ...... 1 1.2 Examples ...... 2 1.3 Approximating Integrals ...... 3

2 5

1 Approximating Integrals using Taylor Polynomials

1.1 Definitions When we first defined the , recall that it was supposed to be the “instantaneous rate of change” of a f(x) at a given point c. In other words, f 0 gives us a linear of f(x) near c: for small values of ε ∈ R, we have f(c + ε) ≈ f(c) + εf 0(c) But if f(x) has higher order , why stop with a ? take this idea of linear approximation and extends it to higher order derivatives, giving us a better approximation of f(x) near c.

Definition (Taylor and Taylor Series) Let f(x) be a Cn function i.e. f is n-times continuously differentiable. Then, the n-th order Taylor polynomial of f(x) about c is: n X f (k)(c) T (f)(x) = (x − c)k n k! k=0 The n-th order of f(x) is:

Rn(f)(x) = f(x) − Tn(f)(x)

If f(x) is C∞, then the Taylor series of f(x) about c is:

∞ X f (k)(c) T (f)(x) = (x − c)k ∞ k! k=0

Note that the first order Taylor polynomial of f(x) is precisely the linear approximation we wrote down in the beginning. Now that we defined Taylor polynomials as higher order extensions of the linear approximation, we have to justify our claim that Taylor polynomials are indeed . So what does it mean for a Taylor polynomial Tn(f)(x) to be a good approximation of f(x)? It means that Tn(f)(x) should be close to the true value of f(x). In other words, we want f(x) − Tn(f)(x) to be close to 0. But we defined this difference to be something...

n Theorem 1.1. Let Rn(f)(x) be the n-th order remainder of f(x). Then, Rn(f)(x) is o((x − c) ).

Page 1 of 6 Seunghee Ye Ma 8: Week 7 Nov 10

Theorem 1.1 is saying precisely that Tn(f)(x) is very close to the real value of f(x) when x is near c. Hence, we have our justification for calling Taylor polynomials “higher order approximations” of f(x). Now,

we look at another very useful theorem, which will actually let us compute Rn(f)(x).

Theorem 1.2. Suppose f(x) is (n + 1)-times continuously differentiable. Then,

Z x (n+1) f (y) n Rn(f)(x) = (x − y) dy c n!

With Theorem 1.2, we will be able to know exactly by how much Tn(f)(x) is off the true value of f(x).

1.2 Examples Example 1.1. Compute the Taylor series for f(x) = ex about 0.

Solution. Recall that the Taylor series of f(x) is simply

∞ X f (k)(0) xk k! k=0

However, for all k, f (k)(x) = ex. Hence, for all k, f (k)(0) = e0 = 1. Therefore,

∞ ∞ X f (k)(0) X xk ex = xk = k! k! k=0 k=0

as we already know.

Here are the Taylor series about 0 for some of the functions that we have come across several times. Try to do a couple of them as an exercise!

∞ x3 x5 X x2k+1 • sin x = x − + − · · · = (−1)k 3! 5! (2k + 1)! k=0

∞ x2 x4 X x2k • cos x = 1 − + − · · · = (−1)k 2! 4! (2k)! k=0

∞ 1 X • = xk 1 − x k=0 Let’s look closely at the Taylor series for sin x and cos x. It looks like we’ve split up the Taylor series of x x2 e = 1 + x + 2! + ··· into two and alternated signs. So can we find any relation between these three Taylor series? The answer is yes and in fact, we will see something amazing come out of the inspection. Let i be the imaginary . If you have never seen i before, it’s just some “number” (not real) with the property that i2 = −1. As baffling as it might be to raise a number to a complex power, let’s take a leap of faith and

Page 2 of 6 Seunghee Ye Ma 8: Week 7 Nov 10

raise e to ix power and see what we get. Plugging in ix in the Taylor series for ex we get:

(ix)2 (ix)3 (ix)4 (ix)5 eix = 1 + (ix) + + + + + ··· (1) 2! 3! 4! 5! x2 ix3 x4 ix5 = 2 + ix − − + + − · · · (2) 2! 3! 4! 5!  x2 x4 x6   ix3 ix5 ix7  = 1 − + − + ··· + ix − + − + ··· (3) 2 4! 6! 3! 5! 7!  x2 x4 x6   x3 x5 x7  = 1 − + − + ··· + i x − + − + ··· (4) 2 4! 6! 3! 5! 7! ∞ ! ∞ ! X x2k X x2k+1 = (−1)k + i (−1)k (5) (2k)! (2k + 1)! k=0 k=0 = cos x + i sin x (6)

So there we have it! eix = cos x + i sin x If you are still not convinced that this formula is the most beautiful thing you’ve seen in math, try plugging in x = π. If we let x = π, what do we get?

eiπ = cos π + i sin π = −1 ⇒ eiπ + 1 = 0

This equation is called the Euler’s formula and dubbed “the most beautiful equation in mathematics”. 0, 1, π, e, and i are arguably the five most important in all of math and to see them appear in one equation is indeed quite amazing!

1.3 Approximating Integrals Now, we will see how Taylor polynomials can help us approximate integrals. For example, consider the 2 Gaussian R e−x dx called the Gaussian for short. The Gaussian is a very important integral, one of the properties being that it is the curve that represents the a.k.a. the bell curve. We would like to evaluate the Gaussian but there is one problem: there is no elementary 2 of e−x . This means that we cannot rely on the Fundamental Theorem of to evaluate the integral. But using Taylor series, we can approximate the value of this integral.

1 Z 3 2 Example 1.2. Approximate e−x dx to within 10−6 of its actual value. 0

−x2 −x2 Solution. To simplify notation, we will write Tn(x) and Rn(x) for Tn(e )(x) and Rn(e )(x), respectively. −x2 For any n, we have e = Tn(x) + Rn(x). By integrating both sides, we obtain

1 1 1 Z 3 Z 3 Z 3 −x2 e dx = Tn(x)dx + Rn(x)dx 0 0 0

1 Z 3 Now, Tn(x) is just a polynomial. Therefore, Tn(x)dx is an integral that we can explicitly compute. On 0 R the other hand, we know that Rn(x) goes to 0 as n increases. So the idea is to make | Rn(x)dx| small by R 1/3 −6 increasing n: In our case, we want to find n such that | 0 Rn(x)dx| < 10 . By Theorem 1.2, we have

Z x −y −x n+1 e n Rn(e )(x) = (−1) (x − y) dy 0 n!

Page 3 of 6 Seunghee Ye Ma 8: Week 7 Nov 10

However, note that

n 2 k ! 2 2 X (−x ) R (x) = e−x − T (x) = e−x − = R (e−x)(x2) n n k! n k=0

Hence, we see that Z x2 −y n+1 e 2 n Rn(x) = (−1) (x − y) dy 0 n! Unfortunately, this is not something we can easily integrate. However, we are not interested in the actual value of the integral. We are only interested in making this integral close to 0. 2 −y 0 2 n 2 n How do we bound Rn(x)? First, note that for any y ∈ [0, x ], e ≤ e = 1; and (x − y) ≤ (x − 0) = 2n 2 2−y 2 n x . Note also that for all y ∈ [0, x ], we have n! (x − y) ≥ 0. This gives us

2 Z x e−y n+1 2 n |Rn(x)| = (−1) (x − y) dy (7) 0 n! 2 Z x e−y = (x2 − y)ndy (8) 0 n! 2 Z x 1 ≤ x2ndy (9) 0 n! 2 x2n x = y (10) n! 0 x2n+2 = (11) n! In our case, we want 1 1 1 Z 3 Z 3 x2n+2  x2n+3  3 −6 Rn(x)dx ≤ dx = < 10 0 0 n! (2n + 3)n! 0 Therefore, we need to find a value of n for which

1 12n+3 < 10−6 (2n + 3)n! 3

Checking small values of n = 1, 2... we see that when n = 3, the inequality is satisfied. 1 1 Z 3 Z 3 −6 −x2 This means that T3(x)dx is within 10 of the true value of e dx. First, let’s compute T3(x) 0 0 which is easy since we already know that Taylor series of ex:

x4 x6 T (x) = 1 − x2 + − 3 2 3!

1 We can now integrate T3(x) over [0, 3 ] to approximate the Gaussian:

1 1 Z 3 Z 3 4 6 2 x x T3(x)dx = 1 − x + − dx (12) 0 0 2 6 1  x3 x5 x7  3 = x − + − (13) 3 10 42 0 147604 = (14) 459270

Page 4 of 6 Seunghee Ye Ma 8: Week 7 Nov 10

Therefore, we conclude that 1 Z 3 2 147604 e−x dx = ± 10−6 0 459270

This example shows that Taylor polynomials can be used effectively to approximate integrals. However, we should note that approximating with Taylor polynomials works well near the point about which we are 2 Z 2 writing the Taylor polynomial. For example, if we were to approximate e−x dx to within 10−1 of its true 0 Z 2 value using Taylor polynomials, we would need to compute T11(x)dx. 0 In our example, the third order Taylor polynomial was good enough to approximate the integral to −6 1 within 10 . However, as we get farther away from 0 (for us from 3 to 2), we need the eleventh order Taylor polynomial just to get a value that is within 10−1 of the true value.

2 Numerical Integration

In Section 1, we saw how we can use Taylor polynomials to approximate integrals. Now, we see a few other numerical methods we can use to approximate integrals. Recall that the integral was defined as the greatest lower bound of all the upper Riemann sums. Equiv- alently, we saw that it was the of the upper Riemann sums associated to the uniform partitions as n → ∞. Numerical integration tries to approximate the integral by a sum that resembles the Riemann sums.

Midpoint rule Let f be a function on [a, b] and consider the uniform partition Pn of [a, b]. Then, define

(j − 1 )(b − a) m = a + 2 j n

In other words, we define mj to be the midpoint of the subinterval (tj−1, tj). Now, define

n X b − a J = f(m ) 2 n j j=1

Note that J2 looks like the Riemann sum except we have replaced sup f(x) with f(mj). It turns out that R b J2 provides a decent approximation of a f(x)dx. In fact, we have

Z b  1  J − f(x)dx = O 2 2 a n Instead of proving this theorem, let’s look at a more advanced numerical integration method:

Simpson’s rule Again, we start with a funciton f(x) defined on [a, b] and let Pn be a uniform partition of [a, b]. Hence, we have j(b − a) x = a + j n

Again, let mj be the midpoint of [xj−1, xj] i.e. x , x m = j−1 j j 2

Page 5 of 6 Seunghee Ye Ma 8: Week 7 Nov 10

Now, we consider n   X f(xj−1) + 4f(mj) + f(xj) b − a J = · 3 6 n j=1

Note that this time, we chose a weighted average of f(xj−1, f(mj) and f(xj) instead of choosing a particular point. Why is this a good idea? Let’s look at the following lemma.

b−a Lemma 2.1. Let I = [a, b] be any and let q(x) be a quadratic polynomial on I. Let m = 2 be the midpoint of I. Then, Z b b − a q(x)dx = (q(a) + 4q(m) + q(b)) a 6

Before we prove the lemma, note that this lemma says that if f is a quadratic polynomial, then J3 is in fact equal to R f(x)dx. Proof. Suppose q(x) is quadratic. By considering p(x) = q(x − m), we can assume without loss of generality 2 that the interval [a, b] is of the form [−a, a]. Suppse p(x) = c0 + c1x + c2x . Then, we get

Z a  2 3 a 2 c1x c2x c0 + c1x + c2x dx = c0x + + (15) −a 2 3 −a 2c a3 = 2c a + 2 (16) 0 3 Computing the right hand side, we see that the equality is indeed satisfied. Now, suppose f(x) is C2. Then, we can consider the second order Taylor polynomial of f(x):

f 00(m ) T (f)(x) = f(m ) + f 0(m )(x − m ) + j (x − m )2 2 j j j 2 j

2 3 By Theorem 1.1, we know that R2(f)(x) is o((x − mj) ). In fact, R2(f)(x) is O((x − mj) ). Since T2(f)(x) is a quadratic polynomial, by Lemma 2.1, we know that

Z xj T2(xj−1) + 4T2(f)(mj) + T2(f)(xj) T2(f)(x)dx = (xj − xj−1) xj−1 6

Z xj In particular, if we consider the difference between f(x)dx and the j-th term in J3, the difference is xj−1 b−a 1  R 1  n O n3 . Hence, the difference between f(x)dx and J3 is O n3 .

Page 6 of 6