P_win = 1e-6 P_loose = 1 - P_win ## Part (a): ## X0 = 1e5 E_log_X0 = log(X0) ## don't play the lottery E_log_X1 = log(X0 - 1) * P_loose + log(X0 - 1 + 1e7) * P_win ## do play the lottery print(sprintf('Part (a): E_log_X0= %f; E_log_X1= %f', E_log_X0, E_log_X1)) ## Part (b): ## f = 9/100 E_log_X1 = log(X0 - f) * P_loose + log(X0 - f + f * 1e7) * P_win ## do play the lottery with a fraction f print(sprintf('Part (b): E_log_X0= %f; E_log_X1= %f', E_log_X0, E_log_X1))