Mayarin Lopéz
Monday, April 04, 2016
El siguiente algoritmo nos da una raiz apróximada de \[P(x) =16x^4-40x^3+5x^2+20x+6\] tomando como aproximaciones iniciales: \[x_0=0.5\] \[x_1=1.0\] \[x_2=1.5\]y una tolerancia de \[10^{-5}\]
f<-function(x)(16*x^4-40*x^3+5*x^2+20*x+6)
x0<-0.5
x1<-1.0
x2<-1.5
tol<-0.00001
N<-80
h1<-x1-x0
h2<-x2-x1
d1<-(f(x1)-f(x0))/h1
d2<-(f(x2)-f(x1))/h2
d<-(d2-d1)/h2+h1
i<-3
while(i<N){b<-d2+h2*d
D<-(b^2-4*(f(x2)*d))^(1/2)
if (abs(b-D)<abs(b+D)){E<-b+D}
else {E<-b-D}
h<-2*f(x2)/E
p<-x2+h
if (abs(h)<tol){p
break}
x0<-x1
x1<-x2
x2<-p
h1<-x1-x0
d1<-(f(x1)-f(x0))/h1
d2<-(f(x2)-f(x1))/h2
d<-(d2-d1)/h2+h1
i<-i+1
}
p
## [1] 1.241677
Hemos obtenido así la primera raiz real del polinomio \[P(x)\]