The Museum of HP Calculators


Theta Functions for the HP-41

This program is Copyright © 2006 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
 

Definitions:       with  q =  e-pi K'/K  ( see Jacobian elliptic functions for the HP-41 )

   Theta1(x;q) =  2.q1/4 SUMk>=0  (-1)k qk(k+1) sin(2k+1)x
   Theta2(x;q) =  2.q1/4 SUMk>=0    qk(k+1) cos(2k+1)x
   Theta3(x;q) =  1 + 2 SUMk>=1    qk*k cos 2kx                                  ( 0 <= q < 1 )
   Theta4(x;q) =  1 + 2 SUMk>=1  (-1)k qk*k cos 2kx
 

Program Listing
 

Data Registers:  /
Flags: F01 , F02 , F03 , F04   ( Set  only one of these 4 Flags )
Subroutines: /

-If flag F01 is set , "THETA" calculates Theta1(x;q)
-If flag F02 is set , "THETA" calculates Theta2(x;q)
-If flag F03 is set , "THETA" calculates Theta3(x;q)
-If flag F04 is set , "THETA" calculates Theta4(x;q)

-Synthetic registers M , N , O may be replaced by any unused data registers.
 

01  LBL "THETA"
02  RAD
03  STO M
04  10
05  CHS
06  RCL Z
07  ABS
08  STO N
09  X#0?
10  LOG
11  X#0?
12  /
13  SQRT
14  INT
15  STO O
16  CLX
17  ISG O
18  LBL 01
19  RCL N
20  RCL O
21  FC? 01
22  FS?02
23  ISG X
24  ""                     TEXT0   or another NOP instruction like  LBL 02   STO X   ABS  ...  etc  ...
25  Y^X
26  FC? 01
27  FS? 04
28  CHS
29  RCL O
30  Y^X
31  LASTX
32  ST+ X
33  FC? 01
34  FS? 02
35  ISG X
36  ""                     TEXT0   or another NOP instruction like  LBL 02   STO X   ABS  ...  etc  ...
37  RCL M
38  *
39  FS? 01
40  SIN
41  FC? 01
42  COS
43  *
44  +
45  DSE O
46  GTO 01
47  FC? 01
48  FS? 02
49  RCL M
50  FS? 01
51  SIN
52  FS? 02
53  COS
54  FC? 03
55  FS? 04
56  .5
57  +
58  ST+ X
59  RCL N
60  SQRT
61  SQRT
62  FC? 03
63  FS? 04
64  SIGN
65  *
66  RCL M
67  SIGN
68  X<> N
69  X<>Y
70  DEG
71  CLA
72  END

( 119 bytes / SIZE 000 )
 
 
      STACK        INPUTS     OUTPUTS
           Y             q            q
           X             x    Thetan (x;q)
           L             /            x

Example:   Compute  Theta1(x;q) , Theta2(x;q) , Theta3(x;q) , Theta4(x;q)   for  x = 2 ; q = 0.3

- CF02 CF 03 CF 04

- SF 01                0.3  ENTER^   2   XEQ "THETA"  gives      1.382545289        ( in 12 seconds )
- CF01   SF 02    0.3  ENTER^   2         R/S              -----     -0.488962527         --------------
- CF 02  SF 03    0.3  ENTER^   2         R/S              -----      0.605489938         --------------
- CF 03  SF 04    0.3  ENTER^   2         R/S              -----      1.389795845         --------------
 

Reference:       Abramowitz and Stegun , "Handbook of Mathematical Functions" -  Dover Publications -  ISBN  0-486-61272-4
 

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