Simpson Rule
Simpson Rule
f[x_] = 1 + x;
lowlimit = a = 0;
upplimit = b = 1;
fa = f[a];
fb = f[b];
h = (b - a) 2;
c = h * fa + 4 f[a + h] + fb 3;
Print"(Simpson rule)integral = ", c;
3
(Simpson rule)integral =
2
In[112]:=
Print"The area approximated value by Simpson rule is ", N[c]
Print"Original value of integral is ", N[int], " and the error is ", N[c] - N[int];
f[x_] = 1 + x;
lowlimit = a = 1;
upplimit = b = 2;
fa = f[a];
fb = f[b];
int = Integrate[f[x], {x, a, b}];
h = (b - a) 2;
c = h * fa + 4 f[a + h] + fb 3;
Print"(Simpson rule)integral = ", c;
Print"The area approximated value by Simpson rule is ", N[c]
Print"Original value of integral is ", N[int], " and the error is ", N[c] - N[int];
2
5
(Simpson rule)integral =
2
The area approximated value by Simpson rule is 2.5
Original value of integral is 2.5 and the error is 0.
In[133]:=
Print"The area approximated value by Simpson rule is ", N[c]
Print"Original value of integral is ", N[int], " and the error is ", N[c] - N[int];
In[152]:=
Print"The area approximated value by Simpson rule is ", N[c]
Print"Original value of integral is ", N[int], " and the error is ", N[c] - N[int];
f[x_] = 1 + x;
lowlimit = a = 0;
upplimit = b = 1;
fa = f[a];
fb = f[b];
h = (b - a) 3;
c = 3 h fa + 3 f[a + h] + 3 fa + 2 h + fb 8;
Print"integral = ", c;
3
integral =
2