\magnification=\magstep1 \vsize=9truein \hsize=6.5truein %\parindent=0.8truein \def\C{{\bf C}} \def\R{{\bf R}} \def\N{{\bf N}} \def\span{{\rm span}} \font\sc=cmcsc10 \font\smalltt=cmtt10 scaled840 \font\smseven=cmr7 scaled840 %verbatim environment \def\uncatcodespecials{\def\do##1{\catcode`##1=12 }\dospecials} \newcount\lineno %\def\listing#1{\par\begingroup\setupverbatim #1\endgroup} \def\setupverbatimc{\parindent=1truecm\tt \smalltt\baselineskip=10pt plus 1pt minus 1pt \def\par{\leavevmode\endgraf}\catcode`\`=\active\obeylines \uncatcodespecials\obeyspaces \everypar{\global\advance\lineno by 1\llap{\smseven\the\lineno\ \ }}} \def\setupverbatimb{\parindent=1truecm\global\lineno=0% \smalltt\baselineskip=10pt plus 1pt minus 1pt \def\par{\leavevmode\endgraf}\catcode`\`=\active\obeylines \uncatcodespecials\obeyspaces \everypar{\advance\lineno by 1{}}} \def\setupverbatim{\global\lineno=0\setupverbatimc} {\obeyspaces\global\let =\ } \def\beginverbatim{\par\begingroup\setupverbatim\doverbatim} {\catcode`\|=0\catcode`\\=12\catcode`|`=|active|gdef`{|relax|lq}% |obeylines|gdef|doverbatim^^M#1\endverbatim{#1|endgroup}} \def\beginverbatimb{\par\begingroup\setupverbatimb\doverbatim} \def\listing#1{\medskip \begingroup\setupverbatim\input#1\endgroup\medskip \noindent\ignorespaces} \def\listout#1{\medskip \begingroup\setupverbatimb\input#1\endgroup\medskip \noindent\ignorespaces} \def\macinput#1{{\catcode`\$=10\catcode`@=3 \input #1 }} \newcount\qnum\qnum=0 \def\qn{\advance\qnum by1\medskip\par\noindent\item{\the\qnum.}} \input epsf %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \qn [Kincaid and Cheney Problem 3.2\#4] \ Steffensen's method is given by the iteration $$ x_{n+1}=x_n-{f(x_n)\over g(x_n)} \qquad\hbox{where}\qquad g(x)={f\big(x+f(x)\big)-f(x)\over f(x)}. $$ Show this method is quadratically convergent under suitable hypothesis. \medskip\noindent Let $r$ be a solution such that $f(r)=0$ and $f'(r)\ne 0$. Moreover assume $|f''|$ is bounded in a neighborhood of $r$. We shall show that Steffensen's method is quadratically convergent provided that $x_0$ is sufficiently close to $r$. Consider the function $$ \kappa (x,\xi,\eta)= {f''(\xi)\big(f'(x) -{\textstyle {1\over 2}} f''(\eta)(x-r)\big)+f''(\eta) \over 2f'(x)+f''(\xi)f(x)}. $$ By assumption the limit supremum of $\big|\kappa(x,\xi,\eta)\big|$ exists as $x\to r$, $\xi\to r$ and $\eta\to r$. Let $C$ denote this limit and choose $\delta_1>0$ so small that $\big|\kappa(x,\xi,\eta)\big|\le 2C$ for every $x$, $\xi$ and $\eta$ such that $|x-r|<\delta_1$, $|\xi-r|<\delta_1$ and $|\eta-r|<\delta_1$. Choose $\delta_2>0$ so small that $|x-r|<\delta_2$ implies $2\big|f(x)\big|\le \delta_1$. Now let $$\delta=\min\Big\{{\delta_1\over 2},\delta_2,{1\over 2C}\Big\}.$$ Claim that if $x_0\in (r-\delta,r+\delta)$ then $x_n$ defined according to Steffensen's method satisfies $x_n\in (r-\delta,r+\delta)$ for all $n\in\N$. Let $x_0\in (r-\delta,r+\delta)$ and define $x_n$ according to Steffensen's method. By Taylor's theorem there exists $\xi_n$ between $x_n$ and $x_n+f(x_n)$ such that $$ f\big(x_n+f(x_n)\big)=f(x_n)+f'(x_n)f(x_n) +{\textstyle {1\over 2}}f''(\xi_n)f(x_n)^2. $$ Therefore $$ g(x_n)=f'(x_n)+{\textstyle {1\over 2}}f''(\xi_n)f(x_n).$$ It follows that $$ e_{n+1}=x_{n+1}-r=e_n-{f(x_n)\over f'(x_n)+{1\over 2}f''(\xi_n)f(x_n)} $$ where $e_n=x_n-r$. Using Taylor's series again yields $$ 0=f(r)=f(x_n-e_n) =f(x_n)-f'(x_n)e_n+{\textstyle {1\over 2}} f''(\eta_n)e_n^2 $$ for some choice of $\eta_n$ between $r$ and $x_n$. Therefore $$\eqalign{ e_{n+1} %&=e_n-{f'(x_n)e_n+{\textstyle {1\over 2}} f''(\eta_n)e_n^2 % \over f'(x_n)+{1\over 2}f''(\xi_n)f(x_n)} &=e_n-e_n{f'(x_n)+{\textstyle {1\over 2}} f''(\eta_n)e_n \over f'(x_n)+{1\over 2}f''(\xi_n)f(x_n)}\cr &=e_n-e_n{f'(x_n)-{1\over 2}f''(\xi_n)f(x_n) +{1\over 2}f''(\xi_n)f(x_n)+{\textstyle {1\over 2}} f''(\eta_n)e_n \over f'(x_n)+{1\over 2}f''(\xi_n)f(x_n)}\cr &=-e_n{ f''(\xi_n)f(x_n)+f''(\eta_n)e_n \over 2f'(x_n)+f''(\xi_n)f(x_n)}\cr &=-e_n{ f''(\xi_n)\big(f'(x_n)e_n -{\textstyle {1\over 2}} f''(\eta_n)e_n^2\big)+f''(\eta_n)e_n \over 2f'(x_n)+f''(\xi_n)f(x_n)}\cr &=-e_n^2 {f''(\xi_n)\big(f'(x_n) -{\textstyle {1\over 2}} f''(\eta_n)e_n\big)+f''(\eta_n) \over 2f'(x_n)+f''(\xi_n)f(x_n)} =-e_n^2\kappa(x_n,\xi_n,\eta_n). }$$ Claim that $x_n\in (r-\delta,r+\delta)$ for every $n\in\N$. For induction suppose $x_n\in (r-\delta,r+\delta)$. Since $\xi_n$ is between $x_n$ and $x_n+f(x_n)$ then $$|\xi_n-r|\le |\xi_n-x_n|+|x_n-r| \le |f(x_n)|+|x_n-r|<\delta_2+\delta\le\delta_1.$$ Since $\eta_n$ is between $x$ and $x_n$ then $$|\eta_n-r|\le\delta<\delta_1.$$ Thus $x_n$, $\xi_n$ and $\eta_n$ satisfy $|x_n-r|<\delta_1$, $|\xi_n-r|<\delta_1$ and $|\eta_n-r|<\delta_1$ so consequently $\big|\kappa(x_n,\xi_n,\eta_n)\big|<2C$. Therefore $$|x_{n+1}-r|=|e_{n+1}|\le 2Ce_n^2=2C|x_n-r|^2\le 2C\delta^2 <\delta.$$ This shows $x_{n+1}\in (r-\delta,r+\delta)$ and completes the induction. Moreover, we have shown that $x_n$ is quadratically convergent. \vfill\eject \qn [Kincaid and Cheney Problem 3.2\#6] \ To compute reciprocals without division, we can solve $x=1/R$ by finding a zero of the function $f(x)=x^{-1}-R$. Write a short algorithm to find $1/R$ by Newton's method applied to $f$. Do not use division or exponentiation in your algorithm. For positive $R$, what starting points are suitable? \medskip\noindent Differentiating yields $$f'(x)=-x^{-2}.$$ Therefore $$ \phi(x)=x-{f(x)\over f'(x)} =x+{x^{-1}-R\over x^{-2}} =x+x-R x^2=x(2-Rx) $$ leads to the iteration formula $x_{n+1}=x_{n}(2-R x_n)$. To determine what starting points $x_0$ are suitable we look for an interval centered at $1/R$ over which $|\phi'|$ is strictly less than 1. $$ \big|\phi'(x)\big|=|2-2Rx|<1 \qquad\hbox{implies}\qquad \Big|{1\over R}-x\Big|<{1\over 2R}. $$ Therefore any starting point $$ x_0\in \Big({1\over 2R},{3\over 2R}\Big) $$ is suitable. In fact, this interval can be extended to $$x_0\in\Big(0,{3\over 2R}\Big)$$ because if $x\in(0,1/2R]$ then $$ \phi(x)-x=x(2-Rx)-x=x(1-Rx) $$ implies $$ {x\over 2}\le\phi(x)-x<{1\over 2R}. $$ Consequently, if $x_0\in(0,1/2R]$, then $x_n$ form an increasing sequence of points that are eventually contained in the interval where $|\phi'|<1$. Similarly $$x_0\in\Big[{3\over 2R},{2\over R}\Big)\qquad\hbox{implies}\qquad x_1\in\Big(0,{3\over 4R}\Big].$$ It follows that the method iteration will converge for any $$x_0\in\Big(0,{2\over R}\Big).$$ We now procede to find a choice for $x_0$ that does not involve performing any divisions. Recall that $R$ is stored on the computer using a binary expansion of the form $$ R=\sum_{i=1}^{m} b_i 2^{n-i} =\sigma 2^n \qquad\hbox{where}\qquad \sigma\in[1/2,1). $$ Therefore taking $$ x_0=\sigma 2^{-n}<{1\over \sigma 2^{n}} = {1\over R} $$ provides a suitable initial condition by simply changing the sign of the exponent in the floating point representation while doing no division or exponentiation to the mantissa. The following C program implements this approach. \listing{newtdiv.c} The output is \listout{newtdiv.out} \vfill\eject \qn [Kincaid and Cheney Problem 3.2\#17] \ Which of the following sequences converge quadratically. \smallskip \centerline{a. $1/n^2$,\quad b. $1/2^{2^n}$,\quad c. $1/\sqrt n$,\quad d. $1/e^n$,\quad e. $1/n^n$} \medskip \noindent A sequence $x_n$ converging to a limit $L$, converges quadratically if there is a constant $C$ and an integer $N$ such that $|x_{n+1}-L|\le C |x_n-L|^2$ for every $n\ge N$. Since $L=0$ for each of the sequences in question and each sequence is moreover positive, then this inequality may be rewritten as $$ {x_{n+1}\over x_n^2}\le C\qquad\hbox{for every} \qquad n\ge N. $$ This inequality will hold for some $C$ and $N$ large enough if and only if $$ \limsup_{n\to\infty} {x_{n+1}\over x_n^2} $$ is bounded. We proceed as follows: \medskip $$ \limsup_{n\to\infty} {1/(n+1)^2\over (1/n^2)^2} =\lim_{n\to\infty} {n^4\over n^2+2n+1}=\infty $$ $$ \limsup_{n\to\infty} {1/2^{2^{n+1}}\over (1/2^{2^n})^2} =\lim_{n\to\infty} {4^{2^n}\over 4^{2^n}}=1 $$ $$ \limsup_{n\to\infty} {1/\sqrt{n+1}\over (1/\sqrt{n})^2} =\lim_{n\to\infty} {n\over\sqrt{n+1}}=\infty $$ $$ \limsup_{n\to\infty} {1/e^{n+1}\over (1/e^n)^2} =\lim_{n\to\infty} {e^{2n}\over e^{n+1}}= =\lim_{n\to\infty} e^{n-1}=\infty $$ $$ \limsup_{n\to\infty} {1/(n+1)^{n+1}\over (1/n^n)^2} =\lim_{n\to\infty} {n^{2n}\over (n+1)^{n+1}}\ge \lim_{n\to\infty} {n^{2n}\over (2n)^{n+1}}= \lim_{n\to\infty} {1\over 4}\Big({n\over 2}\Big)^n=\infty. $$ Therefore only $1/2^{2^n}$ converges quadratically while the others don't. \vfill\eject \qn [Kincaid and Cheney Computer Problem 3.2\#1] \ Write a computer program to solve the equation $x=\tan x$ by Newton's method. Find the roots nearest 4.5 and 7.7. \medskip\noindent The program is \listing{newtontan.c} and the output is \listout{newtontan.out} \vfill\eject \qn [Kincaid and Cheney Computer Problem 3.2\#8] \ Program the Newton algorithm in complex arithmetic and test it on these functions with the given starting points. \itemitem{a.} $f_1(z)=z^2+1,\qquad z_0=3+i$ \itemitem{b.} $f_2(z)=z+\sin z-3,\qquad z_0=2-i$ \itemitem{c.} $f_3(z)=z^4+z^2+2+3i,\qquad z_0=1$ \medskip\noindent We shall use the Maple code generation library to create the functions $\phi(z)=z-f(z)/f'(z)$ needed for Newton's iteration. The Maple script \listing{makephi.mpl} takes an expression $F$ and an integer $N$ and creates the file{\tt\ phiN.i }containing C code to compute $\phi$ in terms of $z$. The script can be used to generate code for the functions $f_n$ given in the problem with the commands \medskip \beginverbatimb $ maple -q -DN=1 -DF="z^2+1" makephi.mpl $ maple -q -DN=2 -DF="z+sin(z)-3" makephi.mpl $ maple -q -DN=3 -DF="z^4+z^2+2+3*I" makephi.mpl \endverbatim \medskip\noindent The resulting files are \listing{phi1.i} \listing{phi2.i} \listing{phi3.i} Notice that{\tt\ phi3.i }contains an optimization where $z^2$ is stored in a temporary variable. These files are included in our main program{\tt\ newtcomp.c }which is given by \listing{newtcomp.c} The output is \listout{newtcomp.out} \vfill\eject \qn [Kincaid and Cheney Computer Problem 3.2\#9] \ Use Steffensen's method to find the first 10 positive roots of the equation $x=\tan x$. \medskip\noindent First graph the equation $y=\tan x$ and $y=x$ to identify on what intervals the roots will be. The gnuplot script \listing{xtanx.plt} produces the output \centerline{\input xtanx.tex } \noindent There is root between each vertical asymptote. The first 10 positive roots satisfy $$x_n\in \Big({(2n-1)\pi\over 2},{(2n+1)\pi\over 2}\Big) \qquad\hbox{where}\qquad n=1,2,\ldots,10.$$ Steffensen's method requires the initial guess be very close to the correct root to converge because of the aymptotes. To overcome this problem we check whether each Steffensen's iterate remains in the interval where the $n$-th root is located. If it does not remain in the interval, then we take a bisection step and try again. The program is \listing{stefbisect.c} and the output is \listout{stefbisect.out} An alternative method is to invert the equations and work with $\arctan(y)$. This is implemented in the program \listing{stefatan.c} which produces the output \listout{stefatan.out} It is worth noting that this second method involves transforming the original problem into something easier to solve and is significantly more efficient than the first. \vfill\eject \qn [Kincaid and Cheney Problem 3.5\#1] \ Use Horner's algorithm to find $p(4)$ where $$ p(z)=3z^5-7z^4-5z^3+z^2-8z+2. $$ \medskip\noindent We arrange the calculation as $$ \vbox{\halign{ \hfil $#$\quad $|$&&\quad\hfil $#$\cr &3&-7&-5&1&-8&2\cr 4&&12&20&60&244&944\cr \noalign{\vglue2pt\hrule\vglue2pt} &3&5&15&61&236&946\cr}} $$ Therefore $p(4)=946$. \vfill\eject \qn [Kincaid and Cheney Problem 3.5\#5] \ For the polynomial $$ p(z)=3z^5-7z^4-5z^3+z^2-8z+2 $$ find a disk centered at the origin that contains all the roots. \medskip\noindent By the localization theorem all roots lie inside an open disk centered at the origin of radius $$\eqalign{ \rho&=1+|a_n|^{-1}\max\big\{\, |a_k| : k=0,1,\ldots, n-1\,\big\}\cr &=1+3^{-1}\max\{ 2, 8, 1, 5, 7\}=1+8/3=11/3. }$$ \vfill\eject \qn [Kincaid and Cheney Problem 3.5\#19] \ Prove that if $p$ is a polynomial of degree $n$ having real coefficients, then $$ (n-1)\big(p'(x)\big)^2\ge np(x)p''(x).$$ Assume that the roots are real. \def\P{{\cal P}}% \medskip\noindent We prove this statement by induction. Let $\P_n$ be the set of all polynomials of degree $n$ having real coefficient and real roots. \smallskip {\bf Base case:} If $n=1$ then the statement reduces to the fact that $0\ge 0$. \smallskip {\bf Induction step:} Suppose $(n-1)\big(p_n'(x)\big)^2\ge n p_n(x)p_n''(x)$ for every $p_n\in\P_n$. Let $p_{n+1}\in\P_{n+1}$. Claim that $n\big(p_{n+1}'(x)\big)^2\ge (n+1) p_{n+1}(x)p_{n+1}''(x).$ Let $r\in\R$ be a root of $p_{n+1}$. Then there is $p_n\in\P_n$ such that $$\eqalignno{ p_{n+1}(x)&=(x-r)p_n(x)\cr \noalign{\noindent and therefore} p_{n+1}'(x)&=p_n(x)+(x-r)p_n'(x)\cr p_{n+1}''(x)&=2p_n'(x)+(x-r)p_n''(x).\cr }$$ For notational simplicity write $p_n$ in place of $p_n(x)$ and so forth. Estimate using the induction hypothesis and completing the square to obtain $$\eqalign{ (n+1)p_{n+1}p_{n+1}'' &=(n+1)(x-r)p_n\big(2p_n'+(x-r)p_n''\big)\cr &=2(n+1)(x-r)p_n p_n' +(n+1)(x-r)^2p_n p_n''\cr &\le 2(n+1)(x-r)p_n p_n' +(n+1)(x-r)^2{n-1\over n}(p_n')^2\cr &=2(n+1)(x-r)p_n p_n' +{n^2-1\over n}(x-r)^2(p_n')^2\cr &=n\Big\{\big[(x-r)p_n'\big]^2+2p_n\big[(x-r)p_n'\big]\Big\}\cr &\qquad\qquad\qquad -{1\over n}\Big\{\big[(x-r)p_n'\big]^2 -2np_n\big[(x-r)p_n'\big]\Big\}\cr &=n\big((x-r)p_n'+p_n\big)^2-np_n^2 -{1\over n}\big((x-r)p_n'-np_n\big)^2+np_n^2\cr &=n\big((x-r)p_n'+p_n\big)^2 -{1\over n}\big((x-r)p_n'-np_n\big)^2\cr &\le n\big((x-r)p_n'+p_n\big)^2=n(p_{n+1}')^2. }$$ This completes the induction. \vfill\eject \qn [Kincaid and Cheney Computer Problem 3.5\#5] \ Write a computer routine that uses Newton's method and deflation for finding all roots of a polynomial. Test the routine using Wilkinson's polynomial $$ p_{20}(x)=\prod_{n=1}^{20} (x-n). $$ \medskip\noindent Using Newton's method to find a root of an arbitrary polynomial requires care in choosing the initial guess $x_0$. In the code that follows we use Theorem 3 in Kincaid and Cheney page 110 on the localization of polynomial roots to guide choices for the initial guess and to determine whether Newton's iteration has diverged. Let $\rho_{\rm max}$ be $\phi$ times the bound obtained by Theorem 3 where $\phi=(1+\sqrt 5)/2$ and $\rho_n=\mu \phi^n$ where $\mu$ is the unit roundoff error. Choose $N$ to be the largest integer such that $\rho_N\le \rho_{\rm max}$. The following heuristics are used to guess $x_0$. Since it is desired to find roots of smallest magnitude first, we always try $x_0=0$ as the first guess. If this doesn't work we guess randomly an $x_0$ inside a circle centered $\rho_n$ where $n=0,1,\ldots,N$ until a root is found. It is worth noting our strategy for guessing $x_0$ is simple, but may not lead to a root in all cases. If a certain maximum number of initial guesses $K$ has been tried without finding a root the program exits with an error. The program{\tt\ roots.c }is given by \listing{roots.c} and Wilkinson's polynomial{\tt\ wilkpoly.dat }is given by \listing{wilkpoly.dat} Running the program with the command \medskip \beginverbatimb $ ./roots