Recently I have encountered a problem like this:
Let $x<2$. What is the following expression equal to? $\sqrt{9-6x+x^2}$.
First of all I decided to change the order of the numbers to an expression like $x^2 - 6x + 9$. Then I turned it into $(x-3)^2$. And because it was inside of a square root, I turned it into just $x-3$.
But then I decided to check myself using Photomath, and I saw that it didn't change the order of the numbers (like I did), but instead - it turned the expression to $(3-x)^2$, and took it out of the square root, to become $3-x$.
Then I tried checking myself with ChatGPT, but it solved this expression like I did.
It may be a stupid question, but where did I fail?
There is no issue with the difference between $x-3$ and $3-x$.
First, observe that
$$a-b = (-1)(b-a)$$
Then
$$(x-3) = (-1)(3-x)$$
and
$$(x-3)^2 = (x-3)(x-3) = (-1)(3-x)(-1)(3-x) = (-1)^2 (3-x)^2 = (3-x)^2$$
However do note that
$$\sqrt{x^2} = |x|$$
not just $x$. (Try $x=-1.$)