Error Approximation for Taylor Polynomials

The Error Estimate for Taylor Approximations

Enter the function under consideration, the center of the Taylor Polynomial, its degree, and the x-value for which you'd like to compute the error estimate.
(Enter the center and the x-value as "exact" values such as π/4, (Sqrt[2]), or 12/10 rather than using decimal expressions such as 1.2)

\(f[x_] = Sin[x]; 
appcenter = 0; 
appdegree = 15; 
xvalue = 1/2; 


    der[x_] = D[f[x], {x, appdegree + 1}]; 

    error = Abs[
        Max[Table[
              Abs[N[der[x]]], {x, appcenter, xvalue, 
                \((xvalue - appcenter)\)/250}]]\ 
          \((xvalue - appcenter)\)^\((appdegree + 1)\)/
            \(\((appdegree + 1)\)!\)]; 

    digs = Max[Ceiling[\(-Log[10, error]\) + 10], 10]; 

    approx = N[
        Normal[Series[f[x], {x, appcenter, appdegree}]] /. x -> xvalue, 
        digs]; 
truevalue = N[f[xvalue], digs]; 

    Print["The upper estimate for the error,  given by Taylor's Theorem is:
", error]\)Print["The Taylor approximation of degree ",  appdegree, 
      " at x=", xvalue, " is:\n", approx]Print["The true value of f(x) at x=", xvalue, " is:\n", 
      truevalue]Print["The actual error is:\n",  Abs[truevalue - approx]]\(Print["Is the actual error smaller than the predicted error?
", 
      \((Abs[truevalue - approx] < error)\) /. {True -> Yes, False -> No}]

    \)

Etc.

Author: H. Knaust (helmut@math.utep.edu)
Created: August 2000
Last Edits: September 19, 2000