INPUT endpoints a,
b; even positive integer n
OUTPUT approximate XI
to I
Step 1 Set h = (b-a)/n
Step 2 Set XI0 = f(a) + f(b);
XI1 = 0; XI2 = 0;
Step 3
For i = 1, ..., n-1 do Steps 4 and 5.
Step 4 Set X = a + i h.
Step 5 If i is even then
set XI2 = XI2 + f(x) else set XI1
= XI1 + f(x).
Step 6 Set
XI = h(XI0+2*XI2+4*XI1)/3
Step 7 Ouput(XI)
Stop
Problem: Using above algorithm to compute
Requirement:
(a) Read the datas
a, b,
and n from the file input_parameter.dat
(b) Use the command function to define f(x)
and the command subroutine
to implement the algorthm.
(c) Use double precision
for real number to compute the result.