How to calculate unnatural logarithms in Racket?

I know the racket function log, which uses the natural logarithm of a number. I am trying to find the logarithms of numbers raised for arbitrary reasons. In other words, instead:

> (log 9)
2.1972245773362196

I would like to do something similar to this:

> (logarithm 3 9)
2

Is there any function that anyone knows about the built-in Racket or available in the module from PLaneT, can I use this?

+5
source share
2 answers

Use math: log k n = ln n / ln k:

(/ (log 9) (log 3))
+15
source

Racket 6.9.0.1 added a second argument for arbitrary bases. log kn can now be written as (log n k).

(/ (log n) (log k)), , , .

.

+1

All Articles