call theta = t for ease.
Now, the particle attacks the first wall with speed u, usint parellel, ucost perpendicular. So after first collision, travelling usint parellel to first wall, eucost perpendicular to first wall.
Now, to second wall, Parellel to the wall (and sort of up it) are the components
(usint)cost + (eucost)sint
Perpendicular and into it
(eucost)cost - (usint)sint
So after the second collision, it moves with u(e+1)sintcost parellel to second wall and up it, and eu(ecos2t - sin2t) and away from it. For this to be parellel to first wall, the vertical components of each must cancel out, i.e.
u(e+1)costsint . sint = eucost(ecos2t - sin2t)
=>
(e+1)sin2t = e2cos2t - esin2t
=> (2e+1)tan2t = e2.
Q.E.D