- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# How to Solve Quadratic Equation using Python?

You can use the cmath module in order to solve Quadratic Equation using Python. This is because roots of quadratic equations might be complex in nature. If you have a quadratic equation of the form ax^2 + bx + c = 0, then,

## Example

**import cmath**

a = 12 b = 8 c = 1 # Discriminent d = (b**2) - (4*a*c) root1 = (-b - cmath.sqrt(d)) / (2 * a) root2 = (-b + cmath.sqrt(d)) / (2 * a) print(root1) print(root2)

## Output

This will give the output

(-0.5+0j) (-0.16666666666666666+0j)

- Related Articles
- How to solve a circulant matrix equation using Python SciPy?
- How to solve Hermitian positive-banded matrix equation using Python SciPy?
- How to solve an Equation?
- Solve the following quadratic equation by factorization: $3x^2 = -11x – 10$
- Solve the following quadratic equation by factorization: $25x(x + 1) = –4$
- Solve the quadratic equation $2x^{2} +ax-a^{2} =0$ for $x$.
- Solve the following quadratic equation by factorization: $(x – 4)(x + 2) = 0$
- Solve the following quadratic equation by factorization: $(2x + 3)(3x – 7) = 0$
- Solve the following quadratic equation by factorization: $3x^2 – 14x – 5 = 0$
- Solve the following quadratic equation by factorization: $9x^2 – 3x – 2 = 0$
- Solve the following quadratic equation by factorization: $6x^2 + 11x + 3 = 0$
- Solve the following quadratic equation by factorization: $5x^2 – 3x – 2 = 0$
- Solve the following quadratic equation by factorization: $48x^2 – 13x – 1 = 0$
- Solve the following quadratic equation by factorization: $16x – frac{10}{x} = 27$
- Solve the tensor equation in Python

Advertisements