Vorige Mail
Nächste Mail
Unformatiert/Volle Header
Übersicht 10 Tage
Betreff
Datum
Thread
Autor
Von: Mirsad Todorovac
Betreff: Complex_SqRt bug
Datum: 14.1.2002, 14:53:38
On Mon, 14 Jan 2002, Emil Jerabek wrote:
> Joe da Silva wrote:
> > OK, if you're happy that the code is correct ... I guess I just don't
> > understand what the "a := Abs(Im(z)) / (2 * b)" statement does ...
>
> That's easy. Let u+iv=\sqrt{x+iy}. Then (u+iv)^2=x+iy, i.e. y=2uv. (The code makes
> either a:=u and b:=v, or a:=v and b:=u, depending on the sign of x. Both "a := ..."
> assignments in the "if" statement are mathematically equivalent, but
> "SqRt ((a - Abs (Re (z))) / 2)" is too inexact if |y|<<|x|, since it computes a _small_
> number as a difference of two _big_ numbers.)
I guess this is because with 16-digit precision double floating-point numbers
things like
(1e20 + 1 - 1 == 1e20)
fail ....
Also,
(1 + 0.1 + ... + 1/(10^n) == 1/(10^n) + ... + 0.1 + 1)
... can fail - the right hand side calculation is more precise if both
are done left-to-right.
But it can be that GNU libm on Linux is doing it in the order shown on
left hand side, since by using 'long double' intermediate results and
adding Taylor series for cos(x) I have achieved _exactly the same_ square
error sum of
sum (x - acos(cos(x )))^2
i=1..n i i
with my Taylor series as with original libm's cos(x)!!!!
If the sums of squares of errors are exactly the same over a wide range of
parameters, my guess is that they're using the same Taylor series, and
that they're adding it from larger to smaller series member -- yes, as you
guessed: IN LESS PRECISE ORDER!
Now, could it be that GNU libm on x86-*-linux is just using Intel FPU's
result, and that FPU on x86 chips is suffering from this imprecision?
Any ideas?
Mirsad
--
This message has been made up using recycled ideas and language constructs.
No tree has been cut nor animal harmed in process of making it.
Visit http://www.hungersite.com/, save one CHILD from DYING!!!
Vorige Mail
Nächste Mail
Unformatiert/Volle Header
Übersicht 10 Tage
Betreff
Datum
Thread
Autor
| Autor | Betreff | Datum |
|---|---|---|
| Emil Jerabek | Complex_SqRt bug | 14.1.2002, 13:55:03 |
Hinweis: Diese Seite enthält Informationen, die nicht vom Betreiber dieser Website, sondern von den Autoren der archivierten Mails stammen. Der Betreiber dieser Website ist nicht für den Inhalt dieser Informationen verantwortlich. Die weitere Verwendung dieser Informationen bedarf des Einverständnisses des jeweiligen Autors.
Sofern WWW-Adressen (URLs) in den archivierten Mails als Hyperlinks hervorgehoben werden, so geschieht dies ausschließlich zur Annehmlichkeit für den Leser. Der Inhalt der auf diese Weise angelinkten Webseiten spiegelt nicht notwendigerweise die Meinung des Betreibers dieser Webseite oder der Autoren der archivierten Mails wider. Der Betreiber dieser Webseite ist nicht für den Inhalt solcher Webseiten verantwortlich. Diese Seiten sind ausdrücklich nicht als Teil des Inhalts dieser Seite zu betrachten, sondern lediglich als Referenzen.
Diese Seite wurde erzeugt von Crystal 0.999 (Linux 2.4.27/i686).