You have seen that the math library contains a function that computes the square root of...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
You have seen that the math library contains a function that computes the square root of numbers. 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 computing the next guess as: guess + 2 x 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. You have seen that the math library contains a function that computes the square root of numbers. 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 computing the next guess as: guess + 2 x 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.
Expert Answer:
Answer rating: 100% (QA)
python import math def newtonsmethodsqrtx numiterations guess x ... View the full answer
Related Book For
Numerical Methods With Chemical Engineering Applications
ISBN: 9781107135116
1st Edition
Authors: Kevin D. Dorfman, Prodromos Daoutidis
Posted Date:
Students also viewed these programming questions
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
List three specific parts of the Case Guide, Objectives and Strategy Section (See below) that you had the most difficulty understanding. Describe your current understanding of these parts. Provide...
-
How is it that a state, or any state, such as Oregon, can offer more provisions under FMLA (OFLA) than then the federal rule of FMLA does?
-
Consider an ideal air-standard diesel cycle where the state before the compression process is 14 lbf/in 2, 63 F and the compression ratio is 20. Find the maximum temperature (by iteration) in the...
-
Consumer Reports listed the price (in dollars) and power (in cold cranking amps) of auto batteries. We want to know if more expensive batteries are generally better in terms of starting power. Here...
-
Consider the following cash flow profile and assume MARR is 10 percent/year. a. What does Descartes' rule of signs tell us about the IRR(s) of this project? b. What does Norstrom's criterion tell us...
-
Refinancing of Short-Term Debt On December 31, 2010, Santana Company has $7,000,000 of short-term debt in the form of notes payable to Golden State Bank due in 2011. On January 28, 2011, Santana...
-
An aluminum-alloy rod has a length of 9.2293 cm at 20.00C and a length of 9.2767 cm at the boiling point of water. (a) What is the length of the rod at the freezing point of water? (b) What is the...
-
Schedule the final exams for Math 115, Math 116, Math 185, Math 195, CS 101, CS 102, CS 273, and CS 473, using the fewest number of different time slots, if there are no students taking both Math 115...
-
Powder Company spent $240,000 to acquire all of Sawmill Corporation's stock on January 1, 20X2. On December 31, 20X4, the trial balances of the two companies were as follows: Powder Company Sawmill...
-
What type of networking opportunities are available via your college or university, or entrepreneurial-minded organizations in the city or town that you live in, which could be helpful to you in your...
-
From the following information prepare trading and profit and loss account of M/s Indian sports house for the year ending December 31, 2005. Adjustments 1. Closing stock was Rs.45,000. 2. Provision...
-
Explain why recruiting a well-known and highly respected board of directors lends legitimacy to a firm.
-
Charlie Berry, Shelly Jones, Nancy Harder, Keith Hawkins, Jennifer Atwood, and Cliff Barnes are all experienced software engineers. For some time, theyve been talking about starting a companythe six...
-
Spend some time studying Kim Levine, the homemaker who created Wuvit, a pillow filled with 100 percent natural grain. Describe how the Wuvit was created and the steps that Levine took to bring it to...
-
Design a welded box section axial compression member, the steel is Q235B. Column height 9m, hinged at the top and fixed at the bottom. The standard value of permanent load under axial pressure is...
-
From a medical tourist perspective, compare Shouldice with the traditional hospital in terms of the key factors of competition. Using Table 15-3, why would Shouldice attract patients from outside the...
-
Write a MATLAB program to do LU decomposition for the matrix in Example 2.12. Data from Example 2.12: Use the built-in MATLAB solver to find the solution to 2 4 X1 BAGHA TH 4 1 2 2 -2 -3 X3 1 3 -2...
-
Write the determinant of the following 33 matrix A as a sum of the determinants of 2 2 matrices using co-factor expansion on the third row (i = 3): A = 6 3 5 215 23 2
-
Using the LU decomposition in Problem 2.32, determine the value of x 2 for Ax = b if the forcing function is Data from Problem 2.32: In LU decomposition, determine the missing value of L for 5 --[:]...
-
Powerhouse Ltd purchased machinery on 2 January 2019, at a cost of $800 000. The machinery is depreciated using the straightline method over a useful life of 8 years with a residual value of $80 000....
-
The purchases and sales of Big Flower Pty Ltd of one brand of lawn fertiliser for the year ended 31 December 2019 are contained in the schedule below. The selling price up to 30 June was $12 per unit...
-
In groups of four or five, consider the following information. On 1 July 2019, Stevenson Pty Ltd, a proprietary company with three shareholders, acquired some property by issuing 100 000 shares to...
Study smarter with the SolutionInn App