# Solve Quadratic Equations for Analog Design Engineers

## the story of a new formula

Almost everyone learns in school, how to solve a quadratic equation using this formula

There is even a rosetta code task where you can see a plethora of programming languages implementing this formula to solve several quadratic equations.

However as

in this formula becomes bigger, relative tobanda, it’s difficult to calculate one of the roots correctly.c

To zoom into the numerator, **assuming b is positive**, it becomes obvious

that for one of the roots, this term amounts to subtracting two very close numbers. That should certainly be avoided for any numerical computations.

By the way, **if b is negative**, it’s the other term in the formula

that suffers from this “**subtracting two close numbers**” syndrome.

Fortunately, one can apply one property of the quadratic roots, that is

In this case, when *a* = *c* = 1 and *b* = -100000, you can get one of the roots using

Then applying the property of two roots (eq: 4), you can calculate the other root as 1/(100000).

Or if you like *Mathematica*, just keep the results in the symbolic form rather than the numerical form.

At this point, you might think this is just some toy problem that was used to illustrate one issue of the numerical computation.

Although it is quite alarming, since among all these programming languages, if one choose to blindly implement a well known mathematical formula, numerical error can occur so easily.

When would anyone ever need to solve a quadratic equation like this in the real world?

The answer is *analog circuit design engineers*.

The story goes back to the late Caltech professor David Middlebrook. He suggested a new formula for solving quadratic equations.

The idea is to define two extra terms, a “correction term” *F* and a “q-factor” *Q*. The motivation here is not to advocate changing math textbooks, so that school children all over the world now have to memorize two more “complicated” terms for their math exams.

The goal is to help circuit design engineers.

In fact many of Professor Middlebrook’s design-oriented analysis (D-OA) approach for electric engineers is to

- use approximation and rearrange the formula with the important design quantity explicit, followed by some “correction term”
- use a single quantity, such as “q-factor” to depict a wide range of behavior of a complicated circuitry

There are many good illustration of this philosophy if you dig deep into his extra-element theorem, inverted zero, pole graph method for frequency response, and general feedback theorem.

His method for solving the quadratic equation is just another good illustration of the D-OA philosophy.

According to his new formula, the two roots of a quadratic equation are

The first advantage is that both *F* and *Q* calculations are “numerically stable”. In the previous example, when *a* = *c* = 1 and *b* = -100000, we have *Q* = -1/100000 and *F* = 1, so the two roots can be calculated correctly 100000, and 1/100000, according to this new formula (eq: 5).

In fact, if *Q* is much smaller than 0.5, the correction term *F* is very close to 1, you get two real roots being approximated very well by

The second big advantage of the new formula is for electrical engineers calculating the frequency response of a circuit network for filtering, gain stage, etc., it often involves factoring a polynomial into pole, zero form. In case of a quadratic polynomial, you can apply this new formula.

To be more specific, in this case

*s* being the frequency domain variable. The last approximation holds, if *F* is close to 1, which can be verified by calculating *Q*

Notice that this formula (eq: 7, eq: 8)is exactly the same as the one (eq: 5, eq: 6)before, with *a* = a₂, *b* = a₁, and *c *= 1

Here is the circuit diagram of a simple R-C circuit.

The idea is that you designed a lead-lag network, and there is some small stray capacitance across the output. How would that affect the frequency response of the voltage transfer function *Vout/Vin*.

Since the circuit now has two loops, instead of one, the transfer function will have quadratic terms inside. The key is to try to factor it into zero, pole form.

After some algebra,

The zero is still the same at 1/R₂ C₂, but now the denominator is a quadratic term. We can recognize the single pole of a lead-lag network at 1/(R₁ + R₂)C₂, but there is an extra term Cs R₂.

- since Cs is much smaller than C₂, thus Cs R₂ much smaller than (R₁ + R₂)C₂ we can, as an approximation, throw the term Cs R₂ away.

Well, there is an extra (R₁ R₂ C₁ C₂)s² term at the end. Can we factor this quadratic according to formula (7)?

In this case Q is much smaller than 0.5, yes, we can factor the quadratic according to (7). So the transfer function becomes

Again the approximate equal sign is because

- we threw away Cs R₂ term
- we use
*F*=1, due to*Q*much less than 0.5, to factor the quadratic

Both can be justified by the components value in the original circuit schematic.

Now you can easily recognize two poles, one still at 1/(R₁ + R₂)C₂. The extra pole caused by Cs is at 1/(R1 ∥ R2)Cs

Let’s sweep the frequency of the circuit in our mind, to see if we can intuitively predict the behavior of this circuit.

- At low enough frequency, C₂ is high enough impedance, as an open, so the gain is 1
- As the frequency goes up, we hit a single pole at 1/(R₁ + R₂)C₂, as the impedance of C₂ drops, comparable to (R₁ + R₂)
- As the frequency goes further up, impedance of C₂ drops, comparable to R R₂, the zero kicks in at 1/R₂ C₂, which levels up the gain drop to a voltage divider R₂/ (R₁ + R₂)
- Until the frequency goes so high, now the impedance of Cs starts to show another pole at 1/(R1 ∥ R2)Cs, which drops the gain again at 20 dB/dec

As a good circuit designer, such intuitive understanding of the circuit is invaluable.