Question: One method for calculating square-roots directly is called the Babylonian method, where an equation is run iteratively (over and over) until the output converges to

One method for calculating square-roots directly is called the Babylonian method, where an equation is run iteratively (over and over) until the output converges to the desired result. The iterative equation Babylonian method of square-roots is given below: 1 X Yn- + 1 1-1 where x is the original value to be square-rooted, yn and yn-1 are the current and previous iteration values of the square-root-estimate, respectively, and n is the iteration number. Write a MATLAB function which accepts two inputs, and generates one output. The first input should be the value to be square-rotted. The second input will be the number of iterations to run with the Babylonian equation above. The output should be the value of the nth iteration. Include comments which provide a detailed response to the "help" command. Before you can process the first iteration, you must set the initial condition of the output value. In other words, the value of yo must be defined. You can set the initial condition yo to be half of the input variable x. You can use a loop to iterate the equation, where the iteration number, n, can be your loop counter. Below are some sample outputs: >> mysqrt(2,0) ans 1.0000 >> mysqrt(2,1) ans = 1.5000
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
