s-news
[Top] [All Lists]

Roots of negative numbers

To: "'ripley@stats.ox.ac.uk '" <ripley@stats.ox.ac.uk>
Subject: Roots of negative numbers
From: "Sorkin, John (NIA/IRP)" <SorkinJ@grc.nia.nih.gov>
Date: Wed, 19 Sep 2001 16:51:14 -0400
Cc: "'s-news@lists.biostat.wustl.edu '" <s-news@lists.biostat.wustl.edu>
Professor Brian D Ripley indicated how we can get the square root of a
negative number:

> sqrt(-9+0i)
[1] 1.83691e-016+3i

He noted that the unexpected real part, i.e. 1.83691e-016, was a result of
rounding. I wonder if someone could explain why
sqrt(-9+0i) results in rounding error where as 

> sqrt(9)
[1] 3
> 
does not result in an error. Looking at 
sqrt() was not helpful (at least to me):

 sqrt()
> sqrt
function(x)
x^0.5
> 

I am running SPlus 2000 Professoinal Release 3 on a Windows NT box

Thanks

John Sorkin

P.S. I understand that the error is very small. Never the less, I am curious
about the etiology of the error.

<Prev in Thread] Current Thread [Next in Thread>