wr = 2*pi*10e9; % Rabi frequency [rad/s]
del = wr; % Detuning [rad/s]
t = linspace(0,100e-12); % [s]
e = 1.6e-19; % [C]
M = e*0.5e-9; % Dipole moment [C*m]

c = 2.998e8; % [m/s]


W = sqrt(del^2+wr^2/4);
Pe = 1/5*sin(W*t).^2;
Pg = 1-Pe;
subplot(121);
plot(t*1e12,Pg); hold on;
plot(t*1e12,Pe,'r');
xlabel('Time [ps]');
ylabel('Populations'); 
grid on;
title('\Omega_r = 2{\pi}{\cdot}10GHz; and detuning \Delta = \Omega_r');

Cg = cos(W*t)+j*delta/W*sin(W*t);
Ce = j*wr/W*sin(W*t);
subplot(122);
d = M*Cg.*conj(Ce).*exp(
