home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!wupost!crcnis1.unl.edu!tssi!backbone!backbone!wayne
- From: wayne@backbone.uucp (Wayne Schlitt)
- Newsgroups: comp.lang.c
- Subject: Re: 9th order polynomial
- Date: Thu, 31 Dec 1992 04:44:30 GMT
- Organization: The Backbone Cabal
- Lines: 53
- Sender: wayne@backbone (Wayne Schlitt)
- Message-ID: <WAYNE.92Dec30224430@backbone.uucp>
- References: <1992Dec10.154522.15893@lambda.msfc.nasa.gov>
- <1992Dec14.214016.149@ondec.lonestar.org>
- <1992Dec29.103955.4864@spillman.uucp>
- NNTP-Posting-Host: helios.unl.edu
- In-Reply-To: tye@spillman.uucp's message of Tue, 29 Dec 1992 10: 39:55 GMT
-
- In article <1992Dec29.103955.4864@spillman.uucp> tye@spillman.uucp (E. Tye McQueen) writes:
- > )
- > ) for (temp=d_src, accum=1.0, i=i_pow; i ; i>>=1, temp*=temp)
- > ) if (i&1) accum *= temp;
- > ) return(accum);
- > [...]
- >
- > Note that the order in which you perform the operations to
- > compute a polynomial value can greatly affect the accuracy
- > of your calculation [ ... ]
- >
- > It's been too long so I can't recall whether computing it as
- >
- > ((((a*x+b)*x+c)*x+d)*x+e)*x+f
- >
- > was a particularly good or particularly bad method. [ ... ]
- >
- > Note that if a*x is almost equal to -b then this method
- > probably yields very poor results [ ... ]
-
- if a*x aprox equals -b then a*x^n aprox equals -b*x^(n-1), so either
- way, you will loose gobs of precision. The "missing" information is
- the least significant digits and they weren't stored anyway. When you
- compute x^n and store it in a register, you are going to be missing
- _lots_ of least significant bits, where as if you multiply and
- accumulate, you don't loose as many if things cancel.
-
- As an example, assume that we have 4 digits of accuracy in the
- floating point arithmetic:
-
- x = 7.301
- a = 2.001
- b = -14.59
- c = 9.300
-
- then a*x = 14.61 and a*x + b = .02000
-
- the result of (a*x+b)*x+c = 9.446
-
- the result of a*x^2+b*x+c = (2.001 * 53.30) + (-14.59 * 7.301) + 9.300 = 9.500
-
- the real result should be: 9.440916601
-
-
-
-
- It's been a while since I studied this type of
- problem real hard too, but I think that the (a*x+b)*x+c method will
- typically give as good a result as you can get.
-
-
-
- -wayne
-