Example 2.  Use Romberg integration to compute a numerical approximation to the integral  [Graphics:Images/RombergMod_gr_74.gif].  
Use the tolerances [Graphics:Images/RombergMod_gr_75.gif].  Compare with the analytic or "true value" of the integral.

Solution 2.

[Graphics:../Images/RombergMod_gr_76.gif]
[Graphics:../Images/RombergMod_gr_77.gif]

2 (a). Plot the function over the interval  [0, 2].

[Graphics:../Images/RombergMod_gr_78.gif]

[Graphics:../Images/RombergMod_gr_79.gif]

[Graphics:../Images/RombergMod_gr_80.gif]

2 (b). Construct the Romberg table using   tol = 0.001
What do the entries in the first column mean ?
What do the entries in the second column mean ?
Which entries in the table are used to determine if Romberg integration is converging ?

[Graphics:../Images/RombergMod_gr_81.gif]


[Graphics:../Images/RombergMod_gr_82.gif]
[Graphics:../Images/RombergMod_gr_83.gif]
[Graphics:../Images/RombergMod_gr_84.gif]
[Graphics:../Images/RombergMod_gr_85.gif]
[Graphics:../Images/RombergMod_gr_86.gif]
[Graphics:../Images/RombergMod_gr_87.gif]
[Graphics:../Images/RombergMod_gr_88.gif]

2 (c). The last entry in the table is  [Graphics:../Images/RombergMod_gr_89.gif].  Let's find it.
    (This is possible because  j  is a global variable in the subroutine.)

[Graphics:../Images/RombergMod_gr_90.gif]


[Graphics:../Images/RombergMod_gr_91.gif]
[Graphics:../Images/RombergMod_gr_92.gif]

2 (d). Look at 10 digits in  [Graphics:../Images/RombergMod_gr_93.gif].

[Graphics:../Images/RombergMod_gr_94.gif]


[Graphics:../Images/RombergMod_gr_95.gif]

2 (e). Are all 10 digits correct ?   Why ?  
Be sure to support your answer to this question !
NO.  The subroutine was called with the accuracy  [Graphics:../Images/RombergMod_gr_96.gif].  

 

2 (f). Determine how to call the Romberg integration subroutine so that it will achieve 10 digits of accuracy.   
You will need to experiment to find the solution.  Do it !
Report the answer with 10 digits of accuracy.
How many function evaluations were required to achieve this answer ?

We suspect the following answer might have 10 digits of accuracy.

[Graphics:../Images/RombergMod_gr_97.gif]


[Graphics:../Images/RombergMod_gr_98.gif]
[Graphics:../Images/RombergMod_gr_99.gif]
[Graphics:../Images/RombergMod_gr_100.gif]
[Graphics:../Images/RombergMod_gr_101.gif]
[Graphics:../Images/RombergMod_gr_102.gif]
[Graphics:../Images/RombergMod_gr_103.gif]
[Graphics:../Images/RombergMod_gr_104.gif]
[Graphics:../Images/RombergMod_gr_105.gif]
[Graphics:../Images/RombergMod_gr_106.gif]
[Graphics:../Images/RombergMod_gr_107.gif]

Since the last row was row 8, the sequential trapezoidal rule used the following number of function calls.

[Graphics:../Images/RombergMod_gr_108.gif]


[Graphics:../Images/RombergMod_gr_109.gif]

2 (g). Use Mathematica to find the analytic solution to the integral, i.e. the "true value" of the integral.

[Graphics:../Images/RombergMod_gr_110.gif]


[Graphics:../Images/RombergMod_gr_111.gif]
[Graphics:../Images/RombergMod_gr_112.gif]
[Graphics:../Images/RombergMod_gr_113.gif]
[Graphics:../Images/RombergMod_gr_114.gif]
[Graphics:../Images/RombergMod_gr_115.gif]
[Graphics:../Images/RombergMod_gr_116.gif]
[Graphics:../Images/RombergMod_gr_117.gif]
[Graphics:../Images/RombergMod_gr_118.gif]

2 (h). How close did our last numerical approximation using Romberg integration come to the "true value" of the integral.

[Graphics:../Images/RombergMod_gr_119.gif]


[Graphics:../Images/RombergMod_gr_120.gif]
[Graphics:../Images/RombergMod_gr_121.gif]


[Graphics:../Images/RombergMod_gr_122.gif]

[Graphics:../Images/RombergMod_gr_123.gif]

[Graphics:../Images/RombergMod_gr_124.gif]
[Graphics:../Images/RombergMod_gr_125.gif]
[Graphics:../Images/RombergMod_gr_126.gif]

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

(c) John H. Mathews 2004