[Ecls-list] log(complex) inaccurate for some values

Juan Jose Garcia-Ripoll jjgarcia at users.sourceforge.net
Sun Apr 13 09:01:01 UTC 2008

The following does not imply anything. I will look into this, but I
presume one needs special functions to handle the high precision case,
as in CMUCL. I also wonder how many digits of accuracy this
systematically brings in other cases.


# /afs/ipp/common/bin/matlab -v 2007b -nojvm

                              < M A T L A B >
                  Copyright 1984-2007 The MathWorks, Inc.
                         Version (R2007b)
                               August 9, 2007

  To get started, type one of these: helpwin, helpdesk, or demo.
  For product information, visit www.mathworks.com.

>> format long
>> log(1.000000001e0+1e-5*1i)
ans =
      1.050000086326139e-09 + 9.999999989666666e-06i

On Fri, Apr 11, 2008 at 3:59 AM, Raymond Toy <toy.raymond at gmail.com> wrote:
> I reported this bug with clisp, but ecl has the same issue:
>  (log #c(1.000000001d0 1d-5)) ->
>  #C(1.0500000857748893d-9 9.999999989666666d-6)
>  But with clisp's long-float, the true answer is closer to:
>  (setf (long-float-digits) 256)
>  (log (coerce #c(1.000000001d0 1d-5) '(complex long-float))) ->
>  #C(1.0500000821378709167497674762372261576369237933558916554150445317294087
>  7702943L-9
>  9.9999999896666666683134966416887953589434016059498897741294881863894719391
>  568L-6)
>  CMUCL returns #C(1.0500000821378709d-9 9.999999989666666d-6)
>  I'm guessing here, but I suspect ecl is computing the real part as
>  log(sqrt(x^2+y^2)).  This loses accuracy if x is near 1 and y is small
>  (or vice versa).
>  Ray

Facultad de Fisicas, Universidad Complutense,
Ciudad Universitaria s/n Madrid 28040 (Spain)

More information about the ecl-devel mailing list