Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Alternate form of the quadratic formula

  1. Jun 14, 2004 #1
  2. jcsd
  3. Jun 14, 2004 #2


    User Avatar
    Science Advisor
    Homework Helper
    Gold Member
    Dearly Missed

    Multiply the usual form with

    Edited a small mistake
    (Usual form:[tex]\frac{-b\pm\sqrt{b^{2}-4ac}}{2a}[/tex])
    Last edited: Jun 14, 2004
  4. Jun 14, 2004 #3
    The alternative form comes in handy in some applications of computer science. One form of the quadratic equation will often produce more random error than the other. Just because two statements are equivalent doesn't mean the computer will run them the same.
  5. Jun 15, 2004 #4
    why doesn't the computer run them the same?
  6. Jun 15, 2004 #5
    Because you might know one of coefficients better than the others, and depending on whereit is (inside or outsode of the radical) it's error will be less. For example, let's just say you have f(C)=2C and g(C)=(C)^(1/2)

    If your value of C is off by 0.5, then in f your answer will be off by 1, but in g your answer will be off by less than one.

    Or, if you know each coefficient exactly, but they're way too long to compute with, depending on where you enter them into the formula, your forced rounding will matter less.

    That's just my guess, anyway.
  7. Jun 15, 2004 #6


    User Avatar
    Science Advisor
    Homework Helper
    Gold Member
    Dearly Missed

    It has to do with loss of significant digits when subtracting two nearly equal magnitudes from each other.
    The loss of significant digits means that the relative error between exact value and computer value can become very large.
    Hence, it is best to use the following expressions for the two roots:
  8. Jun 16, 2004 #7
    It also has to do with the number of operations you have to perform, although that isn't an issue here.
  9. Jun 16, 2004 #8


    User Avatar
    Science Advisor
    Homework Helper
    Gold Member
    Dearly Missed

    Now, that's interesting..
    I didn't know that, could you expound a bit?
    (Is it merely that the expression in the numerator of one root might be used as the denominator in the other root?)
  10. Jun 16, 2004 #9
    Each time a computer performs an operation, it truncates the result (roundoff error). Furthermore, some numbers can be represented exactly in IEEE floating point notation, other's can't. See Rubin Landau's book Computational Physics.

    This issue is especially important in approximation theory, where series representations of solutions need to be expressed in the lowest number of operations possible -- a process called economization. You can economize a Taylor series by incorporating information from the higher-order terms into the lower order terms, producing a series that produces roughly the same result but at lower order -- the so-called Chebyshev economization method.) The book Numerical Recipes discusses this method fairly well. Anthony Ralston's book on Numerical Methods probably has the best treatment on the subject. See also http://www.nhn.ou.edu/~walkup/researchdocuments/br3.pdf

    If you have Mathematica, check out the relationship between Pade approximants and economized rational approximants. The latter is the economized version of the former.
  11. Jun 17, 2004 #10
    My value or the computer's value? What would cause the computer to make an error?

    IOW, putting it in the alternate form will simplify the computer processing, like JohnDubYa said. BTW, JohnDubYa, that was extremely interesting. How is this theory in particular used? Is "it's" specialty in processing...?
  12. Jun 17, 2004 #11
    How is this theory used? Hmmm...

    1. Computers cannot really find exponentials and logarithms, because the circuit designs can only add, subtract, multiply and divide. So all buttons on the calculator have to be expressed in terms of those four basic operations. The most boneheaded way to accomplish that (other than lookup tables) is to use Taylor series expansions of the functions, so instead of computing [tex]e^x[/tex] you compute [tex]1+x + \frac{x^2}{2} + ...[/tex]. Since you cannot sum an infinite number of terms, you must truncate the series at some order. The problem is round-off error. Each term introduces round-off error, so the trick is to get an accurate representation at low order. This is where economization (and other tricks) come into play.

    2. One of the most common ways to solve differential equations is by a series solution (for example, perturbation theory in quantum mechanics). But you again must truncate the solution to some finite order. As with the problem stated in (1), summing the series at some value of the independent variable introduces round-off error.

    3. Converting series that diverge into convergent series.

    Let me give you an example: If you place hydrogen in a magnetic field, you can write out a perturbation (series) expansion of the energy solution that is a function of the magnetic field strength. So you get something like (making up numbers)

    [tex] E = 0.2 B + 0.004 B^2 + 0.00043 B^3 + ...[/tex]

    If you tell me the field strength B, I will tell you the energy of the atom. But for sufficiently large values of B, this series diverges. (Adding on more terms makes the energy larger and larger.)

    But a clever researcher would realize that you can re-cast the series into a new series that CONVERGES for large field strengths. One such method is Pade summation, which replaces the series expansion polynomial with a RATIO of polynomials. (This introduces a denominator that can mock the singularity structure of the physical system.) If that doesn't work, you can economize the Pade approximant, producing economized rational approximants. There are hundreds of techniques, and most physistics are not even aware of them. (Ooodles of good research gets tossed every year because physicists do not realize that they can re-sum divergent series into convergent series.)

    Let me give you an example.

    Suppose your quantum system produced a series representation of the energy that looked like this:

    [tex]E = 1 + B + B^2 + B^3 + ...[/tex]

    Now, it is obvious that such a solution blows up for any value of B equal to or greater than 1. Wanna' know why? Factor a B out of the RHS:

    [tex] E = 1 + B( 1 + B^2 + B^3 + ...), [/tex]

    which means E = 1 + BE. Solve for E and you get [tex]E = \frac{1}{1 - B}[/tex]

    Oh ho! There is a singularity at B = 1, so the series will diverge for values greater than 1.

    So [tex]E = 1 + B + B^2 + B^3 + ... [/tex] is bad. So what can we do? Well, our series sucks because it does not contain a denominator, which is needed to simulate the pole at B = 1. So let's instead create a new series representation that DOES have a denominator. The most general case would be something like

    [tex]E = \frac{a + bB + cB^2 + ...}{1 + dB + eB^2 + ...}.[/tex]

    To find the coefficients, we simply match this ratio with the original series at B = 0. And then we match the derivative of this ratio with the derivative of the original series at B = 0. And then we match the second derivative... and so on. If you do that, you will find that a = 1, d = -1, and the rest are 0. In other words, we get

    [tex]E = \frac{1}{1-B}[/tex]

    This Pade approximant actually is equal to the original function because our original function was a ratio of polynomials. But you can apply it to any function, such as [tex]e^x[/tex].

    So if your physics professor tells you that you can only apply perturbation theory for small values of the magnetic field, then he is wrong. (Yes, at some point the field gets so strong that any series representation will diverge, but you can push the envelope much further than textbooks allow.)

    By the way, I'm writing a book on this topic. Interesting?
  13. Jun 18, 2004 #12
    Yes, very interesting. Surely it will be a success.

    Let me make it quite clear that I am only in 9th grade. Please simplify on the maths....
    (or just teach it to me if you lke, I'm a very fast learner...)
    Can you explain the logic that goes into this please?

    What's round-off error? I'm guessing "low order" refers to the order of polynomials?
  14. Jun 18, 2004 #13
    Maybe I'm being a fish out of water here, but I'm feeling kinda talkative at the moment...

    [tex]1+x + \frac{x^2}{2} + ...[/tex]

    is the Taylor Series expansion for [itex]e^x[/itex]. It's necessary because a computer doesn't understand e^x. It hardly understand e, in fact. Exponentiation like that isn't one of the operations a computer can perform. So you use a series representation or some other kind of representation that only contains operations that the computer can perform. The Taylor Series has only operations a computer likes, so there you go.

    As you add more and more terms, the series gets closer and closer to equaling the original expression. The infinite sum of the terms is identically equal to the expression. But nothing but humans can handle an infinite number of terms, so you have to truncate the number for computers.

    So a computer might say e^x = (1 + x + x^2 + x^3). (1 + x + x^2 + x^3) clearly isn't equal to e^x, so there's some error. Try a value of x and see for yourself. But if you add another term, say e^x = (1 + x + x^2 + x^3 + x^4), you get closer. Less error. Keep adding more and more terms and you get closer and closer. Add enough terms and you have a hard time telling the difference, and it becomes pretty practical.

    Round off error's pretty easy. Say you have a number 1.23456789. But a computer can only store 8 digits. So it rounds the 9-digit number off to fit it into 8 digits. You get 1.2345679. 1.23456789 - 1.2345679 = -.000000001, so there's error. The computer literally isn't using the right value.

    Last edited: Jun 18, 2004
  15. Jun 19, 2004 #14
    Good explanation, cookiemonster.

    "So a computer might say e^x = (1 + x + x^2 + x^3). (1 + x + x^2 + x^3) clearly isn't equal to e^x, so there's some error. Try a value of x and see for yourself. But if you add another term, say e^x = (1 + x + x^2 + x^3 + x^4), you get closer. Less error. Keep adding more and more terms and you get closer and closer. Add enough terms and you have a hard time telling the difference, and it becomes pretty practical."

    Aaaaaah, but there is a catch! As you add on more terms, you decrease the systematic error in the calculation, no doubt. But you INCREASE the roundoff error, because the result of each computaton has to be truncated internally to fit the computer's memory registers. (It takes longer to compute more terms too.) The more operations you perform, the worse the roundoff error becomes.

    So you have two competing errors -- one that likes a large number of terms in the series, and another that likes a low number of terms. The best thing to do would be to take infomration from the higher order terms and introduce it into the lower order terms. This way you decrease both systematic error and roundoff error. This is the essence of economization.

    One more thing -- you said that by adding more terms you get a closer result. This is only true if the series CONVERGES. The series representation for e^x always converges no matter what value of x you try because e^x is an entire function. But a Taylor series of (say) the tan(x) diverges badly for large values of x (that is, as you add on more terms, the systematic error gets WORSE, not better). The trick then is to convert the Taylor series into an approximant like the Pade approximent, which tends to have better convergence properties.

    If a student understands the meaning of a polynomial, they can probably understand much of the fundamentals of this discussion. I think the Mathematica manual has one of the easiest discussions to read about this issue. Also the Numerical Recipes has a good discussion.
    Last edited: Jun 19, 2004
  16. Jun 19, 2004 #15
    RE: "Can you explain the logic that goes into this please?"

    I suspect you didn't give the GIF file time to load. Try again.

    RE: "What's round-off error?"

    Pick up a pocket calculator and multiply 3.29443 and 5.34433 together. The result
    is something like 17.6065210819. But the computer may not be able to store all of those digits because its memory registers are only so big. So it may have to truncate the result to 17.6065. By scrubbing off digits, the calculation loses accurary. This is round-off error.

    I'm guessing "low order" refers to the order of polynomials?


    1 + 3.64x -> low (first) order

    1 + 3.64x - 4.52x^2 + 67.33x^3 + 85.84x^4 -> higher (fourth) order
  17. Mar 9, 2009 #16
    I think multiply the usual form with
    is correct.

    Last edited: Mar 9, 2009
  18. Mar 9, 2009 #17
    Wow. Tons of good information in this thread! Thanks!
  19. Jun 5, 2009 #18
    I remember there was one way where if b is divisible by 2, you can use a simpler formula but I forgot what it was...
    like when ax2+bx+c=0; b is divisible by 2

    I might be wrong though : )
    Last edited: Jun 5, 2009
  20. Jun 5, 2009 #19


    User Avatar

    Also, to get the alternate form, divide ax2+bx+c = 0 by x2 to get a + b(1/x) + c(1/x)2=0. This is just a quadratic in 1/x with a and c switched around. So, you can switch a and c in the standard quadratic formula to solve for (1/x) and then switch numerator and denominator to get the alternate form for x.
  21. Jun 5, 2009 #20

    D H

    User Avatar
    Staff Emeritus
    Science Advisor

    Computers typically work in base 2. For the point of illustration, assume you are working with a computer that uses base 10 for floating point arithmetic and assume it only has 5 significant digits. For example, computing 1.0/3.0 and 200.0/3.0 on this computer yields 0.33333 and 66.667, respectively. Now suppose you need to find the solutions to


    You apply the simple version of the quadratic formula:

    [tex]x=\frac{315\pm\sqrt{315^2-4}}2 = \frac{315\pm\sqrt{99221}}2[/tex]

    On this computer, [itex]\surd 99221 = 314.99[/tex] (the correct answer: [itex]314.993651\cdots[/itex]. The two solutions as calculated on this computer are

    x_1 &= \frac{315-314.99}2 = 0.005 \\
    x_2 &= \frac{315+314.99}2 = 315.00

    The correct values are [itex]0.00317463517\cdots[/itex] and [itex]314.996825\cdots[/itex]. The larger of the two values is correct to five decimal places. The smaller of the two has zero significant digits. Now look what happens when you calculate the smaller value using the alternate form:

    [tex]x_1 = \frac 2{315+314.99} = 0.0031747[/tex]

    which is correct to four significant digits.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook