function R=profit(x, M)
% calculate profit of a company vs fraction 'x' invested in expansion
% and (1-x) spent in speculations.
% M - money  available for  spending

% M=10^6 - small business company
% M=10^7 - intermediate
% M=10^8 - large

Me=M*x; % money for business expansion i.e. new tools, goods making machines etc.
Ms=M*(1-x); % money for speculations on a stock market

% return from expansion investments
Mt=10^7; % threshold for low overhead investment
% Re -> 0 for large sum of money due to overhead, 
% think about extra buildings for extra workers or management overhead which grows
Re=1.1*Me*exp(-(Me/Mt)^2); % after certain threshold overhead eats up the profit

% return from speculations 
% for small investment return proportional to input
% but large sum of money allows to manipulate the market and increase the profit
% after Mst  threshold speculations bring very high profits
Mst=1e8;
Rs=1.05*Ms*(1.5-exp(-(Ms/Mst)^2) );


R=Rs+Re;
end



