Quadratic

Solves quadratic equations with real roots

The general quadratic equation is:


 * $$ax^2+bx+c=0\ \ .$$

The quadratic formula is:


 * $$x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}\ \ $$

import cmath,sys a = float(sys.argv[1]) b = float(sys.argv[2]) c = float(sys.argv[3]) d = (b**2) - (4*a*c) x1 = (-b-cmath.sqrt(d))/(2*a) x2 = (-b+cmath.sqrt(d))/(2*a) print('Roots: {0} and {1}'.format(x1,x2))
 * 1) !/usr/bin/python3