real::lambda,t,N,dt,NP,NC,N1,t1
f(t,N)=-lambda*N
open(1,file="output.dat")
t=0;N=0.5;lambda=0.1;dt=0.1
write(1,*)t,N
N1=N+dt*f(t,N)
t1=t+dt
write(1,*)t1,N1
2 NP=N1+0.5*dt*(f(t,N)+f(t1,N1))
NC=N1+0.5*dt*(f(t,N)+f(t1,NP))
if(t1<=100) then
N=N1
N1=NP
t=t1
t1=t1+dt
write(1,*)t1,NC
goto 2
endif
end
f(t,N)=-lambda*N
open(1,file="output.dat")
t=0;N=0.5;lambda=0.1;dt=0.1
write(1,*)t,N
N1=N+dt*f(t,N)
t1=t+dt
write(1,*)t1,N1
2 NP=N1+0.5*dt*(f(t,N)+f(t1,N1))
NC=N1+0.5*dt*(f(t,N)+f(t1,NP))
if(t1<=100) then
N=N1
N1=NP
t=t1
t1=t1+dt
write(1,*)t1,NC
goto 2
endif
end
Comments
Post a Comment