As values are floating point numbers, they have a finite precision. You should compare their difference against some threshold value
if (abs(X(1,1) - Y(1,1)) > 1e-10)
fprintf('Iter %i disagrees by %g\n', i, X(1,1) - Y(1,1));
end
here 1e-10
is a threshold.
Consider the following example
> X = 0.037900
X = 0.037900
> Y = exp(log(X))
Y = 0.037900
> X -Y
ans = 1.3878e-17
Two numbers X
and Y
look the same, but their decimal notation start to differ from 17th digit.