Ask Your Question
0

Law of logs false for symbols but true for numbers

asked 2020-08-15 07:15:55 +0200

cybervigilante gravatar image

updated 2020-08-15 07:38:05 +0200

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 flag offensive close merge delete

Comments

And how do I delete a comment?

cybervigilante gravatar imagecybervigilante ( 2020-08-15 07:23:24 +0200 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-08-15 12:48:46 +0200

tmonteil gravatar image

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
edit flag offensive delete link more

Comments

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}$.

nbruin gravatar imagenbruin ( 2020-08-15 18:40:50 +0200 )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.

cybervigilante gravatar imagecybervigilante ( 2020-08-16 01:16:52 +0200 )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.

nbruin gravatar imagenbruin ( 2020-08-16 05:43:38 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2020-08-15 07:15:55 +0200

Seen: 57 times

Last updated: Aug 15 '20