Question: Write code and solve in Matlab Edmond Halley ( the astronomer famous for discovering Halley's Comet ) invented a fast algorithm for computing the square

Write code and solve in Matlab
Edmond Halley (the astronomer famous for discovering Halley's Comet) invented a fast algorithm for computing the square root of a number, A. Halley's algorithm approximates A2 as follows:
Start with an initial guess x1. The new approximation is then given by
yn=1Axn2
xn+1=xn8(15-yn(10-3yn))
These two calculations are repeated until some convergence criterion, (epsilon), is met. (Note: a convergence criterion is some sufficiently small number used to determine if the estimate is changing significantly with each iteration. In this situation you could use epsilon =0.00001
|xn+1-xn|
Write a MATLAB program that utilizes a for loop to approximate the square root of a number. The program should have two user defined inputs, the number to determine the square root of, and the initial guess.
One way to stop the loop when some condition is satisfied is to use an if statement to test the criteria and the term break, both within the loop, as demonstrated in class. Incorporate this tool in your loop so it stops when the convergence criterion is satisfied.
Test your function by approximating the square root of 5 and comparing it to the value calculated with the built-in MATLAB function, sqrt.
Note: yn or xn+1 utilize a notation method analogous to the indicial notation that we use in MatLab. Therefore yn could be considered synonymous with y(n). Likewise for xn+1 and x(n+1).
Write code and solve in Matlab Edmond Halley (

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!