 The Museum of HP Calculators

# HP-85B: Mandelbrot

Copyright (C) 2002 Glen Kilpatrick

This program is supplied without representation or warranty of any kind. The author and The Museum of HP Calculators therefore assume no responsibility and shall have no liability, consequential or otherwise, of any kind arising from the use of this program material or any part thereof.

## Description

I hardly need introduce Benoit B. Mandelbrot's fascinating discovery. A Google search on "Mandelbrot Set" turned up "about 35,900" hits as I was writing this; many of them will probably give a better introduction than I can, so I'm going to completely pass over what it is, and just give code to compute it.

## Notes

I sold my HP-85B to Museum of HP Calculators years ago, so may not be very useful for support, but you're always welcome to ask....

## Example

None given. This is a "hardcoded" example to be executed directly. Exploration of the Mandelbrot set is done by varying the DATA statement at line 210, then re-executing the program.

## Program Listing

```10 ! HP-85B (Benoit B.) Mandelbrot Set (ported from HP-28S 6->19SEP92)
30 ! 1:1 aspect for 132*73 HP-28S is (-6.1015625,-1.25),(4.6015625,1.25)
40 CLEAR @ INTEGER B,N.P,R ! ?0/1/8/9 <=> Real/Imaginary/Lower/Upper
50 T8=TIME @ D8=DATE @ READ X8,X9,Y8,Y9,B,R,P ! 1:1 aspect for 256*192
60 PEN P @ A=(X9-X8)/(Y9-Y8) @ A=A*192/256 @ IF A>=1 THEN 70 ELSE 80
70 M=Y8+(Y9-Y8)/2 @ D=M-Y8 @ D=D*A @ Y8=M-D @ Y9=M+D @ GOTO 90 ! *H
80 M=X8+(X9-X8)/2 @ D=M-X8 @ D=D/A @ X8=M-D @ X9=M+D ! INV *W
90 DISP INT(.5+SQR(100/9+6.25)/SQR((X9-X8)^2+(Y9-Y8)^2));"magnification"
100 DISP "PMIN=(";X8;",";Y8;")" @ DISP "PMAX=(";X9;",";Y9;")"
110 DISP "RES=";R;"BntB=";B @ WAIT 99999 @ SCALE X8,X9,Y8,Y9 @ GCLEAR
120 FOR C0=X8 TO X9 STEP R*(X9-X8)/256 ! outer loop runs left -> right
130 FOR C1=Y8 TO Y9 STEP R*(Y9-Y8)/192 ! inner loop runs bottom -> top
140 Z0,Z1=0 @ FOR N=1 TO B @ T0=Z0 @ Z0=Z0*Z0-Z1*Z1+C0 @ Z1=2*T0*Z1+C1
150 IF Z0*Z0+Z1*Z1>4 THEN 170 ! set exclusion loop (|R|>2 => not in set)
160 NEXT N @ PENUP @ PLOT C0,C1 @ PENUP ! set inclusion, plot this point
170 NEXT C1 @ NEXT C0 @ D9=DATE @ T9=TIME ! done; show hours, toggle axes
180 DISP (D9-D8)*24+INT(.5+10*((24*(T9-T8)/3600)MOD24))/10;"hours"
190 XAXIS Y8,(X9-X8)/10 @ YAXIS X9,(Y9-Y8)/10 @ P=-P @ PEN P
200 YAXIS X8,(Y9-Y8)/10 @ XAXIS Y9,(X9-X8)/10 @ WAIT 99999 @ GOTO 190
210 DATA -2.41666666667,.91666666667,-1.25,1.25,100,1,-1
220 END
```

Not applicable.