Polynomials

Roots and factor over the integers.

A Poly has degree, roots, and factor over the integers.

Goal

Factor x^2-5x+6 and print roots.

import sympy as sp
x = sp.symbols('x')
p = sp.Poly(x ** 2 - 5 * x + 6)
print(p.degree())
print(p.factor())
import sympy as sp
x = sp.symbols('x')
print(sp.roots(x ** 2 - 5 * x + 6))
import sympy as sp
x = sp.symbols('x')
print(sp.discriminant(x ** 2 - 5 * x + 6))
import sympy as sp
x = sp.symbols('x')
print(sp.gcd(x ** 2 - 1, x - 1))