HP Solver Equation that Back-solves the BLACK-SCHOLES
-----------------------------------------------------

BLACKSCH.EQN handles analytical European-type equity, index,
currency and futures options.

It has 6 main inputs: P,q%,r%,s%,T and X, under keys F2-F7, on
the first "page" of the EQN. There are 6 pages in total,
accessed by pressing F10.

The option has term T years and strike price X. The current
asset price is P, and the asset has "volatility" s%. All of
P,s%,T and X must be positive or the solver will respond "bad
guesses, try again".

These may vary freely:
q%=dividend rate
r%=risk free rate

Either Call or Put (F8,F9) may be solved for. Solving for
either does also give the results for the other, so in general
it doesn't matter which is pressed. However if Put is pressed
a flag is set to force the Put value (rather than the
Call value) to be used in any subsequent back-solving, as
explained below.

Any of the 6 main inputs may also be solved for, based on a
specified Call or Put. Whether the Put or Call value is used
in this back-solving depends on which of the flags #Put and
#Call is set. If Put is solved for then #Put is set, until
Call is solved for, when #Call is set. In addition the flags
#Call and #Put can be manually set by "pressing" them (i.e.
solving for them).

In particular the "implied volatility", s%, can be
back-solved, given a put or call option price. Variation of s%
with X will show a "volatility smile", for constant
P,q%,r%,and T. Ironically the markets do not consider
volatility to be constant<G>.

Many results are output to subsequent Solver pages, accessed
by pressing F10, after solving for a variable on the first
page. On the last page there is another variable called
g%_ov_r% which needs to be set to zero for the standard
Black-Scholes. It is used to allow an asset price growth rate
different to r%, and can also be re-solved for. A non-zero
g%_ov_r% will always give lower Put and Call than having
g%_ov_r%=0. Many "what-if" scenarios can be tested. For
example a regular Black-Scholes Put value can be solved for,
then r% can be resolved for after setting a non-zero g%_ov_r%,
and you will always find the new r% is less than the original.
Vice-versa for the Call. Instead of g%_ov_r% it is also
possible to set g% itself and set #g% (a flag on the last
page) to ensure that this g% is used. In this case resolving
for r% will change the g%_ov_r%.

The other outputs are all fairly standard. First we have delta
 and gamma, the first and second derivatives of Call and Put
with respect to P. I also show P*delta which is the initial
asset position that will fully hedge changes in option price,
provided the future share price develops according to theory.
Also, a 1% change in P will alter the option by 1%*P*delta.
The next order effect is the gamma - a 1% change in P will
change the option price by an additional 1%*1%/2*P*P*Gamma.
So, P*P*Gamma is also output.

On page 2 I show how Put and Call are derived from the
P*delta, and page 4 shows how the expected payouts at time T
are calculated.

Page 3 has the other "Greeks", including 
Theta, the derivative with respect to T. By
default it is expressed per year but by setting Theta_F
(Theta_Frequency) to 365 it will be quoted per day. 252 can be
used (a proxy for the number of trading days in a year)
instead of 365. Only 1,252 and 365 are allowed by the EQN.

Next are derivatives with respect to to q% (called Lambda), r%
(called Rho) and s% (called "vega" or Kappa).

There is only one Gamma and Vega. The others have separate
values for call/put.

For options on futures, set q%=r%, and for currencies q% is
the foreign risk-free rate.

TECHNICAL BACKGROUND
---------------------
These are the elements of Call and Put, where P(T) is the
price at time T, distributed lognormally:

TPRPOX= probability that P(T) is over X
      = probability that a Call option is exercised
TPRPUX= 1-TPRPOX= probability that P(T) is under X
TEVP  = Expected value (EV) of P(T)
TEVPOX= portion of TEVP that is over X
TEVPUX= TEVP-TEVPOX=portion of TEVP that is under X
At time T the Call payout is TEVPOX-X*TPRPOX and 
the Put payout is Put=X*TPRPUX-TEVPUX.
Page 4 shows these relations and labels -X*TPRPOX as "mTXPOX"
and X*TPRPUX as "TXPUX", and -TEVPUX as "mTEVPUX".

The X term is discounted back using EXP(-r%*T/100).
These results are labeled "mDXPOX" and "DXPUX" on page 2.
This r% is the cash return on the deal to the writer of a
call option, and the borrowing cost to the writer of a put.

The TEVP term is effectively discounted back at the full asset
growth rate, as it is fully hedged by a position in the asset.
The initial hedge is just P*Delta. This grows naturally to the
TEVP term.

The *POX and *PUX values above are calculated as follows:

TPRPOX=N(-z)
TEVPOX=TEVP*N(-z1)

z and z1 are output (see page 5) , as is N(-z1) which is
called ND1.

N(z) is by definition a lower tailed normal probability. So we
see N(-z) is an upper tailed probability, as required (i.e. P
being over X), where

z= (y-tmu)/tsigma 
y=LN(P(T)/P) in general, here P(T)=X
tmu=T*mu where mu=g-q-SQ(s)/2
tsigma=SQRT(T)*s

Here I use "x" as "x%/100" for x=g,q,r & s
The default value of g% is r%.

Note:
EV of P(T) =P*EXP(tmu+SQ(tsigma)/2) 
           =P*EXP((g-q)*T)*P
This is output as TEVP. 
The standard deviation of P(T) is given by: 
TSDP= TEVP*SQRT(EXP(SQ(tsigma)-1) 
    = TEVP*SQRT(EXP(T*SQ(s)-1)
TEVP is here multiplied by a factor being called the
coefficient of variation, for the lognormal.

100*tmu is output as TNMU% and 100*tsigma as TNSIG%. Also, the
100*mu is output as NMU%, or Normal MU%. These define the
underlying continous returns assumed, which give rise to the
price development in time, which takes the form
EXP(return*time). The expected value of P(T) is not P*EXP(tmu)
- in fact that is the median of P(T). The mode is lower still,
at P*EXP(tmu-SQ(tsigma)). The reason the SQ(tsigma)/2 term
appears in the statistical mean of P(T) is the same reason
that EXP(SQ(x)/2) is very close to the mean of EXP(x) and
EXP(-x), namely (EXP(x)+EXP(-x))/2, the later being cosh(x)
and also the arithmetic average of a 2 valued random variable
V where LN(V) can be +x or -x with equal probability, and
therefore LN(V) has mean zero and variance SQ(x))

g%, q% and r% are all assumed to be continuously compounding,
and s% is also based on continuous returns for the asset. All
of g%, q%, r% and s% are rates per annum.

g%=r% defines Black-Scholes...
Everything else is perfectly standard lognormal theory. g=r%
is a popular assumption in the market as to a large extent any
g%<>r% is all covered automatically by hedging which can
presumably be a busy task, albeit supposedly risk-free. So, it
is true that g% is largely irrelevant, but we still have to
use a g% to get an answer<G>. g%=r% is quite special in that
the answers for Call and Put are *maxima*. I like to allow g%
to be explicitly different though, as a practical test of the
validity of the g%=r% assumption, and of all the academic
theory behind it. In spite of that I hid the g% away on the
last page of the solver, because not many will want to use it.
I believe it is frowned upon<G>. In fact, because g%=r%
produces maxima, g%<>r% does produce frowns in the Call and
Put prices.<G>. However, it does show that if the writer of a
Call Option prices it using g%=r%, but in practice g% is not
equal to r%, the option premium is *more* than a sufficient
contribution to the cost of hedging the deal and he will earn
more than r%. Only if the Call writer is a bad hedger will he
earn the r%. In the real world he *has* to hedge. The theory
behind g%=r% is that the pricing can be done in a
"risk-neutral" world, and it will automatically work in the
real world, a frequently quoted generalisation, and not too
far wrong anyway.

Back to the above formulae for z & y ...
This all works because we assume that y=LN(P(T)/P), is normally
distributed with mean T*mu and variance T*SQ(s). This
makes sense as the convolution of T (integral for this
argument) independent and identically distributed normal
variates with mean mu and variance SQ(s) is itself
normally distributed with mean T*mu and variance T*SQ(s).
That is not peculiar to the Black-Scholes formula. 

z1 is a special z required for dissecting the EV of P(T) into
portions above and below the exercise price(X).

This value of z1:
z1=z-tsigma

This is the z for a normal distribution with mean
tmu+SQ(tsigma) and gives the correct value for TEVPOX above.
This is a nice property of the lognormal distribution. In the
general case for integral j and z1=z-j*tsigma one can expand
the algeraic expression for SQ(z1) = SQ(z-tsigma) and show:

j*y  -SQ(z)/2  =  j*tmu+SQ(j*tsigma)/2 - SQ(z1)/2

Taking EXP of both sides, and dividing by SQRT(2*PI) we see
the unit normal density,Z(t)=EXP(-SQ(t)/2)/SQRT((2*PI), appear:

EXP(j*y)*Z(z) = EXP(j*mu+SQ(j*tsigma)/2*Z(z1)

By integrating we see that the expected value
of EXP(j*y) over any range of y from y1 to y2 is just
EXP(j*tmu+SQ(j*tsigma)/2)*(N(z1(y2)-N(z1(y1)). For j=1 and
y1=LN(X/P) and y2=+infinity, we have our result for TEVPOX.
Also we then have for our particular z,z1:
X*Z(z) = P*EXP((g-q)*T)*Z(z1), which is useful in
differentiating the Call/Put equations, remembering that
dN(x)/dx=Z(x).

There is a slight complication in the EQN as the well known
approximation to N(x) is used (from the Dover Handbook by
Abramowitz & Stegun, formula 26.2.17) but works for positive x
only, so the SGN needs remembering. The formula has a maximum
absolute error of 7.5e-8.

I should point out that the standard Black-Scholes formula has
N(d1) and N(d2) in the Call option formula. This always
confused me as a Call option is about the upper tail, and
N(d1) looks like a lower tail probability. What they have done
is use d1=-z1 and d2=-z, where the z and z1 are what I have
used. My mind is wedded to the old "z=(x-mu)/sigma". Also,
where I have z1=z-tsigma they have d2=d1-tsigma. This is of
course the same thing, but I prefer the traditional
presentation showing clearly that z comes first and z1 is
derived from it.

OTHER FORMULAE:
--------------
Z(z1) is the unit normal ordinate at z1.
Here again q,r,s are not percentages.

CDelta : EXP(-q*T)*N(-z1) 
PDelta :-EXP(-q*T)*N(z1)
Gamma  : EXP(-q*T)*Z(z1)/P/s/SQRT(T)
CTheta : r*Call-(r-q)*P*CDelta -SQ(s*P)/2*Gamma
PTheta : r*Put -(r-q)*P*PDelta -SQ(s*P)/2*Gamma
CLambda:-T*P*CDelta          
PLambda:-T*P*PDelta
CRho   : T*X*EXP(-r*T)*N(-z) 
PRho   :-T*X*EXP(-r*T)*N(z)
Vega   : EXP(-q*T)*Z(z1)*P*SQR(T)

The EQN does not follow the above exactly - for example it
uses this form of algebra for CTheta:
(-r*CRho+T*q*P_CDelta-vega*s/2)/(T*Theta_F)

In addition Lambda, Rho and Vega are expressed
per percent, in the EQN. I put P*P*Gamma on the last page only
because it didn't fit nicely anywhere else, and also I have
never used it.

The above "Greeks" are only strictly valid for g%=r%.
(For g%<>r% other terms appear).

Re-stating the basic Put/Call formulae:
Call=P*EXP(-q*T)*N(-z1)  -  X*EXP(-r*T)*N(-z)
Put =X*EXP(-r*T)*N(z)    -  P*EXP(-q*T)*N(z1)
z=(LN(X/P)-(g-q+SQ(s)/2)*T)/s/SQRT(T)
z1=z-s*SQRT(T)

In terms of the UTPN function (Upper Tailed Probability
Normal) on the HP48/49 calculators:
Call= P*EXP(-q*T)*UTPN(T*(mu+SQ(s),T*SQ(s),LN(X/P))
     -X*EXP(-r*T)*UTPN(T*mu,T*SQ(s),LN(X/P))
So the following program may be used in the "NUM.SLV" on the
HP49G (in RPN mode) or in the HP48:
<<
g q - s SQ 2. / + T * s SQ T * X P / LN UTPN
P * q * T NEG EXP *
g q - s SQ 2. / - T * s SQ T * X P / LN UTPN
X * r * T NEG EXP *
- CALL -
>>

Also, on the HP49G in RPN mode this may be used:
`'P*EXP(-q*T)*UTPN(T*(g-q+SQ(s)/2),T*s^2,LN(X/P))
 -X*EXP(-r*T)*UTPN(T*(g-q-SQ(s)/2),T*s^2,LN(X/P))
 -CALL'`

Note the backward quotes surrounding the above.

One advantage of the HP48/49 is the built-in UTPN function which
is accurate to 1e-12, whereas the approximation I use is
accurate to 7.5e-8.

EXAMPLE
-------

This is taken from Chapter 14 of John Hull's book - 
"Options Futures and Other Derivatives".

Asset Data:
P=305 q%=3 r%=8 s%=25
On the first page of Solver do:
305 F2 3 F3 8 F4 25 F5

Option Data:
T=4/12 X=300
do:4 ENTER 12/ F6 300 F7
Set Theta_F=365 (press F10 5 times to get to the last page,
then do 365 F3, and F10 to get back to the first page)
and FIX 6 (Menu O N F 6 F10)

Solving for Call (F8) you should see:

P             =      305.000000
q%            =        3.000000
r%            =        8.000000
s%            =       25.000000
T             =        0.333333
X             =      300.000000
Call          =       22.468030
Put           =       12.608555

F10 for page 2 (values as at time zero):

CDelta        =        0.612577
P_CDelta      =      186.836082
mDXPOX        =     -164.368052
eq_Call       =       22.468030 (restates Call)
PDelta        =       -0.377473
DXPUX         =      127.737673
P_PDelta      =     -115.129118
eq_Put        =       12.608555 (restates Put)

F10 for page 3 (all small numbers, as at time zero):

Gamma         =        0.008572 Hull Ex. 14.5 gives .00866
CTheta        =       -0.088938 
PTheta        =       -0.049734 Hull Ex. 14.3 gives -0.0497
Clambda       =       -0.622787
PLambda       =        0.383764
CRho          =        0.547894
PRho          =       -0.425792 Hull Ex 14.8 gives -0.426
Vega          =        0.664479 Hull Ex 14.7 gives 0.6644

F10 for page 4 (all big numbers, as at time T):
TEVP          =      310.125931
TSDP          =       44.996977
TEVPOX        =      191.885402
mTXPOX        =     -168.810165
eq_CallPayout =       23.075237
TXPUX         =      131.189835
mTEVPUX       =     -118.240529
eq_PutPayout  =       12.949307

F10 for page 5 (misc. data, as at time T):

z             =       -0.157820
TPRPOX        =        0.562701
TPRPUX        =        0.437299
z1            =       -0.302157
ND1           =        0.618734
TNMU%         =        0.625000
NMU%          =        1.875000
TNSIG%        =       14.433757

F10 for last page (mainly additional parameters):
PP_Gamma=     =      797.374346
Theta_F       =      365.000000
#Call         =        1.000000
#Put          =        0.000000
#g%           =        0.000000
#g%_ov_r%     =        1.000000
g%            =        8.000000
g%_ov_r%      =        0.000000

Now, do 20 F8 (set g% to 20%) and press F6 (This sets #g%=1 &
#g%_ov_r%=0). Now, we can resolve for r% using a growth rate
of g=20%, and the Black-Scholes Call value already calculated.

i.e.:
F10 for page 1 again.
Press F4 to solve for r% (or, use the up/down arrows to
highlight r% then press spacebar), and see r%=8.92% which
exceeds the Black-Scholes r%=8%, showing it is no surprise
that a Black-Scholes strategy can produce returns
significantly above those assumed. I have seen market studies
that put this down to transaction costs of around 1%, but it
appears to be a built-in byproduct of the model itself.

If you study the new page 4 you will see how the new
expected CallPayout goes up to 31.556610 (from 23.075237) based on the
difference between 232.016550 and 200.459949) and on page 2
the "eq_Call" itself stays the same, but is likewise the
difference between 2 larger numbers than before (between
217.053103 and 194.585073 compared with 186.836082 and
164.368052)

The above example is used in Hull, as indicated for the 4
examples 14.3,14.5,14.7 and 14.8. Example 14.5 in my copy (5th
ed) gives 0.00866 whereas it should be 0.00857 as shown here.
The numbers shown here do agree with those produced by the
software that came with Hull's book.  

Tony Hutchins
th@csi.com
2003-02-23
