Cut the Cards
08-26-2020, 03:06 AM (This post was last modified: 09-01-2020 02:22 PM by Albert Chan.)
Post: #11
 Albert Chan Senior Member Posts: 1,896 Joined: Jul 2018
RE: Cut the Cards
(08-25-2020 11:41 PM)Gerson W. Barbosa Wrote:  FWIW,

« 1. Psi + EXP 6. OVER INV 12. + / + 1. - »

'H­-¹' STO

Example:

1100 H7.58073560027

H­-¹1100

H-­¹ should be accurate to 11 or 12 digits for arguments equal or greater than 7.5

Here is another version, using asymptotic estimate: $$\quad\exp(\psi(x+0.5)) ≈ x + \large{1\over24x}$$

Let k = exp(ψ(x+0.5)), n = x - 0.5 → k = exp(H(n) + ψ(1)) ≈ x + 1/(24x)

If x is big, x ≈ k, we have: ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ $$n ≈ k - \large{1\over 24k} - {1\over2}$$

HP50g inverse harmonic function: ﻿ ﻿ ﻿ ﻿ ﻿ « 1. Psi + EXP DUP 24. * INV - .5 - »

Both formulas perform well for large H, but this new version is also good for smaller H

>>> from mpmath import exp, euler, harmonic
>>> f1 = lambda k: k + 6/(1/k+12) - 1
>>> f2 = lambda k: k - 1/(24*k) - .5 ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ # new version
>>> for n in range(50,100,10):
... ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ h = harmonic(n)
... ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ k = exp(h - euler)
... ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿e1, e2 = n - f1(k), n - f2(k) ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ # under-estimated errors
... ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿﻿print '%d\t%.10f\t%.10f\t%g' % (n, e1, e2, abs(e1/e2))
...
50 ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿-0.0000013228 ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿0.0000000364 ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿36.3546
60 ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿-0.0000009261 ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿0.0000000212 ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿43.7606
70 ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿-0.0000006844 ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿0.0000000134 ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿51.1669
80 ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿-0.0000005263 ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿0.0000000090 ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿58.5736
90 ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿-0.0000004172 ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿0.0000000063 ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿65.9804
 « Next Oldest | Next Newest »

 Messages In This Thread Cut the Cards - David Hayden - 07-30-2020, 08:00 PM RE: Cut the Cards - Albert Chan - 07-30-2020, 08:58 PM RE: Cut the Cards - Albert Chan - 08-21-2020, 11:00 PM RE: Cut the Cards - Jim Horn - 07-30-2020, 09:49 PM RE: Cut the Cards - John Keith - 07-31-2020, 12:24 AM RE: Cut the Cards - Gerson W. Barbosa - 08-24-2020, 01:57 PM RE: Cut the Cards - Albert Chan - 08-25-2020, 06:14 PM RE: Cut the Cards - Albert Chan - 07-30-2020, 10:21 PM RE: Cut the Cards - pinkman - 08-24-2020, 09:49 PM RE: Cut the Cards - Gerson W. Barbosa - 08-25-2020, 11:41 PM RE: Cut the Cards - Albert Chan - 08-26-2020 03:06 AM RE: Cut the Cards - Gerson W. Barbosa - 08-26-2020, 08:23 AM RE: Cut the Cards - Albert Chan - 08-26-2020, 02:13 PM RE: Cut the Cards - Gerson W. Barbosa - 08-26-2020, 06:13 PM RE: Cut the Cards - Gerson W. Barbosa - 08-27-2020, 10:07 PM RE: Cut the Cards - Albert Chan - 08-28-2020, 09:26 PM RE: Cut the Cards - Albert Chan - 08-29-2020, 04:02 PM RE: Cut the Cards - Gerson W. Barbosa - 08-28-2020, 11:39 PM RE: Cut the Cards - Albert Chan - 06-23-2021, 12:08 AM

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