# Type of variable is changed after using factor() function

I defined a polynomial using polynomial ring. In my program, I need to simplify expressions using factor(). But the type of variable is changed and it becomes "None". For example,

Ra=PolynomialRing(QQ,'a',6)
Fa=Ra.fraction_field()
a=Ra.gens()
r1=(a[1]^2+a[2])/(a[3]+2*a[4])
r1.subs( { a[1]:2, a[4]:2*a[2]+a[3] } )
r2=r1.factor()
print(type(r1)), print(type(r2))
print(simplify(r2))


How to use factor() inside the ring Ra=PolynomialRing(QQ,'a',6)? Thank you very much.

edit retag close merge delete

Sort by ยป oldest newest most voted

factor() is defined for polynomials.

None results from using simplify() function on fraction of polynomials. It is a function, which works with symbolic expressions not polynomials or their fractions. Besides, there is nothing to "simplify" in polynomials or their fractions (the latter is always stored in reduced form).

Said that,, you can enforce using simplify() by first converting its argument to symbolic expression, although it seems pointless:

print(simplify(SR(r2)))

more

Should factor throw an error when the input is not in SR?

( 2024-04-03 03:46:59 +0200 )edit

No, factor works fine for polynomials as well. Issue is not in factor but in simplify.

( 2024-04-03 04:31:56 +0200 )edit