Find the shortest path from a point inside the square touching its 3 sides 
Let $ABCD$ be a square such that $A=(0,0)$ and $D=(1,1)$. $P(\frac{2}{7},\frac{1}{4})$ is a point inside the square. An ant starts walking from $P$, touches $3$ sides of the square and comes back to the point $P$. What is the least possible distance traveled by the ant?

This is a question from BdMO 2021. I don't understand the question very much. Though here is my little approach:


Here is the figure of the problem. The co-ordinates are multiplied by $28$ to get a clearer view. We get the least possible path (probably) when the ant goes from $P$ to $F$ such that $PF\perp{AB}$, then goes to $H$ such that $PH\perp{AD}$ and then to $G$ such that $PG\perp{CD}$ and returns from $G$ to $P$ ( I'm not sure about this and I don't have any proof of this).

So, what's the solution with proper proof?
 A: We can reflect the original square in some directions. For example, if you think the solution should bump into the sides top right, top left and bottom left, then we can make three reflections and each segment, instead of coming back to the original square, keeps advancing with reflected angle. This is a common technique in this kind of problems, and it's not hard to prove that every solution in one view is a solution in the other, with both having the same length because reflections are isometries, so they preserve lengths of segments.

You can see here two solutions with the segments reflected, sorry for the bad quality, I just did it quickly. The point $P$ is the little circles, and each of them is one reflection of the same $P$ over the sides. In blue I've added your attempt reflected. In red I've added the optimal solution for those particular sides: top right, top left and bottom left. You can notice the red one goes more directly than the blue one, it's literally the straight line joining both points, that's why it's easier to solve in this reflected space. You'd have to transform back this red solution in the original space.
Now, you'd have to consider if the solution could be made with less length choosing other three sides, there are a total of four options. You can just calculate the length quickly for the four options, because it's the length of a segment in the space.
Notice also how the condition that the path should bump into three sides in this new view is just crossing three sides.
A: Consider a slightly more general configuration. Let $ADEF$ be a rectangle, where $|AF|=|DE|=b$ and $|FE|=|AD|=c$, with a point $P$ fixed on $FE$ such that $|FP|=a$ (and so $|PE|=c-a$). Think of $P$ as a smooth peg and $FA,\,AD,\,DE$ as smooth rods, all of negligible thickness, around which a loop of string $PQRS$ is tightened, where $Q$ is on $DE$, $R$ is on $AD$, and $S$ is on $AF$. Let $\theta:=\angle ARS$. Since the string is tight and the rods are smooth, $\angle DRQ=\theta$ as well. Similarly, $\angle DQR=\angle EQP$ and $\angle PSF=\angle RSA$, all four angles equalling $\frac12\pi-\theta$.
By considering the sides of the four similar right-angled triangles around the figure, we get consecutively $|PF|=a$, $|FS|=b-a\tan\theta$, $|AR|=b\cot\theta-a$, $|RD|=c+a-b\cot\theta$, $|DQ|=(c+a)\tan\theta-b$, $|QE|=2b-(c+a)\tan\theta$, and finally $|EP|=c-a$. Comparing the sides $EP$ and $EQ$ of triangle $PEQ$ gives $2b-(c+a)\tan\theta=(c-a)\tan\theta$, or
$$\tan\theta=\frac b{c-a}.$$
The particular (scaled-up) example given corresponds to $a=\frac{15}2\surd2$, $b=\frac12\surd2$, and $c=28\surd2$, giving $\tan\theta=\tfrac1{41}.$ The length of the ant's walk (i.e. string) is then $2c\sec\theta$ or, after scaling back, $$2\sqrt\frac{3362}{1681}.$$
A: 

*figure not to be scaled*

Let $ABCD$ be the square and $P(\frac{2}{7},\frac{1}{4})$ be the point. We reflect the square and the point $P$ repeatedly as shown in the picture.
The sides of square $ABCD$ are colored pink, blue, green and violet. The segments with same color represent that they are the reflections of a same segment of square $ABCD$.
Let $PE$ be the perpendicular segment from $P$ to $AD$ (not shown in the figure). We see that from $\Delta{PAD}$: $$PE=\frac{1}{28\sqrt{2}}.$$ We now see that we get the shortest path when the ant touches $AD$, $AB$ and $CD$ sides i.e pink, blue and violet segments respectively (Because $P$ is closer to these segments). We see that $PP_1$ touches these $3$ segments, which means $PP_1$ is the shortest path.
Now we draw $\Delta{PP_1P_2}$, which is a right triangle with $PP_2=2\sqrt{2}$ (double of the side length of square $ABCD$) and $P_1P_2=2PE=\frac{1}{14\sqrt{2}}$. So, we have $$PP_1=\sqrt{(2\sqrt{2})^{2}+(\frac{1}{14\sqrt{2}})^2}=\boxed{\frac{\sqrt{6274}}{28}}.$$ Hence, we conclude the problem. $\square$
