When working with a *non-polynomial function*, we often seek a *polynomial approximation* that closely matches the original function at a specific point $x$ and in its vicinity. Polynomials are computationally easier to work with (e.g., for differentiation and integration), making them a practical choice.
Using the [[Taylor Series|Taylor Series Method]], we approximate a function by a finite polynomial (truncated series), which is referred to as an $n$-th order approximation. The number of terms $n$ we include depends on the desired level of accuracy.
$ g_n(x) = g(c) + g^\prime(c)(x-c) + \frac{g^{\prime\prime}(c)}{2!}(x-c)^2 + \dots+\frac{g^{(n)}(c)}{n!}(x-c)^n$
## Derivation
Let us illustrate this with an example. Suppose our original function is $f(x)$, and we want to approximate it with a cubic polynomial as good as possible around the point $x=0$.
A cubic polynomial $y$ has the following general form:
$ y = d + cx + bx^2 + ax^3 $
For a good approximation we want to fit the parameters $\{a,b,c,d\}$ as good as possible. We achieve this by *aligning the function value, slope, curvature, etc.* of the polynomial $y$ with the original function $f$, evaluated at the point of interest $x=0$.
**Step 1:** Take derivatives of $y$
$
\begin{align}
y &= ax^3 + bx^2+cx+d \\
y'&= 3ax^2 + 2bx +c \\
y''&= 6ax+2b \\
y^{(3)}&= 6a
\end{align}
$
**Step 2:** Evaluate derivatives at $x=0$ and equate with derivatives from original function
$
\begin{align}
y &= d \approx f(0)\\
y'&= c \approx f^\prime(0)\\
y''&= 2b \approx f^{\prime\prime}(0)\\
y^{(3)}&= 6a \approx f^{(3)}(0)
\end{align}
$
**Step 3:** Express approximations in terms of $\{a,b,c,d\}$
$
\begin{align}
d= f(x), \quad
c= f'(x), \quad
b=\frac{1}{2}f''(x), \quad
a=\frac{1}{6}f^{(3)}(x)
\end{align}
$
**Step 4:** Filling in representation of $\{a,b,c,d\}$ into the polynomial form from above:
$ y=f(x) + f'(x)\,x + \frac{1}{2}f^{\prime\prime}(x)\,x^2 + \frac{1}{6}f^{(3)}(x)\,x^3 $
## Example
Consider $f(x)= \cos(x)$ as the original function which we want to approximate by a polynomial. The derivatives of $\cos(x)$ are:
$
\begin{aligned}
f(x)&=\cos(0)&=1 \\
f'(x)&=-\sin(0)&=0 \\
f''(x)&=-\cos(0)&=-1\\
f^{(3)}(x)&=\sin(0)&=0\\
\end{aligned} $
Substituting these values into the polynomial:
$
\begin{align}
y &=f(x) + f^\prime(x)\,x + \frac{1}{2}f^{\prime\prime}(x)\,x^2 + \frac{1}{6}f^{(3)}(x)\,x^3 \\
y&=1+0x+\frac{1}{2}*{-1}x^2 -{\frac{1}{6}* 0x^3} \\
y&=1-\frac{1}{2}x^2
\end{align}
$
Thus, the cubic approximation of the cosine function at $x=0$ is $y=1-\frac{1}{2}x^2$.