
r     = 0.05;
sigma = 0.2;
T     = 2.5;
S     = 4;
K     = 3;
B     = 2.5;


eps = 1e-20;

delta = down_and_out_call(r,sigma,T,S,K,B,'delta');
V     = down_and_out_call(r,sigma,T,S+i*eps,K,B,'value');

disp(sprintf('delta (analytic) = %g',delta))
disp(sprintf('delta (CVT)      = %g',imag(V)/eps))

gamma = down_and_out_call(r,sigma,T,S,K,B,'gamma');
delta = down_and_out_call(r,sigma,T,S+i*eps,K,B,'delta');

disp(sprintf('gamma (analytic) = %g',gamma))
disp(sprintf('gamma (CVT)      = %g',imag(delta)/eps))

vega  = down_and_out_call(r,sigma,T,S,K,B,'vega');
V     = down_and_out_call(r,sigma+i*eps,T,S,K,B,'value');

disp(sprintf('vega (analytic)  = %g',vega))
disp(sprintf('vega (CVT)       = %g',imag(V)/eps))


%
% plot price versus S(0)
%

S = linspace(B,5);
K = 4;

V = down_and_out_call(r,sigma,T,S,K,B,'value');

figure(1)
plot(S,V)
xlabel('S'); ylabel('V')

%
% plot price versus strike
%

S = 3;
K = linspace(B,5);

V = down_and_out_call(r,sigma,T,S,K,B,'value');

figure(2)
plot(K,V)
xlabel('K'); ylabel('V')

