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

90.2K

Verified Solution

Question

Advance Math

The “divide and average” method, an old time method forapproximating the square root of any positive number a, can beformulated as

x = (x + a/x) / 2

Write a well-structured M-file function based on the while…breakloop structure to implement this algorithm. At each step estimatethe error in your approximation as

? = abs(( Xnew ? Xold )/Xnew

Repeat the loop until e is less than or equal to a specifiedvalue. Design your program so that it returns both the result andthe error. Make sure that it can evaluate the square root ofnumbers that are equal to and less than zero. For the latter case,display the result as an imaginary number. Test your program byevaluating a = 0, 2, 10 and -4 for ? = 1×10?4. Hint: This issimilar to the IterMeth function discussed in class.

Answer & Explanation Solved by verified expert
3.9 Ratings (719 Votes)
Matlab code for finding square root of a numberclear allclose    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students