# Circuit Theory/Quadratic Equation Revisited
### The Quadratic Equation

The roots to the quadratic polynomial
$y=ax^{2}+bx+c$
are easily derived and many people memorized them in high school:
${\begin{aligned}x&={\frac {-b\pm {\sqrt {b^{2}-4ac}}}{2a}}.\end{aligned}}$

### Derivation of the Quadratic Equation

To derive this set $y=0$ and complete the square:
${\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 $x$ gives
${\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
${\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 $a$, $b$, and $c$.
[Give an example here]
Middlebrook showed how a better expression can be obtained as follows. First, factor $-{\frac {b}{2a}}$ out of the expression:
${\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
$Q^{2}={\frac {ac}{b^{2}}}.$
Then
${\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
${\begin{aligned}x_{1}&=\left(-{\frac {b}{2a}}\right)\left(1-{\sqrt {1-4Q^{2}}}\right).\end{aligned}}$
Multiplying the numerator and denominator by $1+{\sqrt {1-4Q^{2}}}$ gives
${\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
$F={\frac {1}{2}}+{\frac {1}{2}}{\sqrt {1-4Q^{2}}}$
we can write
${\begin{aligned}x_{1}&=-{\frac {c}{bF}}.\end{aligned}}$
Note that as $Q\to 0$, $F\to 1$.

### Finding the Positive Root Using the Same Approach

Turning now to the positive square root we have
${\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 $x_{1}$ and $x_{2}$, we can factor the quadratic equation
${\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 $Q$

For values of $Q\leq 0.3$ the value of $F$ is within 10% of 1 and we may neglect it. As noted above, the approximation gets better as $Q\to 0$. With this approximation the quadratic equation has a very simple factorization:
${\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 $Q$ being small before using the simplification. Without this simplification, $F$ needs to be calculated and the roots are slightly more complicated.
[Explore the consequences if $Q>0.5$.]