Problem 1: Write a function x = newtonsearch(f, xguess)
that finds the solution of the equation for an input function f
and an initial guess xguess
using the Newton search algorithm.
for
loop to perform the Newton-search iteration. Take up to ten Newton steps.if
statement inside the for
loop to test if either or . If so, use a break
statement to terminate the iteration and return from the function. For our purposes 1e-07
is a decent choice for the value of tolerance . Problem 2:
Test your Newton-search algorithm by solving the following problems. Check your answers by
plugging the answer x
back into f
and verifying that f(x)
is approximately zero.
(a) Find an x
for which
(b) Find the cube root of 54. (Hint: devise an equation whose answer is .)
(c) Find an x
for which .
Hint: find good initial guesses for the Newton search by plotting each function and roughly estimating an position at which is zero.
Problem 3: Use your Newton-search algorithm to solve the following problem:
Utility companies must avoid freezing water mains in cold weather. If we assume uniform soil conditions, the temperature at distance below the surface and time after the beginning of a cold spell is given approximately by
where
erf
.If is in meters and is in seconds, the . Let and and recall that water freezes at .
Use your Newton-search algorithm to determine how deep a water main must be buried so that it will not freeze until at least 60 days' exposure to these conditions.