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.Mon, 16 Feb 2015 02:52:28 -0600complete expansion of polynomial substitutionhttp://ask.sagemath.org/question/25827/complete-expansion-of-polynomial-substitution/ In the following code, I have substituted a polynomial in other polynomial and the result even after using the command
".expand" shows no complete expansion,Is there any other way to get complete expansion of polynomial substitution?
g1=1+ (s^2) ;
g2=g1.subs(s= 1/(z-1) ) ;
g2.expand()
Result:
1+ 1/((z-1)^2) is shown, but not expansion (z^2-z+2)/z^2-z+1.
Sat, 14 Feb 2015 13:16:35 -0600http://ask.sagemath.org/question/25827/complete-expansion-of-polynomial-substitution/Answer by FrédéricC for <p>In the following code, I have substituted a polynomial in other polynomial and the result even after using the command
".expand" shows no complete expansion,Is there any other way to get complete expansion of polynomial substitution?</p>
<pre><code>g1=1+ (s^2) ;
g2=g1.subs(s= 1/(z-1) ) ;
g2.expand()
</code></pre>
<p>Result:
1+ 1/((z-1)^2) is shown, but not expansion (z^2-z+2)/z^2-z+1.</p>
http://ask.sagemath.org/question/25827/complete-expansion-of-polynomial-substitution/?answer=25828#post-id-25828If you want to compute with polynomials, you should rather use polynomial variables:
sage: s = polygen(QQ,'s')
sage: z = polygen(QQ,'z')
sage: g1=1+s^2 ; g2=g1(s=1/(z-1) ) ; g2
(z^2 - 2*z + 2)/(z^2 - 2*z + 1)
This means using `polygen` instead of `var`. You also have to choose a coefficient field.Sat, 14 Feb 2015 13:31:22 -0600http://ask.sagemath.org/question/25827/complete-expansion-of-polynomial-substitution/?answer=25828#post-id-25828Answer by rws for <p>In the following code, I have substituted a polynomial in other polynomial and the result even after using the command
".expand" shows no complete expansion,Is there any other way to get complete expansion of polynomial substitution?</p>
<pre><code>g1=1+ (s^2) ;
g2=g1.subs(s= 1/(z-1) ) ;
g2.expand()
</code></pre>
<p>Result:
1+ 1/((z-1)^2) is shown, but not expansion (z^2-z+2)/z^2-z+1.</p>
http://ask.sagemath.org/question/25827/complete-expansion-of-polynomial-substitution/?answer=25841#post-id-25841Just a command to convert to polynomial fraction is needed additionally:
sage: g1=1+ (s^2) ; g2=g1.subs(s= 1/(z-1) ) ; g2.expand().fraction(QQ)
(z^2 - 2*z + 2)/(z^2 - 2*z + 1)
Mon, 16 Feb 2015 02:52:28 -0600http://ask.sagemath.org/question/25827/complete-expansion-of-polynomial-substitution/?answer=25841#post-id-25841