You are on page 1of 1

Numerical and Statistical Methods | 1

Roll No.: 302B052


Name of Student: Shaunak Shetye
Experiment No. 03
Program on Simultaneous Equations
Program for Trapezoidal rule
Python Program

import math

def f(x):
return(math.exp(x))
x0= float(input("Enter the lower limit:"))
xn= float(input("Enter the upper limit:"))
n= int(input("Enter number of iterations:"))
h= ((xn-x0)/n)

summ=0
for i in range (n):
summ=summ+f(x0)+f(x0+h)
x0=x0+h

Area= h/2*summ
print("Area by using trapezoidal rule is{}".format(Area))

Output of Program:

Area by using trapezoidal rule is 1.7222574924714813

Sinhgad College of Engineering, Pune | NSM- Journal

You might also like