2
$\begingroup$

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.

Wolfram Link: http://www.wolframalpha.com/input/?i=integrate+sqrt%28x%29+cos+x+dx+from+0+to+pi%2F2

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)).

  • 0
    @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).2012-02-21

2 Answers 2

4

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{$_1$F$_2$}\left(\frac34;\frac32,\frac74;-\frac{\pi^2}{16}\right)}\right)$

3

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.