The roots to the quadratic polynomial

${\displaystyle y=ax^{2}+bx+c}$

are easily derived and many people memorized them in high school:

{\displaystyle {\begin{aligned}x&={\frac {-b\pm {\sqrt {b^{2}-4ac}}}{2a}}.\end{aligned}}}

### Derivation of the Quadratic Equation

To derive this set ${\displaystyle y=0}$  and complete the square:

{\displaystyle {\begin{aligned}0&=ax^{2}+bx+c\\0&=a\left(x^{2}+{\frac {b}{a}}x+{\frac {c}{a}}\right)\\0&=x^{2}+{\frac {b}{a}}x+\left({\frac {b}{2a}}\right)^{2}+{\frac {c}{a}}-\left({\frac {b}{2a}}\right)^{2}\\0&=\left(x+{\frac {b}{2a}}\right)^{2}+\left({\frac {c}{a}}-\left({\frac {b}{2a}}\right)^{2}\right).\end{aligned}}}

Solving for ${\displaystyle x}$  gives

{\displaystyle {\begin{aligned}0&=\left(x+{\frac {b}{2a}}\right)^{2}+\left({\frac {c}{a}}-\left({\frac {b}{2a}}\right)^{2}\right)\\\left(x+{\frac {b}{2a}}\right)^{2}&=-\left({\frac {c}{a}}-\left({\frac {b}{2a}}\right)^{2}\right)\\&={\frac {b^{2}-4ac}{\left(2a\right)^{2}}}.\end{aligned}}}

Taking the square root of both sides and putting everything over a common denominator gives

{\displaystyle {\begin{aligned}x+{\frac {b}{2a}}&=\pm {\sqrt {\frac {b^{2}-4ac}{\left(2a\right)^{2}}}}\\x&={\frac {-b\pm {\sqrt {b^{2}-4ac}}}{2a}}.\end{aligned}}}

### Numerical Instability of the Usual Formulation of the Quadratic Equation

Middlebrook has pointed out that this is a poor expression from a numerical point of view for certain values of ${\displaystyle a}$ , ${\displaystyle b}$ , and ${\displaystyle c}$ .

[Give an example here]

Middlebrook showed how a better expression can be obtained as follows. First, factor ${\displaystyle -{\frac {b}{2a}}}$  out of the expression:

{\displaystyle {\begin{aligned}x&={\frac {-b\pm {\sqrt {b^{2}-4ac}}}{2a}}\\&=\left(-{\frac {b}{2a}}\right)\left(1\pm {\sqrt {1-{\frac {4ac}{b^{2}}}}}\right).\end{aligned}}}

Now let

${\displaystyle Q^{2}={\frac {ac}{b^{2}}}.}$

Then

{\displaystyle {\begin{aligned}x&=\left(-{\frac {b}{2a}}\right)\left(1\pm {\sqrt {1-4Q^{2}}}\right)\end{aligned}}}

### A More Numerically Stable Formulation of the Negative Root

Considering just the negative square root we have

{\displaystyle {\begin{aligned}x_{1}&=\left(-{\frac {b}{2a}}\right)\left(1-{\sqrt {1-4Q^{2}}}\right).\end{aligned}}}

Multiplying the numerator and denominator by ${\displaystyle 1+{\sqrt {1-4Q^{2}}}}$  gives

{\displaystyle {\begin{aligned}x_{1}&=\left(-{\frac {b}{2a}}\right)\left(1-{\sqrt {1-4Q^{2}}}\right)\left({\frac {1+{\sqrt {1-4Q^{2}}}}{1+{\sqrt {1-4Q^{2}}}}}\right)\\&=\left(-{\frac {b}{2a}}\right)\left({\frac {1-1+4Q^{2}}{1+{\sqrt {1-4Q^{2}}}}}\right)\\&=-{\frac {2bQ^{2}}{a}}\left({\frac {1}{1+{\sqrt {1-4Q^{2}}}}}\right)\\&=-{\frac {2b\left({\frac {ac}{b^{2}}}\right)}{a}}\left({\frac {1}{1+{\sqrt {1-4Q^{2}}}}}\right)\\&=-{\frac {2c}{b}}\left({\frac {1}{1+{\sqrt {1-4Q^{2}}}}}\right)\\&=-{\frac {c}{b}}\left({\frac {1}{{\frac {1}{2}}+{\frac {1}{2}}{\sqrt {1-4Q^{2}}}}}\right).\end{aligned}}}

By defining

${\displaystyle F={\frac {1}{2}}+{\frac {1}{2}}{\sqrt {1-4Q^{2}}}}$

we can write

{\displaystyle {\begin{aligned}x_{1}&=-{\frac {c}{bF}}.\end{aligned}}}

Note that as ${\displaystyle Q\to 0}$ , ${\displaystyle F\to 1}$ .

### Finding the Positive Root Using the Same Approach

Turning now to the positive square root we have

{\displaystyle {\begin{aligned}x_{2}&=\left(-{\frac {b}{2a}}\right)\left(1+{\sqrt {1-4Q^{2}}}\right)\\&=\left(-{\frac {b}{a}}\right)\left({\frac {1}{2}}+{\frac {1}{2}}{\sqrt {1-4Q^{2}}}\right)\\&=-{\frac {bF}{a}}.\end{aligned}}}

Using the two roots ${\displaystyle x_{1}}$  and ${\displaystyle x_{2}}$ , we can factor the quadratic equation

{\displaystyle {\begin{aligned}y&=ax^{2}+bx+c\\&=a\left(x^{2}+{\frac {b}{a}}+{\frac {c}{a}}\right)\\&=a\left(x-x_{1}\right)\left(x-x_{2}\right)\\&=a\left(x+{\frac {c}{bF}}\right)\left(x+{\frac {bF}{a}}\right).\end{aligned}}}

### Accuracy for Low ${\displaystyle Q}$

For values of ${\displaystyle Q\leq 0.3}$  the value of ${\displaystyle F}$  is within 10% of 1 and we may neglect it. As noted above, the approximation gets better as ${\displaystyle Q\to 0}$ . With this approximation the quadratic equation has a very simple factorization:

{\displaystyle {\begin{aligned}y&=ax^{2}+bx+c\\&\approx a\left(x+{\frac {c}{b}}\right)\left(x+{\frac {b}{a}}\right),\end{aligned}}}

an expression that involves no messy square roots and can be written by inspection. Of course, it is necessary to check the assumption about ${\displaystyle Q}$  being small before using the simplification. Without this simplification, ${\displaystyle F}$  needs to be calculated and the roots are slightly more complicated.

[Explore the consequences if ${\displaystyle Q>0.5}$ .]