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 as follows:
Start with an initial guess The new approximation is then given by
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
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 and comparing it to the value calculated with the builtin MATLAB function, sqrt
Note: or utilize a notation method analogous to the indicial notation that we use in MatLab. Therefore could be considered synonymous with Likewise for and
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
