COMPUTER PROBLEMS 1.3

1 (a) Check the derivatives of \(f(x)=\sin x-x\) to see that \(f(0)=f'(0)=f''(0)=0\) and \(f'''(0)=-\cos 0=-1\), giving multiplicity \(3\).

1 (b) brentq returns \(x_a=-1.7531084141128772\times 10^{-8}\). The forward error is \(1.7531084141128772\times 10^{-8}\) and the backward error is reported as \(|f(x_c)|=0\). This means the true backward error is less than machine epsilon.


3 (a) The Python command
>> xc = brentq(lambda x:2.*x*np.cos(x)-2.*x+np.sin(x**3),-0.1,0.2)
returns \(x_c=0.00018135027239607221\). The forward error is \(|x_c-r|=0.00018135027239607221\) and the backward error is reported as \(|f(x_c)|=-1.565121604046725e-20\).

3 (b) The bisection method with starting interval \([-0.1,0.2]\) stops after 13 steps, giving \(x_c=-0.00006103\). Neither method can determine the root \(r=0\) to more than about 3 correct decimal places.


5 To use (1.21), set \(f(x)=(x-1)(x-2)(x-3)(x-4)\), \(\epsilon=-10^{-6}\) and \(g(x)=x^6\). Then near the root \(r=4\), \(\Delta r\approx-\epsilon g(r)/f'(r)=4^6\times 10^{-6}/6\approx0.00068267\). According to (1.22), the error magnification factor is \(|g(r)|/|rf'(r)|=4^6/24\approx170.7\). brentq on the interval \([3.9, 4.1]\) returns the approximate root \(4.000682511531738\), close to the approximation \(4.00068267\) given by (1.21).