"""Tests for algorithms for computing symbolic roots of polynomials. """

from sympy import (S, symbols, Symbol, Wild, Integer, Rational, sqrt,
    powsimp, Lambda, sin, cos, pi, I, Interval, re, im, exp, ZZ)

from sympy.polys import (Poly, cyclotomic_poly, intervals, nroots,
    PolynomialError)

from sympy.polys.polyroots import (root_factors, roots_linear,
    roots_quadratic, roots_cubic, roots_quartic, roots_cyclotomic,
    roots_binomial, preprocess_roots, roots)

from sympy.utilities.pytest import raises
from sympy.utilities.randtest import test_numerically


a, b, c, d, e, q, t, x, y, z = symbols('a,b,c,d,e,q,t,x,y,z')


def test_roots_linear():
    assert roots_linear(Poly(2*x + 1, x)) == [-Rational(1, 2)]


def test_roots_quadratic():
    assert roots_quadratic(Poly(2*x**2, x)) == [0, 0]
    assert roots_quadratic(Poly(2*x**2 + 3*x, x)) == [-Rational(3, 2), 0]
    assert roots_quadratic(Poly(2*x**2 + 3, x)) == [-I*sqrt(6)/2, I*sqrt(6)/2]
    assert roots_quadratic(Poly(2*x**2 + 4*x + 3, x)) == [-1 - I*sqrt(2)/2, -1 + I*sqrt(2)/2]

    f = x**2 + (2*a*e + 2*c*e)/(a - c)*x + (d - b + a*e**2 - c*e**2)/(a - c)