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 g = 4 # our guess is 4 initially error...


Python


We are trying to find the square root using RECURSION. Look at the instructions.


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

Jun 07, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here