% sim_difeq.m     needs files  ode_test1.m and ode_test4.m
function sim_difeq
format compact
sprintf('integrate constants x=0,1  1,2,3,4')
options = odeset('RelTol', 1e-4, 'AbsTol', [1e-4 1e-4 1e-4 1e-4]);
%              funct     X range   Y initial
[X,Y] = ode45(@ode_test1, [0 1], [0.0 0.0 0.0 0.0 ], options);
n=size(Y); % last row is n(1), final value
sprintf('%f  %f  %f  %f',Y(n(1),1),Y(n(1),2),Y(n(1),3),Y(n(1),4))
figure(1)
plot(X, Y(:,1), '-', X, Y(:,2), '-.', X, Y(:,3), '.', X, Y(:,4), '.-')
xlabel('X');
ylabel('Y');
title('derivatives 1, 2, 3, 4');
sprintf('integrate 1, x, x^2, x^3 x=0,1  1, 1/2, 1/6, 1/24')
[X,Y] = ode45(@ode_test4, [0 1], [0.0 0.0 0.0 0.0], options);
n=size(Y);
sprintf('%f  %f  %f  %f',Y(n(1),1),Y(n(1),2),Y(n(1),3),Y(n(1),4))
sprintf('Y(4)*24.0=%f',Y(n(1),4)*24.0)
figure(2)
plot(X, Y(:,1), '-', X, Y(:,2), '-.', X, Y(:,3), '.', X, Y(:,4), '.-')
xlabel('X');
ylabel('Y');
title('derivatives 1, x, x^2, x^3');
end
