function e=pricerror(par,call,put,S0,K,T)
% outputs the sum of squared pricing error in BS model.
% input prices call, put of call and put options  on a stock with same maturity T and strike K
% par=(r,sigma)=(risk-free interest rate, volatility)
% Minimize Black Scholes pricing error with respect to parameters par using 
%fminsearch('pricerror',[.05 .4],[],call,put,S0,K,T)
%r=par(1);
%sigma=par(2);
[C,P]=blsprice(S0,K,par(1),T,par(2),0);
e=(C-call)^2+(P-put)^2;
