Scroll to Top

Virtual Math Learning Center

Virtual Math Learning Center Texas A&M University Virtual Math Learning Center

Plotting Expressions and Solving Equations Numerically in Python

Author: David Manuel

In this video, it is showin how to plot an expression in Python. Then to use the plot to help obtian numerical approximations of solutions. 

Transcript 05

Problem: Plot the expression \[50\tan(\theta)-\dfrac{13.61}{\cos(\theta)^2} = 0.\] Then solve the equation numerically.

Python Code:
from sympy import *

matplotlib notebook

theta=symbols('theta')
LHS=50*tan(theta)-13.61/(cos(theta))**2
plot(LHS,(theta,0,1.5),ylim=[-20,20])
angle1=nsolve(LHS,theta,0.3)
angle2=nsolve(LHS,theta,1.3)
print('The angle needed is',angle1*180/pi.evalf(),'or',angle2*180/pi.evalf(),'degrees')

Open Python Notebook File

See more videos from this section