Graphics Programs Reference
In-Depth Information
Using the extrapolation formulas in Eqs. (6.13), wecan now construct the following
table:
=
R 1 , 1
R 2 , 1 R 2 , 2
R 3 , 1 R 3 . 2 R 3 , 3
R 4 , 1 R 4 , 2 R 4 , 3 R 4 , 4
0
1
.
57082
.
0944
.
.
.
1
8961 2
00461
9986
1
.
97422
.
00032
.
0000 2
.
0000
It appearsthat the procedurehasconverged. Therefore, 0
sin x dx
=
R 4 , 4 =
2
.
0000,
which is, of course, the correct result.
EXAMPLE 6.7
Use Romberg integration to evaluate π
0
2 x 2 cos x 2 dx and compare the results with
Example 6.4.
Solution
>> format long
>> [Integral,numEval] = romberg(@fex6
_
7,0,sqrt(pi))
Integral =
-0.89483146948416
numEval =
257
>>
Here the M-file defining the function to be integratedis
functiony=fex6
7(x)
% Function used in Example 6.7
y = 2*(xˆ2)*cos(xˆ2);
_
It is clear that Romberg integrationisconsiderablymoreefficientthan the trape-
zoidal rule. It required 257 function evaluations ascompared to 4097 evaluations with
the composite trapezoidal rule in Example 6.4.
PROBLEM SET 6.1
Use the recursivetrapezoidal rule to evaluate π/ 4
0
1.
ln(1
+
tan x ) dx
.
Explain the
results.
2.
The table shows the power P supplied to the driving wheels of a car as a function
of the speed v . If the mass of the car is m
=
t it
takes for the car to accelerate from1m/s to 6m/s. Use the trapezoidal rule for
2000 kg, determine the time
Search WWH ::




Custom Search