TITLE: Computing the volume of a simplex-like object with constraints
QUESTION [6 upvotes]: For any $n \geq 2$, let 
$$D_n [r , (a_1, b_1 ) , \ldots , (a_n, b_n) ] = 
\{ (x_1 , \ldots , x_n ) \in \mathbb R^n \mid
\sum_i x_i = r \mbox{ and } b_i \geq x_i \geq a_i \, \forall i \},$$
where $r \geq b_i \geq a_i \geq 0$ for all $i$, and all are real numbers.

Question: What is the 'volume' of $D_n [r , (a_1, b_1 ) , \ldots , (a_n, b_n) ]$?

So for example for $n=2$, this set is either empty or it is some short line, and the purpose would be to calculate the length of that line (in terms of the parameters $r, a_i, b_i$). This is easy, I've done that already. Also the case $n=3$ would in principle still be doable to do by hand: it would be either zero (in case the set is empty) or part of a plane in $\mathbb R^3$, the area of which we desire to compute.
Now to come up with a formula for the case $n=3$ (and higher) in a smarter way, my idea was to reason inductively from the case $n=2$, so basically reducing the three dimensional case to the two dimensional one, etc. I obviously tried to use integrals. 
The problem I run into, is that in order to compute the volume we want with integrals, we have to view this set as (a subset of) an $n-1$-dimensional space. (Indeed, the integral of the constant function $1$ over the region $D_n [r , (a_1, b_1 ) , \ldots , (a_n, b_n) ]$ seen as part of $\mathbb R^n$ (rather than $\mathbb R^{n-1}$), is equal to $0$. That's not what we want.) But to do that, it seems to me that we would need a concrete isometric embedding of $D_n [r , (a_1, b_1 ) , \ldots , (a_n, b_n) ]$ into $\mathbb R^{n-1}$, and I can't really find a nice one.
Do you have an idea about how to approach this problem best?
(This question was previously posted on Math.StackExchange, see https://math.stackexchange.com/questions/3135606/computing-hyper-area-of-a-contrained-simplex.)

REPLY [2 votes]: We may assume without loss of generality that $a_i=0$. If
$r$ and each $b_i$ are positive integers, then consider
  $$ f(x) = \frac{\left( 1-x^{tb_1+1}\right)\cdots
    \left( 1-x^{tb_n+1}\right)}{(1-x)^n}. $$
The coefficient of $x^{tr}$ is a polynomial function of $t$,
and the volume $V$ will be its leading coefficient. If I didn't
make a computational error, then
 $$ V=\frac{1}{(n-1)!}\sum_{\substack{S\subseteq
 \{1,\dots,n\}\\ \sum_{i\in S}b_i<r}} (-1)^{|S|}
  \left(r-\sum_{i\in S}b_i\right)^{n-1}. $$
If this isn't correct, then something close to it will be.