subject
Computers and Technology, 01.03.2021 21:30 mem8163

The Babylonian method is very simple. Given a number n and a guess at its square root x, we make the observation that if x is an overestimate of the square root of n, then n / x will be an underestimate of the square root. In contrast, if x is an underestimate of the square root of n then n / x will be an overestimate (convince yourself of this with a bit of algebra). From this, it is reasonable to expect that the average of x and n / x is a better estimate of the square root than we started with. For this algorithm, your program should prompt the user for a number to take the square root of (you should allow floating point or integer values) and an initial guess, and apply the Babylonian method, printing out each estimate of the square root until the change in estimates is less than 1e-8.

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 21:00
In this lab, you add a loop and the statements that make up the loop body to a c++ program that is provided. when completed, the program should calculate two totals: the number of left-handed people and the number of right-handed people in your class. your loop should execute until the user enters the character x instead of l for left-handed or r for right-handed. the inputs for this program are as follows: r, r, r, l, l, l, r, l, r, r, l, x variables have been declared for you, and the input and output statements have been written.
Answers: 3
question
Computers and Technology, 22.06.2019 10:10
3. bob is arguing that if you use output feedback (ofb) mode twice in a row to encrypt a long message, m, using the same key each time, it will be more secure. explain why bob is wrong, no matter what encryption algorithm he is using for block encryption (15 points).
Answers: 3
question
Computers and Technology, 22.06.2019 12:10
1. package newton’s method for approximating square roots (case study 3.6) in a function named newton. this function expects the input number as an argument and returns the estimate of its square root. the script should also include a main function that allows the user to compute square roots of inputs until she presses the enter/return key. 2. convert newton’s method for approximating square roots in project 1 to a recursive function named newton. (hint: the estimate of the square root should be passed as a second argument to the function.) 3. elena complains that the recursive newton function in project 2 includes an extra argument for the estimate. the function’s users should not have to provide this value, which is always the same, when they call this function. modify the definition of the function so that it uses a keyword parameter with the appropriate default value for this argument, and call the function without a second argument to demonstrate that it solves this problem. 4. restructure newton’s method (case study 3.6) by decomposing it into three cooperating functions. the newton function can use either the recursive strategy of project 1 or the iterative strategy of case study 3.6. the task of testing for the limit is assigned to a function named limitreached, whereas the task of computing a new approximation is assigned to a function named improveestimate. each function expects the relevant arguments and returns an appropriate value. 5. a list is sorted in ascending order if it is empty or each item except the last one is less than or equal to its successor. define a predicate issorted that expects a list as an argument and returns true if the list is sorted, or returns false otherwise. (hint: for a list of length 2 or greater, loop through the list and compare pairs of items, from left to right, and return false if the first item in a pair is greater.)
Answers: 1
question
Computers and Technology, 23.06.2019 03:30
How can you repin an image on your pinterest pin board a. click on the "repin" button b. click on the "add pin" button c. click on the "upload a pin" button d. click on the "save pin" button.
Answers: 2
You know the right answer?
The Babylonian method is very simple. Given a number n and a guess at its square root x, we make the...
Questions
question
Physics, 12.11.2020 14:00
question
Mathematics, 12.11.2020 14:00
question
Mathematics, 12.11.2020 14:00
question
Mathematics, 12.11.2020 14:00
question
Mathematics, 12.11.2020 14:00
question
Mathematics, 12.11.2020 14:00
question
Mathematics, 12.11.2020 14:10