If we reflect $(x,y)$ about $y=x$ then we get $(y,x)$. And because $x^2+y^2=y^2+x^2$ this can also be represented by a rotation.
Using this we get:
$$(x,y)•(y,x)=2xy=(x^2+y^2)\cos (\theta)$$
Hence
$\theta=\arccos (\frac{2xy}{x^2+y^2})$
So using complex numbers we rotate $(x,y)$ clockwise/counterclockwise an angle of $\arccos (\frac{2xy}{x^2+y^2})$ depending on which side of $y=x$ the point is, i.e. Depending on wether or not $y > x$.
My question : How can we know the angle is $\arccos (\frac{2xy}{x^2+y^2})$ without using the already known result that $(x,y)$ rotated about $x=y$ is $(y,x)$?
What follows might be difficult to understand because of abuse of notation.
First calculate the orthogonal projection of $(x,y)$ onto the line $y=x$ (i.e. the point on the line $y=x$ which is closest to the point $(x,y)$).
Call the resulting point $(a,b)$.
Then calculate the angle between the vector with $(a,b)$ as its arrow and $(0,0)$ as its base and the vector with $(x,y)$ as its head and $(0,0)$ as its base. Call this angle $\theta$.
If $(x,y)$ is $\theta$ to the right of $y=x$ then its reflection about the line is $\theta$ to the left of $y=x$ (and $2\theta$ to the left of the vector with arrow $(x,y)$ and base at the origin).
Likewise everything above with left and right interchanged if $(x,y)$ is $\theta$ to the left of $y=x$.
The rotation of $(a,b)$ by $\theta$ or $(x,y)$ by $2\theta$ can be accomplished by using a 2d rotation matrix: https://en.wikipedia.org/wiki/Rotation_matrix