You are on page 1of 2

TRAPEZOIDAL RULE :

ClearAlln, a, b, f

In[16]:= a  0Enter the lower Limit ;


b  5Enter the upper Limit;
n  5Enter the number of sub intervals to be formed 
h  b  a  n;
Print"Value of h  ", h
k  Tablea  i h, i, 1, n;
sum  0;
fx  1  2  x ^ 2
For i  1, i  n, i , sum  2  fx . x  ki;
Trp  Nh  2  sum  fx . x  a  fx . x  b;
Print"For n  ", n, " Equal Parts", ", Trapezoidal Approximation is : ", Trp
in  Integrate1  2  x ^ 2, x, 0, 5;
Print"Integration of given function from ", a , " to ", b , "  ", in
Print"True value is ", in , "  ", Nin
Print"Absolute error is Trapezoidal ApproximationTrue Value  ", AbsTrp  in

Out[18]= 5

Value of h  1

1
Out[23]=
2  x2
For n  5 Equal Parts, Trapezoidal Approximation is : 0.914983


5
ArcTan
2
Integration of given function from 0 to 5 
2


5
ArcTan
2
True value is  0.915812
2
Absolute error is Trapezoidal ApproximationTrue Value  0.000828677

Evaluate by Simpson Method and


Compare with the actual Value
2 Practical 7(a),Trapezoidal INT Method.nb

0.6
2
a ex  x, h  0.1
0

6 1
b  x, n  6
2
0 1x

1 x2
c  x, h  0.25
3
0 1x

d. sin x  x, n  11
0
6 ex
e.  x, n  12
0 1x

You might also like