Factor a quadratic polynomial in Python
问题 Since factoring a quadratic equation in my head just happens, and has done that since I learned it - how would I go about starting to write a quadratic factorer in Python? 回答1: Improving Keiths's answer: Start with a polynomial P(x) = a*x^2 + b*x + c . Use the quadratic formula (or another another method of your choice) to find the roots r1 and r2 to P(x) = 0 . You can now factor P(x) as a*(x-r1)(x-r2) . If your factor (3x - 4)(x - 9) the solution will be 3*(x - 4/3)(x - 9). You might want to