1. (1)Modify the program AmPutLattice (as below) so it applies to calls. Then compute American option prices with parameters asS0=50, K=54, T = 5 months, risk free rate = 3%, and volatility = 30% and with three values for N=1000, 2000, and 5000. Compare your values with the output of blsprice and binprice.
function price = AmPutLattice(S0,K,r,T,sigma,N)
% Precompute invariant quantities
deltaT = T/N;
u=exp(sigma * sqrt(deltaT));
d=1/u;
p=(exp(r*deltaT) - d)/(u-d);
discount = exp(-r*deltaT);
p_u = discount*p;
p_d = discount*(1-p);
% set up S values
SVals = zeros(2*N+1,1);
SVals(N+1) = S0;
for i=1:N
SVals(N+1+i) = u*SVals(N+i);
SVals(N+1-i) = d*SVals(N+2-i);
end
% set up terminal values
PVals = zeros(2*N+1,1);
for i=1:2:2*N+1
PVals(i) = max(K-SVals(i),0);
end
% work backwards
for tau=1:N
for i= (tau+1):2:(2*N+1-tau)
hold = p_u*PVals(i+1) + p_d*PVals(i-1);
PVals(i) = max(hold, K-SVals(i));
end
end
price = PVals(N+1);
(2)Back to the American put with the same parameters and N=5. Use AmPutLattice to determine whether this option is going to be exercised one month before expiration. [Hint: you need to determine for each node on the tree whether it is an "exercise node" or not.]