Approximation of a Function by a Polynomial Function
Total Page:16
File Type:pdf, Size:1020Kb
1 Approximation of a function by a polynomial function 1. step: Assuming that f(x) is differentiable at x = a, from the picture we see: 푓(푥) = 푓(푎) + ∆푓 ≈ 푓(푎) + 푓′(푎)∆푥 Linear approximation of f(x) at point x around x = a 푓(푥) = 푓(푎) + 푓′(푎)(푥 − 푎) 푅푒푚푎푛푑푒푟 푹 = 푓(푥) − 푓(푎) − 푓′(푎)(푥 − 푎) will determine magnitude of error Let’s try to get better approximation of f(x). Let’s assume that f(x) has all derivatives at x = a. Let’s assume there is a possible power series expansion of f(x) around a. ∞ 2 3 푛 푓(푥) = 푐0 + 푐1(푥 − 푎) + 푐2(푥 − 푎) + 푐3(푥 − 푎) + ⋯ = ∑ 푐푛(푥 − 푎) ∀ 푥 푎푟표푢푛푑 푎 푛=0 n 푓(푛)(푥) 푓(푛)(푎) 2 3 0 푓 (푥) = 푐0 + 푐1(푥 − 푎) + 푐2(푥 − 푎) + 푐3(푥 − 푎) + ⋯ 푓(푎) = 푐0 2 1 푓′(푥) = 푐1 + 2푐2(푥 − 푎) + 3푐3(푥 − 푎) + ⋯ 푓′(푎) = 푐1 2 2 푓′′(푥) = 2푐2 + 3 ∙ 2푐3(푥 − 푎) + 4 ∙ 3(푥 − 푎) ∙∙∙ 푓′′(푎) = 2푐2 2 3 푓′′′(푥) = 3 ∙ 2푐3 + 4 ∙ 3 ∙ 2(푥 − 푎) + 5 ∙ 4 ∙ 3(푥 − 푎) ∙∙∙ 푓′′′(푎) = 3 ∙ 2푐3 ⋮ (푛) (푛) n 푓 (푥) = 푛(푛 − 1) ∙∙∙ 3 ∙ 2 ∙ 1푐푛 + (푛 + 1)푛(푛 − 1) ⋯ 2푐푛+1(푥 − 푎) 푓 (푎) = 푛! 푐푛 ⋮ Taylor’s theorem If f (x) has derivatives of all orders in an open interval I containing a, then for each x in I, ∞ 푓(푛)(푎) 푓(푛)(푎) 푓(푛+1)(푎) 푓(푥) = ∑ (푥 − 푎)푛 = 푓(푎) + 푓′(푎)(푥 − 푎) + ⋯ + (푥 − 푎)푛 + (푥 − 푎)푛+1 + ⋯ 푛! 푛! (푛 + 1)! 푛=0 푛 ∞ 푓(푘)(푎) 푓(푘)(푎) = ∑ (푥 − 푎)푘 + ∑ (푥 − 푎)푘 푘! 푘! 푘=0 푘=푛+1 convention for the sake of algebra: 0! = 1 = 푇푛 + 푅푛 푛 푓(푘)(푎) 푇 = ∑ (푥 − 푎)푘 푝표푙푦푛표푚푎푙 표푓 푛푡ℎ 표푟푑푒푟 푛 푘! 푘=0 푓(푛+1)(푧) 푛+1 푅푛(푥) = (푥 − 푎) 푠 푟푒푚푎푛푑푒푟 푅푛 (푛 + 1)! Taylor’s theorem says that there exists some value 푧 between 푎 and 푥 for which: ∞ 푓(푘)(푎) 푓(푛+1)(푧) ∑ (푥 − 푎)푘 can be replaced by 푅 (푥) = (푥 − 푎)푛+1 푘! 푛 (푛 + 1)! 푘=푛+1 2 Approximating function by a polynomial function So we are good to go. We can find value of 풇(풙) around 풂 by calculating 푇푛 , and then adding 푅푛. Instead of adding infinite number of terms (how in the world???), we have finite number of terms. Beautiful. A little problem: We know z exists, BUT we don’t know how to find z . That’s why we use approximation: By approximating 풇(풙) with 푇푛 we neglect 푅푛. We can do it only if 푅푛 is very small compared to 푇푛. So if we find maximum possible value for 푅푛, and that value is small compared to 푇푛, we found good approximation: 푛 푓(푘)(푎) 푓(푥) ≈ ∑ (푥 − 푎)푘 푘! 푘=0 푓(푛+1)(푧) error is remainder 푅 (푥) = (푥 − 푎)푛+1 푧 is the value between 푎 and 푥 , that yields maximum 푅 푛 (푛 + 1)! 푛 A Maclaurin series is a Taylor series for n = 0 푓(푥) = 푓(푎) + 푓′(푧)(푥 − 푎) expansion of a function about 0 푓(푥) − 푓(푎) 푓′(푧) = → 푀퐸퐴푁 푣푎푙푢푒 푡ℎ푒표푟푒푚 푥 − 푎 Problems: • For what values of x can we expect a Taylor series to represent f (x)?→ 푟푎푑푢푠 표푓 푐표푛푣푒푟푔푒푛푐푒 • How accurately do Taylor polynomials approximate the f (x)? → magnitude of the error 푅푛 example 1: Find Taylor’s series for sin x centered at a = 0 (McLaurin series). 푓(푥) = 푠푛 푥 푓(0) = 0 ′ 푓 (푥) = 푐표푠 푥 푓′(1) = 1 ′′ 푓′′(푥) = −푠푛 푥 푓 (1) = 0 ′′′ ′′′ 푓 (푥) = − cos 푥 푓 (1) = −1 (4) (4) 푓 (푥) = sin 푥 푓 (1) = 0 푡ℎ푠 푝푎푡푒푟푟푛 푤푙푙 푟푒푝푒푎푡 ∞ 푓(푛)(푎) −1 푓(푥) = ∑ (푥 − 푎)푛 = 0 + 1푥 + 0푥2 + 푥3 + 0푥4 + ⋯ 푛! 3! 푛=0 ∞ 푥3 푥5 푥7 (−1)푛푥2푛+1 = 푥 − + − + ⋯ = ∑ 3! 5! 7! (2푛 + 1)! 푛=0 Signs alternate and the denominators get very big; factorials grow very fast. Ratio test: 푥2푛+3 (2푛 + 1)! 1 lim | ∙ | = |푥2| lim | | = |푥2| ∙ 0 푛→∞ (2푛 + 3)! 푥2푛+1 푛→∞ (2푛 + 3)(2푛 + 2) This converges for any value of x. The radius of convergence is infinity. 3 example 2: Find fifth order Taylor’s approximation for f(x) = ln x centered at a = 1. 푓(푥) = ln 푥 푓(1) = 0 푓′(푥) = 1/ 푥 푓′(1) = 1 푓′′(푥) = −1/푥2 푓′′(1) = −1 푓′′′(푥) = 2!⁄푥3 푓′′′(1) = 2! 푓(4)(푥) = − 3!⁄푥4 푓(4)(1) = − 3! 푓(5)(푥) = 4!⁄푥5 푓(5)(1) = 4! (−1)푛+1 (푛 − 1)! 푓(푛)(푥) = → 푓(푛)(1) = (−1)푛+1 (푛 − 1)! 푥푛 푓(푛)(1) (−1)푛+1 푐 = = 푛 푛! 푛 ∞ ∞ 푓(푛)(1) (−1)푛+1 1 1 1 ln(푥) = ∑ (푥 − 1)푛 = ∑ (푥 − 1)푛 = (푥 − 1) − (푥 − 1)2 + (푥 − 1)3 − (푥 − 1)4 + ⋯ 풇풐풓 |풙 − ퟏ| < ퟏ 푛! 푛 2 3 4 푛=0 푛=1 1 1 1 1 ퟎ < 풙 ≤ ퟐ 푃 (푥) = (푥 − 1) − (푥 − 1)2 + (푥 − 1)3 − (푥 − 1)4 + (푥 − 1)5 5 2 3 4 5 example 2: Find Maclaurin series for f(x) = ln (x+1) 푓(푥) = ln(1 + 푥) 푓(0) = 0 푓′(푥) = 1/(1 + 푥) 푓′(0) = 1 푓′′(푥) = −1/(1 + 푥)2 푓′′(0) = −1 푓′′′(푥) = 2!⁄(1 + 푥)3 푓′′′(0) = 2! 푓(4)(푥) = − 3!⁄(1 + 푥)4 푓(4)(0) = −3! (−1)푛+1 (푛 − 1)! 푓(푛)(푥) = 푓(푛)(0) = (−1)푛+1 (푛 − 1)! (1 + 푥)푛 푓(푛)(0) (−1)푛+1 푐 = = 푛 푛! 푛 ∞ ∞ 푓(푛)(0) (−1)푛+1 푥푛 푥2 푥3 푥4 푥5 ln(1 + 푥) = ∑ 푥푛 = ∑ = 푥 − + − + + ⋯ 풇풐풓 |풙| < ퟏ − ퟏ < 풙 ≤ ퟏ 푛! 푛 2 3 4 5 푛=0 푛=1 Exact value of z is only a dream. If we knew it we would know exact expansion of a given function and it wouldn’t be approximation any more. Our goal is to find the bounds for 푓(푛+1)(푧) so we can see how large remainder could be. example: Use Taylor theorem to approximate sin(0.1) by the third order polynom P3(0.1) and determine the accuracy of the approximation. 푥3 푥3 푓(4)(푧) 푠푛 푥 = 푥 − + 푅 (푥) = 푥 − + 푥4 0 < z < 0.1 푓(4)(푧) = sin 푧 3! 3 3! 4! (0.1)3 푠푛(0.1) ≈ 0.1 − = 0.0099833 3! sin 푧 0.0001 0 < 푅 (0.1) = (0.1)4 < ≈ 0.000004 0.0099833 < 푠푛(0.1) < 0.0099833 + 0.000004 = 0.099837 3 4! 4! 4 example: Use Taylor theorem to approximate ln (1.2) so error is less than 0.001 푓(푛+1)(푧) 푅 (푥) = (푥 − 푎)푛+1 < 0.001 푛 (푛 + 1)! 1. Taylor theorem with a = 0 gives Maclaurin series of ln(1 + 푥) 푤푡ℎ 푥 = 0.2 In example 2 you saw that (n+1)st derivate of 푓(푥) = 푙푛(푥 + 1) is given by (−1)푛+2 푛! (−1)푛+2 푛! (1 + 푧)푛+1 (−1)푛+2 푓(푛+1)(푥) = → |푅 (0.2)| = | | (0.2)푛+1 = | | (0.2)푛+1 (1 + 푥)푛+1 푛 (푛 + 1)! (푛 + 1) (1 + 푧)푛+1 0 < z < 0.2 maximum error would be for z = 0 (−1)푛+2 (0.2)푛+1 | | (0.2)푛+1 < 0.001 < 0.001 (푛 + 1) 푛 + 1 Either trial and error or Wolframalpha n = 2.5 → n = 3 푥2 푥3 ln(1 + 푥) ≈ 푥 − + = ⋯ 푤푡ℎ 푑푒푠푟푒푑 푎푐푐푢푟푎푐푦 2 3 2. Taylor theorem with a = 1 gives Taylor’s approximation for f(x) = ln x with x = 1.2 푓(푛+1)(푧) 푅 (푥) = (푥 − 푎)푛+1 < 0.001 푛 (푛 + 1)! In example 1 you saw that (n+1)st derivate of 푓(푥) = 푙푛(푥) is given by (−1)푛+2 푛! 푛+2 푛+1 푛+1 (푛+1) (−1) 푛! 푧 푛+1 (0.2) 푓 (푥) = 푛+1 → |푅푛(1.2)| = | (1.2 − 1) | = 푛+1 푥 (푛 + 1)! (푛 + 1) 푧 1 < z < 1.2 maximum error would be for z = 1 푛+2 푛+1 (−1) 푛+1 (0.2) | | (0.2) < 0.001 < 0.001 here we go again (푛+1) 푛+1 Convergence of Taylor Series If f (x) has derivatives of all orders in an open interval I containing a, then for each x in I, ∞ 푓(푛)(푎) 푓(푥) = ∑ (푥 − 푎)푛 푛! 푛=0 ℎ표푙푑푠 푓 푎푛푑 표푛푙푦 푓 (푛+1) 푓 (푧) 푛+1 lim 푅푛(푥) = lim (푥 − 푎) = 0 푓표푟 ∀ 푥 ∈ 퐼 푛→∞ 푛→∞ (푛 + 1)! 5 풆풙풂풎풑풍풆: 푆ℎ표푤 푡ℎ푎푡 푀푎푐푙푎푢푟푛 푠푒푟푒푠 푓표푟 푓(푥) = 푠푛 푥 푐표푛푣푒푟푔푒푠 푡표 푠푛 푥 푓표푟 푎푙푙 푥. 푥3 푥5 푥7 (−1)푛푥2푛+1 푌표푢 푛푒푒푑 푡표 푠ℎ표푤 푡ℎ푎푡 푠푛 푥 = 푥 − + − + ⋯ + + ⋯ 푠 푡푟푢푒 푓표푟 푎푙푙 푥 3! 5! 7! (2푛 + 1)! (푛+1) (푛+1) 퐹표푟 푅푛 푤푒 푛푒푒푑 푓 (푧), 푎푛푑 푎푠 푓 (푥) 푠 푒푡ℎ푒푟 ± 푠푛 푥 표푟 ± 푐표푠 푥 푤푒 푘푛표푤 푡ℎ푎푡 푚푎푥푚푢푚 푣푎푙푢푒 표푓 |푓(푛+1)(푧)| 푠 1 푓표푟 푒푣푒푟푦 푟푒푎푙 푛푢푚푏푒푟 푧. → 푓(푛+1)(푧) |푥|푛+1 | 푅 (푥)| = | 푥푛+1| ≤ → 0 푛 (푛 + 1)! (푛 + 1)! 푥푛 퐹푟표푚 푇푎푦푙표푟 푒푥푝푎푛푠표푛 ≤ 푒푥 ∀푥 ≥ 0.