TITLE: Family of Generalized Integrals ${I}(a,b,p)=\int_0^{ab} \left( \left\{\frac{x}{a}\right\}-p\right) \left( \left\{\frac{x}{b}\right\}-p\right) \; dx$
QUESTION [10 upvotes]: Background:
I came across the following family of generalized Franel integrals, and found them quite interesting.  I don't think I've seen anything about these integrals before, at least not generalized, and I want to know if this is a known family of generalized integrals.  I am also interested behind the behavior of this family of integrals, specifically when $p=\frac{1}{2}$.  I want to find out if there's a simple algebraic closed form expression for this family of integrals.  Wolfram does not do a good job factoring the integrands, but to be fair it didn't factor $I(a,b,p)$ as I have done in this post.  Also, how would you approach cases where $\gcd{(a,b,c,\dots)} \neq 1$?
Consider the family of generalized integrals as the following:
$${I}(a,b,p)=\int_0^{ab} \left( \bigg\{\frac{x}{a}\bigg\}-p\right) \left( \bigg\{\frac{x}{b}\bigg\}-p\right) \; dx$$
$${I}(a,b,c,p)=\int_0^{abc} \left( \bigg\{\frac{x}{a}\bigg\}-p\right) \left( \bigg\{\frac{x}{b}\bigg\}-p\right) \left( \bigg\{\frac{x}{c}\bigg\}-p\right)\; dx$$
$${I}(a,b,c,d,p)=\int_0^{abcd} \left( \bigg\{\frac{x}{a}\bigg\}-p\right) \left( \bigg\{\frac{x}{b}\bigg\}-p\right) \left( \bigg\{\frac{x}{c}\bigg\}-p\right) \left( \bigg\{\frac{x}{d}\bigg\}-p\right)\; dx$$
$$\ldots$$
Where $a,b,c,\ldots \in \mathbb{N}$, $p \in \mathbb{Q}^+$, and $\gcd{(a,b,c,\ldots)}=1$.
Calculations:
Express the integral as the following:
$${I}(a,b,p)=\sum_{i=0}^{a-1} \sum_{k=0}^{b-1} \int_0^1 \left(\frac{t+i}{a}-p\right)\left(\frac{t+k}{b}-p\right) \; dt$$
Changing the order of the summations and integral and using some algebra:
$${I}(a,b,p)=\int_0^1 \left(\frac{a-1}{2}+t-ap\right)\left(\frac{b-1}{2}+t-bp\right) \; dt$$
Expanding the integrand out and factoring yields:
$${I}(a,b,p)=\int_0^1 \frac{ab}{4}{\left(2p-1\right)}^2+\frac{at}{2}\left(1-2p\right)+\frac{bt}{2}\left(1-2p\right)+\frac{(a+b)}{4}\left(2p-1\right)+{\left(t-\frac{1}{2}\right)}^2 \; dt$$
$${I}(a,b,p)=\int_0^1 \frac{ab}{4}{\left(2p-1\right)}^2+{\left(t-\frac{1}{2}\right)}^2 \; dt$$
And so:
$$\boxed{{I}(a,b,p)= \frac{ab}{4}{\left(1-2p\right)}^2+\frac{1}{12}}$$
Calculated similarly,I got the following:
$$I(a,b,c,p)=\frac{abc{\left(1-2p\right)}^3}{8}+\frac{c}{24}\left(1-2p\right)$$
$$I(a,b,c,d,p)= \frac{abcd}{16}{\left(1-2p\right)}^4+\frac{{(1-2p)}^2}{48}\left(ab+cd\right)+\frac{1}{80} $$
However, as @Varun Vejalla and @OliverDiaz pointed out in the comments, these results are illogical, and there actually is no closed form for $I(a,b,c,d,p)$.
Further Observations:
Interestingly enough, $p=\frac{1}{2}$ is a special case for this entire family generalized integrals.  Why is this?
Assuming the aforementioned conditions are met:
$$I\left(a,b,\frac{1}{2}\right)=\frac{1}{12}$$
$$I\left(a,b,c,\frac{1}{2}\right)=\int_0^1 {\left(t-\frac{1}{2}\right)}^3 \; dt=0$$
$$I\left(a,b,c,d,\frac{1}{2}\right)=\int_0^1 {\left(t-\frac{1}{2}\right)}^4 \; dt=\frac{1}{80} $$
$$I\left(a,b,c,d,e,\frac{1}{2}\right)=\int_0^1 {\left(t-\frac{1}{2}\right)}^5 \; dt=0$$
And so it seems that the following statement is true:
$$I\left(a_1,a_2,\ldots,a_n,\frac{1}{2}\right)=\int_0^1 {\left(t-\frac{1}{2}\right)}^n \; dt=\cases{        0       & $n \; \text{is odd}$ \cr
                        \frac{1}{2^n\left(n+1\right)}       & $n \; \text{is even}$ }$$
However, Wolfram Alpha computed $I\left(a,b,c,d,\frac{1}{2}\right)=0$ for valid $a,b,c,d$ values.
Final Remarks:
I wonder what other interesting observations can be made about this family of generalized integrals.  Specifically, are there other interesting special cases, and if so why are they so special?

REPLY [2 votes]: This answer is only for the case $\gcd(a_1, a_2), \gcd(a_1, a_3),... = 1$ (i.e. the $\gcd$ of any pair of $a_i$ is $1$).
Starting from what you have already done:
$$I(a_1, a_2, ..., a_n, p) = \int_0^1 \prod_{i=1}^n \left(\frac{a_i-1}{2} +t-a_ip \right)dt$$
Let $c_i = \frac{a_i-1}{2}-a_ip$. Then the task is to find $$\int_0^1 \prod_{i=1}^n\left( t+c_i \right)dt$$
The integrand can be expanded as $$\int_0^1 \sum_{k=0}^nS_{k, n}x^{n-k} dt$$
where $S_{k, n}$ is the sum of the product of all $\binom{n}{k}$ "$k$-tuples" from $c_1, c_2, ..., c_n$ (except for $S_{0, n} = 1$). For example, $S_{2, 4} = c_1c_2+c_1c_3+c_1c_4 + c_2c_3+c_2c_4+c_3c_4$ and $S_{3, 4} = c_1c_2c_3+c_1c_2c_4+c_1c_3c_4+c_2c_3c_4$. Let $s_{k, n}$ be defined in a similar way, but for $a_i$ instead of $c_i$
Then the integral is
$$\sum_{k=0}^{n} \frac{S_{k, n}}{n+1-k}$$
For $n = 3$, this gives $$\frac{(1-2p)^3a_1a_2a_3}{8}+\frac{(1-2p)(a_1+a_2+a_3)}{24} = $$ $$\frac{(1-2p)^3 s_{3, 3}}{8} + \frac{(1-2p) s_{1, 3}}{24}$$
For $n = 4$, this gives $$\frac{(1-2p)^4 s_{4, 4}}{16}+\frac{s_{2, 4}}{48}(1-2p)^2 + \frac{1}{80}$$
For $n = 5$, this gives $$\frac{(1-2p)^5 s_{5, 5}}{32} + \frac{(1-2p)^3 s_{3, 5}}{96} + \frac{(1-2p)s_{1, 5}}{160}$$
In general it seems like $$I(a_1, ..., a_n, p) = \sum_{1 \le k \le n+1, k\pmod2 = 1} \frac{(1-2p)^{n+1-k} s_{n+1-k, n}}{k\cdot 2^n}$$
although I have not confirmed this.