Ejercicio 1
Usa el método de Newton paso por paso para aproximar la solución de las siguientes ecuaciones en el intervalo dado.
- \(x^3-2x^2-5=0\), \([1,4]\)
## [1] 2.871783
- \(x-cosx=0\), \([0, \pi/2]\)
## [1] 0.7390851
Utilizando el método de Newton-Raphson la aproximación de la raíz de la función después de cuatro iteraciones es 0.7390851
Ejercicio 2
Aproxima la solución de las siguientes ecuaciones por medio del método de Newton y compáralo con las soluciones obtenidas por medio del método de la bisección (ejercicio 3 de la tarea 2).
- \(x-2^{-x}=0\) para \(0\leq x\leq 1\)
newtonRaphson(f_2a,0,df_2a)## $root
## [1] 0.6411857
##
## $f.root
## [1] 0
##
## $niter
## [1] 4
##
## $estim.prec
## [1] 8.131176e-09
bisect(f_2a,0,1)## $root
## [1] 0.6411857
##
## $f.root
## [1] 0
##
## $iter
## [1] 54
##
## $estim.prec
## [1] 1.110223e-16
- \(e^x-x^2+3x-2=0\) para \(0\leq x\leq 1\)
newtonRaphson(f_2b, 0, df_2b)## $root
## [1] 0.2575303
##
## $f.root
## [1] 0
##
## $niter
## [1] 4
##
## $estim.prec
## [1] 2.665238e-12
bisect(f_2b,0,1)## $root
## [1] 0.2575303
##
## $f.root
## [1] -4.440892e-16
##
## $iter
## [1] 55
##
## $estim.prec
## [1] 5.551115e-17
- \(2x\cos (2x)-(x+1)^2=0\) para \(-3\leq x\leq -2\) y \(-1\leq x \leq 0\)
newtonRaphson(f_2c,-3,df_2c)## $root
## [1] -2.191308
##
## $f.root
## [1] -1.856085e-08
##
## $niter
## [1] 15
##
## $estim.prec
## [1] 4.640211e-09
bisect(f_2c,-3,-2)## $root
## [1] -2.191308
##
## $f.root
## [1] -3.108624e-15
##
## $iter
## [1] 52
##
## $estim.prec
## [1] 4.440892e-16
newtonRaphson(f_2c,-1,df_2c)## $root
## [1] -2.191308
##
## $f.root
## [1] -3.220438e-08
##
## $niter
## [1] 22
##
## $estim.prec
## [1] 8.051095e-09
bisect(f_2c,-1,0)## $root
## [1] -0.79816
##
## $f.root
## [1] 4.857226e-17
##
## $iter
## [1] 54
##
## $estim.prec
## [1] 1.110223e-16
- \(x\cos x-2x^2+3x-1=0\) para \(0.2\leq x\leq 0.3\) y \(1.2\leq x \leq 1.3\)
newtonRaphson(f_2c,-0.2,df_2c)## $root
## [1] -2.191308
##
## $f.root
## [1] 2.346462e-08
##
## $niter
## [1] 29
##
## $estim.prec
## [1] 5.866156e-09
newtonRaphson(f_2c,-1.2,df_2c)## Warning in newtonRaphson(f_2c, -1.2, df_2c): Maximum number of iterations
## 'maxiter' was reached.
## $root
## [1] -10341.16
##
## $f.root
## [1] -106911826
##
## $niter
## [1] 501
##
## $estim.prec
## [1] 3488.496
bisect(f_2c, -1.2, 1.3)## $root
## [1] -0.79816
##
## $f.root
## [1] 4.857226e-17
##
## $iter
## [1] 55
##
## $estim.prec
## [1] 1.110223e-16
Ejercicio 3
Aproxima la solución de las siguientes ecuaciones por medio del método de Newton y de la secante.
- \(e^x+2^{-x}+2\,cos\,x-6=0\), para \(1\leq x\leq 2\).
newtonRaphson(f_3a, 1, df_3a)## $root
## [1] 1.829384
##
## $f.root
## [1] 8.881784e-16
##
## $niter
## [1] 8
##
## $estim.prec
## [1] 5.786101e-10
secant(f_3a, 1, 2)## $root
## [1] 1.829384
##
## $f.root
## [1] 2.306688e-11
##
## $iter
## [1] 6
##
## $estim.prec
## [1] 2.559105e-07
- \(log(x-1)+cos(x-1)=0\) para \(1.3\leq x \leq 2\).
## Warning in log(x - 1): Se han producido NaNs
newtonRaphson(f_3b, 1.3, df_3b)## $root
## [1] 1.397748
##
## $f.root
## [1] 2.220446e-16
##
## $niter
## [1] 5
##
## $estim.prec
## [1] 1.651129e-13
secant(f_3b, 1.3, 2)## $root
## [1] 1.397748
##
## $f.root
## [1] -2.376654e-12
##
## $iter
## [1] 8
##
## $estim.prec
## [1] 6.395966e-08
- \(2x\,cos\,2x-(x-2)^2=0\) para \(2\leq x \leq 3\) y \(3\leq x \leq 4\).
newtonRaphson(f_3c, 2, df_3c)## $root
## [1] 2.370687
##
## $f.root
## [1] 1.720846e-15
##
## $niter
## [1] 5
##
## $estim.prec
## [1] 5.970602e-15
secant(f_3c, 2, 3)## $root
## [1] 2.370687
##
## $f.root
## [1] 3.376466e-13
##
## $iter
## [1] 5
##
## $estim.prec
## [1] 1.939082e-08
- \(e^x-3x^2=0\) para \(0\leq x \leq 1\) y \(3\leq x \leq 5\).
newtonRaphson(f_3d, 1, df_3c)## $root
## [1] 0.9100076
##
## $f.root
## [1] -9.359533e-09
##
## $niter
## [1] 34
##
## $estim.prec
## [1] 8.247578e-09
secant(f_3d, 0, 1)## $root
## [1] 0.9100076
##
## $f.root
## [1] 2.827174e-09
##
## $iter
## [1] 5
##
## $estim.prec
## [1] 5.22289e-06
secant(f_3d, 3, 5)## $root
## [1] 3.733079
##
## $f.root
## [1] -2.557954e-13
##
## $iter
## [1] 10
##
## $estim.prec
## [1] 5.375394e-09