Calculus CA2 Sem
Calculus CA2 Sem
2023
A RT S SC I E
OF NC
E E
&
EG
LL
CO
CO
MM
P I L LAI
ER
CE
Name: Aman .D. Chaurasiya
Class: FYCS A
Roll no: 2121
Subject: Calculus Project (CA2)
Year: 2022-23
Thomas Simpson
6. Set: i = 1
13. Stop
code for 1/3 rule:
# Simpson's 1/3 Rule
# Define function to integrate
def f(x):
return 1/(1 + x**2)
# Implementing Simpson's 1/3
def simpson13(x0,xn,n):
# calculating step size
h = (xn - x0) / n
# Finding sum
integration = f(x0) + f(xn)
for i in range(1,n):
k = x0 + i*h
if i%2 == 0:
integration = integration + 2 * f(k)
else:
integration = integration + 4 * f(k)
# Input section
lower_limit = float(input("Enter lower limit of
integration: "))
upper_limit = float(input("Enter upper limit of
integration: "))
sub_interval = int(input("Enter number of sub
intervals: "))
output(2):
output(3):
Algorithm of 3/8 rule:
1.Start
2.Define function f(x)
3.Read lower limit of integration, upper limit
of integration and number of sub interval
6.Set: i = 1
7.If i > number of sub interval then go to
8.Calculate: k = lower limit + i * h
9.If i mod 3 =0 then
Integration value = Integration Value + 2* f(k)
Otherwise
Integration Value =Integration Value + 3 * f(k)
End If
# Finding sum
integration = f(x0) + f(xn)
for i in range(1,n):
k = x0 + i*h
if i%2 == 0:
integration = integration + 2 * f(k)
else:
integration = integration + 3 * f(k)
return integration
# Input section
lower_limit = float(input("Enter lower limit of
integration: "))
upper_limit = float(input("Enter upper limit of
integration: "))
sub_interval = int(input("Enter number of sub
intervals: "))
output(2):
output(3):
Conclusion:
Conclusion is that the complicated Simpsons
method which we use long formulas but in this
code we made it simple to solve big problems in
seconds I have used python to do this project...…