7

This is a sort of inspired sequel to the following question:

Evaluating $\sum\limits_{x=2}^\infty \frac{1}{!x}$ in exact form.

where the question is the discussion of the "$e$-like constant"

$$\sum_{n=2}^{\infty} \frac{1}{!n}$$

which is at least visually similar to the series for $e$, i.e.

$$\sum_{n=0}^{\infty} \frac{1}{n!}$$

except there's also an indexing difference. I call the former the "derangement constant" ($ɘ$?), for lack of a better name. This number is about 1.638. I want more digits. Millions; billions maybe. Kind of like $\pi$, but $\pi$ is old stuff; need a new kid on the block. :)

Actually the reason is because that comments on that question were talking about how that the series for the derangement constant converges fast, superlinear actually in a digit-for-digit sense, which at first seems like we should be able to use it to compute millions of digits. But in reality, things aren't so simple - "fast convergence" alone by no means does a fast algorithm make for a computer.

On a computer, it's not just the amount of terms that matters (i.e. the convergence rate), but also how many digits you need to keep for each term, because the computer has to go through the digits and add and multiply them. Addition, of course, is cheap; multiplication is not - in this domain, it's typically done using tricked out and once written, often kept secret, code based on Fast Fourier Transform (FFT) methods, which for numbers of $n$ digits have complexities

$$O(n \log n\ a(n))$$

for some slow-grow function $a(n)$. The ideal FFT has $a(n) = 1$, but this is unachievable in practice because of precision limits of the computer processor. We can call the complexity above $M(n)$, or complexity of multiplication of $n$-digit numbers.

Fortunately though, for a naive implementation of $e$, we don't need this FFT multiplication. Naively, to sum a series of the type above, if we want millions of digits, we better evaluate each term to millions of digits precision. Given the factorial has a recurrence relation

$$(n+1)! = (n+1) \cdot n!$$

which gives

$$\frac{1}{n!} = \frac{1}{n} \frac{1}{(n-1)!}$$

we can get $n$ digits in time

$$O\left(n\ e^{W(\ln n)}\right)$$

which isn't too bad, but is still bad enough for large $n$ (millions or more) that we want something better. So we need to do something more clever. The usual way to overcome this is to use methods based on binary splitting - basically, consider the following. Note that we can write a factorial as

$$n! = \left(1 \cdot 2 \cdot 3 \cdot \cdots \cdot m\right) \cdot \left((m+1) \cdot (m+2) \cdot \cdots \cdot (n-1) \cdot n\right)$$

for some $m$ with $1 < m < n$. Defining

$$P(a, b) := (a+1)(a+2)\cdots(b-1)b$$

we have the identity

$$P(a, b) = P(a, m) P(m, b)$$

which allows us to recursively compute

$$P(0, n) = n!$$

using much smaller multiplications. Something similar can be done by splitting the sum for $e$. Take

$$e = \sum_{n=0}^{\infty} \frac{1}{n!}$$

and now write the equation

$$\frac{P(a, b)}{Q(a, b)} = \sum_{n=a+1}^{b} \frac{1}{(a+1)(a+2)\cdots (n-1)n}$$

Then note that

$$\frac{P(a, b)}{Q(a, b)} = \frac{P(a, m)}{Q(a, m)} + \frac{1}{Q(a, m)} \frac{P(m, b)}{Q(m, b)}$$

once we take

$$Q(a, b) := (a+1)(a+2) \cdots (b-1)b$$

like before. In particular, we have the recurrence equations

$$Q(a, b) = Q(a, m) Q(m, b)$$

and

$$P(a, b) = P(a, m) + Q(m, b) P(m, b)$$

of which the second can be found by multiplying out. Then,

$$e \approx 1 + \frac{P(0, N)}{Q(0, N)}$$

gives $N+1$ terms of the $e$-series, with, again, smaller multiplies. This saves a lot; and permits efficient computation of $e$ by leveraging fast multiplication - in particular, the complexity to generate $n$ digits is now on the order instead of $O(\log(n)\ M(n \log n))$; obviously much better at least if $M(n)$ is suitably good, which it is for FFT-based multiplication methods (giving $O(n \log^2(n)\ a(n))$).

However, this trick does not appear to generalize so easily to the derangements. In particular, while factorials expand nicely as a product, derangements $!n$ have a "branching" recurrence identity

$$!(n+1) = n(!n\ +\ !(n-1))$$

which means that, in particular, we cannot simply parcel out the computation of $!n$ into a "1 to $m$" and "$m+1$ to $n$" part as we did above. Worse, because the derangement is in the denominator, we cannot do something analogous to

$$\frac{1}{n!} = \frac{1}{n} \frac{1}{(n-1)!}$$

which was key to the naive method for $e$! Instead, we must do the full reciprocal, and now have horrible costs on the order of $O(e^{W(\ln n)} \lg(n)\ M(n))$!

So is there some trick that we can use to compute $ɘ$ efficiently like how we can use binary splitting + FFT multiplication to compute $e$ efficiently?


ADD: Not sure if this is useful. But I found on Wikipedia that

$$!n = n! \sum_{i=0}^{n} \frac{(-1)^i}{i!}$$

Thus

$$\frac{1}{!n} = \frac{1}{n!} \frac{1}{\sum_{i=0}^{n} \frac{(-1)^i}{i!}}$$

and then we can use the series reciprocal formula to get

$$\frac{1}{!n} = \frac{1}{n!} \sum_{k=0}^{\infty} (-1)^k d_{k,n}$$

where $d_{0,n} = 1$ and $d_{k,n} = -\sum_{l=\max(0, k-n)}^{k-1} \frac{d_{l,n}}{(k-l)!}$. See:

https://mathoverflow.net/questions/53384/power-series-of-the-reciprocal-does-a-recursive-formula-exist-for-the-coeffic

Thus

$$ɘ = \sum_{n=2}^{\infty} \sum_{k=0}^{\infty} \frac{(-1)^k d_{k,n}}{n!}$$

however; I'm not sure if this recursion for this $d_{k,n}$ is any better. At least though we're no longer recursing in a denominator!

ADD 2: The next thing I wonder about is the possibility that, because this is a nested sum, we should not consider a simple binary splitting, but a splitting into four "squares" or "rectangles", i.e. a quad splitting. In particular, if we want to sum the double sum

$$\sum_{n=0}^{\infty} \sum_{m=0}^{\infty} a_{n,m}$$

as an approximant

$$\sum_{n=0}^{N} \sum_{m=0}^{M} a_{n,m}$$

we should break into fours

$$a_{0,0} + a_{0,1} + a_{1,0} + \sum_{n=1}^{N} \sum_{m=1}^{M} a_{n,m} = \left(\sum_{n=1}^{n_m} \sum_{m=1}^{m_m} a_{n, m}\right) + \left(\sum_{n=n_m+1}^{N} \sum_{m=1}^{m_m} a_{n, m}\right) + \left(\sum_{n=1}^{n_m} \sum_{m=m_m+1}^{M} a_{n, m}\right) + \left(\sum_{n=n_m+1}^{N} \sum_{m=m_m+1}^{M} a_{n, m}\right)$$

viz.

$$a_{0,0} + a_{0,1} + a_{1,0} + \frac{P(0, 0, N, M)}{Q(0, 0, N, M)} = \frac{P(0, 0, n_m, m_m)}{Q(0, 0, n_m, m_m)} + \frac{P(n_m, 0, N, m_m)}{Q(n_m, 0, N, m_m)} + \frac{P(0, m_m, n_m, M)}{Q(0, m_m, n_m, M)} + \frac{P(n_m, m_m, N, M)}{Q(n_m, m_m, N, M)}$$

  • Basically you're just asking for $!n$, or am I missing something? – Trebor Sep 16 '21 at 05:51
  • @Trebor : Tweaked it some. I want to compute $ɘ$ efficiently. – The_Sympathizer Sep 16 '21 at 05:57
  • Have you tried the programs given at http://oeis.org/A281682 ? – Gerry Myerson Sep 16 '21 at 07:20
  • @Gerry Myerson : I'm looking for a specialized algorithm that will compute it at high speed. – The_Sympathizer Sep 16 '21 at 07:24
  • 1
    @GerryMyerson Those programs are just naive brute-force calculations. Slightly better is code that computes the subfactorial iteratively, rather than calculating each factorial separately & dividing by e. Eg, this Sage script easily does a couple of hundred digits almost instantly, but I wouldn't recommend it for a million digits. ;) – PM 2Ring Sep 16 '21 at 07:33
  • 2
    "Given we have the factorial relation

    $n!=(n+1)\cdot n!$" - is that supposed to read $(n+1)!=(n+1)\cdot n!$

    – Poo2uhaha Sep 16 '21 at 08:45
  • @Poo2uhaha : Yes. Fixed. – The_Sympathizer Sep 17 '21 at 00:01
  • Hmm… I wonder where this is from? Anyways, please see alternative forms in the question. The OEIS has not much information. – Тyma Gaidash Sep 17 '21 at 01:59
  • Also maybe try the series reciprocal formula for $E_x(-1),Γ(x,-1)$ as these may also work? These are in the question link. There is also no good fractional approximation for the constant as the first few continued fraction terms are smaller than 15. – Тyma Gaidash Sep 17 '21 at 02:11
  • That formula from Wikipedia is derived from the sum of the first $n$ terms for the Taylor series of $e^{-1}$, which is $\frac{!n}{n!}$. That $d_{k,n}$ is interesting, but it converges pretty slowly, especially for small $n$. OTOH, it's reasonably efficient to compute if the recursive calls use caching. And the factorials in the denominators suggest that it might be useful to represent the $d_{k,n}$ in factorial base notation, like I used in this $e$ program. – PM 2Ring Sep 17 '21 at 09:48
  • Here's a short Sage / Python demo of $d_{k,n}$, using rational numbers, which shows how slow it converges. – PM 2Ring Sep 17 '21 at 09:50
  • @PM 2Ring : Interesting comments. The question is if we can exploit the recursion on $d_{k,n}$ to somehow give a general recursion for the entire sum. Note that it's still ultimately a (nested) series of rational numbers, so ideally we want to still find some $\frac{P(N)}{Q(N)}$-like expression for $N$ terms but the relations of $P$ and $Q$ will have to be more subtle. – The_Sympathizer Sep 17 '21 at 18:01
  • add: perhaps expressions like $\frac{P(N, M)}{Q(N, M)}$ makes more sense; i.e. separate max count on outer and inner sum – The_Sympathizer Sep 17 '21 at 18:04
  • @Tyma Gaidash: Ideally it would be great if a hypergeometric series existed for the constant. However, that may be too much to hope for. – The_Sympathizer Sep 17 '21 at 22:21
  • @The_Sympathizer It is because of the incomplete gamma function/incomplete exponential integral in the denominator. I tried finding an integral representation, but could not find any using Abel Plana nor through the link. – Тyma Gaidash Sep 17 '21 at 23:20
  • I suspect that there's an efficient algorithm using the AGM and powers of $e$, but I have no idea how to find such a thing. ;) – PM 2Ring Sep 18 '21 at 23:58
  • If you want a good answer from someone else, then I suggest starting a bounty, I would, but not today. – Тyma Gaidash Sep 19 '21 at 22:17
  • @The_Sympathizer. How are you writing that $e$ but inverted? – Rounak Sarkar Oct 12 '21 at 12:40
  • @Rounak Sarkar :D:D:D:D I googled for reversed "e" character. Unicode has a silly huge amount of characters. – The_Sympathizer Oct 12 '21 at 13:11
  • @The_Sympathizer. What is the code in mathjax? – Rounak Sarkar Oct 12 '21 at 13:16
  • @Rounak Sarkar: It doesn't have any. It's a character. Unicode (UTF-16) hex is 0258. You'll need to figure how to enter this for whatever platform you use. I just Googled it and cut/paste. – The_Sympathizer Oct 12 '21 at 13:19
  • @The_Sympathizer. How can I figure it out? That's the main question I should have asked. Cause I wanna know – Rounak Sarkar Oct 12 '21 at 13:21
  • @Rounak Sarkar: Ah, you want to know how to enter UNICODE characters? What OS do you use? Doing so directly is very much dependent upon that, so I can't advise without knowing which one. I just googled for "unicode reversed e" (no quotes), is what I meant when I said "google it", I mean you can use google to find an instance of the character. It should be on the first page of results, then you just copy and paste. That method is pretty independent of OS :) – The_Sympathizer Oct 12 '21 at 13:25
  • To "figure it out" for your OS for direct entry, you can Google for how to enter unicode on your OS. E.g. I googled for "how to enter unicode linux firefox" in my case I believe. – The_Sympathizer Oct 12 '21 at 13:26
  • @RounakSarkar Try drawing the symbol in detextify. – Тyma Gaidash Oct 12 '21 at 14:01
  • @RounakSarkar In Linux, you can often enter Unicode code points using ctrl-shift-u followed by the code point in hex. See https://superuser.com/q/59418 for further details and other methods. – PM 2Ring Oct 12 '21 at 15:42

2 Answers2

4

This is not an efficient way to compute zillions of digits of the reciprocal subfactorial series, but it's ok for computing a few thousand digits.

It's just a quick hack of my $e$ calculator which converts the factorial base representation of $e$ to decimal, using (mostly) simple integer arithmetic. It replaces the $(1, 1, 1, \dots)$ of $e$ with the sum of the reciprocals of the subfactorials in factorial base notation. Calculating the reciprocals is straightforward, but the problem is that I'm calculating the subfactorials using Python's arbitrary-precision integers, which gets slow for large $n$. I was hoping that I could avoid the big numbers by using your $d_{k,n}$, but those numerators grow rather large too.

Code


import math

Global constants

W = 5 # Digits per block A = 10 ** W LR2P = .5 * math.log(2.*math.pi) # Log Root 2 Pi L10 = math.log(10.) # Log 10

def invlfact(n): """ Inverse Stirling's approx for log n factorial, using Newton's method """ x = y = n * L10 - LR2P for i in (0,1,2): x = (y + x) / math.log(x) return int(round(x))

def fb_recip(q, out, hi): """ 1/q in factorial base """ u = 1 for i in range(2, hi): u *= i k, u = u // q, u % q out[i] += k if u == 0: break

def big_rs(n): """ Generate n digits of the reciprocal subfactorial series using factorial base notation """ kmax = invlfact(n) + 1 print("Calculating sum to %d places, using %d cells" % (n, kmax))

# Table for factorial base digits. We ignore first two entries
d = [0] * kmax

# Calculate the subfactorials and their reciprocals
t = 1
s = -1
for i in range(3, kmax):
    t = i * t + s
    fb_recip(t, d, kmax)
    s = -s

# We could normalize d here...
print(&quot;1.\n&quot;, end=&quot; &quot;)

j = 1
while n&gt;0:
    # Get the next W digits by firstly multiplying d by A,
    # propagating carries back down the array,
    # then printing the integer part &amp; removing it.
    kmax = invlfact(n)    # Number of cells needed for this loop
    c = 0                 # Clear carry
    for k in range(kmax, 1, -1):
        d[k] = d[k] * A + c
        c = d[k] // k
        d[k] -=  c * k

    # Print block &amp; field separator. May need modifying if you make W large
    jj = (j%10 and 1  or  j%50 and 2  or  j%200 and 3  or  4) - 1
    print(&quot;%0*d%s&quot; % (W, c, &quot;\n&quot; * jj), end=&quot; &quot;)

    j += 1; n -= W

big_rs(10000)

Output

Calculating sum to 10000 places, using 3250 cells
1.
 63822 70745 05370 64754 28931 14151 12266 10635 93249 64443
 61647 23262 82872 63058 29440 68223 98183 03956 72073 29960
 91081 39091 53670 20122 43694 82571 53394 46047 61527 14757
 55152 42350 71557 42208 14216 91285 31530 57204 65948 28752
 24802 91622 99815 35083 81143 85672 96906 20742 95762 93153

14068 92369 93374 31910 89272 73402 80375 76901 48346 63632 90784 49751 11076 73673 70448 22954 76793 23085 59160 98998 96110 86832 28908 05361 21938 70815 06971 91462 70579 72035 97155 36459 18996 17979 36293 37288 85900 56157 18511 07053 00698 38002 00959 40418 45018 10478 64752 38557 61812 27430

89164 53128 52372 50279 56077 94153 89965 70456 57824 95027 61631 25305 69865 49061 20072 09877 13105 38202 39273 91196 75279 87452 95398 84980 54884 52735 53730 91142 14623 91941 23439 48442 69894 89256 59734 54729 22605 52855 75677 76308 50470 95296 07488 03425 95262 95851 02522 68822 57883 05982

28247 09770 33138 22705 86925 35765 04308 16997 73868 86712 77426 72285 18774 92023 33581 15014 38983 62852 14375 82178 63623 46697 96403 63043 38673 24210 49266 33662 76909 79423 54196 42589 53454 64328 10949 50142 93429 22722 56763 99209 64033 50516 72535 58280 87861 52737 42801 04740 79292 25565

70688 83313 19478 27747 95522 37837 39129 97695 99602 33878 20314 91802 26511 36527 10885 62337 30227 76969 08670 82315 41425 15652 97505 36860 61800 59142 33084 24037 40434 89326 64484 12327 11551 95595 77463 16137 72121 62773 47753 30338 21421 36722 16872 02928 26070 07304 30283 07844 77844 38186

03233 65660 70773 95220 12471 50296 32498 04736 79809 43877 78637 40510 34698 15910 40398 67728 33352 46153 81059 41896 01328 90654 74634 59274 30864 11975 60476 27922 44092 80012 56782 67541 67796 07082 67399 05115 54735 12946 24318 29094 37976 49146 47580 51703 39327 18155 85615 36987 73828 61026

67127 98570 43144 04935 51714 15983 84648 81027 94697 04583 35691 58731 18758 22639 54440 37375 40516 71519 51355 85486 69636 81971 02431 36533 70784 73790 76584 17836 51603 92900 01564 82657 32508 53908 35481 55372 84325 01650 50830 46743 86980 89874 57866 80808 38801 23171 60463 87699 04184 13544

18230 94633 35961 19649 52207 33165 71563 40108 82713 09436 10241 32777 76961 22121 07070 86013 86482 10847 80605 78792 12976 33747 91405 51357 72916 54922 06588 94797 37587 83124 53507 66904 60346 93191 85992 15272 77309 46471 71711 98270 47458 09073 38679 52553 11713 92523 82953 61819 91612 18450

09488 49551 20728 87748 71958 27151 91716 77069 31865 72654 25528 22229 16275 07180 40116 08851 29664 58038 15563 22082 38639 47103 47253 81434 36300 73799 63877 84292 86524 46950 87252 16198 60814 97939 49443 68066 31925 44034 20409 67019 47395 61818 60641 27835 64721 70992 65653 55764 48848 44239

79063 80557 43189 63017 44649 65101 15867 89985 56094 55901 39034 30186 34180 54123 35170 49882 37441 03538 39753 61232 43536 72344 51161 20938 37675 14287 32292 66579 65759 01402 74887 00396 50292 63788 69953 37860 28382 26361 32856 10208 68438 93582 47108 16643 51277 79243 76612 97213 77166 91182

04756 76486 67544 93984 87308 42044 66832 22426 44218 66828 50734 82198 29114 34573 28074 39448 56336 07878 47919 18359 96932 91819 56737 22279 86357 68771 61872 99581 46400 15447 56882 20979 80904 14808 13681 75548 58097 12966 60458 36188 16542 43055 23153 55838 19421 84296 34676 12742 56386 39524

31680 86644 84646 00717 95175 79662 53662 34360 90162 42895 96686 61532 32706 15255 58262 20179 95462 23285 35024 93338 55149 41074 29547 49982 91663 27067 06756 28491 63554 68361 05647 09134 32139 90164 92697 63574 74322 24189 49858 38142 46458 56649 08900 08989 72938 61561 06724 92139 12112 67412

93853 10777 43232 08670 15702 97242 14645 57202 74084 38498 86157 67026 35264 97386 84129 21619 42325 10994 95764 94539 35060 47509 73674 39169 03659 19037 04441 17244 57426 83549 72524 02399 10316 45453 14421 80432 49863 55855 22960 00252 26487 71450 58057 38662 11823 75877 57382 55247 50923 06584

90109 07512 57014 26056 64834 05021 09655 10089 87827 45414 18211 64175 33376 46866 69186 13998 17385 47111 95623 20009 33143 92121 66048 46215 32012 54163 35255 06821 35094 50982 97925 72773 47720 35839 82398 49128 67490 79036 85553 67010 67805 36422 15245 50497 58619 21044 24405 37054 17631 08141

85694 58157 16849 77863 92623 60764 14498 25205 97383 54925 09656 37618 44408 63474 26446 87321 76350 45127 72529 33857 39144 32031 27101 20624 18085 22130 74283 54869 81633 98871 18550 14081 92097 02055 71055 95637 28808 89992 20291 92049 03149 83466 19230 97286 43389 85137 39768 69381 80666 72387

64643 32851 19218 17942 34581 90483 18900 56980 34954 21519 20925 57761 28389 61080 40237 06543 50858 80826 95393 69129 55241 14718 70680 76403 05014 64437 46458 42702 52575 73117 31560 58309 26595 42699 81571 43033 83353 42383 28582 79024 04160 79953 24101 66566 71996 73040 11028 28881 30629 13030

44768 25452 62620 81115 27833 70076 34448 93899 01991 47291 68051 71973 69502 94244 06313 88376 57174 01831 26097 26131 53177 23848 01747 55034 74014 84975 16535 23653 71130 66673 04764 07084 00802 96542 93542 58417 96510 97410 40824 21570 42720 78190 93995 45479 00565 68398 51051 37319 16175 06225

26932 94340 75866 67862 51331 33229 40297 98414 25307 29263 75988 63496 26205 69886 39653 94425 59706 53783 23751 80438 27546 06739 73042 80993 11335 61764 89449 47974 13921 19119 42930 39023 58162 83142 01694 01337 55854 51188 48674 85534 76010 60406 98047 98892 47446 01317 47111 98988 11095 87406

85499 77329 29241 90418 27960 27514 77132 27864 09598 88011 97804 00229 48376 16795 75717 95070 71402 43909 09755 18500 19193 44058 97801 06688 69871 78576 09079 76668 87803 86525 87806 98080 12902 61645 54724 50948 74313 41846 32242 99358 74501 86402 74183 75850 46021 23895 66235 50332 54138 11802

12596 95556 98103 59020 22894 90277 59503 00612 37232 42968 81010 85748 09649 91240 25362 76886 23363 89603 54627 13416 63520 44906 78023 04050 49449 10407 72802 34378 85241 48427 75772 12036 51704 13072 29115 10610 33970 62756 83472 65171 11568 90233 06527 41173 04271 95376 51927 26445 39718 18201

33953 47865 26903 38314 44915 82379 21057 99797 80041 96864 01211 29700 01349 84388 23281 43825 72348 46136 65966 48535 59228 81155 19772 12002 05684 46083 45691 13686 23354 68901 05341 11139 65715 65756 90122 42387 87886 58607 19192 54939 16165 90210 93229 71147 91626 70205 96780 08490 34839 75950

10841 32543 92891 16320 35698 28145 56255 34097 79168 07164 33028 70521 55254 22647 03952 23248 37540 30623 87743 85448 74268 04173 30889 80146 28081 86579 66788 80680 86747 68840 09415 34244 15224 97695 98109 56383 22534 19451 34127 31901 67142 21444 26519 57894 15969 80043 31592 88349 78622 13035

36845 80427 21091 01099 09658 36557 31039 57877 59627 03778 46212 51804 32277 40177 92691 94836 68818 42896 07787 40545 80515 46479 88086 39020 70989 68698 18414 43949 03795 93617 10566 36192 48542 04484 34189 62182 09535 28087 51558 00288 39659 05714 79908 56466 69728 84303 83620 26069 62997 69846

25376 03443 26521 91400 96080 19452 40912 07279 84217 61073 98585 28142 84636 34077 54999 32600 49020 73714 67061 62029 85263 41019 44055 40007 47691 57535 31436 45138 34027 17739 16708 54870 92144 66283 00838 98259 09817 65381 63970 40357 48757 22599 66120 83573 74034 40418 43085 78119 58920 66162

43798 89129 34087 55695 90564 45106 42401 50464 94033 34075 88225 36134 84097 16081 45222 10800 85237 82968 62233 77788 89355 53444 00008 48194 93972 55004 69322 15123 58036 40364 27902 06536 89607 31575 68969 75226 38069 50061 65874 64775 01670 68687 11058 46789 88726 11346 41201 67496 18272 21858

05861 48838 05470 23636 88706 73347 71584 06898 28422 58957 60943 77423 78656 29077 62100 08821 66603 62525 86778 64808 26501 44577 40101 68899 20207 97036 21582 66962 32430 98540 84790 97324 34581 55220 76268 09266 66369 40228 34566 06032 66178 09843 26060 89510 11612 17137 04050 45544 25248 00027

08480 01000 44728 10520 73386 99372 69058 46389 75381 35582 00054 06952 14667 19395 41784 95320 36368 31404 80185 68658 94142 94887 09258 36961 98191 57347 85032 60809 81978 53089 31413 90928 23443 38403 75970 49628 95147 50881 11268 66789 18447 80403 91526 08471 33068 43691 10414 98428 71412 85662

30286 75673 12812 30750 16816 35824 50141 80933 57566 32393 13114 74324 29523 68065 01999 09049 67594 51445 99781 40364 44427 61132 00854 92113 66077 75475 29153 85202 08758 17117 40571 42128 76313 55932 42579 32281 65644 80086 37825 31479 18386 06693 42112 21828 40350 51019 83104 22345 80659 52918

62617 07574 81339 24125 11324 47796 86938 68253 45447 83535 98291 99760 97172 81964 76656 09886 90680 46306 27828 20357 08819 77157 98016 46385 81483 20393 50119 31784 04597 67233 21401 04235 17466 37938 82354 67755 61153 85698 83682 36580 19812 56452 68220 17653 69438 44606 97254 19075 24250 87928

13860 99933 09978 19457 44594 51901 49446 26996 55065 65533 89964 26521 28460 00811 86147 21007 42015 34975 41947 00820 29504 92167 24729 07188 01119 42994 99361 30195 78236 54182 00671 63166 08843 50829 28504 11424 67357 28387 06498 01671 02543 86206 13941 98031 72096 42450 38308 02410 51263 27562

99589 95368 00380 30011 43917 45067 37286 09984 49138 13985 88449 68547 51421 04346 55842 33900 44073 15010 63511 32930 40409 32101 69762 43864 58801 16520 41419 67965 77826 65675 13246 62952 82895 39669 64162 19231 92133 51174 64913 79794 55957 18910 77952 86028 54971 50062 47578 38743 67632 45319

87350 89581 68658 30905 82799 54751 97692 03943 16898 12552 09905 84406 09952 35071 25135 67246 95073 91311 77635 94115 65995 85851 87809 03002 44513 86910 66510 12007 62162 32271 52844 26000 22404 78041 00317 51324 27156 07576 56363 62667 60782 04812 50463 12184 52520 33900 20948 51418 32341 53394

30663 05051 58729 10530 33164 20612 71657 97168 79643 79608 08953 44532 77282 65388 08367 13535 77268 35836 76465 00558 33544 69996 56511 40281 33773 90102 08220 20688 63001 83703 46371 33837 97551 55358 64049 24936 87823 77321 00520 47245 55617 71208 21880 93839 10397 84930 61068 36007 91304 62638

33809 52956 14084 66739 31880 45181 75366 97084 30613 27024 83143 66472 42042 42486 55430 55994 72110 76164 74274 21904 22000 40123 83743 72773 12483 65755 28203 83101 52267 76664 43074 45655 60425 99967 77608 65269 77658 53828 51349 95109 65520 49393 06333 68170 93813 62260 47846 01807 57521 46461

43827 50097 75633 04824 06925 63959 46064 31174 64897 17346 34152 60345 31942 30916 34345 40756 03718 62066 86429 48476 86749 34042 73528 31310 66467 09554 70877 97671 07291 84365 45698 94410 07020 99463 09313 06358 19827 84102 01032 17432 35768 98352 57907 97967 99772 88624 52095 91094 54429 86888

08405 44905 00071 97554 67491 69274 66219 50909 56169 02384 02255 49085 72341 00763 66063 97421 72386 05192 89851 82247 79300 40527 08770 32951 28522 73352 91449 45064 24382 99998 19700 56535 97732 06273 01834 19950 70405 28106 25905 94098 72213 78912 79319 73794 00225 96457 65144 95048 88850 55957

09825 45609 11618 26048 40350 53398 82246 77531 58295 23422 27589 33319 89737 09474 63059 50125 52423 64619 30196 69445 84079 46080 42259 13212 58789 06200 66483 36297 04180 07496 08640 20991 37685 67317 01529 62868 36532 61848 50421 21521 89414 85078 79450 55473 48936 29036 60756 76346 35634 75816

97297 74387 92396 53863 81634 63056 60610 73671 43699 17214 16588 32344 90390 57387 26109 88071 54584 82742 36930 30463 00569 21949 57468 94128 65292 66321 75137 65268 23318 38219 28161 74573 03975 56364 47481 01141 95869 80241 79547 71605 42556 67212 81623 47930 70437 04504 43784 34298 01919 99237

83957 39830 96667 25198 67676 33929 08698 08779 98881 35374 97431 69523 47418 33066 77141 69345 28175 96718 46731 58353 35474 50331 05641 58439 43390 88127 16014 98607 72492 86855 81291 09435 18780 99841 71290 03124 09539 48828 58704 91436 33744 96215 74841 54764 46958 68304 43633 82303 72718 89533

73716 38007 79817 94851 95604 27117 88457 49831 82891 53698 49398 25642 10912 53048 08950 04370 00455 72223 01522 20143 23106 08898 74664 17609 30331 15961 15360 04505 28827 71340 56730 10458 95341 03038 47939 04817 20043 64388 50623 46486 65392 28039 62770 49836 10652 66438 37742 43277 92263 24330

Here's a live version, running on the SageMathCell server.

PM 2Ring
  • 4,844
  • FWIW, I've done some experiments in calculating $!n$ via $d_{k,n}$ in factorial base. This can be done using binomial coefficients of $n+k$, which are considerably smaller than $!n$ for large $n$. But as I mentioned above, we need large $k$ for sufficient accuracy, so I don't think this approach is suitable for large $n$. – PM 2Ring Sep 18 '21 at 23:54
2

Here I present forms of the constant. The first will use algebraic properties. Let the constant be denoted c for “constant”. Note I will use “!x” for the derangement as seen in the question. Also note the Pi-Product notation:

$$c\mathop=^\text{def}\sum_2^\infty \frac 1{!x}\implies e^c=e^{\sum_2^\infty \frac 1{!x}}=e^{\frac1{!0}+ \frac1{!1} +\frac1{!2} +…}=e^{\frac1{!0} }e^{\frac1{!1}}e^ \frac1{!2}…= \prod_2^\infty e^\frac{1}{!x}$$

Now you see

various possibilities for a series expansion for $e^y$:

$$e^c= \prod_2^\infty e^\frac{1}{!x}= \prod_{x=2}^\infty \sum_{n=0}^\infty\frac{1}{(!x)^n n!} $$

There is also an option with multinomial theorem as it will converge because a finite sum would be taken with the theorem.

Another nice, but less interesting expansion would be using the Regularized Gamma functions and Poisson random variables section in the linked article:

$$c=\sum_2^\infty \frac1{!x}=e\sum_3^\infty\frac{1}{Γ(x,-1)}= e\sum_3^\infty\frac{1}{Q(x,-1)Γ(x)} $$

Let there be the usage of one of the reciprocal gamma function expansions and Euler-Mascheroni Constant:

$$c= e\sum_3^\infty\frac{1}{Q(x,-1)Γ(x)}= e\sum_3^\infty\frac{x \prod\limits_{n=1}^\infty\frac{\frac xn+1 }{\left(\frac1n+1\right)^n}}{Q(x,-1)}= \sum_3^\infty\frac{xe^{γx+1}\prod_\limits{n=1}^\infty\frac{\frac xn+1}{e^\frac xn}}{1-P(x,-1)} $$

Using the links, Q and P are both the Upper and Lower Regularized Incomplete Gamma functions and:

$Q(x,-1)$, because $x\in\Bbb Z$, is also the Cumulative Distribution Function for Poissan random variables for Probability$(x>X\in\text{Poissan(-1) random variable})$.

Similarly, $P(x,-1)$ is the Cumulative Distribution Function for Gamma random variables with shape parameter $x$ and scale parameter of $1$ evaluated at $-1$.

I have little experience with either of these statistical interpretations, but they help put context to alternative forms of the constant. There are many more possible manipulations we can do of the constant, but not all of them are practical. Please correct me and give me feedback!

It can be shown that the following is true using @Jack Barber’s method in

$$\sum_\Bbb N \text{erfc}(x)$$

Here is an integral representation using the linearity of the Floor function and the Meijer G function:

$$\sum_2^\infty \frac{1}{!x}=-\int_2^\infty \lfloor x-1\rfloor \frac{d}{dx} \frac{1}{!x}dx=\int_2^\infty \frac{d}{dx} \frac{1}{!x} dx-\int_2^\infty\lfloor x\rfloor \frac{d}{dx} \frac{1}{!x} dx=\frac1{!\infty}-\frac1{!2}-\int_2^\infty \lfloor x \rfloor \frac{d}{dx} \frac{1}{!x} =-1-\int_2^\infty \lfloor x \rfloor \frac{d}{dx} \frac{1}{!x}dx= -1-\int_2^\infty \lfloor x \rfloor\left(-\frac{\text G_{2,3}^{3,0}\big(-1\left|_{0,0,x+1}^{\ \ \ \ 1,1}\right)}{e(!x)^2}-\frac{i\pi}{!x}\right)dx =\frac1e\int_2^\infty \frac{\lfloor x\rfloor\text G_{2,3}^{3,0}\left(-1\big|_{0,0,x+1}^{\ \ \ \ 1,1}\right)}{(!x)^2} dx+i\pi\int_2^\infty\frac{\lfloor x\rfloor}{!x}dx-1$$

Please correct me and give me feedback!

There is also the classic Riemann Sum which you will use for approximation.

Тyma Gaidash
  • 12,081
  • You really want to avoid large products. They are much more expensive to compute than large sums. – K.defaoite Sep 17 '21 at 17:47
  • Thanks. The first expression I doubt really helps though because you still need to compute the derangements one at a time instead of via some recursive process. The problem is that the binary splitting rests strongly on the fact that a factorial can be decomposed as $(n + 1)! = (n + 1) \cdot n!$ and that $\frac{1}{ab} = \frac{1}{a} \cdot \frac{1}{b}$ which gives a nice chaining effect also in the reciprocal. – The_Sympathizer Sep 17 '21 at 17:58
  • This is an old answer – Тyma Gaidash May 22 '23 at 12:25