The Museum of HP Calculators


Quadrics for the HP-41

This program is Copyright © 2005 by Jean-Marc Baillard and is used here by permission.

This program is supplied without representation or warranty of any kind. Jean-Marc Baillard 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.

Overview

-A Quadric ( or quadratic surface ) is defined by its cartesian equation:  a.x2 + b.y2 + c.z2 + d.x.y + e.x.z + f.y.z + g.x + h.y + i.z = j
 where at least one of the 6 coefficients   a , b , c , d , e , f  is different from zero.
-After a suitable transformation of coordinates, this equation is reduced to one of the 17 standard forms:

 1°)    x2/a2 + y2/b2 + z2/c2 = 1    Ellipsoid
 2°)    x2/a2 + y2/b2 - z2/c2 = 1    Hyperboloid of one sheet
 3°)    x2/a2 - y2/b2 - z2/c2 = 1     Hyperboloid of two sheets
 4°)    x2/a2 + y2/b2  = z              Elliptic Paraboloid
 5°)    x2/a2 - y2/b2  = z               Hyperbolic Paraboloid

 6°)    x2/a2 + y2/b2 - z2/c2 = 0    Cone
 7°)    x2/a2 + y2/b2  = 1              Elliptic Cylinder
 8°)    x2/a2 - y2/b2  = 1               Hyperbolic Cylinder
 9°)    x2/a2  = y                          Parabolic Cylinder
10°) -x2/a2 - y2/b2 - z2/c2 = 1     Imaginary Ellipsoid
11°)  x2/a2 + y2/b2 + z2/c2 = 0    One Point  ( more precisely an Imaginary Cone )
12°) -x2/a2 - y2/b2  = 1               Imaginary Elliptic Cylinder
13°)  x2/a2 = 0                            One Plane
14°)  x2/a2 = 1                            Two Parallel Planes
15°)  -x2/a2 = 1                          Two Imaginary Parallel Planes
16°)  x2/a2 + y2/b2  = 0              One Straight-Line ( more precisely Two Imaginary Intersecting Planes )
17°)  x2/a2 - y2/b2  = 0               Two Intersecting Planes
 

-The following program uses the Jacobi's iterating method to determine these reduced equations and the type of the quadric.
 

Data Registers:     R00:  unused                                      ( Registers R01 thru R10 are to be initialized before executing "QUADRIC" )

                             R01 = a   R02 = b   R03 = c   R04 = d   R05 = e
                             R06 = f    R07 = g   R08 = h   R09 = i    R10 = j

                         When the program stops, the coefficients of the reduced form are in R01 thru R10
Flags: /
Subroutines: /
 

  01  LBL "QUADRIC"
  02  LBL 01
  03  VIEW 04
  04  RCL 01
  05  RCL 04
  06  RCL 01
  07  RCL 02
  08  ST+ T
  09  -
  10  R-P
  11  RDN
  12  X<> 04
  13  LASTX
  14  R-P
  15  X<>Y
  16  RDN
  17  ST- Z
  18  +
  19  2
  20  ST/ 04
  21  ST/ Z
  22  /
  23  STO 01
  24  X<>Y
  25  STO 02
  26  RCL 04
  27  RCL 07
  28  P-R
  29  RCL 04
  30  RCL 08
  31  P-R
  32  R^
  33  -
  34  STO 08
  35  RDN
  36  +
  37  STO 07
  38  RCL 04
  39  RCL 05
  40  P-R
  41  RCL 04
  42  RCL 06
  43  P-R
  44  R^
  45  -
  46  STO 06
  47  RDN
  48  +
  49  STO 05
  50  R^
  51  R-P
  52   E-8
  53  X>Y?
  54  GTO 03
  55  LASTX
  56  ABS
  57  RCL 05
  58  ABS
  59  X>Y?
  60  GTO 02
  61  RCL 01
  62  X<> 03
  63  STO 01
  64  CLX
  65  X<> 06
  66  STO 04
  67  RCL 07
  68  X<> 09
  69  STO 07
  70  GTO 01
  71  LBL 02
  72  RCL 02
  73  X<> 03
  74  STO 02
  75  CLX
  76  X<> 05
  77  STO 04
  78  RCL 08
  79  X<> 09
  80  STO 08
  81  GTO 01
  82  LBL 03
  83  CLX
  84  STO 04
  85  XEQ 05
  86  RCL 01
  87  X#0?
  88  GTO 02
  89  X<> 02
  90  STO 01
  91  RCL 07
  92  X<> 08
  93  STO 07
  94  LBL 02
  95  RCL 01
  96  X#0?
  97  GTO 02
  98  X<> 03
  99  STO 01
100  RCL 07
101  X<> 09
102  STO 07
103  LBL 02
104  RCL 02
105  X#0?
106  GTO 02
107  X<> 03
108  STO 02
109  RCL 08
110  X<> 09
111  STO 08
112  LBL 02
113  RCL 07
114  X^2
115  RCL 01
116  /
117  RCL 08
118  X^2
119  RCL 02
120  X=0?
121  GTO 04                    ( it should be a three-byte GTO )
122  /
123  +
124  RCL 09
125  X^2
126  RCL 03
127  X=0?
128  GTO 03
129  /
130  +
131  4
132  /
133  ST+ 10
134  CLX
135  STO 07
136  STO 08
137  STO 09
138  XEQ 05
139  RCL 10
140  X=0?
141  GTO 02
142  ST/ 01
143  ST/ 02
144  ST/ 03
145  ST/ 10
146  LBL 02
147  RCL 01
148  SIGN
149  RCL 02
150  SIGN
151  +
152  RCL 03
153  SIGN
154  +
155  RCL 10
156  X=0?
157  GTO 02
158  " IM ELLIPS"          Imaginary Ellipsoid
159  SIGN
160  X=Y?
161  " 1-SH HYP"           One-sheeted Hyperboloid
162  X<Y?
163  " ELLIPSOID"
164  CHS
165  X=Y?
166  " 2-SH HYP"           Two-sheeted Hyperboloid
167  PROMPT
168  LBL 02
169  SIGN
170  X<>Y
171  ABS
172  " POINT"                ( More precisely:  Imaginary Cone with only one real point )
173  X=Y?
174  " CONE"
175  PROMPT
176  LBL 03
177  X<> Z
178  4
179  /
180  ST+ 10
181  CLX
182  STO 07
183  STO 08
184  XEQ 05
185  RCL 01
186  RCL 02
187  *
188  RCL 09
189  X=0?
190  GTO 02
191  ST/ 01
192  ST/ 02
193  ST/ 09
194  CLX
195  STO 10
196  X<>Y
197  " ELL PARAB"       Elliptic Paraboloid
198  X<0?
199  " HYP PARAB"      Hyperbolic Paraboloid
200  PROMPT
201  LBL 02
202  CLX
203  RCL 10
204  X=0?
205  GTO 02
206  ST/ 01
207  ST/ 02
208  ST/ 10
209  X<>Y
210  " HYP CYL"           Hyperbolic Cylinder
211  X<0?
212  PROMPT
213  RCL 01
214  " ELL CYL"            Elliptic Cylinder
215  X<0?
216  " IM ELL CYL"      Imaginary Elliptic Cylinder
217  PROMPT
218  LBL 02
219  X<>Y
220  " STR LINE"           One Straight-Line  ( In fact, 2 intersecting imaginary planes )
221  X<0?
222  " 2 PLANES"          Two intersecting planes
223  PROMPT
224  LBL 04
225  X<> Z
226  4
227  /
228  ST+ 10
229  CLX
230  STO 07
231  XEQ 05
232  RCL 08
233  RCL 09
234  R-P
235  X=0?
236  GTO 02
237  RCL 01
238  ST/ 01
239  /
240  STO 08
241  CLX
242  STO 09
243  STO 10
244  " PARAB CYL"        Parabolic Cylinder
245  PROMPT
246  LBL 02
247  " PLANE"                 One Plane
248  RCL 10
249  X=0?
250  PROMPT
251  ST/ 01
252  ST/ 10
253  " 2 IM PLANES"      Two imaginary parallel Planes
254  RCL 01
255  X>0?
256  " 2//PLANES"           Two parallel Planes
257  PROMPT
258  LBL 05
259  10                              or  1  10^X  ( thus saving one byte )
260   E-7                           or another "small" number
261  LBL 06
262  RCL IND Y
263  ABS
264  X<Y?
265  CLX
266  X=0?
267  STO IND Z
268  RDN
269  DSE Y
270  GTO 06
271  END

( 503 bytes / SIZE 011 )
 

Example1:     (Q):  2xy + 3xz + 4yz = 7

   0  STO 01  STO 02  STO 03  2  STO 04  3  STO 05  4  STO 06  0  STO 07  STO 08  STO 09  7  STO 10
   XEQ "QUADRIC"  the HP-41 displays the successive contents of register R04 ( which tend to zero )

   and eventually displays " 2-SH HYP"      (Q) is an hyperboloid of 2 sheets

-Recalling the new coefficients in registers R01 thru R10 we find:   0.433905256 x2 - 0.299134471 y2 - 0.134770785 z2 = 1
  which may be re-written:   x2/a2 - y2/b2 - z2/c2 = 1   with  a = 1.518107565 , b = 1.828381291 , c = 2.723968753

-The signs may be  + - - ; - + - or - - +  for a 2-sheeted hyperboloid.

Example2:      (Q):   2x2 + y2 + 2z2 - 3xy + 4xz -3yz + 7x + y + 5z = 10

   2  STO 01   1  STO 02  ................  10  STO 10     XEQ "QUADRIC"  >>>>  " HYP PARAB"          (Q) is an hyperbolic Paraboloid

  and the new coefficients in R01 to R10 yield:   -3.604884263 x2 + 0.069350354 y2 + z = 0
  which may be re-written:    x2/a2 - y2/b2  = z   with  a = 0.526689108 ,  b = 3.797306556
 

Remarks:

-The numbers displayed line 04 may seem to increase in the beginning, but they soon tend to zero.
-Of course, execution time depends on the coefficients, but it's usually less than 1 minute.
-When the program stops, R04 = R05 = R06 = 0
-There will be a DATA ERROR line 116  if  a = b = c = d = e = f = 0  ( the equation reduces to  g.x + h.y + i.z = j )
-If you want to take this case into account,
 add   RTN  LBL 07  RCL 07  RCL 08  R-P  RCL 09  R-P  " PLANE"  X#0?  PROMPT  " EMPTY SET"  RCL 10  X=0?  " SPACE"  PROMPT  after line 270
 and add   X=0?  GTO 07  after line 115
-Practically, lines 158-216-253  may replaced with " EMPTY SET"
-Many bytes can be saved if you use more abbreviated alpha strings.
-Register R00 may be used instead of R10 but in this case, replace line 269  by  ISG Y and line 259  by  9   CHS

-This program uses 10-7 ( line 260 ) to identify and delete tiny elements.
-Change this value if, for instance, the coefficients are of the order of 106  ( or divide them by 1 million )

Go back to the HP-41 software library
Go back to the general software library
Go back to the main exhibit hall