2

I was working on some integral problems, and stuck with this one. $$ \int_0^2 \sin(x^2)dx=\,\boldsymbol ? $$ When I searched the internet it turned out that the integral is not elementary and cannot be expressed with the usual mathematical question but instead is denoted as $S(x)$, but I wanted to get the approximation of it. I saw the graph of $\sin(x^2)$, and thought it is possible to get the approximation if it is between $x=0$ and $x=2$. How can I numerically approximate the value of this integral?

I thought of Taylor series, but I was not used to it, and could not apply it.

J. W. Tanner
  • 63,683
  • 4
  • 43
  • 88

2 Answers2

5

Note: I feel the question is ultimately too vague to have a "proper" answer, but this is definitely too long for a comment.


Ultimately, it just really depends. Taylor series would be the go-to, just because of how often these series crop up and how easy integrating polynomials is, if you want a quick-and-dirty brute-forcing type of approach. Here, $$ \sin x^2 = \sum_{n=0}^\infty \frac{(-1)^n x^{4n+2}}{(2n+1)!} $$ Integrating polynomials is easy, and for Taylor series you can interchange integrals and sums just fine within the radius of convergence. So $$\begin{align*} \int_0^2 \sin x^2 \, \mathrm{d}x &= \int_0^2 \sum_{n=0}^\infty \frac{(-1)^n x^{4n+2}}{(2n+1)!} \, \mathrm{d}x\\ &= \sum_{n=0}^\infty \int_0^2 \frac{(-1)^n x^{4n+2}}{(2n+1)!} \, \mathrm{d}x\\ &= \sum_{n=0}^\infty \frac{(-1)^n }{(2n+1)!} \int_0^2 x^{4n+2}\, \mathrm{d}x\\ &= \sum_{n=0}^\infty \frac{(-1)^n }{(2n+1)!} \frac{1}{4n+3} 2^{4n+3} \end{align*}$$ To finish, then, you would examine $$ \sum_{n=0}^N \frac{(-1)^n }{(2n+1)!} \frac{1}{4n+3} 2^{4n+3} $$ for $N$ sufficiently large; what constitutes "sufficiently large" depends on how good of an approximation you need. For some small $N$,

enter image description here

(This table, of course, assumes you know the exact value outright, but is more of a means to show the convergence rate. If you have conditions like "$n$ digits of precision," or "error less than $x$ amount", then you will have to do further analysis, e.g. like here.)

That said, other estimation methods and concerns might arise in other contexts, e.g. speed of convergence. Some of the more basic ones can be found here (midpoint, trapezoid, & Simpson's rules), which work by approximating the function to-be-integrated by constant, linear, and quadratic functions respectively. There is also a Simpson's second rule which uses interpolation by cubics (Wikipedia), and more generally the Newton-Cotes rules (Wikipedia), just to get you started. Taylor's theorem may also be of interest.

PrincessEev
  • 50,606
5

Starting from @PrincessEev's solution, writing

$$\sum_{n=0}^N \frac{(-1)^n }{(2n+1)!} \frac{2^{4n+3}}{4n+3} $$ you want to know what is $N$ such then $$\frac{2^{4 N+7}}{(4 N+7) \ (2N+3)!}\leq 10^{-k}$$ that is to say $$(4 N+7) \ (2N+3)! \geq 2^{4 N+7} \, 10^k$$ For a very first approximation, take logarithms and use Stirling approximation $$2 N (\log (N)-1+\log (2))\geq (4N+7)\log(2)+\log(10^k)$$ that is to say $$2 N \log (N)-2 N (1+\log (2)) \geq 7\log(2)+\log(10^k)$$ which has an explicit solution in terms of Lambert function $$N \geq \frac{\log \left(10^k\right)+7 \log (2)}{2 W\left(\frac{\log \left(10^k\right)+7 \log (2)}{4 e}\right)}$$

If you want $k=15$, $N>17.1466$ so $N=18$.

Notice that the "exact" solution is $N=13.0246$ so $N=14$.

Edit

We can do much better writing $$(4 N+7) \ (2N+3)! \geq 2^{4 N+7} \, 10^k$$ $$ (2N+4)! \geq 4^{2N+4}\,\frac {10^k} 4$$ and have a look at this old question of mine and mainly at @]robjohn's answer (one of our moderators).

Applied to your case, this would give $$2N+4=4 e \,e^{W(t)}-\frac 12 \qquad t=\frac{2 \log \left(\frac{10^k}{4}\right)-\log (8\pi )}{8 e}$$ that is to say $$N \sim 2 \,e^{1+W(t)}-\frac 94=13.0201$$ so $N=14$