\[ \small{ \begin{aligned} f(x) & \cong f(a) + f'(a)(x-a) + \frac{f''(a)}{2}(x-a)^2 + \cdots + \frac{f^{(n)}(a)}{n!}(x-a)^n \\ & = \sum_{k=0}^{n} \frac{f^{(k)}(a)}{k!} (x-a)^k \\ & = P_n(x) \end{aligned} } \]
\[ \small{ f(x) \cong f(a) + f'(a)(x-a) + \frac{f''(a)}{2}(x-a)^2 + \cdots + \frac{f^{(n)}(a)}{n!}(x-a)^n} \]
\[ \small{ P_3(x) = f(a) + f'(a)(x-a) + \frac{f''(a)}{2}(x-a)^2 + \frac{f'''(a)}{6}(x-a)^3 } \]
\[ \small{ \left. \begin{aligned} f(x) &= \ln(x), \,\,\, a = 1 \\ \\ f(1) & = \ln(1) = 0 \\ f'(1) &= \left. \frac{1}{x}\right|_{x=1} = 1 \\ f''(1) &= - \left.\frac{1}{x^2}\right|_{x=1} = -1 \\ f'''(1) &= \left.\frac{2}{x^3}\right|_{x=1} = 2 \end{aligned} \right\} \Rightarrow \begin{aligned} P_3(x) & = 0 + (x-1) - \frac{1}{2}(x-1)^2 + \frac{1}{3}(x-1)^3 \\ & = \frac{1}{3}x^{3}-\frac{3}{2}x^{2}+3x-\frac{11}{6} \\ \end{aligned} } \]
\[ \small{ P_3(x) = (x-1) - \frac{1}{2}(x-1)^2 + \frac{1}{3}(x-1)^3 } \]
\[ \small{ \begin{aligned} P_3(x) & = \frac{1}{3}x^{3}-\frac{3}{2}x^{2}+3x-\frac{11}{6} \\ & = \left(\left(\frac{1}{3}x-\frac{3}{2}\right)x+3\right)x- \frac{11}{6} \end{aligned} } \]
nested <- function(x, coeffs) {
n = length(coeffs)
s <- coeffs[1]
for(i in 2:n)
s <- s*x + coeffs[i]
return(s) }
y<-c(1/3,-3/2,3,-11/6)
(p3 <- nested(1.9,y))
[1] 0.738
(f <- log(1.9))
[1] 0.6418539
(E <- f - p3)
[1] -0.09614611
There is a formula \( R \) for the error \( E \), but an upper bound for it has to be estimated because it involves an unknown value:
\[ \small{ \begin{aligned} E_n(x) &= f(x) - P_n(x) \\ & = \frac{(x-a)^{n+1}}{(n+1)!}f^{(n+1)}(c(x)) \\ & = R_n(c(x),x) \\ & = R_n(x) \end{aligned} } \]
For the remainder \( R \):
Consider the graph of \( R(x) \).
Answer the following.
\[ \small{ R_n(x_0)= \frac{(x_0-a)^{n+1}}{(n+1)!}f^{(n+1)}(c(x_0)) } \]
where \( c(x_0) \) is an unknown value between \( a \) and \( x_0 \).
For \( f(x) = \ln(x) \), \( a=1 \), and \( x_0 = 1.9 \):
\[ \small{ \begin{aligned} c(1.9) & \cong 1.2 \\ R_3(1.9) & \cong 0.1 \\ |R_3(1.9)| & \leq \max_{1 \leq x \leq 2} |R_3(x)| \leq 0.2 \end{aligned} } \]
For \( f(x) = \ln(x) \), derivatives are:
\[ \scriptsize{ \begin{aligned} f'(x) = \frac{1}{x}, \,\, f''(x) = -\frac{1}{x^2}, \,\, f'''(x) &= \frac{-2}{x^3}, \,\, f^{(4)}(x) = \frac{3\cdot 2}{x^4} = \frac{3!}{x^4} \end{aligned} } \]
Now \( 1/x^4 \) positive & decreasing on [1,2], so max occurs \( x=1 \):
\[ \scriptsize{ \begin{aligned} R_3(x) &= \frac{(x-a)^4}{4!}f^{(4)}(c(x)) \\ \left| R_3(1.9) \right| & \leq \max_{1 \leq x \leq 2} \left|\frac{(1.9-1)^4}{4!} \frac{3!}{x^4}\right| = \frac{(0.9)^4}{4} \frac{1}{1^3} \leq 0.17 \end{aligned} } \]
0.25*(0.9)^4
[1] 0.164025
From the previous slides, we have the following results:
\[ \small{ \begin{aligned} f(1.9) &= \ln(1.9) \cong 0.6418539 \,\, \mathrm{(actual \, value)} \\ P_3(1.9) &= 0.738 \,\, \mathrm{(nested \, evaluation)} \\ R_3(1.9) & = f(1.9) - P_3(1.9) \cong 0.09614611 \,\, \mathrm{(actual \, error)} \\ R_3(1.9) & \cong 0.1 \,\, \mathrm{(graphical \, estimate \, of \, error)} \\ |R_3 (1.9)| & \leq \max_{1 \leq x \leq 2} |R_3(x)| \leq 0.17 \,\, \mathrm{(analytical \, bound \, on \, error)} \end{aligned} } \]
(a) Let \( f(x) = \cos(x) \), \( a=0 \), \( x_0 = 1 \), \( n=2 \). Find \( P_2(x) \).
\[ \small{ \left. \begin{aligned} f(0) & = \cos(0) = 1 \\ f'(0) &= \left. -\sin(x)\right|_{x=0} = 0 \\ f''(0) &= - \left.\cos(x)\right|_{x=0} = -1 \\ f'''(x) &= \sin(x) \end{aligned} \right\} \Rightarrow P_2(x) = 1 - \frac{1}{2}x^2 } \]
(b) For \( f(x) = \cos(x) \), \( a=0 \), and \( x_0 = 1 \):
\[ \small{ \begin{aligned} c(1) & \cong 0.24 \\ R_2(1) & \cong 0.05 \\ |R_2(1)| & \leq \max_{0 \leq x \leq 1} |R_2(x)| \leq 0.14 \end{aligned} } \]
\( \mathrm{(c)} \) To find upper bound on \( |R_2(1)| \), first find derivatives:
\[ \small{ f(x) = \cos(x), \, f'(x) = -\sin(x), \, f''(x) = -\cos(x), \, f'''(x) = \sin(x) } \]
For \( |x| \) small, a helpful property is \( \small{\sin(x) < x} \).
Since \( \small{0 < c(1) < 1} \), it follows that \( \small{ \sin(c(1)) < c(1) < 1} \).
\[ \scriptsize{ \begin{aligned} R_2(x) &= \frac{(x-a)^3}{3!}f^{(3)}(c(x)) \\ \left| R_2(1) \right| & \leq \max_{0 \leq x \leq 1} \left|\frac{(1-0)^3}{3!} \sin(c(1)) \right| < \frac{1}{6} c(1) < \frac{1}{6} = 0.1666\ldots < 0.17 \end{aligned} } \]
\[ \small{ \begin{aligned} f(1) &= \cos(1) \cong 0.54030231 \\ P_2(1) &= 1 - \frac{1}{2}(1)^2 = 0.5 \\ R_2(1) & = f(1) - P_2(1) \cong 0.04030231 \,\, \mathrm{(actual \, error)} \\ R_2(1) & \cong 0.05 \,\, \mathrm{(graphical \, estimate \, of \, error)} \\ |R_2(1)| & \leq \max_{1 \leq x \leq 2} |R_2(x)| \leq 0.17 \,\, \mathrm{(analytical \, bound \, on \, error)} \end{aligned} } \]
For some function \( f \), suppose we seek an upper bound on
\[ \small{R_3(x_0) = \frac{(x_0-a)^{n+1}}{(n+1)!}f^{(4)}(c(x_0))} \]
where \( c(x_0) \) is between \( a \) and \( x_0 \) within [0,4], and
\[ \small{ f^{(4)}(x) = 4x^3-x^4} \]
\[ \small{ g'(x) = 12x^2-4x^3 = 4x^2(3-x) = 0 \, \Rightarrow \, x = 0, 3 } \]
g <- function(x){4*x^3-x^4}
(y <- c(g(0),g(3),g(4)))
[1] 0 27 0
\[ \small{ \begin{aligned} f(x) & \cong f(a) + f'(a)(x-a) + \frac{f''(a)}{2}(x-a)^2 + \cdots + \frac{f^{(n)}(a)}{n!}(x-a)^n \\ R_n(x_0) & = \frac{(x_0-a)^{n+1}}{(n+1)!}f^{(n+1)}(c(x_0)) \end{aligned}} \]
Let \( f(x) =3x^3 - 6x^2+15 \) on [-1,6].
Let \( f(x) = \cos(x) \) on [0,1] with \( a = 0 \) and \( x_0 = 0.1 \).
Let \( f(x) = \sqrt{x} \) on [0,4] with \( a = 0 \) and \( x_0 = 1 \).