Professional Documents
Culture Documents
NSM - Trapezoidal Lab 4
NSM - Trapezoidal Lab 4
NSM - Trapezoidal Lab 4
using
2
import
math
import
numpy
as np
import
pandas
as pd
def f(x):
''' for Q.1'''
return (4*x+2) ## Function to be solved
'''for Q.2'''
#return (1/(1+(x**2))) ## Function to be solved
## Inputs
a= float(input('Enter initial
limit= ')) b=float(input('final
limit= ')) N=int(input('no. of
strips= '))
# Calculate the
trapezium step size h =
(b-a)/N
# Get the array of inputs (x-values)
X = np.linspace(a, b, N+1)
df = pd.DataFrame(table_of_output,columns=['X', 'Y=F(X)'])
print('Output') print(df) print ('Value of Integration=
',Yn)
Output Output for Q.1
Flowchart(Paste
Photo of Flowchart