# Evaluating the definite integral $\int_{0}^{\pi/2} x^{1/2} \cos x \, dx$

I am having trouble integrating

\begin{aligned}
\ \int_{0}^{\pi/2} x^{1/2} \cos x\, dx \end{aligned}

I see I can use the Trapezoidal or Simpson's Rule to approximate the integral, but when I used the Trapezoidal Rule, I got .6366 for n=4. I understand there should be some margin of error because I am only using 4 trapezoids, but the real answer is .7040 according to Wolfram. It seems my answer is a bit beyond what I expected - I thought I would be closer to the .7040 value.

When I used Simpson's Rule, I got .6847 when n=4.

Edit: I resolved my own error - it was a simple button punching error (I made it for Simpon's Rule and Trapezoidal Rule - twice (I did the problem over again, too)).

-
If anyone could fix my title, that would be nice. I'm not sure where I made a formatting error. –  Joe Feb 21 '12 at 0:47
$n = 4$ isn't enough because the integrand changes quickly near $x = 0$. You need to subdivide more finely near $x = 0$ to capture this. –  Qiaochu Yuan Feb 21 '12 at 0:49
Thanks for the title fix David Mitra. –  Joe Feb 21 '12 at 0:55
I resolved my own error - it was a simple button punching error (I made it for Simpon's Rule and Trapezoidal Rule - twice (I did the problem over again, too)). –  Joe Feb 21 '12 at 1:06
@Jay Electronics: To add to the comment by Qiaochu Yuan, many numerical integration packages use more points where the function is changing most rapidly (adaptive integration). –  André Nicolas Feb 21 '12 at 1:35

It can be expressed in "closed form" as $\sqrt{\pi/2}(1 - \text{FresnelS}(1))$ or $$\sqrt{\frac{\pi}{2}} \left(1-\frac{\pi}{6} \ {\mbox{_1F_2}\left(\frac34;\frac32,\frac74;-\frac{\pi^2}{16}\right)}\right)$$

-

You should get a good approximation with

$${x^{1/2}}\cos x \sim {x^{1/2}}\left( {1 - \frac{{{x^2}}}{{2!}} + \frac{{{x^4}}}{{4!}}} \right)$$

since for $x\in(0,\pi)$ the error of the polynomial is at most $0.025$ .

This gives

\eqalign{ & \int\limits_0^{\frac{\pi }{2}} {{x^{1/2}}\left( {1 - \frac{{{x^2}}}{{2!}} + \frac{{{x^4}}}{{4!}}} \right)} dx = \int\limits_0^{\frac{\pi }{2}} {\left( {{x^{1/2}} - \frac{{{x^{5/2}}}}{{2!}} + \frac{{{x^{9/2}}}}{{4!}}} \right)} dx = \cr & \left[ {\frac{2}{3}{x^{3/2}} - \frac{1}{7}{x^{7/2}} + \frac{1}{{12}}\frac{{{x^{11/2}}}}{{11}}} \right]_0^{\frac{\pi }{2}} \approx 0.709328026752218 \cr}

If you include the next term in the Taylor polynomial (the error is at most $0.0011$) you get $0.703851503882453$ which is quite enough.

-