Write a program that uses Newton's Method to find the square root of a number. The...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a program that uses Newton's Method to find the square root of a number. The number will be entered by the user. Your program's only output wili be its square root. The algorithm for Newton's method follows: Read x from the user Initialize gues s to x / 2 While guess is not good enough do Update guess to be the average of guess and x/ guess Display guess as the square root of the number For the puproses of this exercise, we will define "good enough" as the absolute value of the difference between guess guess and x being less than 10 *-12. Write a program that uses Newton's Method to find the square root of a number. The number will be entered by the user. Your program's only output wili be its square root. The algorithm for Newton's method follows: Read x from the user Initialize gues s to x / 2 While guess is not good enough do Update guess to be the average of guess and x/ guess Display guess as the square root of the number For the puproses of this exercise, we will define "good enough" as the absolute value of the difference between guess guess and x being less than 10 *-12.
Expert Answer:
Answer rating: 100% (QA)
Solution include float absolutefloat num To make the ... View the full answer
Related Book For
Microsoft Visual C# An Introduction to Object-Oriented Programming
ISBN: 978-1337102100
7th edition
Authors: Joyce Farrell
Posted Date:
Students also viewed these finance questions
-
Write the code to find the square root of the number stored in the second element in a one-dimensional double array named mathNumbers. Display the result on the computer screen.
-
Write the code to find the square root of the number stored in the first row, third column in a two-dimensional double array named mathNumbers. Display the result on the screen.
-
A matrix S is the square root of another T if S2 = T. Show that any nonsingular matrix has a square root.
-
Warnerwoods Company uses a periodic inventory system. It entered into the following purchases and sales transactions for March. Date Activities Units Acquired at Cost Units Sold at Retail Mar. 1...
-
The Vehicle Inventory and Use Survey (VIUS) has been conducted by the U.S. government to provide information on the number of private and commercial trucks in each state. The stratified random...
-
Market demand is P = 64 - (Q/7). A multiplant monopolist operates three plants, with marginal cost functions: a) Find the monopolist's profit-maximizing price and output at each plant. b) How would...
-
Does the fact that selling is included as part of the promotional mix weaken or strengthen its role as a sub-element of marketing?
-
Stillwater Video Company, Inc., produces and markets two popular video games, High Range and Star Boundary. The closing account balances on the companys balance sheet for last year are as follows:...
-
Must be in context to labor and employee relation and not in general Five Key Cases [Wm. Scott, Steel Equip., Renaud, Meiorin, Fraser Lakes] that LR pros refer to (noting what they are used for...
-
The variables x and u are related by ux = 2. The variable y is dependent on x. a. Show that b. Show also that reduces to 16d 2 y/du 2 8 dy/du + y = u and find the general solution in the form y =...
-
Your client owns $7,000 of Stock A with a beta of 1.8 and $5,000 of Stock B with a beta of 1.1. If the market rises by 22%, this portfolio would be expected to rise by approximately what percentage?...
-
In a three-car crash, car A bumps into the back end of car \(B\), which then goes forward and bumps into the back end of car C. Is the distance that car B moves between the collisions the same in all...
-
How can you tell from the motion of the center of mass of an isolated system whether the reference frame from which the motion is measured is inertial?
-
You are sitting, facing rearward, in the bed of a pickup truck and hop off while the truck is moving forward. When you land, do you move toward or away from the truck \((a)\) from the point of view...
-
A two-stage rocket is traveling at \(4000 \mathrm{~m} / \mathrm{s}\) before the stages separate. The \(3000-\mathrm{kg}\) first stage is pushed away from the second stage with an explosive charge,...
-
Moving sidewalks are commonplace at large airports, but you must use caution getting on and off them. What should you do to make the transition easy when stepping onto one of these sidewalks? When...
-
How does functionalism contribute to our understanding of social institutions such as family, education, religion, and government, by examining their roles in maintaining social order, stability, and...
-
Saccharin is an artificial sweetener that is used in diet beverages. In order for it to be metabolized by the body, it must pass into cells. Below are shown the two forms of saccharin. Saccharin has...
-
If necessary, create a new project named Introductory20 Project and save it in the Cpp8\Chap14 folder. Also create a new source file named Introductory20.cpp. Create a program that saves prices in a...
-
Which of the following concatenates the contents of a string variable named city, a comma, a space, and the contents of a string variable named state and then assigns the result to a string variable...
-
Use the code shown in Figure 6-34 to answer What will the code in Figure 6-34 display when the id variable contains the number 4? a. Janet b. Jerry c. Mark d. Sue switch (id) { case 8: cout < <...
-
As the Human Resources manager for Beautiful Bottles Pty Ltd, a company manufacturing bottles for the food industry, you have been asked by the accountant to help reduce the product costs of each...
-
Innovative Computers Pty Ltd produces laptops. Each laptop contains a rechargeable battery and LCD screen. Batteries and screens are purchased from an outside supplier for \($192\) and \($300\) each,...
-
As the marketing manager for Smart Fones Industries Pty Ltd you have asked the accountant what it costs to make the SFI2026 model as you want to set a price for the phone. A similar phone produced by...
Study smarter with the SolutionInn App