# But is it really true that $\log(xy) = \log(x)+\log(y)$

We probably all know that

$$\log (x y)=\log x + \log y$$

However the expression on the left needs only $$x y >0$$ to be defined, whereas the expression on the right requires $$x>0$$ and $$y>0$$.

For example suppose you were maximizing $$\max \log(x)+\log(y), s.t. constraints$$

vs

$$\max \log(xy) s.t. constraints$$

The two problems seem to be entirely different, although a naive substitution would imply that the two are identical.

My question is: Is this point discussed anywhere? I haven't come across a discussion of this. Are there any references to find more on that?

• In this context, the correct statement is "for all positive numbers $x$ and $y$, $\log(xy) = \log(x) + \log(y)$." The statement "for all real numbers $x$ and $y$, $\log(xy) = \log(x) + \log(y)$" is ill-defined (assuming we only define $\log$ on positive numbers). Nov 12, 2022 at 2:50
• If $\log (x y)$ is defined opportunistically (for anything that makes sense) then it does not equal $\log x+\log y$ defined opportunistically (for anything that makes sense, ignoring imaginary numbers)
– Cris
Nov 12, 2022 at 2:55
• Yes, only when $x,y>0$. Nov 12, 2022 at 2:58
• It is not technically appropriate to directly talk about the truth value of an open formula (i.e., a formula that includes unquantified variables). For example, it is technically inappropriate to say that the formula "$x - x = 0$" is true. The formula "for all real numbers $x$, $x - x = 0$", however, is a true closed formula. In practice, the latter is usually implied when referring to the former. Nov 12, 2022 at 3:00

You are right: Formulas and theorems come with conditions on the variables they are about. $$\log(x)+\log(y)=\log(xy)$$ is false. What is true is

For every positive real numbers $$x$$ and $$y$$, $$\log(x)+\log(y)=\log(xy)$$

I guess that some people would consider that, when writing $$\log(x)+\log(y)=\log(xy)$$, it is implicitly assumed that each number exists (here, $$x$$ and $$y$$ are positive), but I think it is a bad habit, especially for students.

This has practical implications. As an example, the equation $$2\log(x+1)-\log(x+3)=0$$ is NOT equivalent to $$\log\left( \frac{(x+1)^2}{x+3} \right)=0$$ since $$-2$$ is a solution of the latter but not of the former ($$\log(-1)$$ is not defined).

Your optimization problem is another example. In maximizing $$\log(xy)$$, you have the constraint that the product $$xy$$ should be positive (so $$x$$ and $$y$$ are nonzero and have the same sign), while in maximizing $$\log(x)+\log(y)$$, the constraints are stronger ($$x$$ and $$y$$ should be positive).

If we work with real valued logarithm and if we only have the constraint $$xy>0$$, you can derive the similar logarithm rule:

\begin{align}\log(xy)&=\log \left(|xy|\right)\\ &=\log \left(|x|×|y|\right)\\ &=\log |x|+\log |y|.\end{align}

In general, note that

$$\log (xy)=\log x+\log y$$

holds, iff $$x>0\wedge y>0$$.

If you define it via integral formula i.e. $$\displaystyle \ln(x)=\int_1^x \dfrac{dt}t$$

You can see that you need the interval $$[1,x]$$ (or $$[x,1]$$ if $$x<1$$) to not cross $$0$$ else the integral would be divergent, which consequently means that $$x$$ must be strictly positive.

The multiplication to addition formula can be proven this way ($$a,b>0$$):

First by substituting $$u=\frac 1t$$ then $$\ln(\tfrac 1x)=\int_1^{\frac 1x}\dfrac{dt}{t}=\int_1^x \dfrac{-u\mathop{du}}{u^2}=-\int_1^x du=-\ln(x)$$

Then by substituting $$t=bu$$ then $$\ln(ab)=\int_1^{ab}\dfrac{dt}{t}=\int_{\frac 1b}^a \dfrac{b\mathop{du}}{bu}=\int_{\frac 1b}^a \dfrac{du}{u}\ \overset{(*)}{=}\ \ln(a)-\ln(\tfrac 1b)=\ln(a)+\ln(b)$$

Justification of (*):

• It is straightforward when $$a,b>0$$ since we can rewrite $$\displaystyle\int_{\frac 1b}^1 \frac{du}{u}+\int_1^a \frac{du}{u}\$$ and then use the definition.

• On the contrary when $$a,b<0$$ this split is not possible since each individual integral is divergent. But we can substitute $$v=-u$$ and get

$$\int_{\frac 1b}^a \dfrac{du}{u}=\int_{-\frac 1b}^{-a} \dfrac{-dv}{-v}=\int_{\frac 1{|b|}}^{|a|} \dfrac{dv}{v}=\ln(|a|)+\ln(|b|)$$

Now with $$|a|,|b|>0$$ the split is possible.

In the end the "true" formula is rather:

• if $$\ln(a),\ln(b)$$ are defined (i.e. then $$a,b>0$$) then their sum is equal to $$\ln(ab)$$
• if $$\ln(ab)$$ is defined (i.e. $$ab>0\iff\{a,b>0\}\lor\{a,b<0\}$$) then it is equal to $$\ln(|a|)+\ln(|b|)$$

Yet commonly the case where $$a,b$$ are both negative is not very frequent, and the usage settled for the omission of the absolute values.