Informally speaking, an "almost integer" is a real number very close to an integer.

There are some known ways to construct such examples in a systematic way. One is through the use of certain algebraic numbers called Pisot numbers. These numbers $\alpha$ have the property that their powers can get arbitrarly close to integers, that is:

$\lim_{n \to \infty} \alpha - [\alpha^n] = 0$

where $[ .]$ is the nearest integer function.

A well-known example is given by the golden ratio $\varphi = \frac{1 + \sqrt{5}}{2}$, whose powers are increasingly close to integers:

$\varphi^{19} = 9349.000107...$

$\varphi^{25} = 167761.00000596...$

Another example comes from numbers of the form $e^{\pi\sqrt{n}}$.

A well-known example is Ramanujan's constant:

$e^{\pi\sqrt{163}} = 262537412640768743.99999999999925007...$

There's another interesting way to generate almost integers by using the numbers $e$ and $\pi$. By using the identity

$$\sum_{n=-\infty}^\infty e^{-\pi n^2x}=x^{-1/2}\sum_{n=-\infty}^\infty e^{-\pi n^2/x}.$$

we can derive the approximate identity

$$ (*) \sum_{k=0}^{n-1}{e^{-\frac{k^2\pi}{n}}}\approx\frac{1+\sqrt{n}}{2}$$

which provides a way to construct almost integers with increasing precision:

$ e^{-\frac{\pi}{9}} + e^{-4\frac{\pi}{9}} + e^{-9\frac{\pi}{9}} + e^{-16\frac{\pi}{9}} + e^{-25\frac{\pi}{9}} + e^{-36\frac{\pi}{9}} + e^{-49\frac{\pi}{9}} + e^{-64\frac{\pi}{9}} = 1.0000000000010504... $

$\sum_{k=1}^{24} e^{-k^2\frac{\pi}{25}} = 2.000000000000000000000000000000000310793...$

$\sum_{k=1}^{48} e^{-k^2\frac{\pi}{49}} = 3.000000000000000000000000000000000000000000000000000000000000000000838654...$

So, the question is: is there another way to generate almost integers -with or without increasing precision- by using transcendental functions, as in the previous example?

(Note that there's a trivial way to do this: By taking a convergent series $\sum_{k = 1 }^\infty x_k$ and its limit $L$, the number $1/L\sum_{k = 1 }^n x_k$ will be an almost integer, namely close to $1$, but I'm looking for a an example like identity (*), or for a different, non trivial one). So, I am looking for an example that may be of the form $\sum_{k = 1 }^n f(x_k)$, where $f(x)$ is a transcendental function of $x$, that is able to generate a set of different almost integers (zero excluded).

  • 6
    Your original definition looks wrong. Shouldn't it be $\alpha^n-[\alpha^n]\to 0$? – herb steinberg Mar 02 '19 at 01:42
  • 3
    Previously posted to MO, https://mathoverflow.net/questions/324394/transcendental-functions-generating-almost-integers – Gerry Myerson Mar 02 '19 at 04:25
  • 1
    Are you looking for explanations of why the given examples work? – anomaly Mar 07 '19 at 18:31
  • No, I'm looking for another way to generate almost integers like in the last example given (similar to that one, or entirely different). –  Mar 07 '19 at 18:52
  • 3
    The Borwein brothers are usually a great reference for this kind of stuff, e.g. : http://www.math.grinnell.edu/~chamberl/courses/444/worksheets/high-precision-fraud.pdf – Alex R. Mar 07 '19 at 21:50
  • Would you add a few words as to why this holds your interest? I will happily accept curiosity as an explanation, but is there perhaps some related matter which you hope to understand better using these examples? I was surprised to find this question tagged "numerical methods", perhaps you can replace it? – Carl Christian Mar 07 '19 at 22:35
  • 3
    As well as φ the same holds for any real quadratic integer such that $N(\alpha)/\alpha \in (-1,1)$ because $\alpha^n +(N(\alpha)/\alpha)^n = Tr(\alpha^n)$ is an integer. For example $\alpha = 3 + \sqrt{7}, N(\alpha)/\alpha = 3-\sqrt{7}$ then $\alpha^n = \lfloor \alpha^n+1/2\rfloor+ O(10^{-n/2})$ – reuns Mar 08 '19 at 16:51
  • The function $f(n)=\frac{1}{n!}$ is transcendental, and approaches the integer $0$ very rapidly as $n$ increases. – This site has become a dump. Mar 09 '19 at 15:32
  • Also, I find the question rather unclear. Going by your last sentence, you *may be* looking for a transcendental function $f$ such that the partial sums $S_n:=\sum_{k=1}^nf(x_k)$ yield different almost integers, where I guess $(x_k)_{k\in\Bbb{N}}$ should be a sequence of real or complex numbers? Then $g(n):=S_n-\lfloor S_n\rfloor$ is a transcendental function that is almost zero for all $n$. My comment above gives a simple example of such a function, but that doesn't seem to be what you are looking for. – This site has become a dump. Mar 09 '19 at 22:26
  • Alternatively, setting $f(1):=1+10^{-100}$ and $f(k)=k$ for all $k>1$ also extends to a transcendental function whose partial sums all yield different almost integers, but again that doesn't seem to be what you are looking for. – This site has become a dump. Mar 09 '19 at 22:27
  • 2
    @Servaes As you can see from the examples given in the post, I'm looking for similar "interesting" ways to generate almost integers by combining transcendental functions. Indeed, there's a certain ambiguity, but it's because any way that you can recognize as "non trivial" counts. Trying to be more concrete, I asked for another example of the form "$S_n = \sum_{k = 1 }^n f(x_k)$. I added the constraint that zero is excluded, since it's trivial. However, it's not easy to draw the line between "interesting" examples from trivial ones. –  Mar 10 '19 at 11:03
  • Actualy what Fractional Inquirer means is examples such Ramanujan's constant $e^{\pi\sqrt{163}}$. There is a ''theory'' (explanation) of such phenomenon and this is what I try to reproduce. – Nikos Bagis Mar 11 '19 at 19:27
  • 1
    A 19th-century mathematician, who, as a boy, gave exhibitions as a "lightning calculator", observed (prior to the Hermite-Lindemann Transcendence Theorem) that $e^{\pi \sqrt {163}}$ is within $10^{-12}$ of an integer. See the chapter on Calculating Prodigies in "Mathematical Recreations & Essays" by Rousse-Ball and Coxeter. – DanielWainfleet Mar 13 '19 at 17:20

1 Answers1


1) If $a,b\in\textbf{R}$ and $a<x<b$, then if $f(x)$ is continuous: $$ \frac{b-a}{N}\sum^{N}_{n=0}f\left(a+\frac{b-a}{N}n\right)=\int^{b}_{a}f(t)dt+o(1)\textrm{, }N\rightarrow\infty. $$ 2) If $\left[x\right]$ denotes largest integer $\leq x$ and $a$ is a non-rational real number, then $$ \lim_{n\rightarrow\infty}\frac{\left[na\right]}{n}=a $$ i.e. every real number can be approximated by rational numbers arbitrarily well.

3) If $\beta_{1}=1/2$, $$ \beta_{r+1}=\frac{1-\sqrt{1-\beta_{r/2}}}{2}, $$ then $$ \sin\left(\frac{\pi}{2(r+1)}\right)=\sqrt{\beta_r} $$ 4) This one is quite involved. $$ e^{-25\pi}=\frac{1}{3}-\frac{1}{6}\sqrt{4+75\pi-12\log 2+6\log k}-6.2619875...\times 10^{-103}, $$ where
$$ k=\sqrt{\frac{1}{2}-\frac{1}{2}\sqrt{1-(51841-23184\sqrt{5})Y^{12}}}, $$ where $Y$ is a root of $$ Y^3+5s^{-1}Y^2-sY-1=0, $$ where $s$ is such $$ s=\sqrt[3]{\frac{(t-1)^5}{11+6t+6t^2+t^3+t^4}}, $$ where $$ t=2\sinh\left(\frac{1}{4}\textrm{arcsinh}\left(\frac{9+\sqrt{5}}{2}\right)\right). $$ Note that $t$ is an algebraic number.

5) Set $$ p=\sqrt{2+216\cdot 5^{1/4}-96\cdot 5^{3/4}} $$ and $$ k=1-\frac{2}{1+t}\textrm{, }t=\frac{\left(\sqrt{2}+\sqrt{p}\right)^2}{2\cdot 2^{3/4}p^{1/4}\sqrt{2+p}}. $$ Also $$ l=\left(1+\frac{2^{3/4}p^{1/4}}{\sqrt{2+p}}\right)^2\frac{4+2\sqrt{5}+\sqrt{2}(3+2\cdot 5^{1/4})}{160}. $$ Then $$ \frac{\Gamma\left(\frac{1}{4}\right)^2}{\pi^{3/2}}=\frac{4+k^2-6k^4}{4l}-7.01743379...\times 10^{-107}. $$ 6) (Ramanujan) For $|x|<1$, $$ \prod_{k=1}^{\infty}\left(1-x^{p_k}\right)^{-1}=1+\sum^{\infty}_{k=1}\frac{x^{p_1+p_2+\ldots+p_k}}{(1-x)(1-x^2)\ldots(1-x^k)},\tag 1 $$ where $p_1,p_2,\ldots,$ denote the primes in ascending order. The above formula $(1)$ is canceled i.e. the Taylor series on both sides of $(1)$ agree only to the first 22 terms. (see Bruce C. Berndt. "Ramanujan's Notebooks I." Springer-Verlag, New York Inc. (1985) page 130).

7) This one is inspired from a formula of Ramanujan

Let $a,b$ be positive reals with $ab=2\pi$ and $\Psi(x)$ analytic on $\textbf{R}$. Let also $$ M\Psi(s)=\int^{\infty}_{0}\Psi(x)x^{s-1}dx, $$
be the Mellin transform of $\Psi$. If also $$ \phi(x)=Re\left(M\Psi(ix)n^{-ix}\right). $$ Then $$ a\sum^{\infty}_{k=0}\Psi\left(ne^{ak}\right)=a\left(1/2-\sum^{\infty}_{k=1}\frac{\Psi^{(k)}(0)}{k!}\frac{n^k}{e^{ak}-1}\right)+c+2\sum^{\infty}_{k=1}\phi(bk),\tag 2 $$ where $c=\lim_{h\rightarrow 0}\phi(h)=:\phi(0)$.


For $\Psi(x)=e^{-x}$, we get $$ a\sum^{\infty}_{k=0}e^{-ne^{ak}}=a\left(1/2-\sum^{\infty}_{k=1}\frac{(-1)^kn^k}{k!(e^{ak}-1)}\right)-\gamma-\log n+2\sum^{\infty}_{k=1}\phi(bk),\tag 3 $$ where $\phi(x)=Re\left(\Gamma(ix)n^{-ix}\right)$ and $c=\phi(0)=-\gamma-\log n$.

For $n=1$ in (3), we get the formula of Ramanujan and a good approximation of $\gamma$ constant (Euler's constant).

If $a=1/N$ then $b=2\pi N$ and we get as $N\rightarrow\infty$ $$ \gamma=-\frac{1}{N}\sum^{\infty}_{k=0}\exp\left(-e^{k/N}\right)+\frac{1}{N}\left(\frac{1}{2}-\sum^{\infty}_{k=1}\frac{(-1)^k}{k!\left(e^{k/N}-1\right)}\right)+O\left(e^{-\pi^2N}\right)\tag 4 $$ Also for $a=\frac{\log A}{N}$, then $b=\frac{2\pi N}{\log A}$ and holds $$ \gamma=-\frac{\log A}{N}\sum^{\infty}_{k=0}\exp\left(-A^{k/N}\right)+\frac{\log A}{N}\left(\frac{1}{2}-\sum^{\infty}_{k=1}\frac{(-1)^k}{k!(A^{k/N}-1)}\right)+O\left(e^{-\pi^2N/\log A}\right).\tag 5 $$ Set now $$ k_{10}(N)=\left[\frac{N}{\log A}\log\left(\frac{N\pi^2}{\log A}\right)\right]+1 $$ and $$ k_{20}(N)=\left[\frac{N\pi^2}{C_N\log A}\right]+1\textrm{, }C_N=P_L\left(\frac{A^{1/N}N\pi^2}{e\log A}\right), $$ where $P_L(x)$ is the product log function i.e. $e^{P_L(x)}P_L(x)=x$. Then $$ \frac{\gamma}{\log A}=-\frac{1}{N}\sum^{k_{10}(N)}_{k=0}\exp\left(-A^{k/N}\right)+\frac{1}{N}\left(\frac{1}{2}-\sum^{k_{20}(N)}_{k=1}\frac{(-1)^k}{k!(A^{k/N}-1)}\right)+O\left(e^{-\pi^2N/\log A}\right).\tag 6 $$

8) $$\left(e^{\pi\sqrt{163}}-744\right)^{1/3}=640319.99999999999999999999999939031735...$$

Nikos Bagis
  • 6,637
  • 20
  • 31
  • 1
    Well, sure, but this generic example gives (generically) extremely slow convergence compared to the OP. For $N$ terms you only get $O(\log N)$ digits precision, versus $O(N)$ for Pisot numbers and for the theta-series. I dare say that mere convergence to an integer is a very poor fit for the OP’s concept of “almost integer”. – Erick Wong Mar 07 '19 at 18:31
  • 1
    Well ok is a start to continue the list. – Nikos Bagis Mar 07 '19 at 20:43
  • 3
    I appreciate your interest in my question, but I have to say that you don't seem to understand it. I'm looking about any other way to combinate transcendenal functions that gives almost integers as a result, such as in the last example in my post. So 2) or 3) have nothing to do in here. 4) is close, but still is not about almost integers. Yet, although it is unrelated, how did you came up with 4)? –  Mar 08 '19 at 18:41
  • 1
    First you have to prove that $k_r=4q^{1/2}\exp\left(-4\sum_{n\geq 1}q^n\sum_{d|n}(-1)^{d+n/d}d^{-1}\right)$, $q=e^{-\pi\sqrt{r}}$, $r>0$ and then evaluate $k_{625}$ using a quite involved method which I describe in https://arxiv.org/abs/1202.6246 – Nikos Bagis Mar 08 '19 at 18:58
  • 2
    Regarding 4), I have a question: Can you use that method to generate similar representations for every rational number $p/q$, apart from $1/3$? –  Mar 11 '19 at 17:06
  • I don't know. I think no but I will search it. – Nikos Bagis Mar 11 '19 at 19:10