1 | initial version |
It is not clear how you constructed the data but it is clearly wrong. It is not a polynomial but a symbolic expression. Notice the difference in construction between
sage: x = SR.var('x')
sage: p_symb = x^2 + x - 2
sage: x = polygen(QQ)
sage: p_pol = x^2 + x - 2
Or similarly
sage: p_symb2 = SR('x^2 + x - 2')
sage: p_pol2 = QQ['x']('x^2 + x - 2')
You can check that these are indeed different
sage: parent(p_symb)
Symbolic Ring
sage: parent(p_symb2)
Symbolic Ring
sage: parent(p_pol)
Univariate Polynomial Ring in x over Rational Field
sage: parent(p_pol2)
Univariate Polynomial Ring in x over Rational Field
Then, as you already experienced, the symbolic version has no is_irreducible method
sage: p_symb.is_irreducible()
Traceback (most recent call last):
...
AttributeError: 'sage.symbolic.expression.Expression' object has no attribute 'is_irreducible'
whereas
sage: p_pol.is_irreducible()
False
sage: p_pol.factor()
(x - 1) * (x + 2)
2 | No.2 Revision |
It is not clear how you constructed the data but it is clearly wrong. It is not a polynomial but a symbolic expression. Notice the difference in construction between
sage: x = SR.var('x')
sage: p_symb = x^2 + x - 2
sage: x = polygen(QQ)
sage: p_pol = x^2 + x - 2
Or similarly
sage: p_symb2 = SR('x^2 + x - 2')
sage: p_pol2 = QQ['x']('x^2 + x - 2')
You can check that these are indeed different
sage: parent(p_symb)
Symbolic Ring
sage: parent(p_symb2)
Symbolic Ring
sage: parent(p_pol)
Univariate Polynomial Ring in x over Rational Field
sage: parent(p_pol2)
Univariate Polynomial Ring in x over Rational Field
Then, as you already experienced, the symbolic version has no is_irreducible method
sage: p_symb.is_irreducible()
Traceback (most recent call last):
...
AttributeError: 'sage.symbolic.expression.Expression' object has no attribute 'is_irreducible'
whereas
sage: p_pol.is_irreducible()
False
sage: p_pol.factor()
(x - 1) * (x + 2)
Considering your input given as a list of lists of strings, you should do something like
sage: data = [ ['x^2 + x + 1', 'x^2 - 1'], ['x - 1', 'x', 'x^3 - 1']]
sage: R = QQ['x']
sage: p = R(data[0][0])
sage: p
x^2 + x + 1
sage: p.is_irreducible()
True
3 | No.3 Revision |
It is not clear how you constructed the data but and you might have done it is clearly wrong. It is the wrong way. Your data does not seem to be a polynomial but a symbolic expression. Notice the difference in construction between
sage: x = SR.var('x')
sage: p_symb = x^2 + x - 2
sage: x = polygen(QQ)
sage: p_pol = x^2 + x - 2
Or similarly
sage: p_symb2 = SR('x^2 + x - 2')
sage: p_pol2 = QQ['x']('x^2 + x - 2')
You can check that these are indeed different
sage: parent(p_symb)
Symbolic Ring
sage: parent(p_symb2)
Symbolic Ring
sage: parent(p_pol)
Univariate Polynomial Ring in x over Rational Field
sage: parent(p_pol2)
Univariate Polynomial Ring in x over Rational Field
Then, as you already experienced, the symbolic version has no is_irreducible method
sage: p_symb.is_irreducible()
Traceback (most recent call last):
...
AttributeError: 'sage.symbolic.expression.Expression' object has no attribute 'is_irreducible'
whereas
sage: p_pol.is_irreducible()
False
sage: p_pol.factor()
(x - 1) * (x + 2)
Considering your input given as a list of lists of strings, you should do something like
sage: data = [ ['x^2 + x + 1', 'x^2 - 1'], ['x - 1', 'x', 'x^3 - 1']]
sage: R = QQ['x']
sage: p = R(data[0][0])
sage: p
x^2 + x + 1
sage: p.is_irreducible()
True