Exercise: Newton on x=cos²x

Full application of Newton's method to x=cos²x from x0=0.3: table of iterates, residuals, increments and ACOC tending to the theoretical order 2.

Setup

Solve x=cos2xx=\cos^2 x, that is, f(x)=cos2xx=0f(x)=\cos^2 x-x=0, with initial estimate x0=0.3x_0=0.3, stopping criterion xk+1xk<109|x_{k+1}-x_k|<10^{-9} and at most 20 iterations. Newton needs the derivative:

f(x)=2cosxsinx1=sin2x1f'(x)=-2\cos x\,\sin x-1=-\sin 2x-1

Iterations

iterxkx_kf(xk)|f(x_k)|xkxk1|x_k-x_{k-1}|ACOC
10.6915700.0982930.39157n/a
20.6419895.3803·10⁻⁴0.049581n/a
30.6417142.1349·10⁻⁸2.7463·10⁻⁴2.5143
40.6417143.3663·10⁻¹⁷1.0898·10⁻⁸1.9505
50.6417148.3691·10⁻³⁵1.7184·10⁻¹⁷1.9999
Newton iterations from x0=0.3x_0=0.3 (the last two rows require extended-precision arithmetic).