You are on page 1of 1

◼ TRapezoidal Rule

In[339]:=

f[x_] := 1 / (1 + x)
a = 0.0;
b = 1.0;
h = b - a;
AprInt = (h / 2) * (f[a] + f[b])
ExactInt = Integrate[f[x], {x, 0.0, 1.0}]
Err = Abs[ExactInt - AprInt]
Out[343]=

0.75
Out[344]=

0.693147
Out[345]=

0.0568528

In[353]:=

f[x_] := 1 / (x ^ 2 - 1)
a = 2.0;
b = 3.0;
h = b - a;
AprxInt1 = (h / 2) * (f[a] + f[b])
ExactInt1 = Integrate[f[x], {x, 0.0, 1.0}]
Err1 = Abs[ExactInt1 - AprxInt1]
Out[357]=

0.229167
Out[358]=

0.693147
Out[359]=

0.463981

You might also like