Professional Documents
Culture Documents
implicit none
integer i,n,iter,itmax,opc
real*8 f,df,x,xi,tol,f1,f2,a
character*10 name
external f,df
call funciones(opc,f,df)
iter=0
5 iter=iter+1
if(iter.EQ.itmax)go to 10
f1=f(x,a)
f2=df(x,a)
xi=x-f1/f2
if(abs(xi-x).LT.tol)then
write(*,*)' La raiz es=',xi
else
x=xi
go to 5
end if
10 continue
pause
end
subroutine funciones(opc,f,df)
implicit none
integer opc,n,i,o
real*8 x,a,f,df
parameter (o=100)
dimension a(o)
external f,df
if(opc.EQ.1)then
write(*,*)'Ingrese el grado del polinomio'
read(*,*) n
write(*,*)'Ingrese los valores de los coeficientes, comenzando'
write(*,*)'por el termino ao'
do i=1,n+1
read(*,*) a(i-1)
end do
function f(x,a)
implicit none
integer i,n
real*8 x,a,f
f=0
do i=1,n+1
f=f+a(i-1)*x**(i-1)
end do
return
end
function df(x,a)
implicit none
integer i,n
real*8 x,a,df
df=0
do i=1,n+1
df=df+x(i-1)*a(i-1)*x**(i-2)
end do
return
end
end