Question

To find the square root of x, make a guess g. If g**2 is close enough...

To find the square root of x, make a guess g. If g**2 is close enough to x, then report g as the square root. Otherwise, make a new guess which is the average of g and x/g. Check the new guess and keep repeating until the square of the guess is close enough to x. Suppose x is 99 and the first guess is 5. Using this algorithm, how many guesses will it take until the guess squared is within 1 of x? Use Python to answer this question.

Homework Answers

Answer #1

Python code:

#initializing x as 99
x=99
#initializing guess g as 5
g=5
#initializing guess count as 0
count=0
#looping till absolute value of g**2-x is less than 1
while(abs(g**2-x)>=1):
#finding new guess
g=(g+x/g)/2
#incrementing count
count+=1
#printing number of guess
print("Number of guess:",count)


Screenshot:


Output:

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
for a and b use x= Square root x and g(x)=x/2 a)      Find the arc length...
for a and b use x= Square root x and g(x)=x/2 a)      Find the arc length of the curve of f(x) for 0≤x≤4.                   b)      Find the surface area of the solid of revolution revolved about the x-axis of             f(x) for 0≤x≤4.
Find the derivative of the function G(x)=1/2x^4+5x^3−x^2+6.8x+ square root of 3
Find the derivative of the function G(x)=1/2x^4+5x^3−x^2+6.8x+ square root of 3
For a C program hangman game: Create the function int setup_game [int setup_game ( Game *g,...
For a C program hangman game: Create the function int setup_game [int setup_game ( Game *g, char wordlist[][MAX_WORD_LENGTH], int numwords)] for a C program hangman game. (The existing code for other functions and the program is below, along with what the function needs to do) What int setup_game needs to do setup_game() does exactly what the name suggests. It sets up a new game of hangman. This means that it picks a random word from the supplied wordlist array and...
QUESTION 1 Advanced Security Inc. was hired by the Treasury Bank Inc. for securing their systems....
QUESTION 1 Advanced Security Inc. was hired by the Treasury Bank Inc. for securing their systems. The first thing they did was implement the best practice if separation of domains. As a result of this The bank had to get a new domain name. any change made in the records points to only one party who could have made that change. If you are a technical person, you must have office in a particular area of the building. accessing outside...
STRICT DOWNVOTE IF NOT DONE FULLY, WILL REPORT ALSO IF COPY PASTED OR MODIFIED ANSWER Develop...
STRICT DOWNVOTE IF NOT DONE FULLY, WILL REPORT ALSO IF COPY PASTED OR MODIFIED ANSWER Develop a class, using templates, to provide functionality for a set of recursive functions. The functions specified as recursive must be written recursively (not iterativly). The UML class specifications are provided below. A main will be provided. Additionally, a make file will need to be developed and submitted. ● Recursion Set Class The recursion set template class will implement the template functions. recursionSet -length: int...
STRICT DOWNVOTE IF NOT DONE FULLY, WILL REPORT ALSO IF COPY PASTED OR MODIFIED ANSWER Develop...
STRICT DOWNVOTE IF NOT DONE FULLY, WILL REPORT ALSO IF COPY PASTED OR MODIFIED ANSWER Develop a class, using templates, to provide functionality for a set of recursive functions. The functions specified as recursive must be written recursively (not iterativly). The UML class specifications are provided below. A main will be provided. Additionally, a make file will need to be developed and submitted. ● Recursion Set Class The recursion set template class will implement the template functions. recursionSet -length: int...
2. SECURING THE WORKFORCE Diversity management in X-tech, a Japanese organisation This case is intended to...
2. SECURING THE WORKFORCE Diversity management in X-tech, a Japanese organisation This case is intended to be used as a basis for class discussion rather than as an illustration of the effective or ineffective handling of an administrative situation. The name of the company is disguised. INTRODUCTION In light of demographic concerns, in 2012, the Japanese government initiated an effort to change the work environment in order to secure the workforce of the future. Japan is world renowned for its...
Case 13 ✍ It Was Really So Simple Background Information Brenda Galway leaned back in her...
Case 13 ✍ It Was Really So Simple Background Information Brenda Galway leaned back in her chair, sighed heavily, and slowly rubbed her eyes in big circular motions. “I don’t need all this aggravation,” she thought to herself. She had just finished reviewing the report she had requested from her new employee, Bill Stanley. The entire report was incorrect and would have to be redone. Brenda supervised Unit B of the Audit Department. The Unit B team had earned the...
I've posted this question like 3 times now and I can't seem to find someone that...
I've posted this question like 3 times now and I can't seem to find someone that is able to answer it. Please can someone help me code this? Thank you!! Programming Project #4 – Programmer Jones and the Temple of Gloom Part 1 The stack data structure plays a pivotal role in the design of computer games. Any algorithm that requires the user to retrace their steps is a perfect candidate for using a stack. In this simple game you...
Medication errors by a nurse happen every day. In fact, adverse drug events account for almost...
Medication errors by a nurse happen every day. In fact, adverse drug events account for almost 700,000 ER visits and 100,000 hospitalizations every year. In many cases, these errors can lead to medical malpractice claims made against individual practitioners or even against entire health care teams. The majority of medication errors are preventable, and knowing how they happen can teach you what to be aware as future nurses. These five real-life medication error case studies that involved nurses. While these...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT