%% Résolution de l'équation de Van der Pol modifiée
% y'' - a*(1 - y^2)*y' + y = 0, avec a = 0.25
clear all; close all; clc;
%% Paramètres
a = 0.25; % Paramètre donné
tspan = [0, 50]; % Intervalle de temps [t0, tf]
y0 = [2; 0]; % Conditions initiales [y(0); y'(0)]
%% Résolution avec ode45
[t, Y] = ode45(@(t,y) vdp_eq(t, y, a), tspan, y0);
% Extraction des solutions
y = Y(:, 1); % Solution y(t)
ydot = Y(:, 2); % Dérivée y'(t)
%% Tracé des résultats
figure('Position', [100, 100, 1200, 400]);
% 1. Solution y(t) en fonction du temps
subplot(1, 3, 1);
plot(t, y, 'b', 'LineWidth', 2);
xlabel('Temps t', 'FontSize', 12);
ylabel('y(t)', 'FontSize', 12);
title('Solution y(t)', 'FontSize', 14);
grid on;
% 2. Portrait de phase (y' en fonction de y)
subplot(1, 3, 2);
plot(y, ydot, 'r', 'LineWidth', 1.5);
xlabel('y', 'FontSize', 12);
ylabel('y''', 'FontSize', 12);
title('Portrait de phase', 'FontSize', 14);
grid on;
% 3. Les deux solutions sur le même graphe
subplot(1, 3, 3);
plot(t, y, 'b', 'LineWidth', 2);
hold on;
plot(t, ydot, 'r--', 'LineWidth', 2);
xlabel('Temps t', 'FontSize', 12);
ylabel('Amplitude', 'FontSize', 12);
title('y(t) et y''(t)', 'FontSize', 14);
legend('y(t)', 'y''(t)', 'Location', 'best');
grid on;
%% Analyse des résultats
fprintf('=== Résultats pour a = %.2f ===\n', a);
fprintf('Temps final: %.1f\n', t(end));
fprintf('Valeur finale y(tf): %.4f\n', y(end));
fprintf('Valeur finale y''(tf): %.4f\n', ydot(end));
fprintf('Amplitude max de y: %.4f\n', max(abs(y)));
%% Fonction de l'équation différentielle
function dydt = vdp_eq(t, y, a)
% y(1) = y, y(2) = y'
% Equation: y'' - a*(1 - y^2)*y' + y = 0
% Réécriture: y'' = a*(1 - y^2)*y' - y
dydt = zeros(2, 1);
dydt(1) = y(2); % y' = y(2)
dydt(2) = a*(1 - y(1)^2)*y(2) - y(1); % y'' = a*(1-y^2)*y' - y
end