!      program Taylor series

      open(1,file='inpaula.txt')
	open(2,file='outnum1.txt')
	open(3,file='outteo.txt')
	open(4,file='Table-of-results.txt')
	open(5,file='outnum4.txt')
!
!	integrador de EDO's com passo fixo 
!
	read(1,*)n,tau0
	write(*,*)'n=',n,'tau0=',tau0
	read(1,*) tend,h,x0
	write(*,*)'tend=',tend,'h=',h,'x0=',x0
!
!	initial values
!
	x=x0
	x4=x0
	xteo=x0
	time=tau0
	k=0 
	write(*,*) '     Table of results'
	write(*,*)'-----------------------------'
	write(*,*)'  Step Nr     time  x1  x4   xteo  '
	write(*,*)'-----------------------------'
	write(*,*)k,time,x,x4,xteo
	write(4,*)k,time,x,x4,xteo
	write(2,*)time,x
	write(3,*)time,x
	write(5,*)time,x4
 50	k=k+1 

	time=time+h

	! Taylor series method - 4th derivative
	xprime=x
	x2prime=xprime
	x3prime=x2prime
	xIV=x3prime
	x4=x4+h*xprime+h**2*x2prime/2+h**3*x3prime/6+h**4*xIV/24

	! Taylor series method - 1st derivative	- Euler method

	x=x+h*xprime

	write(2,*)time,x

	write(5,*)time,x4

	xteo=exp(time)
	write(3,*)time,xteo

	write(*,*)k,time,x,x4,xteo

	write(4,*)k,time,x,x4,xteo

    if (time.lt.tend) goto 50 

	close(2)
	close(3)
	close(4)
	close(5)


  call system('notepad outnum1.txt') 

  call system('notepad outnum4.txt') 

  call system('notepad outteo.txt') 

  call system('notepad Table-of-results.txt') 

  call system('wgnuplot dados.gnu') ! gráfico

	stop
	end
!**************************************




