Problem

An early application of recursion can be found in the seventeenth century in John Napier’s...

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.

Step-by-Step Solution

Request Professional Solution

Request Solution!

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.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 5
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT