function pp = rcos(tt,aa)
% rcos - make a raised cosine pulse
%
% Usage:
%   pp = rcos(tt,aa)

num = cos(pi*aa*tt);
denom = 1-4*aa^2*tt.^2;

% guard against dividing by zero.
% we find the indices where denom is very close to zero (tt = +/- 1/(2aa)).
% By L'Hospital's rule the ratio of num/denom equals pi/4 in those places
indZero = find(abs(denom) < sqrt(eps(1))); % eps(1) reflects machine precision

denom(indZero) = 1;
num(indZero) = pi/4;

% we can now make the puls without worrying about dividing by zero
pp = sinc(tt) .* num ./ denom;


