Launching billiard balls at 45 degree angles and bouncing of off edges. Say I have a billiard ball and I launch it from the bottom-left corner of a table with length $x$ and width $y$. Given $x$ and $y$ will the ball reach a corner again, which corner and in how many times will it need to bounce off the edge.
*I launch it from a $45$ degree angle at the start and it always bounces off the edges at $45$ degrees
 A: I have an idea how to model the problem. Look at the picture: when the ball bounces, it may be thought as entering a virtual pool placed next to the one it's coming from. Now, thinking of a coordinate system whose origin is in the bottom left corner, the tables corners have coordinates $(nx, my)$ with $n, m \in \mathbb N$, and you want them to be equal so that they can be touched by the ball travelling at $45°$. So $nx=my$ for some $m, n$, that is $n/m = y/x$. I think this is providing the solution: to ever reach another corner the sides of the table must be commensurable. And the number of bounces is $n+m-2$.
A: Let's set this up in a coordinate plane. Just for the sake of convenience, I'm going to have the ball be launched from the bottom left corner instead so that I can let the origin be the launching point. Then let the top left corner be $(0,y)$, the bottom right corner be $(x,0)$, and the top right corner be $(x,y)$. Let us make $x\gt y$ (we are avoiding the trivial case $x=y$ when it is a square, since it will go directly into the opposite corner). Then the first bounce will occur at the point $(x,x)$.
Here is what we must do to make this problem manageable. Instead of having the ball bounce off the left and right sides, we will have it pass through them like portals and come out the opposite side. This will not affect whether or not the ball reaches a corner.
Then we only want to count the bounces on the top and bottom of the table, since the left and right are now "portals". In this case each bounce will occur at a multiple of $y$. The abscissa of the nth bounce will be
$$yn \bmod x$$
and the final bounce in the hole will be when
$$yn \bmod x=0$$
and the smallest $n$ for which this is true is
$$n_h=\frac{x}{GCD(x,y)}$$
Then the number of bounces on the top and bottom is $n_h$. Then number of side bounces is the number of times the ball passes through the "portal", which is
$$\frac{yn_h}{x}-1$$
excluding the final bounce in the hole, since the number of vertical bounces counts it. Then the total number of bounces is
$$n_h+\frac{yn_h}{x}-2$$
where $x \gt y$ and $n_h=\frac{x}{GCD(x,y)}$.
This expression can be simplified to
$$\frac{x+y}{GCD(x,y)}-2$$
And, if we assume that $x$ and $y$ are relatively prime,
$$x+y-2$$
But wait... doesn't a billiards table have side pockets?
Okay, so by following the reasoning used previously, the ball will enter a side pocket when
$$yn \bmod x=\frac{1}{2}x$$
So, of course, this can only happen when $x$ is even. We can change this to
$$2yn \bmod 2x=x$$
This is the same as when
$$\frac{2yn-x}{2x}$$
is an integer. If we simplify this to
$$\frac{yn}{x}-\frac{1}{2}$$
If we assume again that $x$ and $y$ are relatively prime, then we have that the smallest $n$ for which this is true must be
$$n_h=\frac{x}{2}$$
However, this can still only occur when $x$ is even.
If we have that $n_h=x$, then the number of bounces on the top and bottom is
$$\frac{x}{2}-1$$
and the total distance travelled by the ball horizontally is
$$\frac{yx}{2}$$
so the number of bounces on the left and right sides is
$$\lfloor\frac{yx}{2x}\rfloor$$
$$\lfloor\frac{y}{2}\rfloor$$
and the total number of bounces is then
$$\frac{x}{2}+\lfloor\frac{y}{2}\rfloor-1$$
Which, given our assumptions, can be simplified to
$$\frac{x}{2}+\frac{y}{2}-\frac{3}{2}$$
$$\frac{x+y-3}{2}$$
And so, if we let $b(x,y)$ be a function taking in two relatively prime integers as arguments, and outputting the number of bounces made by the billiards ball shot on a table with those side lengths, we get
$$
b(x,y) = \left\{\begin{aligned}
\frac{x+y-3}{2} && 2|x\\
x+y-2 && else
\end{aligned}
\right.$$
