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.Wed, 17 Nov 2021 23:09:03 +0100Order of variable for simplificationhttps://ask.sagemath.org/question/59776/order-of-variable-for-simplification/Let's say I have two variables x, q. When I use simplify_full(), how do I make sure the final expression is ordered as monomial of X instead of q? For example, let f=q^2+x+1, g=qx+1. Somehow if I use simplify_full() to simplify fg, then the monomial is of the following form (expression in terms of x)q^3+(expression in terms of x)q^2...
But actually I regard x as the variable, q as power of prime number. So I wish to order the expression like: (expression in terms of q)X^2+(expression in terms of q)X+(expression in terms of q)
Thanks!Wed, 17 Nov 2021 00:36:34 +0100https://ask.sagemath.org/question/59776/order-of-variable-for-simplification/Comment by slelievre for <p>Let's say I have two variables x, q. When I use simplify_full(), how do I make sure the final expression is ordered as monomial of X instead of q? For example, let f=q^2+x+1, g=qx+1. Somehow if I use simplify_full() to simplify fg, then the monomial is of the following form (expression in terms of x)q^3+(expression in terms of x)q^2...</p>
<p>But actually I regard x as the variable, q as power of prime number. So I wish to order the expression like: (expression in terms of q)X^2+(expression in terms of q)X+(expression in terms of q)</p>
<p>Thanks!</p>
https://ask.sagemath.org/question/59776/order-of-variable-for-simplification/?comment=59799#post-id-59799Great. You might even include the code you have so far.Wed, 17 Nov 2021 17:25:56 +0100https://ask.sagemath.org/question/59776/order-of-variable-for-simplification/?comment=59799#post-id-59799Comment by Studentaaaaaaaa for <p>Let's say I have two variables x, q. When I use simplify_full(), how do I make sure the final expression is ordered as monomial of X instead of q? For example, let f=q^2+x+1, g=qx+1. Somehow if I use simplify_full() to simplify fg, then the monomial is of the following form (expression in terms of x)q^3+(expression in terms of x)q^2...</p>
<p>But actually I regard x as the variable, q as power of prime number. So I wish to order the expression like: (expression in terms of q)X^2+(expression in terms of q)X+(expression in terms of q)</p>
<p>Thanks!</p>
https://ask.sagemath.org/question/59776/order-of-variable-for-simplification/?comment=59797#post-id-59797@slelievre Thanks! I just edited the question.Wed, 17 Nov 2021 17:19:15 +0100https://ask.sagemath.org/question/59776/order-of-variable-for-simplification/?comment=59797#post-id-59797Comment by slelievre for <p>Let's say I have two variables x, q. When I use simplify_full(), how do I make sure the final expression is ordered as monomial of X instead of q? For example, let f=q^2+x+1, g=qx+1. Somehow if I use simplify_full() to simplify fg, then the monomial is of the following form (expression in terms of x)q^3+(expression in terms of x)q^2...</p>
<p>But actually I regard x as the variable, q as power of prime number. So I wish to order the expression like: (expression in terms of q)X^2+(expression in terms of q)X+(expression in terms of q)</p>
<p>Thanks!</p>
https://ask.sagemath.org/question/59776/order-of-variable-for-simplification/?comment=59791#post-id-59791Ideally, add the simplest example illustrating your question.Wed, 17 Nov 2021 11:47:17 +0100https://ask.sagemath.org/question/59776/order-of-variable-for-simplification/?comment=59791#post-id-59791Comment by slelievre for <p>Let's say I have two variables x, q. When I use simplify_full(), how do I make sure the final expression is ordered as monomial of X instead of q? For example, let f=q^2+x+1, g=qx+1. Somehow if I use simplify_full() to simplify fg, then the monomial is of the following form (expression in terms of x)q^3+(expression in terms of x)q^2...</p>
<p>But actually I regard x as the variable, q as power of prime number. So I wish to order the expression like: (expression in terms of q)X^2+(expression in terms of q)X+(expression in terms of q)</p>
<p>Thanks!</p>
https://ask.sagemath.org/question/59776/order-of-variable-for-simplification/?comment=59790#post-id-59790Welcome to Ask Sage! Thank you for your question.Wed, 17 Nov 2021 11:47:03 +0100https://ask.sagemath.org/question/59776/order-of-variable-for-simplification/?comment=59790#post-id-59790Answer by eric_g for <p>Let's say I have two variables x, q. When I use simplify_full(), how do I make sure the final expression is ordered as monomial of X instead of q? For example, let f=q^2+x+1, g=qx+1. Somehow if I use simplify_full() to simplify fg, then the monomial is of the following form (expression in terms of x)q^3+(expression in terms of x)q^2...</p>
<p>But actually I regard x as the variable, q as power of prime number. So I wish to order the expression like: (expression in terms of q)X^2+(expression in terms of q)X+(expression in terms of q)</p>
<p>Thanks!</p>
https://ask.sagemath.org/question/59776/order-of-variable-for-simplification/?answer=59809#post-id-59809I guess you should use
(f*g).expand().collect(x)
See `x.collect?` for more information. Wed, 17 Nov 2021 23:09:03 +0100https://ask.sagemath.org/question/59776/order-of-variable-for-simplification/?answer=59809#post-id-59809