-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.m
46 lines (35 loc) · 813 Bytes
/
test.m
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
%% 3.1
a = 3;
b = 9;
c = 15;
d = 15;
p = 1.17288;
H = @(x, y) c*x + b*y - d * log(x) - a * log(y);
f = @(t, y) [a*y(1) - b*y(1)*y(2); c*y(1)*y(2) - d*y(2)];
y0 = [2; 1];
[t, y] = adaptiveRK34(f, y0, 0, 1000*p, 10^-6);
figure(1);
plot(y(1,:), y(2, :))
%%
figure(1);
semilogx(t, abs(H(y(1, :), y(2, :))/H(y0(1), y0(2))-1));
figure(2);
semilogy(t, abs(H(y(1, :), y(2, :))/H(y0(1), y0(2))-1));
figure(3);
loglog(t, abs(H(y(1, :), y(2, :))/H(y0(1), y0(2))-1));
%% 4.1
y0=[2;0];
mu = 100;
f = @(t, y) [y(2); mu*(1-y(1)^2)*y(2)-y(1)];
[t,y] = adaptiveRK34(f,y0,0,2*mu,10^-6);
plot(t,y(2,:))
%%
y0=[2;0];
mu = 100;
f = @(t, y) [y(2); mu*(1-y(1)^2)*y(2)-y(1)];
[t,y] = adaptiveRK34(f,y0,0,2*mu,10^-6);
plot(y(1,:),y(2,:))
hold on
y0=[0;-0.1];
[t,y] = adaptiveRK34(f,y0,0,2*mu,10^-6);
plot(y(1,:),y(2,:))