$\ln(x^2)$ vs. $2\ln(x)$

Are the following functions equal or one is the restriction of the other?

$f(x) = \ln(x^2)$

$g(x) = 2\ln(x)$

My book says that $g(x)$ is the restriction of $f(x)$ to $\mathbb{R^+}$ and I can verify that on my calculator.

But that doesn't make any sense to me. Shouldn't $2\ln(x) = \ln(x^2)$ ? Or is it because my calculator does $\ln(x)$ first, and then multiplies the result by 2, and so $x$ cannot take a negative value?

Does that mean that these functions are analitically equal but diferent in practice? Or does this happen just because this is the way my calculator is programmed?

Can someone explain this to me?


Solution 1:

The function $f(x)$ has as domain $x\ne0$, $g(x)$ has $x>0$ as domain so they are different. In fact $\ln(-4)^2$ exists for the first function, not for the second one $2\ln(-4)=???$. You can transform the first function in $2\ln|x|$, but you must pay attention to put the absolute value so that the domain remains the same!

Solution 2:

$\ln x^2 = 2 \ln \vert x \vert$

The logarithm of a negative number requires delving into the land of complex numbers. See here.

It turns out that $2\operatorname{Log}(-5) = 2\ln 5 +\pi i$ for the so-called principal branch of the complex logarithm, which is a good thing to Google if you're interested.

Solution 3:

$\ln(x)$ domain is $\mathbb{R}^+$, so any function used as its argument must not have a range that exceeds $\mathbb{R}^+$. $x^2$'s range $\mathbb{R}^+$, whereas $x$'s range is $\mathbb{R}$.