Approximate a root of function surfaceAreaPrime given its first derivative SurfaceAreaDoublePrime, an initial guess (xGuess) and an error limit.

What will be an ideal response?


```
double newton (double xGuess, double okError, int& converges)
{
double xN, xNplus1, absDiff;
int iter = 0;

xN = xGuess;
do {
++iter;
xNplus1 = xN -
surfaceAreaPrime(xN) / surfaceAreaDoublePrime(xN);
absDiff = fabs(xN-xNplus1);
xN = xNplus1;
} while (absDiff >= okError && iter < MAX_ITER);

if (absDiff < okError) {
converges = 1;
return xN;
} else {
cout << endl << "Newton's method did not converge to a "
<< "minimum surface area in " << MAX_ITER << endl
<< "iterations using an initial guess of " << xGuess
<< " centimeters." << endl;
converges = 0;
return xGuess;
}
}

double surfaceArea (double r)
{
return (2 * M_PI * r * r + 4000 / r);
}

double surfaceAreaPrime (double r)
{
return (4 * M_PI * r - 4000 / (r * r));
}

double surfaceAreaDoublePrime (double r)
{
return (4 * M_PI + 8000 / (r * r * r));
}

```

Computer Science & Information Technology

You might also like to view...

Repeat Exercise 10 of Chapter 13 to use a menu instead of an Accept button. The menu should contain an “Add Name” item that has the same function as the Accept button.

What will be an ideal response?

Computer Science & Information Technology

There are no font sets that include only symbols

Indicate whether the statement is true or false

Computer Science & Information Technology

Supporters of neutral locations for interviews believe that it _____.

A. makes the interviewee feel comfortable during the meeting B. gives the interviewee easy access to supporting material that might be needed C. keeps interruptions to a minimum so people can concentrate fully D. gives the interviewee an opportunity to take calls during the interview

Computer Science & Information Technology

Fred finds a packet that his protocol analyzer shows with both PSH and URG set. What type of packet is he looking at, and what do the flags mean?

A. A UDP packet; PSH and URG are used to indicate that the data should be sent at high speed B. A TCP packet; PSH and URG are used to clear the buffer and indicate that the data is urgent C. A TCP packet; PSH and URG are used to preset the header and indicate that the speed of the network is unregulated D. A UDP packet; PSH and URG are used to indicate that the UDP buffer should be cleared and that the data is urgent

Computer Science & Information Technology