Question: USE MATLAB 4. The divide and average method, a time-honored method for approximating the square root of any positive number a, can be formulated as
USE MATLAB
4. The divide and average" method, a time-honored method for approximating the square root of any positive number a, can be formulated as x +alx Write a well-structured M-file function based on the while...break loop structure to implement this algorithm. Use proper indentation so that the structure is clear. At each step estimate the error in your approximation as new X old Xnew Repeat the loop until is less than or equal to a value specified by the user. 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 example, the square root of-4 would return 2i. Test your program by evaluating a 0,2, 10 and -4 for-1x 104*
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
