# Revision history [back]

I think you have found a bug.

Here is a simpler example showing the bug.

sage: s, z = var('s z')
sage: f = s^2 + s + 1/s + 1/s^2 + 1.
sage: g = f.subs(s=(z-1)/(z+1))
sage: g.full_simplify()
(5.0*z^6 + 5.0*z^4 - 9.0*z^2 - 1.0)/(z^6 - 3.0*z^4 + 3.0*z^2 - 1.0)

By contrast:

sage: s, z = var('s z')
sage: f = s^2 + s + 1/s + 1/s^2 + 1
sage: g = f.subs(s=(z-1)/(z+1))
sage: g = f.subs(s=(z-1)/(z+1))
sage: g.full_simplify()
(5*z^4 + 10*z^2 + 1)/(z^4 - 2*z^2 + 1)

So in the buggy case, simplify_full introduced an extra factor (z^2-1) in the numerator and denominator.

I think you have found a bug.

Here is a simpler example showing the bug.problem (which comes from using floating-point entries).

sage: s, z = var('s z')
sage: f = s^2 + s + 1/s + 1/s^2 + 1.
sage: g = f.subs(s=(z-1)/(z+1))
sage: g.full_simplify()
(5.0*z^6 + 5.0*z^4 - 9.0*z^2 - 1.0)/(z^6 - 3.0*z^4 + 3.0*z^2 - 1.0)

By contrast:contrast, with integer entries:

sage: s, z = var('s z')
sage: f = s^2 + s + 1/s + 1/s^2 + 1
sage: g = f.subs(s=(z-1)/(z+1))
sage: g = f.subs(s=(z-1)/(z+1))
sage: g.full_simplify()
(5*z^4 + 10*z^2 + 1)/(z^4 - 2*z^2 + 1)

So in the buggy case, applying simplify_full introduced in the first seems to introduce an extra factor (z^2-1) in the numerator and denominator.

Exercise: find out what simplify_full does, follow each step and figure out where things go wrong.