Question: The function sqrt from the header file can be used to find the square root of a nonnegative real number. Using Newtons method, you can

The function sqrt from the header file can be used to find the square root of a nonnegative real number. Using Newtons method, you can also write an algorithm to find the square root of a nonnegative real number within a given tolerance as follows: Suppose x is a nonnegative real number, a is the approximate square root of x, and epsilon is the tolerance. Start with a = x.

a. If |a2 - x| epsilon, then a is the square root of x within the tolerance; otherwise:

b. Replace a with (a2 + x) / (2a) and repeat Step a in which |a2 - x| denotes the absolute value of a2 - x. Write a recursive function to implement this algorithm to find the square root of a nonnegative real number. Also, write a program to test your function.

Turn in your source code file and one or more screen shots showing the results of your testing.

After completing this project you will show that you can

Identify the base case(s) and general case in a recursive algorithm

Utilize tail recursion in the construction of a recursive algorithm

Construct a recursive algorithm that does not use global variables

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!