Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Definea new function called mySqrt with one formal parameter defined in the parameter list. The parameter represents the number of which you will find the

Definea new function called mySqrt with one formal parameter defined in the parameter list. The parameter represents the number of which you will find the square root, you can call it n if you want.Include the input, output, and process below as docstrings in your function. You can use the parameter names provided above or pick your own. I listed them so that it would be easier to reference them in the text below. Newtons approach is an iterative guessing algorithm where the initial guess is n/2 and each subsequent guess is computed using the formula: newguess = (1/2) * (oldguess + (n/oldguess)).

1. Write the code to calculatethe initial guess andassignit to a variable called square_root.

2. Setup your for-loop header. As the number of times you iterate increases, the closer your approximation. I iterated 100 times in my solution. 2(a). Calculate the subsequent guesses using the formula: (1/2) * oldguess + (n/ oldguess). Use the update pattern with the square_root variable to store the values.

3. Return the square root.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Secrets Of Analytical Leaders Insights From Information Insiders

Authors: Wayne Eckerson

1st Edition

1935504347, 9781935504344

More Books

Students also viewed these Databases questions