Factoring Polynomials

Tim Rowe digitig at gmail.com
Fri Dec 19 06:32:05 EST 2008


2008/12/18 Scott David Daniels <Scott.Daniels at acm.org>:

> def quadsolve(a, b, c):
>    try:
>        discriminant = sqrt(b**2 - 4 * a * c)

The discriminant of a quadratic is more usually just the b**2 - 4 * a
* c part, not the square root of it. Testing that for negative, zero
or positive avoids the need to use an exception for a normal case.

-- 
Tim Rowe



More information about the Python-list mailing list