% Simulation of the Ito integral

T=1;
N=500;
dt=T/N;
dW=sqrt(dt)*randn(1,N);
W=cumsum(dW);
itoint=sum([0 W(1:end-1)].*dW); % .* componentwise vector multiplication
error=abs(itoint-0.5*(W(end)^2-T));