1

Calculate $\int_{0}^{1} \sin(x^2)$ with an error $\le 10^{-3}$

Let $f(x)= \sin(x^2) $ continuous in [0,1] so by the MVT for integrals we know $\int_{0}^{1} \sin(x^2) = \sin(c^2) \; \text{for} \; c \in [0,1]$. I don't really know if this is of any help. Another thing that I know is that $\int_{0}^{1} \sin(x^2) \le \int_{0}^{1} x^2 \; \text{for} \; x \in [0,1]$. Any hints on how to resolve this ? Thanks in advance.

Just_A_User
  • 2,126
Augusto
  • 563
  • 3
    Use the Taylor series. – Jochen Aug 05 '20 at 21:06
  • Error estimation of an alternating series is really cool... – imranfat Aug 05 '20 at 21:09
  • The observation about the MVT is not of any help. You should replace $\sin(x^2)$ with its Maclaurin series. Then bring the integration into the summation. Then you will have an infinite series (no longer a power series). And you can approximate its value by taking a partial sum. How many terms you include affects how good the approximation is, and you can use standard features of an alternating series to know how many terms to include. – 2'5 9'2 Aug 05 '20 at 21:13
  • @alex.jordan I'll try that. Thanks – Augusto Aug 05 '20 at 21:15

3 Answers3

2

Using the Taylor series representation of the sine function we have

$$\begin{align} \int_0^1 \sin(x^2)\,dx&=\lim_{N\to\infty}\sum_{n=1}^N \frac{(-1)^{n-1}}{(4n-1)(2n-1)!}\\\\&=\sum_{n=1}^N \frac{(-1)^{n-1}}{(4n-1)(2n-1)!}+E_N \end{align}$$

Inasmuch as this is an alternative series, we would like to choose $N$ such that $E_N<0.001$ or

$$(4N+3)(2N+1)!>1,000$$

For $N=2$, we have $(4N+3)(2N+1)!=1,320$

Hence, we find that

$$\left|\int_0^1 \sin(x^2)\,dx-\left(\frac13-\frac1{42}\right)\right|=\left|\int_0^1 \sin(x^2)\,dx-\left(\frac{13}{42}\right)\right|<0.001$$

Mark Viola
  • 179,405
  • @karl Please let me know how I can improve my answer. I really want to give you the best answer I can. – Mark Viola Aug 05 '20 at 21:27
  • I find it useful. Thanks. The only problem I'm finding(not with your answer but overall) is that using wolfram alpha the integral converges to a very different approximation. Thanks – Augusto Aug 06 '20 at 00:18
  • HERE is output from Wolfram Alpha. It agrees with the estimate within the 0.001 error. It gives a result equal to roughly 0.310268. – Mark Viola Aug 06 '20 at 00:29
  • You are right. I was calculating $\sum_{n=1}^2 (-1)^{n-1} a_{n+1}$ and not $\sum_{n=1}^2 (-1)^{n-1} a_{n}$ like i should, that was the problem. Thanks for taking the time to help me. – Augusto Aug 06 '20 at 01:20
  • And feel free to up vote an answer as you see fit. – Mark Viola Aug 06 '20 at 01:26
  • Hi Mark ! If you enjoy approximations and have time to waste, have a look at my answer. Cheers and take care. – Claude Leibovici Aug 06 '20 at 04:51
  • @karl And feel free to up vote an answer as you see fit. – Mark Viola Aug 21 '20 at 16:09
0

Use the Maclaurin series for $\;\sin x^2\;$, which converges absolutely at every point and thus you can integrate/differentiate it termwise:

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

$$\int_0^1\left(\sum_{n=0}^\infty\frac{(-1)^n x^{4n+2}}{(2n+1)!}\right)dx=\sum_{n=0}^\infty\frac{(-1)^n}{(2n+1)!}\int_0^1 x^{4n+2}dx=\sum_{n=0}^\infty\frac{(-1)^n}{(2n+1)!}\cdot\frac1{4n+3}$$

The above is a Leibniz series and we can estimate its value in a reasonably easy way:Leibniz theorem telss us that if $\;S\;$ is the series sum and $\;S_n\;$ the $\;n\,$- th term of its partial sums sequence, and $\;a_n\;$ is its general term sequence, then

$$|S-S_n|<|a_{n+1}|=\frac1{(2n+3)!(4n+7)}\stackrel{\text{we want!}}<\frac1{1000}$$

Well, you can now even try a very few times and get the correct value of $\;n\;$

DonAntonio
  • 211,718
  • 17
  • 136
  • 287
  • Hi Don Antonio my friend! I hope that you are staying safe and healthy. – Mark Viola Aug 05 '20 at 21:20
  • @MarkViola Hi there, my good friend. We're doing fine so far, though my brother, wife and mother in law got the virus...But they're fine now. What's with you, anyway? – DonAntonio Aug 05 '20 at 21:21
  • I'm sorry to hear about your family members, but pleased that they are OK! My wife and I are doing well and following the guidelines of the CDC The WHO--"We won't get fooled again." – Mark Viola Aug 05 '20 at 21:22
  • Good to know you'redoing fine. It's been a tough time, plans to travel and visit family went down the tubes....but hey! We've Zoom, at least. – DonAntonio Aug 05 '20 at 21:24
  • Indeed. Imagine if this pandemic occurred 30 years ago. – Mark Viola Aug 05 '20 at 21:25
  • That'd be way worse! I'm a lecturer in an ingeneering college here and I would ve out of work without Zoom...But at least in that we were lucky. Thanks for asking and take care! – DonAntonio Aug 05 '20 at 21:28
  • You're welcome. And you also. – Mark Viola Aug 05 '20 at 21:28
0

In the same spirit as the other answers but making the problem more general, consider $$I=\int_0^t \sin(x^2)\,dx= \sum_{n=0}^\infty\frac{(-1)^n}{(2n+1)!}\int_0^t x^{4n+2}dx=\sum_{n=0}^\infty\frac{(-1)^n}{(2n+1)!}\,\frac{t^{4n+3}}{4n+3}$$ Writing $$I=\sum_{n=0}^p\frac{(-1)^n}{(2n+1)!}\,\frac{t^{4n+3}}{4n+3}+\sum_{n=p+1}^\infty\frac{(-1)^n}{(2n+1)!}\,\frac{t^{4n+3}}{4n+3}$$ you then want to know the value of $p$ such that $$\frac {t^{4p+7}}{(2p+3)!\,(4p+7)} \leq 10^{-k}$$ that is to say $$(2p+3)!\,(4p+7) \geq t^{4p+7}\,10^{k}\tag 1$$ To simplify the problem we shall approximate the lhs $\big[(4p+7\sim 4p+8=2(2p+4)\big]$and rewrite $(1)$ as $$ (2p+4)! \geq \left(t^2\right)^{2 p+4}\frac{10^k} {2t}\tag 2$$ If you look at this question of mine, you will see a magnificent approximation by @robjohn. Applied to your problem, this will give $$\color{blue}{p \sim \frac 12 t^2\, e^{1+W(u)}-\frac 94} \qquad \text{where} \qquad \color{blue}{u=\frac 1{e\,t^2}\,\log \left(\frac{10^k}{2 t^2\sqrt{2 \pi } }\right)}\tag3$$ where $W(.)$ is Lambert function. For sure, after computing $p$ as a real, you will need to take $\lceil p\rceil$.

Applied to your case $t=1$ and $k=3$, this gives $p=0.90006$ then $p=1$.

Satrting from @DonAntonio's last equation (copy/paste)

$$|S-S_n|<|a_{n+1}|=\frac1{(2n+3)!(4n+7)}\stackrel{\text{we want!}}<\frac1{1000}$$ the exact solution would be $n=0.92604$. Checking with $n=1$ $$\frac1{5!11}=\frac 1{1320}$$

But now, suppose that you want a very high accuracy such as $k=20$ : using $(3)$, you would find $p=8.49617$ then $p=9$. The exact result for @DonAntonio's last equation would be $8.50041$.