Since `x` is the distance of the image of the object in the mirror from the left edge of the figure, the remaining distance to the right edge is `D-x`. Both triangles are right triangles, and the remaining distances are hypotenuses. By the Pythagorean Theorem, the distance from `P` to `R` is `sqrt(p^2+x^2)`, and the distance from `Q` to `R` is `sqrt(q^2+text[(]D-xtext[)]^2)`. Thus, the length `Ltext[(]xtext[)]` of the toatal path is the sum of these two lengths: `Ltext[(]xtext[)]=sqrt(p^2+x^2)+sqrt(q^2+text[(]D-xtext[)]^2)`.