On Tue, Jan 5, 2010 at 5:25 PM, Carl Witthoft <carl@witthoft.com> wrote:

> quote:
> > There are certainly formulas for solving polynomials numerically up to
> 4th degree non-iteratively, but you will almost certainly get better results
> using iterative methods.
>


> I must be missing something here.  Why not use the analytic formulas for
> polynomials below 5th degree?  Once you do so, your answer is as precise as
> the level of precision you enter for the coefficients.


Why do you believe that? Are you assuming you can perform *exact*
arithmetic?  Did you read the references I gave?

* George Forsythe, How do you solve a quadratic equation?
* Yves Nievergelt, How (Not) to Solve Quadratic Equations

They show that that isn't even true for quadratic equations without a lot of
care.

Let's try a cubic:

     p =  1000000*x^3-998000*x^2-1001999*x+999999

That factors exactly over the integers to:

        (x-1001)*(x-1000)*(x-999)

but plugging the floating-point coefficients (which are exactly
representable as floats) into (one version of) the cubic formula (using
Maxima), I get the roots

     x = 966.1329834413779+58.65086897690403i
     x = 966.1329834413779-58.65086897690403i
     x = 1067.734033117244

On the other hand, using an interative approach, I get:

    x = 999.0000000278754
    x = 999.9999926817675
    x = 1001.000007290357

Which looks better to you?

            -s

	[[alternative HTML version deleted]]

