def test_roots_binomial(): assert roots_binomial(Poly(5*x, x)) == [0] assert roots_binomial(Poly(5*x**4, x)) == [0, 0, 0, 0] assert roots_binomial(Poly(5*x+2, x)) == [-Rational(2, 5)] A = 10**Rational(3, 4)/10 assert roots_binomial(Poly(5*x**4+2, x)) == \ [A+I*A, -A+I*A, -A-I*A, A-I*A] a1 = Symbol('a1', nonnegative=True) b1 = Symbol('b1', nonnegative=True) r0 = roots_quadratic(Poly(a1*x**2 + b1, x)) r1 = roots_binomial(Poly(a1*x**2 + b1, x)) assert separate(r0[0]) == separate(r1[0]) assert separate(r0[1]) == separate(r1[1])
def test_separate(): x, y, z = map(Symbol, 'xyz') assert separate((x*y*z)**4) == x**4*y**4*z**4 assert separate((x*y*z)**x) == x**x*y**x*z**x assert separate((x*(y*z)**2)**3) == x**3*y**6*z**6 assert separate((sin((x*y)**2)*y)**z) == sin((x*y)**2)**z*y**z assert separate((sin((x*y)**2)*y)**z, deep=True) == sin(x**2*y**2)**z*y**z assert separate(exp(x)**2) == exp(2*x) assert separate((exp(x)*exp(y))**2) == exp(2*x)*exp(2*y) assert separate((exp((x*y)**z)*exp(y))**2) == exp(2*(x*y)**z)*exp(2*y) assert separate((exp((x*y)**z)*exp(y))**2, deep=True) == exp(2*x**z*y**z)*exp(2*y)
def test_separate(): x, y, z = symbols('xyz') assert separate((x*y*z)**4) == x**4*y**4*z**4 assert separate((x*y*z)**x) == x**x*y**x*z**x assert separate((x*(y*z)**2)**3) == x**3*y**6*z**6 assert separate((sin((x*y)**2)*y)**z) == sin((x*y)**2)**z*y**z assert separate((sin((x*y)**2)*y)**z, deep=True) == sin(x**2*y**2)**z*y**z assert separate(exp(x)**2) == exp(2*x) assert separate((exp(x)*exp(y))**2) == exp(2*x)*exp(2*y) assert separate((exp((x*y)**z)*exp(y))**2) == exp(2*(x*y)**z)*exp(2*y) assert separate((exp((x*y)**z)*exp(y))**2, deep=True) == exp(2*x**z*y**z)*exp(2*y)
def test_action_verbs(): assert nsimplify((1/(exp(3*pi*x/5)+1))) == (1/(exp(3*pi*x/5)+1)).nsimplify() assert ratsimp(1/x + 1/y) == (1/x + 1/y).ratsimp() assert trigsimp(log(x), deep=True) == (log(x)).trigsimp(deep = True) assert radsimp(1/(2+sqrt(2))) == (1/(2+sqrt(2))).radsimp() assert powsimp(x**y*x**z*y**z, combine='all') == (x**y*x**z*y**z).powsimp(combine='all') assert simplify(x**y*x**z*y**z) == (x**y*x**z*y**z).simplify() assert together(1/x + 1/y) == (1/x + 1/y).together() assert separate((x*(y*z)**3)**2) == ((x*(y*z)**3)**2).separate() assert collect(a*x**2 + b*x**2 + a*x - b*x + c, x) == (a*x**2 + b*x**2 + a*x - b*x + c).collect(x) assert apart(y/(y+2)/(y+1), y) == (y/(y+2)/(y+1)).apart(y) assert combsimp(y/(x+2)/(x+1)) == (y/(x+2)/(x+1)).combsimp() assert factor(x**2+5*x+6) == (x**2+5*x+6).factor() assert refine(sqrt(x**2)) == sqrt(x**2).refine() assert cancel((x**2+5*x+6)/(x+2)) == ((x**2+5*x+6)/(x+2)).cancel()
def test_separate(): x, y, z = symbols('x,y,z') assert separate((x*y*z)**4) == x**4*y**4*z**4 assert separate((x*y*z)**x).is_Pow assert separate((x*y*z)**x, force=True) == x**x*y**x*z**x assert separate((x*(y*z)**2)**3) == x**3*y**6*z**6 assert separate((sin((x*y)**2)*y)**z).is_Pow assert separate((sin((x*y)**2)*y)**z, force=True) == sin((x*y)**2)**z*y**z assert separate((sin((x*y)**2)*y)**z, deep=True) == (sin(x**2*y**2)*y)**z assert separate(exp(x)**2) == exp(2*x) assert separate((exp(x)*exp(y))**2) == exp(2*x)*exp(2*y) assert separate((exp((x*y)**z)*exp(y))**2) == exp(2*(x*y)**z)*exp(2*y) assert separate((exp((x*y)**z)*exp(y))**2, deep=True, force=True) == exp(2*x**z*y**z)*exp(2*y) assert separate((exp(x)*exp(y))**z).is_Pow assert separate((exp(x)*exp(y))**z, force=True) == exp(x)**z*exp(y)**z
def test_separate_X1(): x, y, z = map(Symbol, 'xyz') assert separate((exp(x)*exp(y))**z) == exp(x*z)*exp(y*z)
def test_separate_X1(): x, y, z = map(Symbol, 'xyz') assert separate((exp(x) * exp(y))**z) == exp(x * z) * exp(y * z)
def test_separate_X1(): assert separate((exp(x)*exp(y))**z) == exp(x*z)*exp(y*z)
def test_separate_X1(): assert separate((exp(x) * exp(y))**z) == exp(x * z) * exp(y * z)