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.
|