function c=BSCall(s,tau,K)
%BSCall(s,tau,K) evaluates the standard Black-Scholes
%formula. s (which may be a vector) is the stock price(s), tau is
%the time to expiry, K is the exercise price.  The volatility sigma
%and the risk-free rate r are supplied as global variables.
global sigma r
d1=(log(s/K)+(r+sigma^2/2)*tau)/(sigma*sqrt(tau));
d2=d1-sigma*sqrt(tau);
c=(s.*erfc(-d1/sqrt(2))-K*exp(-r*tau)*erfc(-d2/sqrt(2)))/2;
%Note that erfc(-x/sqrt(2))/2 gives the standard normal distribution
%function.
