16 Profit from Roundoff Error Accumulation In the 1999 movie
1.6 Profit from Roundoff Error Accumulation In the 1999 movie Office Space, a character creates a program that takes frac- tions of cents that are truncated in a bank\'s transactions and deposits them into his own account. This is not a new idea, and hackers who have actually attempted it have been arrested. In this exercise, we will simulate the program to determine how long it would take to become a millionaire. account balances to be uniformly distributed between, say S100 adn $100,000. The annual interest rate on the accounts is 5%, and interest is compounded daily and added to the accounts, except that fractions of a cent are truncated.
Solution
%setup accounts
accounts = 100 + (100000-100)*rand(50000,1);
%truncate each accounts
accounts = floor(100*accounts)/100;
illegal = 0
for i = 1:10000
% adding interest compoundly
illegal = illegal + (sum(accounts)*(0.05/365));
illegal = floor(100*illegal)/100;
%saving data
save(\'accounts.dat\',\'illegal\')
end
