Program Secondorder_initialvalue

Implicit none
integer i
real    y,y1,h,t,pi                 !y1 derivada
real    f1,f2,k1,k2,k3,k4
real    k5,k6,k7,k8,a,b


a=-0.4
b=-0.6
h=0.1
pi=4*atan(1.0)


do i=1,11

	y=a
	y1=b

	t=h*(i-1)

	k1=h*f1(t,y,y1)
	k2=h*f2(t,y,y1)

	k3=h*f1(t/(2*pi)+h/2,y+0.5*k1,y1+0.5*k2)
	k4=h*f2(t/(2*pi)+h/2,y+0.5*k1,y1+0.5*k2)

	k5=h*f1(t/(2*pi)+0.5*h,y+0.5*k3,y1+0.5*k4)
	k6=h*f2(t/(2*pi)+0.5*h,y+0.5*k3,y1+0.5*k4)

	k7=h*f1((t+h)/(2*pi),y+k5,y1+k6)
	k8=h*f2((t+h)/(2*pi),y+k5,y1+k6)

	a=a+(1.0/6)*(k1+2*k3+2*k5+k7)
	b=b+(1.0/6)*(k2+2*k4+2*k6+k8)
	write(*,*) a,b
end do
write(*,*) "final:",a,b

end Program Secondorder_initialvalue

function f2(t,y,y1)
real t,y,y1,f2
f2=2*y1-2*y+exp(2*t)*sin(t)
return
end function

function f1(t,y,y1)
real t,y,y1,f1
f1=y1
return
end function

