Lerch Transcendent Function for the HP-41
Overview
1°) Real Arguments
a) Focal Program
b) M-Code Routine
2°) Complex Arguments
3°) Quaternionic Arguments
-Lerch transcendent function is defined by F(
x , s , a ) = SUM k=0,1,2,.... xk / (
a + k )s ( F
is the greek letter "PHI" )
-The following programs compute this sum and stop when 2 consecutive
partial sums are equal.
1°) Real Arguments
a) Focal Program
-Here, we assume that x , s , a are 3 real numbers
( a # 0 , -1 , -2 , ..... )
Data Registers: R00
to R03: temp
Flags: /
Subroutines: /
01 LBL "LERCH"
02 STO 01 03 CLX 04 SIGN 05 STO 00 06 RDN 07 STO 02 08 X<>Y 09 STO 03 10 CHS 11 Y^X 12 LBL 01 13 RCL 01 14 RCL 00 15 * 16 STO 00 17 RCL 02 18 1 19 + 20 STO 02 21 RCL 03 22 Y^X 23 / 24 + 25 X#Y? 26 GTO 01 27 END |
( 38 bytes / SIZE 004 )
STACK | INPUTS | OUTPUTS |
Z | s | F( x , s , a ) |
Y | a | F( x , s , a ) |
X | x | F( x , s , a ) |
Examples:
PI ENTER^
0.6 ENTER^
0.7 XEQ "LERCH" >>>> F(
0.7 ; PI ; 0.6 ) = 5.170601130
---Execution time = 28s---
3 ENTER^
-4.6 ENTER^
0.8 R/S
>>>> F( 0.8 ; 3 ; -4.6
) = 3.152827048
---Execution time = 41s---
Note:
-Execution time tends to infinity as | x | tends to 1.
b) M-Code Routine
-Faster results may be obtained with M-Code.
-However, the Y^X function remains relatively slow, so the improvement
is real but not fantastic !
-No data register is used and the alpha "register" is undisturbed.
-But synthetic register Q is employed.
088 "H"
003 "C"
012 "R"
005 "E"
00C "L"
2A0 SETDEC
0F8 C=X
128 L=C
078 C=Z
2BE C=-C
0E8 X=C
3C4 C
045 =
06C Y^C
070 N=C ALL
04E C
35C =
050 1
068 Z=C
078 C=Z
LOOP
10E A=C ALL
138 C=L
135 C=
060 A*C
068 Z=C
0B8 C=Y
02E C
0FA ->
0AE AB
001 C=
060 AB+1
0A8 Y=C
0F8 C=X
3C4 C
045 =
06C Y^C
078 C=Z
13D C=
060 AB*C
0B0 C=N ALL
025 C=
060 AB+C
0F0 C<>N ALL
10E A=C ALL
0B0 C=N ALL
36E ?A#C ALL
32F JC-27d
goto LOOP
0E8 X=C
046 C
270 =
038 T
068 Z=C
0A8 Y=C
3E0 RTN
( 54 words )
STACK | INPUTS | OUTPUTS |
T | T | T |
Z | s | T |
Y | a | T |
X | x | F( x , s , a ) |
L | L | x |
Examples:
PI ENTER^
0.6 ENTER^
0.7 XEQ "LERCH" >>>> F(
0.7 ; PI ; 0.6 ) = 5.170601129
---Execution time = 19s---
3 ENTER^
-4.6 ENTER^
0.8 R/S
>>>> F( 0.8 ; 3 ; -4.6
) = 3.152827047
---Execution time = 27s---
Notes:
-Execution time also tends to infinity as | x | tends to 1.
-The M-Code routine is about 34% as fast as the focal program.
-There is no check for alpha data, overflow or underflow.
2°) Complex Arguments
-We now assume that z , s , a may be complex numbers.
Data Registers: R00 & R05 to R10: temp ( Registers R01 thru R04 are to be initialized before executing "ZLER" )
• R01-R02 = s
• R03-R04 = a
Flags: /
Subroutines: "Z*Z" "Z^Z" ( cf
"Complex Functions for the HP-41" )
01 LBL "ZLER"
02 STO 05 03 X<>Y 04 STO 06 05 CLX 06 STO 00 07 STO 10 08 SIGN 09 STO 09 10 RCL 04 11 RCL 03 12 RCL 02 13 CHS |
14 RCL 01
15 CHS 16 XEQ "Z^Z" 17 STO 07 18 X<>Y 19 STO 08 20 LBL 01 21 RCL 10 22 RCL 09 23 RCL 06 24 RCL 05 25 XEQ "Z*Z" 26 STO 09 |
27 X<>Y
28 STO 10 29 RCL 04 30 RCL 03 31 RCL 00 32 1 33 + 34 STO 00 35 + 36 RCL 02 37 CHS 38 RCL 01 39 CHS |
40 XEQ "Z^Z"
41 RCL 10 42 RCL 09 43 XEQ "Z*Z" 44 RCL 07 45 + 46 ENTER^ 47 X<> 07 48 - 49 ABS 50 X<>Y 51 RCL 08 52 + |
53 ENTER^
54 X<> 08 55 - 56 ABS 57 + 58 X#0? 59 GTO 01 60 RCL 08 61 RCL 07 62 END |
( 90 bytes / SIZE 011 )
STACK | INPUTS | OUTPUTS |
Y | y | Y |
X | x | X |
where X + i Y = F( x+i.y , s , a )
Example: Compute F( 0.3 + 0.4 i , 3 + 4 i , 1 + 2 i )
3 STO 01
1 STO 03
4 STO 02
2 STO 04
0.4 ENTER^
0.3 XEQ "ZLER" >>>>
7.658159106
---Execution time = 60s---
X<>Y -1.515114365
-So, F( 0.3 + 0.4 i , 3 + 4 i , 1 + 2 i ) = 7.658159106 - 1.515114365 i
Notes:
-The last decimals may differ according to the version of "Z^Z" or "Z*Z"
that you are using.
-The execution time was measured with an M-Code routine for Z*Z
3°) Quaternionic Arguments
-We can generalize the formulas above in several ways since the multiplication
is not commutative.
-Moreover, q^q' has also several definitions.
-"QLER" calculates F( x , s , a ) = SUM k=0,1,2,.... qk ( a + k ) -s
with b^c = exp [ ( Ln b ) c ]
Data Registers: R00 to R08: temp ( Registers R09 thru R16 are to be initialized before executing "QLER" )
• R09 to R12 = s
R17 to R20 = q R22 to R25 = q^k
• R13 to R16 = a
R21 = k
R26 to R29 = Sum
Flags: /
Subroutines: "Q*Q" "Q^Q" - the 2nd
version - ( cf "Quaternions for the HP-41" )
-Line 144 is a three-byte GTO 01
01 LBL "QLER"
02 STO 17 03 RDN 04 STO 18 05 RDN 06 STO 19 07 X<>Y 08 STO 20 09 CLX 10 STO 21 11 STO 23 12 STO 24 13 STO 25 14 SIGN 15 STO 22 16 RCL 13 17 STO 01 18 RCL 14 19 STO 02 20 RCL 15 21 STO 03 22 RCL 16 23 STO 04 24 RCL 09 25 CHS 26 STO 05 27 RCL 10 28 CHS 29 STO 06 30 RCL 11 |
31 CHS
32 STO 07 33 RCL 12 34 CHS 35 STO 08 36 XEQ "Q^Q" 37 STO 26 38 RDN 39 STO 27 40 RDN 41 STO 28 42 X<>Y 43 STO 29 44 LBL 01 45 RCL 17 46 STO 01 47 RCL 18 48 STO 02 49 RCL 19 50 STO 03 51 RCL 20 52 STO 04 53 RCL 22 54 STO 05 55 RCL 23 56 STO 06 57 RCL 24 58 STO 07 59 RCL 25 60 STO 08 |
61 XEQ "Q*Q"
62 STO 22 63 RDN 64 STO 23 65 RDN 66 STO 24 67 X<>Y 68 STO 25 69 RCL 13 70 RCL 21 71 1 72 + 73 STO 21 74 + 75 STO 01 76 RCL 14 77 STO 02 78 RCL 15 79 STO 03 80 RCL 16 81 STO 04 82 RCL 09 83 CHS 84 STO 05 85 RCL 10 86 CHS 87 STO 06 88 RCL 11 89 CHS 90 STO 07 |
91 RCL 12
92 CHS 93 STO 08 94 XEQ "Q^Q" 95 STO 05 96 RDN 97 STO 06 98 RDN 99 STO 07 100 X<>Y 101 STO 08 102 RCL 22 103 STO 01 104 RCL 23 105 STO 02 106 RCL 24 107 STO 03 108 RCL 25 109 STO 04 110 XEQ "Q*Q" 111 STO 01 112 CLX 113 RCL 27 114 + 115 ENTER^ 116 X<> 27 117 - 118 ABS 119 X<>Y 120 RCL 28 |
121 +
122 ENTER^ 123 X<> 28 124 - 125 ABS 126 + 127 X<>Y 128 RCL 29 129 + 130 ENTER^ 131 X<> 29 132 - 133 ABS 134 + 135 RCL 01 136 RCL 26 137 + 138 ENTER^ 139 X<> 26 140 - 141 ABS 142 + 143 X#0? 144 GTO 01 145 RCL 29 146 RCL 28 147 RCL 27 148 RCL 26 149 END |
( 221 bytes / SIZE 030 )
STACK | INPUTS | OUTPUTS |
T | t | T |
Z | z | Z |
Y | y | Y |
X | x | X |
where X + i Y + j Z + k T = F( x+i.y+j.z+k.t , s , a ) provided R09 thru R12 = s & R13 thru R16 = a
Example: Calculate q = F( 0.1 + 0.2 i + 0.3 j + 0.4 k , 3 + 4 i + 5 j + 6 k , 4 + 3 i + 2 j + k )
3 STO 09
4 STO 13
4 STO 10
3 STO 14
5 STO 11
2 STO 15
6 STO 12
1 STO 16
0.4 ENTER^
0.3 ENTER^
0.2 ENTER^
0.1 XEQ "QLER" >>>>
-0.306202194 = R26
---Execution time = 3m42s---
RDN 1.087605292 = R27
RDN 0.829024250 = R28
RDN 1.330181628 = R29
-So, q = -0.306202194 + 1.087605292 i + 0.829024250 j + 1.330181628 k
Notes:
-A different definition for q^q' would give a different
result, at least in the imaginary part.
-I've used an M-Code routine for Q*Q, so you could find small differences
in the last decimals.
-Several bytes may be saved if you employ the M-Code routines listed
in "M-Code routines for hypercomplex numbers"
-For instance, lines 111 to 142 may be simply replaced by DSQ
26
Reference: