Cubic Equation

Yaser Rahmati | یاسر رحمتی

In algebra, a cubic equation in one variable is an equation of the form:

ax3+bx2+cx+d=0ax^{3} + bx^{2} + cx + d = 0

in which aa is nonzero. The solutions of this equation are called roots of the cubic function.

Solving Equations

SymPy’s solve() function can be used to find solutions to equations. When you input an expression with a symbol representing a variable, such as xx, solve() calculates the value of that symbol. This function always makes its calculation by assuming the expression you enter is equal to zero—that is, it prints the value that, when substituted for the symbol, makes the entire expression equal zero.

Example

Determine the roots of the cubic equation 2x3+3x211x6=02x^3+3x^2–11x–6=0.

import sympy as sp

# Define the symbolic variable
x = sp.symbols('x')

# Define the function symbolically
expr = 2*x**3 +3*x**2 - 11*x -6

sp.solve(expr)

The point(s) where its graph crosses the x-axis, is a solution of the equation. The number of real solutions of the cubic equations is same as the number of times its graph crosses the x-axis.

sp.plot(expr , (x, -5, 3))

My Training Video

My Aparat Channel

Keywords

Web Development (Django, Flask) , Data Science (Pandas, NumPy, Matplotlib) , Machine Learning (Scikit-learn, TensorFlow, PyTorch) , Artificial Intelligence , Automation , GUI Development (Tkinter, PyQt) , Game Development (Pygame) , Scientific Computing , Financial Analysis (Pandas, NumPy) , Network Programming , Image Processing (OpenCV) , Web Scraping (Beautiful Soup, Scrapy) , Internet of Things (IoT) Development , Robotics , Cybersecurity , Mobile App Development (Kivy) , Cloud Computing (Boto3, AWS Lambda) , Big Data Analysis (PySpark) , Geographical Information Systems , Natural Language Processing (NLTK, spaCy) , Data Visualization (Seaborn, Plotly) , Bioinformatics (Biopython) , Multimedia Applications , Education and Teaching

Last updated