1. ## taylor series

Can anyone help me with how to get the Taylor series of a function(for example sinx)?

Furthur how to get a value for sin(for example pi/4) with an particular error?
Thank You

2. Originally Posted by Dili
Can anyone help me with how to get the Taylor series of a function(for example sinx)?

Furthur how to get a value for sin(for example pi/4) with an particular error?
Thank You
The Taylor series for a function $\displaystyle f(x)$ (at least I presume you are talking about a single variable function) to N + 1 terms about a point x = a has the form:
$\displaystyle f(x) \approx f(a) + \frac{1}{1!}f^{\prime}(a)(x - a) + \frac{1}{2!}f^{\prime \prime}(a)(x - a)^2 + ~ ... ~ + \frac{1}{N!}f^{(N)}(a)(x - a)^N$

or in summation notation:
$\displaystyle f(x) \approx \sum_{k = 0}{N}\frac{1}{k!}f^{(k)}(a)(x - a)^k$

For the error estimate I will refer you here as I have forgotten which one is "standard" (if any.)

So as an example, let $\displaystyle f(x) = sin(x)$ and let us expand the series about the point $\displaystyle x = \frac{\pi}{4}$.

We have:
$\displaystyle f(x) = sin(x) \implies f \left ( \frac{\pi}{4} \right ) = sin \left ( \frac{\pi}{4} \right ) = \frac{\sqrt{2}}{2}$

$\displaystyle f^{\prime}(x) = cos(x) \implies f^{\prime} \left ( \frac{\pi}{4} \right ) = cos \left ( \frac{\pi}{4} \right ) = \frac{\sqrt{2}}{2}$

$\displaystyle f^{\prime \prime}(x) = -sin(x) \implies f^{\prime \prime} \left ( \frac{\pi}{4} \right ) = -sin \left ( \frac{\pi}{4} \right ) = -\frac{\sqrt{2}}{2}$

$\displaystyle f^{\prime \prime \prime}(x) = -cos(x) \implies f^{\prime \prime \prime} \left ( \frac{\pi}{4} \right ) = -cos \left ( \frac{\pi}{4} \right ) = -\frac{\sqrt{2}}{2}$

So the Taylor series to 4 terms looks like:
$\displaystyle sin(x) \approx \frac{\sqrt{2}}{2} + \frac{\sqrt{2}}{2} \left ( x - \frac{\pi}{4} \right ) - \frac{\sqrt{2}}{4} \left ( x - \frac{\pi}{4} \right )^2 - \frac{\sqrt{2}}{12} \left ( x - \frac{\pi}{4} \right )^3$

-Dan

3. ## lagrange's remainder

Thank you

But what if we take the point x=0, where you get the familiar Taylor series expansion of sinx? Is it the same as taking any value(pi/4)?
And can you explain with the Lagrange's remainder?

4. Originally Posted by Dili
Thank you

But what if we take the point x=0, where you get the familiar Taylor series expansion of sinx? Is it the same as taking any value(pi/4)?
And can you explain with the Lagrange's remainder?
I'll have to let someone else explain the remainder (I'm just not up on it myself, which is why I posted the link. )

Yes, you could use the Maclaurin expansion (the Taylor series expansion about the point x = 0), but note that $\displaystyle \frac{\pi}{4} \approx 0.785398$ is not particularly close to 0. The further x is from 0, the greater the error in the approximation.

On the other hand using 3 terms in the expansion I get
$\displaystyle sin(x) \approx x - \frac{1}{3!}x^3 + \frac{1}{5!}x^5$

Gives me
$\displaystyle sin \left ( \frac{\pi}{4} \right ) \approx 0.707143$
which is only off by $\displaystyle 5.129 \times 10^{-3}$ %, which is pretty close by most people's judgment.

-Dan

5. Theorem: Let $\displaystyle f(x)$ be an infinitely differenciable function on $\displaystyle (a,b)$ (with $\displaystyle a<0<b$). Let $\displaystyle T_n(x)$ represent the $\displaystyle n$-th degree Taylor polynomial around the origin for the point $\displaystyle x\in (a,b)$ (with $\displaystyle x\not = 0$). And let $\displaystyle R_{n+1}(x) = f(x) - T_{n}(x)$ be the remainder term. Then there exists a number $\displaystyle y$ strictly between $\displaystyle 0$ and $\displaystyle x$ so that,
$\displaystyle R_{n+1}(x) = \frac{f^{(n+1)}(y)}{(n+1)!}\cdot x^{n+1}$.

So given $\displaystyle f(x) = \sin x$ let us work on the interval $\displaystyle (a,b)$ where $\displaystyle a=-\infty$ and $\displaystyle b=+\infty$. This function is infinitely differenciable so the above results apply. You can to approximate $\displaystyle T_n \left( \frac{\pi}{4} \right)$. Now by the theorem we know that,
$\displaystyle R_{n+1}\left( \frac{\pi}{4} \right) = \frac{f^{(n+1)} \left( \frac{\pi}{4} \right)}{(n+1)!} \cdot \left( \frac{\pi}{4} \right)^{n+1}$ for some $\displaystyle 0<y<\frac{\pi}{4}$.

Notice that $\displaystyle f^{n+1}$ is one of these: $\displaystyle \sin x,\cos x,-\sin x,-\cos x$. Thus, $\displaystyle |f^{n+1}|\leq 1$. And also notice that $\displaystyle \frac{\pi}{4} \leq 1$ thus, $\displaystyle \left(\frac{\pi}{4}\right)^{n+1} \leq 1$.

This means,
$\displaystyle \left| R_{n+1}\left( \frac{\pi}{4}\right) \right| \leq \frac{1}{(n+1)!}$.

This approximation might be greatly improved all I did was place an approximation that works and furthermore converges rapidply.

Remark) The theorem applys in more general to $\displaystyle (n+1)$-differentiable functions but there was no need to use it here.