Could someone show the procedure for the following two numerical method problems:
Solve an equation $f(x)=x^2-e^x+2=0$ with precision up to $10^{-4}$ using the secant method.
Using the tangent method, find one positive root of equation $\cos x=x^2-2$, with precision less than $10^{-4}.$ Localize the solution on an interval of length at least $0.5.$
1 Answer
$\begingroup$$1$: Find root using secant method
$$ f(x) = x^{2} - e^{x} + 2 $$
The root is at $x= 1.3190736768573654$
Secant method
MathWorld: Secant Method; Wikipedia: Secant method
Method
Pick a value for $x_{0}$
Pick a value for $x_{1}$
Iterate using $$ x_{n} = x_{n-1} - f\left(x_{n-1}\right) \frac{x_{n-1} - x_{n-2}}{f\left(x_{n-1}\right) - f\left(x_{n-2})\right)} $$
Example
Set $x_{0}=1$, $x_{1} = 1.5$.
$$ \begin{align} x_{2} &= \color{blue}{1}.2743613145286912 \\ x_{3} &= \color{blue}{1.31}28043183949625 \\ x_{4} &= \color{blue}{1.319}2956677042882 \\ x_{5} &= \color{blue}{1.31907}25774798735 \\\hline x_{6} &= \color{blue}{1.319073676}6646676 \\ \end{align} $$
$2$: Find root using Newton's method
$$ f(x) = x^{2} - 2 - \cos x $$
The roots are at $x= \pm1.4546189292081113$
Tangent method
MathWorld: Newton's Method, Wikipedia: Newton's method
Method
Pick a value for $x_{0}$
Iterate using $$ x_{n} = x_{n-1} - \frac{f\left(x_{n-1}\right)} {f'\left(x_{n-1}\right)} $$
Example
Set $x_{0}=1$. The derivative is $$ f'(x)= 2x+\sin x $$ The sequence of roots is $$ \begin{align} x_{1} &= \color{blue}{1}.5420791956361556951 \\ x_{2} &= \color{blue}{1.45}65461937663345119 \\ x_{3} &= \color{blue}{1.45461}99345022899466 \\ x_{4} &= \color{blue}{1.454618929208}3852544 \\\hline x_{5} &= \color{blue}{1.454618929208111}2788 \\ \end{align} $$
$\endgroup$ 6