Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

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

Students also viewed these Databases questions

Question

7. It is advisable to do favors for people whenever possible.

Answered: 1 week ago

Question

9. Power and politics can be destructive forces in organizations.

Answered: 1 week ago