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

SIMPSON.py E/BN/Python/SEM3/SIMPSON.py (3.9.

7)
File Format Run Options Window Help
Edit

INTEGRATION METHOD using SIMPSON RULE FOR N rOUS EUNCTION


Simpson's 1/3 Rule
Define function to i tegrate
def f(x)
return 1/(1 +x**2)

Implementing SimpsonS
def simpson13 (x0,xn, n)
calculating step siz
h (xn x0) n

Finding sum
integration f (x0) + f(*n)

range (1,n):
k X0 i*h
is2 0:
integration integration 2 2 f(k)

integration integration 4f (k
#Finding
integration
final int
integration
1on Va!
h/3
h/3
e
tunn integration

nput
1imit sectio :
owerLimit at (input
(input ("Ente oweE 1imitOf 1ntegration:
fintegration: ion:
"))
"))
uppe1mit ")) )
")
upper1imit
nterva t
loat
int
(input(Enter
(input ("Enter numbe of sub intevals: "))
"))

Cai4 method and get esult upper 1imit subinterval)


resultsimpson13 (lowerimit,
rint (Integratilon rESult| ethed is s0.6f" s (result) )

You might also like