
%
%  Rossler ODE system (1976) - minimal model of chaos
%
%

global a b c;
a = 0.2; b = 0.2; c = 5.7;

f = @(t,y) [-y(2)-y(3); y(1)+a*y(2); b + y(3).*(y(1)-c) ];

T0 = 300;

options = odeset('RelTol', 1e-11);

IC1 = [1 1 1];
[T1 Y1] = ode45(f, [0 T0], IC1, options);

IC2 = IC1 + [1e-6 0 0];
[T2 Y2] = ode45(f, [0 T0], IC2, options);

figure(1); 

S = diff( sign(Y1(:,1)) );
I = find( S == 2);
p2 = Y1(I,2);

p21 = p2(1:2:end);
p22 = p2(2:2:end);

subplot(511);
D = Y1(:,1) - spline(T2,Y2(:,1),T1)
LD = log(D);
plot(T1, LD);

subplot(512);
plot(T1, Y1(:,1), T2, Y2(:,1));
subplot(513);
plot(T1, Y1(:,3), T2, Y2(:,3));

subplot(5,1,[4 5]);
plot3(Y1(:,1), Y1(:,2), Y1(:,3), 'b-'); hold on;
plot3(Y2(:,1), Y2(:,2), Y2(:,3), 'r-');
