On Tuesday, December 2, 2003, at 11:09 AM, Jacob Davenport wrote: >John, how did you modify Newton's Method to solve a quadratic equation? Put the quadratic into this form: ax^2 + bx + c = 0 so x^2 = -(bx + c) / a Now use Newton's Method to find x. Newton's Method uses an initial guess, which can be *way* off, and a recursive procedure to find the answer. Make an initial guess G[n] for x. Keep popping it into this equation: G[n+1] = ((-bG[n] -c)/aG[n] + G[n] ) / 2 That averages two guesses of x, that's one for x and another for -(bx+c)/a/x (which *should* be equal to x in the end), and closes in after each iteration. After getting close enough (i.e. G[n] and G[n-1] are equal in whatever resolution you're using), plug -x as G[0] into the Method. If there are two solutions to the quadratic, that should immediately flush out the other, and the new answer should continue through the following iterations*. If there is only one solution it will pop up the previous answer. If the equation has NO solutions (or the solution involves a complex number?), the Method jumps around all over the place, never finding a stable result. Still testing it, but it works so far... I'm sure people must have figured this out before, especially since it's so basic and I don't fiddle with mathematics much; but I'm still pleased with my discovery. It's like finding a little magic spell. Of course, compared to the Quadratic Formula this method is like going around the barn to get in the front door, but hey, it was an enjoyable trip. * - For some two-solution quads, my computer sometimes settles on the second solution for about eight iterations, then falls off to the previously found x! I think it's because of rounding errors. But I can still tell when there's a second solution when the second is stable for a good long while. (I could just check the discriminant, but that's cheating. :) ) Oh! I just noticed Liam is on the bill (yuk yuk). Tear it apart, Liam! -- jc