$\log(x^2)$ is not equal to $2\log(x)$ [duplicate]

on internet we usually see: $$2\log(x) = \log(x^2)$$ (example)but how is this true? one is defined for $$x>0$$ and the other one for $$x\neq0$$

• One ought to write $\log (x^2)=2\log |x|$.
– lulu
Dec 11, 2021 at 16:14
• That identity holds for positive real x, in the same way as $\sqrt{x^2} = x$ holds only for $x \ge 0$, or $1/(1/x) = x$ holds only for $x \ne 0$. Dec 11, 2021 at 16:15
• Fun fact: $1\ne\frac{x}{x}$
– Vega
Dec 11, 2021 at 16:17
• You can have two functions defined on different domains, which coincide on the intersection of their domains. Dec 11, 2021 at 16:18
• Does this answer your question? Is Wolfram Alpha calculating this incorrectly? Dec 11, 2021 at 16:26

The assertion $$\log(x^2)=2\log(x)$$ and similar expressions usually means that we have that equality when both the LHS and RHS are defined. It's like the equality$$\frac1{1/x}=x.\tag1\label1$$The LHS is undefined when $$x=0$$, whereas the RHS is defined for every number. And asserting that $$\eqref1$$ holds means, in this case, that it holds when $$x\ne0$$.
• thank you, sorry but this was in one of the prof solutions and he passed from $log((t-1)^2)$ to $log((1-t)^2)$ Dec 11, 2021 at 18:24