Finding $P( x_1 + x_2 + x_3\le 8) $ where the variables are uniformly distributed

integrationprobability

Problem:
Suppose that $x_1$, $x_2$ and $x_3$ are independent uniformly distributed on the interval $[1,3]$. What is the probability that
$x_1 + x_2 + x_3 < 8$.
Answer:
Let $p$ be the probability we seek. The density for these three random variables is:
$$ f(x) = \begin{cases}
\frac{1}{2} & \text{for } 1 \leq x \leq 3 \\
0, & \text{otherwise }
\end{cases} $$

\begin{align*}
p &= \int_{1}^{3} \int_{1}^{5-x_1} \int_{1}^{8-x_1-x_2} \left( \frac{1}{2}\right)^3 \, dx_3 \, dx_2 \, dx_1 \\
p &= \int_{1}^{3} \int_{1}^{5-x_1} \frac{x_3}{8} \, \Big|_{x_3 = 1}^{x_3 = 8-x_1-x_2} \, dx_2 \, dx_1 \\
p &= \int_{1}^{3} \int_{1}^{5-x_1} \frac{8 – x_1 – x_2}{8} – \frac{1}{8} \, dx_2 dx_1 \\
p &= \int_{1}^{3} \int_{1}^{5-x_1} \frac{7 – x_1 – x_2}{8} \, dx_2 \, dx_1 \\
p &= \int_{1}^{3} \frac{7x_2 – x_1 x_2 – \frac{x_2^2}{2}}{8} \Big|_{1}^{5-x_1} \, dx_1 \\
p &= \int_{1}^{3} \frac{7(5-x_1) – x_1(5-x_1) – \frac{(5-x_1)^2}{2} }{8} – \frac{1}{8} \, dx_1 \\
p &= \int_{1}^{3} \frac{14(5-x_1) – 2x_1(5-x_1) – (5-x_1)^2 – 2 }{16} \, dx_1 \\
p &= \int_{1}^{3} \frac{ 70 – 14x_1 – 2x_1(5-x_1) – ( 25 – 10x_1 + x_1^2 ) – 2 }{16} \, dx_1 \\
p &= \int_{1}^{3} \frac{ 70 – 14x_1 – 2x_1(5-x_1) – 25 + 10x_1 – x_1^2 – 2 }{16} \, dx_1 \\
p &= \int_{1}^{3} \frac{ – 14x_1 – 2x_1(5-x_1) + 10x_1 – x_1^2 + 43 }{16} \, dx_1 \\
p &= \int_{1}^{3} \frac{ -4x_1 – 2x_1(5-x_1) – x_1^2 + 43 }{16} \, dx_1 \\
p &= \int_{1}^{3} \frac{ -4x_1 – 10x_1 + 2x_1^2 – x_1^2 + 43 }{16} \, dx_1 \\
p &= \int_{1}^{3} \frac{ x_1^2 – 14x_1 + 43 }{16} \, dx_1 \\
p &= \int_{1}^{3} \frac{ x_1^2 – 14x_1 }{16} \, dx_1 + (3-1)\left( \frac{43}{16} \right) \\
p &= \int_{1}^{3} \frac{ x_1^2 – 14x_1 }{16} \, dx_1 + \frac{43}{8} \\
p &= \left( \frac{1}{16 }\right) \int_{1}^{3} ( x_1^2 – 14x_1 ) \, dx_1 + \frac{43}{8} \\
\end{align*}

Using an online integral calculator, I find:
$$ \int_{1}^{3} ( x_1^2 – 14x_1 ) \, dx_1 = – \frac{142}{3} $$
\begin{align*}
p &= \left( \frac{1}{16 }\right) \left( – \frac{142}{3} \right) \,+ \frac{43}{8} \\
p &= -\frac{71}{3(8)} + \frac{43}{8} = \frac{139 – 71}{24}
\end{align*}

Since $p$ is greater than $1$, my answer cannot be right. Were did I go wrong?

I would also like to know if I setup the integral correctly.

I ran the following R script:

count = 0
limit = 10*1000*1000
for ( i in 1:limit ) {
    num =  sum( runif( 3, 1, 3 ) )
    if ( num <= 8 )
         count = count + 1
}

The result was around 0.979. Therefore, I question the answer of $\frac{7}{8}$.

Best Answer

I disagree with the other answer (and OP, and another commenter) that the $x_2$ limit has to be $\min(5-x_1, 3)$. Why should it be that? $x_2$ can be the entire range $[1,3]$. There is zero reason to restrict $x_1+x_2 \le 5$ because, for any $(x_1,x_2) \in [1,3]^2$ we can account for $x_1+x_2+x_3 \le 8$ simply by integrating $x_3 \in [1, \min(8-x_1-x_2,3)]$. E.g. the point $(3,3,1.9)$ is a part of the event (i.e. it satisfies the inequality) but is not part of the integral if we use the limits $x_2 \in [1, \min(5-x_1, 3)] = [1, 2]$.

I.e. I think the correct integral should be:

$$\int_1^3 dx_1 \int_1^3 dx_2 \int_1^{\min(8-x_1-x_2,3)} \frac18 dx_3 = {47 \over 48}$$

as evaluated by wolfram alpha. Note that $7/8$ has to be way off because

$$\frac18 = P(x_1 > 2) P( x_2 > 2) P(x_3 > 2)$$

but it is very obvious that $x_1, x_2, x_3 > 2$ are necessary but very insufficient for $x_1 + x_2 + x_3 > 8$.