ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 24 Jul 2018 18:08:11 -0500simplifying out negative signs in exponentshttp://ask.sagemath.org/question/43132/simplifying-out-negative-signs-in-exponents/Hello all!
I can't for the life of me find a way to force sage to return terms with only positive coefficient variable exponents. For example, if I enter something like
assume(n, 'integer', n>10)
c = 2^(-n)
I would like the output to be something like `1/(2^n)`, but instead I can only get something like `2^(-n)`. Is there a way to force the output to display only positive coefficients in front of the n?
In general I'd like some `magicFunc` function which I could feed some expression `g(x,n)` and have it return a rational expression with no negatives; eg.
var('x,n')
assume(x,'real')
assume(n,'integer',n>10)
g(x,n) = 2^(-n)*x^(-3*n)*3^n
magicFunc(g(x,n))
Would return `3^n/(2^n*x^(3n))`
Is this possible? This seems like it should be an existent simplification method, but nothing I've tried seems to work.
Thanks!Tue, 24 Jul 2018 16:19:26 -0500http://ask.sagemath.org/question/43132/simplifying-out-negative-signs-in-exponents/Comment by slelievre for <p>Hello all!</p>
<p>I can't for the life of me find a way to force sage to return terms with only positive coefficient variable exponents. For example, if I enter something like</p>
<pre><code>assume(n, 'integer', n>10)
c = 2^(-n)
</code></pre>
<p>I would like the output to be something like <code>1/(2^n)</code>, but instead I can only get something like <code>2^(-n)</code>. Is there a way to force the output to display only positive coefficients in front of the n?</p>
<p>In general I'd like some <code>magicFunc</code> function which I could feed some expression <code>g(x,n)</code> and have it return a rational expression with no negatives; eg.</p>
<pre><code>var('x,n')
assume(x,'real')
assume(n,'integer',n>10)
g(x,n) = 2^(-n)*x^(-3*n)*3^n
magicFunc(g(x,n))
</code></pre>
<p>Would return <code>3^n/(2^n*x^(3n))</code></p>
<p>Is this possible? This seems like it should be an existent simplification method, but nothing I've tried seems to work.</p>
<p>Thanks!</p>
http://ask.sagemath.org/question/43132/simplifying-out-negative-signs-in-exponents/?comment=43134#post-id-43134What version of Sage are you using? Type `version()` at the Sage prompt.Tue, 24 Jul 2018 18:08:11 -0500http://ask.sagemath.org/question/43132/simplifying-out-negative-signs-in-exponents/?comment=43134#post-id-43134Answer by tmonteil for <p>Hello all!</p>
<p>I can't for the life of me find a way to force sage to return terms with only positive coefficient variable exponents. For example, if I enter something like</p>
<pre><code>assume(n, 'integer', n>10)
c = 2^(-n)
</code></pre>
<p>I would like the output to be something like <code>1/(2^n)</code>, but instead I can only get something like <code>2^(-n)</code>. Is there a way to force the output to display only positive coefficients in front of the n?</p>
<p>In general I'd like some <code>magicFunc</code> function which I could feed some expression <code>g(x,n)</code> and have it return a rational expression with no negatives; eg.</p>
<pre><code>var('x,n')
assume(x,'real')
assume(n,'integer',n>10)
g(x,n) = 2^(-n)*x^(-3*n)*3^n
magicFunc(g(x,n))
</code></pre>
<p>Would return <code>3^n/(2^n*x^(3n))</code></p>
<p>Is this possible? This seems like it should be an existent simplification method, but nothing I've tried seems to work.</p>
<p>Thanks!</p>
http://ask.sagemath.org/question/43132/simplifying-out-negative-signs-in-exponents/?answer=43133#post-id-43133Isn't this the case already ? On my laptop (SageMath version 8.3.rc2), i have:
sage: var('x,n')
....: assume(x,'real')
....: assume(n,'integer',n>10)
....: g(x,n) = 2^(-n)*x^(-3*n)*3^n
(x, n)
sage: g
(x, n) |--> 3^n/(2^n*x^(3*n))
sage: c = 2^(-n)
sage: c
1/(2^n)
Tue, 24 Jul 2018 17:34:57 -0500http://ask.sagemath.org/question/43132/simplifying-out-negative-signs-in-exponents/?answer=43133#post-id-43133