0

I am suppose to approximate it in two different ways. one by just using one taylor series at one point and the other way by breaking it down into segments and integrating. Which is suppose to be more accurate. The second way is supposed to be better by the wording of the problem but it is way off?? which way is better??

I want to edit the rest of the bottom out at some point.

Using third order Taylor series to approximate around $x_0$ to find an approximation to the integral 

$$ \int^{1}_{0} e^{-x^2} dx$$

Will first find the derivatives of $f(x)=e^{-x^2}$

$$ \begin{aligned} f^0 (x)&=e^{-x^2} \\ f^1(x)&= -2 xe^{-x^2} \\ f^2(x)&= e^{-x^2}(4x^2-2) \\ f^3(x) &= -4 e^{-x^2} x (2x^2-3) \end{aligned} $$

We will try to find a better approximation

$$\int^{1}_0 e^{-x^2} dx =\int^{1/4} _0 e^{-x^2} dx +\int^{1/2} _{1/4} e^{-x^2} dx +\int^{3/4} _{1/2} e^{-x^2} dx +\int^{1} _{3/4} e^{-x^2} dx $$

First evaluating from interval starting at $0$ to $1/4$ at $x_0=0$ $$ \begin{aligned} \int^{1/4}_0 T_3(x)dx &= \int^{1/4}_0 (1-x^2)dx =47/192 \approx .24479 \end{aligned} $$

Finding Taylor polynomial at $x_0=1$

$$ \begin{aligned} T_3(x;x_0=1) &= e^{-1} -2e^{-1}(x-1)^1 +\frac{1}{2!}e^{-1}(4-2)(x-1)^2 -\frac{1}{3!}4 e^{-1}(2-3)(x-1)^3 \\ &=e^{-1} -2e^{-1}(x-1)^1 + e^{-1}(x-1)^2 -\frac{1}{2*3}*4 e^{-1}*(-1)(x-1)^3 \\&= e^{-1}-2e^{-1}(x-1)+e^{-1}(x-1)^2+\frac{2}{3}e^{-1}(x-1)^3 \end{aligned} $$

Let us use a brainless computer to find the integral and save energy

$$\int^{1/2} _{1/4} T(x:x_0=1)dx= \frac{317}{512 e} \approx .22777 $$

Finding $T_3(x:x_0=-1)$

$$ \begin{aligned} T_3(x:x_0=-1) &=e^{-1} -2(-1)e^{-1}(x-(-1))^1 +\frac{1}{2!}e^{-1}(4-2)(x-(-1))^2 -\frac{1}{3!}4^{-1}(-1)(2(-1)-3)(x-(-1))^3 \\&= e^{-1}+2e^{-1}(x+1) + e^{-1} (x+1)^2 -\frac{1}{3!}4 e^{-1}(x+1)^3 \end{aligned} $$

Again from Wolfram alpha integrating for us

$$ \begin{aligned} \int^{3/4} _{1/2} T_3(x:x_0=-1) =\frac{1543}{1536*e}\approx .36956 \end{aligned} $$

Finding $T_3(x:x_0=2)$

$$ \begin{aligned} T_3(x:x_0=2) &= e^{-(2^2)}- 2 (2) e^{-(2^2)}(x-2)^1 +\frac{1}{2!} e^{-(2^2)}(4(2)^2-2)(x-2)^2 -\frac{1}{3!}4 e^{-(2^2)}(2)(2(2)^2-3)(x-2)^3 \\ &= e^{-4}-4e^{-4}(x-2) +e^{-4}6*(x-2)^2-e^{-4}\frac{20}{3}(x-2)^3 \end{aligned} $$

integrating $T_3(x:x_0=2)$ from $3/4$ to $1$ we get that

$$\int^1_{3/4} T_3(x:x_0=2)dx=\frac{1481}{1536e} $$

Adding everything together we get together

$$ \frac{47}{192}+\frac{317}{512e}+\frac{1543}{1536*e}+\frac{1481}{1536e}=1.1968$$

Matlab says that

$$ \int^{1}_{0} e^{-x^2}dx=.746824\dots $$

Which is better ?

The Maclaurin series is better

why?

Because it is way less work and it is more elegant simple and accurate. THATS WHY!
Tiger Blood
  • 1,940
  • Something went super wrong with your integral. Even trapezoidal integration gets $0.743$, far better than the $2/3$ from the series. – eyeballfrog Sep 01 '17 at 02:41

3 Answers3

1

I don't have enough reputation for a comment, but one thing to note in your post is that $1 - \frac{1}{3} = \frac{2}{3} = 0.666\dots \neq .75$

Also I have a different coefficient for your third term for your Taylor Expansion for $x_0=2$. You wrote 6, but I have 7:

enter image description here

Which therefore changes the value of your fourth integral computation:

enter image description here

Which brings your sum to this: enter image description here

But then again, even with this change, your sum gets a little bit closer to $0.746824$, but it's still not as close as $\frac{2}{3}$.

But let's be honest. This question shows that the Maclaurin Series is better. Perhaps it's trying to show you, that perhaps while not being as complicated, sometimes simpler is better.

1

OK, you seem to have gone wrong in a few ways here. First off, as mentioned, $2/3 \ne 0.75$. Secondly, why are you using the Taylor series about 1, 2, and 3 for the intervals $[1/4,1/2]$, $[1/2,3/4]$, and $[3/4,1]$? Of course you're getting the wrong answer: you're expanding about points way outside the intervals! If you instead expand about 1/4, 1/2, and 3/4 (which I'm sure you can handle yourself), you'll get $$ \int_0^1e^{-x^2}dx\approx \frac{47}{192}+ \frac{3773}{16384}e^{-1/16}+ \frac{1333}{6144} e^{-1/4}+ \frac{10061}{49152 }e^{-9/16}\approx 0.746723, $$ which is accurate to within 135ppm. You can greatly improve this (to 4ppm) by expanding about the midpoints of the intervals instead.

Still, both of these methods are inferior to a good integration rule. Simpson's rule gives $$ \int_0^1e^{-x^2}dx \approx \frac{1}{12}\left[1 + 4e^{-1/16} + 2e^{-1/4} + 4e^{-9/16} + e^{-1}\right]\approx 0.746855, $$ accurate to 42ppm and didn't require anything more than function evaluations.

eyeballfrog
  • 22,485
  • I did not know I was suppose to expand along the intervals. Ill do it with sage. – Tiger Blood Sep 01 '17 at 03:40
  • @Ugo Taylor series get more accurate the closer to the expansion point you are, so you want to get it as close as possible to the points you're evaluating it at. As another example, had you done your initial Taylor expansion (the one with only one interval) about 1/2 instead of 0, you'd have gotten $23e^{-1/4}/24 \approx 0.746350$ instead, accurate to 634ppm. – eyeballfrog Sep 01 '17 at 03:46
1

For sure, the idea of dividing the interval of integration is a good idea for improvement.

What you could also have done is the following : develop the integrand around the mid point of the integration interval (in order to not promote any end of it) and get $$e^{-x^2}=e^{-\frac{(a+b)^2}{4} }-(a+b) e^{-\frac{(a+b)^2}{4} } \left(x-\frac{a+b}{2}\right)+\frac{1}{2} \left((a+b)^2-2\right) e^{-\frac{(a+b)^2}{4} } \left(x-\frac{a+b}{2}\right)^2+O\left(\left(x-\frac{a+b}{2}\right)^3\right)$$ leading to $$\int_a^b e^{-x^2}\,dx=\frac{b-a}{24} \left(\left((a+b)^2-2\right) (a-b)^2+24\right) e^{-\frac{(a+b)^2}{4} }$$ Then, making some minot simplifications, we should get for $$I=\int^{1}_0 e^{-x^2} dx =\int^{1/4} _0 e^{-x^2} dx +\int^{1/2} _{1/4} e^{-x^2} dx +\int^{3/4} _{1/2} e^{-x^2} dx +\int^{1} _{3/4} e^{-x^2} dx$$ $$I=\frac{6161+6137 e^{3/8}+6121 e^{5/8}+6113 e^{3/4}}{24576 e^{49/64}}\approx 0.7468211538$$ which is accurate to within $4$ ppm (the exact value being $\approx 0.7468241328$).