% One million logistic maps x <- r x (1 - x) iterated in lockstep. % The loop body compiles once; 500 iterations replay on the GPU. n = 1000000; r = 3.5 + 0.5*rand(n, 1); x = rand(n, 1); tic; for k = 1:500 x = r .* x .* (1 - x); end toc fprintf('mean x after 500 iterations: %.4f\n', mean(x));