Problem

The “divide and average” method, an old-time method for approximating the square root of a...

The “divide and average” method, an old-time method for approximating the square root of any positive number a, can be formulated as

Write a well-structured M-file function based on the while...break loop structure to implement this algo­rithm. Use proper indentation so that the structure is clear. At each step estimate the error in your approximation as

Repeat the loop until ε  is less than or equal to a specified value. Design your program so that it returns both the result and the error. Make sure that it can evaluate the square root of numbers that are equal to and less than zero. For the latter case, display the result as an imaginary number. For exam­ple, the square root of –4 would return 2i. Test your program by evaluating a = 0, 2, 10 and –4 for ε = 1 × 10–4.

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 3