A powerful and easy-to-use PyPI package for solving and visualizing quadratic equations. This tool computes key properties of quadratic functions and provides a graphical representation of the curve.
Note: It is recommended to use the stable release.
-
Solve quadratic equations of the form: ax² + bx + c = 0
-
Compute:
- Real or complex roots
- Discriminant
- Vertex (turning point)
- Axis of symmetry
- Ordered pairs (for plotting)
- Nature of roots (distinct, repeated, or complex)
-
Graph the quadratic function directly from the CLI
Install via pip:
pip install quadratic-solverStart by importing the model in Python:
from quadratic_solver.model import QuadraticFunctionsMake an instance of QuadraticFunctions:
qf = QuadraticFunctions(8, 23, 1)Then call the methods:
qf.quadratic_formula() # solve and display the roots, discriminant, vertex and axis of symmetry
qf.plot_and_display_graph() # plot and display graph of the quadratic function- convert_to_float - convert user input (a, b, c) to float and returns it.
- vertex - return tuple of ordered pair (vertex) of the function.
- discriminant - returns the discriminant of the function.
- quadratic_formula - solve and display the roots, discriminant, vertex and axis of symmetry
- plot_and_display_graph - plot and display graph of the quadratic function
Quadratic Equation: x² - 3x + 2 = 0
Discriminant: 1
Roots: x₁ = 2, x₂ = 1
Nature of Roots: Real and Distinct
Vertex: (1.5, -0.25)
Axis of Symmetry: x = 1.5
Sample Points:
(0, 2)
(1, 0)
(2, 0)
(3, 2)
A graph window will also appear displaying the parabola.
The application automatically generates a plot of the quadratic function, highlighting:
- The roots
- The vertex
- The curve shape (concave up or down)
The app uses standard quadratic formula logic:
x = (-b ± √(b² - 4ac)) / (2a)
-
If the discriminant is:
- > 0 → Two real roots
- = 0 → One repeated root
- < 0 → Two complex roots
Graphing is handled programmatically using Python plotting libraries.
-
Python 3.10+
-
Required dependencies (installed automatically):
- matplotlib
- numpy
Contributions are welcome!
- Fork the repository
- Create a new branch
- Make your changes
- Submit a pull request
This project is licensed under the MIT License.
- Batch processing of multiple equations
- Interactive mode with command flags
Built by Uchenna Adubasim
If you find this project useful, consider giving it a star on GitHub!