The Museum of HP Calculators

HP Forum Archive 14

[ Return to Index | Top of Index ]

More bad news on the 17bII+ (Long)
Message #1 Posted by Bob Wang on 12 Jan 2005, 3:24 p.m.

Well, since L() and G() won't work on the new 17bII+ ROMs I decided to take a chance on the program size limitation being solved. NO SUCH LUCK! The more accurate 5th order polynomial approximation implementation can calculate the first half correctly, but returns CALLV=0 after about 70 characters into the second half.

This behavior seems similar to the L() and G() problem where G() seems to just return 0, no matter what. The Solver also seems to return 0, instead of an error, when a certain program size is exceeded.

I'm including my Black-Scholes program below for those masochists interested in entering it into their own 17bII+'s as an exercise. If you delete the entire second half, you'll get PS*N(d1) for CALLV, so for HP's example

PS=52 PE=45 RF%= 0.5 T=6 S=.2054

CALLV = 37.713812252994

Bob Wang

Black-Scholes using 5th Order Polynomial Approximation

BLK.SCHLS.5TH: 0×(PS+PE+RF%+T+S)

+PS×ABS( IF((LN(PS÷PE)+(RF%÷100+S^2÷2)×T)÷S÷SQRT(T)<0:0:-1) +((((1.061405429 ÷(1+.2316419×ABS((LN(PS÷PE)+(RF%÷100+S^2÷2)×T)÷S÷SQRT(T)))-1.453152027) ÷(1+.2316419×ABS((LN(PS÷PE)+(RF%÷100+S^2÷2)×T)÷S÷SQRT(T)))+1.421413741) ÷(1+.2316419×ABS((LN(PS÷PE)+(RF%÷100+S^2÷2)×T)÷S÷SQRT(T)))-.284496736) ÷(1+.2316419×ABS((LN(PS÷PE)+(RF%÷100+S^2÷2)×T)÷S÷SQRT(T)))+.254829592) ÷(1+.2316419×ABS((LN(PS÷PE)+(RF%÷100+S^2÷2)×T)÷S÷SQRT(T)))

×EXP(-((LN(PS÷PE)+(RF%÷100+S^2÷2)×T)÷S÷SQRT(T))^2÷2)÷2)

–PE×EXP(-RF%×T÷100)×ABS( IF((LN(PS÷PE)+(RF%÷100+S^2÷2)×T)÷S÷SQRT(T)-S×SQRT(T)<0:0:-1) +((((1.061405429 ÷(1+.2316419×ABS((LN(PS÷PE)+(RF%÷100+S^2÷2)×T)÷S÷SQRT(T)-S×SQRT(T)))-1.453152027) ÷(1+.2316419×ABS((LN(PS÷PE)+(RF%÷100+S^2÷2)×T)÷S÷SQRT(T)-S×SQRT(T)))+1.421413741) ÷(1+.2316419×ABS((LN(PS÷PE)+(RF%÷100+S^2÷2)×T)÷S÷SQRT(T)-S×SQRT(T)))-.284496736) ÷(1+.2316419×ABS((LN(PS÷PE)+(RF%÷100+S^2÷2)×T)÷S÷SQRT(T)-S×SQRT(T)))+.254829592) ÷(1+.2316419×ABS((LN(PS÷PE)+(RF%÷100+S^2÷2)×T)÷S÷SQRT(T)-S×SQRT(T)))

×EXP(-((LN(PS÷PE)+(RF%÷100+S^2÷2)×T)÷S÷SQRT(T)-S×SQRT(T))^2÷2)÷2)

-CALLV

      
Black-Scholes for HP-71B (different polynomial)
Message #2 Posted by Valentin Albillo on 13 Jan 2005, 9:18 a.m.,
in response to message #1 by Bob Wang

Hi, Bob:

Too bad the 17BII+ is giving you such a headache. Implementing Black-Scholes in other HP models can be very easy, like this very simple code of mine for the HP-71B, which uses a different polynomial approximation. Perhaps you can use this polynomial instead of yours, to try and fit the expression in your own machine:

>list
10 INPUT " Current price PS= ";P
20 INPUT "Exercise price PE= ";X
30 INPUT "Risk free rate RF= ";R
40 INPUT "Term of option T = ";T
50 INPUT "    Volatility S = ";S
60 PRINT @ R=R/100 @ D1=(LN(P/X)+R*T)/(S*SQR(T))+S*SQR(T)/2 @ D2=D1-S*SQR(T)
70 C=P*FNN(D1)-EXP(-R*T)*X*FNN(D2) @ PRINT "    Call Value CV=";C @ END
80 DEF FNN(D) @ N=.5*(1+.196854*D+.115194*D^2+.000344*D^3+.019527*D^4)^(-4)
90 IF X<0 THEN FNN=N ELSE FNN=1-N
Let's run your own example:
>RUN
 Current price PS= 52
Exercise price PE= 45
Risk free rate RF= 0.5
Term of option T = 6
    Volatility S = .2054

Call Value CV= 14.2383025355

and the first term is:
>P*FNN(D1)
 37.7232626591
more or less in accordance with your result. The corresponding program code for most any vintage SHARP handheld (the PC-1350 for example) is:
100 "S" CLEAR: INPUT "Current price P=";P
102 INPUT "Risk free rate R=";R
104 INPUT "Volatility S=";S
106 INPUT "Term of option T=";T
108 INPUT "Exercise price X=";X
110 D1=(LN(P/X)+R*T)/(S*SQR(T))+S*SQR(T)/2, D2=D1-S*SQR(T)
120 D=D1: GOSUB "N": N1=N, D=D2: GOSUB "N": N2=N, CV=P*N1-EXP(-R*T)*X*N2
130 PRINT "Call Value=";CV: END
140 "N" N=1-.5*(1+.196854*D+.115194*D^2+.000344*D^3+.019527*D^4)^-4
150 IF X<0 LET N=1-N
160 RETURN

Best regards from V.

            
Re: Black-Scholes for HP-71B (different polynomial)
Message #3 Posted by hugh steers on 13 Jan 2005, 10:15 a.m.,
in response to message #2 by Valentin Albillo

hey valentin,

bob’s program uses hasting approx whose error is bounded by 7.5e-8, but yours is bounded by 2.5e-4. you could get better accuracy (but still less than bob) with a shorter approximation, thus:

UTPN(x) = exp(-x*x/2-4*x/(x/.85+5))/2

error bounded by 9.2e-5.

                  
Re: Black-Scholes for HP-71B (different polynomial)
Message #4 Posted by Valentin Albillo on 13 Jan 2005, 11:34 a.m.,
in response to message #3 by hugh steers

Thank, Hugh, but come to that I could simply use the INTEGRAL keyword and have a relative error of 1.E-12 or so, i.e., nearly full machine precision.

I refrained from doing so as I guess the 17BII+ doesn't have the INTEGRAL functionality (not to mention the SHARPs or most BASIC dialects). The idea was to provide a shorter (if less accurate) formula that perhaps would do where the longer, more accurate one wouldn't.

Thanks again and best regards from V.

                        
Re: Black-Scholes for HP-71B (different polynomial)
Message #5 Posted by hugh steers on 13 Jan 2005, 12:41 p.m.,
in response to message #4 by Valentin Albillo

indeed, and this is a peeve i have with hp’s latest models.

these days, if you’re going to market a professional financial model, it should already have black scholes, utpn, erf, and others together with their inverses to full precision. why not?

is the 17bi++ a rom emulation of the old 17bii (if so, why doesn’t l() & g() work properly) or is it a remake like the 12cp?

if a rom emulation, surely you could add new codes that map into new features, if not, then there’s no excuse not to add the new features.

or is it simply, that the model was completely engineered outside hp and the 17bii was given as a “specification” for the new model?

                              
Re: Black-Scholes for HP-71B (different polynomial)
Message #6 Posted by Ron Ross on 13 Jan 2005, 12:58 p.m.,
in response to message #5 by hugh steers

I shouldn't bother to rant and rave, but I get so fed up with Hp incompetence in their designs and screw ups!

First you have a bunch of whipped puppies left, if you speak out, Carly's henchmen will hunt you down and find a Compaq drone to replace you with. (a side note here, HP bought Compaq, not the other way around, but guess who lost their jobs, except for Carly. This is easily verified, many Hp execs were replaced with their Compaq counterparts.)

Not that Hp marketing was a whole lot better when they were in charge either.

Today, Hp could make the Hp17Bii+ with buried trig functions (or just toss in the Hp42s with a replacable face plate like the Hp30s) and toggle it between modes. Give it a USB or RS 232 port (I prefer RS 232), and sell it for $100 (same price as an Hp48Gii, which is what the Hp17Bii+ actually does sell for).

But a calculator like that would ROB sales from their graphics line ( I suspect the thought of robbing sales from Ti's graphics line doesn't even come up).

I stand upon this mountain (I am fanatasizing again) and shout, "HP, YOU ARE A BUNCH OF MORONS!"

I don't think they care, or they may even be laughing at the Hp calculator zealot that I am.

I end another RANT!

                              
Re: Black-Scholes for HP-71B (different polynomial)
Message #7 Posted by Valentin Albillo on 13 Jan 2005, 1:12 p.m.,
in response to message #5 by hugh steers

Hi again, Hugh:

"these days, if you’re going to market a professional financial model, it should already have black scholes, utpn, erf, and others together with their inverses to full precision. why not?"

Indeed. But nobody cares at KinHPo.

"is the 17bi++ a rom emulation of the old 17bii (if so, why doesn’t l() & g() work properly) or is it a remake like the 12cp?"

I daresay it's a (bad) remake.

"if a rom emulation, surely you could add new codes that map into new features, if not, then there’s no excuse not to add the new features."

Again true. But nobody cares at KinHPo.

"or is it simply, that the model was completely engineered outside hp and the 17bii was given as a “specification” for the new model?"

Most probable. But nobody cares at KinHPo. If someone did, the 33S wouldn't have an antiergonomic key layout, poor display and invisible decimal point, nor would it have nearly 32 Kb of unusable RAM, nor would it fail miserably when doing some essential mathematical operations. The HP-12C Platinum wouldn't have a sub-par, "pessimized" algorithm to compute the IRR, nor would it have the serious GOTO bug which makes it very difficult to use the 400-steps RAM for long programs, nor ...

But who cares ? Who's counting ? Everyone has their own interests and I couldn't be less interested in the latest KinHPo crap. This is a "Museum of HP", so theoretically devoted to the awesome models of old, and as long as I do have a functioning, physical HP-15C, HP-41CX, HP42S, or HP-71B (to name a few, let alone my SHARPs), and a wonderful site dedicated to them such as this, who cares what KinHPo does or doesn't do ? They are NONEXISTENT to me.

Best regards from V.

                  
Re: Black-Scholes for HP-71B (different polynomial)
Message #8 Posted by tony on 13 Jan 2005, 3:48 p.m.,
in response to message #3 by hugh steers

Hi Hugh,

Quote:
UTPN(x) = exp(-x*x/2-4*x/(x/.85+5))/2

error bounded by 9.2e-5.

That is indeed a good approximation to UTPN(x) for x>=0.
The absolute error bound is [-9.14e-5, 5.62e-5].
I'm curious if you saw this in an HPCC DataFile article (V23N3p25) about Peter Carr's Black-Scholes program for the HP-12C, or did you find it elsewhere?
Review of Peter Carr's HP-12C Black-Scholes

Tony

                        
Re: Black-Scholes for HP-71B (different polynomial)
Message #9 Posted by hugh steers on 13 Jan 2005, 7:19 p.m.,
in response to message #8 by tony

yes, i confess. i did get this from datafile.

i remember reading this in issue v23n3 from last june and being impressed by the derenzo formula for Q. in the past, i have played with many approximations to this function, but none of these have ever been interested in making the coefficients shorter (ie for calculator programming) which is why the derenzo formula is so elegant.

i am also intrigued by the hp32e’s ability to get full 10 digit accuracy for both is Q and inverse Q functions. i wonder what approximation it uses. whatever it does, its good at it.

                              
Re: Black-Scholes for HP-71B (different polynomial)
Message #10 Posted by tony on 13 Jan 2005, 9:01 p.m.,
in response to message #9 by hugh steers

Ah I should have guessed - now I see you in the HPCC MemberPack :-). I have Stephen Derenzo's original paper. Brilliant piece of work, and what Peter Carr did with the Q was most ingenious - and stimulated by the challenge of just fitting something reasonable in the HP-12C.

                                    
Re: Black-Scholes for HP-71B (different polynomial)
Message #11 Posted by hugh steers on 14 Jan 2005, 6:43 a.m.,
in response to message #10 by tony

its probably the best use of the 12c program memory ever.


[ Return to Index | Top of Index ]

Go back to the main exhibit hall