2. Edmund Halley (the astronomer famous for discovering Halley\'s comet) invente
ID: 3601116 • Letter: 2
Question
2. Edmund 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 A as follows: Start with an initial guess s,. The new approximation is then given by These two calculations are repeated until some convergence is met: However, if you have a bad guess, or a extremely high convergence, it could take quite a while to converge. Therefore, make a maximum number of iterations allowable within the while loop before quitting it, and returning a value of -1' as the output value. Create a function called my sqrt that approximates the square root of a number It should have three inputs: 1. the number you are trying to find the square root of (4) 2. the initial guess (x) 3. the convergence criteria () 4. the maximum number of iterations allowed before giving up (maxit) Your function will return the approximation for the square root of A. You must use a while loop to get full credit. Test your script by i. Approximating the square root of 5 (A -5) ii. Comparing it to the value calculated with the built-in MATLAB function, sqrt iii. Use format long to compare results. iv. Start with an initial guess, x-2 v. Use a convergence criteria, -0.001.Explanation / Answer
image wasnot clear please provide clear Image so that we can provide you complete solution
Thanking you
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.