1 | initial version |
x=var('x')
is the variable x defined in the symbolic ring. You want to avoid that. The following creates the variable x
that lives in the Univariate Polynomial Ring in x over Algebraic Field.
sage: QQbar
Algebraic Field
sage: R.<x> = QQbar[]
sage: R
Univariate Polynomial Ring in x over Algebraic Field
sage: p = 1-2*x-7*x^2-4*x^3
sage: p.roots()
[(-1, 2), (1/4, 1)]
sage: p.roots(multiplicities=False)
[-1, 1/4]
You may replace QQbar by QQ or AA. In any case, you may specify the domain when you search for the roots by p.roots(QQbar)
or p.roots(CC)
or p.roots(RealField(50))
or etc.
2 | No.2 Revision |
x=var('x')
is the variable x defined in the symbolic ring. You want to avoid that. that ring. The following creates the variable x
that lives in the Univariate Polynomial Ring in x over Algebraic Rational Field.
sage: QQbar
Algebraic QQ
Rational Field
sage: R.<x> = QQbar[]
QQ[]
sage: R
Univariate Polynomial Ring in x over Algebraic Rational Field
sage: p = 1-2*x-7*x^2-4*x^3
sage: p.roots()
[(-1, 2), (1/4, 1)]
sage: p.roots(multiplicities=False)
[-1, 1/4]
You may replace QQbar by QQ or AA. In any case, When there are complex roots, you may specify extend the domain when you search for the ring where to find roots by doing:p.roots(QQbar)
or p.roots(CC)
or p.roots(RealField(50))
or etc.
sage: p.roots(QQbar)
[(-1, 2), (1/4, 1)]
where QQbar is:
sage: QQbar
Algebraic Field
3 | No.3 Revision |
x=var('x')
is the variable x defined in the symbolic ring. You want to avoid that ring. The following creates the variable x
that lives in the Univariate Polynomial Ring in x over Rational Field.
sage: QQ
Rational Field
sage: R.<x> = QQ[]
sage: R
Univariate Polynomial Ring in x over Rational Field
sage: p = 1-2*x-7*x^2-4*x^3
sage: p.roots()
[(-1, 2), (1/4, 1)]
sage: p.roots(multiplicities=False)
[-1, 1/4]
When there are complex roots, you may extend the ring where to find roots by doing:
sage: p.roots(QQbar)
[(-1, 2), (1/4, 1)]
where QQbar is:is the algebraic closure of the rational field QQ:
sage: QQbar
Algebraic Field