Sign of square root of a real number May we write $\sqrt{x^2}=\pm x$.      
Is  $\sqrt{x^2}=\sqrt{(\pm x)^2}=\pm{x}$ true ?
 But we write $\sqrt{x^2}=|x|=x$
What is the actual logic? 
 A: You are confused because there are two notions at play here which the standard treatment of the square root obfuscates: functions and solutions of equations.
The right way to think about the square root is as a function: given any positive number $a$, the square root function returns the square root $\sqrt a$ (I should technically write"nonnegative" instead of "positive," but I wanted to shoot for clarity over pedantry). And what is $\sqrt a$? The unique positive solution to the equation $x^2=a$. I can't emphasize the "positive" part of that definition enough. It would not make any sense to define the square root to be the solution to the equation $x^2=a$ since in general that equation has two solutions: for instance, the equation $x^2=4$ has the two solutions $x=2$ and $x=-2$. If we defined the square root of $2$ to be the solution to the equation $x^2=4$, we would not know what to do when it came time to actually compute $\sqrt4$ since we would have to choose between $2$ and $-2$. Mathematicians chose $\sqrt a$ to mean the positive solution to the equation $x^2=a$, but they could just as well have chosen it to mean the negative solution (although that would have been unpopular for aesthetic reasons).
My response is a little more rambling than I intended. Does that clear up the matter?
A: The square root is like a function. The function $f(x)=\sqrt{x^2}$ exists, but the function $f(x)=\pm \sqrt{x^2}$ does not. By convention, we define $\sqrt{x^2}=|x|$, but logically $\sqrt{x^2}=-x$ as well.
Think of it like a traffic light. We define the red light to mean "stop", and the green light to mean "go". But logically, it could be the other way around. But if you think the green light means "stop", people are going to take you for a fool. Same with the whole $\sqrt{x^2}=|x|$ thing.
If you want an explanation from a mathematical point of view, continue reading. The function $g(x)=\sqrt{x}$ is the inverse of the function $f(x)=x^2$. But, we must restrict the domain to $x \ge 0$ in order for $f(x)$ to have an inverse. If the domain was $x \in \mathbb{R}$, $f(x)$ would not pass the horizontal line test.
