ALGORITHM OF TRAPEZOIDAL RULE
Step 01.Start of the program.
Step 02.Input Lower limit a
Step 03.Input Upper Limit b
Step 04.Input number of sub intervals n
Step 05.h=(b-a)/n
Step 06.sum=0
Step 07.sum=fun(a)+fun(b)
Step 08.for i=1; i<n; i++
Step 09.sum +=2*fun(a+i)
Step 10.End Loop i
Step 11.result =sum*h/2;
Step 12.Print Output result
Step 13.End of Program
Step 14.Start of Section fun
Step 15.temp = 1/(1+(x*x))
Step 16.Return temp
Step 17.End of Section fun.
ALGORITHM OF SIMPSON’S 3/8th RULE
Step 01.Start of the program.
Step 02.Input Lower limit a
Step 03.Input Upper limit b
Step 04.Input number of sub itervals n
Step 05.h = (b – a)/n
Step 06.sum = 0
Step 07.sum = fun(a) + fun (b)
Step 08.for i = 1; i < n; i++
Step 09.if i%3=0:
Step 10.sum + = 2*fun(a + i*h)
Step 11.else:
Step 12.sum + = 3*fun(a+(i)*h)
Step 13.End of loop i
Step 14.result = sum*3*h/8
Step 15.Print Output result
Step 16.End of Program
Step 17.Start of Section fun
Step 18.temp = 1/(1+(x*x))
Step 19.Return temp
Step 20.End of section fun
ALGORITHM OF SIMPSON’S 1/3rd RULE
Step 01.Start of the program.
Step 02.Input Lower limit a
Step 03.Input Upper limit b
Step 04.Input number of subintervals n
Step 05.h=(b–a)/n
Step 06.sum=0
Step 07.sum=fun(a)+4*fun(a+h)+fun(b)
Step 08.for i=3; i<n; i + = 2
Step 09.sum + = 2*fun(a+(i – 1)*h) + 4*fun(a+i*h)
Step 10.End of loop i
Step 11.result=sum*h/3
Step 12.Print Output result
Step 13.End of Program
Step 14.Start of Section fun
Step 15.temp = 1/(1+(x*x))
Step 16.Return temp
Step 17.End of Section fun
Переглядів: 168 |