Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

/** * Determines the number of iterations of Newton's method * required to approximate the square root of x within * the given bound. Newton's

/** * Determines the number of iterations of Newton's method * required to approximate the square root of x within * the given bound. Newton's method starts out by * setting the initial approximate answer to x. * Then in each iteration, answer is replaced by * the quantity (answer + x / answer) / 2.0. * The process stops when the difference between * x and (answer * answer) is strictly less than * the given bound err. The method * returns the number of iterations required. * The given value x must be non-negative. *

* For example, given x = 10 the first three iterations * of Newton's method produce the approximate values * 5.5, 3.66, and 3.20. Those three values squared are * 30.29, 13.39, and 10.21, respectively. * Therefore countIterations(10, 1.0) * returns 3, since it takes 3 iterations to get the result 10.21 * that is within 1.0 of x. * On the other hand, countIterations(10, 200) returns 0, * since 10 * 10 = 100 is already within 200 units of x = 10. * @param x * value whose square root is to be approximated * @param err * given bound for the approximation * @return * number of iterations required to get an approximation * whose square is within the given bound of x */ public static int countIterations(double x, double err) { // TODO return 0; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Filing And Computer Database Projects

Authors: Jeffrey Stewart

2nd Edition

007822781X, 9780078227813

More Books

Students also viewed these Databases questions

Question

Discuss the impact of technology on marketing activities.

Answered: 1 week ago