Simpson Rules: 1 Composite Simpson's 1/3 Rule

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

Simpson rules

June 10, 2022

1 Composite Simpson’s 1/3 rule


a=0 ; b = 0.8 ; n=4

f (x) = 0.2 + 25x − 200x2 + 675x3 − 900x4 + 400x5

∫ 0.8
(0.2 + 25x − 200x2 + 675x3 − 900x4 + 400x5 )dx = 1.640533
0


n−1 ∑
n−2
f (x0 ) + 4 f (xi ) + 2 f (xj ) + f (xn )
i=1,3,5 j=2,4,6
I = (b − a) ∗
3n

[1]: import numpy as np

a=0; b=0.8; n=4;


x=np.linspace(a,b,n+1)
y=0.2 + 25*x - 200*x**2 + 675*x**3 - 900*x**4 + 400*x**5

s1=[]; sum1=0
for i in range(1,n,2):
s1.append(y[i])
sum1=np.sum(s1)

s2=[]; sum2=0
for j in range(2,n-1,2):
s2.append(y[j])
sum2=np.sum(s2)

I=(b-a)*(y[0]+4*sum1+2*sum2+y[-1])/(3*n)

print("La integral estimada es: ", I)

La integral estimada es: 1.6234666666666717

You might also like