# Law of logs false for symbols but true for numbers

Why do I get False for the additive law of logs for symbols, but True for numbers?

var('a b')
print(bool(log(a)+log(b)==log(a*b)))
print(bool(log(5)+log(10)==log(5*10)))

False
True

edit retag close merge delete

And how do I delete a comment?

( 2020-08-15 07:23:24 +0100 )edit

Sort by » oldest newest most voted

As you can see with its source code (by typing log??), the log function first tries to call the .log method, which is different from symbolic expressions and for Sage integers, so there is no contradiction here.

What you are pointing here is the fact that when the symbolic ring is not able to prove something, it considers it as False. Here, False means False or Unknown. I admit that such a trivial case should be dealt with.

As a workaround, you can help the symbolic ring to prove the equality by expanding the logs:

sage: print(bool((log(a)+log(b)==log(a*b)).simplify_log()))
True

more

The problem here, once again, is that most functions we consider are actually multivalued complex functions, which really aren't function on $\mathbb{C}$ at all in the normal sense. This usually gets solved by picking a "principal branch", but that sacrifices analyticity along the branch cut. For log, you can see what happens:

sage: log(-1)
I*pi
sage: log(-1)+log(-1)
2*I*pi
sage: log( (-1)*(-1))
0


These two values are not equal: they differ by an integer multiple of $2\pi I$. Since complex logs are "only defined up to multiples of $2\pi I$, they are "essentially" equal (as values taken by logs), but not as elements of $\mathbb{C}$.

( 2020-08-15 18:40:50 +0100 )edit

I couldn't find a description of simplify_log anywhere, or in Help. Can you point me to one? So far it doesn't seem to do anything. It returned the same log of products as the same that was input, and as the same symbolic type. I'm curious what it actually does.

I think what bothers me is bool(log(a)+log(b)==log(a*b) was working Entirely in symbolic values, so I'm wondering just where I can trust Sagemath for symbolic results without checking type for every single step.

( 2020-08-16 01:16:52 +0100 )edit

It still works:

sage: var('a,b')
sage: bool(log(a)+log(b) == log(a*b))
False


In general you cannot expect that a symbolic engine will be able to prove all symbolic identities, so it's important that False can mean Don't know. In this case, however, it's really the case that there are numerical inputs for which the identity doesn't hold, so the False really is False in this case.

( 2020-08-16 05:43:38 +0100 )edit