User:Egm6341.s11.team4.BM/HW2

Given
Given the remainder term after the first integration by parts upon a function


 * $$ \int_{x_{0}}^{x} (x-t) f^{(2)}(t) dt \!$$

Objectives
1.    Repeat the integration by parts method used for 3 more degrees of the Taylor Series Approximation


 * $$ \frac{(x-x_{0})^{2}}{2!}f^{(2)}(x_{0}) +   \frac{(x-x_{0})^{3}}{3!}   f^{(3)}(x_{0})   +     \frac{(x-x_{0})^{4}}{4!}   \!$$

2. Use the Intermediate Mean Value Theorem to express the remainder in terms of


 * $$ f^{(5)}(\xi) \!$$
 * $$ \xi \epsilon [x_{0},x] \!$$

3. Do integration by parts a fourth time on the equation to verify the Taylor Series remainder equations for (n+1) expansion with $$ R_{n+2}(x) $$.

4. Use the Intermediate Mean Value Theorem on the Remainder term to show


 * $$ R_{n+1}(x) = \frac{(x-x_{0})^{n+1}}{(n+1)!}f^{(n+1)}(\xi) \!$$

Solution
1. First we will start with the "remainder" term from the Taylor series expansion as derived in class lecture [].


 * $$ R_{1}=\int_{x_{0}}^{x}(x-t)f^{(2)}(t)dt \!$$

The same integration by parts method used in class will be used on this remainder to further expand the Taylor series.


 * $$\int v(t) u'(t)\, dt = v(t) u(t) - \int v'(t) u(t)\, dt\!$$

Here we will now define the parts in our integration by parts scheme.


 * $$ u^{\prime}=(x-t) \!$$


 * $$ v=f^{(2)}(t) \!$$


 * $$  u=(xt-\frac{t^{2}}{2})       \!$$

Now, substituting into our integration by parts equation.


 * $$  R_{1}=\left [ (xt-\frac{t^{2}}{2}) f^{(2)}(t)\right ]_{t=x_{0}}^{t=x}-\int_{x_{0}}^{x}(xt-\frac{t^{2}}{2}) f^{(3)}(t)dt       \!$$

Expanding out the term in brackets we obtain


 * $$ R_{1}=(\frac{1}{2}x^{2})f^{(2)}(x)-(xx_{0}-\frac{1}{2}x_{0}^{2})f^{(2)}(x_{0}) -\int_{x_{0}}^{x}(xt-\frac{t^{2}}{2}) f^{(3)}(t)dt  \!$$


 * $$+ [ (\frac{1}{2}x^{2})f^{(2)}(x_{0})-(\frac{1}{2}x^{2})f^{(2)}(x_{0}) ]     \!$$

The second line in this equation sums to zero and is added so that we can rearrange the resulting equation into an integral term and a non-integral term.


 * $$     R_{1}=[ \frac{1}{2}x^{2}f^{(2)}(x)-\frac{1}{2}x^{2}f^{(2)}(x_{0}) ] +(\frac{1}{2}x^{2}-xx_{0}+\frac{1}{2}x_{0}^{2})f^{(2)}(x_{0})  -\int_{x_{0}}^{x}(xt-\frac{t^{2}}{2}) f^{(3)}(t)dt                     \!$$

The bracketed term can be re-expressed as an integral. Additionally, the term $$ (\frac{1}{2}x^{2}-xx_{0}+\frac{1}{2}x_{0}^{2}) \!$$ can be expressed as $$ \frac{1}{2}(x-x_{0})^{2} \!$$. This gives us the following.


 * $$   R_{1}= \int_{x_{0}}^{x}\frac{1}{2}x^{2}f^{(3)}(t)+\frac{1}{2}(x-x_{0})^{2}f^{(2)}(x_{0})-\int_{x_{0}}^{x}(xt-\frac{t^{2}}{2}) f^{(3)}(t)dt                                 \!$$

Now regrouping the integral terms under one integral we obtain the following.


 * $$     R_{1}=  \int_{x_{0}}^{x}\frac{1}{2}(x-t)^{2}f^{(3)}(t)+\frac{1}{2}(x-x_{0})^{2}f^{(2)}(x_{0})                       \!$$

This can be grouped back into our Taylor series expansion to give us the following.


 * {| style="width:70%" border="0" align="center"

$$\displaystyle f(x)=f(x_{0})+\frac{(x-x_{0})^{1}}{1!}f^{(1)}(x_{0})+\frac{(x-x_{0})^{2}}{2!}f^{(2)}(x_{0})+\int_{x_{0}}^{x}\frac{1}{2}(x-t)^{2}f^{(3)}(t) $$ $$
 * style="width:20%; padding:10px; border:2px solid #8888aa" |
 * style="width:20%; padding:10px; border:2px solid #8888aa" |
 * $$\displaystyle
 * style= |
 * }.
 * }.

Our new remainder term, the term in the integral, will now be further expanded.


 * $$      R_{2} =   \int_{x_{0}}^{x}\frac{1}{2}(x-t)^{2}f^{(3)}(t)                       \!$$

Our integration by parts terms are now the following.
 * $$          u'=  \frac{1}{2}(x-t)^{2}                  \!$$
 * $$             v=f^{(3)}(t)                  \!$$
 * $$             u=\frac{1}{6}t^{3}-.5t^{2}x+.5tx^{2}                 \!$$

Substituting into our integration by parts equation we obtain the following.


 * $$ R_{2} =   [(\frac{1}{6}t^{3}-.5t^{2}x+.5tx^{2})f^{(3)}(t)]_{t=x_{0}}^{t=x} - \int_{x_{0}}^{x}  (\frac{1}{6}t^{3}-.5t^{2}x+.5tx^{2} )  f^{(4)}(t) dt            \!$$

For clarity, the term in brackets will now be expressed as $$ \alpha \!$$. Expanding the terms in bracket we obtain the following.
 * $$  R_{2} =(\frac{1}{6}x^{3}) f^{(4)}(x)- (\frac{1}{6}x_{0}^{3}-\frac{1}{2}x_{0}^{2}x+\frac{1}{2}x_{0}x^{2}) f^{(4)}(x_{0}) - \alpha             \!$$


 * $$ +(\frac{1}{6}x^{3}) f^{(4)}(x_{0}) - (\frac{1}{6}x^{3}) f^{(4)}(x_{0})                    \!$$

The second line of the equation adds to zero as before and is added to help rearrange the expressions into an integral later on.

Now we can group together the terms appropriately so that we can simplify the equation.


 * $$ R_{2} =  \int_{x_{0}}^{x} \frac{1}{6}x^{3} f^{(4)} dt   + (\frac{1}{6}x^{3} - \frac{1}{6}x_{0}^{3}-\frac{1}{2}x_{0}^{2}x+\frac{1}{2}x_{0}x^{2})f^{(3)}(x_{0}) - \alpha                 \!$$

Pulling out the fractional coefficients of the terms outside of the integrals.


 * $$ R_{2} =  \int_{x_{0}}^{x} \frac{1}{6}x^{3} f^{(4)} dt +\frac{1}{3!}(x^{3}-3x_{0}^{2}x+3x_{0}x^{2}-x_{0}^{3})  f^{(3)}(x_{0}) -\alpha                           \!$$

We can further simplify the term outside of the integral to be


 * $$ R_{2} =  \int_{x_{0}}^{x} \frac{1}{6}x^{3} f^{(4)} dt +\frac{1}{3!} (x-x_{0})  f^{(3)}(x_{0}) -\alpha                           \!$$

Now combining the terms under the integrals to eliminate our $$ \alpha \!$$ expression.


 * $$  R_{2} =  \int_{x_{0}}^{x} (\frac{1}{3!}x^{3}-\frac{1}{6}t^{3}-\frac{1}{2}t^{2}x+\frac{1}{2}tx^{2})f^{(4)} + \frac{1}{3!} (x-x_{0})  f^{(3)}(x_{0})                           \!$$

Further simplifying, this becomes


 * $$ R_{2} =  \frac{1}{3!} (x-x_{0})  f^{(3)}(x_{0})   +\int_{x_{0}}^{x} (\frac{1}{3!}(x-t)^{3})f^{(4)}(t)dt                         \!$$

Substituting this back into our original equation we obtain the following.


 * {| style="width:70%" border="0" align="center"

$$\displaystyle f(x)=f(x_{0})+\frac{(x-x_{0})^{1}}{1!}f^{(1)}(x_{0})+\frac{(x-x_{0})^{2}}{2!}f^{(2)}(x_{0})+  \frac{(x-x_{0})^{3}}{3!}   f^{(3)}(x_{0})   +\int_{x_{0}}^{x} (\frac{1}{3!}(x-t)^{3})f^{(4)}(t)dt                                    $$ $$
 * style="width:20%; padding:10px; border:2px solid #8888aa" |
 * style="width:20%; padding:10px; border:2px solid #8888aa" |
 * $$\displaystyle
 * style= |
 * }.
 * }.

Now we can use the same method for the next term in the Taylor series.


 * $$       \int_{x_{0}}^{x} \frac{1}{3!}(x-t)^{3}f^{(4)}(t)dt                             \!$$
 * $$      u'=     \frac{1}{3!}(x-t)^{3}                   \!$$
 * $$       v= f^{(4)}(t)                       \!$$
 * $$       u=(-\frac{t^{4}}{24}+\frac{1}{6}t^{3}x-\frac{1}{4}t^{2}x^{2}+\frac{1}{6}tx^{3} )                      \!$$

Now substituting into our integration by parts equation
 * $$   R_{3}= [(-\frac{t^{4}}{24}+\frac{1}{6}t^{3}x-\frac{1}{4}t^{2}x^{2}+\frac{1}{6}tx^{3} ) f^{(4)}(t)  ]_{x_{0}}^{x} -\int_{x_{0}}^{x}  (-\frac{t^{4}}{24}+\frac{1}{6}t^{3}x-\frac{1}{4}t^{2}x^{2}+\frac{1}{6}tx^{3} )  f^{(5)}(t)  dt                           \!$$

Expanding the bracket and substituting $$ \alpha \!$$ for the integral term, we obtain the following equation.


 * $$ R_{3}= (-\frac{x^{4}}{24}+\frac{1}{6}x^{4}-\frac{1}{4}x^{4}+\frac{1}{6}x^{4} )f^{(4)}(x)  -(-\frac{x_{0}^{4}}{24}+\frac{1}{6}x_{0}^{3}x-\frac{1}{4}x_{0}^{2}x^{2}+\frac{1}{6}x_{0}x^{3} )f^{(4)}(x_{0}) -\alpha                            \!$$
 * $$ +\frac{1}{24}x^{4}  f^{(4)}(x_{0})-    \frac{1}{24}x^{4}   f^{(4)}(x_{0})                         \!$$

The second line sums to zero and is added in order to re-arrange the terms into an integral.

Now we can express the equation as the following.


 * $$ R_{3}=   \int_{x_{0}}^{x}   \frac{1}{24}x^{4}f^{(5)}(t)dt -\alpha +[\frac{1}{24}x^{4} +\frac{x_{0}^{4}}{24}-\frac{1}{6}x_{0}^{3}x+\frac{1}{4}x_{0}^{2}x^{2}-\frac{1}{6}x_{0}x^{3}  ]             \!$$

Now, combining the integral term with our $$ \alpha \!$$ term and then simplifying the terms in brackets we can express the equation as follows


 * $$R_{3}=  \frac{(x-x_{0})^{4}}{4!}   +  \int_{x_{0}}^{x}   \frac{1}{4!}(x-t)^{4}f^{(5)}(t)dt  \!$$

Substituting this into our Taylor series polynomial expression, we obtain


 * {| style="width:70%" border="0" align="center"

$$\displaystyle f(x)=f(x_{0})+\frac{(x-x_{0})^{1}}{1!}f^{(1)}(x_{0})+\frac{(x-x_{0})^{2}}{2!}f^{(2)}(x_{0})        \!$$
 * style="width:20%; padding:10px; border:2px solid #8888aa" |
 * style="width:20%; padding:10px; border:2px solid #8888aa" |
 * $$ +  \frac{(x-x_{0})^{3}}{3!}   f^{(3)}(x_{0})   +     \frac{(x-x_{0})^{4}}{4!}   +  \int_{x_{0}}^{x}   \frac{1}{4!}(x-t)^{4}f^{(5)}(t)dt  $$

$$ 2.
 * $$\displaystyle
 * style= |
 * }.
 * }.

First we state the Intermediate Mean Value Theorem (IMVT)
 * $$ \int_{a}^{b} w(t)f(t)dt = f(\xi) \int_{a}^{b} w(t)dt \!$$

This was previously proven in assignment 1 [] Now, we know the remainder for our equation is the following
 * $$ R_{4}=\int_{x_{0}}^{x}  \frac{1}{4!}(x-t)^{4}f^{(5)}(t)dt \!$$

Now, if we identify w(t) and f(t) we can use the IMVT for our problem
 * $$ W(t)= \frac{1}{4!}(x-t) \!$$
 * $$ f(t) = f^{(5)}(t) \!$$

Since we are integrating from our constants of integration x and $$ x_{0} $$ we can use the IMVT, substituting our equations, to obtain the following.


 * {| style="width:70%" border="0" align="center"

$$\displaystyle \int_{x_{0}}^{x}   \frac{1}{4!}(x-t)^{4}f^{(5)}(t)dt = f^{(5)}(\xi)\int_{x_{0}}^{x}  \frac{1}{4!}(x-t)^{4} dt    $$ $$
 * style="width:20%; padding:10px; border:2px solid #8888aa" |
 * style="width:20%; padding:10px; border:2px solid #8888aa" |
 * $$\displaystyle
 * style= |
 * }.
 * }.

Where

$$ \xi \in [x_{0},x] \!$$

3.

Here, we must do integration by parts for a fourth time to verify equations 3 and 4 on lecture slide 3-3 for (n+1) expansion with $$ R_{n+2}(x) $$. In essence, this requires us to see if


 * $$ R_{n+2}(x) = \frac{1}{(n+1)!} \int_{x_{0}}^{x} (x-t)^{(n+1)} f^{n+2}(t)dt \!$$

Where, in our case, n=4.

We will start with the remainder we obtained in part 1.
 * $$ R_{5}(x)=\frac{1}{4!}\int_{x_{0}}^{x} (x-t)^{4} f^{(5)}(t)dt \!$$

Now identifying our integration by parts terms.


 * $$  u'=\frac{(x-t)^{4}}{4!}       \!$$
 * $$   v=f^{(5)}(t)      \!$$
 * $$    u=(\frac{t^{5}}{5!}-\frac{t^{4}x}{4!}+\frac{t^{3}x^{2}}{12}-\frac{t^{2}x^{3}}{12}+\frac{tx^{4}}{4!})     \!$$

Substituting into our integration by parts equation.


 * $$ R_{5}(x)= [(\frac{t^{5}}{5!}-\frac{t^{4}x}{4!}+\frac{t^{3}x^{2}}{12}-\frac{t^{2}x^{3}}{12}+\frac{tx^{4}}{4!}) (f^{(5)}(t) )]_{x_{0}}^{x} - \int_{x_{0}}^{x}  (\frac{t^{5}}{5!}-\frac{t^{4}x}{4!}+\frac{t^{3}x^{2}}{12}-\frac{t^{2}x^{3}}{12}+\frac{tx^{4}}{4!}) f^{(6)}(t) dt     \!$$

Now referring to the term to the integral term as $$ \alpha $$ as in the previous several iterations, expanding the bracketed term as before, and adding two terms that sum to zero in order to aid in re-arranging the equation


 * $$ R_{5}(x)=(\frac{x^{5}}{5!}-\frac{x^{5}}{4!}+\frac{x^{5}}{12}-\frac{x^{5}}{12}+\frac{x^{5}}{4!}) f^{(5)}(x)   - (\frac{x_{0}^{5}}{5!}-\frac{x_{0}^{4}x}{4!}+\frac{x_{0}^{3}x^{2}}{12}-\frac{x_{0}^{2}x^{3}}{12}+\frac{x_{0}x^{4}}{4!}) f^{(5)}(x_{0})   -\alpha \!$$
 * $$ +\frac{x^{5}}{5!}f^{(5)}(x_{0}) - \frac{x^{5}}{5!}f^{(5)}(x_{0})        \!$$

The second line of the above equation sums to zero and is added so that we can rearrange the equation into a simpler form.


 * $$  R_{5}(x)= [\frac{x^{5}}{5!}f^{(5)}(x) -\frac{x^{5}}{5!}f^{(5)}(x_{0}) ]_{x_{0}}^{x} -(\frac{x_{0}^{5}}{5!}-\frac{x_{0}^{4}x}{4!}+\frac{x_{0}^{3}x^{2}}{12}-\frac{x_{0}^{2}x^{3}}{12}+\frac{x_{0}^{4}x}{4!}-\frac{x^{5}}{5!}) f^{(5)}(x)  -\alpha    \!$$

Now we can express the bracketed term as an integral. Meanwhile, the complex polynomial simplifies to $$ \frac{(x-x_{0})^{5}}{5!} $$.
 * $$  R_{5}(x)= \int_{x_{0}}^{x}\frac{x^{5}}{5!}f^{(6)}(t)dt+\frac{(x-x_{0})^{5}}{5!}f^{(5)}(x_{0})-\alpha      \!$$

Now, combining the integral term with the $$ \alpha $$ term we end up with the following equation


 * $$ R_{6}= \frac{(x-x_{0})^{5}}{5!}f^{(5)}(x_{0}) +  \int_{x_{0}}^{x}\frac{(x-t)^{5}}{5!}f^{(6)}(t)dt     \!$$

Since n=4 in our case, this verifies the expansion with $$ R_{n+2}(x) $$

4.

We can use the IMVT on the Remainder term, given as equation 4 lecture slide 3-3  in order to show equation 5 lecture slide 3-3. The IMVT can be stated as follows.


 * $$  \int_{a}^{b}w(t)g(t)dt=g(\xi)\int_{a}^{b}w(t)dt       \!$$

When applied to equation 4, the Taylor series remainder, we can evaluate the individual terms of the IMVT to be
 * $$  a=x_{0}          \!$$
 * $$  b=x        \!$$
 * $$  w(t)= \frac{(x-t)^{n}}{n!}       \!$$
 * $$     g(t)=f^{(n+1)}(t)       \!$$

Simple substitution of these equations into the IMVT gives us the following


 * $$  \int_{x_{0}}^{x}\frac{(x-t)^{n}}{n!}f^{(n+1)}(t)dt=f^{(n+1)}(\xi)  \int_{x_{0}}^{x}  \frac{(x-t)^{n}}{n!} dt        \!$$

Now, evaluating the integral present on the right hand side, we can further simplify the remainder to the following
 * $$   R_{n+1}(x) = \frac{(x-x_{0})^{(n+1)}}{(n+1)!}f^{(n+1)}(\xi)      \!$$

And this result is simply equation 5, so we have effectively shown that equation 5 arises naturally out of equation 4 in conjunction with the Intermediate Mean Value Theorem.

Given
The function f(x)
 * $$ f(x)=sin(x) \!$$

and the span of x
 * $$ x \epsilon [0, \pi] \!$$

Objective
Evaluate the Taylor Series about the point
 * $$ x_{0}=\frac{3\pi}{8} \!$$

For Taylor Series degrees of
 * $$ n=0,1,2,...,10 \!$$

We must then plot these series for each value of n in order to visually see how the Taylor Series improves with each degree of approximation.

Next we must estimate the error in our solution at the point $$ x= \frac{3\pi}{4} \!$$ for each degree of Taylor Series approximation.

Solution
Evaluating the Taylor Series of the sin(x) is a simple matter of following the general Taylor Series expansion formula for the case where f(x) is sin(x).

The general Taylor Series expansion as presented in the lecture slides is


 * $$ P_{n}(x) = f(x_{0}) + \frac{(x-x_{0})}{1!} f^{(1)}(x_{0}) +...+\frac{(x-x_{0})^{n}}{n!}f^{(n)}(x_{0}) \!$$

For the case of sin(x), the equation then becomes


 * $$ f(x) = sin(x_{0}) + \frac{(sin(x)-sin(x_{0}))^{1}}{1!}cos(x_{0}) - \frac{(sin(x)-sin(x_{0}))^{2}}{2!}sin(x_{0}) - ...\!$$

The periodicity of the sine function shows up in our evaluation of the Taylor Series and can be capitalized upon. Since the derivative of sine is the sine function itself every 4 derivatives evaluating the nth derivative is a simple matter of determining what the remainder is when n is divided by 4 and matching the derivative with the appropriate trigonometric function based on what the remainder is.

This method is implemented in code about the point $$ x_{0} = \frac{3\pi}{8}$$ up to degree n=10 and then plotted. The result is a plot that graphically shows how the Taylor Series comes closer to the true function it evaluates with each successive degree evaluated.

The maximum error of the Taylor Series can be expressed mathematically using equation 5 lecture slide 3-3
 * $$ \left | R_{n+1}(x) \right | \leq \frac{(x-x_{0})^{n+1}}{(n+1)!}(\alpha ) \!$$

Where $$ \alpha \!$$ represents the maximum of the maximum value of the n+1 derivative over the relevant range.


 * $$ \alpha = max \left | f^{(n+1)}(t) \right | \!$$
 * $$ t \epsilon [x_{0},x] \!$$

Now we will apply these equations to our specific function; the sine function and an evaluation point of $$ x_{0} = \frac{3\pi}{8} $$ and measurement point of $$ x = \frac{3\pi}{4} $$. First, we can say that


 * $$ \alpha = max \left | f^{(n+1)}(t) \right | = 1 \!$$
 * $$ t \epsilon [x_{0},x] \!$$

This arises because of the nature of the sine function. Every nth order derivative of sine is going to be positive or negative sine or cosine. Sine and cosine functions are bounded above and below by 1 and -1. This means that the maximum absolute value of any derivative of sine is 1.

Now we can use this result to simplify our remainder equation.


 * $$ \left | R_{n+1}(x) \right | \leq \frac{(x-x_{0})^{n+1}}{(n+1)!} \!$$

Since, for the problem we are evaluating $$ x_{0} = \frac{3\pi}{8} $$ and $$ x = \frac{3\pi}{4} $$ we can say that $$ (x-x_{0})=\frac{3\pi}{8} $$


 * $$ \left | R_{n+1}(\frac{3\pi}{4}) \right | \leq \frac{(\frac{3\pi}{8})^{n+1}}{(n+1)!} \!$$

Now we have an upper bound on the error for any degree Taylor Series approximation of our function. This equation is included in the code used to plot the sine function and evaluated for all degree Taylor Series approximations from 0 to 10.

Matlab Code:

The code as printed above gives us several outputs, the plot of the Taylor Series and the error for each degree of the Taylor series about the point $$ \frac{3\pi}{4} $$.

Plots:



As can be seen, the higher order Taylor Series functions do an excellent job of approximating the sine function. In fact, every approximation above the 5th degree approximation cannot even be seen in the plot since they coincide with and are obscured by the plotting of the true value of sin(x). Thus, we would expect to see a very small error associated with these higher order approximations. The code used above gives us the following error estimations.


 * $$ \left | R_{1}(\frac{3\pi}{4}) \right | \leq 1.1781 \!$$
 * $$ \left | R_{2}(\frac{3\pi}{4}) \right | \leq 0.6940 \!$$
 * $$ \left | R_{3}(\frac{3\pi}{4}) \right | \leq 0.2725 \!$$
 * $$ \left | R_{4}(\frac{3\pi}{4}) \right | \leq 0.0803 \!$$
 * $$ \left | R_{5}(\frac{3\pi}{4}) \right | \leq 0.0189 \!$$
 * $$ \left | R_{6}(\frac{3\pi}{4}) \right | \leq 0.0037 \!$$
 * $$ \left | R_{7}(\frac{3\pi}{4}) \right | \leq 6.2494*10^{-4} \!$$
 * $$ \left | R_{8}(\frac{3\pi}{4}) \right | \leq 9.2030*10^{-5} \!$$
 * $$ \left | R_{9}(\frac{3\pi}{4}) \right | \leq 1.2047*10^{-5} \!$$
 * $$ \left | R_{10}(\frac{3\pi}{4}) \right | \leq 1.4192*10^{-6} \!$$
 * $$ \left | R_{11}(\frac{3\pi}{4}) \right | \leq 1.5200*10^{-7} \!$$

As expected, the higher order approximations from about degree six onward produce an almost negligible error.