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 $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:
$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:
$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 $f(x) = sin(x)$ and let us expand the series about the point $x = \frac{\pi}{4}$.

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

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

$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}$

$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:
$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 $\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
$sin(x) \approx x - \frac{1}{3!}x^3 + \frac{1}{5!}x^5$

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

-Dan

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

So given $f(x) = \sin x$ let us work on the interval $(a,b)$ where $a=-\infty$ and $b=+\infty$. This function is infinitely differenciable so the above results apply. You can to approximate $T_n \left( \frac{\pi}{4} \right)$. Now by the theorem we know that,
$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 $0.

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

This means,
$\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 $(n+1)$-differentiable functions but there was no need to use it here.