![]() | ![]() | ![]() | Exercise 1 - Logarithms | Documentation and user's manual | Table of contents | OCaml programs |
First consider mathematics.
Given a positive real number a other than 1 the domain of the logarithm function loga (logarithm in base a) is the set of all positive real numbers and loga(x) = ln(x) / ln(a) for any x in this domain (where ln denotes the natural logarithm function).
Now consider programming.
Using float
values to represent real numbers write the type of the functional value that computes loga given a positive real number a other than 1.
Then write a definition of this functional value (using log
whose type is float -> float
and which represents the natural logarithm function).
Name this functional value log_in_base
.
Use log_in_base
to write values that represent log10 and log2(1024) and write their types.
![]() | ![]() | ![]() | Exercise 1 - Logarithms | Documentation and user's manual | Table of contents | OCaml programs |