User:Egm6341.s11.team2.S

$$ \int $$

University of Florida

[Google map]

group page

=Useful Links=

Template

Group Page

Lecture Plan

[http://en.wikipedia.org/wiki/Wikipedia:How_to_edit_a_page How to Edit a Page? ]

Help:Displaying_a_formula

wolframalpha

Manual


 * [CST]

HW2 Problem 2
Note that for $$ f(x) = {e^x} $$

$$ {f^{(n)}}({x_0}) = {f^{(n)}}(0) = {e^0} = 1 $$

So,

$$ {p_n}(x) = f(0) + \frac{f^{(1)}}(0) + \frac{f^{(2)}}(0) + ... + \frac{f^{(n)}}(0) $$


 * {| style="width:100%" border="0"

$$  \displaystyle {p_n}(x) = 1 + \sum\limits_{i = 1}^\infty {\frac} $$     (2-1)
 * style="width:95%" |
 * style="width:95%" |
 * 
 * }

and

$$ {R_{n + 1}}(x) = \frac{f^{(n + 1)}}(\xi ) = \frac{e^\xi } $$


 * {| style="width:100%" border="0"

$$  \displaystyle {R_{n + 1}}(x) = \frac{e^\xi } $$     (2-2)
 * style="width:95%" |
 * style="width:95%" |
 * 
 * }


 * {| style="width:100%" border="0"

$$  \displaystyle {e^x} = {p_n}(x) + {R_{n + 1}}(x) = 1 + \sum\limits_{i = 1}^\infty {\frac}  + \frac{e^\xi } $$     (2-3)
 * style="width:92%; padding:10px; border:2px solid #8888aa" |
 * style="width:92%; padding:10px; border:2px solid #8888aa" |
 * 
 * }

From Eq(2-3)

$$ {e^x} - 1 = \sum\limits_{i = 1}^\infty {\frac}  + \frac{e^\xi }$$

so,

$$ f(x) = \frac{x} = \frac{x} = \sum\limits_{i = 1}^\infty {\frac}  + \frac{e^\xi } $$


 * {| style="width:100%" border="0"

$$  \displaystyle f(x) = {p_n}(x) + {R_{n + 1}}(x) = \frac{x} = \sum\limits_{i = 1}^\infty {\frac}  + \frac{e^\xi } $$     (2-4)
 * style="width:92%; padding:10px; border:2px solid #8888aa" |
 * style="width:92%; padding:10px; border:2px solid #8888aa" |
 * 
 * }

So for $$ f(x) = \frac{x} $$


 * {| style="width:100%" border="0"

$$  \displaystyle {p_n}(x)= \sum\limits_{i = 1}^\infty {\frac} $$
 * style="width:92%; padding:10px; border:2px solid #8888aa" |
 * style="width:92%; padding:10px; border:2px solid #8888aa" |

$$  \displaystyle {R_{n + 1}}(x)=\frac{e^\xi } $$

where $$ \xi \in [{x_0},x] $$ (2-5)
 * 
 * }

= Problem 2.12 Numerically calculating integral of a function using Lagrange method =

Ref: Egm6341.s10.team3.sa/HW2

Given
$$ f(x)=\frac{e^{x}-1}{x} $$ on $$ x\in[0,1] (a) $$ and $$ x\in[0,1] (b) $$

Find
A) Construct $$ f_{n}(x)= \sum_{i=0}^{n}l_{i,n}(x)f(x_{i}) $$ for $$\displaystyle n = 1, 2, 4, 8, 16 $$ for both intervals.

B) Plot $$\displaystyle f(x) $$ and $$\displaystyle f_{n}(x) $$ for n = 1, 2, 4, 8, 16.

C) Compute $$ I_{n}=\int_{b}^{b}f_{n}(x)dx $$ for n = 1, 2, 4, 8 and compare to $$\displaystyle I $$.

D) For n = 5, plot $$\displaystyle l_{0}, l_{1}, l_{2} $$.

Solution
A) Considering the following equations:

$$  \displaystyle l_{i,n}(x) = \prod_{j=0,i\neq j}^{n}\frac{x-x_{j}}{x_{i}-x_{j}} $$ and $$  \displaystyle

f_{n}=\sum_{i=0}^{n}l_{i,n}(x)f(x_{i}) $$

for different n values and $$ x\in[0,1] $$, the followings can be calculated:

When n = 1

$$ \displaystyle x_{0} = 0, x_{1} = 1 $$.

$$\displaystyle l_{0,1}=\prod_{j=0,j\neq 0}^{1}\frac{x-x_{j}}{x_{0}-x_{j}}=\frac{x-1}{0-1}, \quad f(x_{0})=f(0)=1, $$

$$\displaystyle l_{1,1}=\prod_{j=0,j\neq 1}^{1}\frac{x-x_{j}}{x_{1}-x_{j}}=\frac{x-0}{1-0}, \quad f(x_{1})=f(1)=e-1. $$

When n = 2

$$ x_{0} = 0, x_{1} = \frac{1}{2}, x_{2} = 1 $$.

$$\displaystyle l_{0,2}=\prod_{j=0,j\neq 0}^{2}\frac{x-x_{j}}{x_{0}-x_{j}}=\frac{(x-\frac{1}{2})(x-1)}{(0-\frac{1}{2}(0-1)}, \quad f(x_{0})=f(0)=1, $$

$$\displaystyle l_{1,2}=\prod_{j=0,j\neq 1}^{2}\frac{x-x_{j}}{x_{1}-x_{j}}=\frac{(x-0)(x-1)}{(\frac{1}{2}-0)(\frac{1}{2}-1)}, \quad f(x_{1})=f(\frac{1}{2})=2\left(e^{\frac{1}{2}}-1\right), $$

$$\displaystyle l_{2,2}=\prod_{j=0,j\neq 2}^{2}\frac{x-x_{j}}{x_{2}-x_{j}}=\frac{(x-0)(x-\frac{1}{2})}{(1-0)(1-\frac{1}{2})}, \quad f(x_{2})=f(1)=e-1. $$

When n = 4

$$ x_{0} = 0, x_{1} = \frac{1}{4}, x_{2} = \frac{2}{4}, x_{3} = \frac{3}{4}, x_{4} = 1 $$.

$$\displaystyle l_{0,4}=\prod_{j=0,j\neq 0}^{4}\frac{x-x_{j}}{x_{0}-x_{j}}=\frac{(x-\frac{1}{4})(x-\frac{2}{4})(x-\frac{3}{4})(x-1)}{(0-\frac{1}{4})(0-\frac{2}{4})(0-\frac{3}{4})(0-1)}, \quad f(x_{0})=f(0)=1, $$

$$\displaystyle l_{1,4}=\prod_{j=0,j\neq 1}^{4}\frac{x-x_{j}}{x_{1}-x_{j}}=\frac{(x-0)(x-\frac{2}{4})(x-\frac{3}{4})(x-1)}{(\frac{1}{4}-0)(\frac{1}{4}-\frac{2}{4})(\frac{1}{4}-\frac{3}{4})(\frac{1}{4}-1)}, \quad f(x_{1})=f(\frac{1}{4})=4\left(e^{\frac{1}{4}}-1\right), $$ $$\displaystyle l_{2,4}=\prod_{j=0,j\neq 2}^{4}\frac{x-x_{j}}{x_{2}-x_{j}}=\frac{(x-0)(x-\frac{1}{4})(x-\frac{3}{4})(x-1)}{(\frac{2}{4}-0)(\frac{2}{4}-\frac{1}{4})(\frac{2}{4}-\frac{3}{4})(\frac{2}{4}-1)}, \quad f(x_{2})=f(\frac{2}{4})=2\left(e^{\frac{2}{4}}-1\right), $$

$$\displaystyle l_{3,4}=\prod_{j=0,j\neq 3}^{4}\frac{x-x_{j}}{x_{3}-x_{j}}=\frac{(x-0)(x-\frac{1}{4})(x-\frac{2}{4})(x-1)}{(\frac{3}{4}-0)(\frac{3}{4}-\frac{1}{4})(\frac{3}{4}-\frac{2}{4})(\frac{3}{4}-1)}, \quad f(x_{3})=f(\frac{3}{4})=\frac{4}{3}\left(e^{\frac{3}{4}}-1\right), $$

$$\displaystyle l_{4,4}=\prod_{j=0,j\neq 4}^{4}\frac{x-x_{j}}{x_{4}-x_{j}}=\frac{(x-0)(x-\frac{1}{4})(x-\frac{2}{4})(x-\frac{3}{4})}{(1-0)(1-\frac{1}{4})(1-\frac{2}{4})(1-\frac{3}{4})}, \quad f(x_{4})=f(1)=e-1, $$

When n = 8

$$ x_{0} = 0, x_{1} = \frac{1}{8}, x_{2} = \frac{2}{8}, x_{3} = \frac{3}{8}, x_{4} = \frac{4}{8}, x_{5} = \frac{5}{8}, x_{6} = \frac{6}{8}, x_{7} = \frac{7}{8}, x_{8} = 1 $$.

$$\displaystyle l_{0,8}=\prod_{j=0,j\neq 0}^{8}\frac{x-x_{j}}{x_{0}-x_{j}}=\frac{(x-\frac{1}{8})(x-\frac{2}{8})(x-\frac{3}{8})(x-\frac{4}{8})(x-\frac{5}{8})(x-\frac{6}{8})(x-\frac{7}{8})(x-1)}{(0-\frac{1}{8})(0-\frac{2}{8})(0-\frac{3}{8})(0-\frac{4}{8})(0-\frac{5}{8})(0-\frac{6}{8})(0-\frac{7}{8})(0-1)}, \quad f(x_{0})=f(0)=1, $$

$$\displaystyle l_{1,8}=\prod_{j=0,j\neq 1}^{8}\frac{x-x_{j}}{x_{1}-x_{j}}=\frac{(x-0)(x-\frac{2}{8})(x-\frac{3}{8})(x-\frac{4}{8})(x-\frac{5}{8})(x-\frac{6}{8})(x-\frac{7}{8})(x-1)}{(\frac{1}{8}-0)(\frac{1}{8}-\frac{2}{8})(\frac{1}{8}-\frac{3}{8})(\frac{1}{8}-\frac{4}{8})(\frac{1}{8}-\frac{5}{8})(\frac{1}{8}-\frac{6}{8})(\frac{1}{8}-\frac{7}{8})(\frac{1}{8}-1)}, \quad f(x_{1})=f(\frac{1}{8})=8\left(e^{\frac{1}{8}}-1\right), $$

$$\displaystyle l_{2,8}=\prod_{j=0,j\neq 2}^{8}\frac{x-x_{j}}{x_{2}-x_{j}}=\frac{(x-0)(x-\frac{1}{8})(x-\frac{3}{8})(x-\frac{4}{8})(x-\frac{5}{8})(x-\frac{6}{8})(x-\frac{7}{8})(x-1)}{(\frac{2}{8}-0)(\frac{2}{8}-\frac{1}{8})(\frac{2}{8}-\frac{3}{8})(\frac{2}{8}-\frac{4}{8})(\frac{2}{8}-\frac{5}{8})(\frac{2}{8}-\frac{6}{8})(\frac{2}{8}-\frac{7}{8})(\frac{2}{8}-1)}, \quad f(x_{2})=f(\frac{2}{8})=\frac{8}{2}\left(e^{\frac{2}{8}}-1\right), $$

$$\displaystyle l_{3,8}=\prod_{j=0,j\neq 3}^{8}\frac{x-x_{j}}{x_{3}-x_{j}}=\frac{(x-0)(x-\frac{1}{8})(x-\frac{2}{8})(x-\frac{4}{8})(x-\frac{5}{8})(x-\frac{6}{8})(x-\frac{7}{8})(x-1)}{(\frac{3}{8}-0)(\frac{3}{8}-\frac{1}{8})(\frac{3}{8}-\frac{2}{8})(\frac{3}{8}-\frac{4}{8})(\frac{3}{8}-\frac{5}{8})(\frac{3}{8}-\frac{6}{8})(\frac{3}{8}-\frac{7}{8})(\frac{3}{8}-1)}, \quad f(x_{3})=f(\frac{3}{8})=\frac{8}{3}\left(e^{\frac{3}{8}}-1\right), $$

$$\displaystyle l_{4,8}=\prod_{j=0,j\neq 4}^{8}\frac{x-x_{j}}{x_{4}-x_{j}}=\frac{(x-0)(x-\frac{1}{8})(x-\frac{2}{8})(x-\frac{3}{8})(x-\frac{5}{8})(x-\frac{6}{8})(x-\frac{7}{8})(x-1)}{(\frac{4}{8}-0)(\frac{4}{8}-\frac{1}{8})(\frac{4}{8}-\frac{2}{8})(\frac{4}{8}-\frac{3}{8})(\frac{4}{8}-\frac{5}{8})(\frac{4}{8}-\frac{6}{8})(\frac{4}{8}-\frac{7}{8})(\frac{4}{8}-1)}, \quad f(x_{4})=f(\frac{4}{8})=\frac{8}{4}\left(e^{\frac{4}{8}}-1\right), $$

$$\displaystyle l_{5,8}=\prod_{j=0,j\neq 5}^{8}\frac{x-x_{j}}{x_{5}-x_{j}}=\frac{(x-0)(x-\frac{1}{8})(x-\frac{2}{8})(x-\frac{3}{8})(x-\frac{4}{8})(x-\frac{6}{8})(x-\frac{7}{8})(x-1)}{(\frac{5}{8}-0)(\frac{5}{8}-\frac{1}{8})(\frac{5}{8}-\frac{2}{8})(\frac{5}{8}-\frac{3}{8})(\frac{5}{8}-\frac{4}{8})(\frac{5}{8}-\frac{6}{8})(\frac{5}{8}-\frac{7}{8})(\frac{5}{8}-1)}, \quad f(x_{5})=f(\frac{5}{8})=\frac{8}{5}\left(e^{\frac{5}{8}}-1\right), $$

$$\displaystyle l_{6,8}=\prod_{j=0,j\neq 6}^{8}\frac{x-x_{j}}{x_{6}-x_{j}}=\frac{(x-0)(x-\frac{1}{8})(x-\frac{2}{8})(x-\frac{3}{8})(x-\frac{4}{8})(x-\frac{5}{8})(x-\frac{7}{8})(x-1)}{(\frac{6}{8}-0)(\frac{6}{8}-\frac{1}{8})(\frac{6}{8}-\frac{2}{8})(\frac{6}{8}-\frac{3}{8})(\frac{6}{8}-\frac{4}{8})(\frac{6}{8}-\frac{5}{8})(\frac{6}{8}-\frac{7}{8})(\frac{6}{8}-1)}, \quad f(x_{6})=f(\frac{6}{8})=\frac{8}{6}\left(e^{\frac{6}{8}}-1\right), $$

$$\displaystyle l_{7,8}=\prod_{j=0,j\neq 7}^{8}\frac{x-x_{j}}{x_{7}-x_{j}}=\frac{(x-0)(x-\frac{1}{8})(x-\frac{2}{8})(x-\frac{3}{8})(x-\frac{4}{8})(x-\frac{5}{8})(x-\frac{6}{8})(x-1)}{(\frac{7}{8}-0)(\frac{7}{8}-\frac{1}{8})(\frac{7}{8}-\frac{2}{8})(\frac{7}{8}-\frac{3}{8})(\frac{7}{8}-\frac{4}{8})(\frac{7}{8}-\frac{5}{8})(\frac{7}{8}-\frac{6}{8})(\frac{7}{8}-1)}, \quad f(x_{7})=f(\frac{7}{8})=\frac{8}{7}\left(e^{\frac{7}{8}}-1\right), $$ $$\displaystyle l_{8,8}=\prod_{j=0,j\neq 8}^{8}\frac{x-x_{j}}{x_{8}-x_{j}}=\frac{(x-0)(x-\frac{1}{8})(x-\frac{2}{8})(x-\frac{3}{8})(x-\frac{4}{8})(x-\frac{5}{8})(x-\frac{6}{8})(x-\frac{7}{8})}{(1-0)(1-\frac{1}{8})(1-\frac{2}{8})(1-\frac{3}{8})(1-\frac{4}{8})(1-\frac{5}{8})(1-\frac{6}{8})(1-\frac{7}{8})}, \quad f(x_{8})=f(1)=e-1. $$

When n = 16 $$ x_{0} = 0, x_{1} = \frac{1}{16}, x_{2} = \frac{2}{16}, x_{3} = \frac{3}{16}, x_{4} = \frac{4}{16}, x_{5} = \frac{5}{16}, x_{6} = \frac{6}{16}, x_{7} = \frac{7}{16}, x_{8} = \frac{8}{16}, x_{9} = \frac{9}{16}, x_{10} = \frac{10}{16}, x_{11} = \frac{11}{16}, x_{12} = \frac{12}{16}, x_{13} = \frac{13}{16}, x_{14} = \frac{14}{16}, x_{15} = \frac{15}{16}, x_{16} = 1 $$.

$$\displaystyle l_{0,16}=\prod_{j=0,j\neq 0}^{16}\frac{x-x_{j}}{x_{0}-x_{j}}=\frac{(x-\frac{1}{16})(x-\frac{2}{16})(x-\frac{3}{16})(x-\frac{4}{16})(x-\frac{5}{16})(x-\frac{6}{16})(x-\frac{7}{16})(x-\frac{8}{16})(x-\frac{9}{16})(x-\frac{10}{16})(x-\frac{11}{16})(x-\frac{12}{16})(x-\frac{13}{16})(x-\frac{14}{16})(x-\frac{15}{16})(x-1)}{(0-\frac{1}{16})(0-\frac{2}{16})(0-\frac{3}{16})(0-\frac{4}{16})(0-\frac{5}{16})(0-\frac{6}{16})(0-\frac{7}{16})(0-\frac{8}{16})(0-\frac{9}{16})(0-\frac{10}{16})(0-\frac{11}{16})(0-\frac{12}{16})(0-\frac{13}{16})(0-\frac{14}{16})(0-\frac{15}{16})(0-1)}, \quad f(x_{0})=f(0)=1, $$

$$\displaystyle l_{1,16}=\prod_{j=0,j\neq 1}^{16}\frac{x-x_{j}}{x_{1}-x_{j}}=\frac{(x-0)(x-\frac{2}{16})(x-\frac{3}{16})(x-\frac{4}{16})(x-\frac{5}{16})(x-\frac{6}{16})(x-\frac{7}{16})(x-\frac{8}{16})(x-\frac{9}{16})(x-\frac{10}{16})(x-\frac{11}{16})(x-\frac{12}{16})(x-\frac{13}{16})(x-\frac{14}{16})(x-\frac{15}{16})(x-1)}{(\frac{1}{16}-0)(\frac{1}{16}-\frac{2}{16})(\frac{1}{16}-\frac{3}{16})(\frac{1}{16}-\frac{4}{16})(\frac{1}{16}-\frac{5}{16})(\frac{1}{16}-\frac{6}{16})(\frac{1}{16}-\frac{7}{16})(\frac{1}{16}-\frac{8}{16})(\frac{1}{16}-\frac{9}{16})(\frac{1}{16}-\frac{10}{16})(\frac{1}{16}-\frac{11}{16})(\frac{1}{16}-\frac{12}{16})(\frac{1}{16}-\frac{13}{16})(\frac{1}{16}-\frac{14}{16})(\frac{1}{16}-\frac{15}{16})(\frac{1}{16}-1)}, \quad f(x_{1})=f(\frac{1}{16})=16\left(e^{\frac{1}{16}}-1\right), $$

and it can be calculate up to $$ l_{16,16} $$ in the same manner.

$$\displaystyle l_{16,16}=\prod_{j=0,j\neq 16}^{16}\frac{x-x_{j}}{x_{16}-x_{j}}=\frac{(x-0)(x-\frac{1}{16})(x-\frac{2}{16})(x-\frac{3}{16})(x-\frac{4}{16})(x-\frac{5}{16})(x-\frac{6}{16})(x-\frac{7}{16})(x-\frac{8}{16})(x-\frac{9}{16})(x-\frac{10}{16})(x-\frac{11}{16})(x-\frac{12}{16})(x-\frac{13}{16})(x-\frac{14}{16})(x-\frac{15}{16})}{(1-0)(1-\frac{1}{16})(1-\frac{2}{16})(1-\frac{3}{16})(1-\frac{4}{16})(1-\frac{5}{16})(1-\frac{6}{16})(1-\frac{7}{16})(1-\frac{8}{16})(1-\frac{9}{16})(1-\frac{10}{16})(1-\frac{11}{16})(1-\frac{12}{16})(1-\frac{13}{16})(1-\frac{14}{16})(1-\frac{15}{16})}, \quad f(x_{16})=f(1)=e-1, $$

And for different n values and $$ x\in[-1,1] $$, the followings can be calculated:

When n = 1

$$ \displaystyle x_{0} = -1, x_{1} = 1 $$.

$$\displaystyle l_{0,1} = \prod\limits_{j = 0,j \ne 0}^1 {\frac} = \frac,\quad f({x_0}) = f( - 1) =  - ({e^{ - 1}} - 1) $$

$$ {l_{1,1}} = \prod\limits_{j = 0,j \ne 1}^1 {\frac} = \frac,\quad f({x_1}) = f(1) = e - 1. $$

When n = 2

$$ \displaystyle x_{0} = -1, x_{1} = 0, x_{2} = 1 $$.

$${l_{0,2}} = \prod\limits_{j = 0,j \ne 0}^2 {\frac} = \frac,\quad f({x_0}) = f( - 1) =  - ({e^{ - 1}} - 1), $$

$${l_{1,2}} = \prod\limits_{j = 0,j \ne 1}^2 {\frac} = \frac,\quad f({x_1}) = f(0) = 1 $$

$${l_{2,2}} = \prod\limits_{j = 0,j \ne 2}^2 {\frac} = \frac,\quad f({x_2}) = f(1) = e - 1. $$

When n = 4

$$ \displaystyle x_{0} = -1, x_{1} = -\frac{1}{2}, x_{2} = 0, x_{3} = \frac{1}{2}, x_{4} = 1 $$.

$$ {l_{0,4}} = \prod\limits_{j = 0,j \ne 0}^4 {\frac} = \frac,\quad f({x_0}) = f( - 1) =  - ({e^{ - 1}} - 1)$$

$${l_{1,4}} = \prod\limits_{j = 0,j \ne 1}^4 {\frac} = \frac,\quad f({x_1}) = f( - \frac{1}{2}) =  - 2\left( {{e^{ - \frac{1}{2}}} - 1} \right), $$

$${l_{2,4}} = \prod\limits_{j = 0,j \ne 2}^4 {\frac} = \frac,\quad f({x_2}) = f(0) = 1, $$

$${l_{3,4}} = \prod\limits_{j = 0,j \ne 3}^4 {\frac} = \frac,\quad f({x_3}) = f(\frac{1}{2}) = 2\left( {{e^{\frac{1}{2}}} - 1} \right), $$

$$ {l_{4,4}} = \prod\limits_{j = 0,j \ne 4}^4 {\frac} = \frac,\quad f({x_4}) = f(1) = e - 1, $$

When n = 8

$$ \displaystyle x_{0} = -1, x_{1} = -\frac{3}{4}, x_{2} =- \frac{2}{4}, x_{3} = -\frac{1}{4}, x_{4} = 0, x_{5} = \frac{1}{4}, x_{6} = \frac{2}{4}, x_{7} = \frac{3}{4}, x_{8} = 1 $$.

$$ l_{0,8} = \prod\limits_{j = 0,j \ne 0}^8 {\frac} = \frac,\quad f({x_0}) = f( - 1) =  - ({e^{ - 1}} - 1), $$

$${l_{1,8}} = \prod\limits_{j = 0,j \ne 1}^8 {\frac} = \frac,\quad f({x_1}) = f( - \frac{3}{4}) =  - \frac{4}{3}\left( {{e^{ - \frac{3}{4}}} - 1} \right), $$

$$ {l_{2,8}} = \prod\limits_{j = 0,j \ne 2}^8 {\frac}  = \frac,\quad f({x_2}) = f( - \frac{2}{4}) =  - 2\left( {{e^{ - \frac{2}{4}}} - 1} \right), $$

$$ {l_{3,8}} = \prod\limits_{j = 0,j \ne 3}^8 {\frac}  = \frac,\quad f({x_3}) = f( - \frac{1}{4}) =  - 4\left( {{e^{ - \frac{1}{4}}} - 1} \right)$$

$$ {l_{4,8}} = \prod\limits_{j = 0,j \ne 4}^8 {\frac}  = \frac,\quad f({x_4}) = f(0) = 1, $$

$$ {l_{5,8}} = \prod\limits_{j = 0,j \ne 5}^8 {\frac} = \frac,\quad f({x_5}) = f(\frac{1}{4}) = 4\left( {{e^{\frac{1}{4}}} - 1} \right),$$

$$ {l_{6,8}} = \prod\limits_{j = 0,j \ne 6}^8 {\frac}  = \frac,\quad f({x_6}) = f(\frac{2}{4}) = 2\left( {{e^{\frac{2}{4}}} - 1} \right), $$

$$ {l_{7,8}} = \prod\limits_{j = 0,j \ne 7}^8 {\frac} = \frac,\quad f({x_7}) = f(\frac{3}{4}) = \frac{4}{3}\left( {{e^{\frac{3}{4}}} - 1} \right),$$

$${l_{8,8}} = \prod\limits_{j = 0,j \ne 8}^8 {\frac} = \frac,\quad f({x_8}) = f(1) = e - 1. $$

When n = 16 $$ \displaystyle x_{0} = -1, x_{1} = -\frac{7}{8}, x_{2} = -\frac{6}{8}, x_{3} = -\frac{5}{8}, x_{4} = -\frac{4}{8}, x_{5} = -\frac{3}{8}, x_{6} = -\frac{2}{8}, x_{7} = \frac{1}{8}, x_{8} = 0, x_{9} = \frac{1}{8}, x_{10} = \frac{2}{8}, x_{11} = \frac{3}{8}, x_{12} = \frac{4}{8}, x_{13} = \frac{5}{8}, x_{14} = \frac{6}{8}, x_{15} = \frac{7}{8}, x_{16} = 1 $$.

$$ l_{0,16} = \prod\limits_{j = 0,j \ne 0}^{16} {\frac} = \frac,\quad f({x_0}) = f( - 1) =  - ({e^{ - 1}} - 1), $$

$${l_{1,16}} = \prod\limits_{j = 0,j \ne 1}^{16} {\frac} = \frac,\quad f({x_1}) = f( - \frac{7}{8}) =  - \frac{8}{7}\left( {{e^{ - \frac{7}{8}}} - 1} \right),$$

and it can be calculate up to $$ l_{16,16} $$ in the same manner.

$$ {l_{16,16}} = \prod\limits_{j = 0,j \ne 16}^{16} {\frac}  = \frac,\quad f({x_{16}}) = f(1) = e - 1, $$

B) Considering the following equation, the approximated integral can be calculated:

$$ {I_n} = \int\limits_a^b {\sum\limits_{i = 0}^n {{l_{i,n}}({x_i}).f({x_i})dx} } $$

note that $$ {E_n} = \left| {I - {I_n}} \right| $$ is the difference between the exact integral $$\displaystyle I $$ and approximated integral $$\displaystyle  I_n $$ The exact integral was calculated using wolframalpha

C)


 * [[File:HW2 P12 A.png|1000px|center|thumb|Figure 12.1: $$\displaystyle f(x), f_1(x), f_2(x), f_4(x), f_8(x) for x\in[0,1] $$]]
 * [[File:HW2 P12 B.png|1000px|center|thumb|Figure 12.2: $$\displaystyle f(x), f_1(x), f_2(x), f_4(x), f_8(x) for x\in[-1,1] $$]]

D)
 * [[File:HW2 P12 C.png|1000px|center|thumb|Figure 12.3: $$\displaystyle f(x), l_{0,5},l_{1,5},l_{2,5} for x\in[0,1] $$]]

= Problem 2.2 Taylor series expansion of sin(x) =

Ref: Egm6341.s10.team3.sa/HW1

Given
$$ f(x)=sin x, x \in [0,\pi] $$

Find
Construct a Taylor series of $$f(x)$$ around $$x_0 = \frac{\pi}{4}$$ for $$\displaystyle n=0,1,2......,10.$$

Construct a Taylor series of $$f(x)$$ around $$x_0 = \frac{3\pi}{8}$$ for $$\displaystyle n=0,1,2......,10.$$

Estimate the maximum $$\displaystyle R(x)$$ at $$ x=\frac{3\pi}{4}$$

Plot the series for each $$\displaystyle n $$

Solution
Considering

$$ {p_n}(x) = f({x_0}) + \frac{f^{(1)}}({x_0}) + \frac{f^{(2)}}({x_0}) + ... + \frac{f^{(n)}}({x_0}) $$

for $$ \displaystyle f({x}) = \sin ({x}) $$ around the point $${x_0} = \frac{\pi }{4} $$ the follwoing equations can be calculated for $$ \displaystyle n= 0,1,2,...,10.$$ Note that $$f({x_0}) = \sin (\frac{\pi }{4}) = \frac{2} $$

$${p_0}(x) = \frac{2}$$

$${p_1}(x) = \frac{2} + \frac\cos (\frac{\pi }{4}) $$

$${p_2}(x) = \frac{2} + \frac\cos (\frac{\pi }{4}) - \frac\sin (\frac{\pi }{4}) $$

$${p_3}(x) = \frac{2} + \frac\cos (\frac{\pi }{4}) - \frac\sin (\frac{\pi }{4}) - \frac\cos (\frac{\pi }{4}) $$

$${p_4}(x) = \frac{2} + \frac\cos (\frac{\pi }{4}) - \frac\sin (\frac{\pi }{4}) - \frac\cos (\frac{\pi }{4}) + \frac\sin (\frac{\pi }{4}) $$

$${p_5}(x) = \frac{2} + \frac\cos (\frac{\pi }{4}) - \frac\sin (\frac{\pi }{4}) - \frac\cos (\frac{\pi }{4}) + \frac\sin (\frac{\pi }{4}) + \frac\cos (\frac{\pi }{4}) $$

$$ {p_6}(x) = \frac{2} + \frac\cos (\frac{\pi }{4}) - \frac\sin (\frac{\pi }{4}) - \frac\cos (\frac{\pi }{4}) + \frac\sin (\frac{\pi }{4}) + \frac\cos (\frac{\pi }{4}) - \frac\sin (\frac{\pi }{4}) $$

$${p_7}(x) = \frac{2} + \frac\cos (\frac{\pi }{4}) - \frac\sin (\frac{\pi }{4}) - \frac\cos (\frac{\pi }{4}) + \frac\sin (\frac{\pi }{4}) + \frac\cos (\frac{\pi }{4}) - \frac\sin (\frac{\pi }{4}) - \frac\cos (\frac{\pi }{4})$$

$$ {p_8}(x) = \frac{2} + \frac\cos (\frac{\pi }{4}) - \frac\sin (\frac{\pi }{4}) - \frac\cos (\frac{\pi }{4}) + \frac\sin (\frac{\pi }{4}) + \frac\cos (\frac{\pi }{4}) - \frac\sin (\frac{\pi }{4}) - \frac\cos (\frac{\pi }{4}) + \frac\sin (\frac{\pi }{4}) $$

$${p_9}(x) = \frac{2} + \frac\cos (\frac{\pi }{4}) - \frac\sin (\frac{\pi }{4}) - \frac\cos (\frac{\pi }{4}) + \frac\sin (\frac{\pi }{4}) + \frac\cos (\frac{\pi }{4}) - \frac\sin (\frac{\pi }{4}) - \frac\cos (\frac{\pi }{4}) + \frac\sin (\frac{\pi }{4}) + \frac\cos (\frac{\pi }{4}) $$

$${p_{10}}(x) = \frac{2} + \frac\cos (\frac{\pi }{4}) - \frac\sin (\frac{\pi }{4}) - \frac\cos (\frac{\pi }{4}) + \frac\sin (\frac{\pi }{4}) + \frac\cos (\frac{\pi }{4}) - \frac\sin (\frac{\pi }{4}) - \frac\cos (\frac{\pi }{4}) + \frac\sin (\frac{\pi }{4}) + \frac\cos (\frac{\pi }{4}) - \frac\sin (\frac{\pi }{4}) $$

which can be simplified to the following equations:

Considering

$$ {p_n}(x) = f({x_0}) + \frac{f^{(1)}}({x_0}) + \frac{f^{(2)}}({x_0}) + ... + \frac{f^{(n)}}({x_0}) $$

for $$ \displaystyle f({x}) = \sin ({x}) $$ around the point $${x_0} = \frac{3\pi }{8} $$ the follwoing equations can be calculated for $$ \displaystyle n= 0,1,2,...,10.$$

$${p_0}(x) = \sin (\frac{8}) $$

$${p_1}(x) = \sin (\frac{8}) + \frac\cos (\frac{8})$$ $${p_2}(x) = \sin (\frac{8}) + \frac\cos (\frac{8}) - \frac\sin (\frac{8}) $$

$${p_3}(x) = \sin (\frac{8}) + \frac\cos (\frac{8}) - \frac\sin (\frac{8}) - \frac\cos (\frac{8}) $$

$${p_4}x) = \sin (\frac{8}) + \frac\cos (\frac{8}) - \frac\sin (\frac{8}) - \frac\cos (\frac{8}) + \frac\sin (\frac{8}) $$

$${p_5}(x) = \sin (\frac{8}) + \frac\cos (\frac{8}) - \frac\sin (\frac{8}) - \frac\cos (\frac{8}) + \frac\sin (\frac{8}) + \frac\cos (\frac{8}) $$

$${p_6}(x) = \sin (\frac{8}) + \frac\cos (\frac{8}) - \frac\sin (\frac{8}) - \frac\cos (\frac{8}) + \frac\sin (\frac{8}) + \frac\cos (\frac{8}) - \frac\sin (\frac{8})$$

$${p_7}(x) = \sin (\frac{8}) + \frac\cos (\frac{8}) - \frac\sin (\frac{8}) - \frac\cos (\frac{8}) + \frac\sin (\frac{8}) + \frac\cos (\frac{8}) - \frac\sin (\frac{8}) - \frac\cos (\frac{8}) $$

$${p_8}(x) = \sin (\frac{8}) + \frac\cos (\frac{8}) - \frac\sin (\frac{8}) - \frac\cos (\frac{8}) + \frac\sin (\frac{8}) + \frac\cos (\frac{8}) - \frac\sin (\frac{8}) - \frac\cos (\frac{8}) + \frac\sin (\frac{8}) $$

$${p_9}(x) = \sin (\frac{8}) + \frac\cos (\frac{8}) - \frac\sin (\frac{8}) - \frac\cos (\frac{8}) + \frac\sin (\frac{8}) + \frac\cos (\frac{8}) - \frac\sin (\frac{8}) - \frac\cos (\frac{8}) + \frac\sin (\frac{8}) + \frac\cos (\frac{8}) $$

$${p_{10}}(x) = \sin (\frac{8}) + \frac\cos (\frac{8}) - \frac\sin (\frac{8}) - \frac\cos (\frac{8}) + \frac\sin (\frac{8}) + \frac\cos (\frac{8}) - \frac\sin (\frac{8}) - \frac\cos (\frac{8}) + \frac\sin (\frac{8}) + \frac\cos (\frac{8}) - \frac\sin (\frac{8})$$

which can be simplified to the following equations:

Matlab Code and Graphs
And here, the graphs show the results. Note that the Matlab code is the same for part A and B and in order to run the Matlab code for part B, the value for $$ x_0 $$ needs to be changed to $$ \frac{8} $$


 * HW2 P2 A.png
 * HW2 P2 B.png

=HW3-P6=


 * {| style="width:100%" border="0"

$$\displaystyle {q_{n + 1}}(x) = \prod\limits_{j = 0}^n {(x - {x_j})} = (x - {x_0})(x - {x_1})...(x - {x_{n - 1}})(x - {x_n}) $$    (6.1)
 * 
 * }


 * {| style="width:100%" border="0"

q_{n + 1}^{n + 1}(x) = (n + 1)! $$     (6.2)
 * $$\displaystyle
 * $$\displaystyle
 * 
 * }

We know that $$ \displaystyle{q_{n + 1}}(x) \in {p_{n + 1}}$$, so (6.1) can be written as:


 * {| style="width:100%" border="0"

{q_{n + 1}}(x) = \underbrace _{f(x)} + \underbrace {{a_n}{x^n} + {a_{n - 1}}{x^{n - 1}} + ... + {a_1}{x^1} + {a_0}{x^0}}_{{p_n}(x)} $$     (6.3)
 * $$\displaystyle
 * $$\displaystyle
 * 
 * }

note that in (6.3), $$ {a_{n + 1}} = 1\displaystyle $$.


 * {| style="width:100%" border="0"

q_{n + 1}^{n + 1}(x) = {f^{n + 1}}(x) + p_n^{n + 1}(x) $$     (6.4)
 * $$\displaystyle
 * $$\displaystyle
 * 
 * }

where $$\displaystyle p_n^{n + 1}(x) = 0 $$ and $$\displaystyle {f^{n + 1}}(x) $$ can be calculated as follows:


 * {| style="width:100%" border="0"

f(x) = {x^{n + 1}} $$
 * $$\displaystyle
 * $$\displaystyle
 * 
 * }


 * {| style="width:100%" border="0"

{f^1}(x) = (n + 1){x^n} $$
 * $$\displaystyle
 * $$\displaystyle
 * 
 * }


 * {| style="width:100%" border="0"

{f^2}(x) = (n + 1)(n){x^{n - 1}} $$
 * $$\displaystyle
 * $$\displaystyle
 * 
 * }


 * {| style="width:100%" border="0"

{f^3}(x) = (n + 1)(n)(n - 1){x^{n - 2}} $$
 * $$\displaystyle
 * $$\displaystyle
 * 
 * }


 * {| style="width:100%" border="0"

{f^{n - 1}}(x) = (n + 1)(n)(n - 1)......(2){x^{n - (n - 1)}} $$
 * $$\displaystyle
 * $$\displaystyle
 * 
 * }


 * {| style="width:100%" border="0"

{f^n}(x) = (n + 1)(n)(n - 1)......(2)(1){x^{n - n}} $$
 * $$\displaystyle
 * $$\displaystyle
 * 
 * }


 * {| style="width:100%" border="0"

{f^{n + 1}}(x) = (n + 1)! $$
 * $$\displaystyle
 * $$\displaystyle
 * 
 * }

and consequently

= Summary=

Licensing
{| cellspacing="1" cellpadding="1" style="background: #f7f8ff; border: 1px solid #88a; padding: 5px; font-size: 80%;"
 * - style="text-align: center;"
 * style="width: 88px; padding-right: 6px;" | [[Image:CC_some_rights_reserved.svg|90px]]
 * style="background: #ccf;" |Multi-licensed with any Creative Commons Attribution Share-Alike License
 * style="width: 88px; padding-left: 6px;" | [[Image:CC_some_rights_reserved.svg|90px]]
 * colspan="3" |I agree to multi-license my text contributions, unless otherwise stated, under Wikipedia's copyright terms and the Creative Commons license Attribution Share-Alike version 3.0 and the Creative Commons license Attribution Non-Commercial Share-Alike version 3.0. Please be aware that other contributors might not do the same, so if you want to use my contributions under the Creative Commons terms, please check the CC dual-license and Multi-licensing guides.
 * colspan="3" |I agree to multi-license my text contributions, unless otherwise stated, under Wikipedia's copyright terms and the Creative Commons license Attribution Share-Alike version 3.0 and the Creative Commons license Attribution Non-Commercial Share-Alike version 3.0. Please be aware that other contributors might not do the same, so if you want to use my contributions under the Creative Commons terms, please check the CC dual-license and Multi-licensing guides.