up

HW4 solution. MAE 185. Spring 2006

All blames to Nasser Abbasi

June 24, 2013

1 Problem

Integrate the following using Romberg integration

∫1       ∫1       ∫1             ∫10         ∫1          ∫5
  ex2dx,    xxdx,    sin (50 x) dx,   ln (x )dx,   √1-ex2dx,    (x-21)0.2dx
                                                 x          x +1
0        0        0              0           0           1

2 Answer

An important part is to select a tolerance which can be used to stop the Romberg iteration. This is the tolerance shown in the pseudocode on page 212 with the letter ϵ  .

The source code is attached at the end, and the output.txt (in which the Romberg table is also printed for each problem).

The following is the Fortran source code to solve this HW. ??

The following is the output from running the program. ??

2.1 Problem 1

∫1
  ex2dx
0

No preprocessing needed. Use Romberg integration on the integral as shown.

The answer is 1.4626517459

2.2 Problem 2

 1
∫  x
  x dx
0

No preprocessing needed. Use Romberg integration on the integral as shown.

The answer is 0.7834305142

2.3 Problem 3

∫1
   sin (50 x) dx
 0

No preprocessing needed. Use Romberg integration on the integral as shown. Just make sure the tolerance is small enough. Use a multiple of machine double precision limit.

The answer is 0.0007006794

2.4 Problem 4

 10
∫
   ln (x )dx
0

To handle the singularity at x = 0  we can either integrate from some very small ϵ > 0  or use integration by parts to change the integrand to something without singularity.

Using integration by parts. ∫ udv = uv - ∫ vdu  hence let u = ln (x )  and dv = dx  . Hence du =  1dx
      x    and v = x.

∫10                            ∫10 ( 1   )                 1∫0
  (ln(x) × 1) dx = [x ln(x)]100-   x  -dx   = [10 × ln(10)]-   dx
0                              0    x                     0

So the integral becomes

          ∫10
23.02585-   dx
          0

(Clearly we do not need to do numerical integration now, since the answer is 13.02585  by just looking at the above, but we need to use Romberg integration, so our integrand here is 1  )

The answer is 13.0258509299

2.5 Problem 5

∫1
  √1-ex2dx
    x
0

To handle the singularity at x = 0  we can either integrate from some very small ϵ > 0  or use integration by parts to change the integrand to something without singularity.

Using integration by parts. ∫ udv = uv - ∫ vdu  hence let u = ex2   and dv = √1-dx
       x  . Hence du = 2xex2dx    and     ∫ - 12      √ --
v =  x   dx = 2  x

Hence

pict

And we apply Romberg integration on the second part above.

The answer is 2.5425742098

2.6 Problem 6

∫5(x- 1)0.2
  --2-----dx
1  x  + 1

No preprocessing needed. Use Romberg integration on the integral as shown.

The answer is 0.5613773544

3 Appendix

PIC

4 Output

PIC