Areas Between Curves in Python
Author: David Manuel
In this video, it is shown how to use Python to find the area between curves. The presenter uses Python to plot the curves and then uses the solve command to find the points of intersection. Lastly, the presenter uses the Python command to evaluate the two definite integrals representing the area of the region.
Transcript 21
Transcript 21
Exercises
Python Code:
Area under y=(4/3)sqrt(9-x^2), above x-axis, and to the left of y=2x
from sympy import *
x=symbols('x')
f=4/3*sqrt(9-x**2)
g=2*x
matplotlib notebook
plot((f,(x,-3,3)),(g,(x,-3,3)))
c=solve(f-g,x)[0]
# this case only has one solution so adding [0] gives that single solution as a number, instead of a list
print(c)
Area1=integrate(f,(x,-3,0))
Area2=integrate(f-g,(x,0,c))
print(Area1,Area2)
print('The area is equal to', (Area1+Area2).evalf())
Open Python Notebook File
Area under y=(4/3)sqrt(9-x^2), above x-axis, and to the left of y=2x
from sympy import *
x=symbols('x')
f=4/3*sqrt(9-x**2)
g=2*x
matplotlib notebook
plot((f,(x,-3,3)),(g,(x,-3,3)))
c=solve(f-g,x)[0]
# this case only has one solution so adding [0] gives that single solution as a number, instead of a list
print(c)
Area1=integrate(f,(x,-3,0))
Area2=integrate(f-g,(x,0,c))
print(Area1,Area2)
print('The area is equal to', (Area1+Area2).evalf())
Open Python Notebook File
Related Videos (168)
Area Between Two Curves
Finding the area between two curves on an interval using a definite integral
MATH 152: Work Exercise 13
Calculating the work done pulling part of a rope to the top of a building
MATH 152: Work Exercise 8
Calculating the work done pumping water out of a tank shaped like a trough
