# Estimating the error in the alternating series

So I have the following question here:

Find the Macluarin series of $$\displaystyle F(x) = \int_{0}^{x} (1+t^2)\cos(t^2)dt$$. Use this series to Evaluate $$F(\frac{\pi}{2})$$ with an error less than $$0.001$$.

Now, I know the basic idea. The Maclaurin series of $$\displaystyle \cos(x)=\sum_{n=0}^{\infty} \frac{(-1)^n(t^{2n})}{(2n)!}$$. So then I would just expand the Integral like so:

$$\displaystyle F(x) = \int_{0}^{x} (1+t^2)\cos(t^2)dt$$

$$\displaystyle F(x) = \int_{0}^{x} (1+t^2)\sum_{n=0}^{\infty} \frac{(-1)^n(t^{4n})}{(2n)!}dt$$

$$\displaystyle F(x) = \int_{0}^{x}\sum_{n=0}^{\infty} \frac{(-1)^n(t^{4n})}{(2n)!}dt + \int_{0}^{x}\sum_{n=0}^{\infty} \frac{(-1)^n(t^{4n+2})}{(2n)!}dt$$

$$\displaystyle F(x) = \sum_{n=0}^{\infty} \frac{(-1)^n(x^{4n+1})}{(2n)!(4n+1)} + \sum_{n=0}^{\infty} \frac{(-1)^n(x^{4n+3})}{(2n)!(4n+3)}$$

As far as I know, I would have to combine both of these into a single sum to get my maclaurin series.

Now I know that because these series alternate, I have to use the alternating series estimation theorem and make the error less than $$0.001$$.

Here's where I'm stuck... How do I do that? This would be fine if I had a single sum. However I have two sums here. How do I deal with that?

I could do this by adding up terms if I wanted to I guess. This would require me to integrate $$10$$ terms as such:

$$\displaystyle \int_{0}^{\frac{\pi}{2}}\left(1+x^2-\frac{x^4}{2}-\frac{x^6}{2}+\frac{x^8}{24}+\frac{x^{10}}{24}-\frac{x^{12}}{720}-\frac{x^{14}}{720}+\frac{x^{16}}{40320}+\frac{x^{18}}{40320}\right)dx \approx 0.9259$$ which gives me the desired ammount I want to that the error does not exceed $$0.001$$. However, this requires me to know the value of the integral which I can't find using elementary methods.

Is there a way I could do it with my original method or using a series + the Alternating series estimation theorem? Help would be appreciated. Thank you very much.

EDIT: Corrected to account for the $$t^2$$ for the maclaurin series of cosine.

• It seems that you expanded $\cos(t)$ instead of $\cos(t^2)$. Also, you can write $$\sum_n a_n+\sum_n b_n =\sum_n (a_n+b_n)$$ – Maximilian Janisch Feb 27 at 7:04
• Oops. You're right... Sure. I can do that but even if I combine the sums, don't I have to match the $x$ coefficents? – Future Math person Feb 27 at 7:06
• I just corrected my mistake. – Future Math person Feb 27 at 7:18
• You don’t have to, and it might also be tricky since the first sum has the powers $x,x^5,x^9,\dots$ and the second sum has the powers $x^3,x^7,x^{11},\dots$ – Maximilian Janisch Feb 27 at 7:57
• Okay but in that case, without know the exact value of the integral, how can I make sure the error is less than what I want? – Future Math person Feb 28 at 2:29

Since they are each alternating series and eventually the terms are decreasing you can use the alternating series rule on each one. If you make your error criteria on each series to be half the desired error, then the overall error when you combine the two will be what you want.

• Ohh cool. I didn't know you could just do half the error. Thanks! – Future Math person Feb 28 at 6:07

It could be easier to use the fundamental theorem of calculus $$F(x) = \int_{0}^{x} (1+t^2)\cos(t^2)\,dt \implies F'(x)=(1+x^2)\cos(x^2)$$ Now, let $$y=x^2$$ and you should arrive at $$F'(x)=1+\sum_{n=1}^\infty\frac{n \sin \left(\frac{\pi n}{2}\right)+\cos \left(\frac{\pi n}{2}\right)}{n!} x^{2n}$$ and integrating termwise $$F(x)=x+\sum_{n=1}^\infty\frac{n \sin \left(\frac{\pi n}{2}\right)+\cos \left(\frac{\pi n}{2}\right)}{(2n+1)n!} x^{2n+1}$$ This is an alernating series. So, if you write $$F(x)=x+\sum_{n=1}^{p-1}\frac{n \sin \left(\frac{\pi n}{2}\right)+\cos \left(\frac{\pi n}{2}\right)}{(2n+1)n!} x^{2n+1}+\sum_{n=p}^\infty\frac{n \sin \left(\frac{\pi n}{2}\right)+\cos \left(\frac{\pi n}{2}\right)}{(2n+1)n!} x^{2n+1}$$ The first neglected term is $$R_p=\frac{p \sin \left(\frac{\pi p}{2}\right)+\cos \left(\frac{\pi p}{2}\right)}{(2p+1)p!} x^{2p+1}$$ which makes $$R_{2p}=\frac{x^{4 p+1}}{(4 p+1) (2 p)!}\sim \frac{x^{4 p+1}}{2 (2 p+1)!} \qquad\text{and}\qquad R_{2p+1}=\frac{x^{4 p+3}}{(4 p+3) (2p)!}\sim \frac{x^{4 p+3}}{2 (2 p+1)!}$$

So, depending on the value of $$x$$ we need to solve either $$(2p+1)!=\frac 1{2x} (x^2)^{(2p+1)} 10^k\qquad\text{or}\qquad (2p+1)!=\frac x{2} (x^2)^{(2p+1)} 10^k$$ in order to have $$R \leq 10^{-k}$$.

Have a look at this question of mine; you will find a magnificent approximation provided by @robjohn, an eminent user on this site. Adapted to your problem, this would give $$2p+1 \sim e x^2 \exp\Big[{W\left(2 \log \left(\frac{10^k}{8 \pi x^3}\right)\right) }\Big]-\frac 12$$ $$2p+1 \sim e x^2 \exp\Big[{W\left(2 \log \left(\frac{10^k}{8 \pi x}\right)\right) }\Big]-\frac 12$$ where $$W(.)$$ is Lambert function.

Applied to $$x=1$$ and $$k=3$$, both formulae will give $$p=5.68784$$, that is to say $$p=6$$.

• How did you get $\displaystyle F'(x)=1+\sum_{n=1}^\infty\frac{n \sin \left(\frac{\pi n}{2}\right)+\cos \left(\frac{\pi n}{2}\right)}{n!} x^{2n}$? – Future Math person Feb 28 at 2:28