An early application of recursion can be found in the seventeenth century in John Napier’s method of finding logarithms. The method was as follows:
start with two numbers n, m and their logarithms logn, logm if they areknown;while not done for a geometric mean of two earlier numbers find a logarithm which is an arithmetic mean of two earlier logarithms, that is, logk = (logn+logm)/2 for k =; proceed recursively for pairs (n,
) and (
, m);
For example, the 10-based logarithms of 100 and 1,000 are numbers 2 and 3, the geometric mean of 100 and 1,000 is 316.23, and the arithmetic mean of their logarithms, 2 and 3, is 2.5. thus, the logarithm of 316.23 equals 2.5. The process can be continued: the geometric mean of 100 and 316.23 is 177.83, whose logarithm is equal to (2 + 2.5)/2 = 2.25.
a. Write a recursive function logarithm() that outputs logarithms until the difference between adjacent logarithms is smaller than a certain small number.
b. Modify this function so that a new function logarithmOf() finds a logarithm of a specific number x between 100 and 1,000. Stop processing if you reach a number y such that y – x < ϵ for some ϵ.
c. Add a function that calls logarithmOf() after determining between what powers of 10 a number x falls so that it does not have to be a number between 100 and 1,000.
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.