# Integral with floor function resulting in EulerGamma

Allegedly

$$1 - \int_1^\infty \frac{ (t-\left \lfloor{t}\right \rfloor ) } { t^2 } dt = \gamma$$

where $$\gamma$$ = EulerGamma

( Introduction to Analytic Number Theory, Apostol; Theorem 3.2 p 56 )

I would like to prove this with Mathematica. ( Use Fourier Series or whatever if necessary. )

Is this possible?

This is almost the required one.

Sum[Integrate[1/t - n/t^2, {t, n, n + 1}], {n, 1, Infinity}]
(*1 - EulerGamma*)


The difficulty consists in

FullSimplify[1/t - Floor[t]/t^2, Assumptions -> n > 0 && n \[Element] Integers && t >=n && t < n + 1]
(*(t - Floor[t])/t^2*)


One sees Mathematica is not able to simplify Floor[t] to n under the assumptions.

• Interesting... that is at least a start. – nilo de roock Jul 12 at 7:35
• Yes, I like the technique! Could handle most integrals with Floor / Fraction like that, I suppose. – nilo de roock Jul 12 at 7:41
• Just to compare. The code of Maple 2019.1 int(1/t - floor(t)/t^2, t = 1 .. n)assuming n>1,n::integer:limit(%, n = infinity) assuming n::integer  does the job. – user64494 Jul 12 at 7:45
• Work to do for Wolfram... – nilo de roock Jul 12 at 8:06
• Would you know if Sage can handle this? My Sage is rusty... – nilo de roock Jul 12 at 8:12

In cases you have problems to determine the integrand depending on n, you can calculate integrals for some n and find formula for the integral with FindSequenceFunction  .

Calculate the difference for n+1 and n and sum up the found formula. Since FindSequenceFunction does not recognize Log, do it in two steps.

tab = Flatten@
Table[{Integrate[(t - Floor[t])/t^2, {t, 1, n + 1}] -
Integrate[(t - Floor[t])/t^2, {t, 1, n}] // Expand}, {n, 1, 8}]

fs1 = FindSequenceFunction[tab /. Log[_] -> 0, n];
fs2 = FindSequenceFunction[Cases[tab, Log[aa_] -> aa, 2], n];

int1 = fs1 + Log[fs2]

(*   1/(-1 - n) + Log[(1 + n)/n]   *)

Sum[int1, {n, 1, ∞}]

(*   1 - EulerGamma   *)


An other example:

tabx = Flatten@
Table[{Integrate[(Floor[t] - t)/Ceiling[t]^2, {t, 1, n + 1}] -
Integrate[(Floor[t] - t)/Ceiling[t]^2, {t, 1, n}] //
Expand}, {n, 1, 8}]

(*   {-(1/8), -(1/18), -(1/32), -(1/50), -(1/72), -(1/98),
-(1/128), -(1/162)}   *)

fs1 = FindSequenceFunction[tabx, n]

(*   -(1/(2 (1 + n)^2))   *)

Sum[fs1, {n, 1, ∞}]

(*   1/2 (1 - π^2/6)   *)