This site is a static rendering of the Trac instance that was used by R7RS-WG1 for its work on R7RS-small (PDF), which was ratified in 2013. For more information, see Home. For a version of this page that may be more recent, see ComplexLog in WG2's repo for R7RS-large.

Complex­Log

cowan
2014-12-28 08:03:19
6history
source

Complex logarithm

Guy Steele's three-part smoke test for Common Lisp involves evaluating (atanh -2). Traditionally, a Lisp passes if it returns a complex number; if it returns the correct complex number, so much the better. The atanh function is not provided in R7RS-small, so I defined it as follows:

(define (atanh x) (/ (- (log (+ 1 x)) (log (- 1 x))) 2))

(Note: KSi already defines atanh and will not allow its redefinition.)

Returns -0.5493061443340549+1.5707963267948966i, the correct complex number: Racket, Gauche, MIT, Chicken with the numbers egg, Scheme48, Guile, Kawa, Chibi, Chez, Vicare, Larceny, Ypsilon, IronScheme, STklos, KSi, S7, Spark, Sagittarius

Returns NaN (i.e. it is attempting to use a real-number log function) when the argument is 2, but returns the correct complex number when the argument is 2.0+0.0i: scsh, SISC, Mosh

Returns an incorrect complex number: SCM

No support for log of negative numbers: UMB, Owl Lisp

No complex numbers: plain Chicken, Bigloo, Ikarus, NexJ, SigScheme, Shoe, TinyScheme, Scheme 9, Dream, RScheme, BDC, XLisp, Rep, Schemik, Elk, VX, Oaklisp, Llava, SXM, Sizzle, FemtoLisp, Dfsch, Inlab.