Ask Your Question
1

complete expansion of polynomial substitution

asked 2015-02-14 20:16:35 +0100

kartheek gravatar image

updated 2015-02-16 14:38:52 +0100

vdelecroix gravatar image

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.

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
3

answered 2015-02-16 09:52:28 +0100

rws gravatar image

Just 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)
edit flag offensive delete link more
2

answered 2015-02-14 20:31:22 +0100

FrédéricC gravatar image

If 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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-02-14 20:16:35 +0100

Seen: 2,763 times

Last updated: Feb 16 '15