-
Notifications
You must be signed in to change notification settings - Fork 3
/
logisticEquation.f
58 lines (56 loc) · 1.38 KB
/
logisticEquation.f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
parameter (nc=10)
dimension xc(0:nc)
read(5,*) x0,R,h
c logistic dx/dt=-x+R*x^2 with Euler fwd marching
c carle0
t0 = 0.0
nt = 10./h
xc(0) = x0
write(10,*) t0,x0
do it=1,nt
t = it*h
exa= x0*exp(-t)/(1.0-R*x0*(1.0-exp(-t)))
xc(0) = (1.0-h)*xc(0)
write(10,*) t,xc(0),exa
end do
c carle1
xc(1)=x0
x2 = x0*x0
write(11,*) t0,x0
do it=1,nt
t = it*h
exa= x0*exp(-t)/(1.0-R*x0*(1.0-exp(-t)))
x2 = (1.0-2.0*h)*x2
xc(1) = (1.0-h)*xc(1)+h*R*x2
write(11,*) h*it,xc(1),exa
end do
c carle2
xc(1)= x0
xc(2)= x0*x0
x3 = x0*x0*x0
write(12,*) t0,x0
do it=1,nt
t = it*h
exa= x0*exp(-t)/(1.0-R*x0*(1.0-exp(-t)))
x3 = (1.0-3.0*h)*x3
xc(2) = (1.0-2.0*h)*xc(2)+2.0*h*R*x3
xc(1) = (1.0-h)*xc(1) +h*R*xc(2)
write(12,*) t,xc(1),exa
end do
c carle3
xc(1)= x0
xc(2)= x0*x0
xc(3)= x0*x0*x0
x4 = x0*x0*x0*x0
write(13,*) t0,x0
do it=1,nt
t = it*h
exa= x0*exp(-t)/(1.0-R*x0*(1.0-exp(-t)))
x4 = (1.0-4.0*h)*x4
xc(3) = (1.0-3.0*h)*xc(3)+3.0*h*R*x4
xc(2) = (1.0-2.0*h)*xc(2)+2.0*h*R*xc(3)
xc(1) = (1.0-h)*xc(1) +h*R*xc(2)
write(13,*) t,xc(1),exa
end do
stop
end