# 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{align}
  x &= \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}.
\end{align}$

### Derivation of the Quadratic Equation

To derive this set $y = 0$ and complete the square:

$\begin{align}
  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{align}$

Solving for $x$ gives

$\begin{align}
  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{align}$

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

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

### 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{align}
  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{align}$

Now let

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

Then

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

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

Considering just the negative square root we have

$\begin{align}
  x_1 &= \left( -\frac{b}{2a} \right) \left( 1 - \sqrt{1 - 4Q^2} \right).
\end{align}$

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

$\begin{align}
  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{2 b Q^2}{a} \left( \frac{1}{1 + \sqrt{1 - 4Q^2}} \right) \\
&= -\frac{2 b \left( \frac{ac}{b^2} \right)}{a} \left( \frac{1}{1 + \sqrt{1 - 4Q^2}} \right) \\
&= -\frac{2 c}{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{align}$

By defining

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

we can write

$\begin{align}
  x_1 &= -\frac{c}{bF} .
\end{align}$

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{align}
  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{align}$

Using the two roots $x_1$ and $x_2$, we can factor the quadratic
equation

$\begin{align}
  y &= a x^2 + b x + 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{align}$

### Accuracy for Low $Q$

For values of $Q \le 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{align}
  y &= a x^2 + b x + c \\
&\approx a \left( x + \frac{c}{b}\right) \left( x +\frac{b}{a}\right),
\end{align}$

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$.\]

