### Differentiation, derivatives and Taylor approximations: Taylor approximations

### Taylor polynomials

Approximating a mathematical function by a linear function We have already seen that we can approximate the graph of a neat function \(f\) near a point \(x=a\) with the tangent line given by the equation \[y=f(a)+f'(a)\cdot (x-a)\tiny.\] This is precisely the straight line near \(\bigl(a, f(a)\bigr)\) which is the closest to the graph of \(f\).

The straight line is the graph of the following polynomial function \[P(x) = f(a)+f'(a)\cdot (x-a)\tiny.\] Note that \(P\) is the only first-degree polynomial with the property that \[P(a)=f(a),\quad P'(a)=f'(a)\tiny.\]

Once the dam breaks, the flood comes: we can also do the above for second-degree polynomials.

Approximating a mathematical function by a quadratic function We assume that the second derivative of \(f\) exists (this is part of being a neat function).

Define the polynomial \[P(x) = f(a)+f'(a)\cdot (x-a)+ \frac{1}{2}f''(a)\cdot (x-a)^2\tiny.\] Then: \[P(a)=f(a),\quad P'(a)=f'(a),\quad P''(a)=f''(a)\tiny.\] The graph of \(P\) is precisely the parabola that is near \(\bigl(a, f(a)\bigr)\) closest to the graph of \(f\). This parabola is near \(\bigl(a, f(a)\bigr)\) closer to the graph of \(f\) than the tangent line at this point.

Approximating a mathematical function by a cubic function You can continue in this way with a third-degree polynomial and define \[P(x) = f(a)+f'(a)\cdot (x-a)+ \frac{1}{2}f''(a)\cdot (x-a)^2+ \frac{1}{6}f'''(a)\cdot (x-a)^3\tiny.\] The graph of the cubic polynomial is near \(\bigl(a, f(a)\bigr)\) closer to the graph of \(f\) than the two previous approximations.

The following theorem makes the above statements mathematically more precise; moreover, it works for polynomials of any degree. We say that a function is \(k\) times differentiable if the derivatives \(f', f'', f''', \ldots f^{(k)}\) exist.

Taylor's theorem Suppose that \(k\) is a natural number and the function \(f\) is at least \(k+1\) times differentiable. Then \[f(x)=P(x)+R(x)\] with \[P(x) = f(a)+f'(a)\cdot (x-a)+ \frac{1}{2}f''(a)\cdot (x-a)^2+ \cdots + \frac{1}{k!}f^{(k)}(a)\cdot (x-a)^k\] is a polynomial function of degree \(k\) and \[R(x)=\frac{1}{(k+1)!}f^{(k+1)}(\xi)\cdot (x-a)^{k+1}\] for some \(\xi\) that is situated between \(a\) and \(x\) and that depends on \(x\).

The polynomial \(P\) is called the **Taylor polynomial for \(f\) about \(a\) of degree \(k\)**; \(R\) is called the **(Lagrange)** **remainder term of order \(k\)**.

Actually we should write \(P_k\) and \(R_k\) to express the dependence of \(k\), but that is usually clear from the context. For numerical approximation methods, the following two points are important: \[\frac{R_k(x)}{(x-a)^k}\rightarrow 0\;\;\text{when}\;\;x\rightarrow a\] and \[|R_k(x)|\le M\cdot |x-a|^{k+1}\;\;\text{if } |x-a|\le r\text{ for some }M\text{ and }r\tiny.\] To save ink, but yet to give an indication of the order of a truncation, one often uses the (big-\(O\)) **\(O\) symbol of Landau** and one writes \[R_k(x)=O\bigl((x-a)^{k+1}\bigr)\tiny.\]

The table below shows the quadratic approximations of some functions about the origin. \[\begin{array}{ccccccccc} e^x &= &1 &+ &x &+ &\frac{1}{2}x^2 &+ &O(x^3) \\ \sin x &= & & &x & & &+ &O(x^3) \\ \cos x &= &1 & & &- &\frac{1}{2}x^2 &+ &O(x^3) \\ \dfrac{1}{1-x} &= &1 &+ &x &+ &x^2 &+ &O(x^3)\\ \sqrt{1+x} &= &1 &+ &\frac{1}{2} x &- &\frac{1}{8}x^2 &+ &O(x^3)\\ \ln(1+x) &= & & &x &- &\frac{1}{2}x^2 &+ &O(x^3)\end{array}\]

Taylor approximation of a function In the interactive diagram below you can visually inspects how well a Taylor polynomial ff certain degree about some expansion point approxiamtes the given function.

A direct calculation shows that the 6th-order Taylor approximation of #f(x) = \sin(x)# around the point \(0\) is given by #P_6(x) = x - \frac{1}{3!} x^3 + \frac{1}{5!} x^5#. The absolute value of the seventh derivative #\left(\frac{d}{dx}\right)^7\sin (x) = -\cos(x)# is at most 1. Therefore: \[|\sin(x) - x - \frac{1}{3!} x^3 + \frac{1}{5!} x^5| \le \frac{1}{7!} |x|^{7}\tiny.\] We conclude that #\frac{1}{7!} |x|^{7} < \frac{1}{10000}# for #|x| < \sqrt[7]{\frac{7!}{10000}} \approx 0.821#. Thus, on the interval #[-0.8,0.8]#, the sine function is approximated by the polynomial #P_6(x)# with an error less than #0.0001#.