The Museum of HP Calculators

HP Forum Archive 20

[ Return to Index | Top of Index ]

Lambert W functions on WP 34s
Message #1 Posted by Hans Milton on 25 Nov 2011, 9:00 a.m.

It is impressive to see the Lambert W functions included in WP 34s.
However, the W-1 function give incorrect results. Example:

x ex = -0.2 has two solutions
-0.259171
-2.542641

On the emulator W(-0.2) correctly returns the first solution.
But W-1(-0.2), which is expected to give the second solution,
instead returns -0.163746

      
Re: Lambert W functions on WP 34s
Message #2 Posted by Walter B on 25 Nov 2011, 9:26 a.m.,
in response to message #1 by Hans Milton

FYI, W^-1 represents the inverse of W in the WP 34S.

            
Re: Lambert W functions on WP 34s
Message #3 Posted by Hans Milton on 25 Nov 2011, 10:10 a.m.,
in response to message #2 by Walter B

I see. What I thought was the Lambert W-1 function is
actually the inverse of the Lambert W0 function. Which
could also be easily calculated as x ex.

W-1 is not so easily calculated. So would be more useful
to have on the calc.

                  
Re: Lambert W functions on WP 34s
Message #4 Posted by Walter B on 26 Nov 2011, 4:57 a.m.,
in response to message #3 by Hans Milton

With the next software build, you'll find both branches on the WP 34S: Wp for the principal branch and Wm=W-1 for the lower branch. The latter is calculated by an XROM routine, so it may not be as accurate as Wp.

                        
Re: Lambert W functions on WP 34s
Message #5 Posted by Hans Milton on 26 Nov 2011, 8:14 a.m.,
in response to message #4 by Walter B

Great!

      
Re: Lambert W functions on WP 34s
Message #6 Posted by Gerson W. Barbosa on 25 Nov 2011, 10:15 a.m.,
in response to message #1 by Hans Milton

Easily done on the HP-12C:

01 CHS               
02 1/x               
03 STO 0              
04 STO 1              
05 LN                
06 RCL 0             
07 *                 
08 RCL 1             
09 x<>y               
10 -                 
11 x=0                
12 GTO 15            
13 LST x             
14 GTO 04            
15 LST x             
16 RCL 0             
17 /                  
18 CHS                
19 GTO 00           

-0.2 R/S -> -2.542641358

http://www.hpmuseum.org/cgi-sys/cgiwrap/hpmuseum/archv019.cgi?read=159032

Edited: 25 Nov 2011, 10:54 a.m.

            
Re: Lambert W functions on WP 34s
Message #7 Posted by Paul Dale on 25 Nov 2011, 6:52 p.m.,
in response to message #6 by Gerson W. Barbosa

It would be easy enough to include a user code programme to calculate this branch of the W function in the device -- for real arguments only. I'd guess 100 or so bytes of precious flash.

Alternatively, use this program:

	01  LBL'W[sub-1]'
	02  LocR 02
	03  STO .02
	04  +/-
	05  1/x
	06  STO .00
	07  STO .01
	08  LN
	09  RCL[times] .00
	10  RCL .01
	11  x[<->] Y
	12  -
	13  x=0?
	14  SKIP 03
	15  DROP
	16  RCL L
	17  BACK 10
	18  DROP
	19  RCL L
	20  RCL/ .00
	21  +/-
	22  x[<->] .02
	23  STO L
	24  x[<->] .02
	25  RTN

Store it in one of the flash segments and you've got the W-1 function. It behaves like a keyboard command in that Last X is set properly and the stack is not damaged. The argument range is not correctly validated however.

- Pauli

                  
Re: Lambert W functions on WP 34s
Message #8 Posted by Walter B on 25 Nov 2011, 6:59 p.m.,
in response to message #7 by Paul Dale

Pauli, [sub-1] ??

                        
Re: Lambert W functions on WP 34s
Message #9 Posted by Paul Dale on 25 Nov 2011, 7:30 p.m.,
in response to message #8 by Walter B

Yeah, [sub-1] which displays as 1. We don't have a subscript minus or minus 1. All our codes for subscripts are [sub-X].

The other convention I've seen is Wm and Wp for w-1 and W0 respectively.

- Pauli

                              
Re: Lambert W functions on WP 34s
Message #10 Posted by Walter B on 26 Nov 2011, 3:20 a.m.,
in response to message #9 by Paul Dale

Exactly. And we feature [sub-m] and [sub-p] ... :-)

                                    
Re: Lambert W functions on WP 34s
Message #11 Posted by Paul Dale on 26 Nov 2011, 3:27 a.m.,
in response to message #10 by Walter B

I know that was why I mentioned them ;-)

- Pauli

      
Re: Lambert W functions on WP 34s
Message #12 Posted by Ángel Martin on 25 Nov 2011, 10:49 a.m.,
in response to message #1 by Hans Milton

Just in case it's useful, functions WL1 and WL0 are available in the SandMath-II module for the HP-41, both implemented in MCODE.

The module is available at TOS for V41 and i41CX usage - also possible to burn into Clonix, MLDL2k, etc. of course.

Cheers, ÁM

Edited: 25 Nov 2011, 10:49 a.m.


[ Return to Index | Top of Index ]

Go back to the main exhibit hall