# Problem 7 # print( (1+0.07/365)^365 ) # Problem 8 # S_n = 1000 # the initial amount S_0 n = 0 while( n<36 ){ n = n+1 S_n = (1+0.08/12) * S_n + 25 } print(S_n) # Problem 9 # rho = 1+0.1/12 S_0 = 8000 numer = S_0 * rho^36 denom = (1 - rho^36)/(1-rho) print( numer/denom ) # Problem 10 # rs = c( 0.09, 0.1, 0.12 ) rho = 1+rs/12 S_0 = 100000 n_payoff = 30*12 numer = S_0 * rho^n_payoff denom = (1 - rho^n_payoff)/(1-rho) print( numer/denom ) # Problem 11 # r = 0.09 rho = 1+r/12 S_0 = 100000 n_payoff = c( 30*12, 20*12 ) numer = S_0 * rho^n_payoff denom = (1 - rho^n_payoff)/(1-rho) bs = numer/denom print('monthly payments=') print(bs) print('total amount payed=') print(bs*n_payoff) # Problem 12 # rho = 1+0.1/12 b = 1000 n = 240 numer = ( b / (1-rho) ) * ( 1 - rho^n ) denom = rho^n print(numer/denom) # Problem 13 # rs = seq( 0.09, 0.11, length.out=100 ) rhos = 1+rs/12 n = 240 S0 = 95000 lhs = (1-rhos) * rhos^n * S0 - 900 * (1-rhos^n) plot( rs, lhs, type='l', xlab='yearly interest rate (r)' ) grid() argmin = which.min(abs(lhs)) print(rs[argmin])