Let $X,Y$ and $Z$ be the three random variables. For the middle value to lie between $a$ and $b$ we have the following cases
- All $X,Y$ and $Z$ are between $a$ and $b$
- $2$ of $X,Y$ and $Z$ are between $a$ and $b$ and one is less than $a$
- $2$ of $X,Y$ and $Z$ are between $a$ and $b$ and one is greater than $a$
- Exactly one of $X,Y$ and $Z$ is between $a$ and $b$ and one other is less than $a$ and the remaining is greater than $b$
- Probability of case $1:$ $\left({b-a}\right)^3$ (Uniform distribution)
- Probability of case $2:$ ${}^3C_2 \times \left({b-a}\right)^2 \times {a}$
- Probability of case $3:$ ${}^3C_2 \times \left({b-a}\right)^2 \times ({1-b})$
- Probability of case $4:$ $3! \times {a} \times ({b-a}) \times ({1-b})$
Since, all these cases are mutually exclusive (no overlapping) and exhaustive (no other favorable case) we can get the required probability by adding the probabilities for the four cases as
$(b-a) \left[ (b-a)^2+3(b-a)a+3(b-a)(1-b)+6a(1-b)\right]$
$=(b-a) \left[ (b-a)^2+3(b-a)a+3(1-b) (b+a)\right]$
$=(b-a) \left[ (b-a)^2+3(ab-a^2+b+a-b^2-ab)\right]$
$=(b-a) \left[ (b-a)^2+3(-a^2-b^2+b+a)\right]$
$=(b-a) \left[ a^2+b^2-2ab-3a^2 -3b^2+3b+3a\right]$
$=(b-a) \left[ -2a^2-2b^2-2ab+3b+3a\right]$
$= -2a^2b-2b^3-2ab^2+3b^2+3ab + 2a^3+2ab^2+2a^2b-3ab-3a^2$
$ =2(a^3-b^3)+3(b^2-a^2)$
$ =3(b^2-a^2)-2(b^3-a^3)$
$ =6((b^2-a^2)/2-(b^3-a^3)/3)$
Correct Option: E