Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Q 1 ) In this question, you asked to write a MATLAB code for the following algorithm. This algorithm describes an iterative method called the

Q1) In this question, you asked to write a MATLAB code for the following algorithm. This algorithm
describes an iterative method called the Babylonian method for finding the square root of a given
positive number S.
Algorithm 1 The Babylonian square-root algorithm
Require: Initial positive guess x0, a prespecified tolerance S, maximum number of iterations.
Set i=0
xi+1=xi+Sxi2
Calculate |a|=|xi+1-xixi+1|100%
if The stopping criterion is satisfied or the maximum number of iterations is reached then
Stop
else
i=i+1
Go back to Step 2.
end if
Output: x**=xi+1~~S2
DO the following tasks:
a) Write a MATLAB code for the Algorithm 1 using the FOR-END loop command. Use the ta-
ble command to print the results. Remember: you need to use the break command to stop the
algorithm when |a|S.
b) Write a MATLAB code for the Algorithm 1 using the WHILE-END loop command. Use the
table command to print the results.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions