The following code implements Newton's algorithm for finding the square root of a number using repetition: n = 17 # we want the square root of 17 for example # our guess is 4 initially # we want to...


The following code implements Newton's algorithm for finding<br>the square root of a number using repetition:<br>n = 17<br># we want the square root of 17 for<br>example<br># our guess is 4 initially<br># we want to stop when we are this close<br>g = 4<br>error = 0.0000000001<br>while abs(n - (g**2)) > error:<br>g = g - ((g**2 - n)/(2 * g))<br># g holds the square root of n at this point<br>Implement this algorithm in a function sqRoot (n), that returns<br>the square root using recursion.<br>Assume that the function will be called with positive numbers<br>only.<br>Note: Your initial guess cannot be zero!<br>

Extracted text: The following code implements Newton's algorithm for finding the square root of a number using repetition: n = 17 # we want the square root of 17 for example # our guess is 4 initially # we want to stop when we are this close g = 4 error = 0.0000000001 while abs(n - (g**2)) > error: g = g - ((g**2 - n)/(2 * g)) # g holds the square root of n at this point Implement this algorithm in a function sqRoot (n), that returns the square root using recursion. Assume that the function will be called with positive numbers only. Note: Your initial guess cannot be zero!

Jun 08, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here