Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Divide and average, an old-time method for approximating the square root of any positive number a, can be formulated as x = x + a/x/2
"Divide and average", an old-time method for approximating the square root of any positive number "a", can be formulated as x = x + a/x/2 Write a MATLAB function to implement this algorithm. At each step estimate the error in your approximation as epsilon = |x_new - x_old/x_new| Repeat the loop until epslion is less than or equal to a specified tolerance. 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 where i is square root - 1 Details about the MATLAB function: Function Name: sqrtApp Inputs: a, tol a: Function sqrtApp approximates the square root of number a. tol: Error of the approximation has to be less than a user-defined tolerance tol. Outputs: sqrt_a. EApp sqrt_a: Approximation of square root of a. EApp: Error of the approximation
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started