# How to calculate the echo magnitude of an hanh echo using bloch simulation?

Stanford provided all basic functions/M-files needed for Bloch simulation. The following MATLAB code snippet was made on top of these M-files to simulate the Hanh Echo:

T = 1000;   % total duration
df = 10;    % Hz off-resonance.
T1 = 600;   % ms.
T2 = 100;   % ms.
tau = 50;   % ms. TE/2
TR = 500;   % ms.
alpha1 = pi/2;
alpha2 = pi;

% ===== Get the Propagation Matrix ======

[A,B] = freeprecess(tau,T1,T2,df);

% ===== Simulate the Decay 90 - 180 ======

M = zeros(3,3);

M(:,1)=[0;0;1]; % Starting magnetization.
% Let   M(:,1) be the magnetization just before the 90.
%   M(:,2) be just before the 180.
%   M(:,3) be at TE = 2*tau.

Rflip = yrot(alpha1);
Rrefoc = xrot(alpha2);

M(:,2)=A*Rflip*M(:,1)+B; % just before - P2
M(:,3)=A*Rrefoc*M(:,2)+B; % Echo
sig = abs(M(1,3)+1i*M(2,3)); %Echo Magnitude

% ===== Simulate the Decay 90 - 90 ======
alpha1 = pi/2;
alpha2 = pi/2;
M1 = zeros(3,3);    % Keep track of magnetization at all time points.
M1(:,1)=[0;0;1];    % Starting magnetization.

Rflip1 = yrot(alpha1);
Rrefoc1 = xrot(alpha2);

M1(:,2)=A*Rflip1*M1(:,1)+B; % before -P2
M1(:,3)=A*Rrefoc1*M1(:,2)+B; % Echo

sig1 = abs(M1(1,3)+1i*M1(2,3));

disp(sig1/sig) % should be 0.5


According to some basic knowledges, a spin echo using 90-180 would produce the maximum echo amplitude. While the maximum SE(Hanh Echo) intensity of a 90°-90° pair is only half as large as that produced by a 90°-180° pair. This means sig1/sig should be 0.5 . But what I got is a number larger than 1. What's wrong with my simulation code? How to derive the following conclusion using Bloch Simulation?

In general, if the first RF-pulse has flip angle α1 and the second has flip angle α2, the maximum signal intensity of the Hahn echo will be smaller than the conventional (90°-180°) echo by a factor of (sin α1)•(sin² α2/2).