I need to integrate
$$
\int\limits\_{[1,a]^n} \frac {\chi(\{ b \le x\_1 \cdots x\_n \le c \})} {( x\_1 x\_2 \cdots x\_n)^k} \,dx\_1 \cdots dx\_n,
$$ where $\chi(E)$ is the characteristic function of a set $E$.
We have $a>1$ and $c>b>1$; furthermore $k\in\mathbb R$, but feel free to restrict it to either larger than $0$ or smaller than $0$ if that's easier; the case $k=0$ would also be of independent interest.


While this might look like homework, it's come up in a research context; I sincerely hope it is as easy as homework for someone, I've dug through various papers, but it seems tough. So I'm happy for any pointers!!


Thanks!


PS: I'm happy to give more context, but I'm not sure it'll add much.



Integrate $1/(x_1x_2\cdots x_n)^k$ for $1\le x_i \le a$, where product of coordinates satisfies $ b\le x_1\cdots x_n\le c$
**UPDATE 2019-05-31.** Formulae are corrected and SageMath code added.


Let us assume that $a$ is fixed, and define:
$$
I\_n^{k,l}(b,c) := \iiiint\_{[1,a]^n} \frac {\chi(\{ b \le x\_1 \cdots x\_n \le c \})\log(x\_1 x\_2 \cdots x\_n)^l} {( x\_1 x\_2 \cdots x\_n)^k} \,dx\_1 \cdots dx\_n.
$$
Hence, the integral in question equals $I\_n^{k,0}(b,c)$.


We first consider the case $b\leq\frac{c}a$, while the other case is considered similarly.


We will need the following formula, which holds for all integer $l\geq 0$:
$$\int \frac{\log(y)^l}{y^k}dy = \begin{cases}
\frac{\log(y)^{l+1}}{l+1}, & \text{if }k=1;\\
-\sum\_{i=0}^l \frac{l!}{i!(k-1)^{l+1-i}} \frac{\log(y)^i}{y^{k-1}} & \text{if }k\ne 1.
\end{cases}$$


Making a substitution $x\_n := \frac{t}{x\_1\cdots x\_{n-1}}$, we get
$$I\_n^{k,l}(b,c) = \int\_1^a dx\_1 \cdots \int\_1^a dx\_{n-1} \int\_{x\_1\cdots x\_{n-1}}^{ax\_1\cdots x\_{n-1}} dt\frac{\log(t)^l\chi(b\leq t\leq c)}{t^k x\_1\cdots x\_{n-1}}.$$


If $k\ne 1$, depending on the value of $x\_1\cdots x\_{n-1}$ the last integral breaks into 4 cases:


* If $x\_1\cdots x\_{n-1}\leq \frac{b}{a}$ or $x\_1\cdots x\_{n-1}\geq c$, then the integral over $t$ is zero.
* If $\frac{b}{a} \leq x\_1\cdots x\_{n-1}\leq b$, then the integral over $t$ equals 
$$-\sum\_{i=0}^l \frac{l!}{i!(k-1)^{l+1-i}} \frac{\log(ax\_1\cdots x\_{n-1})^i}{a^{k-1}(x\_1\cdots x\_{n-1})^k} + \sum\_{i=0}^l \frac{l!}{i!(k-1)^{l+1-i}} \frac{\log(b)^i}{b^{k-1}x\_1\cdots x\_{n-1}}$$
* If $b\leq x\_1\cdots x\_{n-1}\leq \frac{c}{a}$, then the integral over $t$ equals 
$$-\sum\_{i=0}^l \frac{l!}{i!(k-1)^{l+1-i}} \frac{\log(ax\_1\cdots x\_{n-1})^i}{a^{k-1}(x\_1\cdots x\_{n-1})^k} + \sum\_{i=0}^l \frac{l!}{i!(k-1)^{l+1-i}} \frac{\log(x\_1\cdots x\_{n-1})^i}{(x\_1\cdots x\_{n-1})^k}.$$
* If $\frac{c}{a}\leq x\_1\cdots x\_{n-1}\leq c$, then the integral over $t$ equals 
$$-\sum\_{i=0}^l \frac{l!}{i!(k-1)^{l+1-i}} \frac{\log(c)^i}{c^{k-1}x\_1\cdots x\_{n-1}} + \sum\_{i=0}^l \frac{l!}{i!(k-1)^{l+1-i}} \frac{\log(x\_1\cdots x\_{n-1})^i}{(x\_1\cdots x\_{n-1})^k}$$


Hence, if $b\leq\frac{c}{a}$ and $k\neq 1$, we get a recurrence formula:
$$I\_n^{k,l}(b,c) = -\sum\_{i=0}^l \frac{l!}{i!(k-1)^{l+1-i}} \left( \sum\_{j=0}^i \binom{i}{j} \frac{\log(a)^{i-j}}{a^{k-1}} I\_{n-1}^{k,j}(\frac{b}{a},\frac{c}{a}) - \frac{\log(b)^i}{b^{k-1}} I\_{n-1}^{1,0}(\frac{b}{a},b) - I\_{n-1}^{k,i}(b,c) + \frac{\log(c)^i}{c^{k-1}}I\_{n-1}^{1,0}(\frac{c}{a},c) \right).$$
It can be easily verified that the same formula holds in the case $b\geq\frac{c}{a}$ as well. In fact, for the original problem, we don't need this formula in full generality, but rather its special case with $l=0$:
$$I\_n^{k,0}(b,c) = \frac{1}{1-k} \left( \frac{1}{a^{k-1}} I\_{n-1}^{k,0}(\frac{b}{a},\frac{c}{a}) - \frac{1}{b^{k-1}} I\_{n-1}^{1,0}(\frac{b}{a},b) - I\_{n-1}^{k,0}(b,c) + \frac{1}{c^{k-1}}I\_{n-1}^{1,0}(\frac{c}{a},c) \right).$$


Similarly, when $k=1$, we get the formula:
$$I\_n^{1,l}(b,c) = \frac{1}{l+1}\left(\sum\_{j=0}^{l+1} \binom{l+1}{j} \log(a)^{l+1-j} I\_{n-1}^{1,j}(\frac{b}{a},\frac{c}{a}) - \log(b)^{l+1} I\_{n-1}^{1,0}(\frac{b}{a},b) - I\_{n-1}^{1,l+1}(b,c) + \log(c)^{l+1} I\_{n-1}^{1,0}(\frac{c}{a},c) \right).$$


These formulae allow to compute the integral $I\_n^{k,l}(b,c)$ recursively. The recursion stops as soon as $n=1$, $c\leq 1$, or $b\leq 1$ and $c\geq a^n$ -- in all these cases the corresponding integral can be computed explicitly.




---


SageMath code implementing these formulae:



```
def II(n,k,l,a,b,c):
  if (c<=1) or (c<=b) or (b>=a^n):
    return 0

  if n==1:
    if k==1:
      return ( log(min(a,c))^(l+1) - log(max(1,b))^(l+1) ) / (l+1)
    return - sum( factorial(l)/factorial(i)/(k-1)^(l+1-i) * ( log(min(a,c))^i/min(a,c)^(k-1) - log(max(1,b))^i/max(1,b)^(k-1) ) for i in range(l+1) )

  if k==1:
    return ( sum( binomial(l+1,j)*log(a)^(l+1-j)*II(n-1,1,j,a,b/a,c/a) for j in range(l+2) ) - log(b)^(l+1)*II(n-1,1,0,a,b/a,b) - II(n-1,1,l+1,a,b,c) + log(c)^(l+1)*II(n-1,1,0,a,c/a,c) ) / (l+1)
  return - sum( factorial(l)/factorial(i)/(k-1)^(l+1-i) * ( sum( binomial(i,j)*log(a)^(i-j)/a^(k-1)*II(n-1,k,j,a,b/a,c/a) for j in range(i+1) ) - log(b)^i/b^(k-1)*II(n-1,1,0,a,b/a,b) - II(n-1,k,i,a,b,c) + log(c)^i/c^(k-1)*II(n-1,1,0,a,c/a,c) ) for i in range(l+1) )

```

