====== Differences ====== This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
gibson:teaching:fall-2014:math445:lab4 [2014/10/20 10:59] gibson |
gibson:teaching:fall-2014:math445:lab4 [2014/10/25 05:01] (current) gibson |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | **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. | + | **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. |
- | - Use a ''for'' loop to perform the Newton-search iteration $x_{n+1} = x_n + dx$. Take up to ten Newton steps. | + | - Use a ''for'' loop to perform the Newton-search iteration. Take up to ten Newton steps. |
- | - Use a ''if'' statement inside the ''for'' loop to test if either $|f(x)| < tolerance$ or $|dx| < tolerance$. If so, use a ''break'' statement to terminate the iteration and return from the function. For our purposes $10^{-7}$ is a decent choice for $tolerance$. | + | - 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$. |
| | ||
Line 11: | Line 11: | ||
plugging the answer ''x'' back into ''f'' and verifying that ''f(x)'' is approximately zero. | plugging the answer ''x'' back into ''f'' and verifying that ''f(x)'' is approximately zero. | ||
- | **(a)** Find an ''x'' for which $x^3 - 7x - 13 = 0$. | + | **(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}$.) | **(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{4-x^2} = x \tan x$. | + | **%%(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 | Hint: find good initial guesses for the Newton search by plotting each function and roughly |