ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 20 Apr 2021 02:12:55 +0200Why don't log rules work for symbolic values?https://ask.sagemath.org/question/56724/why-dont-log-rules-work-for-symbolic-values/Log rules are working for actual values, but fail for symbolic ones. What am I doing wrong?
var('a b')
c = bool(log(a*b) == log(a) + log(b));print(c)
c = bool(log(5*3) == log(5) + log(3));print(c)
c = log(5*3).n(); print(c)
c = log(5).n() + log(3).n(); print(c)
False
False
2.70805020110221
2.70805020110221Mon, 19 Apr 2021 06:17:20 +0200https://ask.sagemath.org/question/56724/why-dont-log-rules-work-for-symbolic-values/Answer by Emmanuel Charpentier for <p>Log rules are working for actual values, but fail for symbolic ones. What am I doing wrong?</p>
<pre><code>var('a b')
c = bool(log(a*b) == log(a) + log(b));print(c)
c = bool(log(5*3) == log(5) + log(3));print(c)
c = log(5*3).n(); print(c)
c = log(5).n() + log(3).n(); print(c)
False
False
2.70805020110221
2.70805020110221
</code></pre>
https://ask.sagemath.org/question/56724/why-dont-log-rules-work-for-symbolic-values/?answer=56726#post-id-56726Log rules *do* workfor symbolic values ; they just aren't autimatically applied :
sage: var("a, b")
(a, b)
sage: bool(log(a*b)==log(a)+log(b))
False
sage: bool((log(a*b)==log(a)+log(b)).log_expand())
True
HTH,Mon, 19 Apr 2021 09:23:29 +0200https://ask.sagemath.org/question/56724/why-dont-log-rules-work-for-symbolic-values/?answer=56726#post-id-56726Comment by cybervigilante for <p>Log rules <em>do</em> workfor symbolic values ; they just aren't autimatically applied :</p>
<pre><code>sage: var("a, b")
(a, b)
sage: bool(log(a*b)==log(a)+log(b))
False
sage: bool((log(a*b)==log(a)+log(b)).log_expand())
True
</code></pre>
<p>HTH,</p>
https://ask.sagemath.org/question/56724/why-dont-log-rules-work-for-symbolic-values/?comment=56738#post-id-56738Thanks. Although I was surprised that the log_expand method distributed over the equivalence statement. But this appears to be generally true, which is useful, so thanks again:
In: x = 5*(log(a*b)==log(a)+log(b)); x
Out: 5*log(a*b) == 5*log(a) + 5*log(b)Tue, 20 Apr 2021 02:12:55 +0200https://ask.sagemath.org/question/56724/why-dont-log-rules-work-for-symbolic-values/?comment=56738#post-id-56738