Taylor Series & Error n Series and Iterative methods Any series ∑xn can be turned into an iterative method by considering the sequence of partial sums sn. sn x k x 0 x1 x 2 x n k 0 s n s n 1 x n Functions and Taylor Expansions From Intermediate Calculus we know any function that has n+1 derivatives at a point a has a nth Taylor Polynomial expansion centered at a and an expression for the error. f x n f k k! k 0 f x f a Rn x a x a k f a ' 1! error x a f c n 1 x a n 1 ! f n 1 '' a 2! x a 2 f n a n! x a n R n x The value f(k)(a) is the kth derivative evaluated at a. The function Rn(x) represents the error where c is a value between x and a. Examples of Taylor Series Because the higher derivatives of some functions repeat in a recognizable pattern we are able to get a few "standard" Taylor Series expansions. All of the examples below have the center point of 0 and the error term will go to zero for suitable values of x. Other more complicated functions can be found using the algebra, derivatives and integrals. n 1 1 x x 2 3 k 0 x k k! 1 x x 1! 2 2! 1 k x 2 k 1 x 2 k 1 ! k 0 x sin 1 k x 2 k x 2 k ! k 0 x n cos 1 3 3! n x 3 2 2! x x n2 x n 1 c n 1 ! 4 4! e 5 5! x 1 c n n! 3! x 1 n k 0 e x 1 x x x x k x x n 1 2 n 1 sin c 2 n 1 ! 2 n 2 ! x 2n cos c 2 n ! 2 n 1 ! x 2n2 x 2n2 To find the Taylor series for the function f(x) = arctan(x). 1 1 x x 1 x x x k 2 3 Start with known Taylor Series k 0 1 1 x k x Substitute –x for x 1 x x x 2 3 k 0 1 1 x 2 1 k x 2k 1 x x x 2 4 6 k 0 1 k x 2 k 1 arctan x 2k 1 k 0 x 3 x x 3 5 x 5 cosh x x 2k 2 k ! 1 k 0 x 2 2! x k x k 0 3 x cosh k 3 x x 2 k ! k 0 x 4! x 1 2 k ! 2! x 4 3 x 7 7 To find the Taylor series for the function cosh Substitute x2 for x Integrate both sides. g x x cosh 3 x 6 Start with known Taylor Series 6! x 2 4! x 3 Substitute 6! 4 2! x x 5 4! x 6 6! Multiply by x3 x for x A second version of Taylor Polynomials For any function f(x) consider the function f(x+h) where we think of x as a constant and h is the variable. Consider the Taylor expansion for f(x+h) (with variable h) centered at 0. The kth derivatives are found to the right. f x h n f k 0 k x k! h f x k f ' x 1! h f '' x d f x h k dh k h 2 f k x h h0 f k h0 k f 2! x h k f x c k 1 h k 1 ! k 1 k! This is a more computationally useful way of applying Taylor Series to approximate functions. We think of the value of h as small (close to zero) and will represent the distance between computable derivatives and x. Consider the following example. Approximate sin(30.01º) with an error of less than 0.00000001. h sin 30 . 01 . 01 180 We first need to convert to radians to get the value for h. sin 30 . 01 x sin 30 .01 sin 180 6 . 01 180 We need to figure out the value of k that sin gives the desired accuracy. The exact Error error is given by the expression to the right. 6 c or cos 6 c . 01 k 1! 180 We know the values for sine and cosine are always less than 1 in absolute value and is less than 4. Try different values of k that make this inequality true. Error sin 6 c or cos 6 c . 01 k 1! 180 k 1 k 1! 4500 1 k 1 . 00000001 When we try k=2 we find the right side is 0.000000000001829. This means we need go out to the k=2 term. sin 30 . 01 sin 6 . 01 180 01 01 2 sin 6 cos 6 .180 sin 6 .180 2 3 . 01 1 . 01 0.50015113 4716148 2 2 180 2 180 1 sin 30 . 01 0.50015114 2330817... k 1 Alternating Series and Error From intermediate calc remember that a series ∑(-1)kak converges if the sequence ak are positive terms that decrease to zero, this was called the alternating series test. The series ∑(-1)kak is called an Alternating Series. The nice thing about alternating series is that keeping tract of the error is very easy as given by the theorem below. Alternating Series Error Theorem In any convergent alternating series ∑(-1)kak the error is always less than the first term omitted. In other words: |Error| < ak+1 Example: Compute 1/e accurate to .0001 1 e 1 11 e 1 2! 1 1 3! 1 The series for 1/e is alternating so the theorem applies. 4! We need to go to the k=7 term. 0.00002480 16 .0001 8! 1 e 11 1 2! 1 3! 1 4! 1 5! 1 6! 1 7! 0.36785714 29 1 e 0.36787944 1