# Finding the area under the curve $x^{1/2} \sin x$ between $x=2$ to $x=10$

This question is with reference to my previously asked question. Which is the best way to find the area under the curve $x^{1/2}\sin{x}$ between $x=2$ to $x=10$ to the most accurate numerical value?

• You can make a series expansion for the function and integrate term by term, and then sum up the first 10 to 20 terms would give you a good approximation. Mathematicians used to do so but now you can have it done with professional software. – ZTransformer Jan 2 '16 at 23:47
• @Quark: Which numerical methods have you learned? – Moo Jan 3 '16 at 0:25
• Elementary Calculus and Series @Variable It would be a nice but tough way to try it using limits though. – Quark Jan 3 '16 at 1:48

## 3 Answers

We can use Composite Simpson's Rule as follows

• $x_1 = 2$
• $x_2 = 10$
• $h = \dfrac{x_2 - x_1}{2 \times 80} = \dfrac{10 - 2}{160} = \dfrac{1}{20}$

We are using Composite Simpson's Rule to approximate:

$\displaystyle \int_{x_1}^{x_2} f(x) ~dx \approx \int_{2}^{10} x^{1/2} \sin x~ dx$

A plot shows This yields:

$$\int_{2}^{10} x^{1/2} \sin x dx \approx \dfrac{1}{3} h (f(x_1)+2 \sum_{n=1}^{80-1} f(2 h n+x_1) + 4 \sum_{n=1}^{80} f(h (-1+2 n)+x_1)+f(x_2))$$

The result is:

$$\int_{2}^{10} x^{1/2} \sin x ~dx \approx 1.66839$$

For comparison, using a high-precision Computer Algebra System, we get:

$$\int_{2}^{10} x^{1/2} \sin x~ dx \approx 1.6683852341038987$$

You can see more examples to practice the various methods as there are many numerical methods that will do these calculations just fine.

There is another way : compute first the antiderivative $$I=\int \sqrt{x} \sin (x)\,dx$$ Integrate by parts using $u=\sqrt{x}$, $dv=\sin (x)\,dx$. This gives $$I=-\sqrt{x} \cos (x)+\int \frac{\cos (x)}{2 \sqrt{x}}\,dx$$ For the remaining integral change variable $x=y^2$ which makes $$\int \frac{\cos (x)}{2 \sqrt{x}}\,dx=\int \cos(y^2)\,dy=\sqrt{\frac{\pi }{2}} C\left(\sqrt{\frac{2}{\pi }} y\right)$$ where appears the Fresnel integral.

So, back to $x$ $$I=\int \sqrt{x} \sin (x)\,dx=\sqrt{\frac{\pi }{2}} C\left(\sqrt{\frac{2x}{\pi }} \right)-\sqrt{x} \cos (x)$$ and the problem is now the evaluation of the Fresnel integral if you do not have any access to it.

In the Wikipedia page, they give the following power series expansions that converge (quite fast) for all $t$ $$C(t)=\sum_{n=0}^\infty (-1)^n \frac{t^{4n+1}}{(4n+1)(2n)!}$$ (take care : they do not use exactly the same definition of the argument).

So, for the problem $$J=\int_2^{10}\sqrt{x} \sin (x)\,dx=\sqrt{2} \cos (2)-\sqrt{10} \cos (10)+\sqrt{\frac{\pi }{2}} \left(C\left( \sqrt{\frac{20}{\pi }}\right)-C\left( \sqrt{\frac{4}{\pi }}\right)\right)$$

Using $20$ terms will give accurate results.

Using an adaptive Gaussian quadrature, we obtain the result to be $1.6683852341039$ to a relative accuracy of $10^{-15}$. Below are the details of the AGQ,

Quadrature is: $1.6683852341039$

Total number of panels: $9$

Total number of nodes: $324$

Number of levels of adaptivity: $6$

Time taken: $3.4 \times 10^{-05}$ seconds