To celebrate the $\pi$ day, in our previous post, we were introduced to a very beautiful identity due to Euler
$$\frac{1}{1^2} + \frac{1}{2^2} + \frac{1}{3^2} + \frac{1}{4^2} + \frac{1}{5^2} + \dots = \frac{\pi^2}{6}$$
The mathematician Euler had an intriguing method to derive this identity. Euler's method employed the Taylor series, so today we will learn about Taylor series, and in the next post, we will look at Euler's technique.
An example about quadratic polynomial
Before learning about the Taylor series, let us look at the following little quiz question:
Given a quadratic polynomial $$p(x) = a x^2 + b x + c$$ Express the coefficient $c$ in terms of the function $p$.
Have you got an answer?
The answer is: $$c = p(0)$$
The next question is
Given a quadratic polynomial $$p(x) = a x^2 + b x + c$$
Express the coefficient $b$ in terms of the function $p$.
(Hint: take the derivative of $p$.)
Take the derivative of $p$ we have $$p'(x) = 2 a x + b$$
So $$b = p'(0)$$
By now you probably know the formula for the coefficient $a$?!
Taking the second derivative, we have $$p''(x) = 2a$$
Thus, $$c = p(0), ~~ b = p'(0), ~~ a = \frac{1}{2} p''(0).$$
Substitute these formulas back into the quadratic polynomial, we obtain $$p(x) = a x^2 + bx + c=\frac{1}{2} p''(0) x^2 + p'(0) x + p(0)$$
An example about quintic polynomial
Now, suppose we have a quintic polynomial $$p(x) = a_5 x^5 + a_4 x^4 + a_3 x^3 + a_2 x^2 + a_1 x + a_0$$
We can follow similar steps to derive formula for the coefficients $a_i$.
First of all, we have $$a_0 = p(0)$$
Taking the first derivative, we have $$p'(x) = 5 a_5 x^4 + 4 a_4 x^3 + 3 a_3 x^2 + 2 a_2 x + a_1$$
So $$a_1 = p'(0)$$
Taking the second derivative, we have $$p''(x) = 5 \times 4 \, a_5 x^3 + 4 \times 3 \, a_4 x^2 + 3 \times 2 \, a_3 x + 2 a_2$$
So $$a_2 = \frac{p''(0)}{2}$$
Taking the third derivative, we have $$p'''(x) = 5 \times 4 \times 3 \, a_5 x^2 + 4 \times 3 \times 2 \, a_4 x + 3 \times 2 \times 1 \, a_3$$
Thus, $$a_3 = \frac{p'''(0)}{3 \times 2 \times 1} = \frac{p'''(0)}{3!}$$
(The notation $n!$ reads "$n$ factorial", $n!= 1 \times 2 \times \dots \times (n-1) \times n$)
Keep taking the derivative, we have $$p''''(x) = 5 \times 4 \times 3 \times 2 \, a_5 x + 4 \times 3 \times 2 \times 1 \, a_4$$
So $$a_4 = \frac{p''''(0)}{4 \times 3 \times 2 \times 1} = \frac{p^{(4)}(0)}{4!}$$
(We will write $p^{(n)}(x)$ to denote the $n$th derivative of $p(x)$)
Finally, taking the fifth derivative, we have $$p^{(5)}(x) = 5 \times 4 \times 3 \times 2 \times 1 \, a_5$$
So $$a_5 = \frac{p^{(5)}(0)}{5!}$$
We can see that the general formula is $$a_n = \frac{p^{(n)}(0)}{n!}$$
Therefore, $$p(x) = a_5 x^5 + a_4 x^4 + a_3 x^3 + a_2 x^2 + a_1 x + a_0$$ $$= \frac{p^{(5)}(0)}{5!} x^5 + \frac{p^{(4)}(0)}{4!} x^4 + \frac{p^{(3)}(0)}{3!} x^3 + \frac{p''(0)}{2!} x^2 + p'(0) x + p(0)$$ $$= p(0) + p'(0) x + \frac{p''(0)}{2!} x^2 + \frac{p^{(3)}(0)}{3!} x^3 + \frac{p^{(4)}(0)}{4!} x^4 + \frac{p^{(5)}(0)}{5!} x^5$$
Taylor series
Now, we are ready to learn about the Taylor series.
The Taylor series of a function $f(x)$ is:$$f(x) = f(0) + f'(0) x + \frac{f''(0)}{2!} x^2 + \frac{f^{(3)}(0)}{3!} x^3 + \frac{f^{(4)}(0)}{4!} x^4 + \dots + \frac{f^{(n)}(0)}{n!} x^n + \dots$$
If you ever forget about this formula, just work it out with a quadratic polynomial or a cubic polynomial then you will remember the general formula.
Let us now calculate the Taylor series for the function $e^x$.
The natural exponential function $e^x$
There are two most important constants in mathematics, the first is $\pi \approx 3.14$ and the second is the Euler constant $e \approx 2.72$.
We have $$\lim_{n \to \infty}{\left( 1 + \frac{1}{n} \right)^n} = e$$
The natural exponential function $f(x) = e^x$ is a very special function because its derivative is equal to itself. Therefore, no matter how many times you take the derivative, the answer is always $e^x$: $$f(x) = f'(x) = f''(x) = f^{(3)}(x) = f^{(4)}(x) = f^{(5)}(x) = \dots = e^x$$
So $$f(0) = f'(0) = f''(0) = f^{(3)}(0) = f^{(4)}(0) = f^{(5)}(0) = \dots = e^0 = 1$$
The Taylor series for $f(x) = e^x$ is: $$f(x) = f(0) + f'(0) x + \frac{f''(0)}{2!} x^2 + \frac{f^{(3)}(0)}{3!} x^3 + \frac{f^{(4)}(0)}{4!} x^4 + \dots + \frac{f^{(n)}(0)}{n!} x^n + \dots$$ $$e^x = 1 + x + \frac{1}{2!} x^2 + \frac{1}{3!} x^3 + \frac{1}{4!} x^4 + \dots + \frac{1}{n!} x^n + \dots$$
$$e^x = 1 + \frac{x}{1!} + \frac{x^2}{2!} + \frac{x^3}{3!} + \frac{x^4}{4!} + \dots + \frac{x^n}{n!} + \dots$$
Take $x = \pm 1$, we obtain the following two beautiful identities: $$e = 1 + \frac{1}{1!} + \frac{1}{2!} + \frac{1}{3!} + \frac{1}{4!} + \frac{1}{5!} + \dots $$ $$\frac{1}{e} = 1 - \frac{1}{1!} + \frac{1}{2!} - \frac{1}{3!} + \frac{1}{4!} - \frac{1}{5!} + \dots $$
Let us stop here for now. Next time, we will look at Euler's technique to derive the identity
$$\frac{1}{1^2} + \frac{1}{2^2} + \frac{1}{3^2} + \frac{1}{4^2} + \frac{1}{5^2} + \dots = \frac{\pi^2}{6}$$
Hope to see you again then.
Homework.
1. Use the Taylor series for function $g(x)$ $$g(x) = g(0) + g'(0) x + \frac{g''(0)}{2!} x^2 + \frac{g^{(3)}(0)}{3!} x^3 + \frac{g^{(4)}(0)}{4!} x^4 + \dots + \frac{g^{(n)}(0)}{n!} x^n + \dots$$
and take $f(x+a) = g(x)$, prove that $$f(x+a) = f(a) + f'(a) x + \frac{f''(a)}{2!} x^2 + \frac{f^{(3)}(a)}{3!} x^3 + \frac{f^{(4)}(a)}{4!} x^4 + \dots + \frac{f^{(n)}(a)}{n!} x^n + \dots$$
From here, derive the following formula
$$f(x) = f(a) + f'(a) (x-a) + \frac{f''(a)}{2!} (x-a)^2 + \frac{f^{(3)}(a)}{3!} (x-a)^3 + \frac{f^{(4)}(a)}{4!} (x-a)^4 + \dots + \frac{f^{(n)}(a)}{n!} (x-a)^n + \dots$$
This is called the Taylor series for $f(x)$ at the point $x =a$.
2. Show that the Taylor series for $\sin(x)$ is $$\sin(x) = x - \frac{x^3}{3!} + \frac{x^5}{5!} - \frac{x^7}{7!} + \frac{x^9}{9!} - \dots$$
3. Show that the Taylor series for $\cos(x)$ is $$\cos(x) = 1 - \frac{x^2}{2!} + \frac{x^4}{4!} - \frac{x^6}{6!} + \frac{x^8}{8!} - \dots$$
4. Calculate the Taylor series for $f(x) = \log_{e}(1 + x)$.
5. Calculate the Taylor series for $f(x) = \sqrt{x + 1}$.
6. Go to google.com and search for the Euler constant $e$, read about how Euler constant is used to calculate bank interest.