Ask Your Question
0

Type of variable is changed after using factor() function

asked 1 year ago

lijr07 gravatar image

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.

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
1

answered 1 year ago

Max Alekseyev gravatar image

updated 1 year ago

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)))
Preview: (hide)
link

Comments

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

grhkm gravatar imagegrhkm ( 1 year ago )

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

Max Alekseyev gravatar imageMax Alekseyev ( 1 year ago )

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: 1 year ago

Seen: 198 times

Last updated: Mar 27 '24