Metodos numericos:
1. Metodo del punto fijo: \[
e^{-x}-x=0\\
e^{-x}=x
\]
| k | x |
|---|---|
| 0 | 1 |
| 1 | 0.36787 |
| 2 | 0.96220 |
| 3 | 0.50047 |
| 4 | 0.60624 |
| 5 | 0.54539 |
| 6 | 0.57961 |
\[ e^{-x}-x=0\ \simeq \ 0\\ e^{-0.57961}-0.57961\simeq 0 \\ 3*10^{-3} \]
punto_fijo=function(g,x0,tol,it){
k=1
repeat{
x1=g(x0)
dx= abs(x1-x0)
x0=x1
cat("x_",k,"=",x1,"\n")
k=k+1
if(dx<tol || k>it) break;
}
if(dx>tol){cat("No hubo convergencia")}
else{cat("x* es aproximadamente",x1,"con error menor que",tol)}
}
g= function(x) 3/(x-2)
punto_fijo(g,4,0.01,9)
## x_ 1 = 1.5
## x_ 2 = -6
## x_ 3 = -0.375
## x_ 4 = -1.263158
## x_ 5 = -0.9193548
## x_ 6 = -1.027624
## x_ 7 = -0.9908759
## x_ 8 = -1.003051
## x_ 9 = -0.9989842
## x* es aproximadamente -0.9989842 con error menor que 0.01
f=function(x) sqrt(exp(x)/3)
punto_fijo(f,0,0.001,12)
## x_ 1 = 0.5773503
## x_ 2 = 0.7705652
## x_ 3 = 0.848722
## x_ 4 = 0.8825453
## x_ 5 = 0.8975975
## x_ 6 = 0.9043784
## x_ 7 = 0.9074499
## x_ 8 = 0.9088446
## x_ 9 = 0.9094786
## x* es aproximadamente 0.9094786 con error menor que 0.001
f=function(x) sin(sqrt(x))
punto_fijo(f,0.5,0.001,12)
## x_ 1 = 0.6496369
## x_ 2 = 0.7215238
## x_ 3 = 0.7509012
## x_ 4 = 0.7620969
## x_ 5 = 0.7662481
## x_ 6 = 0.7677717
## x_ 7 = 0.7683287
## x* es aproximadamente 0.7683287 con error menor que 0.001
f= function(x) exp(-x)
punto_fijo(f,0,0,10)
## x_ 1 = 1
## x_ 2 = 0.3678794
## x_ 3 = 0.6922006
## x_ 4 = 0.5004735
## x_ 5 = 0.6062435
## x_ 6 = 0.5453958
## x_ 7 = 0.5796123
## x_ 8 = 0.5601155
## x_ 9 = 0.5711431
## x_ 10 = 0.5648793
## No hubo convergencia