Post Reply 
Ψ(x)⁻¹ [wp 34s]
05-09-2016, 03:19 PM
Post: #1
Ψ(x)⁻¹ [wp 34s]
.
Code:


0001 **LBL A
0002 1
0003 +/-
0004 x>? Y
0005 [sqrt]
0006 x[<->] Y
0007 x<0?
0008 GTO 004
0009 # 002
0010 x[<->] Y
0011 x<? Y
0012 GTO 003
0013 # 004
0014 x[<->] Y
0015 x<? Y
0016 GTO 002
0017 # 009
0018 x[<->] Y
0019 x<? Y
0020 GTO 001
0021 GTO 000
0022 RTN
0023 **LBL 004
0024 STO 03
0025 XEQ 003
0026 XEQ'[PSI]'
0027 RCL- 03
0028 +/-
0029 RCL+ 03
0030 XEQ 003
0031 RTN
0032 **LBL 003
0033 STO 02
0034 XEQ 002
0035 XEQ'[PSI]'
0036 RCL- 02
0037 +/-
0038 RCL+ 02
0039 XEQ 002
0040 RTN
0041 **LBL 002
0042 STO 01
0043 XEQ 001
0044 XEQ'[PSI]'
0045 RCL- 01
0046 +/-
0047 RCL+ 01
0048 XEQ 001
0049 RTN
0050 **LBL 001
0051 STO 00
0052 XEQ 000
0053 XEQ'[PSI]'
0054 RCL- 00
0055 +/-
0056 RCL+ 00
0057 XEQ 000
0058 RTN
0059 **LBL 000
0060 e[^x]
0061 STO+ X
0062 ENTER[^]
0063 1/x
0064 W[sub-p]
0065 STO+ X
0066 1/x
0067 +
0068 INC X
0069 # 003
0070 /
0071 RTN
0072 END


Examples


2 g FILL g LN x - 0.5772156649 STO B - A --> 1.5 (5.0 s)

4 ENTER 3 / 2 g LN 3 x - π 2 / + RCL B - A --> 1.75 (5.0 s)

RCL B +/- A --> 9.99999999997e-1 (10.3 s)

1 +/- A --> 7.850033253 81e-1 (10.5 s)

0 A --> 1.46163214497 (5.0 s)

1 A --> 3.20317146836 (4.3 s)

2 A --> 7.88342863117 (1.7 s)

4 A --> 55.0973869103 (1.4 s)

9 A --> 8103.58392243 (0.7 s)

2.45 RCL B - A 1 - --> 6 (4.2 s); Hn⁻¹(2.45) = 6, that is, 1 + 1/2 + 1/3 + 1/4 + 1/5 + 1/6 = 2.45 = H₆

1.2 +/- A --> Domain Error
x<>y XEQ 04 7.07122399 653e-1

Basically I have used a weighted mean of two assymptotic approximations, which are more accurate than any of them individually:

\[\psi (x+\frac{1}{2})\approx \ln (x)\therefore \psi ^{-1}(x)\approx e^{x}+\frac{1}{2}\]

\[\psi (x)\approx \ln (x)-\frac{1}{2x}\therefore \psi ^{-1}(x)\approx \frac{1}{2W_{p}\left ( \frac{1}{2e^{x}} \right )}\]

\[\psi ^{-1}(x)\approx \frac{1}{3} \left [2\left ( e^{x}+\frac{1}{2} \right )+\frac{1}{2W_{p}\left ( \frac{1}{2e^{x}} \right )} \right ]\]

or,

\[\psi ^{-1}(x)\approx \frac{1}{3} \left [1+2 e^{x}+\frac{1}{2W_{p}\left ( \frac{1}{2e^{x}} \right )} \right ]\]

This requires less evaluations of ψ(x), on the other hand it needs additional evaluations of Lambert's W function. I am not sure wether this takes more time, but it surely will require a lesser number of evaluations of the basic approximation, thus making the resulting code shorter than the equivalent to the one I used for the HP 50g here recently.

The accuracy is mostly twelve digits in the valid range ( x ≥ -1 ). It depends also of the accuracy of the library function 'ψ'.
Find all posts by this user
Quote this message in a reply
05-09-2016, 03:28 PM
Post: #2
RE: Ψ(x)⁻¹ [wp 34s]
Note to moderators:

When trying to edit the title of the post thread, I accidentaly created another one with the same content. I would ask you please to remove this one, as I am not allowed to do it myself. Thanks in advance,

Gerson.
Find all posts by this user
Quote this message in a reply
05-09-2016, 05:24 PM (This post was last modified: 05-09-2016 05:35 PM by Ángel Martin.)
Post: #3
RE: Ψ(x)⁻¹ [wp 34s]
(05-09-2016 03:19 PM)Gerson W. Barbosa Wrote:  Basically I have used a weighted mean of two assymptotic approximations, which are more accurate than any of them individually:

<see above>

This requires less evaluations of ψ(x), on the other hand it needs additional evaluations of Lambert's W function. I am not sure wether this takes more time, but it surely will require a lesser number of evaluations of the basic approximation, thus making the resulting code shorter than the equivalent to the one I used for the HP 50g here recently.

The accuracy is mostly twelve digits in the valid range ( x ≥ -1 ). It depends also of the accuracy of the library function 'ψ'.

Hi Gerson, thanks for this follow-up. What's the accuracy expected from this method? I must be doing something wrong (I admit it, I jumped into coding it without reading the other thread...) but I'm not getting the expected results beyond the second decimal digit.
I'm using WL0 from the SandMath, with that it's an easy task to program your last expression:

01 LBL "APSI"
02 E^X
03 ST+ X
04 1
05 X<>Y
06 +
07 LASTX
08 1/X
09 WL0
10 ST+ X
11 1/X
12 +
13 3
14 /
15 END

Do you see any flagrantly obvious mistake with the code above?

Cheers,
'AM

"To live or die by your own sword one must first learn to wield it aptly."
Find all posts by this user
Quote this message in a reply
05-09-2016, 06:39 PM
Post: #4
RE: Ψ(x)⁻¹ [wp 34s]
(05-09-2016 05:24 PM)Ángel Martin Wrote:  
(05-09-2016 03:19 PM)Gerson W. Barbosa Wrote:  Basically I have used a weighted mean of two assymptotic approximations, which are more accurate than any of them individually:

<see above>

This requires less evaluations of ψ(x), on the other hand it needs additional evaluations of Lambert's W function. I am not sure wether this takes more time, but it surely will require a lesser number of evaluations of the basic approximation, thus making the resulting code shorter than the equivalent to the one I used for the HP 50g here recently.

The accuracy is mostly twelve digits in the valid range ( x ≥ -1 ). It depends also of the accuracy of the library function 'ψ'.

Hi Gerson, thanks for this follow-up. What's the accuracy expected from this method? I must be doing something wrong (I admit it, I jumped into coding it without reading the other thread...) but I'm not getting the expected results beyond the second decimal digit.
I'm using WL0 from the SandMath, with that it's an easy task to program your last expression:

01 LBL "APSI"
02 E^X
03 ST+ X
04 1
05 X<>Y
06 +
07 LASTX
08 1/X
09 WL0
10 ST+ X
11 1/X
12 +
13 3
14 /
15 END

Do you see any flagrantly obvious mistake with the code above?

Cheers,
'AM

Hi, Ángel!

Your code is correct. For x = 2, the expect result is 7.88387350, good to four significant digits (the exact 10-digit result is 7.883428632). For smaller arguments things get worse, but then again the other two approximations get even worse. I don't claim this is a good method, but this is the only one I have so far. Perhaps a specific solver is a better option, the two first approximations being used as the initial guesses, since the true results lie between them (at least for the few arguments I've checked).

Cheers,

Gerson.
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)