Exercise 2 - An accumulatorExercisesExercise 1 - LogarithmsDocumentation and user's manualTable of contentsOCaml programs

Exercise 1 - Logarithms

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.


Latest update : October 5, 2006
This document was translated from LaTeX by Hyperlatex 2.5, which is not the latest version of Hyperlatex.

Exercise 2 - An accumulatorExercisesExercise 1 - LogarithmsDocumentation and user's manualTable of contentsOCaml programs