For solving in IPython, we use the following commands and packages:
%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
)
import libNonlinearEq as ne
Find the real roots of $x^3 − 5.2x^2 − 5.5x + 9.8 = 0$ using the bisection method:
op.ridder
.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
.
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)$.
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?
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
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}$$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}$.
For the function $f(x)=x^2-x-2$ we consider its roots in the interval $[1,3]$. Check graphically that