0% found this document useful (0 votes)
5 views14 pages

Calculus CA2 Sem

Algebra project

Uploaded by

amang22cs
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views14 pages

Calculus CA2 Sem

Algebra project

Uploaded by

amang22cs
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

Calculus

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

Simpson's 1/3 and


3/8 Rules
Introduction to Simpson's
rule:
Simpson's rule is one of
the formulas used to find
the approximate value of a
definite integral. A
definite integral is an
integral with lower and
upper limits. Usually, to
evaluate a definite
integral, we first
integrate (using the
integration techniques) and
then we use the fundamental
theorem of calculus to
apply the limits.
But sometimes, we cannot apply any integration
technique to solve an integral, and sometimes,
we do not have a specific function to
integrate, instead, we have some observed
values (in case of experiments) of the
function. In such cases, Simpson's rule helps
in approximating the value of the definite
integral.

Let us learn this Simpson's Rule and its


formula along with its derivation and a few
solved examples in the upcoming sections.
What is Simpson's
Rule?
Simpson's rule is used
to find the value of a
definite integral (that
is of the form b∫ₐ f(x)
dx) by approximating
the area under the
graph of the function
f(x). While using the
Riemann sum,
we calculate the area under a curve (a definite
integral) by dividing the area under the curve into
rectangles whereas while using Simpson's rule, we
evaluate the area under a curve is by dividing the
total area into parabolas. Simpson's rule is also
known as Simpson's 1/3 rule (which is pronounced as
Simpson's one-third rule).

Real life uses


Many consider DaVinci one of
the greatest machine
designers. His accomplishments
were the result of combining
his talents with the tools of
the day. Imagine the potential
of today’s engineers with the
many tools we have available.
The tip from the trade in this
article is the use of Simpson’s
Rule. Finding the area under a
curve is simplified using
desktop computer tools, MCAD
software, and spreadsheet
programs. If you can draw the
function, you can integrate it.
Just take your MCAD drawing and
use the property command to
measure the area.

Simpson’s Rule is an easy-to-use and reliable


method for solving numerical integrations.
Calculating static and dynamic reaction forces on
areas and volumes. One example would be the
calculation of pressure-volume work done by a
piston:

Solving buoyancy and stability problems when


designing a new marine vessel.

Examples of the use of


Simpson’s rule in this
discipline include the
calculation of a vessel’s
displacement, total wetted
surface area, and the
calculation of the
longitudinal center of
buoyancy of the hull.
Algorithm and
code below

Python is used for


coding
Algorithm of 1/3 rule:
1. Start
2. Define function f(x)
3. Read lower limit of integration, upper limit of
integration and number of sub interval

4. Calcultae: step size = (upper limit - lower


limit)/number of sub interval

5. Set: integration value = f(lower limit) + f(upper


limit)

6. Set: i = 1

7. If i > number of sub interval then goto

8. Calculate: k = lower limit + i * h


9. If i mod 2 =0 then
Integration value = Integration Value + 2* f(k)
Otherwise
Integration Value = Integration Value + 4 * f(k)
End If

10. Increment i by 1 i.e. i = i+1 and go to step 7

11. Calculate: Integration value = Integration value


* step size/3

12. Display Integration value as required answer

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)

# Finding final integration value


integration = integration * h/3
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: "))

# Call trapezoidal() method and get result


result = simpson13(lower_limit, upper_limit,
sub_interval)
print("Integration result by Simpson's 1/3 method
is: %0.6f" % (result) )

Output for 1/3 rule:

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

4.Calculate: step size = (upper limit - lower


limit)/number of sub interval

5.Set: integration value = f(lower limit) +


f(upper limit)

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

10.Increment i by 1 i.e. i = i+1 and go to step 7


11.Calculate: Integration value = Integration
value * step size*3/8

12.Display Integration value as required answer


13.Stop
code for 3/8 rule:
# Simpson's 3/8 Rule

# Define function to integrate


def f(x):
return 1/(1 + x**2)

# Implementing Simpson's 3/8


def simpson38(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 + 3 * f(k)

# Finding final integration value


integration = integration * 3 * h / 8

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: "))

# Call trapezoidal() method and get result


result = simpson38(lower_limit, upper_limit,
sub_interval)
print("Integration result by Simpson's 3/8 method
is: %0.6f" % (result) )

Output for 3/8 rule:

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...…

You might also like