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.Thu, 10 Jun 2021 21:04:14 +0200Rewrite log in exponentshttps://ask.sagemath.org/question/57498/rewrite-log-in-exponents/Does there exist a method in Sage's symbolic ring that would be able to (automatically) rewrite expressions such as
$3^{\log n}$ into $n^{\log 3}$?
Here I assume that $n$ is a positive integer.
Remark: I am quite surprised (and therefore pessimistic for my question) by the following:
sage: [bool(3^(log(i)) == i^(log(3))) for i in range(1, 12)]
[True, True, True, True, False, False, True, False, True, False, False]Wed, 09 Jun 2021 13:52:42 +0200https://ask.sagemath.org/question/57498/rewrite-log-in-exponents/Comment by tolga for <p>Does there exist a method in Sage's symbolic ring that would be able to (automatically) rewrite expressions such as
$3^{\log n}$ into $n^{\log 3}$?</p>
<p>Here I assume that $n$ is a positive integer.</p>
<p>Remark: I am quite surprised (and therefore pessimistic for my question) by the following:</p>
<pre><code>sage: [bool(3^(log(i)) == i^(log(3))) for i in range(1, 12)]
[True, True, True, True, False, False, True, False, True, False, False]
</code></pre>
https://ask.sagemath.org/question/57498/rewrite-log-in-exponents/?comment=57508#post-id-57508I do not know if this would be helpful for your question but .canonicalize_radical() solves the problem in your example:
var('k')
[bool((3^(log(k)) - k^(log(3))).canonicalize_radical()==0) for k in range(1, 12)]
I used the variable k instead of i which is sqrt(-1).Wed, 09 Jun 2021 19:08:50 +0200https://ask.sagemath.org/question/57498/rewrite-log-in-exponents/?comment=57508#post-id-57508Answer by Emmanuel Charpentier for <p>Does there exist a method in Sage's symbolic ring that would be able to (automatically) rewrite expressions such as
$3^{\log n}$ into $n^{\log 3}$?</p>
<p>Here I assume that $n$ is a positive integer.</p>
<p>Remark: I am quite surprised (and therefore pessimistic for my question) by the following:</p>
<pre><code>sage: [bool(3^(log(i)) == i^(log(3))) for i in range(1, 12)]
[True, True, True, True, False, False, True, False, True, False, False]
</code></pre>
https://ask.sagemath.org/question/57498/rewrite-log-in-exponents/?answer=57536#post-id-57536What you want to do may or may no be legitimate. Read the introduction to [this section](https://docs.sympy.org/latest/tutorial/simplification.html#powers) of the Sympy documentation...Thu, 10 Jun 2021 21:04:14 +0200https://ask.sagemath.org/question/57498/rewrite-log-in-exponents/?answer=57536#post-id-57536