Personal Website:
Scott Congreve

Teaching

Download<< Back

function pendfric_stab
% Plots the eigenvalues for the linearised pendulum with friction
% and the domains of stability for RK1, RK2, RK3 and RK4
A = [ 0 1; -1 -0.2 ];

figure;
hold on;
lambda=1;
plot(lambda*eig(A), 'ro', 'MarkerSize', 14);
lambda=0.4;
plot(lambda*eig(A), 'bo', 'MarkerSize', 14);
lambda=0.2;
plot(lambda*eig(A), 'mo', 'MarkerSize', 14);
lambda=0.1;
plot(lambda*eig(A), 'go', 'MarkerSize', 14);

rk_stab(1, 'r.');
rk_stab(2, 'b.');
rk_stab(3, 'm.');
rk_stab(4, 'g.');
xlim([-4 4]);
ylim([-4 4]);
axis('square');
xlabel('Re');
ylabel('Im');
legend('1\lambda','0.4\lambda','0.2\lambda','0.1\lambda', ...
    'First Order RK', 'Second Order RK', 'Third Order RK', 'Fourth Order RK');
end