Optional base argument for LOG (and friends) Jorgen Schaefer (13 May 2006 10:38 UTC)
Re: Optional base argument for LOG (and friends) Aubrey Jaffer (16 May 2006 02:48 UTC)
Re: Optional base argument for LOG (and friends) John Cowan (23 May 2006 13:40 UTC)

Re: Optional base argument for LOG (and friends) Aubrey Jaffer 16 May 2006 02:48 UTC

 | From: Jorgen Schaefer <xxxxxx@forcix.cx>
 | Date: Sat, 13 May 2006 12:38:46 +0200
 |
 | It would be nice if the LOG procedure of R5RS would allow an
 | optional second argument, BASE, for the basis to which the
 | logarithm is calculated. This is the behavior from Common Lisp, and
 | the implementation is trivial - but I don't see a reason why the
 | base procedure shouldn't accept a BASE argument.
 |
 | The implementation for R5RS is trivial, of course:
 |
 | (define log
 |   (let ((ln log))
 |     (lambda (x . basel)
 |       (if (null? basel)
 |           (ln x)
 |           (/ (ln x)
 |              (ln (car basel)))))))
 |
 | Taylor Campbell noted that it would be cleaner to have the base as
 | the first argument, and provide a more "intuitively" named LN
 | procedure for the natural logarithm, i.e. (LOG B Z) and (LN Z).

(LOG B X) is more consistent with mathematical usage, but breaks
Scheme precedent.  To break the tie I would look to Common-Lisp and
have the second argument be the base.

Also, (log x base) == (/ (log x) (log base)) has the same orientation
of division as (atan x1 x2) == (atan (/ x1 x2)).