Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I calculate non-natural logarithms in Racket?

I am aware of racket's log function, which computers the natural logarithm of a number. I am trying to find the logarithms of numbers raised to arbitrary bases. In other words, instead of this:

> (log 9)
2.1972245773362196

I would like to do something similar to this:

> (logarithm 3 9)
2

Is there a function anyone knows about either builtin to Racket or available in a module from PLaneT I can use like this?

like image 454
Alex V Avatar asked Feb 07 '13 01:02

Alex V


1 Answers

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

(/ (log 9) (log 3))
like image 181
nneonneo Avatar answered Oct 10 '22 04:10

nneonneo