Skip to main content

Exercises 3.8 Exercises

1.
Let \(p(x) = 816x^3-3835x^2+6000x-3125\text{.}\)
  1. Find all exact roots of \(p\text{.}\) (Hint: \(p\) is divisible by \((3x-5)\)).
  2. Plot \(p\) with Python in the interval \([1.43,1.71]\text{.}\) (Hint: you can use x=linspace(1.43,1.71) together with the plot function).
  3. What do you get via Newton's method with \(x_0=1.5\text{?}\) (Hint: replace the function and the initial point in our Newton code).
  4. What do you get via the secant method with \(x_0=1\) and \(x_1=2\text{?}\) (Hint: replace the function and the initial points in our secant code).
  5. What do you get via the bisection method applied to the interval \([1,2]\text{?}\) (Hint: replace the function and the interval endpoints in our bisection code)
2.
How many solutions does \(\tan x=x\) have? Find the first 5 digits of the smallest three positive roots with any of the three methods we learned. (Hint: plot the function and use Newton's method with suitable initial points).
3.
Use Newton's Method to estimate the value of \(\pi\) to ten decimal places. (Hint: choose any trigonometric equation having \(\pi\) as solution and choose an appropriate initial point).
4.
Implement in Python the following algorithm that combines the bisection method with the secant method to find a root of a function \(f(x)\text{:}\)
  1. Fix a tolerance \(\varepsilon>0\text{.}\)
  2. Choose the initial points \(x_0,x_1\) so that \(f(x_0)\cdot f(x_1)<0\text{.}\) This ensures that \(f\) has a root in \(I_1=[x_0,x_1]\text{.}\)
  3. Execute one step of the secant method: \(x_2=x_0-f(x_0)\frac{x_1-x_0}{f(x_1)-f(x_0)}\text{.}\)
  4. Either \(f(x_0)\cdot f(x_2)<0\) or \(f(x_1)\cdot f(x_2)<0\) (just as we discussed in the bisection method, the option \(f(x_2)=0\) does not happen in practice!).
  5. Say, for discussion sake, that \(f(x_0)\cdot f(x_2)<0\text{.}\) Then there must be a root in \(I_2=[x_0,x_2]\text{,}\) so now apply the secant method to the interval \(I_2\)
  6. By repeating steps b-e, you get a sequence of intervals \(I_1,I_2,\dots,I_{n-1},I_n\text{.}\) Stop when the length of \(I_n\) is smaller than \(2\varepsilon\text{.}\)
Use your implementation of this algorithm to find any root of \(f(x) = x\sin x-1.2\) with \(\varepsilon=10^{-10}\) in the interval \([-5,5]\) and compare your result using the root SciPy function.

Remarks:
  1. Either one of the two endpoints of \(I_n\) are an approximation of a root of \(f(x)\) within \(\varepsilon/2\text{.}\)
  2. This algorithm is robust as the bisection method (it always finds a root) and it converges as fast as the secant method.
  3. You can assemble this code by putting together pieces of the bisection and secant codes in 3.1 and 3.3.