Write a program that implements newton''s method

Assignment Help Basic Computer Science
Reference no: EM131302442

You have seen that the math library contains a function that computes the square root of numbers. In this exercise, you are to write your own algorithm for computing square roots. One way to solve this problem is to use a guess-and-check approach. You first guess what the square root might be and then see how close your guess is. You can use this information to make another guess and continue guessing until you have found the square root (or a close approximation to it). One particularly good way of making guesses is to use Newton's method. Suppose x is the number we want the root of and guess is the current guessed answer. The guess can be improved by using as the next guess.

Write a program that implements Newton's method. The program should prompt the user for the value to find the square root of (x) and the number of times to improve the guess. Starting with a guess value of x/2, your program should loop the specified number of times applying Newton's method and report the final value of guess. You should also subtract your estimate from the value of math.sqrt(x) to show how close it is.

Reference no: EM131302442

Questions Cloud

What is the result of ok''ing the binary value : Assume odd parity is being used when transmitting 8-bit bytes. What is the value of the parity bit (either 0 or 1) for the byte below. and explain how you arrived at your answer?
What has been the most relevant part of the course so far : What has been the most relevant part of the course so far? What are the top two or three things you are taking away and how might you use them?
Write a six page paper on apples code of conduct : Write a six page paper on Apples Code of Conduct. List specific changes that Apple has made to its Code of Conduct in recent years. Provide at least one example of each change.
Prepare a competitive profile matrix : Identify two colleges or universities in your state that compete directly with your institution.- Prepare a Competitive Profile Matrix that includes your institution and the two competing institutions.
Write a program that implements newton''s method : Write a program that implements Newton's method. The program should prompt the user for the value to find the square root of (x) and the number of times to improve the guess. Starting with a guess value of x/2, your program should loop the specifi..
Examples of reasons for project closures : Provide examples of reasons for project closures aside from normal project completion. How do these reasons affect closure processes for a project manager?
How life insurance does capital retention approach suggest : Assuming a 5% rate of return, how much life insurance does the Capital Retention Approach suggest? (You may find some hints from your textbook, page 217).
Problem regarding the information governance : Using the Internet or Strayer University databases, research health care organizations / providers that have recently had a significant information technology failure, and complete this assignment.
Make it draw squares instead of circles : Print a message on the window "Click again to quit" after the loop, and wait for a final click before closing the window.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  What are labor costs in ms project

What are labor COSTS in MS project? How do we assign labor COSTS to a task in MS Project? Describe AND provide a screen shot of the steps.

  Can you do this if the interface id is 48 bits

Consider fields that would approach maximum allocation only under unusual circumstances. Can you do this if the Interface ID is 48 bits?

  Intrusion detection systems

According to the textbook, Intrusion Detection Systems (IDS), which can be categorized as Host IDS (HIDS) and Network IDS (NIDS), is a means of providing real-time monitoring. Compare and contrast HIDS and NIDS, and provide at least one (1) exa..

  What is schottky diode

What is Schottky diode? Why is it also called Hot-Carrier diode? How does it differ in construction from a normal P-N junction diode?

  The project consists of multiple phases

The project consists of multiple phases.

  Mathematical function categories

How do logical and lookup functions differ from mathematical functions? Are there any other types of non mathematical function categories?

  Values for the items in the risk register

Recommend reasonable values for items in risk register for this asset and threat, and give justifications for your choices.

  Change the number of parameters an operator takes

"You cannot change the number of parameters an operator takes." What does this really mean and what are implications of this when you use polymorphism in your programs? Try to provide specific examples and 600 words.

  Eplain how have these trends challenged the health care

evaluate the impact of at least two major trends that occurred in the u.s. health care system during the twentieth

  Evaluation and collection of data for the intersection

Evaluation and collection of data for the intersection at Yorba-Linda Blvd. and Association Rd. Distribution of project activities equally among all the team members

  What is the proper syntax of declaring a c-style string

Take a look at the following program -- #include using namespace std; int main( ) { char name[100]; //declare a character array cout > name; cout

  Create a gantt chart illustrating the project tasks

Create a Gantt chart illustrating the project tasks. Create a system diagram illustrating the equipment and connections required for this project (use Microsoft Visio or a similar software package).

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd