hp41programs

Theta

Theta Functions for the HP-41


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                                  ( -1 < q < 1 )
   Theta4(x;q) =  1 + 2 SUMk>=1  (-1)k qk*k cos 2kx
 

Program Listing
 

Data Registers:  R00-R03: temp  R01 = x  R02 = q
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 STO 01
 03 10
 04 CHS
 05 RCL Z
 06 STO 02
 07 ABS
 08 X#0?
 09 LOG
 10 X#0?
 11 /
 12 SQRT
 13 INT
 14 STO 00
 15 1
 16 FC? 01
 17 FS? 04
 18 CHS
 19 X<>Y
 20 Y^X
 21 STO 03          
 22 CLX
 23 RAD
 24 ISG 00
 25 LBL 01
 26 RCL 02
 27 RCL 00
 28 ENTER
 29 ST* Y
 30 FC? 03
 31 FS? 04
 32 CLX
 33 +
 34 Y^X
 35 RCL 03
 36 FC? 01
 37 FS? 04
 38 CHS
 39 STO 03          
 40 *
 41 RCL 00
 42 ST+ X
 43 RCL 01
 44 ST* Y
 45 FC? 03
 46 FS? 04
 47 CLX
 48 +
 49 FS? 01
 50 SIN
 51 FC? 01
 52 COS
 53 *
 54 +
 55 DSE 00
 56 GTO 01
 57 FC? 01
 58 FS? 02
 59 RCL 01          
 60 FS? 01
 61 SIN
 62 FS? 02
 63 COS
 64 DEG
 65 FC? 03
 66 FS? 04
 67 .5
 68 +
 69 ST+ X
 70 RCL 02          
 71 ABS
 72 SQRT
 73 SQRT
 74 FC? 03
 75 FS? 04
 76 SIGN
 77 *
 78 END

 
     ( 116 bytes / SIZE 004 )
 
 

      STACK        INPUTS     OUTPUTS
           Y             q            /
           X             x    Thetan (x,q)

 
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             ---Execution time = 10s---
- CF01   SF 02    0.3  ENTER^   2         R/S              gives     -0.488962527
- CF 02  SF 03    0.3  ENTER^   2         R/S              gives      0.605489938                           idem
- CF 03  SF 04    0.3  ENTER^   2         R/S              gives      1.389795845
 

Reference:

[1]  Abramowitz and Stegun , "Handbook of Mathematical Functions" -  Dover Publications -  ISBN  0-486-61272-4