User Tools

Site Tools


gibson:teaching:fall-2014:math445:lab4

Problem 1: Write a function x = newtonsearch(f, xguess) that finds the solution $x$ of the equation $f(x) == 0$ for an input function f and an initial guess xguess using the Newton search algorithm.

  1. Use a for loop to perform the Newton-search iteration. Take up to ten Newton steps.
  2. Use a if statement inside the for loop to test if either $|f(x)| < 2 \epsilon$ or $|dx| < \epsilon$. 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 $\epsilon$.

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

\begin{eqnarray*}
x^3 - 7x - 13 = 0
\end{eqnarray*}

(b) Find the cube root of 54. (Hint: devise an equation whose answer is $x = \sqrt[3]{72}$.)

(c) Find an x for which $\sqrt{3-x^2} = x \tan x$.

Hint: find good initial guesses for the Newton search by plotting each function and roughly estimating an $x$ position at which $f(x)$ 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 $T(x,t)$ at distance $x$ below the surface and time $t$ after the beginning of a cold spell is given approximately by

\begin{eqnarray*}
\frac{T(x,t) - T_s}{T_i-T_s} = \erf\left(\frac{x}{\sqrt{2 \alpha t}}
\end{eqnarray*}

where

  • $T_s$ is the constant surface temperature during the cold spell.
  • $T_i$ is the initial soil temperature before the cold spell started.
  • $\alpha$ is the thermal conductivity of the soil.
  • $\erf$ is the error function, which can be computed with the built-in Matlab function erf.

If $x$ is in meters and $t$ is in seconds, the $\alpha = 0.138 \cdot 10^{-6} m^2/s$. Let $T_i=20 C$ and $T_S = -15 C$ and recall that water freezes at $T = 0 C$.

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.

gibson/teaching/fall-2014/math445/lab4.txt · Last modified: 2014/10/25 05:01 by gibson