Start with the easy stuff:
[MATH]ax^2 + bx + c = 0[/MATH]
[MATH]ax^2 + bx = -c[/MATH]
[MATH]x^2 + \frac{b}{a}x = -\frac{c}{a}[/MATH]
To consolidate the powers of [MATH]x[/MATH], we can
complete the square and find what factor [MATH](x + ?)^2[/MATH] gives us the result we want. It'll give us an extra piece (which fills in a missing corner in the square), but it gives us the powers of [MATH]x[/MATH] that we want.
Let's use [MATH]x + \frac{b}{2a}[/MATH] as our factor. It expands into this:
[MATH]\left(x + \frac{b}{2a}\right)^2 \to x^2 + \frac{b}{a}x + \frac{b^2}{4a^2}[/MATH]
Since this introduces a [MATH]\frac{b^2}{4a^2}[/MATH] that wasn't there before, we need to remember to add it to the
prime numbers right-hand side in our equation:
[MATH]\left(x + \frac{b}{2a}\right)^2 = -\frac{c}{a} + \frac{b^2}{4a^2}[/MATH]
Proceed with autopilot:
[MATH]\left(x + \frac{b}{2a}\right)^2 = \frac{b^2}{4a^2} - \frac{4ac}{4a^2}[/MATH]
[MATH]x + \frac{b}{2a} = \pm\sqrt{\frac{b^2 - 4ac}{4a^2}} = \pm\left(\frac{1}{2a}\sqrt{b^2 - 4ac}\right) [/MATH]
[MATH]x = -\frac{b}{2a} \pm \frac{\sqrt{b^2 - 4ac}}{2a} = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}[/MATH]