Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

"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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spatial Databases A Tour

Authors: Shashi Shekhar, Sanjay Chawla

1st Edition

0130174807, 978-0130174802

More Books

Students also viewed these Databases questions

Question

State the uses of job description.

Answered: 1 week ago

Question

Explain in detail the different methods of performance appraisal .

Answered: 1 week ago

Question

Why do HCMSs exist? Do they change over time?

Answered: 1 week ago