This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
|
gibson:teaching:spring-2016:math445:lab7 [2016/03/07 10:11] gibson created |
gibson:teaching:spring-2016:math445:lab7 [2016/03/12 06:39] (current) gibson |
||
|---|---|---|---|
| Line 5: | Line 5: | ||
| * learn the most widely-used algorithm for solving nonlinear equations | * learn the most widely-used algorithm for solving nonlinear equations | ||
| * solve a practical, real-world problem involving a nonlinear equation | * solve a practical, real-world problem involving a nonlinear equation | ||
| + | * learn about anonymous functions | ||
| * gain more experience in programming with ''for'' loops and ''if'' statements | * gain more experience in programming with ''for'' loops and ''if'' statements | ||
| Line 13: | Line 14: | ||
| ''xguess'' using the Newton search algorithm. | ''xguess'' using the Newton search algorithm. | ||
| - | - Use a ''for'' loop to perform the Newton-search iteration $x_{n+1} = x_n + \Delta x$. Take up to ten Newton steps. | + | Your Newton search algorithm should |
| - | - Use an ''if'' statement inside the ''for'' loop to test if either $|f(x)| < \epsilon$ | + | |
| - | or $|\Delta x| < \epsilon$ for some specified tolerance $\epsilon$. If either condition is true, | + | 1. Use a ''for'' loop to perform the Newton-search iteration $x_{n+1} = x_n + \Delta x$. Take up to ten Newton-search iterations. |
| - | use a ''break'' statement to terminate the iteration and return from the function. For our | + | |
| - | purposes $\epsilon = 10^{-7}$ is a decent choice. | + | 2. Use an ''if'' statement inside the ''for'' loop to test if either $|f(x)| < \epsilon$ or $|\Delta x| < \epsilon$ for some specified tolerance $\epsilon$. |
| + | |||
| + | 3. If either of those conditions is true, use a ''break'' statement to terminate the iteration and return from the function. For our purposes $\epsilon = 10^{-7}$ is a decent choice. | ||
| ---- | ---- | ||
| Line 47: | Line 50: | ||
| where | 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, and | ||
| - | * $\erf$ is the {\it error function}, computed by the built-in Matlab function ''erf''. | ||
| - | If $x$ is in meters and $t$ is in seconds, the $\alpha = 0.138 \times 10^{-6} \; m^2/s$. | + | * $T_s$ is the constant surface temperature during the cold spell, |
| - | Let $T_i= 20\,C$ and $T_S = -15\,C$, and recall that water freezes at $T = 0\,C$. | + | * $T_i$ is the initial soil temperature before the cold spell started, |
| + | * $\alpha$ is the thermal conductivity of the soil, and | ||
| + | * $\erf$ is the //error function//, computed by the built-in Matlab function **erf**. | ||
| + | |||
| + | If $x$ is in meters and $t$ is in seconds, the thermal conductivity of soil is | ||
| + | $\alpha = 0.138 \times 10^{-6} \; m^2/s$. | ||
| + | Let $T_i= 20\,C$ and $T_S = -15\,C$, and recall that water freezes at $T(x,t) = 0\,C$. | ||
| Use your Newton-search algorithm to determine how deep a water main must be | 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 | buried so that it will not freeze until at least 60 days' exposure to these | ||
| conditions. | conditions. | ||
| + | |||