Post Reply 
Ψ⁻¹(x) [wp 34s]
05-09-2016, 03:20 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
Post Reply 




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