Exercises of zeros of nonlinear equations

Contents

For solving in IPython, we use the following commands and packages:

In [1]:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
import scipy.optimize as op

We also use the file (library) containing the functions defined in the last lab (bisection1, bisection2, bisection3, newton1, newton2, secant1 and secant2)

In [2]:
import libNonlinearEq as ne

Exercise 1

Find the real roots of $x^3 − 5.2x^2 − 5.5x + 9.8 = 0$ using the bisection method:

  • Draw a plot containing all the roots.
  • Give intervals satisfying the conditions of Bolzano's theorem.
  • Giva an approximation to the roots.
  • Chack your approximations using the python function op.ridder.

Exercise 2

Find all the positive solutions of $\sin x - 0.1 x=0$ using Newton's method with $tol = 10^{-3}$. Check your results with the python function op.newton.

Exercise 3

  • Use Newton's method and the four basic operations (addition, substraction, multiplication and division) to compute $\sqrt[3]{75}$ with $tol = 10^{-6}$. Give the number of iterations.
  • Use now the bisection method and give the number of iterations.
  • Starting from the same interval than in the bisection method, solve now with the secant method, and give the number of iterations.
  • Clasify the results in terms of the number of iterations.

Exercise 4

  • Draw a plot of $f(x)=\cosh x \cos x-1$ in $[0,10]$.
  • Check from the plot that the smaller positive root is in the interval $[4,5]$.
  • Check that Newton's method does not converge to this root if $x_0=4$.
  • Find an initial guess for which the method converges and compute it with $tol=10^{-6}$.

Exercise 5

Use Newton' method to approximate, with $tol=10^{-6}$, the roots of $$(a)~x=1-e^{-2x},\quad(b)~x\ln(x)-1=0.$$ Compute the residual and check that the order of convergence is two, using the smallest root of $(a)$.

Exercise 6

  • Use Newton's method to approximate the roots of $x^4-6x^2+9=0$ with $tol=10^{-6}$. What is the order of convergence?

  • Use now the secant method. What is the order of convergence?

  • Use, finally, the bisection method. What is the order of convergence?

Exercise 7

  • Use Newton's method to approximate with $tol=10^{-6}$ the roots of $x^4-6x^2+9=0$
$$(a)~x^3−1.2x^2−8.19x+13.23=0 \quad (b)~x^4 + 0.9x^3 − 2.3x^2 + 3.6x − 25.2=0 \quad (c)~x^4 +2x^3 −7x^2 +3=0$$

What is the order of convergence?

  • Use now the secant method. What is the order of convergence?

  • Use, finally, the bisection method. What is the order of con

Exercise 8

For solving the equation $x+\ln x=0$ by the fixed point method, we consider the following equivalent equations:

$$(i) \; x=-\ln x \quad \quad (ii) \; x=e^{-x}\quad \quad (iii) \; x=\dfrac{x+e^{-x}}{2}$$
  1. Which equations may be used?
  2. Which equations should be used?
  3. For the latter, set the iteration function and find graphically an interval satisfying the conditions of the theorem of the contractive mapping.
  4. Compute the fixed points with $tol=10^{-6}$.

Exercise 9

Consider the function $f(x)= x - \cos(x)$, with $x \in \left(0,\frac{\pi}{2}\right)$. Check graphically that the equations $f(x)=0$ and $g_i(x)=x$ with $i=1,2,3,4$ have the same root, being

$$g_1(x)=\cos(x)\quad g_2(x)=\arccos(x) \quad g_3(x)=2x-\cos(x) \quad g_4(x)=x-\dfrac{x-\cos(x)}{1+\sin(x)}$$

Which is the best to approximate the solution by the fixed point method? Why?

For the equations that can be used, give the iteration function and find graphically an interval satisfying the conditions of the theorem of the contractive mapping. Compute the fixed points with $tol=10^{-6}$.

Exercise 10

For the function $f(x)=x^2-x-2$ we consider its roots in the interval $[1,3]$. Check graphically that

  • The equation $f(x)=0$ and $g_i(x)=x$ with $i=1,2,3,4$ have the same roots, being $$g_1(x)=x^2-2\quad g_2(x)=\sqrt{x+2} \quad g_3(x)=1+\dfrac{2}{x} \quad g_4(x)=\dfrac{x^2+2}{2x-1}$$
  • Take the best of them to approximate the solution using the initial guess $x_0=1$.
  • Compute the fixed point with $tol=10^{-6}$.