7
$\begingroup$

I have the integral

$$\int_0^1\lfloor nx\rfloor\mathrm dx=\sum_{k=0}^{n-1}k\frac1n=\frac{n-1}2$$

where $n\in\Bbb N_{\ge 1}$ and $\lfloor{\cdot}\rfloor$ is the floor function. But when I try to evaluate in Mathematica with this code:

Refine[Integrate[Floor[n*x], {x, 0, 1}], n ∈ Integers && n > 0]

It stays unevaluated. How I can evaluate it?

$\endgroup$

4 Answers 4

8
$\begingroup$

One can use the Fourier series representation of the floor function: $\lfloor x\rfloor=\frac{1}{\pi}\sum _{k=1}^{\infty } \frac{1}{k}\sin (2 \pi k x)+x-\frac{1}{2}$. Integrating the $(x-1/2)$ we obtain your expected answer.

Integrate[(n x - 1/2), {x, 0, 1}]

$\frac{n}{2}-\frac{1}{2}$

For the rest, we can verify that it gives zero contribution.

res = 1/π Sum[Integrate[Sin[2 π k x n], {x, 0, 1}]/k, {k, 1,Infinity}]

$\frac{-3 \text{Li}_2\left(e^{-2 i n \pi }\right)-3 \text{Li}_2\left(e^{2 i n \pi }\right)+\pi ^2}{12 \pi ^2 n}$

FullSimplify[res, Assumptions -> n ∈ Integers]
(*0*)
$\endgroup$
1
  • 1
    $\begingroup$ It's too bad this doesn't have more upvotes... $\endgroup$ Nov 15, 2017 at 1:25
5
$\begingroup$
FindSequenceFunction[
  Table[
   Integrate[Floor[n*x], {x, 0, 1}],
   {n, 10}],
  n] ==
 Sum[k/n, {k, 0, n - 1}] ==
 (n - 1)/2

(*  True  *)
$\endgroup$
4
$\begingroup$

If you specify a range for n, then you can use PiecewiseExand and integrate:

Integrate[PiecewiseExpand[Floor[n x], {0 < x < 1, 0 < n < 5}], {x, 0, 1}]
$\endgroup$
3
$\begingroup$

Maple gives the desired result straight away,

restart:
assume(n>0,n::integer):
int(floor(n*x),x=0..1);

enter image description here

simplify(%)

enter image description here

If we make the assumption $n>1$, then we get

assume(n>1,n::integer):
int(floor(n*x),x=0..1);

enter image description here

$\endgroup$
1
  • $\begingroup$ Why did you give a Maple solution in the Mathematica section? $\endgroup$ Jul 11, 2020 at 7:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.