Hi Angel,
Many thanks for your appreciations.
The complex version "JNZ" is missing in the museum,
all the more that I wrote it after your post on J1+i(-1-i)
-Here is the listing:
Data Registers: R00 thru R10: temp
Flag: F01 CF 01 to compute Jn(z)
SF 01 to compute In(z)
Subroutines: "GAMZ" or "GAMZ+" ( cf "Gamma Function For the HP-41" § 1°)-h) )
"Z^2" "Z*Z" "Z^Z" "Z/Z" ( cf "Complex Functions for the HP-41" )
"Z^2" "Z*Z" ... and so on ... may replaced by M-Code routines
( cf "A few M-Code Routines for the HP-41" )
01 LBL "JNZ"
02 STO 01
03 RDN
04 STO 02
05 RDN
06 STO 03
07 X<>Y
08 STO 04
09 2
10 ST/ 01
11 ST/ 02
12 RCL 02
13 RCL 01
14 XEQ "Z^2"
15 STO 09
16 X<>Y
17 STO 10
18 CLX
19 STO 06
20 STO 08
21 SIGN
22 STO 00
23 STO 05
24 STO 07
25 LBL 01
26 RCL 10
27 RCL 09
28 RCL 06
29 RCL 05
30 XEQ "Z*Z"
31 RCL 00
32 FC? 01
33 CHS
34 ST/ Z
35 /
36 RCL 03
37 RCL 00
38 +
39 RCL 04
40 X<>Y
41 XEQ "Z/Z"
42 STO 05
43 X<>Y
44 STO 06
45 RCL 08
46 +
47 STO 08
48 LATSX
49 -
50 X<>Y
51 RCL 07
52 +
53 STO 07
54 LASTX
55 -
56 R-P
57 ISG 00
58 CLX
59 X#0?
60 GTO 01
61 RCL 02
62 RCL 01
63 RCL 04
64 RCL 03
65 XEQ "Z^Z"
66 RCL 08
67 RCL 07
68 XEQ "Z*Z"
69 STO 07
70 X<>Y
71 STO 08
72 RCL 04
73 RCL 03
74 1
75 +
76 XEQ "GAMZ" or XEQ "GAMZ+"
77 RCL 08
78 RCL 07
79 R^
80 R^
81 XEQ "Z/Z"
82 END
( 125 bytes / SIZE 011 )
STACK INPUTS OUTPUTS
T b /
Z a /
Y y Im [ f(z) ]
X x Re [ f(z) ]
n = a + i b
where z = x + i y
and f(z) = Jn(z) if flag F01 is clear,
f(z) = In(z) if flag F01 is set.
Examples: n = 1 + 4 i , z = 2 + 3 i
• CF 01
4 ENTER^
1 ENTER^
3 ENTER^
2 XEQ "JNZ" >>>> J1+4i ( 2+3.i ) = 0.342267397 - 0.424349408 i ( Execution time = 33s )
• SF 01
4 ENTER^
1 ENTER^
3 ENTER^
2 XEQ "JNZ" >>>> I1+4i ( 2+3.i ) = 1.391608538 + 0.315041667 i ( Execution time = 33s )
With respect to the Lambert W functions, "ROOTZ" seems to work well
provided we choose 2 initial guesses close to Ln(z) [ if z # 0 ]
For example, if z = 5 + 5i , try z0 = 1.9 + 0.8 i and z1 = 2 + 0.9 i
With the subroutine
LBL "W"
STO 11
X<>Y
STO 12
X<>Y
XEQ "E^Z"
RCL 12
RCL 11
XEQ "Z*Z"
RCL 10
RCL 09
XEQ "Z-Z"
RTN
"ROOTZ" returns w(5+5i) = 1.501424530 + 0.477488825 i after 6 or 7 iterations.
But Newton's method has a better convergence,
and it is used in the following routine:
LBL "LAMBZ"
STO O1
X<>Y
STO 02
R-P
X=0?
GTO 01
RCL 02
RCL 01
XEQ "LNZ"
GTO 02
LBL 01
CLST
LBL 02
STO 03
X<>Y
STO 04
LBL 03
RCL 04
RCL 03
XEQ "E^Z"
STO 05
X<>Y
STO 06
X<>Y
RCL 04
RCL 03
XEQ "Z*Z"
ST+ 05
X<>Y
ST+ 06
X<>Y
RCL 02
RCL 01
XEQ "Z-Z"
RCL 06
RCL 05
XEQ "Z/Z"
CHS
RCL 03
+
STO 03
LASTX
-
X<>Y
CHS
RCL 04
+
STO 04
LASTX
-
R-P
VIEW 03
E-9
X<Y?
GTO 03
RCL 04
RCL 03
END
and for example, 5 ENTER^ XEQ "LAMBZ" gives
w(5+5i) = 1.501424530 + 0.477488825 i
( the same result as "ROOTZ" with one iteration less )
Likewise w(7+9i) = 1.796464032 + 0.591616466 i
"RTZ4" should give even faster results...
My contribution to the HP-41 programs has not stopped:
Since 2007, I've sent about 80 ( yes, eighty ) new or updated pages
and I'm surprised not to see them in the MoHPC!
Perhaps will I create my own website, but it's impossible for the moment:
my access provider has many problems since the end of October
and it still does not work normally!
Best Regards,
Jean-Marc.