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

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