full_simplify produces unexpected result
I applied full_simplify to an expression obtained by substituting a quotient of two polynomials in a polynomial expression, as illustrated below.
The highest degree in the result was expected to be 8, but I get an output where the highest degree is 20.
Can anyone help me find what is the mistake i have done?
Code:
var('s,z')
g1 = 12108.8236080100*s^4 + 3016.35528790190*s^3 + 10600.0709715245*s^2 + 1937.60970085071*s + 409.016662847740/s + 472.343751699259/s^2 + 28.3730874809756/s^3 + 24.0436698653890/s^4 + 3397.06167138687
g2 = g1.subs(s=(z-1)/(z+1))
g2.full_simplify()
Output:
(31993.69841156735*z^20 - 158174.2276629893*z^19 + 216392.4500464178*z^18 + 280148.4057432631*z^17 - 1211263.434674058*z^16 + 1037191.771384268*z^15 + 1264180.797481716*z^14 - 3364714.4688927*z^13 + 1723475.12974153*z^12 + 2648901.578200325*z^11 - 4385755.889381289*z^10 + 1244061.427447394*z^9 + 2634639.643830222*z^8 - 2874359.710320266*z^7 + 417712.5402619956*z^6 + 1209501.453649961*z^5 - 917808.742510938*z^4 + 93647.83955663575*z^3 + 205222.817859467*z^2 - 116204.0691059264*z + 21210.98893340469)/(z^20 - 10.0*z^18 + 45.0*z^16 - 120.0*z^14 + 210.0*z^12 - 252.0*z^10 + 210.0*z^8 - 120.0*z^6 + 45.0*z^4 - 10.0*z^2 + 1.0)
Note that if you ask for
g2
you will see that the problem does not come from the substitution step. The problem comes from the simplification step withfull_simplify
.