## Black-Scholes for 17BII+ with 12 Digit Accuracy

Tony Hutchins has an article in DataFile V24N2pp13-21 *Wronski's Lex Suprema on the HP-12C* that presents a Black-Scholes program accurate to 12 digits. Tony has graciously given me permission to post the HP 17BII+ version here. The INIT.VARS equation is to initialize all one-letter variables to allow L() and G() to work properly. I also included run-times for this version; as strike prices become less probable, times increase to around 9 minutes.

PS=52, PE=47, RF%=0.5, T=6, S=0.2054

INIT.VARS:A+B+C+D+E+F+G+H+I+J+K+L+M+N+O+P+Q+R+S+T+U+V+W+X+Y+Z

BLK.SCHLS,11.9:

0xPSxPExRF%xTxS+IF(S(CALLV):

0xL(X:(LN(PS÷PE)+(RF%÷100+S^2÷2)xT)÷S÷SQRT(T))

xL(Y:G(X)-SxSQRT(T))+PSxIF(G(X)^2>49:

IF(G(X)>0:1:0):.5+G(X)xEXP(-(G(X)^2)÷2)÷SQRT(2xPI)x(1+

SIGMA(N:1:10xABS(G(X))+IF(ABS(G(X))<1.4:5:0):1:(2xG(X)^2)^NxFACT(N)÷FACT(2xN+1))))

-PExEXP(-RF%xT÷100)xIF(G(Y)^2>49:

IF(G(Y)>0:1:0):.5+G(Y)xEXP(-(G(Y)^2)÷2)÷SQRT(2xPI)x(1+

SIGMA(N:1:10xABS(G(Y))+IF(ABS(G(Y))<1.4:5:0):1:(2xG(Y)^2)^NxFACT(N)÷FACT(2xN+1))))

-CALLV:

-PS+PExEXP(-RF%xT÷100)+CALLV-PUTV)

Exact Call Calculated Call Error Execution Time

PE=47, d1=.6957 13.208118745061 13.208118745100 -3.92344E-11 39 sec

PE=37, d1=.9876 18.961966848997 18.961966849000 -3.1477E-12 58 sec

PE=22, d1=2.0209 30.902477228531 30.902477228600 -6.94556E-11 1 min 34 sec

PE=13, d1=3.0666 39.393284752365 39.393284752200 1.64839E-10 2 min 50 sec

PE=02, d1=6.7869 50.059108932926 50.059108932900 2.57856E-11 8 min 55 sec

PE=01, d1=8.1645 51.029554466452 51.029554466500 -4.85088E-11 7 sec

An alternative is to use a 5th order polynomial approximation that always executes in 13 seconds, but only has 7.4 digits of accuracy:

BLK.SCHLS,7.4:

0xPSxPExRF%xTxS+IF(S(CALLV):

0xL(B:1÷(1+.2316419xABS(L(D:L(C:(LN(PS÷PE)

+(RF%÷100+S^2÷2)xT)÷S÷SQRT(T))-SxSQRT(T)))))

xL(A:1÷(1+.2316419xABS(G(C))))+PSxABS(IF(G(C)<0:0:-1)

+(.254829592xG(A)-.284496736xG(A)^2+1.421413741xG(A)^3

-1.453152027xG(A)^4+1.061405429xG(A)^5)xEXP(-G(C)^2÷2)÷2)

-PExEXP(-RF%xT÷100)xABS(IF(G(D)<0:0:-1)

+(.254829592xG(B)-.284496736xG(B)^2+1.421413741xG(B)^3

-1.453152027xG(B)^4+1.061405429xG(B)^5)xEXP(-G(D)^2÷2)÷2)

-CALLV:

-PS+PExEXP(-RF%xT÷100)+CALLV-PUTV)

Exact Call Calculated Call Error Execution Time

PE=47, d1=.6957 13.208118745061 13.208118448700 2.96361E-07 13 sec

PE=37, d1=.9876 18.961966848997 18.961966877200 -2.82031E-08 13 sec

PE=22, d1=2.0209 30.902477228531 30.902481308000 -4.07947E-06 13 sec

PE=13, d1=3.0666 39.393284752365 39.393281519000 3.23336E-06 13 sec

PE=02, d1=6.7869 50.059108932926 50.059108932900 2.57856E-11 11 sec

PE=01, d1=8.1645 51.029554466452 51.029554466500 -4.85088E-11 11 sec

Bob