hash
stringlengths 64
64
| content
stringlengths 0
1.51M
|
---|---|
590f88bf7af5985bd3716a0b725053ea9ed11c3428e727486b55cd1edfec8fcf | from sympy import Rational, sqrt, symbols, sin, exp, log, sinh, cosh, cos, pi, \
I, erf, tan, asin, asinh, acos, atan, Function, Derivative, diff, simplify, \
LambertW, Ne, Piecewise, Symbol, Add, ratsimp, Integral, Sum, \
besselj, besselk, bessely, jn, tanh
from sympy.integrals.heurisch import components, heurisch, heurisch_wrapper
from sympy.testing.pytest import XFAIL, skip, slow, ON_TRAVIS
from sympy.integrals.integrals import integrate
x, y, z, nu = symbols('x,y,z,nu')
f = Function('f')
def test_components():
assert components(x*y, x) == {x}
assert components(1/(x + y), x) == {x}
assert components(sin(x), x) == {sin(x), x}
assert components(sin(x)*sqrt(log(x)), x) == \
{log(x), sin(x), sqrt(log(x)), x}
assert components(x*sin(exp(x)*y), x) == \
{sin(y*exp(x)), x, exp(x)}
assert components(x**Rational(17, 54)/sqrt(sin(x)), x) == \
{sin(x), x**Rational(1, 54), sqrt(sin(x)), x}
assert components(f(x), x) == \
{x, f(x)}
assert components(Derivative(f(x), x), x) == \
{x, f(x), Derivative(f(x), x)}
assert components(f(x)*diff(f(x), x), x) == \
{x, f(x), Derivative(f(x), x), Derivative(f(x), x)}
def test_issue_10680():
assert isinstance(integrate(x**log(x**log(x**log(x))),x), Integral)
def test_heurisch_polynomials():
assert heurisch(1, x) == x
assert heurisch(x, x) == x**2/2
assert heurisch(x**17, x) == x**18/18
# For coverage
assert heurisch_wrapper(y, x) == y*x
def test_heurisch_fractions():
assert heurisch(1/x, x) == log(x)
assert heurisch(1/(2 + x), x) == log(x + 2)
assert heurisch(1/(x + sin(y)), x) == log(x + sin(y))
# Up to a constant, where C = pi*I*Rational(5, 12), Mathematica gives identical
# result in the first case. The difference is because sympy changes
# signs of expressions without any care.
# XXX ^ ^ ^ is this still correct?
assert heurisch(5*x**5/(
2*x**6 - 5), x) in [5*log(2*x**6 - 5) / 12, 5*log(-2*x**6 + 5) / 12]
assert heurisch(5*x**5/(2*x**6 + 5), x) == 5*log(2*x**6 + 5) / 12
assert heurisch(1/x**2, x) == -1/x
assert heurisch(-1/x**5, x) == 1/(4*x**4)
def test_heurisch_log():
assert heurisch(log(x), x) == x*log(x) - x
assert heurisch(log(3*x), x) == -x + x*log(3) + x*log(x)
assert heurisch(log(x**2), x) in [x*log(x**2) - 2*x, 2*x*log(x) - 2*x]
def test_heurisch_exp():
assert heurisch(exp(x), x) == exp(x)
assert heurisch(exp(-x), x) == -exp(-x)
assert heurisch(exp(17*x), x) == exp(17*x) / 17
assert heurisch(x*exp(x), x) == x*exp(x) - exp(x)
assert heurisch(x*exp(x**2), x) == exp(x**2) / 2
assert heurisch(exp(-x**2), x) is None
assert heurisch(2**x, x) == 2**x/log(2)
assert heurisch(x*2**x, x) == x*2**x/log(2) - 2**x*log(2)**(-2)
assert heurisch(Integral(x**z*y, (y, 1, 2), (z, 2, 3)).function, x) == (x*x**z*y)/(z+1)
assert heurisch(Sum(x**z, (z, 1, 2)).function, z) == x**z/log(x)
def test_heurisch_trigonometric():
assert heurisch(sin(x), x) == -cos(x)
assert heurisch(pi*sin(x) + 1, x) == x - pi*cos(x)
assert heurisch(cos(x), x) == sin(x)
assert heurisch(tan(x), x) in [
log(1 + tan(x)**2)/2,
log(tan(x) + I) + I*x,
log(tan(x) - I) - I*x,
]
assert heurisch(sin(x)*sin(y), x) == -cos(x)*sin(y)
assert heurisch(sin(x)*sin(y), y) == -cos(y)*sin(x)
# gives sin(x) in answer when run via setup.py and cos(x) when run via py.test
assert heurisch(sin(x)*cos(x), x) in [sin(x)**2 / 2, -cos(x)**2 / 2]
assert heurisch(cos(x)/sin(x), x) == log(sin(x))
assert heurisch(x*sin(7*x), x) == sin(7*x) / 49 - x*cos(7*x) / 7
assert heurisch(1/pi/4 * x**2*cos(x), x) == 1/pi/4*(x**2*sin(x) -
2*sin(x) + 2*x*cos(x))
assert heurisch(acos(x/4) * asin(x/4), x) == 2*x - (sqrt(16 - x**2))*asin(x/4) \
+ (sqrt(16 - x**2))*acos(x/4) + x*asin(x/4)*acos(x/4)
assert heurisch(sin(x)/(cos(x)**2+1), x) == -atan(cos(x)) #fixes issue 13723
assert heurisch(1/(cos(x)+2), x) == 2*sqrt(3)*atan(sqrt(3)*tan(x/2)/3)/3
assert heurisch(2*sin(x)*cos(x)/(sin(x)**4 + 1), x) == atan(sqrt(2)*sin(x)
- 1) - atan(sqrt(2)*sin(x) + 1)
assert heurisch(1/cosh(x), x) == 2*atan(tanh(x/2))
def test_heurisch_hyperbolic():
assert heurisch(sinh(x), x) == cosh(x)
assert heurisch(cosh(x), x) == sinh(x)
assert heurisch(x*sinh(x), x) == x*cosh(x) - sinh(x)
assert heurisch(x*cosh(x), x) == x*sinh(x) - cosh(x)
assert heurisch(
x*asinh(x/2), x) == x**2*asinh(x/2)/2 + asinh(x/2) - x*sqrt(4 + x**2)/4
def test_heurisch_mixed():
assert heurisch(sin(x)*exp(x), x) == exp(x)*sin(x)/2 - exp(x)*cos(x)/2
def test_heurisch_radicals():
assert heurisch(1/sqrt(x), x) == 2*sqrt(x)
assert heurisch(1/sqrt(x)**3, x) == -2/sqrt(x)
assert heurisch(sqrt(x)**3, x) == 2*sqrt(x)**5/5
assert heurisch(sin(x)*sqrt(cos(x)), x) == -2*sqrt(cos(x))**3/3
y = Symbol('y')
assert heurisch(sin(y*sqrt(x)), x) == 2/y**2*sin(y*sqrt(x)) - \
2*sqrt(x)*cos(y*sqrt(x))/y
assert heurisch_wrapper(sin(y*sqrt(x)), x) == Piecewise(
(-2*sqrt(x)*cos(sqrt(x)*y)/y + 2*sin(sqrt(x)*y)/y**2, Ne(y, 0)),
(0, True))
y = Symbol('y', positive=True)
assert heurisch_wrapper(sin(y*sqrt(x)), x) == 2/y**2*sin(y*sqrt(x)) - \
2*sqrt(x)*cos(y*sqrt(x))/y
def test_heurisch_special():
assert heurisch(erf(x), x) == x*erf(x) + exp(-x**2)/sqrt(pi)
assert heurisch(exp(-x**2)*erf(x), x) == sqrt(pi)*erf(x)**2 / 4
def test_heurisch_symbolic_coeffs():
assert heurisch(1/(x + y), x) == log(x + y)
assert heurisch(1/(x + sqrt(2)), x) == log(x + sqrt(2))
assert simplify(diff(heurisch(log(x + y + z), y), y)) == log(x + y + z)
def test_heurisch_symbolic_coeffs_1130():
y = Symbol('y')
assert heurisch_wrapper(1/(x**2 + y), x) == Piecewise(
(-I*log(x - I*sqrt(y))/(2*sqrt(y))
+ I*log(x + I*sqrt(y))/(2*sqrt(y)), Ne(y, 0)),
(-1/x, True))
y = Symbol('y', positive=True)
assert heurisch_wrapper(1/(x**2 + y), x) == (atan(x/sqrt(y))/sqrt(y))
def test_heurisch_hacking():
assert heurisch(sqrt(1 + 7*x**2), x, hints=[]) == \
x*sqrt(1 + 7*x**2)/2 + sqrt(7)*asinh(sqrt(7)*x)/14
assert heurisch(sqrt(1 - 7*x**2), x, hints=[]) == \
x*sqrt(1 - 7*x**2)/2 + sqrt(7)*asin(sqrt(7)*x)/14
assert heurisch(1/sqrt(1 + 7*x**2), x, hints=[]) == \
sqrt(7)*asinh(sqrt(7)*x)/7
assert heurisch(1/sqrt(1 - 7*x**2), x, hints=[]) == \
sqrt(7)*asin(sqrt(7)*x)/7
assert heurisch(exp(-7*x**2), x, hints=[]) == \
sqrt(7*pi)*erf(sqrt(7)*x)/14
assert heurisch(1/sqrt(9 - 4*x**2), x, hints=[]) == \
asin(x*Rational(2, 3))/2
assert heurisch(1/sqrt(9 + 4*x**2), x, hints=[]) == \
asinh(x*Rational(2, 3))/2
def test_heurisch_function():
assert heurisch(f(x), x) is None
@XFAIL
def test_heurisch_function_derivative():
# TODO: it looks like this used to work just by coincindence and
# thanks to sloppy implementation. Investigate why this used to
# work at all and if support for this can be restored.
df = diff(f(x), x)
assert heurisch(f(x)*df, x) == f(x)**2/2
assert heurisch(f(x)**2*df, x) == f(x)**3/3
assert heurisch(df/f(x), x) == log(f(x))
def test_heurisch_wrapper():
f = 1/(y + x)
assert heurisch_wrapper(f, x) == log(x + y)
f = 1/(y - x)
assert heurisch_wrapper(f, x) == -log(x - y)
f = 1/((y - x)*(y + x))
assert heurisch_wrapper(f, x) == Piecewise(
(-log(x - y)/(2*y) + log(x + y)/(2*y), Ne(y, 0)), (1/x, True))
# issue 6926
f = sqrt(x**2/((y - x)*(y + x)))
assert heurisch_wrapper(f, x) == x*sqrt(x**2)*sqrt(1/(-x**2 + y**2)) \
- y**2*sqrt(x**2)*sqrt(1/(-x**2 + y**2))/x
def test_issue_3609():
assert heurisch(1/(x * (1 + log(x)**2)), x) == atan(log(x))
### These are examples from the Poor Man's Integrator
### http://www-sop.inria.fr/cafe/Manuel.Bronstein/pmint/examples/
def test_pmint_rat():
# TODO: heurisch() is off by a constant: -3/4. Possibly different permutation
# would give the optimal result?
def drop_const(expr, x):
if expr.is_Add:
return Add(*[ arg for arg in expr.args if arg.has(x) ])
else:
return expr
f = (x**7 - 24*x**4 - 4*x**2 + 8*x - 8)/(x**8 + 6*x**6 + 12*x**4 + 8*x**2)
g = (4 + 8*x**2 + 6*x + 3*x**3)/(x**5 + 4*x**3 + 4*x) + log(x)
assert drop_const(ratsimp(heurisch(f, x)), x) == g
def test_pmint_trig():
f = (x - tan(x)) / tan(x)**2 + tan(x)
g = -x**2/2 - x/tan(x) + log(tan(x)**2 + 1)/2
assert heurisch(f, x) == g
@slow # 8 seconds on 3.4 GHz
def test_pmint_logexp():
if ON_TRAVIS:
# See https://github.com/sympy/sympy/pull/12795
skip("Too slow for travis.")
f = (1 + x + x*exp(x))*(x + log(x) + exp(x) - 1)/(x + log(x) + exp(x))**2/x
g = log(x + exp(x) + log(x)) + 1/(x + exp(x) + log(x))
assert ratsimp(heurisch(f, x)) == g
def test_pmint_erf():
f = exp(-x**2)*erf(x)/(erf(x)**3 - erf(x)**2 - erf(x) + 1)
g = sqrt(pi)*log(erf(x) - 1)/8 - sqrt(pi)*log(erf(x) + 1)/8 - sqrt(pi)/(4*erf(x) - 4)
assert ratsimp(heurisch(f, x)) == g
def test_pmint_LambertW():
f = LambertW(x)
g = x*LambertW(x) - x + x/LambertW(x)
assert heurisch(f, x) == g
def test_pmint_besselj():
f = besselj(nu + 1, x)/besselj(nu, x)
g = nu*log(x) - log(besselj(nu, x))
assert heurisch(f, x) == g
f = (nu*besselj(nu, x) - x*besselj(nu + 1, x))/x
g = besselj(nu, x)
assert heurisch(f, x) == g
f = jn(nu + 1, x)/jn(nu, x)
g = nu*log(x) - log(jn(nu, x))
assert heurisch(f, x) == g
@slow
def test_pmint_bessel_products():
# Note: Derivatives of Bessel functions have many forms.
# Recurrence relations are needed for comparisons.
if ON_TRAVIS:
skip("Too slow for travis.")
f = x*besselj(nu, x)*bessely(nu, 2*x)
g = -2*x*besselj(nu, x)*bessely(nu - 1, 2*x)/3 + x*besselj(nu - 1, x)*bessely(nu, 2*x)/3
assert heurisch(f, x) == g
f = x*besselj(nu, x)*besselk(nu, 2*x)
g = -2*x*besselj(nu, x)*besselk(nu - 1, 2*x)/5 - x*besselj(nu - 1, x)*besselk(nu, 2*x)/5
assert heurisch(f, x) == g
@slow # 110 seconds on 3.4 GHz
def test_pmint_WrightOmega():
if ON_TRAVIS:
skip("Too slow for travis.")
def omega(x):
return LambertW(exp(x))
f = (1 + omega(x) * (2 + cos(omega(x)) * (x + omega(x))))/(1 + omega(x))/(x + omega(x))
g = log(x + LambertW(exp(x))) + sin(LambertW(exp(x)))
assert heurisch(f, x) == g
def test_RR():
# Make sure the algorithm does the right thing if the ring is RR. See
# issue 8685.
assert heurisch(sqrt(1 + 0.25*x**2), x, hints=[]) == \
0.5*x*sqrt(0.25*x**2 + 1) + 1.0*asinh(0.5*x)
# TODO: convert the rest of PMINT tests:
# Airy functions
# f = (x - AiryAi(x)*AiryAi(1, x)) / (x**2 - AiryAi(x)**2)
# g = Rational(1,2)*ln(x + AiryAi(x)) + Rational(1,2)*ln(x - AiryAi(x))
# f = x**2 * AiryAi(x)
# g = -AiryAi(x) + AiryAi(1, x)*x
# Whittaker functions
# f = WhittakerW(mu + 1, nu, x) / (WhittakerW(mu, nu, x) * x)
# g = x/2 - mu*ln(x) - ln(WhittakerW(mu, nu, x))
|
f03d586d4adb78f5c3c27cca7feb9987206b8d88020c8866f0e657f6f45074d4 | from sympy import (sin, cos, tan, sec, csc, cot, log, exp, atan, asin, acos,
Symbol, Integral, integrate, pi, Dummy, Derivative,
diff, I, sqrt, erf, Piecewise, Ne, symbols, Rational,
And, Heaviside, S, asinh, acosh, atanh, acoth, expand,
Function, jacobi, gegenbauer, chebyshevt, chebyshevu,
legendre, hermite, laguerre, assoc_laguerre, uppergamma, li,
Ei, Ci, Si, Chi, Shi, fresnels, fresnelc, polylog, erfi,
sinh, cosh, elliptic_f, elliptic_e)
from sympy.integrals.manualintegrate import (manualintegrate, find_substitutions,
_parts_rule, integral_steps, contains_dont_know, manual_subs)
from sympy.testing.pytest import raises, slow
x, y, z, u, n, a, b, c = symbols('x y z u n a b c')
f = Function('f')
def test_find_substitutions():
assert find_substitutions((cot(x)**2 + 1)**2*csc(x)**2*cot(x)**2, x, u) == \
[(cot(x), 1, -u**6 - 2*u**4 - u**2)]
assert find_substitutions((sec(x)**2 + tan(x) * sec(x)) / (sec(x) + tan(x)),
x, u) == [(sec(x) + tan(x), 1, 1/u)]
assert find_substitutions(x * exp(-x**2), x, u) == [(-x**2, Rational(-1, 2), exp(u))]
def test_manualintegrate_polynomials():
assert manualintegrate(y, x) == x*y
assert manualintegrate(exp(2), x) == x * exp(2)
assert manualintegrate(x**2, x) == x**3 / 3
assert manualintegrate(3 * x**2 + 4 * x**3, x) == x**3 + x**4
assert manualintegrate((x + 2)**3, x) == (x + 2)**4 / 4
assert manualintegrate((3*x + 4)**2, x) == (3*x + 4)**3 / 9
assert manualintegrate((u + 2)**3, u) == (u + 2)**4 / 4
assert manualintegrate((3*u + 4)**2, u) == (3*u + 4)**3 / 9
def test_manualintegrate_exponentials():
assert manualintegrate(exp(2*x), x) == exp(2*x) / 2
assert manualintegrate(2**x, x) == (2 ** x) / log(2)
assert manualintegrate(1 / x, x) == log(x)
assert manualintegrate(1 / (2*x + 3), x) == log(2*x + 3) / 2
assert manualintegrate(log(x)**2 / x, x) == log(x)**3 / 3
def test_manualintegrate_parts():
assert manualintegrate(exp(x) * sin(x), x) == \
(exp(x) * sin(x)) / 2 - (exp(x) * cos(x)) / 2
assert manualintegrate(2*x*cos(x), x) == 2*x*sin(x) + 2*cos(x)
assert manualintegrate(x * log(x), x) == x**2*log(x)/2 - x**2/4
assert manualintegrate(log(x), x) == x * log(x) - x
assert manualintegrate((3*x**2 + 5) * exp(x), x) == \
3*x**2*exp(x) - 6*x*exp(x) + 11*exp(x)
assert manualintegrate(atan(x), x) == x*atan(x) - log(x**2 + 1)/2
# Make sure _parts_rule does not go into an infinite loop here
assert manualintegrate(log(1/x)/(x + 1), x).has(Integral)
# Make sure _parts_rule doesn't pick u = constant but can pick dv =
# constant if necessary, e.g. for integrate(atan(x))
assert _parts_rule(cos(x), x) == None
assert _parts_rule(exp(x), x) == None
assert _parts_rule(x**2, x) == None
result = _parts_rule(atan(x), x)
assert result[0] == atan(x) and result[1] == 1
def test_manualintegrate_trigonometry():
assert manualintegrate(sin(x), x) == -cos(x)
assert manualintegrate(tan(x), x) == -log(cos(x))
assert manualintegrate(sec(x), x) == log(sec(x) + tan(x))
assert manualintegrate(csc(x), x) == -log(csc(x) + cot(x))
assert manualintegrate(sin(x) * cos(x), x) in [sin(x) ** 2 / 2, -cos(x)**2 / 2]
assert manualintegrate(-sec(x) * tan(x), x) == -sec(x)
assert manualintegrate(csc(x) * cot(x), x) == -csc(x)
assert manualintegrate(sec(x)**2, x) == tan(x)
assert manualintegrate(csc(x)**2, x) == -cot(x)
assert manualintegrate(x * sec(x**2), x) == log(tan(x**2) + sec(x**2))/2
assert manualintegrate(cos(x)*csc(sin(x)), x) == -log(cot(sin(x)) + csc(sin(x)))
assert manualintegrate(cos(3*x)*sec(x), x) == -x + sin(2*x)
assert manualintegrate(sin(3*x)*sec(x), x) == \
-3*log(cos(x)) + 2*log(cos(x)**2) - 2*cos(x)**2
def test_manualintegrate_trigpowers():
assert manualintegrate(sin(x)**2 * cos(x), x) == sin(x)**3 / 3
assert manualintegrate(sin(x)**2 * cos(x) **2, x) == \
x / 8 - sin(4*x) / 32
assert manualintegrate(sin(x) * cos(x)**3, x) == -cos(x)**4 / 4
assert manualintegrate(sin(x)**3 * cos(x)**2, x) == \
cos(x)**5 / 5 - cos(x)**3 / 3
assert manualintegrate(tan(x)**3 * sec(x), x) == sec(x)**3/3 - sec(x)
assert manualintegrate(tan(x) * sec(x) **2, x) == sec(x)**2/2
assert manualintegrate(cot(x)**5 * csc(x), x) == \
-csc(x)**5/5 + 2*csc(x)**3/3 - csc(x)
assert manualintegrate(cot(x)**2 * csc(x)**6, x) == \
-cot(x)**7/7 - 2*cot(x)**5/5 - cot(x)**3/3
def test_manualintegrate_inversetrig():
# atan
assert manualintegrate(exp(x) / (1 + exp(2*x)), x) == atan(exp(x))
assert manualintegrate(1 / (4 + 9 * x**2), x) == atan(3 * x/2) / 6
assert manualintegrate(1 / (16 + 16 * x**2), x) == atan(x) / 16
assert manualintegrate(1 / (4 + x**2), x) == atan(x / 2) / 2
assert manualintegrate(1 / (1 + 4 * x**2), x) == atan(2*x) / 2
ra = Symbol('a', real=True)
rb = Symbol('b', real=True)
assert manualintegrate(1/(ra + rb*x**2), x) == \
Piecewise((atan(x/sqrt(ra/rb))/(rb*sqrt(ra/rb)), ra/rb > 0),
(-acoth(x/sqrt(-ra/rb))/(rb*sqrt(-ra/rb)), And(ra/rb < 0, x**2 > -ra/rb)),
(-atanh(x/sqrt(-ra/rb))/(rb*sqrt(-ra/rb)), And(ra/rb < 0, x**2 < -ra/rb)))
assert manualintegrate(1/(4 + rb*x**2), x) == \
Piecewise((atan(x/(2*sqrt(1/rb)))/(2*rb*sqrt(1/rb)), 4/rb > 0),
(-acoth(x/(2*sqrt(-1/rb)))/(2*rb*sqrt(-1/rb)), And(4/rb < 0, x**2 > -4/rb)),
(-atanh(x/(2*sqrt(-1/rb)))/(2*rb*sqrt(-1/rb)), And(4/rb < 0, x**2 < -4/rb)))
assert manualintegrate(1/(ra + 4*x**2), x) == \
Piecewise((atan(2*x/sqrt(ra))/(2*sqrt(ra)), ra/4 > 0),
(-acoth(2*x/sqrt(-ra))/(2*sqrt(-ra)), And(ra/4 < 0, x**2 > -ra/4)),
(-atanh(2*x/sqrt(-ra))/(2*sqrt(-ra)), And(ra/4 < 0, x**2 < -ra/4)))
assert manualintegrate(1/(4 + 4*x**2), x) == atan(x) / 4
assert manualintegrate(1/(a + b*x**2), x) == atan(x/sqrt(a/b))/(b*sqrt(a/b))
# asin
assert manualintegrate(1/sqrt(1-x**2), x) == asin(x)
assert manualintegrate(1/sqrt(4-4*x**2), x) == asin(x)/2
assert manualintegrate(3/sqrt(1-9*x**2), x) == asin(3*x)
assert manualintegrate(1/sqrt(4-9*x**2), x) == asin(x*Rational(3, 2))/3
# asinh
assert manualintegrate(1/sqrt(x**2 + 1), x) == \
asinh(x)
assert manualintegrate(1/sqrt(x**2 + 4), x) == \
asinh(x/2)
assert manualintegrate(1/sqrt(4*x**2 + 4), x) == \
asinh(x)/2
assert manualintegrate(1/sqrt(4*x**2 + 1), x) == \
asinh(2*x)/2
assert manualintegrate(1/sqrt(a*x**2 + 1), x) == \
Piecewise((sqrt(-1/a)*asin(x*sqrt(-a)), a < 0), (sqrt(1/a)*asinh(sqrt(a)*x), a > 0))
assert manualintegrate(1/sqrt(a + x**2), x) == \
Piecewise((asinh(x*sqrt(1/a)), a > 0), (acosh(x*sqrt(-1/a)), a < 0))
# acosh
assert manualintegrate(1/sqrt(x**2 - 1), x) == \
acosh(x)
assert manualintegrate(1/sqrt(x**2 - 4), x) == \
acosh(x/2)
assert manualintegrate(1/sqrt(4*x**2 - 4), x) == \
acosh(x)/2
assert manualintegrate(1/sqrt(9*x**2 - 1), x) == \
acosh(3*x)/3
assert manualintegrate(1/sqrt(a*x**2 - 4), x) == \
Piecewise((sqrt(1/a)*acosh(sqrt(a)*x/2), a > 0))
assert manualintegrate(1/sqrt(-a + 4*x**2), x) == \
Piecewise((asinh(2*x*sqrt(-1/a))/2, -a > 0), (acosh(2*x*sqrt(1/a))/2, -a < 0))
# piecewise
assert manualintegrate(1/sqrt(a-b*x**2), x) == \
Piecewise((sqrt(a/b)*asin(x*sqrt(b/a))/sqrt(a), And(-b < 0, a > 0)),
(sqrt(-a/b)*asinh(x*sqrt(-b/a))/sqrt(a), And(-b > 0, a > 0)),
(sqrt(a/b)*acosh(x*sqrt(b/a))/sqrt(-a), And(-b > 0, a < 0)))
assert manualintegrate(1/sqrt(a + b*x**2), x) == \
Piecewise((sqrt(-a/b)*asin(x*sqrt(-b/a))/sqrt(a), And(a > 0, b < 0)),
(sqrt(a/b)*asinh(x*sqrt(b/a))/sqrt(a), And(a > 0, b > 0)),
(sqrt(-a/b)*acosh(x*sqrt(-b/a))/sqrt(-a), And(a < 0, b > 0)))
def test_manualintegrate_trig_substitution():
assert manualintegrate(sqrt(16*x**2 - 9)/x, x) == \
Piecewise((sqrt(16*x**2 - 9) - 3*acos(3/(4*x)),
And(x < Rational(3, 4), x > Rational(-3, 4))))
assert manualintegrate(1/(x**4 * sqrt(25-x**2)), x) == \
Piecewise((-sqrt(-x**2/25 + 1)/(125*x) -
(-x**2/25 + 1)**(3*S.Half)/(15*x**3), And(x < 5, x > -5)))
assert manualintegrate(x**7/(49*x**2 + 1)**(3 * S.Half), x) == \
((49*x**2 + 1)**(5*S.Half)/28824005 -
(49*x**2 + 1)**(3*S.Half)/5764801 +
3*sqrt(49*x**2 + 1)/5764801 + 1/(5764801*sqrt(49*x**2 + 1)))
def test_manualintegrate_trivial_substitution():
assert manualintegrate((exp(x) - exp(-x))/x, x) == -Ei(-x) + Ei(x)
f = Function('f')
assert manualintegrate((f(x) - f(-x))/x, x) == \
-Integral(f(-x)/x, x) + Integral(f(x)/x, x)
def test_manualintegrate_rational():
assert manualintegrate(1/(4 - x**2), x) == Piecewise((acoth(x/2)/2, x**2 > 4), (atanh(x/2)/2, x**2 < 4))
assert manualintegrate(1/(-1 + x**2), x) == Piecewise((-acoth(x), x**2 > 1), (-atanh(x), x**2 < 1))
def test_manualintegrate_special():
f, F = 4*exp(-x**2/3), 2*sqrt(3)*sqrt(pi)*erf(sqrt(3)*x/3)
assert manualintegrate(f, x) == F and F.diff(x).equals(f)
f, F = 3*exp(4*x**2), 3*sqrt(pi)*erfi(2*x)/4
assert manualintegrate(f, x) == F and F.diff(x).equals(f)
f, F = x**Rational(1, 3)*exp(-x/8), -16*uppergamma(Rational(4, 3), x/8)
assert manualintegrate(f, x) == F and F.diff(x).equals(f)
f, F = exp(2*x)/x, Ei(2*x)
assert manualintegrate(f, x) == F and F.diff(x).equals(f)
f, F = exp(1 + 2*x - x**2), sqrt(pi)*exp(2)*erf(x - 1)/2
assert manualintegrate(f, x) == F and F.diff(x).equals(f)
f = sin(x**2 + 4*x + 1)
F = (sqrt(2)*sqrt(pi)*(-sin(3)*fresnelc(sqrt(2)*(2*x + 4)/(2*sqrt(pi))) +
cos(3)*fresnels(sqrt(2)*(2*x + 4)/(2*sqrt(pi))))/2)
assert manualintegrate(f, x) == F and F.diff(x).equals(f)
f, F = cos(4*x**2), sqrt(2)*sqrt(pi)*fresnelc(2*sqrt(2)*x/sqrt(pi))/4
assert manualintegrate(f, x) == F and F.diff(x).equals(f)
f, F = sin(3*x + 2)/x, sin(2)*Ci(3*x) + cos(2)*Si(3*x)
assert manualintegrate(f, x) == F and F.diff(x).equals(f)
f, F = sinh(3*x - 2)/x, -sinh(2)*Chi(3*x) + cosh(2)*Shi(3*x)
assert manualintegrate(f, x) == F and F.diff(x).equals(f)
f, F = 5*cos(2*x - 3)/x, 5*cos(3)*Ci(2*x) + 5*sin(3)*Si(2*x)
assert manualintegrate(f, x) == F and F.diff(x).equals(f)
f, F = cosh(x/2)/x, Chi(x/2)
assert manualintegrate(f, x) == F and F.diff(x).equals(f)
f, F = cos(x**2)/x, Ci(x**2)/2
assert manualintegrate(f, x) == F and F.diff(x).equals(f)
f, F = 1/log(2*x + 1), li(2*x + 1)/2
assert manualintegrate(f, x) == F and F.diff(x).equals(f)
f, F = polylog(2, 5*x)/x, polylog(3, 5*x)
assert manualintegrate(f, x) == F and F.diff(x).equals(f)
f, F = 5/sqrt(3 - 2*sin(x)**2), 5*sqrt(3)*elliptic_f(x, Rational(2, 3))/3
assert manualintegrate(f, x) == F and F.diff(x).equals(f)
f, F = sqrt(4 + 9*sin(x)**2), 2*elliptic_e(x, Rational(-9, 4))
assert manualintegrate(f, x) == F and F.diff(x).equals(f)
def test_manualintegrate_derivative():
assert manualintegrate(pi * Derivative(x**2 + 2*x + 3), x) == \
pi * (x**2 + 2*x + 3)
assert manualintegrate(Derivative(x**2 + 2*x + 3, y), x) == \
Integral(Derivative(x**2 + 2*x + 3, y))
assert manualintegrate(Derivative(sin(x), x, x, x, y), x) == \
Derivative(sin(x), x, x, y)
def test_manualintegrate_Heaviside():
assert manualintegrate(Heaviside(x), x) == x*Heaviside(x)
assert manualintegrate(x*Heaviside(2), x) == x**2/2
assert manualintegrate(x*Heaviside(-2), x) == 0
assert manualintegrate(x*Heaviside( x), x) == x**2*Heaviside( x)/2
assert manualintegrate(x*Heaviside(-x), x) == x**2*Heaviside(-x)/2
assert manualintegrate(Heaviside(2*x + 4), x) == (x+2)*Heaviside(2*x + 4)
assert manualintegrate(x*Heaviside(x), x) == x**2*Heaviside(x)/2
assert manualintegrate(Heaviside(x + 1)*Heaviside(1 - x)*x**2, x) == \
((x**3/3 + Rational(1, 3))*Heaviside(x + 1) - Rational(2, 3))*Heaviside(-x + 1)
y = Symbol('y')
assert manualintegrate(sin(7 + x)*Heaviside(3*x - 7), x) == \
(- cos(x + 7) + cos(Rational(28, 3)))*Heaviside(3*x - S(7))
assert manualintegrate(sin(y + x)*Heaviside(3*x - y), x) == \
(cos(y*Rational(4, 3)) - cos(x + y))*Heaviside(3*x - y)
def test_manualintegrate_orthogonal_poly():
n = symbols('n')
a, b = 7, Rational(5, 3)
polys = [jacobi(n, a, b, x), gegenbauer(n, a, x), chebyshevt(n, x),
chebyshevu(n, x), legendre(n, x), hermite(n, x), laguerre(n, x),
assoc_laguerre(n, a, x)]
for p in polys:
integral = manualintegrate(p, x)
for deg in [-2, -1, 0, 1, 3, 5, 8]:
# some accept negative "degree", some do not
try:
p_subbed = p.subs(n, deg)
except ValueError:
continue
assert (integral.subs(n, deg).diff(x) - p_subbed).expand() == 0
# can also integrate simple expressions with these polynomials
q = x*p.subs(x, 2*x + 1)
integral = manualintegrate(q, x)
for deg in [2, 4, 7]:
assert (integral.subs(n, deg).diff(x) - q.subs(n, deg)).expand() == 0
# cannot integrate with respect to any other parameter
t = symbols('t')
for i in range(len(p.args) - 1):
new_args = list(p.args)
new_args[i] = t
assert isinstance(manualintegrate(p.func(*new_args), t), Integral)
def test_issue_6799():
r, x, phi = map(Symbol, 'r x phi'.split())
n = Symbol('n', integer=True, positive=True)
integrand = (cos(n*(x-phi))*cos(n*x))
limits = (x, -pi, pi)
assert manualintegrate(integrand, x) == \
((n*x/2 + sin(2*n*x)/4)*cos(n*phi) - sin(n*phi)*cos(n*x)**2/2)/n
assert r * integrate(integrand, limits).trigsimp() / pi == r * cos(n * phi)
assert not integrate(integrand, limits).has(Dummy)
def test_issue_12251():
assert manualintegrate(x**y, x) == Piecewise(
(x**(y + 1)/(y + 1), Ne(y, -1)), (log(x), True))
def test_issue_3796():
assert manualintegrate(diff(exp(x + x**2)), x) == exp(x + x**2)
assert integrate(x * exp(x**4), x, risch=False) == -I*sqrt(pi)*erf(I*x**2)/4
def test_manual_true():
assert integrate(exp(x) * sin(x), x, manual=True) == \
(exp(x) * sin(x)) / 2 - (exp(x) * cos(x)) / 2
assert integrate(sin(x) * cos(x), x, manual=True) in \
[sin(x) ** 2 / 2, -cos(x)**2 / 2]
def test_issue_6746():
y = Symbol('y')
n = Symbol('n')
assert manualintegrate(y**x, x) == Piecewise(
(y**x/log(y), Ne(log(y), 0)), (x, True))
assert manualintegrate(y**(n*x), x) == Piecewise(
(Piecewise(
(y**(n*x)/log(y), Ne(log(y), 0)),
(n*x, True)
)/n, Ne(n, 0)),
(x, True))
assert manualintegrate(exp(n*x), x) == Piecewise(
(exp(n*x)/n, Ne(n, 0)), (x, True))
y = Symbol('y', positive=True)
assert manualintegrate((y + 1)**x, x) == (y + 1)**x/log(y + 1)
y = Symbol('y', zero=True)
assert manualintegrate((y + 1)**x, x) == x
y = Symbol('y')
n = Symbol('n', nonzero=True)
assert manualintegrate(y**(n*x), x) == Piecewise(
(y**(n*x)/log(y), Ne(log(y), 0)), (n*x, True))/n
y = Symbol('y', positive=True)
assert manualintegrate((y + 1)**(n*x), x) == \
(y + 1)**(n*x)/(n*log(y + 1))
a = Symbol('a', negative=True)
b = Symbol('b')
assert manualintegrate(1/(a + b*x**2), x) == atan(x/sqrt(a/b))/(b*sqrt(a/b))
b = Symbol('b', negative=True)
assert manualintegrate(1/(a + b*x**2), x) == \
atan(x/(sqrt(-a)*sqrt(-1/b)))/(b*sqrt(-a)*sqrt(-1/b))
assert manualintegrate(1/((x**a + y**b + 4)*sqrt(a*x**2 + 1)), x) == \
y**(-b)*Integral(x**(-a)/(y**(-b)*sqrt(a*x**2 + 1) +
x**(-a)*sqrt(a*x**2 + 1) + 4*x**(-a)*y**(-b)*sqrt(a*x**2 + 1)), x)
assert manualintegrate(1/((x**2 + 4)*sqrt(4*x**2 + 1)), x) == \
Integral(1/((x**2 + 4)*sqrt(4*x**2 + 1)), x)
assert manualintegrate(1/(x - a**x + x*b**2), x) == \
Integral(1/(-a**x + b**2*x + x), x)
@slow
def test_issue_2850():
assert manualintegrate(asin(x)*log(x), x) == -x*asin(x) - sqrt(-x**2 + 1) \
+ (x*asin(x) + sqrt(-x**2 + 1))*log(x) - Integral(sqrt(-x**2 + 1)/x, x)
assert manualintegrate(acos(x)*log(x), x) == -x*acos(x) + sqrt(-x**2 + 1) + \
(x*acos(x) - sqrt(-x**2 + 1))*log(x) + Integral(sqrt(-x**2 + 1)/x, x)
assert manualintegrate(atan(x)*log(x), x) == -x*atan(x) + (x*atan(x) - \
log(x**2 + 1)/2)*log(x) + log(x**2 + 1)/2 + Integral(log(x**2 + 1)/x, x)/2
def test_issue_9462():
assert manualintegrate(sin(2*x)*exp(x), x) == exp(x)*sin(2*x)/5 - 2*exp(x)*cos(2*x)/5
assert not contains_dont_know(integral_steps(sin(2*x)*exp(x), x))
assert manualintegrate((x - 3) / (x**2 - 2*x + 2)**2, x) == \
Integral(x/(x**4 - 4*x**3 + 8*x**2 - 8*x + 4), x) \
- 3*Integral(1/(x**4 - 4*x**3 + 8*x**2 - 8*x + 4), x)
def test_cyclic_parts():
f = cos(x)*exp(x/4)
F = 16*exp(x/4)*sin(x)/17 + 4*exp(x/4)*cos(x)/17
assert manualintegrate(f, x) == F and F.diff(x) == f
f = x*cos(x)*exp(x/4)
F = (x*(16*exp(x/4)*sin(x)/17 + 4*exp(x/4)*cos(x)/17) -
128*exp(x/4)*sin(x)/289 + 240*exp(x/4)*cos(x)/289)
assert manualintegrate(f, x) == F and F.diff(x) == f
@slow
def test_issue_10847_slow():
assert manualintegrate((4*x**4 + 4*x**3 + 16*x**2 + 12*x + 8)
/ (x**6 + 2*x**5 + 3*x**4 + 4*x**3 + 3*x**2 + 2*x + 1), x) == \
2*x/(x**2 + 1) + 3*atan(x) - 1/(x**2 + 1) - 3/(x + 1)
def test_issue_10847():
assert manualintegrate(x**2 / (x**2 - c), x) == c*atan(x/sqrt(-c))/sqrt(-c) + x
rc = Symbol('c', real=True)
assert manualintegrate(x**2 / (x**2 - rc), x) == \
rc*Piecewise((atan(x/sqrt(-rc))/sqrt(-rc), -rc > 0),
(-acoth(x/sqrt(rc))/sqrt(rc), And(-rc < 0, x**2 > rc)),
(-atanh(x/sqrt(rc))/sqrt(rc), And(-rc < 0, x**2 < rc))) + x
assert manualintegrate(sqrt(x - y) * log(z / x), x) == \
4*y**Rational(3, 2)*atan(sqrt(x - y)/sqrt(y))/3 - 4*y*sqrt(x - y)/3 +\
2*(x - y)**Rational(3, 2)*log(z/x)/3 + 4*(x - y)**Rational(3, 2)/9
ry = Symbol('y', real=True)
rz = Symbol('z', real=True)
assert manualintegrate(sqrt(x - ry) * log(rz / x), x) == \
4*ry**2*Piecewise((atan(sqrt(x - ry)/sqrt(ry))/sqrt(ry), ry > 0),
(-acoth(sqrt(x - ry)/sqrt(-ry))/sqrt(-ry), And(x - ry > -ry, ry < 0)),
(-atanh(sqrt(x - ry)/sqrt(-ry))/sqrt(-ry), And(x - ry < -ry, ry < 0)))/3 \
- 4*ry*sqrt(x - ry)/3 + 2*(x - ry)**Rational(3, 2)*log(rz/x)/3 \
+ 4*(x - ry)**Rational(3, 2)/9
assert manualintegrate(sqrt(x) * log(x), x) == 2*x**Rational(3, 2)*log(x)/3 - 4*x**Rational(3, 2)/9
assert manualintegrate(sqrt(a*x + b) / x, x) == \
2*b*atan(sqrt(a*x + b)/sqrt(-b))/sqrt(-b) + 2*sqrt(a*x + b)
ra = Symbol('a', real=True)
rb = Symbol('b', real=True)
assert manualintegrate(sqrt(ra*x + rb) / x, x) == \
-2*rb*Piecewise((-atan(sqrt(ra*x + rb)/sqrt(-rb))/sqrt(-rb), -rb > 0),
(acoth(sqrt(ra*x + rb)/sqrt(rb))/sqrt(rb), And(-rb < 0, ra*x + rb > rb)),
(atanh(sqrt(ra*x + rb)/sqrt(rb))/sqrt(rb), And(-rb < 0, ra*x + rb < rb))) \
+ 2*sqrt(ra*x + rb)
assert expand(manualintegrate(sqrt(ra*x + rb) / (x + rc), x)) == -2*ra*rc*Piecewise((atan(sqrt(ra*x + rb)/sqrt(ra*rc - rb))/sqrt(ra*rc - rb), \
ra*rc - rb > 0), (-acoth(sqrt(ra*x + rb)/sqrt(-ra*rc + rb))/sqrt(-ra*rc + rb), And(ra*rc - rb < 0, ra*x + rb > -ra*rc + rb)), \
(-atanh(sqrt(ra*x + rb)/sqrt(-ra*rc + rb))/sqrt(-ra*rc + rb), And(ra*rc - rb < 0, ra*x + rb < -ra*rc + rb))) \
+ 2*rb*Piecewise((atan(sqrt(ra*x + rb)/sqrt(ra*rc - rb))/sqrt(ra*rc - rb), ra*rc - rb > 0), \
(-acoth(sqrt(ra*x + rb)/sqrt(-ra*rc + rb))/sqrt(-ra*rc + rb), And(ra*rc - rb < 0, ra*x + rb > -ra*rc + rb)), \
(-atanh(sqrt(ra*x + rb)/sqrt(-ra*rc + rb))/sqrt(-ra*rc + rb), And(ra*rc - rb < 0, ra*x + rb < -ra*rc + rb))) + 2*sqrt(ra*x + rb)
assert manualintegrate(sqrt(2*x + 3) / (x + 1), x) == 2*sqrt(2*x + 3) - log(sqrt(2*x + 3) + 1) + log(sqrt(2*x + 3) - 1)
assert manualintegrate(sqrt(2*x + 3) / 2 * x, x) == (2*x + 3)**Rational(5, 2)/20 - (2*x + 3)**Rational(3, 2)/4
assert manualintegrate(x**Rational(3,2) * log(x), x) == 2*x**Rational(5,2)*log(x)/5 - 4*x**Rational(5,2)/25
assert manualintegrate(x**(-3) * log(x), x) == -log(x)/(2*x**2) - 1/(4*x**2)
assert manualintegrate(log(y)/(y**2*(1 - 1/y)), y) == \
log(y)*log(-1 + 1/y) - Integral(log(-1 + 1/y)/y, y)
def test_issue_12899():
assert manualintegrate(f(x,y).diff(x),y) == Integral(Derivative(f(x,y),x),y)
assert manualintegrate(f(x,y).diff(y).diff(x),y) == Derivative(f(x,y),x)
def test_constant_independent_of_symbol():
assert manualintegrate(Integral(y, (x, 1, 2)), x) == \
x*Integral(y, (x, 1, 2))
def test_issue_12641():
assert manualintegrate(sin(2*x), x) == -cos(2*x)/2
assert manualintegrate(cos(x)*sin(2*x), x) == -2*cos(x)**3/3
assert manualintegrate((sin(2*x)*cos(x))/(1 + cos(x)), x) == \
-2*log(cos(x) + 1) - cos(x)**2 + 2*cos(x)
def test_issue_13297():
assert manualintegrate(sin(x) * cos(x)**5, x) == -cos(x)**6 / 6
def test_issue_14470():
assert manualintegrate(1/(x*sqrt(x + 1)), x) == \
log(-1 + 1/sqrt(x + 1)) - log(1 + 1/sqrt(x + 1))
@slow
def test_issue_9858():
assert manualintegrate(exp(x)*cos(exp(x)), x) == sin(exp(x))
assert manualintegrate(exp(2*x)*cos(exp(x)), x) == \
exp(x)*sin(exp(x)) + cos(exp(x))
res = manualintegrate(exp(10*x)*sin(exp(x)), x)
assert not res.has(Integral)
assert res.diff(x) == exp(10*x)*sin(exp(x))
# an example with many similar integrations by parts
assert manualintegrate(sum([x*exp(k*x) for k in range(1, 8)]), x) == (
x*exp(7*x)/7 + x*exp(6*x)/6 + x*exp(5*x)/5 + x*exp(4*x)/4 +
x*exp(3*x)/3 + x*exp(2*x)/2 + x*exp(x) - exp(7*x)/49 -exp(6*x)/36 -
exp(5*x)/25 - exp(4*x)/16 - exp(3*x)/9 - exp(2*x)/4 - exp(x))
def test_issue_8520():
assert manualintegrate(x/(x**4 + 1), x) == atan(x**2)/2
assert manualintegrate(x**2/(x**6 + 25), x) == atan(x**3/5)/15
f = x/(9*x**4 + 4)**2
assert manualintegrate(f, x).diff(x).factor() == f
def test_manual_subs():
x, y = symbols('x y')
expr = log(x) + exp(x)
# if log(x) is y, then exp(y) is x
assert manual_subs(expr, log(x), y) == y + exp(exp(y))
# if exp(x) is y, then log(y) need not be x
assert manual_subs(expr, exp(x), y) == log(x) + y
raises(ValueError, lambda: manual_subs(expr, x))
raises(ValueError, lambda: manual_subs(expr, exp(x), x, y))
def test_issue_15471():
f = log(x)*cos(log(x))/x**Rational(3, 4)
F = -128*x**Rational(1, 4)*sin(log(x))/289 + 240*x**Rational(1, 4)*cos(log(x))/289 + (16*x**Rational(1, 4)*sin(log(x))/17 + 4*x**Rational(1, 4)*cos(log(x))/17)*log(x)
assert manualintegrate(f, x) == F and F.diff(x).equals(f)
def test_quadratic_denom():
f = (5*x + 2)/(3*x**2 - 2*x + 8)
assert manualintegrate(f, x) == 5*log(3*x**2 - 2*x + 8)/6 + 11*sqrt(23)*atan(3*sqrt(23)*(x - Rational(1, 3))/23)/69
g = 3/(2*x**2 + 3*x + 1)
assert manualintegrate(g, x) == 3*log(4*x + 2) - 3*log(4*x + 4)
|
7b9ea1a90c532cba286f0c195efcf7566ddc43fa29f527356976ee0272b79eda | from sympy import (meijerg, I, S, integrate, Integral, oo, gamma, cosh, sinc,
hyperexpand, exp, simplify, sqrt, pi, erf, erfc, sin, cos,
exp_polar, polygamma, hyper, log, expand_func, Rational)
from sympy.integrals.meijerint import (_rewrite_single, _rewrite1,
meijerint_indefinite, _inflate_g, _create_lookup_table,
meijerint_definite, meijerint_inversion)
from sympy.utilities import default_sort_key
from sympy.testing.pytest import slow
from sympy.testing.randtest import (verify_numerically,
random_complex_number as randcplx)
from sympy.abc import x, y, a, b, c, d, s, t, z
def test_rewrite_single():
def t(expr, c, m):
e = _rewrite_single(meijerg([a], [b], [c], [d], expr), x)
assert e is not None
assert isinstance(e[0][0][2], meijerg)
assert e[0][0][2].argument.as_coeff_mul(x) == (c, (m,))
def tn(expr):
assert _rewrite_single(meijerg([a], [b], [c], [d], expr), x) is None
t(x, 1, x)
t(x**2, 1, x**2)
t(x**2 + y*x**2, y + 1, x**2)
tn(x**2 + x)
tn(x**y)
def u(expr, x):
from sympy import Add, exp, exp_polar
r = _rewrite_single(expr, x)
e = Add(*[res[0]*res[2] for res in r[0]]).replace(
exp_polar, exp) # XXX Hack?
assert verify_numerically(e, expr, x)
u(exp(-x)*sin(x), x)
# The following has stopped working because hyperexpand changed slightly.
# It is probably not worth fixing
#u(exp(-x)*sin(x)*cos(x), x)
# This one cannot be done numerically, since it comes out as a g-function
# of argument 4*pi
# NOTE This also tests a bug in inverse mellin transform (which used to
# turn exp(4*pi*I*t) into a factor of exp(4*pi*I)**t instead of
# exp_polar).
#u(exp(x)*sin(x), x)
assert _rewrite_single(exp(x)*sin(x), x) == \
([(-sqrt(2)/(2*sqrt(pi)), 0,
meijerg(((Rational(-1, 2), 0, Rational(1, 4), S.Half, Rational(3, 4)), (1,)),
((), (Rational(-1, 2), 0)), 64*exp_polar(-4*I*pi)/x**4))], True)
def test_rewrite1():
assert _rewrite1(x**3*meijerg([a], [b], [c], [d], x**2 + y*x**2)*5, x) == \
(5, x**3, [(1, 0, meijerg([a], [b], [c], [d], x**2*(y + 1)))], True)
def test_meijerint_indefinite_numerically():
def t(fac, arg):
g = meijerg([a], [b], [c], [d], arg)*fac
subs = {a: randcplx()/10, b: randcplx()/10 + I,
c: randcplx(), d: randcplx()}
integral = meijerint_indefinite(g, x)
assert integral is not None
assert verify_numerically(g.subs(subs), integral.diff(x).subs(subs), x)
t(1, x)
t(2, x)
t(1, 2*x)
t(1, x**2)
t(5, x**S('3/2'))
t(x**3, x)
t(3*x**S('3/2'), 4*x**S('7/3'))
def test_meijerint_definite():
v, b = meijerint_definite(x, x, 0, 0)
assert v.is_zero and b is True
v, b = meijerint_definite(x, x, oo, oo)
assert v.is_zero and b is True
def test_inflate():
subs = {a: randcplx()/10, b: randcplx()/10 + I, c: randcplx(),
d: randcplx(), y: randcplx()/10}
def t(a, b, arg, n):
from sympy import Mul
m1 = meijerg(a, b, arg)
m2 = Mul(*_inflate_g(m1, n))
# NOTE: (the random number)**9 must still be on the principal sheet.
# Thus make b&d small to create random numbers of small imaginary part.
return verify_numerically(m1.subs(subs), m2.subs(subs), x, b=0.1, d=-0.1)
assert t([[a], [b]], [[c], [d]], x, 3)
assert t([[a, y], [b]], [[c], [d]], x, 3)
assert t([[a], [b]], [[c, y], [d]], 2*x**3, 3)
def test_recursive():
from sympy import symbols
a, b, c = symbols('a b c', positive=True)
r = exp(-(x - a)**2)*exp(-(x - b)**2)
e = integrate(r, (x, 0, oo), meijerg=True)
assert simplify(e.expand()) == (
sqrt(2)*sqrt(pi)*(
(erf(sqrt(2)*(a + b)/2) + 1)*exp(-a**2/2 + a*b - b**2/2))/4)
e = integrate(exp(-(x - a)**2)*exp(-(x - b)**2)*exp(c*x), (x, 0, oo), meijerg=True)
assert simplify(e) == (
sqrt(2)*sqrt(pi)*(erf(sqrt(2)*(2*a + 2*b + c)/4) + 1)*exp(-a**2 - b**2
+ (2*a + 2*b + c)**2/8)/4)
assert simplify(integrate(exp(-(x - a - b - c)**2), (x, 0, oo), meijerg=True)) == \
sqrt(pi)/2*(1 + erf(a + b + c))
assert simplify(integrate(exp(-(x + a + b + c)**2), (x, 0, oo), meijerg=True)) == \
sqrt(pi)/2*(1 - erf(a + b + c))
@slow
def test_meijerint():
from sympy import symbols, expand, arg
s, t, mu = symbols('s t mu', real=True)
assert integrate(meijerg([], [], [0], [], s*t)
*meijerg([], [], [mu/2], [-mu/2], t**2/4),
(t, 0, oo)).is_Piecewise
s = symbols('s', positive=True)
assert integrate(x**s*meijerg([[], []], [[0], []], x), (x, 0, oo)) == \
gamma(s + 1)
assert integrate(x**s*meijerg([[], []], [[0], []], x), (x, 0, oo),
meijerg=True) == gamma(s + 1)
assert isinstance(integrate(x**s*meijerg([[], []], [[0], []], x),
(x, 0, oo), meijerg=False),
Integral)
assert meijerint_indefinite(exp(x), x) == exp(x)
# TODO what simplifications should be done automatically?
# This tests "extra case" for antecedents_1.
a, b = symbols('a b', positive=True)
assert simplify(meijerint_definite(x**a, x, 0, b)[0]) == \
b**(a + 1)/(a + 1)
# This tests various conditions and expansions:
meijerint_definite((x + 1)**3*exp(-x), x, 0, oo) == (16, True)
# Again, how about simplifications?
sigma, mu = symbols('sigma mu', positive=True)
i, c = meijerint_definite(exp(-((x - mu)/(2*sigma))**2), x, 0, oo)
assert simplify(i) == sqrt(pi)*sigma*(2 - erfc(mu/(2*sigma)))
assert c == True
i, _ = meijerint_definite(exp(-mu*x)*exp(sigma*x), x, 0, oo)
# TODO it would be nice to test the condition
assert simplify(i) == 1/(mu - sigma)
# Test substitutions to change limits
assert meijerint_definite(exp(x), x, -oo, 2) == (exp(2), True)
# Note: causes a NaN in _check_antecedents
assert expand(meijerint_definite(exp(x), x, 0, I)[0]) == exp(I) - 1
assert expand(meijerint_definite(exp(-x), x, 0, x)[0]) == \
1 - exp(-exp(I*arg(x))*abs(x))
# Test -oo to oo
assert meijerint_definite(exp(-x**2), x, -oo, oo) == (sqrt(pi), True)
assert meijerint_definite(exp(-abs(x)), x, -oo, oo) == (2, True)
assert meijerint_definite(exp(-(2*x - 3)**2), x, -oo, oo) == \
(sqrt(pi)/2, True)
assert meijerint_definite(exp(-abs(2*x - 3)), x, -oo, oo) == (1, True)
assert meijerint_definite(exp(-((x - mu)/sigma)**2/2)/sqrt(2*pi*sigma**2),
x, -oo, oo) == (1, True)
assert meijerint_definite(sinc(x)**2, x, -oo, oo) == (pi, True)
# Test one of the extra conditions for 2 g-functinos
assert meijerint_definite(exp(-x)*sin(x), x, 0, oo) == (S.Half, True)
# Test a bug
def res(n):
return (1/(1 + x**2)).diff(x, n).subs(x, 1)*(-1)**n
for n in range(6):
assert integrate(exp(-x)*sin(x)*x**n, (x, 0, oo), meijerg=True) == \
res(n)
# This used to test trigexpand... now it is done by linear substitution
assert simplify(integrate(exp(-x)*sin(x + a), (x, 0, oo), meijerg=True)
) == sqrt(2)*sin(a + pi/4)/2
# Test the condition 14 from prudnikov.
# (This is besselj*besselj in disguise, to stop the product from being
# recognised in the tables.)
a, b, s = symbols('a b s')
from sympy import And, re
assert meijerint_definite(meijerg([], [], [a/2], [-a/2], x/4)
*meijerg([], [], [b/2], [-b/2], x/4)*x**(s - 1), x, 0, oo) == \
(4*2**(2*s - 2)*gamma(-2*s + 1)*gamma(a/2 + b/2 + s)
/(gamma(-a/2 + b/2 - s + 1)*gamma(a/2 - b/2 - s + 1)
*gamma(a/2 + b/2 - s + 1)),
And(0 < -2*re(4*s) + 8, 0 < re(a/2 + b/2 + s), re(2*s) < 1))
# test a bug
assert integrate(sin(x**a)*sin(x**b), (x, 0, oo), meijerg=True) == \
Integral(sin(x**a)*sin(x**b), (x, 0, oo))
# test better hyperexpand
assert integrate(exp(-x**2)*log(x), (x, 0, oo), meijerg=True) == \
(sqrt(pi)*polygamma(0, S.Half)/4).expand()
# Test hyperexpand bug.
from sympy import lowergamma
n = symbols('n', integer=True)
assert simplify(integrate(exp(-x)*x**n, x, meijerg=True)) == \
lowergamma(n + 1, x)
# Test a bug with argument 1/x
alpha = symbols('alpha', positive=True)
assert meijerint_definite((2 - x)**alpha*sin(alpha/x), x, 0, 2) == \
(sqrt(pi)*alpha*gamma(alpha + 1)*meijerg(((), (alpha/2 + S.Half,
alpha/2 + 1)), ((0, 0, S.Half), (Rational(-1, 2),)), alpha**2/16)/4, True)
# test a bug related to 3016
a, s = symbols('a s', positive=True)
assert simplify(integrate(x**s*exp(-a*x**2), (x, -oo, oo))) == \
a**(-s/2 - S.Half)*((-1)**s + 1)*gamma(s/2 + S.Half)/2
def test_bessel():
from sympy import besselj, besseli
assert simplify(integrate(besselj(a, z)*besselj(b, z)/z, (z, 0, oo),
meijerg=True, conds='none')) == \
2*sin(pi*(a/2 - b/2))/(pi*(a - b)*(a + b))
assert simplify(integrate(besselj(a, z)*besselj(a, z)/z, (z, 0, oo),
meijerg=True, conds='none')) == 1/(2*a)
# TODO more orthogonality integrals
assert simplify(integrate(sin(z*x)*(x**2 - 1)**(-(y + S.Half)),
(x, 1, oo), meijerg=True, conds='none')
*2/((z/2)**y*sqrt(pi)*gamma(S.Half - y))) == \
besselj(y, z)
# Werner Rosenheinrich
# SOME INDEFINITE INTEGRALS OF BESSEL FUNCTIONS
assert integrate(x*besselj(0, x), x, meijerg=True) == x*besselj(1, x)
assert integrate(x*besseli(0, x), x, meijerg=True) == x*besseli(1, x)
# TODO can do higher powers, but come out as high order ... should they be
# reduced to order 0, 1?
assert integrate(besselj(1, x), x, meijerg=True) == -besselj(0, x)
assert integrate(besselj(1, x)**2/x, x, meijerg=True) == \
-(besselj(0, x)**2 + besselj(1, x)**2)/2
# TODO more besseli when tables are extended or recursive mellin works
assert integrate(besselj(0, x)**2/x**2, x, meijerg=True) == \
-2*x*besselj(0, x)**2 - 2*x*besselj(1, x)**2 \
+ 2*besselj(0, x)*besselj(1, x) - besselj(0, x)**2/x
assert integrate(besselj(0, x)*besselj(1, x), x, meijerg=True) == \
-besselj(0, x)**2/2
assert integrate(x**2*besselj(0, x)*besselj(1, x), x, meijerg=True) == \
x**2*besselj(1, x)**2/2
assert integrate(besselj(0, x)*besselj(1, x)/x, x, meijerg=True) == \
(x*besselj(0, x)**2 + x*besselj(1, x)**2 -
besselj(0, x)*besselj(1, x))
# TODO how does besselj(0, a*x)*besselj(0, b*x) work?
# TODO how does besselj(0, x)**2*besselj(1, x)**2 work?
# TODO sin(x)*besselj(0, x) etc come out a mess
# TODO can x*log(x)*besselj(0, x) be done?
# TODO how does besselj(1, x)*besselj(0, x+a) work?
# TODO more indefinite integrals when struve functions etc are implemented
# test a substitution
assert integrate(besselj(1, x**2)*x, x, meijerg=True) == \
-besselj(0, x**2)/2
def test_inversion():
from sympy import piecewise_fold, besselj, sqrt, sin, cos, Heaviside
def inv(f):
return piecewise_fold(meijerint_inversion(f, s, t))
assert inv(1/(s**2 + 1)) == sin(t)*Heaviside(t)
assert inv(s/(s**2 + 1)) == cos(t)*Heaviside(t)
assert inv(exp(-s)/s) == Heaviside(t - 1)
assert inv(1/sqrt(1 + s**2)) == besselj(0, t)*Heaviside(t)
# Test some antcedents checking.
assert meijerint_inversion(sqrt(s)/sqrt(1 + s**2), s, t) is None
assert inv(exp(s**2)) is None
assert meijerint_inversion(exp(-s**2), s, t) is None
def test_inversion_conditional_output():
from sympy import Symbol, InverseLaplaceTransform
a = Symbol('a', positive=True)
F = sqrt(pi/a)*exp(-2*sqrt(a)*sqrt(s))
f = meijerint_inversion(F, s, t)
assert not f.is_Piecewise
b = Symbol('b', real=True)
F = F.subs(a, b)
f2 = meijerint_inversion(F, s, t)
assert f2.is_Piecewise
# first piece is same as f
assert f2.args[0][0] == f.subs(a, b)
# last piece is an unevaluated transform
assert f2.args[-1][1]
ILT = InverseLaplaceTransform(F, s, t, None)
assert f2.args[-1][0] == ILT or f2.args[-1][0] == ILT.as_integral
def test_inversion_exp_real_nonreal_shift():
from sympy import Symbol, DiracDelta
r = Symbol('r', real=True)
c = Symbol('c', extended_real=False)
a = 1 + 2*I
z = Symbol('z')
assert not meijerint_inversion(exp(r*s), s, t).is_Piecewise
assert meijerint_inversion(exp(a*s), s, t) is None
assert meijerint_inversion(exp(c*s), s, t) is None
f = meijerint_inversion(exp(z*s), s, t)
assert f.is_Piecewise
assert isinstance(f.args[0][0], DiracDelta)
@slow
def test_lookup_table():
from random import uniform, randrange
from sympy import Add
from sympy.integrals.meijerint import z as z_dummy
table = {}
_create_lookup_table(table)
for _, l in sorted(table.items()):
for formula, terms, cond, hint in sorted(l, key=default_sort_key):
subs = {}
for ai in list(formula.free_symbols) + [z_dummy]:
if hasattr(ai, 'properties') and ai.properties:
# these Wilds match positive integers
subs[ai] = randrange(1, 10)
else:
subs[ai] = uniform(1.5, 2.0)
if not isinstance(terms, list):
terms = terms(subs)
# First test that hyperexpand can do this.
expanded = [hyperexpand(g) for (_, g) in terms]
assert all(x.is_Piecewise or not x.has(meijerg) for x in expanded)
# Now test that the meijer g-function is indeed as advertised.
expanded = Add(*[f*x for (f, x) in terms])
a, b = formula.n(subs=subs), expanded.n(subs=subs)
r = min(abs(a), abs(b))
if r < 1:
assert abs(a - b).n() <= 1e-10
else:
assert (abs(a - b)/r).n() <= 1e-10
def test_branch_bug():
from sympy import powdenest, lowergamma
# TODO gammasimp cannot prove that the factor is unity
assert powdenest(integrate(erf(x**3), x, meijerg=True).diff(x),
polar=True) == 2*erf(x**3)*gamma(Rational(2, 3))/3/gamma(Rational(5, 3))
assert integrate(erf(x**3), x, meijerg=True) == \
2*x*erf(x**3)*gamma(Rational(2, 3))/(3*gamma(Rational(5, 3))) \
- 2*gamma(Rational(2, 3))*lowergamma(Rational(2, 3), x**6)/(3*sqrt(pi)*gamma(Rational(5, 3)))
def test_linear_subs():
from sympy import besselj
assert integrate(sin(x - 1), x, meijerg=True) == -cos(1 - x)
assert integrate(besselj(1, x - 1), x, meijerg=True) == -besselj(0, 1 - x)
@slow
def test_probability():
# various integrals from probability theory
from sympy.abc import x, y
from sympy import symbols, Symbol, Abs, expand_mul, gammasimp, powsimp, sin
mu1, mu2 = symbols('mu1 mu2', nonzero=True)
sigma1, sigma2 = symbols('sigma1 sigma2', positive=True)
rate = Symbol('lambda', positive=True)
def normal(x, mu, sigma):
return 1/sqrt(2*pi*sigma**2)*exp(-(x - mu)**2/2/sigma**2)
def exponential(x, rate):
return rate*exp(-rate*x)
assert integrate(normal(x, mu1, sigma1), (x, -oo, oo), meijerg=True) == 1
assert integrate(x*normal(x, mu1, sigma1), (x, -oo, oo), meijerg=True) == \
mu1
assert integrate(x**2*normal(x, mu1, sigma1), (x, -oo, oo), meijerg=True) \
== mu1**2 + sigma1**2
assert integrate(x**3*normal(x, mu1, sigma1), (x, -oo, oo), meijerg=True) \
== mu1**3 + 3*mu1*sigma1**2
assert integrate(normal(x, mu1, sigma1)*normal(y, mu2, sigma2),
(x, -oo, oo), (y, -oo, oo), meijerg=True) == 1
assert integrate(x*normal(x, mu1, sigma1)*normal(y, mu2, sigma2),
(x, -oo, oo), (y, -oo, oo), meijerg=True) == mu1
assert integrate(y*normal(x, mu1, sigma1)*normal(y, mu2, sigma2),
(x, -oo, oo), (y, -oo, oo), meijerg=True) == mu2
assert integrate(x*y*normal(x, mu1, sigma1)*normal(y, mu2, sigma2),
(x, -oo, oo), (y, -oo, oo), meijerg=True) == mu1*mu2
assert integrate((x + y + 1)*normal(x, mu1, sigma1)*normal(y, mu2, sigma2),
(x, -oo, oo), (y, -oo, oo), meijerg=True) == 1 + mu1 + mu2
assert integrate((x + y - 1)*normal(x, mu1, sigma1)*normal(y, mu2, sigma2),
(x, -oo, oo), (y, -oo, oo), meijerg=True) == \
-1 + mu1 + mu2
i = integrate(x**2*normal(x, mu1, sigma1)*normal(y, mu2, sigma2),
(x, -oo, oo), (y, -oo, oo), meijerg=True)
assert not i.has(Abs)
assert simplify(i) == mu1**2 + sigma1**2
assert integrate(y**2*normal(x, mu1, sigma1)*normal(y, mu2, sigma2),
(x, -oo, oo), (y, -oo, oo), meijerg=True) == \
sigma2**2 + mu2**2
assert integrate(exponential(x, rate), (x, 0, oo), meijerg=True) == 1
assert integrate(x*exponential(x, rate), (x, 0, oo), meijerg=True) == \
1/rate
assert integrate(x**2*exponential(x, rate), (x, 0, oo), meijerg=True) == \
2/rate**2
def E(expr):
res1 = integrate(expr*exponential(x, rate)*normal(y, mu1, sigma1),
(x, 0, oo), (y, -oo, oo), meijerg=True)
res2 = integrate(expr*exponential(x, rate)*normal(y, mu1, sigma1),
(y, -oo, oo), (x, 0, oo), meijerg=True)
assert expand_mul(res1) == expand_mul(res2)
return res1
assert E(1) == 1
assert E(x*y) == mu1/rate
assert E(x*y**2) == mu1**2/rate + sigma1**2/rate
ans = sigma1**2 + 1/rate**2
assert simplify(E((x + y + 1)**2) - E(x + y + 1)**2) == ans
assert simplify(E((x + y - 1)**2) - E(x + y - 1)**2) == ans
assert simplify(E((x + y)**2) - E(x + y)**2) == ans
# Beta' distribution
alpha, beta = symbols('alpha beta', positive=True)
betadist = x**(alpha - 1)*(1 + x)**(-alpha - beta)*gamma(alpha + beta) \
/gamma(alpha)/gamma(beta)
assert integrate(betadist, (x, 0, oo), meijerg=True) == 1
i = integrate(x*betadist, (x, 0, oo), meijerg=True, conds='separate')
assert (gammasimp(i[0]), i[1]) == (alpha/(beta - 1), 1 < beta)
j = integrate(x**2*betadist, (x, 0, oo), meijerg=True, conds='separate')
assert j[1] == (1 < beta - 1)
assert gammasimp(j[0] - i[0]**2) == (alpha + beta - 1)*alpha \
/(beta - 2)/(beta - 1)**2
# Beta distribution
# NOTE: this is evaluated using antiderivatives. It also tests that
# meijerint_indefinite returns the simplest possible answer.
a, b = symbols('a b', positive=True)
betadist = x**(a - 1)*(-x + 1)**(b - 1)*gamma(a + b)/(gamma(a)*gamma(b))
assert simplify(integrate(betadist, (x, 0, 1), meijerg=True)) == 1
assert simplify(integrate(x*betadist, (x, 0, 1), meijerg=True)) == \
a/(a + b)
assert simplify(integrate(x**2*betadist, (x, 0, 1), meijerg=True)) == \
a*(a + 1)/(a + b)/(a + b + 1)
assert simplify(integrate(x**y*betadist, (x, 0, 1), meijerg=True)) == \
gamma(a + b)*gamma(a + y)/gamma(a)/gamma(a + b + y)
# Chi distribution
k = Symbol('k', integer=True, positive=True)
chi = 2**(1 - k/2)*x**(k - 1)*exp(-x**2/2)/gamma(k/2)
assert powsimp(integrate(chi, (x, 0, oo), meijerg=True)) == 1
assert simplify(integrate(x*chi, (x, 0, oo), meijerg=True)) == \
sqrt(2)*gamma((k + 1)/2)/gamma(k/2)
assert simplify(integrate(x**2*chi, (x, 0, oo), meijerg=True)) == k
# Chi^2 distribution
chisquared = 2**(-k/2)/gamma(k/2)*x**(k/2 - 1)*exp(-x/2)
assert powsimp(integrate(chisquared, (x, 0, oo), meijerg=True)) == 1
assert simplify(integrate(x*chisquared, (x, 0, oo), meijerg=True)) == k
assert simplify(integrate(x**2*chisquared, (x, 0, oo), meijerg=True)) == \
k*(k + 2)
assert gammasimp(integrate(((x - k)/sqrt(2*k))**3*chisquared, (x, 0, oo),
meijerg=True)) == 2*sqrt(2)/sqrt(k)
# Dagum distribution
a, b, p = symbols('a b p', positive=True)
# XXX (x/b)**a does not work
dagum = a*p/x*(x/b)**(a*p)/(1 + x**a/b**a)**(p + 1)
assert simplify(integrate(dagum, (x, 0, oo), meijerg=True)) == 1
# XXX conditions are a mess
arg = x*dagum
assert simplify(integrate(arg, (x, 0, oo), meijerg=True, conds='none')
) == a*b*gamma(1 - 1/a)*gamma(p + 1 + 1/a)/(
(a*p + 1)*gamma(p))
assert simplify(integrate(x*arg, (x, 0, oo), meijerg=True, conds='none')
) == a*b**2*gamma(1 - 2/a)*gamma(p + 1 + 2/a)/(
(a*p + 2)*gamma(p))
# F-distribution
d1, d2 = symbols('d1 d2', positive=True)
f = sqrt(((d1*x)**d1 * d2**d2)/(d1*x + d2)**(d1 + d2))/x \
/gamma(d1/2)/gamma(d2/2)*gamma((d1 + d2)/2)
assert simplify(integrate(f, (x, 0, oo), meijerg=True)) == 1
# TODO conditions are a mess
assert simplify(integrate(x*f, (x, 0, oo), meijerg=True, conds='none')
) == d2/(d2 - 2)
assert simplify(integrate(x**2*f, (x, 0, oo), meijerg=True, conds='none')
) == d2**2*(d1 + 2)/d1/(d2 - 4)/(d2 - 2)
# TODO gamma, rayleigh
# inverse gaussian
lamda, mu = symbols('lamda mu', positive=True)
dist = sqrt(lamda/2/pi)*x**(Rational(-3, 2))*exp(-lamda*(x - mu)**2/x/2/mu**2)
mysimp = lambda expr: simplify(expr.rewrite(exp))
assert mysimp(integrate(dist, (x, 0, oo))) == 1
assert mysimp(integrate(x*dist, (x, 0, oo))) == mu
assert mysimp(integrate((x - mu)**2*dist, (x, 0, oo))) == mu**3/lamda
assert mysimp(integrate((x - mu)**3*dist, (x, 0, oo))) == 3*mu**5/lamda**2
# Levi
c = Symbol('c', positive=True)
assert integrate(sqrt(c/2/pi)*exp(-c/2/(x - mu))/(x - mu)**S('3/2'),
(x, mu, oo)) == 1
# higher moments oo
# log-logistic
alpha, beta = symbols('alpha beta', positive=True)
distn = (beta/alpha)*x**(beta - 1)/alpha**(beta - 1)/ \
(1 + x**beta/alpha**beta)**2
# FIXME: If alpha, beta are not declared as finite the line below hangs
# after the changes in:
# https://github.com/sympy/sympy/pull/16603
assert simplify(integrate(distn, (x, 0, oo))) == 1
# NOTE the conditions are a mess, but correctly state beta > 1
assert simplify(integrate(x*distn, (x, 0, oo), conds='none')) == \
pi*alpha/beta/sin(pi/beta)
# (similar comment for conditions applies)
assert simplify(integrate(x**y*distn, (x, 0, oo), conds='none')) == \
pi*alpha**y*y/beta/sin(pi*y/beta)
# weibull
k = Symbol('k', positive=True)
n = Symbol('n', positive=True)
distn = k/lamda*(x/lamda)**(k - 1)*exp(-(x/lamda)**k)
assert simplify(integrate(distn, (x, 0, oo))) == 1
assert simplify(integrate(x**n*distn, (x, 0, oo))) == \
lamda**n*gamma(1 + n/k)
# rice distribution
from sympy import besseli
nu, sigma = symbols('nu sigma', positive=True)
rice = x/sigma**2*exp(-(x**2 + nu**2)/2/sigma**2)*besseli(0, x*nu/sigma**2)
assert integrate(rice, (x, 0, oo), meijerg=True) == 1
# can someone verify higher moments?
# Laplace distribution
mu = Symbol('mu', real=True)
b = Symbol('b', positive=True)
laplace = exp(-abs(x - mu)/b)/2/b
assert integrate(laplace, (x, -oo, oo), meijerg=True) == 1
assert integrate(x*laplace, (x, -oo, oo), meijerg=True) == mu
assert integrate(x**2*laplace, (x, -oo, oo), meijerg=True) == \
2*b**2 + mu**2
# TODO are there other distributions supported on (-oo, oo) that we can do?
# misc tests
k = Symbol('k', positive=True)
assert gammasimp(expand_mul(integrate(log(x)*x**(k - 1)*exp(-x)/gamma(k),
(x, 0, oo)))) == polygamma(0, k)
@slow
def test_expint():
""" Test various exponential integrals. """
from sympy import (expint, unpolarify, Symbol, Ci, Si, Shi, Chi,
sin, cos, sinh, cosh, Ei)
assert simplify(unpolarify(integrate(exp(-z*x)/x**y, (x, 1, oo),
meijerg=True, conds='none'
).rewrite(expint).expand(func=True))) == expint(y, z)
assert integrate(exp(-z*x)/x, (x, 1, oo), meijerg=True,
conds='none').rewrite(expint).expand() == \
expint(1, z)
assert integrate(exp(-z*x)/x**2, (x, 1, oo), meijerg=True,
conds='none').rewrite(expint).expand() == \
expint(2, z).rewrite(Ei).rewrite(expint)
assert integrate(exp(-z*x)/x**3, (x, 1, oo), meijerg=True,
conds='none').rewrite(expint).expand() == \
expint(3, z).rewrite(Ei).rewrite(expint).expand()
t = Symbol('t', positive=True)
assert integrate(-cos(x)/x, (x, t, oo), meijerg=True).expand() == Ci(t)
assert integrate(-sin(x)/x, (x, t, oo), meijerg=True).expand() == \
Si(t) - pi/2
assert integrate(sin(x)/x, (x, 0, z), meijerg=True) == Si(z)
assert integrate(sinh(x)/x, (x, 0, z), meijerg=True) == Shi(z)
assert integrate(exp(-x)/x, x, meijerg=True).expand().rewrite(expint) == \
I*pi - expint(1, x)
assert integrate(exp(-x)/x**2, x, meijerg=True).rewrite(expint).expand() \
== expint(1, x) - exp(-x)/x - I*pi
u = Symbol('u', polar=True)
assert integrate(cos(u)/u, u, meijerg=True).expand().as_independent(u)[1] \
== Ci(u)
assert integrate(cosh(u)/u, u, meijerg=True).expand().as_independent(u)[1] \
== Chi(u)
assert integrate(expint(1, x), x, meijerg=True
).rewrite(expint).expand() == x*expint(1, x) - exp(-x)
assert integrate(expint(2, x), x, meijerg=True
).rewrite(expint).expand() == \
-x**2*expint(1, x)/2 + x*exp(-x)/2 - exp(-x)/2
assert simplify(unpolarify(integrate(expint(y, x), x,
meijerg=True).rewrite(expint).expand(func=True))) == \
-expint(y + 1, x)
assert integrate(Si(x), x, meijerg=True) == x*Si(x) + cos(x)
assert integrate(Ci(u), u, meijerg=True).expand() == u*Ci(u) - sin(u)
assert integrate(Shi(x), x, meijerg=True) == x*Shi(x) - cosh(x)
assert integrate(Chi(u), u, meijerg=True).expand() == u*Chi(u) - sinh(u)
assert integrate(Si(x)*exp(-x), (x, 0, oo), meijerg=True) == pi/4
assert integrate(expint(1, x)*sin(x), (x, 0, oo), meijerg=True) == log(2)/2
def test_messy():
from sympy import (laplace_transform, Si, Shi, Chi, atan, Piecewise,
acoth, E1, besselj, acosh, asin, And, re,
fourier_transform, sqrt)
assert laplace_transform(Si(x), x, s) == ((-atan(s) + pi/2)/s, 0, True)
assert laplace_transform(Shi(x), x, s) == (acoth(s)/s, 1, True)
# where should the logs be simplified?
assert laplace_transform(Chi(x), x, s) == \
((log(s**(-2)) - log((s**2 - 1)/s**2))/(2*s), 1, True)
# TODO maybe simplify the inequalities?
assert laplace_transform(besselj(a, x), x, s)[1:] == \
(0, And(re(a/2) + S.Half > S.Zero, re(a/2) + 1 > S.Zero))
# NOTE s < 0 can be done, but argument reduction is not good enough yet
assert fourier_transform(besselj(1, x)/x, x, s, noconds=False) == \
(Piecewise((0, 4*abs(pi**2*s**2) > 1),
(2*sqrt(-4*pi**2*s**2 + 1), True)), s > 0)
# TODO FT(besselj(0,x)) - conditions are messy (but for acceptable reasons)
# - folding could be better
assert integrate(E1(x)*besselj(0, x), (x, 0, oo), meijerg=True) == \
log(1 + sqrt(2))
assert integrate(E1(x)*besselj(1, x), (x, 0, oo), meijerg=True) == \
log(S.Half + sqrt(2)/2)
assert integrate(1/x/sqrt(1 - x**2), x, meijerg=True) == \
Piecewise((-acosh(1/x), abs(x**(-2)) > 1), (I*asin(1/x), True))
def test_issue_6122():
assert integrate(exp(-I*x**2), (x, -oo, oo), meijerg=True) == \
-I*sqrt(pi)*exp(I*pi/4)
def test_issue_6252():
expr = 1/x/(a + b*x)**Rational(1, 3)
anti = integrate(expr, x, meijerg=True)
assert not anti.has(hyper)
# XXX the expression is a mess, but actually upon differentiation and
# putting in numerical values seems to work...
def test_issue_6348():
assert integrate(exp(I*x)/(1 + x**2), (x, -oo, oo)).simplify().rewrite(exp) \
== pi*exp(-1)
def test_fresnel():
from sympy import fresnels, fresnelc
assert expand_func(integrate(sin(pi*x**2/2), x)) == fresnels(x)
assert expand_func(integrate(cos(pi*x**2/2), x)) == fresnelc(x)
def test_issue_6860():
assert meijerint_indefinite(x**x**x, x) is None
def test_issue_7337():
f = meijerint_indefinite(x*sqrt(2*x + 3), x).together()
assert f == sqrt(2*x + 3)*(2*x**2 + x - 3)/5
assert f._eval_interval(x, S.NegativeOne, S.One) == Rational(2, 5)
def test_issue_8368():
assert meijerint_indefinite(cosh(x)*exp(-x*t), x) == (
(-t - 1)*exp(x) + (-t + 1)*exp(-x))*exp(-t*x)/2/(t**2 - 1)
def test_issue_10211():
from sympy.abc import h, w
assert integrate((1/sqrt((y-x)**2 + h**2)**3), (x,0,w), (y,0,w)) == \
2*sqrt(1 + w**2/h**2)/h - 2/h
def test_issue_11806():
from sympy import symbols
y, L = symbols('y L', positive=True)
assert integrate(1/sqrt(x**2 + y**2)**3, (x, -L, L)) == \
2*L/(y**2*sqrt(L**2 + y**2))
def test_issue_10681():
from sympy import RR
from sympy.abc import R, r
f = integrate(r**2*(R**2-r**2)**0.5, r, meijerg=True)
g = (1.0/3)*R**1.0*r**3*hyper((-0.5, Rational(3, 2)), (Rational(5, 2),),
r**2*exp_polar(2*I*pi)/R**2)
assert RR.almosteq((f/g).n(), 1.0, 1e-12)
def test_issue_13536():
from sympy import Symbol
a = Symbol('a', real=True, positive=True)
assert integrate(1/x**2, (x, oo, a)) == -1/a
def test_issue_6462():
from sympy import Symbol
x = Symbol('x')
n = Symbol('n')
# Not the actual issue, still wrong answer for n = 1, but that there is no
# exception
assert integrate(cos(x**n)/x**n, x, meijerg=True).subs(n, 2).equals(
integrate(cos(x**2)/x**2, x, meijerg=True))
|
ccc4e60e599e2da7dc585b6f587a91e84e871d67fbe5d79b54807ef483d5e9b9 | from sympy.integrals.transforms import (mellin_transform,
inverse_mellin_transform, laplace_transform, inverse_laplace_transform,
fourier_transform, inverse_fourier_transform,
sine_transform, inverse_sine_transform,
cosine_transform, inverse_cosine_transform,
hankel_transform, inverse_hankel_transform,
LaplaceTransform, FourierTransform, SineTransform, CosineTransform,
InverseLaplaceTransform, InverseFourierTransform,
InverseSineTransform, InverseCosineTransform, IntegralTransformError)
from sympy import (
gamma, exp, oo, Heaviside, symbols, Symbol, re, factorial, pi, arg,
cos, S, Abs, And, sin, sqrt, I, log, tan, hyperexpand, meijerg,
EulerGamma, erf, erfc, besselj, bessely, besseli, besselk,
exp_polar, unpolarify, Function, expint, expand_mul, Rational,
gammasimp, trigsimp, atan, sinh, cosh, Ne, periodic_argument, atan2)
from sympy.testing.pytest import XFAIL, slow, skip, raises
from sympy.matrices import Matrix, eye
from sympy.abc import x, s, a, b, c, d
nu, beta, rho = symbols('nu beta rho')
def test_undefined_function():
from sympy import Function, MellinTransform
f = Function('f')
assert mellin_transform(f(x), x, s) == MellinTransform(f(x), x, s)
assert mellin_transform(f(x) + exp(-x), x, s) == \
(MellinTransform(f(x), x, s) + gamma(s), (0, oo), True)
assert laplace_transform(2*f(x), x, s) == 2*LaplaceTransform(f(x), x, s)
# TODO test derivative and other rules when implemented
def test_free_symbols():
from sympy import Function
f = Function('f')
assert mellin_transform(f(x), x, s).free_symbols == {s}
assert mellin_transform(f(x)*a, x, s).free_symbols == {s, a}
def test_as_integral():
from sympy import Function, Integral
f = Function('f')
assert mellin_transform(f(x), x, s).rewrite('Integral') == \
Integral(x**(s - 1)*f(x), (x, 0, oo))
assert fourier_transform(f(x), x, s).rewrite('Integral') == \
Integral(f(x)*exp(-2*I*pi*s*x), (x, -oo, oo))
assert laplace_transform(f(x), x, s).rewrite('Integral') == \
Integral(f(x)*exp(-s*x), (x, 0, oo))
assert str(2*pi*I*inverse_mellin_transform(f(s), s, x, (a, b)).rewrite('Integral')) \
== "Integral(x**(-s)*f(s), (s, _c - oo*I, _c + oo*I))"
assert str(2*pi*I*inverse_laplace_transform(f(s), s, x).rewrite('Integral')) == \
"Integral(f(s)*exp(s*x), (s, _c - oo*I, _c + oo*I))"
assert inverse_fourier_transform(f(s), s, x).rewrite('Integral') == \
Integral(f(s)*exp(2*I*pi*s*x), (s, -oo, oo))
# NOTE this is stuck in risch because meijerint cannot handle it
@slow
@XFAIL
def test_mellin_transform_fail():
skip("Risch takes forever.")
MT = mellin_transform
bpos = symbols('b', positive=True)
# bneg = symbols('b', negative=True)
expr = (sqrt(x + b**2) + b)**a/sqrt(x + b**2)
# TODO does not work with bneg, argument wrong. Needs changes to matching.
assert MT(expr.subs(b, -bpos), x, s) == \
((-1)**(a + 1)*2**(a + 2*s)*bpos**(a + 2*s - 1)*gamma(a + s)
*gamma(1 - a - 2*s)/gamma(1 - s),
(-re(a), -re(a)/2 + S.Half), True)
expr = (sqrt(x + b**2) + b)**a
assert MT(expr.subs(b, -bpos), x, s) == \
(
2**(a + 2*s)*a*bpos**(a + 2*s)*gamma(-a - 2*
s)*gamma(a + s)/gamma(-s + 1),
(-re(a), -re(a)/2), True)
# Test exponent 1:
assert MT(expr.subs({b: -bpos, a: 1}), x, s) == \
(-bpos**(2*s + 1)*gamma(s)*gamma(-s - S.Half)/(2*sqrt(pi)),
(-1, Rational(-1, 2)), True)
def test_mellin_transform():
from sympy import Max, Min
MT = mellin_transform
bpos = symbols('b', positive=True)
# 8.4.2
assert MT(x**nu*Heaviside(x - 1), x, s) == \
(-1/(nu + s), (-oo, -re(nu)), True)
assert MT(x**nu*Heaviside(1 - x), x, s) == \
(1/(nu + s), (-re(nu), oo), True)
assert MT((1 - x)**(beta - 1)*Heaviside(1 - x), x, s) == \
(gamma(beta)*gamma(s)/gamma(beta + s), (0, oo), re(beta) > 0)
assert MT((x - 1)**(beta - 1)*Heaviside(x - 1), x, s) == \
(gamma(beta)*gamma(1 - beta - s)/gamma(1 - s),
(-oo, -re(beta) + 1), re(beta) > 0)
assert MT((1 + x)**(-rho), x, s) == \
(gamma(s)*gamma(rho - s)/gamma(rho), (0, re(rho)), True)
# TODO also the conditions should be simplified, e.g.
# And(re(rho) - 1 < 0, re(rho) < 1) should just be
# re(rho) < 1
assert MT(abs(1 - x)**(-rho), x, s) == (
2*sin(pi*rho/2)*gamma(1 - rho)*
cos(pi*(rho/2 - s))*gamma(s)*gamma(rho-s)/pi,
(0, re(rho)), And(re(rho) - 1 < 0, re(rho) < 1))
mt = MT((1 - x)**(beta - 1)*Heaviside(1 - x)
+ a*(x - 1)**(beta - 1)*Heaviside(x - 1), x, s)
assert mt[1], mt[2] == ((0, -re(beta) + 1), re(beta) > 0)
assert MT((x**a - b**a)/(x - b), x, s)[0] == \
pi*b**(a + s - 1)*sin(pi*a)/(sin(pi*s)*sin(pi*(a + s)))
assert MT((x**a - bpos**a)/(x - bpos), x, s) == \
(pi*bpos**(a + s - 1)*sin(pi*a)/(sin(pi*s)*sin(pi*(a + s))),
(Max(-re(a), 0), Min(1 - re(a), 1)), True)
expr = (sqrt(x + b**2) + b)**a
assert MT(expr.subs(b, bpos), x, s) == \
(-a*(2*bpos)**(a + 2*s)*gamma(s)*gamma(-a - 2*s)/gamma(-a - s + 1),
(0, -re(a)/2), True)
expr = (sqrt(x + b**2) + b)**a/sqrt(x + b**2)
assert MT(expr.subs(b, bpos), x, s) == \
(2**(a + 2*s)*bpos**(a + 2*s - 1)*gamma(s)
*gamma(1 - a - 2*s)/gamma(1 - a - s),
(0, -re(a)/2 + S.Half), True)
# 8.4.2
assert MT(exp(-x), x, s) == (gamma(s), (0, oo), True)
assert MT(exp(-1/x), x, s) == (gamma(-s), (-oo, 0), True)
# 8.4.5
assert MT(log(x)**4*Heaviside(1 - x), x, s) == (24/s**5, (0, oo), True)
assert MT(log(x)**3*Heaviside(x - 1), x, s) == (6/s**4, (-oo, 0), True)
assert MT(log(x + 1), x, s) == (pi/(s*sin(pi*s)), (-1, 0), True)
assert MT(log(1/x + 1), x, s) == (pi/(s*sin(pi*s)), (0, 1), True)
assert MT(log(abs(1 - x)), x, s) == (pi/(s*tan(pi*s)), (-1, 0), True)
assert MT(log(abs(1 - 1/x)), x, s) == (pi/(s*tan(pi*s)), (0, 1), True)
# 8.4.14
assert MT(erf(sqrt(x)), x, s) == \
(-gamma(s + S.Half)/(sqrt(pi)*s), (Rational(-1, 2), 0), True)
@slow
def test_mellin_transform2():
MT = mellin_transform
# TODO we cannot currently do these (needs summation of 3F2(-1))
# this also implies that they cannot be written as a single g-function
# (although this is possible)
mt = MT(log(x)/(x + 1), x, s)
assert mt[1:] == ((0, 1), True)
assert not hyperexpand(mt[0], allow_hyper=True).has(meijerg)
mt = MT(log(x)**2/(x + 1), x, s)
assert mt[1:] == ((0, 1), True)
assert not hyperexpand(mt[0], allow_hyper=True).has(meijerg)
mt = MT(log(x)/(x + 1)**2, x, s)
assert mt[1:] == ((0, 2), True)
assert not hyperexpand(mt[0], allow_hyper=True).has(meijerg)
@slow
def test_mellin_transform_bessel():
from sympy import Max
MT = mellin_transform
# 8.4.19
assert MT(besselj(a, 2*sqrt(x)), x, s) == \
(gamma(a/2 + s)/gamma(a/2 - s + 1), (-re(a)/2, Rational(3, 4)), True)
assert MT(sin(sqrt(x))*besselj(a, sqrt(x)), x, s) == \
(2**a*gamma(-2*s + S.Half)*gamma(a/2 + s + S.Half)/(
gamma(-a/2 - s + 1)*gamma(a - 2*s + 1)), (
-re(a)/2 - S.Half, Rational(1, 4)), True)
assert MT(cos(sqrt(x))*besselj(a, sqrt(x)), x, s) == \
(2**a*gamma(a/2 + s)*gamma(-2*s + S.Half)/(
gamma(-a/2 - s + S.Half)*gamma(a - 2*s + 1)), (
-re(a)/2, Rational(1, 4)), True)
assert MT(besselj(a, sqrt(x))**2, x, s) == \
(gamma(a + s)*gamma(S.Half - s)
/ (sqrt(pi)*gamma(1 - s)*gamma(1 + a - s)),
(-re(a), S.Half), True)
assert MT(besselj(a, sqrt(x))*besselj(-a, sqrt(x)), x, s) == \
(gamma(s)*gamma(S.Half - s)
/ (sqrt(pi)*gamma(1 - a - s)*gamma(1 + a - s)),
(0, S.Half), True)
# NOTE: prudnikov gives the strip below as (1/2 - re(a), 1). As far as
# I can see this is wrong (since besselj(z) ~ 1/sqrt(z) for z large)
assert MT(besselj(a - 1, sqrt(x))*besselj(a, sqrt(x)), x, s) == \
(gamma(1 - s)*gamma(a + s - S.Half)
/ (sqrt(pi)*gamma(Rational(3, 2) - s)*gamma(a - s + S.Half)),
(S.Half - re(a), S.Half), True)
assert MT(besselj(a, sqrt(x))*besselj(b, sqrt(x)), x, s) == \
(4**s*gamma(1 - 2*s)*gamma((a + b)/2 + s)
/ (gamma(1 - s + (b - a)/2)*gamma(1 - s + (a - b)/2)
*gamma( 1 - s + (a + b)/2)),
(-(re(a) + re(b))/2, S.Half), True)
assert MT(besselj(a, sqrt(x))**2 + besselj(-a, sqrt(x))**2, x, s)[1:] == \
((Max(re(a), -re(a)), S.Half), True)
# Section 8.4.20
assert MT(bessely(a, 2*sqrt(x)), x, s) == \
(-cos(pi*(a/2 - s))*gamma(s - a/2)*gamma(s + a/2)/pi,
(Max(-re(a)/2, re(a)/2), Rational(3, 4)), True)
assert MT(sin(sqrt(x))*bessely(a, sqrt(x)), x, s) == \
(-4**s*sin(pi*(a/2 - s))*gamma(S.Half - 2*s)
* gamma((1 - a)/2 + s)*gamma((1 + a)/2 + s)
/ (sqrt(pi)*gamma(1 - s - a/2)*gamma(1 - s + a/2)),
(Max(-(re(a) + 1)/2, (re(a) - 1)/2), Rational(1, 4)), True)
assert MT(cos(sqrt(x))*bessely(a, sqrt(x)), x, s) == \
(-4**s*cos(pi*(a/2 - s))*gamma(s - a/2)*gamma(s + a/2)*gamma(S.Half - 2*s)
/ (sqrt(pi)*gamma(S.Half - s - a/2)*gamma(S.Half - s + a/2)),
(Max(-re(a)/2, re(a)/2), Rational(1, 4)), True)
assert MT(besselj(a, sqrt(x))*bessely(a, sqrt(x)), x, s) == \
(-cos(pi*s)*gamma(s)*gamma(a + s)*gamma(S.Half - s)
/ (pi**S('3/2')*gamma(1 + a - s)),
(Max(-re(a), 0), S.Half), True)
assert MT(besselj(a, sqrt(x))*bessely(b, sqrt(x)), x, s) == \
(-4**s*cos(pi*(a/2 - b/2 + s))*gamma(1 - 2*s)
* gamma(a/2 - b/2 + s)*gamma(a/2 + b/2 + s)
/ (pi*gamma(a/2 - b/2 - s + 1)*gamma(a/2 + b/2 - s + 1)),
(Max((-re(a) + re(b))/2, (-re(a) - re(b))/2), S.Half), True)
# NOTE bessely(a, sqrt(x))**2 and bessely(a, sqrt(x))*bessely(b, sqrt(x))
# are a mess (no matter what way you look at it ...)
assert MT(bessely(a, sqrt(x))**2, x, s)[1:] == \
((Max(-re(a), 0, re(a)), S.Half), True)
# Section 8.4.22
# TODO we can't do any of these (delicate cancellation)
# Section 8.4.23
assert MT(besselk(a, 2*sqrt(x)), x, s) == \
(gamma(
s - a/2)*gamma(s + a/2)/2, (Max(-re(a)/2, re(a)/2), oo), True)
assert MT(besselj(a, 2*sqrt(2*sqrt(x)))*besselk(
a, 2*sqrt(2*sqrt(x))), x, s) == (4**(-s)*gamma(2*s)*
gamma(a/2 + s)/(2*gamma(a/2 - s + 1)), (Max(0, -re(a)/2), oo), True)
# TODO bessely(a, x)*besselk(a, x) is a mess
assert MT(besseli(a, sqrt(x))*besselk(a, sqrt(x)), x, s) == \
(gamma(s)*gamma(
a + s)*gamma(-s + S.Half)/(2*sqrt(pi)*gamma(a - s + 1)),
(Max(-re(a), 0), S.Half), True)
assert MT(besseli(b, sqrt(x))*besselk(a, sqrt(x)), x, s) == \
(2**(2*s - 1)*gamma(-2*s + 1)*gamma(-a/2 + b/2 + s)* \
gamma(a/2 + b/2 + s)/(gamma(-a/2 + b/2 - s + 1)* \
gamma(a/2 + b/2 - s + 1)), (Max(-re(a)/2 - re(b)/2, \
re(a)/2 - re(b)/2), S.Half), True)
# TODO products of besselk are a mess
mt = MT(exp(-x/2)*besselk(a, x/2), x, s)
mt0 = gammasimp(trigsimp(gammasimp(mt[0].expand(func=True))))
assert mt0 == 2*pi**Rational(3, 2)*cos(pi*s)*gamma(-s + S.Half)/(
(cos(2*pi*a) - cos(2*pi*s))*gamma(-a - s + 1)*gamma(a - s + 1))
assert mt[1:] == ((Max(-re(a), re(a)), oo), True)
# TODO exp(x/2)*besselk(a, x/2) [etc] cannot currently be done
# TODO various strange products of special orders
@slow
def test_expint():
from sympy import E1, expint, Max, re, lerchphi, Symbol, simplify, Si, Ci, Ei
aneg = Symbol('a', negative=True)
u = Symbol('u', polar=True)
assert mellin_transform(E1(x), x, s) == (gamma(s)/s, (0, oo), True)
assert inverse_mellin_transform(gamma(s)/s, s, x,
(0, oo)).rewrite(expint).expand() == E1(x)
assert mellin_transform(expint(a, x), x, s) == \
(gamma(s)/(a + s - 1), (Max(1 - re(a), 0), oo), True)
# XXX IMT has hickups with complicated strips ...
assert simplify(unpolarify(
inverse_mellin_transform(gamma(s)/(aneg + s - 1), s, x,
(1 - aneg, oo)).rewrite(expint).expand(func=True))) == \
expint(aneg, x)
assert mellin_transform(Si(x), x, s) == \
(-2**s*sqrt(pi)*gamma(s/2 + S.Half)/(
2*s*gamma(-s/2 + 1)), (-1, 0), True)
assert inverse_mellin_transform(-2**s*sqrt(pi)*gamma((s + 1)/2)
/(2*s*gamma(-s/2 + 1)), s, x, (-1, 0)) \
== Si(x)
assert mellin_transform(Ci(sqrt(x)), x, s) == \
(-2**(2*s - 1)*sqrt(pi)*gamma(s)/(s*gamma(-s + S.Half)), (0, 1), True)
assert inverse_mellin_transform(
-4**s*sqrt(pi)*gamma(s)/(2*s*gamma(-s + S.Half)),
s, u, (0, 1)).expand() == Ci(sqrt(u))
# TODO LT of Si, Shi, Chi is a mess ...
assert laplace_transform(Ci(x), x, s) == (-log(1 + s**2)/2/s, 0, True)
assert laplace_transform(expint(a, x), x, s) == \
(lerchphi(s*exp_polar(I*pi), 1, a), 0, re(a) > S.Zero)
assert laplace_transform(expint(1, x), x, s) == (log(s + 1)/s, 0, True)
assert laplace_transform(expint(2, x), x, s) == \
((s - log(s + 1))/s**2, 0, True)
assert inverse_laplace_transform(-log(1 + s**2)/2/s, s, u).expand() == \
Heaviside(u)*Ci(u)
assert inverse_laplace_transform(log(s + 1)/s, s, x).rewrite(expint) == \
Heaviside(x)*E1(x)
assert inverse_laplace_transform((s - log(s + 1))/s**2, s,
x).rewrite(expint).expand() == \
(expint(2, x)*Heaviside(x)).rewrite(Ei).rewrite(expint).expand()
@slow
def test_inverse_mellin_transform():
from sympy import (sin, simplify, Max, Min, expand,
powsimp, exp_polar, cos, cot)
IMT = inverse_mellin_transform
assert IMT(gamma(s), s, x, (0, oo)) == exp(-x)
assert IMT(gamma(-s), s, x, (-oo, 0)) == exp(-1/x)
assert simplify(IMT(s/(2*s**2 - 2), s, x, (2, oo))) == \
(x**2 + 1)*Heaviside(1 - x)/(4*x)
# test passing "None"
assert IMT(1/(s**2 - 1), s, x, (-1, None)) == \
-x*Heaviside(-x + 1)/2 - Heaviside(x - 1)/(2*x)
assert IMT(1/(s**2 - 1), s, x, (None, 1)) == \
-x*Heaviside(-x + 1)/2 - Heaviside(x - 1)/(2*x)
# test expansion of sums
assert IMT(gamma(s) + gamma(s - 1), s, x, (1, oo)) == (x + 1)*exp(-x)/x
# test factorisation of polys
r = symbols('r', real=True)
assert IMT(1/(s**2 + 1), s, exp(-x), (None, oo)
).subs(x, r).rewrite(sin).simplify() \
== sin(r)*Heaviside(1 - exp(-r))
# test multiplicative substitution
_a, _b = symbols('a b', positive=True)
assert IMT(_b**(-s/_a)*factorial(s/_a)/s, s, x, (0, oo)) == exp(-_b*x**_a)
assert IMT(factorial(_a/_b + s/_b)/(_a + s), s, x, (-_a, oo)) == x**_a*exp(-x**_b)
def simp_pows(expr):
return simplify(powsimp(expand_mul(expr, deep=False), force=True)).replace(exp_polar, exp)
# Now test the inverses of all direct transforms tested above
# Section 8.4.2
nu = symbols('nu', real=True)
assert IMT(-1/(nu + s), s, x, (-oo, None)) == x**nu*Heaviside(x - 1)
assert IMT(1/(nu + s), s, x, (None, oo)) == x**nu*Heaviside(1 - x)
assert simp_pows(IMT(gamma(beta)*gamma(s)/gamma(s + beta), s, x, (0, oo))) \
== (1 - x)**(beta - 1)*Heaviside(1 - x)
assert simp_pows(IMT(gamma(beta)*gamma(1 - beta - s)/gamma(1 - s),
s, x, (-oo, None))) \
== (x - 1)**(beta - 1)*Heaviside(x - 1)
assert simp_pows(IMT(gamma(s)*gamma(rho - s)/gamma(rho), s, x, (0, None))) \
== (1/(x + 1))**rho
assert simp_pows(IMT(d**c*d**(s - 1)*sin(pi*c)
*gamma(s)*gamma(s + c)*gamma(1 - s)*gamma(1 - s - c)/pi,
s, x, (Max(-re(c), 0), Min(1 - re(c), 1)))) \
== (x**c - d**c)/(x - d)
assert simplify(IMT(1/sqrt(pi)*(-c/2)*gamma(s)*gamma((1 - c)/2 - s)
*gamma(-c/2 - s)/gamma(1 - c - s),
s, x, (0, -re(c)/2))) == \
(1 + sqrt(x + 1))**c
assert simplify(IMT(2**(a + 2*s)*b**(a + 2*s - 1)*gamma(s)*gamma(1 - a - 2*s)
/gamma(1 - a - s), s, x, (0, (-re(a) + 1)/2))) == \
b**(a - 1)*(sqrt(1 + x/b**2) + 1)**(a - 1)*(b**2*sqrt(1 + x/b**2) +
b**2 + x)/(b**2 + x)
assert simplify(IMT(-2**(c + 2*s)*c*b**(c + 2*s)*gamma(s)*gamma(-c - 2*s)
/ gamma(-c - s + 1), s, x, (0, -re(c)/2))) == \
b**c*(sqrt(1 + x/b**2) + 1)**c
# Section 8.4.5
assert IMT(24/s**5, s, x, (0, oo)) == log(x)**4*Heaviside(1 - x)
assert expand(IMT(6/s**4, s, x, (-oo, 0)), force=True) == \
log(x)**3*Heaviside(x - 1)
assert IMT(pi/(s*sin(pi*s)), s, x, (-1, 0)) == log(x + 1)
assert IMT(pi/(s*sin(pi*s/2)), s, x, (-2, 0)) == log(x**2 + 1)
assert IMT(pi/(s*sin(2*pi*s)), s, x, (Rational(-1, 2), 0)) == log(sqrt(x) + 1)
assert IMT(pi/(s*sin(pi*s)), s, x, (0, 1)) == log(1 + 1/x)
# TODO
def mysimp(expr):
from sympy import expand, logcombine, powsimp
return expand(
powsimp(logcombine(expr, force=True), force=True, deep=True),
force=True).replace(exp_polar, exp)
assert mysimp(mysimp(IMT(pi/(s*tan(pi*s)), s, x, (-1, 0)))) in [
log(1 - x)*Heaviside(1 - x) + log(x - 1)*Heaviside(x - 1),
log(x)*Heaviside(x - 1) + log(1 - 1/x)*Heaviside(x - 1) + log(-x +
1)*Heaviside(-x + 1)]
# test passing cot
assert mysimp(IMT(pi*cot(pi*s)/s, s, x, (0, 1))) in [
log(1/x - 1)*Heaviside(1 - x) + log(1 - 1/x)*Heaviside(x - 1),
-log(x)*Heaviside(-x + 1) + log(1 - 1/x)*Heaviside(x - 1) + log(-x +
1)*Heaviside(-x + 1), ]
# 8.4.14
assert IMT(-gamma(s + S.Half)/(sqrt(pi)*s), s, x, (Rational(-1, 2), 0)) == \
erf(sqrt(x))
# 8.4.19
assert simplify(IMT(gamma(a/2 + s)/gamma(a/2 - s + 1), s, x, (-re(a)/2, Rational(3, 4)))) \
== besselj(a, 2*sqrt(x))
assert simplify(IMT(2**a*gamma(S.Half - 2*s)*gamma(s + (a + 1)/2)
/ (gamma(1 - s - a/2)*gamma(1 - 2*s + a)),
s, x, (-(re(a) + 1)/2, Rational(1, 4)))) == \
sin(sqrt(x))*besselj(a, sqrt(x))
assert simplify(IMT(2**a*gamma(a/2 + s)*gamma(S.Half - 2*s)
/ (gamma(S.Half - s - a/2)*gamma(1 - 2*s + a)),
s, x, (-re(a)/2, Rational(1, 4)))) == \
cos(sqrt(x))*besselj(a, sqrt(x))
# TODO this comes out as an amazing mess, but simplifies nicely
assert simplify(IMT(gamma(a + s)*gamma(S.Half - s)
/ (sqrt(pi)*gamma(1 - s)*gamma(1 + a - s)),
s, x, (-re(a), S.Half))) == \
besselj(a, sqrt(x))**2
assert simplify(IMT(gamma(s)*gamma(S.Half - s)
/ (sqrt(pi)*gamma(1 - s - a)*gamma(1 + a - s)),
s, x, (0, S.Half))) == \
besselj(-a, sqrt(x))*besselj(a, sqrt(x))
assert simplify(IMT(4**s*gamma(-2*s + 1)*gamma(a/2 + b/2 + s)
/ (gamma(-a/2 + b/2 - s + 1)*gamma(a/2 - b/2 - s + 1)
*gamma(a/2 + b/2 - s + 1)),
s, x, (-(re(a) + re(b))/2, S.Half))) == \
besselj(a, sqrt(x))*besselj(b, sqrt(x))
# Section 8.4.20
# TODO this can be further simplified!
assert simplify(IMT(-2**(2*s)*cos(pi*a/2 - pi*b/2 + pi*s)*gamma(-2*s + 1) *
gamma(a/2 - b/2 + s)*gamma(a/2 + b/2 + s) /
(pi*gamma(a/2 - b/2 - s + 1)*gamma(a/2 + b/2 - s + 1)),
s, x,
(Max(-re(a)/2 - re(b)/2, -re(a)/2 + re(b)/2), S.Half))) == \
besselj(a, sqrt(x))*-(besselj(-b, sqrt(x)) -
besselj(b, sqrt(x))*cos(pi*b))/sin(pi*b)
# TODO more
# for coverage
assert IMT(pi/cos(pi*s), s, x, (0, S.Half)) == sqrt(x)/(x + 1)
@slow
def test_laplace_transform():
from sympy import fresnels, fresnelc
LT = laplace_transform
a, b, c, = symbols('a b c', positive=True)
t = symbols('t')
w = Symbol("w")
f = Function("f")
# Test unevaluated form
assert laplace_transform(f(t), t, w) == LaplaceTransform(f(t), t, w)
assert inverse_laplace_transform(
f(w), w, t, plane=0) == InverseLaplaceTransform(f(w), w, t, 0)
# test a bug
spos = symbols('s', positive=True)
assert LT(exp(t), t, spos)[:2] == (1/(spos - 1), 1)
# basic tests from wikipedia
assert LT((t - a)**b*exp(-c*(t - a))*Heaviside(t - a), t, s) == \
((s + c)**(-b - 1)*exp(-a*s)*gamma(b + 1), -c, True)
assert LT(t**a, t, s) == (s**(-a - 1)*gamma(a + 1), 0, True)
assert LT(Heaviside(t), t, s) == (1/s, 0, True)
assert LT(Heaviside(t - a), t, s) == (exp(-a*s)/s, 0, True)
assert LT(1 - exp(-a*t), t, s) == (a/(s*(a + s)), 0, True)
assert LT((exp(2*t) - 1)*exp(-b - t)*Heaviside(t)/2, t, s, noconds=True) \
== exp(-b)/(s**2 - 1)
assert LT(exp(t), t, s)[:2] == (1/(s - 1), 1)
assert LT(exp(2*t), t, s)[:2] == (1/(s - 2), 2)
assert LT(exp(a*t), t, s)[:2] == (1/(s - a), a)
assert LT(log(t/a), t, s) == ((log(a*s) + EulerGamma)/s/-1, 0, True)
assert LT(erf(t), t, s) == (erfc(s/2)*exp(s**2/4)/s, 0, True)
assert LT(sin(a*t), t, s) == (a/(a**2 + s**2), 0, True)
assert LT(cos(a*t), t, s) == (s/(a**2 + s**2), 0, True)
# TODO would be nice to have these come out better
assert LT(exp(-a*t)*sin(b*t), t, s) == (b/(b**2 + (a + s)**2), -a, True)
assert LT(exp(-a*t)*cos(b*t), t, s) == \
((a + s)/(b**2 + (a + s)**2), -a, True)
assert LT(besselj(0, t), t, s) == (1/sqrt(1 + s**2), 0, True)
assert LT(besselj(1, t), t, s) == (1 - 1/sqrt(1 + 1/s**2), 0, True)
# TODO general order works, but is a *mess*
# TODO besseli also works, but is an even greater mess
# test a bug in conditions processing
# TODO the auxiliary condition should be recognised/simplified
assert LT(exp(t)*cos(t), t, s)[:-1] in [
((s - 1)/(s**2 - 2*s + 2), -oo),
((s - 1)/((s - 1)**2 + 1), -oo),
]
# Fresnel functions
assert laplace_transform(fresnels(t), t, s) == \
((-sin(s**2/(2*pi))*fresnels(s/pi) + sin(s**2/(2*pi))/2 -
cos(s**2/(2*pi))*fresnelc(s/pi) + cos(s**2/(2*pi))/2)/s, 0, True)
assert laplace_transform(fresnelc(t), t, s) == (
((2*sin(s**2/(2*pi))*fresnelc(s/pi) - 2*cos(s**2/(2*pi))*fresnels(s/pi)
+ sqrt(2)*cos(s**2/(2*pi) + pi/4))/(2*s), 0, True))
# What is this testing:
Ne(1/s, 1) & (0 < cos(Abs(periodic_argument(s, oo)))*Abs(s) - 1)
assert LT(Matrix([[exp(t), t*exp(-t)], [t*exp(-t), exp(t)]]), t, s) ==\
Matrix([
[(1/(s - 1), 1, True), ((s + 1)**(-2), 0, True)],
[((s + 1)**(-2), 0, True), (1/(s - 1), 1, True)]
])
def test_issue_8368_7173():
LT = laplace_transform
# hyperbolic
assert LT(sinh(x), x, s) == (1/(s**2 - 1), 1, True)
assert LT(cosh(x), x, s) == (s/(s**2 - 1), 1, True)
assert LT(sinh(x + 3), x, s) == (
(-s + (s + 1)*exp(6) + 1)*exp(-3)/(s - 1)/(s + 1)/2, 1, True)
assert LT(sinh(x)*cosh(x), x, s) == (
1/(s**2 - 4), 2, Ne(s/2, 1))
# trig (make sure they are not being rewritten in terms of exp)
assert LT(cos(x + 3), x, s) == ((s*cos(3) - sin(3))/(s**2 + 1), 0, True)
def test_inverse_laplace_transform():
from sympy import sinh, cosh, besselj, besseli, simplify, factor_terms
ILT = inverse_laplace_transform
a, b, c, = symbols('a b c', positive=True)
t = symbols('t')
def simp_hyp(expr):
return factor_terms(expand_mul(expr)).rewrite(sin)
# just test inverses of all of the above
assert ILT(1/s, s, t) == Heaviside(t)
assert ILT(1/s**2, s, t) == t*Heaviside(t)
assert ILT(1/s**5, s, t) == t**4*Heaviside(t)/24
assert ILT(exp(-a*s)/s, s, t) == Heaviside(t - a)
assert ILT(exp(-a*s)/(s + b), s, t) == exp(b*(a - t))*Heaviside(-a + t)
assert ILT(a/(s**2 + a**2), s, t) == sin(a*t)*Heaviside(t)
assert ILT(s/(s**2 + a**2), s, t) == cos(a*t)*Heaviside(t)
# TODO is there a way around simp_hyp?
assert simp_hyp(ILT(a/(s**2 - a**2), s, t)) == sinh(a*t)*Heaviside(t)
assert simp_hyp(ILT(s/(s**2 - a**2), s, t)) == cosh(a*t)*Heaviside(t)
assert ILT(a/((s + b)**2 + a**2), s, t) == exp(-b*t)*sin(a*t)*Heaviside(t)
assert ILT(
(s + b)/((s + b)**2 + a**2), s, t) == exp(-b*t)*cos(a*t)*Heaviside(t)
# TODO sinh/cosh shifted come out a mess. also delayed trig is a mess
# TODO should this simplify further?
assert ILT(exp(-a*s)/s**b, s, t) == \
(t - a)**(b - 1)*Heaviside(t - a)/gamma(b)
assert ILT(exp(-a*s)/sqrt(1 + s**2), s, t) == \
Heaviside(t - a)*besselj(0, a - t) # note: besselj(0, x) is even
# XXX ILT turns these branch factor into trig functions ...
assert simplify(ILT(a**b*(s + sqrt(s**2 - a**2))**(-b)/sqrt(s**2 - a**2),
s, t).rewrite(exp)) == \
Heaviside(t)*besseli(b, a*t)
assert ILT(a**b*(s + sqrt(s**2 + a**2))**(-b)/sqrt(s**2 + a**2),
s, t).rewrite(exp) == \
Heaviside(t)*besselj(b, a*t)
assert ILT(1/(s*sqrt(s + 1)), s, t) == Heaviside(t)*erf(sqrt(t))
# TODO can we make erf(t) work?
assert ILT(1/(s**2*(s**2 + 1)),s,t) == (t - sin(t))*Heaviside(t)
assert ILT( (s * eye(2) - Matrix([[1, 0], [0, 2]])).inv(), s, t) ==\
Matrix([[exp(t)*Heaviside(t), 0], [0, exp(2*t)*Heaviside(t)]])
def test_inverse_laplace_transform_delta():
from sympy import DiracDelta
ILT = inverse_laplace_transform
t = symbols('t')
assert ILT(2, s, t) == 2*DiracDelta(t)
assert ILT(2*exp(3*s) - 5*exp(-7*s), s, t) == \
2*DiracDelta(t + 3) - 5*DiracDelta(t - 7)
a = cos(sin(7)/2)
assert ILT(a*exp(-3*s), s, t) == a*DiracDelta(t - 3)
assert ILT(exp(2*s), s, t) == DiracDelta(t + 2)
r = Symbol('r', real=True)
assert ILT(exp(r*s), s, t) == DiracDelta(t + r)
def test_inverse_laplace_transform_delta_cond():
from sympy import DiracDelta, Eq, im, Heaviside
ILT = inverse_laplace_transform
t = symbols('t')
r = Symbol('r', real=True)
assert ILT(exp(r*s), s, t, noconds=False) == (DiracDelta(t + r), True)
z = Symbol('z')
assert ILT(exp(z*s), s, t, noconds=False) == \
(DiracDelta(t + z), Eq(im(z), 0))
# inversion does not exist: verify it doesn't evaluate to DiracDelta
for z in (Symbol('z', extended_real=False),
Symbol('z', imaginary=True, zero=False)):
f = ILT(exp(z*s), s, t, noconds=False)
f = f[0] if isinstance(f, tuple) else f
assert f.func != DiracDelta
# issue 15043
assert ILT(1/s + exp(r*s)/s, s, t, noconds=False) == (
Heaviside(t) + Heaviside(r + t), True)
def test_fourier_transform():
from sympy import simplify, expand, expand_complex, factor, expand_trig
FT = fourier_transform
IFT = inverse_fourier_transform
def simp(x):
return simplify(expand_trig(expand_complex(expand(x))))
def sinc(x):
return sin(pi*x)/(pi*x)
k = symbols('k', real=True)
f = Function("f")
# TODO for this to work with real a, need to expand abs(a*x) to abs(a)*abs(x)
a = symbols('a', positive=True)
b = symbols('b', positive=True)
posk = symbols('posk', positive=True)
# Test unevaluated form
assert fourier_transform(f(x), x, k) == FourierTransform(f(x), x, k)
assert inverse_fourier_transform(
f(k), k, x) == InverseFourierTransform(f(k), k, x)
# basic examples from wikipedia
assert simp(FT(Heaviside(1 - abs(2*a*x)), x, k)) == sinc(k/a)/a
# TODO IFT is a *mess*
assert simp(FT(Heaviside(1 - abs(a*x))*(1 - abs(a*x)), x, k)) == sinc(k/a)**2/a
# TODO IFT
assert factor(FT(exp(-a*x)*Heaviside(x), x, k), extension=I) == \
1/(a + 2*pi*I*k)
# NOTE: the ift comes out in pieces
assert IFT(1/(a + 2*pi*I*x), x, posk,
noconds=False) == (exp(-a*posk), True)
assert IFT(1/(a + 2*pi*I*x), x, -posk,
noconds=False) == (0, True)
assert IFT(1/(a + 2*pi*I*x), x, symbols('k', negative=True),
noconds=False) == (0, True)
# TODO IFT without factoring comes out as meijer g
assert factor(FT(x*exp(-a*x)*Heaviside(x), x, k), extension=I) == \
1/(a + 2*pi*I*k)**2
assert FT(exp(-a*x)*sin(b*x)*Heaviside(x), x, k) == \
b/(b**2 + (a + 2*I*pi*k)**2)
assert FT(exp(-a*x**2), x, k) == sqrt(pi)*exp(-pi**2*k**2/a)/sqrt(a)
assert IFT(sqrt(pi/a)*exp(-(pi*k)**2/a), k, x) == exp(-a*x**2)
assert FT(exp(-a*abs(x)), x, k) == 2*a/(a**2 + 4*pi**2*k**2)
# TODO IFT (comes out as meijer G)
# TODO besselj(n, x), n an integer > 0 actually can be done...
# TODO are there other common transforms (no distributions!)?
def test_sine_transform():
from sympy import EulerGamma
t = symbols("t")
w = symbols("w")
a = symbols("a")
f = Function("f")
# Test unevaluated form
assert sine_transform(f(t), t, w) == SineTransform(f(t), t, w)
assert inverse_sine_transform(
f(w), w, t) == InverseSineTransform(f(w), w, t)
assert sine_transform(1/sqrt(t), t, w) == 1/sqrt(w)
assert inverse_sine_transform(1/sqrt(w), w, t) == 1/sqrt(t)
assert sine_transform((1/sqrt(t))**3, t, w) == 2*sqrt(w)
assert sine_transform(t**(-a), t, w) == 2**(
-a + S.Half)*w**(a - 1)*gamma(-a/2 + 1)/gamma((a + 1)/2)
assert inverse_sine_transform(2**(-a + S(
1)/2)*w**(a - 1)*gamma(-a/2 + 1)/gamma(a/2 + S.Half), w, t) == t**(-a)
assert sine_transform(
exp(-a*t), t, w) == sqrt(2)*w/(sqrt(pi)*(a**2 + w**2))
assert inverse_sine_transform(
sqrt(2)*w/(sqrt(pi)*(a**2 + w**2)), w, t) == exp(-a*t)
assert sine_transform(
log(t)/t, t, w) == -sqrt(2)*sqrt(pi)*(log(w**2) + 2*EulerGamma)/4
assert sine_transform(
t*exp(-a*t**2), t, w) == sqrt(2)*w*exp(-w**2/(4*a))/(4*a**Rational(3, 2))
assert inverse_sine_transform(
sqrt(2)*w*exp(-w**2/(4*a))/(4*a**Rational(3, 2)), w, t) == t*exp(-a*t**2)
def test_cosine_transform():
from sympy import Si, Ci
t = symbols("t")
w = symbols("w")
a = symbols("a")
f = Function("f")
# Test unevaluated form
assert cosine_transform(f(t), t, w) == CosineTransform(f(t), t, w)
assert inverse_cosine_transform(
f(w), w, t) == InverseCosineTransform(f(w), w, t)
assert cosine_transform(1/sqrt(t), t, w) == 1/sqrt(w)
assert inverse_cosine_transform(1/sqrt(w), w, t) == 1/sqrt(t)
assert cosine_transform(1/(
a**2 + t**2), t, w) == sqrt(2)*sqrt(pi)*exp(-a*w)/(2*a)
assert cosine_transform(t**(
-a), t, w) == 2**(-a + S.Half)*w**(a - 1)*gamma((-a + 1)/2)/gamma(a/2)
assert inverse_cosine_transform(2**(-a + S(
1)/2)*w**(a - 1)*gamma(-a/2 + S.Half)/gamma(a/2), w, t) == t**(-a)
assert cosine_transform(
exp(-a*t), t, w) == sqrt(2)*a/(sqrt(pi)*(a**2 + w**2))
assert inverse_cosine_transform(
sqrt(2)*a/(sqrt(pi)*(a**2 + w**2)), w, t) == exp(-a*t)
assert cosine_transform(exp(-a*sqrt(t))*cos(a*sqrt(
t)), t, w) == a*exp(-a**2/(2*w))/(2*w**Rational(3, 2))
assert cosine_transform(1/(a + t), t, w) == sqrt(2)*(
(-2*Si(a*w) + pi)*sin(a*w)/2 - cos(a*w)*Ci(a*w))/sqrt(pi)
assert inverse_cosine_transform(sqrt(2)*meijerg(((S.Half, 0), ()), (
(S.Half, 0, 0), (S.Half,)), a**2*w**2/4)/(2*pi), w, t) == 1/(a + t)
assert cosine_transform(1/sqrt(a**2 + t**2), t, w) == sqrt(2)*meijerg(
((S.Half,), ()), ((0, 0), (S.Half,)), a**2*w**2/4)/(2*sqrt(pi))
assert inverse_cosine_transform(sqrt(2)*meijerg(((S.Half,), ()), ((0, 0), (S.Half,)), a**2*w**2/4)/(2*sqrt(pi)), w, t) == 1/(t*sqrt(a**2/t**2 + 1))
def test_hankel_transform():
from sympy import gamma, sqrt, exp
r = Symbol("r")
k = Symbol("k")
nu = Symbol("nu")
m = Symbol("m")
a = symbols("a")
assert hankel_transform(1/r, r, k, 0) == 1/k
assert inverse_hankel_transform(1/k, k, r, 0) == 1/r
assert hankel_transform(
1/r**m, r, k, 0) == 2**(-m + 1)*k**(m - 2)*gamma(-m/2 + 1)/gamma(m/2)
assert inverse_hankel_transform(
2**(-m + 1)*k**(m - 2)*gamma(-m/2 + 1)/gamma(m/2), k, r, 0) == r**(-m)
assert hankel_transform(1/r**m, r, k, nu) == (
2*2**(-m)*k**(m - 2)*gamma(-m/2 + nu/2 + 1)/gamma(m/2 + nu/2))
assert inverse_hankel_transform(2**(-m + 1)*k**(
m - 2)*gamma(-m/2 + nu/2 + 1)/gamma(m/2 + nu/2), k, r, nu) == r**(-m)
assert hankel_transform(r**nu*exp(-a*r), r, k, nu) == \
2**(nu + 1)*a*k**(-nu - 3)*(a**2/k**2 + 1)**(-nu - S(
3)/2)*gamma(nu + Rational(3, 2))/sqrt(pi)
assert inverse_hankel_transform(
2**(nu + 1)*a*k**(-nu - 3)*(a**2/k**2 + 1)**(-nu - Rational(3, 2))*gamma(
nu + Rational(3, 2))/sqrt(pi), k, r, nu) == r**nu*exp(-a*r)
def test_issue_7181():
assert mellin_transform(1/(1 - x), x, s) != None
def test_issue_8882():
# This is the original test.
# from sympy import diff, Integral, integrate
# r = Symbol('r')
# psi = 1/r*sin(r)*exp(-(a0*r))
# h = -1/2*diff(psi, r, r) - 1/r*psi
# f = 4*pi*psi*h*r**2
# assert integrate(f, (r, -oo, 3), meijerg=True).has(Integral) == True
# To save time, only the critical part is included.
F = -a**(-s + 1)*(4 + 1/a**2)**(-s/2)*sqrt(1/a**2)*exp(-s*I*pi)* \
sin(s*atan(sqrt(1/a**2)/2))*gamma(s)
raises(IntegralTransformError, lambda:
inverse_mellin_transform(F, s, x, (-1, oo),
**{'as_meijerg': True, 'needeval': True}))
def test_issue_7173():
from sympy import cse
x0, x1, x2, x3 = symbols('x:4')
ans = laplace_transform(sinh(a*x)*cosh(a*x), x, s)
r, e = cse(ans)
assert r == [
(x0, arg(a)),
(x1, Abs(x0)),
(x2, pi/2),
(x3, Abs(x0 + pi))]
assert e == [
a/(-4*a**2 + s**2),
0,
((x1 <= x2) | (x1 < x2)) & ((x3 <= x2) | (x3 < x2))]
def test_issue_8514():
from sympy import simplify
a, b, c, = symbols('a b c', positive=True)
t = symbols('t', positive=True)
ft = simplify(inverse_laplace_transform(1/(a*s**2+b*s+c),s, t))
assert ft == (I*exp(t*cos(atan2(0, -4*a*c + b**2)/2)*sqrt(Abs(4*a*c -
b**2))/a)*sin(t*sin(atan2(0, -4*a*c + b**2)/2)*sqrt(Abs(
4*a*c - b**2))/(2*a)) + exp(t*cos(atan2(0, -4*a*c + b**2)
/2)*sqrt(Abs(4*a*c - b**2))/a)*cos(t*sin(atan2(0, -4*a*c
+ b**2)/2)*sqrt(Abs(4*a*c - b**2))/(2*a)) + I*sin(t*sin(
atan2(0, -4*a*c + b**2)/2)*sqrt(Abs(4*a*c - b**2))/(2*a))
- cos(t*sin(atan2(0, -4*a*c + b**2)/2)*sqrt(Abs(4*a*c -
b**2))/(2*a)))*exp(-t*(b + cos(atan2(0, -4*a*c + b**2)/2)
*sqrt(Abs(4*a*c - b**2)))/(2*a))/sqrt(-4*a*c + b**2)
def test_issue_12591():
x, y = symbols("x y", real=True)
assert fourier_transform(exp(x), x, y) == FourierTransform(exp(x), x, y)
def test_issue_14692():
b = Symbol('b', negative=True)
assert laplace_transform(1/(I*x - b), x, s) == \
(-I*exp(I*b*s)*expint(1, b*s*exp_polar(I*pi/2)), 0, True)
|
0a6a21a0873316fbfcb1c1091f6a8ab98bcbe57d5a1a49d991eef26491cf59b7 | """
Parser for FullForm[Downvalues[]] of Mathematica rules.
This parser is customised to parse the output in MatchPy rules format. Multiple
`Constraints` are divided into individual `Constraints` because it helps the
MatchPy's `ManyToOneReplacer` to backtrack earlier and improve the speed.
Parsed output is formatted into readable format by using `sympify` and print the
expression using `sstr`. This replaces `And`, `Mul`, 'Pow' by their respective
symbols.
Mathematica
===========
To get the full form from Wolfram Mathematica, type:
```
ShowSteps = False
Import["RubiLoader.m"]
Export["output.txt", ToString@FullForm@DownValues@Int]
```
The file ``output.txt`` will then contain the rules in parseable format.
References
==========
[1] http://reference.wolfram.com/language/ref/FullForm.html
[2] http://reference.wolfram.com/language/ref/DownValues.html
[3] https://gist.github.com/Upabjojr/bc07c49262944f9c1eb0
"""
import re
import os
import inspect
from sympy import sympify, Function, Set, Symbol
from sympy.printing import StrPrinter
from sympy.utilities.misc import debug
class RubiStrPrinter(StrPrinter):
def _print_Not(self, expr):
return "Not(%s)" % self._print(expr.args[0])
def rubi_printer(expr, **settings):
return RubiStrPrinter(settings).doprint(expr)
replacements = dict( # Mathematica equivalent functions in SymPy
Times="Mul",
Plus="Add",
Power="Pow",
Log='log',
Exp='exp',
Sqrt='sqrt',
Cos='cos',
Sin='sin',
Tan='tan',
Cot='1/tan',
cot='1/tan',
Sec='1/cos',
sec='1/cos',
Csc='1/sin',
csc='1/sin',
ArcSin='asin',
ArcCos='acos',
# ArcTan='atan',
ArcCot='acot',
ArcSec='asec',
ArcCsc='acsc',
Sinh='sinh',
Cosh='cosh',
Tanh='tanh',
Coth='1/tanh',
coth='1/tanh',
Sech='1/cosh',
sech='1/cosh',
Csch='1/sinh',
csch='1/sinh',
ArcSinh='asinh',
ArcCosh='acosh',
ArcTanh='atanh',
ArcCoth='acoth',
ArcSech='asech',
ArcCsch='acsch',
Expand='expand',
Im='im',
Re='re',
Flatten='flatten',
Polylog='polylog',
Cancel='cancel',
#Gamma='gamma',
TrigExpand='expand_trig',
Sign='sign',
Simplify='simplify',
Defer='UnevaluatedExpr',
Identity = 'S',
Sum = 'Sum_doit',
Module = 'With',
Block = 'With',
Null = 'None'
)
temporary_variable_replacement = { # Temporarily rename because it can raise errors while sympifying
'gcd' : "_gcd",
'jn' : "_jn",
}
permanent_variable_replacement = { # Permamenely rename these variables
r"\[ImaginaryI]" : 'ImaginaryI',
"$UseGamma": '_UseGamma',
}
# These functions have different return type in different cases. So better to use a try and except in the constraints, when any of these appear
f_diff_return_type = ['BinomialParts', 'BinomialDegree', 'TrinomialParts', 'GeneralizedBinomialParts', 'GeneralizedTrinomialParts', 'PseudoBinomialParts', 'PerfectPowerTest',
'SquareFreeFactorTest', 'SubstForFractionalPowerOfQuotientOfLinears', 'FractionalPowerOfQuotientOfLinears', 'InverseFunctionOfQuotientOfLinears',
'FractionalPowerOfSquareQ', 'FunctionOfLinear', 'FunctionOfInverseLinear', 'FunctionOfTrig', 'FindTrigFactor', 'FunctionOfLog',
'PowerVariableExpn', 'FunctionOfSquareRootOfQuadratic', 'SubstForFractionalPowerOfLinear', 'FractionalPowerOfLinear', 'InverseFunctionOfLinear',
'Divides', 'DerivativeDivides', 'TrigSquare', 'SplitProduct', 'SubstForFractionalPowerOfQuotientOfLinears', 'InverseFunctionOfQuotientOfLinears',
'FunctionOfHyperbolic', 'SplitSum']
def contains_diff_return_type(a):
"""
This function returns whether an expression contains functions which have different return types in
diiferent cases.
"""
if isinstance(a, list):
for i in a:
if contains_diff_return_type(i):
return True
elif type(a) == Function('With') or type(a) == Function('Module'):
for i in f_diff_return_type:
if a.has(Function(i)):
return True
else:
if a in f_diff_return_type:
return True
return False
def parse_full_form(wmexpr):
"""
Parses FullForm[Downvalues[]] generated by Mathematica
"""
out = []
stack = [out]
generator = re.finditer(r'[\[\],]', wmexpr)
last_pos = 0
for match in generator:
if match is None:
break
position = match.start()
last_expr = wmexpr[last_pos:position].replace(',', '').replace(']', '').replace('[', '').strip()
if match.group() == ',':
if last_expr != '':
stack[-1].append(last_expr)
elif match.group() == ']':
if last_expr != '':
stack[-1].append(last_expr)
stack.pop()
current_pos = stack[-1]
elif match.group() == '[':
stack[-1].append([last_expr])
stack.append(stack[-1][-1])
last_pos = match.end()
return out[0]
def get_default_values(parsed, default_values={}):
"""
Returns Optional variables and their values in the pattern
"""
if not isinstance(parsed, list):
return default_values
if parsed[0] == "Times": # find Default arguments for "Times"
for i in parsed[1:]:
if i[0] == "Optional":
default_values[(i[1][1])] = 1
if parsed[0] == "Plus": # find Default arguments for "Plus"
for i in parsed[1:]:
if i[0] == "Optional":
default_values[(i[1][1])] = 0
if parsed[0] == "Power": # find Default arguments for "Power"
for i in parsed[1:]:
if i[0] == "Optional":
default_values[(i[1][1])] = 1
if len(parsed) == 1:
return default_values
for i in parsed:
default_values = get_default_values(i, default_values)
return default_values
def add_wildcards(string, optional={}):
"""
Replaces `Pattern(variable)` by `variable` in `string`.
Returns the free symbols present in the string.
"""
symbols = [] # stores symbols present in the expression
p = r'(Optional\(Pattern\((\w+), Blank\)\))'
matches = re.findall(p, string)
for i in matches:
string = string.replace(i[0], "WC('{}', S({}))".format(i[1], optional[i[1]]))
symbols.append(i[1])
p = r'(Pattern\((\w+), Blank\))'
matches = re.findall(p, string)
for i in matches:
string = string.replace(i[0], i[1] + '_')
symbols.append(i[1])
p = r'(Pattern\((\w+), Blank\(Symbol\)\))'
matches = re.findall(p, string)
for i in matches:
string = string.replace(i[0], i[1] + '_')
symbols.append(i[1])
return string, symbols
def seperate_freeq(s, variables=[], x=None):
"""
Returns list of symbols in FreeQ.
"""
if s[0] == 'FreeQ':
if len(s[1]) == 1:
variables = [s[1]]
else:
variables = s[1][1:]
x = s[2]
else:
for i in s[1:]:
variables, x = seperate_freeq(i, variables, x)
return variables, x
return variables, x
def parse_freeq(l, x, cons_index, cons_dict, cons_import, symbols=None):
"""
Converts FreeQ constraints into MatchPy constraint
"""
res = []
cons = ''
for i in l:
if isinstance(i, str):
r = ' return FreeQ({}, {})'.format(i, x)
# First it checks if a constraint is already present in `cons_dict`, If yes, use it else create a new one.
if r not in cons_dict.values():
cons_index += 1
c = '\n def cons_f{}({}, {}):\n'.format(cons_index, i, x)
c += r
c += '\n\n cons{} = CustomConstraint({})\n'.format(cons_index, 'cons_f{}'.format(cons_index))
cons_name = 'cons{}'.format(cons_index)
cons_dict[cons_name] = r
else:
c = ''
cons_name = next(key for key, value in sorted(cons_dict.items()) if value == r)
elif isinstance(i, list):
s = sorted(set(get_free_symbols(i, symbols)))
s = ', '.join(s)
r = ' return FreeQ({}, {})'.format(generate_sympy_from_parsed(i), x)
if r not in cons_dict.values():
cons_index += 1
c = '\n def cons_f{}({}):\n'.format(cons_index, s)
c += r
c += '\n\n cons{} = CustomConstraint({})\n'.format(cons_index, 'cons_f{}'.format(cons_index))
cons_name = 'cons{}'.format(cons_index)
cons_dict[cons_name] = r
else:
c = ''
cons_name = next(key for key, value in cons_dict.items() if value == r)
if cons_name not in cons_import:
cons_import.append(cons_name)
res.append(cons_name)
cons += c
if res != []:
return ', ' + ', '.join(res), cons, cons_index
return '', cons, cons_index
def generate_sympy_from_parsed(parsed, wild=False, symbols=[], replace_Int=False):
"""
Parses list into Python syntax.
Parameters
==========
wild : When set to True, the symbols are replaced as wild symbols.
symbols : Symbols already present in the pattern.
replace_Int: when set to True, `Int` is replaced by `Integral`(used to parse pattern).
"""
out = ""
if not isinstance(parsed, list):
try: # return S(number) if parsed is Number
float(parsed)
return "S({})".format(parsed)
except:
pass
if parsed in symbols:
if wild:
return parsed + '_'
return parsed
if parsed[0] == 'Rational':
return 'S({})/S({})'.format(generate_sympy_from_parsed(parsed[1], wild=wild, symbols=symbols, replace_Int=replace_Int), generate_sympy_from_parsed(parsed[2], wild=wild, symbols=symbols, replace_Int=replace_Int))
if parsed[0] in replacements:
out += replacements[parsed[0]]
elif parsed[0] == 'Int' and replace_Int:
out += 'Integral'
else:
out += parsed[0]
if len(parsed) == 1:
return out
result = [generate_sympy_from_parsed(i, wild=wild, symbols=symbols, replace_Int=replace_Int) for i in parsed[1:]]
if '' in result:
result.remove('')
out += "("
out += ", ".join(result)
out += ")"
return out
def get_free_symbols(s, symbols, free_symbols=None):
"""
Returns free_symbols present in `s`.
"""
free_symbols = free_symbols or []
if not isinstance(s, list):
if s in symbols:
free_symbols.append(s)
return free_symbols
for i in s:
free_symbols = get_free_symbols(i, symbols, free_symbols)
return free_symbols
def set_matchq_in_constraint(a, cons_index):
"""
Takes care of the case, when a pattern matching has to be done inside a constraint.
"""
lst = []
res = ''
if isinstance(a, list):
if a[0] == 'MatchQ':
s = a
optional = get_default_values(s, {})
r = generate_sympy_from_parsed(s, replace_Int=True)
r, free_symbols = add_wildcards(r, optional=optional)
free_symbols = sorted(set(free_symbols)) # remove common symbols
r = sympify(r, locals={"Or": Function("Or"), "And": Function("And"), "Not":Function("Not")})
pattern = r.args[1].args[0]
cons = r.args[1].args[1]
pattern = rubi_printer(pattern, sympy_integers=True)
pattern = setWC(pattern)
res = ' def _cons_f_{}({}):\n return {}\n'.format(cons_index, ', '.join(free_symbols), cons)
res += ' _cons_{} = CustomConstraint(_cons_f_{})\n'.format(cons_index, cons_index)
res += ' pat = Pattern(UtilityOperator({}, x), _cons_{})\n'.format(pattern, cons_index)
res += ' result_matchq = is_match(UtilityOperator({}, x), pat)'.format(r.args[0])
return "result_matchq", res
else:
for i in a:
if isinstance(i, list):
r = set_matchq_in_constraint(i, cons_index)
lst.append(r[0])
res = r[1]
else:
lst.append(i)
return lst, res
def _divide_constriant(s, symbols, cons_index, cons_dict, cons_import):
# Creates a CustomConstraint of the form `CustomConstraint(lambda a, x: FreeQ(a, x))`
lambda_symbols = sorted(set(get_free_symbols(s, symbols, [])))
r = generate_sympy_from_parsed(s)
r = sympify(r, locals={"Or": Function("Or"), "And": Function("And"), "Not":Function("Not")})
if r.has(Function('MatchQ')):
match_res = set_matchq_in_constraint(s, cons_index)
res = match_res[1]
res += '\n return {}'.format(rubi_printer(sympify(generate_sympy_from_parsed(match_res[0]), locals={"Or": Function("Or"), "And": Function("And"), "Not":Function("Not")}), sympy_integers = True))
elif contains_diff_return_type(s):
res = ' try:\n return {}\n except (TypeError, AttributeError):\n return False'.format(rubi_printer(r, sympy_integers=True))
else:
res = ' return {}'.format(rubi_printer(r, sympy_integers=True))
# First it checks if a constraint is already present in `cons_dict`, If yes, use it else create a new one.
if not res in cons_dict.values():
cons_index += 1
cons = '\n def cons_f{}({}):\n'.format(cons_index, ', '.join(lambda_symbols))
if 'x' in lambda_symbols:
cons += ' if isinstance(x, (int, Integer, float, Float)):\n return False\n'
cons += res
cons += '\n\n cons{} = CustomConstraint({})\n'.format(cons_index, 'cons_f{}'.format(cons_index))
cons_name = 'cons{}'.format(cons_index)
cons_dict[cons_name] = res
else:
cons = ''
cons_name = next(key for key, value in cons_dict.items() if value == res)
if cons_name not in cons_import:
cons_import.append(cons_name)
return cons_name, cons, cons_index
def divide_constraint(s, symbols, cons_index, cons_dict, cons_import):
"""
Divides multiple constraints into smaller constraints.
Parameters
==========
s : constraint as list
symbols : all the symbols present in the expression
"""
result =[]
cons = ''
if s[0] == 'And':
for i in s[1:]:
if i[0]!= 'FreeQ':
a = _divide_constriant(i, symbols, cons_index, cons_dict, cons_import)
result.append(a[0])
cons += a[1]
cons_index = a[2]
else:
a = _divide_constriant(s, symbols, cons_index, cons_dict, cons_import)
result.append(a[0])
cons += a[1]
cons_index = a[2]
r = ['']
for i in result:
if i != '':
r.append(i)
return ', '.join(r),cons, cons_index
def setWC(string):
"""
Replaces `WC(a, b)` by `WC('a', S(b))`
"""
p = r'(WC\((\w+), S\(([-+]?\d)\)\))'
matches = re.findall(p, string)
for i in matches:
string = string.replace(i[0], "WC('{}', S({}))".format(i[1], i[2]))
return string
def process_return_type(a1, L):
"""
Functions like `Set`, `With` and `CompoundExpression` has to be taken special care.
"""
a = sympify(a1[1])
x = ''
processed = False
return_value = ''
if type(a) == Function('With') or type(a) == Function('Module'):
for i in a.args:
for s in i.args:
if isinstance(s, Set) and not s in L:
x += '\n {} = {}'.format(s.args[0], rubi_printer(s.args[1], sympy_integers=True))
if not type(i) in (Function('List'), Function('CompoundExpression')) and not i.has(Function('CompoundExpression')):
return_value = i
processed = True
elif type(i) == Function('CompoundExpression'):
return_value = i.args[-1]
processed = True
elif type(i.args[0]) == Function('CompoundExpression'):
C = i.args[0]
return_value = '{}({}, {})'.format(i.func, C.args[-1], i.args[1])
processed = True
return x, return_value, processed
def extract_set(s, L):
"""
this function extracts all `Set` functions
"""
lst = []
if isinstance(s, Set) and not s in L:
lst.append(s)
else:
try:
for i in s.args:
lst += extract_set(i, L)
except: # when s has no attribute args (like `bool`)
pass
return lst
def replaceWith(s, symbols, index):
"""
Replaces `With` and `Module by python functions`
"""
return_type = None
with_value = ''
if type(s) == Function('With') or type(s) == Function('Module'):
constraints = ' '
result = '\n\n\ndef With{}({}):'.format(index, ', '.join(symbols))
if type(s.args[0]) == Function('List'): # get all local variables of With and Module
L = list(s.args[0].args)
else:
L = [s.args[0]]
lst = []
for i in s.args[1:]:
lst += extract_set(i, L)
L += lst
for i in L: # define local variables
if isinstance(i, Set):
with_value += '\n {} = {}'.format(i.args[0], rubi_printer(i.args[1], sympy_integers=True))
elif isinstance(i, Symbol):
with_value += "\n {} = Symbol('{}')".format(i, i)
#result += with_value
if type(s.args[1]) == Function('CompoundExpression'): # Expand CompoundExpression
C = s.args[1]
result += with_value
if isinstance(C.args[0], Set):
result += '\n {} = {}'.format(C.args[0].args[0], C.args[0].args[1])
result += '\n return {}'.format(rubi_printer(C.args[1], sympy_integers=True))
return result, constraints, return_type
elif type(s.args[1]) == Function('Condition'):
C = s.args[1]
if len(C.args) == 2:
if all(j in symbols for j in [str(i) for i in C.free_symbols]):
result += with_value
#constraints += 'CustomConstraint(lambda {}: {})'.format(', '.join([str(i) for i in C.free_symbols]), sstr(C.args[1], sympy_integers=True))
result += '\n return {}'.format(rubi_printer(C.args[0], sympy_integers=True))
else:
if 'x' in symbols:
result += '\n if isinstance(x, (int, Integer, float, Float)):\n return False'
if contains_diff_return_type(s):
n_with_value = with_value.replace('\n', '\n ')
result += '\n try:{}\n res = {}'.format(n_with_value, rubi_printer(C.args[1], sympy_integers=True))
result += '\n except (TypeError, AttributeError):\n return False'
result += '\n if res:'
else:
result+=with_value
result += '\n if {}:'.format(rubi_printer(C.args[1], sympy_integers=True))
return_type = (with_value, rubi_printer(C.args[0], sympy_integers=True))
return_type1 = process_return_type(return_type, L)
if return_type1[2]:
return_type = (with_value+return_type1[0], rubi_printer(return_type1[1]))
result += '\n return True'
result += '\n return False'
constraints = ', CustomConstraint(With{})'.format(index)
return result, constraints, return_type
elif type(s.args[1]) == Function('Module') or type(s.args[1]) == Function('With'):
C = s.args[1]
result += with_value
return_type = (with_value, rubi_printer(C, sympy_integers=True))
return_type1 = process_return_type(return_type, L)
if return_type1[2]:
return_type = (with_value+return_type1[0], rubi_printer(return_type1[1]))
result += return_type1[0]
result += '\n return {}'.format(rubi_printer(return_type1[1]))
return result, constraints, None
elif s.args[1].has(Function("CompoundExpression")):
C = s.args[1].args[0]
result += with_value
if isinstance(C.args[0], Set):
result += '\n {} = {}'.format(C.args[0].args[0], C.args[0].args[1])
result += '\n return {}({}, {})'.format(s.args[1].func, C.args[-1], s.args[1].args[1])
return result, constraints, None
result += with_value
result += '\n return {}'.format(rubi_printer(s.args[1], sympy_integers=True))
return result, constraints, return_type
else:
return rubi_printer(s, sympy_integers=True), '', return_type
def downvalues_rules(r, header, cons_dict, cons_index, index):
"""
Function which generates parsed rules by substituting all possible
combinations of default values.
"""
rules = '['
parsed = '\n\n'
repl_funcs = '\n\n'
cons = ''
cons_import = [] # it contains name of constraints that need to be imported for rules.
for i in r:
debug('parsing rule {}'.format(r.index(i) + 1))
# Parse Pattern
if i[1][1][0] == 'Condition':
p = i[1][1][1].copy()
else:
p = i[1][1].copy()
optional = get_default_values(p, {})
pattern = generate_sympy_from_parsed(p.copy(), replace_Int=True)
pattern, free_symbols = add_wildcards(pattern, optional=optional)
free_symbols = sorted(set(free_symbols)) #remove common symbols
# Parse Transformed Expression and Constraints
if i[2][0] == 'Condition': # parse rules without constraints separately
constriant, constraint_def, cons_index = divide_constraint(i[2][2], free_symbols, cons_index, cons_dict, cons_import) # separate And constraints into individual constraints
FreeQ_vars, FreeQ_x = seperate_freeq(i[2][2].copy()) # separate FreeQ into individual constraints
transformed = generate_sympy_from_parsed(i[2][1].copy(), symbols=free_symbols)
else:
constriant = ''
constraint_def = ''
FreeQ_vars, FreeQ_x = [], []
transformed = generate_sympy_from_parsed(i[2].copy(), symbols=free_symbols)
FreeQ_constraint, free_cons_def, cons_index = parse_freeq(FreeQ_vars, FreeQ_x, cons_index, cons_dict, cons_import, free_symbols)
pattern = sympify(pattern, locals={"Or": Function("Or"), "And": Function("And"), "Not":Function("Not") })
pattern = rubi_printer(pattern, sympy_integers=True)
pattern = setWC(pattern)
transformed = sympify(transformed, locals={"Or": Function("Or"), "And": Function("And"), "Not":Function("Not") })
constraint_def = constraint_def + free_cons_def
cons += constraint_def
index += 1
# below are certain if - else condition depending on various situation that may be encountered
if type(transformed) == Function('With') or type(transformed) == Function('Module'): # define separate function when With appears
transformed, With_constraints, return_type = replaceWith(transformed, free_symbols, index)
if return_type is None:
repl_funcs += '{}'.format(transformed)
parsed += '\n pattern' + str(index) + ' = Pattern(' + pattern + '' + FreeQ_constraint + '' + constriant + ')'
parsed += '\n ' + 'rule' + str(index) + ' = ReplacementRule(' + 'pattern' + rubi_printer(index, sympy_integers=True) + ', With{}'.format(index) + ')\n'
else:
repl_funcs += '{}'.format(transformed)
parsed += '\n pattern' + str(index) + ' = Pattern(' + pattern + '' + FreeQ_constraint + '' + constriant + With_constraints + ')'
repl_funcs += '\n\n\ndef replacement{}({}):\n'.format(
index, ', '.join(free_symbols)
) + return_type[0] + '\n return '.format(index) + return_type[1]
parsed += '\n ' + 'rule' + str(index) + ' = ReplacementRule(' + 'pattern' + rubi_printer(index, sympy_integers=True) + ', replacement{}'.format(index) + ')\n'
else:
transformed = rubi_printer(transformed, sympy_integers=True)
parsed += '\n pattern' + str(index) + ' = Pattern(' + pattern + '' + FreeQ_constraint + '' + constriant + ')'
repl_funcs += '\n\n\ndef replacement{}({}):\n return '.format(index, ', '.join(free_symbols), index) + transformed
parsed += '\n ' + 'rule' + str(index) + ' = ReplacementRule(' + 'pattern' + rubi_printer(index, sympy_integers=True) + ', replacement{}'.format(index) + ')\n'
rules += 'rule{}, '.format(index)
rules += ']'
parsed += ' return ' + rules +'\n'
header += ' from sympy.integrals.rubi.constraints import ' + ', '.join(word for word in cons_import)
parsed = header + parsed + repl_funcs
return parsed, cons_index, cons, index
def rubi_rule_parser(fullform, header=None, module_name='rubi_object'):
"""
Parses rules in MatchPy format.
Parameters
==========
fullform : FullForm of the rule as string.
header : Header imports for the file. Uses default imports if None.
module_name : name of RUBI module
References
==========
[1] http://reference.wolfram.com/language/ref/FullForm.html
[2] http://reference.wolfram.com/language/ref/DownValues.html
[3] https://gist.github.com/Upabjojr/bc07c49262944f9c1eb0
"""
if header is None: # use default header values
path_header = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
header = open(os.path.join(path_header, "header.py.txt")).read()
header = header.format(module_name)
cons_dict = {} # dict keeps track of constraints that has been encountered, thus avoids repetition of constraints.
cons_index = 0 # for index of a constraint
index = 0 # indicates the number of a rule.
cons = ''
# Temporarily rename these variables because it
# can raise errors while sympifying
for i in temporary_variable_replacement:
fullform = fullform.replace(i, temporary_variable_replacement[i])
# Permanently rename these variables
for i in permanent_variable_replacement:
fullform = fullform.replace(i, permanent_variable_replacement[i])
rules = []
for i in parse_full_form(fullform): # separate all rules
if i[0] == 'RuleDelayed':
rules.append(i)
parsed = downvalues_rules(rules, header, cons_dict, cons_index, index)
result = parsed[0].strip() + '\n'
cons_index = parsed[1]
cons += parsed[2]
index = parsed[3]
# Replace temporary variables by actual values
for i in temporary_variable_replacement:
cons = cons.replace(temporary_variable_replacement[i], i)
result = result.replace(temporary_variable_replacement[i], i)
cons = "\n".join(header.split("\n")[:-2]) + '\n' + cons
return result, cons
|
2f5df2342d201a8880e40fe5b9f2be7d0e942511aa04374c556d644895f89a60 | from sympy.integrals.rubi.parsetools.parse import generate_sympy_from_parsed, parse_full_form, rubi_printer
from sympy import sympify
from sympy.integrals.rubi.utility_function import List, If
import os, inspect
def rubi_sstr(a):
return rubi_printer(a, sympy_integers=True)
def generate_test_file():
'''
This function is assuming the name of file containing the fullform is test_1.m.
It can be changes as per use.
For more details, see
`https://github.com/sympy/sympy/wiki/Rubi-parsing-guide#parsing-tests`
'''
res =[]
file_name = 'test_1.m'
with open(file_name) as myfile:
fullform =myfile.read().replace('\n', '')
fullform = fullform.replace('$VersionNumber', 'version_number')
fullform = fullform.replace('Defer[Int][', 'Integrate[')
path_header = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
h = open(os.path.join(path_header, "header.py.txt")).read()
header = "import sys\nfrom sympy.external import import_module\nmatchpy = import_module({})".format('\"matchpy\"')
header += "\nif not matchpy:\n disabled = True\n"
header += "if sys.version_info[:2] < (3, 6):\n disabled = True\n"
header += "\n".join(h.split("\n")[8:-9])
header += "from sympy.integrals.rubi.rubi import rubi_integrate\n"
header += "from sympy import Integral as Integrate, exp, log\n"
header += "\na, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z = symbols('a b c d e f g h i j k l m n o p q r s t u v w x y z')"
header += "\nA, B, C, F, G, H, J, K, L, M, N, O, P, Q, R, T, U, V, W, X, Y, Z = symbols('A B C F G H J K L M N O P Q R T U V W X Y Z')"
header += "\n\ndef {}():\n".format(file_name[0:-2])
s = parse_full_form(fullform)
tests = []
for i in s:
res[:] = []
if i[0] == 'HoldComplete':
ss = sympify(generate_sympy_from_parsed(i[1]), locals = { 'version_number' : 11, 'If' : If})
ss = List(*ss.args)
tests.append(ss)
t = ''
for a in tests:
if len(a) == 5:
r = 'rubi_integrate({}, x)'.format(rubi_sstr(a[0]))
t += '\n assert rubi_test({}, {}, {}, expand=True, _diff=True, _numerical=True) or rubi_test({}, {}, {}, expand=True, _diff=True, _numerical=True)'.format(r, rubi_sstr(a[1]), rubi_sstr(a[3]), r, rubi_sstr(a[1]),rubi_sstr(a[4]))
else:
r = 'rubi_integrate({}, x)'.format(rubi_sstr(a[0]))
t += '\n assert rubi_test({}, {}, {}, expand=True, _diff=True, _numerical=True)'.format(r, rubi_sstr(a[1]), rubi_sstr(a[3]))
t = header+t+'\n'
test = open('parsed_tests.py', 'w')
test.write(t)
test.close()
|
b95ab2defbc418ab64cb418fa5f9c818216cd141f2265b01c79490190c369a70 | import os
import inspect
from sympy.integrals.rubi.parsetools.parse import (parse_full_form, downvalues_rules, temporary_variable_replacement,
permanent_variable_replacement)
def generate_rules_from_downvalues():
"""
This function generate rules and saves in file. For more details,
see `https://github.com/sympy/sympy/wiki/Rubi-parsing-guide`
"""
cons_dict = {}
cons_index = 0
index = 0
cons = ''
input = ["Integrand_simplification.txt", "Linear_products.txt", "Quadratic_products.txt", "Binomial_products.txt",
"Trinomial_products.txt", "Miscellaneous_algebra.txt", "Piecewise_linear.txt", "Exponentials.txt", "Logarithms.txt",
"Sine.txt", "Tangent.txt", "Secant.txt", "Miscellaneous_trig.txt", "Inverse_trig.txt", "Hyperbolic.txt",
"Inverse_hyperbolic.txt", "Special_functions.txt", "Miscellaneous_integration.txt"]
output = ['integrand_simplification.py', 'linear_products.py', 'quadratic_products.py', 'binomial_products.py', 'trinomial_products.py',
'miscellaneous_algebraic.py' ,'piecewise_linear.py', 'exponential.py', 'logarithms.py', 'sine.py', 'tangent.py', 'secant.py', 'miscellaneous_trig.py',
'inverse_trig.py', 'hyperbolic.py', 'inverse_hyperbolic.py', 'special_functions.py', 'miscellaneous_integration.py']
for k in range(0, 18):
module_name = output[k][0:-3]
path_header = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
header = open(os.path.join(path_header, "header.py.txt")).read()
header = header.format(module_name)
with open(input[k]) as myfile:
fullform =myfile.read().replace('\n', '')
for i in temporary_variable_replacement:
fullform = fullform.replace(i, temporary_variable_replacement[i])
# Permanently rename these variables
for i in permanent_variable_replacement:
fullform = fullform.replace(i, permanent_variable_replacement[i])
rules = []
for i in parse_full_form(fullform): # separate all rules
if i[0] == 'RuleDelayed':
rules.append(i)
parsed = downvalues_rules(rules, header, cons_dict, cons_index, index)
result = parsed[0].strip() + '\n'
cons_index = parsed[1]
cons += parsed[2]
index = parsed[3]
# Replace temporary variables by actual values
for i in temporary_variable_replacement:
cons = cons.replace(temporary_variable_replacement[i], i)
result = result.replace(temporary_variable_replacement[i], i)
file = open(output[k],'w')
file.write(str(result))
file.close()
cons = "\n".join(header.split("\n")[:-2])+ '\n' + cons
constraints = open('constraints.py', 'w')
constraints.write(str(cons))
constraints.close()
|
5bcbb18a566259ac362beac4af2a5897c0b04447f8fd34b52ba52022c0e34717 | import sys
from sympy.external import import_module
matchpy = import_module("matchpy")
if not matchpy:
#bin/test will not execute any tests now
disabled = True
if sys.version_info[:2] < (3, 6):
disabled = True
from sympy.integrals.rubi.utility_function import (Set, With, Module,
Scan, MapAnd, FalseQ, ZeroQ, NegativeQ, NonzeroQ, FreeQ, List, Log,
PositiveQ, PositiveIntegerQ, NegativeIntegerQ, IntegerQ, IntegersQ,
ComplexNumberQ, RealNumericQ, PositiveOrZeroQ,
NegativeOrZeroQ, FractionOrNegativeQ, NegQ, Equal, Unequal, IntPart,
FracPart, RationalQ, ProductQ, SumQ, NonsumQ, First, Rest,
SqrtNumberQ, LinearQ, Sqrt, ArcCosh, Coefficient,
Denominator, Hypergeometric2F1, Not, Simplify, FractionalPart, IntegerPart,
AppellF1, PolynomialQuotient, ArcTan, ArcTanh, ArcSin, ArcSinh, ArcCos,
ArcCsc, ArcCsch, Sinh, Coth, LessEqual, Less, Greater,
GreaterEqual, FractionQ, IntLinearcQ, Expand, IndependentQ, PowerQ,
IntegerPowerQ, PositiveIntegerPowerQ, FractionalPowerQ, AtomQ, ExpQ, LogQ,
Head, MemberQ, TrigQ, SinQ, CosQ, TanQ, CotQ, SecQ, CscQ, HyperbolicQ,
SinhQ, CoshQ, TanhQ, CothQ, SechQ, CschQ, InverseTrigQ, SinCosQ, SinhCoshQ,
LeafCount, Numerator, NumberQ, NumericQ, Length, ListQ, Im, Re,
InverseHyperbolicQ, InverseFunctionQ, EqQ, FractionalPowerFreeQ,
ComplexFreeQ, PolynomialQ, FactorSquareFree, PowerOfLinearQ, Exponent,
QuadraticQ, LinearPairQ, BinomialParts, TrinomialParts, PolyQ, EvenQ, OddQ,
PerfectSquareQ, NiceSqrtAuxQ, NiceSqrtQ, Together, PosAux, PosQ,
CoefficientList, ReplaceAll, ExpandLinearProduct, GCD, ContentFactor,
NumericFactor, NonnumericFactors, MakeAssocList, GensymSubst, KernelSubst,
ExpandExpression, Apart, SmartApart, MatchQ, PolynomialQuotientRemainder,
FreeFactors, NonfreeFactors, RemoveContentAux, RemoveContent, FreeTerms,
NonfreeTerms, ExpandAlgebraicFunction, CollectReciprocals, ExpandCleanup,
AlgebraicFunctionQ, Coeff, LeadTerm, RemainingTerms, LeadFactor,
RemainingFactors, LeadBase, LeadDegree, Numer, Denom, hypergeom, Expon,
MergeMonomials, PolynomialDivide, BinomialQ, TrinomialQ,
GeneralizedBinomialQ, GeneralizedTrinomialQ, FactorSquareFreeList,
PerfectPowerTest, SquareFreeFactorTest, RationalFunctionQ,
RationalFunctionFactors, NonrationalFunctionFactors, Reverse,
RationalFunctionExponents, RationalFunctionExpand, ExpandIntegrand, SimplerQ,
SimplerSqrtQ, SumSimplerQ, BinomialDegree, TrinomialDegree,
CancelCommonFactors, SimplerIntegrandQ, GeneralizedBinomialDegree,
GeneralizedBinomialParts, GeneralizedTrinomialDegree,
GeneralizedTrinomialParts, MonomialQ, MonomialSumQ, MinimumMonomialExponent,
MonomialExponent, LinearMatchQ, PowerOfLinearMatchQ, QuadraticMatchQ,
CubicMatchQ, BinomialMatchQ, TrinomialMatchQ, GeneralizedBinomialMatchQ,
GeneralizedTrinomialMatchQ, QuotientOfLinearsMatchQ, PolynomialTermQ,
PolynomialTerms, NonpolynomialTerms, PseudoBinomialParts,
NormalizePseudoBinomial, PseudoBinomialPairQ, PseudoBinomialQ,
PolynomialGCD, PolyGCD, AlgebraicFunctionFactors, NonalgebraicFunctionFactors,
QuotientOfLinearsP, QuotientOfLinearsParts, QuotientOfLinearsQ, Flatten,
Sort, AbsurdNumberQ, AbsurdNumberFactors, NonabsurdNumberFactors,
SumSimplerAuxQ, Prepend, Drop, CombineExponents, FactorInteger,
FactorAbsurdNumber, SubstForInverseFunction, SubstForFractionalPower,
SubstForFractionalPowerOfQuotientOfLinears, FractionalPowerOfQuotientOfLinears,
SubstForFractionalPowerQ, SubstForFractionalPowerAuxQ, FractionalPowerOfSquareQ,
FractionalPowerSubexpressionQ, Apply, FactorNumericGcd, MergeableFactorQ,
MergeFactor, MergeFactors, TrigSimplifyQ, TrigSimplify, TrigSimplifyRecur,
Order, FactorOrder, Smallest, OrderedQ, MinimumDegree, PositiveFactors, Sign,
NonpositiveFactors, PolynomialInAuxQ, PolynomialInQ, ExponentInAux, ExponentIn,
PolynomialInSubstAux, PolynomialInSubst, Distrib, DistributeDegree,
FunctionOfPower, DivideDegreesOfFactors, MonomialFactor, FullSimplify,
FunctionOfLinearSubst, FunctionOfLinear, NormalizeIntegrand,
NormalizeIntegrandAux, NormalizeIntegrandFactor, NormalizeIntegrandFactorBase,
NormalizeTogether, NormalizeLeadTermSigns, AbsorbMinusSign,
NormalizeSumFactors, SignOfFactor, NormalizePowerOfLinear,
SimplifyIntegrand, SimplifyTerm, TogetherSimplify, SmartSimplify,
SubstForExpn, ExpandToSum, UnifySum, UnifyTerms, UnifyTerm, CalculusQ,
FunctionOfInverseLinear, PureFunctionOfSinhQ, PureFunctionOfTanhQ,
PureFunctionOfCoshQ, IntegerQuotientQ, OddQuotientQ, EvenQuotientQ,
FindTrigFactor, FunctionOfSinhQ, FunctionOfCoshQ, OddHyperbolicPowerQ,
FunctionOfTanhQ, FunctionOfTanhWeight, FunctionOfHyperbolicQ, SmartNumerator,
SmartDenominator, ActivateTrig, ExpandTrig, TrigExpand,
SubstForTrig, SubstForHyperbolic, InertTrigFreeQ, LCM,
SubstForFractionalPowerOfLinear, FractionalPowerOfLinear,
InverseFunctionOfLinear, InertTrigQ, InertReciprocalQ, DeactivateTrig,
FixInertTrigFunction, DeactivateTrigAux, PowerOfInertTrigSumQ,
PiecewiseLinearQ, KnownTrigIntegrandQ, KnownSineIntegrandQ,
KnownTangentIntegrandQ, KnownCotangentIntegrandQ, KnownSecantIntegrandQ,
TryPureTanSubst, TryTanhSubst, TryPureTanhSubst, AbsurdNumberGCD,
AbsurdNumberGCDList, ExpandTrigExpand, ExpandTrigReduce, ExpandTrigReduceAux,
NormalizeTrig, TrigToExp, ExpandTrigToExp, TrigReduce, FunctionOfTrig,
AlgebraicTrigFunctionQ, FunctionOfHyperbolic, FunctionOfQ, FunctionOfExpnQ,
PureFunctionOfSinQ, PureFunctionOfCosQ, PureFunctionOfTanQ, PureFunctionOfCotQ,
FunctionOfCosQ, FunctionOfSinQ, OddTrigPowerQ, FunctionOfTanQ,
FunctionOfTanWeight, FunctionOfTrigQ, FunctionOfDensePolynomialsQ,
FunctionOfLog, PowerVariableExpn, PowerVariableDegree, PowerVariableSubst,
EulerIntegrandQ, FunctionOfSquareRootOfQuadratic, SquareRootOfQuadraticSubst,
Divides, EasyDQ, ProductOfLinearPowersQ, Rt, NthRoot, AtomBaseQ, SumBaseQ,
NegSumBaseQ, AllNegTermQ, SomeNegTermQ, TrigSquareQ, RtAux, TrigSquare,
IntSum, IntTerm, Map2, ConstantFactor, SameQ, ReplacePart, CommonFactors,
MostMainFactorPosition, FunctionOfExponentialQ, FunctionOfExponential,
FunctionOfExponentialFunction, FunctionOfExponentialFunctionAux,
FunctionOfExponentialTest, FunctionOfExponentialTestAux, stdev, rubi_test,
If, IntQuadraticQ, IntBinomialQ, RectifyTangent, RectifyCotangent,
Inequality, Condition, Simp, SimpHelp, SplitProduct, SplitSum, SubstFor,
SubstForAux, FresnelS, FresnelC, Erfc, Erfi, Gamma, FunctionOfTrigOfLinearQ,
ElementaryFunctionQ, Complex, UnsameQ, _SimpFixFactor,
DerivativeDivides, SimpFixFactor, _FixSimplify, FixSimplify,
_SimplifyAntiderivativeSum, SimplifyAntiderivativeSum, PureFunctionOfCothQ,
_SimplifyAntiderivative, SimplifyAntiderivative, _TrigSimplifyAux,
TrigSimplifyAux, Cancel, Part, PolyLog, D, Dist, IntegralFreeQ, Sum_doit,
rubi_exp, rubi_log, PolynomialRemainder, CoprimeQ, Distribute, ProductLog,
Floor, PolyGamma, process_trig, replace_pow_exp, ExponentList)
# TODO - Add tests for: Int, NFreeQ, PureComplexNumberQ, EllipticPi, EllipticE,
# EllipticF, ArcCot, ArcCoth, Tanh, Cosh, Sech, ArcSec, ArcSech, Subst,
# SqrtNumberSumQ, Sin, Cos, Tan, Cot, Sec, Csc, Csch, TrigHyperbolicFreeQ,
# InverseFunctionFreeQ, RealQ,
from sympy.core.expr import unchanged
from sympy.core.symbol import symbols, S
from sympy.functions.elementary.trigonometric import atan, acsc, asin, acot, acos, asec, atan2
from sympy.functions.elementary.hyperbolic import acosh, asinh, atanh, acsch, cosh, sinh, tanh, coth, sech, csch, acoth
from sympy.functions import (sin, cos, tan, cot, sec, csc, sqrt, log as sym_log)
from sympy import (I, E, pi, hyper, Add, Wild, simplify, Symbol, exp, Pow, li, Ei, expint,
Si, Ci, Shi, Chi, loggamma, zeta, zoo, gamma, polylog, oo, polygamma)
from sympy import Integral, nsimplify, Min
A, B, a, b, c, d, e, f, g, h, y, z, m, n, p, q, u, v, w, F = symbols('A B a b c d e f g h y z m n p q u v w F', real=True, imaginary=False)
x = Symbol('x')
def test_ZeroQ():
e = b*(n*p + n + 1)
d = a
assert ZeroQ(a*e - b*d*(n*(p + S(1)) + S(1)))
assert ZeroQ(S(0))
assert not ZeroQ(S(10))
assert not ZeroQ(S(-2))
assert ZeroQ(0, 2-2)
assert ZeroQ([S(2), (4), S(0), S(8)]) == [False, False, True, False]
assert ZeroQ([S(2), S(4), S(8)]) == [False, False, False]
def test_NonzeroQ():
assert NonzeroQ(S(1)) == True
def test_FreeQ():
l = [a*b, x, a + b]
assert FreeQ(l, x) == False
l = [a*b, a + b]
assert FreeQ(l, x) == True
def test_List():
assert List(a, b, c) == [a, b, c]
def test_Log():
assert Log(a) == rubi_log(a)
def test_PositiveIntegerQ():
assert PositiveIntegerQ(S(1))
assert not PositiveIntegerQ(S(-3))
assert not PositiveIntegerQ(S(0))
def test_NegativeIntegerQ():
assert not NegativeIntegerQ(S(1))
assert NegativeIntegerQ(S(-3))
assert not NegativeIntegerQ(S(0))
def test_PositiveQ():
assert PositiveQ(S(1))
assert not PositiveQ(S(-3))
assert not PositiveQ(S(0))
assert not PositiveQ(zoo)
assert not PositiveQ(I)
assert PositiveQ(b/(b*(b*c/(-a*d + b*c)) - a*(b*d/(-a*d + b*c))))
def test_IntegerQ():
assert IntegerQ(S(1))
assert not IntegerQ(S(-1.9))
assert not IntegerQ(S(0.0))
assert IntegerQ(S(-1))
def test_IntegersQ():
assert IntegersQ([S(1), S(0)])
assert not IntegersQ([S(-1.9), S(1)])
assert not IntegersQ([S(0.0), S(0)])
assert IntegersQ([S(-1), S(0), S(2)])
def test_FracPart():
assert FracPart(S(10)) == 0
assert FracPart(S(10)+0.5) == 10.5
def test_IntPart():
assert IntPart(m*n) == 0
assert IntPart(S(10)) == 10
assert IntPart(1 + m) == 1
def test_NegQ():
assert NegQ(-S(3))
assert not NegQ(S(0))
assert not NegQ(S(0))
def test_RationalQ():
assert RationalQ(S(5)/6)
assert RationalQ(S(5)/6, S(4)/5)
assert not RationalQ(Sqrt(1.6))
assert not RationalQ(Sqrt(1.6), S(5)/6)
assert not RationalQ(rubi_log(2))
def test_ArcCosh():
assert ArcCosh(x) == acosh(x)
def test_LinearQ():
assert not LinearQ(a, x)
assert LinearQ(3*x + y**2, x)
assert not LinearQ(3*x + y**2, y)
assert not LinearQ(S(3), x)
def test_Sqrt():
assert Sqrt(x) == sqrt(x)
assert Sqrt(25) == 5
def test_Util_Coefficient():
from sympy.integrals.rubi.utility_function import Util_Coefficient
assert unchanged(Util_Coefficient, a + b*x + c*x**3, x, a)
assert Util_Coefficient(a + b*x + c*x**3, x, 4).doit() == 0
def test_Coefficient():
assert Coefficient(7 + 2*x + 4*x**3, x, 1) == 2
assert Coefficient(a + b*x + c*x**3, x, 0) == a
assert Coefficient(a + b*x + c*x**3, x, 4) == 0
assert Coefficient(b*x + c*x**3, x, 3) == c
assert Coefficient(x, x, -1) == 0
def test_Denominator():
assert Denominator(-S(1)/S(2) + I/3) == 6
assert Denominator((-a/b)**3) == (b)**(3)
assert Denominator(S(3)/2) == 2
assert Denominator(x/y) == y
assert Denominator(S(4)/5) == 5
def test_Hypergeometric2F1():
assert Hypergeometric2F1(1, 2, 3, x) == hyper((1, 2), (3,), x)
def test_ArcTan():
assert ArcTan(x) == atan(x)
assert ArcTan(x, y) == atan2(x, y)
def test_Not():
a = 10
assert Not(a == 2)
def test_FractionalPart():
assert FractionalPart(S(3.0)) == 0.0
def test_IntegerPart():
assert IntegerPart(3.6) == 3
assert IntegerPart(-3.6) == -4
def test_AppellF1():
assert AppellF1(1,0,0.5,1,0.5,0.25).evalf() == 1.154700538379251529018298
assert unchanged(AppellF1, a, b, c, d, e, f)
def test_Simplify():
assert Simplify(sin(x)**2 + cos(x)**2) == 1
assert Simplify((x**3 + x**2 - x - 1)/(x**2 + 2*x + 1)) == x - 1
def test_ArcTanh():
assert ArcTanh(a) == atanh(a)
def test_ArcSin():
assert ArcSin(a) == asin(a)
def test_ArcSinh():
assert ArcSinh(a) == asinh(a)
def test_ArcCos():
assert ArcCos(a) == acos(a)
def test_ArcCsc():
assert ArcCsc(a) == acsc(a)
def test_ArcCsch():
assert ArcCsch(a) == acsch(a)
def test_Equal():
assert Equal(a, a)
assert not Equal(a, b)
def test_LessEqual():
assert LessEqual(1, 2, 3)
assert LessEqual(1, 1)
assert not LessEqual(3, 2, 1)
def test_With():
assert With(Set(x, 3), x + y) == 3 + y
assert With(List(Set(x, 3), Set(y, c)), x + y) == 3 + c
def test_Module():
# Same as With
assert Module(Set(x, 3), x + y) == 3 + y
assert Module(List(Set(x, 3), Set(y, c)), x + y) == 3 + c
def test_Less():
assert Less(1, 2, 3)
assert not Less(1, 1, 3)
def test_Greater():
assert Greater(3, 2, 1)
assert not Greater(3, 2, 2)
def test_GreaterEqual():
assert GreaterEqual(3, 2, 1)
assert GreaterEqual(3, 2, 2)
assert not GreaterEqual(2, 3)
def test_Unequal():
assert Unequal(1, 2)
assert not Unequal(1, 1)
def test_FractionQ():
assert not FractionQ(S('3'))
assert FractionQ(S('3')/S('2'))
def test_Expand():
assert Expand((1 + x)**10) == x**10 + 10*x**9 + 45*x**8 + 120*x**7 + 210*x**6 + 252*x**5 + 210*x**4 + 120*x**3 + 45*x**2 + 10*x + 1
def test_Scan():
assert list(Scan(sin, [a, b])) == [sin(a), sin(b)]
def test_MapAnd():
assert MapAnd(PositiveQ, [S(1), S(2), S(3), S(0)]) == False
assert MapAnd(PositiveQ, [S(1), S(2), S(3)]) == True
def test_FalseQ():
assert FalseQ(True) == False
assert FalseQ(False) == True
def test_ComplexNumberQ():
assert ComplexNumberQ(1 + I*2, I) == True
assert ComplexNumberQ(a + b, I) == False
def test_Re():
assert Re(1 + I) == 1
def test_Im():
assert Im(1 + 2*I) == 2
assert Im(a*I) == a
def test_PositiveOrZeroQ():
assert PositiveOrZeroQ(S(0)) == True
assert PositiveOrZeroQ(S(1)) == True
assert PositiveOrZeroQ(-S(1)) == False
def test_RealNumericQ():
assert RealNumericQ(S(1)) == True
assert RealNumericQ(-S(1)) == True
def test_NegativeOrZeroQ():
assert NegativeOrZeroQ(S(0)) == True
assert NegativeOrZeroQ(-S(1)) == True
assert NegativeOrZeroQ(S(1)) == False
def test_FractionOrNegativeQ():
assert FractionOrNegativeQ(S(1)/2) == True
assert FractionOrNegativeQ(-S(1)) == True
assert FractionOrNegativeQ(-S(1)/2) == True
assert FractionOrNegativeQ(S(1)) == False
def test_NegativeQ():
assert NegativeQ(-S(1)) == True
assert NegativeQ(S(1)) == False
assert NegativeQ(oo) == False
def test_ProductQ():
assert ProductQ(a*b) == True
assert ProductQ(a + b) == False
def test_SumQ():
assert SumQ(a*b) == False
assert SumQ(a + b) == True
def test_NonsumQ():
assert NonsumQ(a*b) == True
assert NonsumQ(a + b) == False
def test_SqrtNumberQ():
assert SqrtNumberQ(sqrt(2)) == True
def test_IntLinearcQ():
assert IntLinearcQ(1, 2, 3, 4, 5, 6, x) == True
assert IntLinearcQ(S(1)/100, S(2)/100, S(3)/100, S(4)/100, S(5)/100, S(6)/100, x) == False
def test_IndependentQ():
assert IndependentQ(a + b*x, x) == False
assert IndependentQ(a + b, x) == True
def test_PowerQ():
assert PowerQ(a**b) == True
assert PowerQ(a + b) == False
def test_IntegerPowerQ():
assert IntegerPowerQ(a**2) == True
assert IntegerPowerQ(a**0.5) == False
def test_PositiveIntegerPowerQ():
assert PositiveIntegerPowerQ(a**3) == True
assert PositiveIntegerPowerQ(a**(-2)) == False
def test_FractionalPowerQ():
assert FractionalPowerQ(a**(S(2)/S(3)))
assert FractionalPowerQ(a**sqrt(2)) == False
def test_AtomQ():
assert AtomQ(x)
assert not AtomQ(x+1)
assert not AtomQ([a, b])
def test_ExpQ():
assert ExpQ(E**2)
assert not ExpQ(2**E)
def test_LogQ():
assert LogQ(rubi_log(x))
assert not LogQ(sin(x) + rubi_log(x))
def test_Head():
assert Head(sin(x)) == sin
assert Head(rubi_log(x**3 + 3)) in (sym_log, rubi_log)
def test_MemberQ():
assert MemberQ([a, b, c], b)
assert MemberQ([sin, cos, log, tan], Head(sin(x)))
assert MemberQ([[sin, cos], [tan, cot]], [sin, cos])
assert not MemberQ([[sin, cos], [tan, cot]], [sin, tan])
def test_TrigQ():
assert TrigQ(sin(x))
assert TrigQ(tan(x**2 + 2))
assert not TrigQ(sin(x) + tan(x))
def test_SinQ():
assert SinQ(sin(x))
assert not SinQ(tan(x))
def test_CosQ():
assert CosQ(cos(x))
assert not CosQ(csc(x))
def test_TanQ():
assert TanQ(tan(x))
assert not TanQ(cot(x))
def test_CotQ():
assert not CotQ(tan(x))
assert CotQ(cot(x))
def test_SecQ():
assert SecQ(sec(x))
assert not SecQ(csc(x))
def test_CscQ():
assert not CscQ(sec(x))
assert CscQ(csc(x))
def test_HyperbolicQ():
assert HyperbolicQ(sinh(x))
assert HyperbolicQ(cosh(x))
assert HyperbolicQ(tanh(x))
assert not HyperbolicQ(sinh(x) + cosh(x) + tanh(x))
def test_SinhQ():
assert SinhQ(sinh(x))
assert not SinhQ(cosh(x))
def test_CoshQ():
assert not CoshQ(sinh(x))
assert CoshQ(cosh(x))
def test_TanhQ():
assert TanhQ(tanh(x))
assert not TanhQ(coth(x))
def test_CothQ():
assert not CothQ(tanh(x))
assert CothQ(coth(x))
def test_SechQ():
assert SechQ(sech(x))
assert not SechQ(csch(x))
def test_CschQ():
assert not CschQ(sech(x))
assert CschQ(csch(x))
def test_InverseTrigQ():
assert InverseTrigQ(acot(x))
assert InverseTrigQ(asec(x))
assert not InverseTrigQ(acsc(x) + asec(x))
def test_SinCosQ():
assert SinCosQ(sin(x))
assert SinCosQ(cos(x))
assert SinCosQ(sec(x))
assert not SinCosQ(acsc(x))
def test_SinhCoshQ():
assert not SinhCoshQ(sin(x))
assert SinhCoshQ(cosh(x))
assert SinhCoshQ(sech(x))
assert SinhCoshQ(csch(x))
def test_LeafCount():
assert LeafCount(1 + a + x**2) == 6
def test_Numerator():
assert Numerator(-S(1)/S(2) + I/3) == -3 + 2*I
assert Numerator((-a/b)**3) == (-a)**(3)
assert Numerator(S(3)/2) == 3
assert Numerator(x/y) == x
def test_Length():
assert Length(a + b) == 2
assert Length(sin(a)*cos(a)) == 2
def test_ListQ():
assert ListQ([1, 2])
assert not ListQ(a)
def test_InverseHyperbolicQ():
assert InverseHyperbolicQ(acosh(a))
def test_InverseFunctionQ():
assert InverseFunctionQ(rubi_log(a))
assert InverseFunctionQ(acos(a))
assert not InverseFunctionQ(a)
assert InverseFunctionQ(acosh(a))
assert InverseFunctionQ(polylog(a, b))
def test_EqQ():
assert EqQ(a, a)
assert not EqQ(a, b)
def test_FactorSquareFree():
assert FactorSquareFree(x**5 - x**3 - x**2 + 1) == (x**3 + 2*x**2 + 2*x + 1)*(x - 1)**2
def test_FactorSquareFreeList():
assert FactorSquareFreeList(x**5-x**3-x**2 + 1) == [[1, 1], [x**3 + 2*x**2 + 2*x + 1, 1], [x - 1, 2]]
assert FactorSquareFreeList(x**4 - 2*x**2 + 1) == [[1, 1], [x**2 - 1, 2]]
def test_PerfectPowerTest():
assert not PerfectPowerTest(sqrt(x), x)
assert not PerfectPowerTest(x**5-x**3-x**2 + 1, x)
assert PerfectPowerTest(x**4 - 2*x**2 + 1, x) == (x**2 - 1)**2
def test_SquareFreeFactorTest():
assert not SquareFreeFactorTest(sqrt(x), x)
assert SquareFreeFactorTest(x**5 - x**3 - x**2 + 1, x) == (x**3 + 2*x**2 + 2*x + 1)*(x - 1)**2
def test_Rest():
assert Rest([2, 3, 5, 7]) == [3, 5, 7]
assert Rest(a + b + c) == b + c
assert Rest(a*b*c) == b*c
assert Rest(1/b) == -1
def test_First():
assert First([2, 3, 5, 7]) == 2
assert First(y**S(2)) == y
assert First(a + b + c) == a
assert First(a*b*c) == a
def test_ComplexFreeQ():
assert ComplexFreeQ(a)
assert not ComplexFreeQ(a + 2*I)
def test_FractionalPowerFreeQ():
assert not FractionalPowerFreeQ(x**(S(2)/3))
assert FractionalPowerFreeQ(x)
def test_Exponent():
assert Min(ExponentList(x**2 + x + 1 + 5, x)) == 0
assert ExponentList(x**2 + x + 1 + 5, x) == [0, 1, 2]
assert ExponentList(x**2 + x + 1, x) == [0, 1, 2]
assert ExponentList(x**2 + 2*x + 1, x) == [0, 1, 2]
assert Exponent(x**3 + x + 1, x) == 3
assert Exponent(x**2 + 2*x + 1, x) == 2
assert ExponentList(x**3, x) == [3]
assert Exponent(S(1), x) == 0
assert Exponent(x**(-3), x) == 0
def test_Expon():
assert Expon(x**2+2*x+1, x) == 2
def test_QuadraticQ():
assert not QuadraticQ([x**2+x+1, 5*x**2], x)
assert QuadraticQ([x**2+x+1, 5*x**2+3*x+6], x)
assert not QuadraticQ(x**2+1+x**3, x)
assert QuadraticQ(x**2+1+x, x)
assert not QuadraticQ(x**2, x)
def test_BinomialQ():
assert BinomialQ(x**9, x)
assert not BinomialQ((1 + x)**3, x)
def test_BinomialParts():
assert BinomialParts(2 + x*(9*x), x) == [2, 9, 2]
assert BinomialParts(x**9, x) == [0, 1, 9]
assert BinomialParts(2*x**3, x) == [0, 2, 3]
assert BinomialParts(2 + x, x) == [2, 1, 1]
def test_BinomialDegree():
assert BinomialDegree(b + 2*c*x**n, x) == n
assert BinomialDegree(2 + x*(9*x), x) == 2
assert BinomialDegree(x**9, x) == 9
def test_PolynomialQ():
assert not PolynomialQ(x*(-1 + x**2), (1 + x)**(S(1)/2))
assert not PolynomialQ((16*x + 1)/((x + 5)**2*(x**2 + x + 1)), 2*x)
C = Symbol('C')
assert not PolynomialQ(A + b*x + c*x**2, x**2)
assert PolynomialQ(A + B*x + C*x**2)
assert PolynomialQ(A + B*x**4 + C*x**2, x**2)
assert PolynomialQ(x**3, x)
assert not PolynomialQ(sqrt(x), x)
def test_PolyQ():
assert PolyQ(-2*a*d**3*e**2 + x**6*(a*e**5 - b*d*e**4 + c*d**2*e**3)\
+ x**4*(-2*a*d*e**4 + 2*b*d**2*e**3 - 2*c*d**3*e**2) + x**2*(2*a*d**2*e**3 - 2*b*d**3*e**2), x)
assert not PolyQ(1/sqrt(a + b*x**2 - c*x**4), x**2)
assert PolyQ(x, x, 1)
assert PolyQ(x**2, x, 2)
assert not PolyQ(x**3, x, 2)
def test_EvenQ():
assert EvenQ(S(2))
assert not EvenQ(S(1))
def test_OddQ():
assert OddQ(S(1))
assert not OddQ(S(2))
def test_PerfectSquareQ():
assert PerfectSquareQ(S(4))
assert PerfectSquareQ(a**S(2)*b**S(4))
assert not PerfectSquareQ(S(1)/3)
def test_NiceSqrtQ():
assert NiceSqrtQ(S(1)/3)
assert not NiceSqrtQ(-S(1))
assert NiceSqrtQ(pi**2)
assert NiceSqrtQ(pi**2*sin(4)**4)
assert not NiceSqrtQ(pi**2*sin(4)**3)
def test_Together():
assert Together(1/a + b/2) == (a*b + 2)/(2*a)
def test_PosQ():
#assert not PosQ((b*e - c*d)/(c*e))
assert not PosQ(S(0))
assert PosQ(S(1))
assert PosQ(pi)
assert PosQ(pi**3)
assert PosQ((-pi)**4)
assert PosQ(sin(1)**2*pi**4)
def test_NumericQ():
assert NumericQ(sin(cos(2)))
def test_NumberQ():
assert NumberQ(pi)
def test_CoefficientList():
assert CoefficientList(1 + a*x, x) == [1, a]
assert CoefficientList(1 + a*x**3, x) == [1, 0, 0, a]
assert CoefficientList(sqrt(x), x) == []
def test_ReplaceAll():
assert ReplaceAll(x, {x: a}) == a
assert ReplaceAll(a*x, {x: a + b}) == a*(a + b)
assert ReplaceAll(a*x, {a: b, x: a + b}) == b*(a + b)
def test_ExpandLinearProduct():
assert ExpandLinearProduct(rubi_log(x), x**2, a, b, x) == a**2*rubi_log(x)/b**2 - 2*a*(a + b*x)*rubi_log(x)/b**2 + (a + b*x)**2*rubi_log(x)/b**2
assert ExpandLinearProduct((a + b*x)**n, x**3, a, b, x) == -a**3*(a + b*x)**n/b**3 + 3*a**2*(a + b*x)**(n + 1)/b**3 - 3*a*(a + b*x)**(n + 2)/b**3 + (a + b*x)**(n + 3)/b**3
def test_PolynomialDivide():
assert PolynomialDivide((a*c - b*c*x)**2, (a + b*x)**2, x) == -4*a*b*c**2*x/(a + b*x)**2 + c**2
assert PolynomialDivide(x + x**2, x, x) == x + 1
assert PolynomialDivide((1 + x)**3, (1 + x)**2, x) == x + 1
assert PolynomialDivide((a + b*x)**3, x**3, x) == a*(a**2 + 3*a*b*x + 3*b**2*x**2)/x**3 + b**3
assert PolynomialDivide(x**3*(a + b*x), S(1), x) == b*x**4 + a*x**3
assert PolynomialDivide(x**6, (a + b*x)**2, x) == -a**5*(5*a + 6*b*x)/(b**6*(a + b*x)**2) + 5*a**4/b**6 - 4*a**3*x/b**5 + 3*a**2*x**2/b**4 - 2*a*x**3/b**3 + x**4/b**2
def test_MatchQ():
a_ = Wild('a', exclude=[x])
b_ = Wild('b', exclude=[x])
c_ = Wild('c', exclude=[x])
assert MatchQ(a*b + c, a_*b_ + c_, a_, b_, c_) == (a, b, c)
def test_PolynomialQuotientRemainder():
assert PolynomialQuotientRemainder(x**2, x+a, x) == [-a + x, a**2]
def test_FreeFactors():
assert FreeFactors(a, x) == a
assert FreeFactors(x + a, x) == 1
assert FreeFactors(a*b*x, x) == a*b
def test_NonfreeFactors():
assert NonfreeFactors(a, x) == 1
assert NonfreeFactors(x + a, x) == x + a
assert NonfreeFactors(a*b*x, x) == x
def test_FreeTerms():
assert FreeTerms(a, x) == a
assert FreeTerms(x*a, x) == 0
assert FreeTerms(a*x + b, x) == b
def test_NonfreeTerms():
assert NonfreeTerms(a, x) == 0
assert NonfreeTerms(a*x, x) == a*x
assert NonfreeTerms(a*x + b, x) == a*x
def test_RemoveContent():
assert RemoveContent(a + b*x, x) == a + b*x
def test_ExpandAlgebraicFunction():
assert ExpandAlgebraicFunction((a + b)*x, x) == a*x + b*x
assert ExpandAlgebraicFunction((a + b)**2*x, x)== a**2*x + 2*a*b*x + b**2*x
assert ExpandAlgebraicFunction((a + b)**2*x**2, x) == a**2*x**2 + 2*a*b*x**2 + b**2*x**2
def test_CollectReciprocals():
assert CollectReciprocals(-1/(1 + 1*x) - 1/(1 - 1*x), x) == -2/(-x**2 + 1)
assert CollectReciprocals(1/(1 + 1*x) - 1/(1 - 1*x), x) == -2*x/(-x**2 + 1)
def test_ExpandCleanup():
assert ExpandCleanup(a + b, x) == a*(1 + b/a)
assert ExpandCleanup(b**2/(a**2*(a + b*x)**2) + 1/(a**2*x**2) + 2*b**2/(a**3*(a + b*x)) - 2*b/(a**3*x), x) == b**2/(a**2*(a + b*x)**2) + 1/(a**2*x**2) + 2*b**2/(a**3*(a + b*x)) - 2*b/(a**3*x)
def test_AlgebraicFunctionQ():
assert not AlgebraicFunctionQ(1/(a + c*x**(2*n)), x)
assert AlgebraicFunctionQ(a, x) == True
assert AlgebraicFunctionQ(a*b, x) == True
assert AlgebraicFunctionQ(x**2, x) == True
assert AlgebraicFunctionQ(x**2*a, x) == True
assert AlgebraicFunctionQ(x**2 + a, x) == True
assert AlgebraicFunctionQ(sin(x), x) == False
assert AlgebraicFunctionQ([], x) == True
assert AlgebraicFunctionQ([a, a*b], x) == True
assert AlgebraicFunctionQ([sin(x)], x) == False
def test_MonomialQ():
assert not MonomialQ(2*x**7 + 6, x)
assert MonomialQ(2*x**7, x)
assert not MonomialQ(2*x**7 + 5*x**3, x)
assert not MonomialQ([2*x**7 + 6, 2*x**7], x)
assert MonomialQ([2*x**7, 5*x**3], x)
def test_MonomialSumQ():
assert MonomialSumQ(2*x**7 + 6, x) == True
assert MonomialSumQ(x**2 + x**3 + 5*x, x) == True
def test_MinimumMonomialExponent():
assert MinimumMonomialExponent(x**2 + 5*x**2 + 3*x**5, x) == 2
assert MinimumMonomialExponent(x**2 + 5*x**2 + 1, x) == 0
def test_MonomialExponent():
assert MonomialExponent(3*x**7, x) == 7
assert not MonomialExponent(3+x**3, x)
def test_LinearMatchQ():
assert LinearMatchQ(2 + 3*x, x)
assert LinearMatchQ(3*x, x)
assert not LinearMatchQ(3*x**2, x)
def test_SimplerQ():
a1, b1 = symbols('a1 b1')
assert SimplerQ(a1, b1)
assert SimplerQ(2*a, a + 2)
assert SimplerQ(2, x)
assert not SimplerQ(x**2, x)
assert SimplerQ(2*x, x + 2 + 6*x**3)
def test_GeneralizedTrinomialParts():
assert not GeneralizedTrinomialParts((7 + 2*x**6 + 3*x**12), x)
assert GeneralizedTrinomialParts(x**2 + x**3 + x**4, x) == [1, 1, 1, 3, 2]
assert not GeneralizedTrinomialParts(2*x + 3*x + 4*x, x)
def test_TrinomialQ():
assert TrinomialQ((7 + 2*x**6 + 3*x**12), x)
assert not TrinomialQ(x**2, x)
def test_GeneralizedTrinomialDegree():
assert not GeneralizedTrinomialDegree((7 + 2*x**6 + 3*x**12), x)
assert GeneralizedTrinomialDegree(x**2 + x**3 + x**4, x) == 1
def test_GeneralizedBinomialParts():
assert GeneralizedBinomialParts(3*x*(3 + x**6), x) == [9, 3, 7, 1]
assert GeneralizedBinomialParts((3*x + x**7), x) == [3, 1, 7, 1]
def test_GeneralizedBinomialDegree():
assert GeneralizedBinomialDegree(3*x*(3 + x**6), x) == 6
assert GeneralizedBinomialDegree((3*x + x**7), x) == 6
def test_PowerOfLinearQ():
assert PowerOfLinearQ((6*x), x)
assert not PowerOfLinearQ((3 + 6*x**3), x)
assert PowerOfLinearQ((3 + 6*x)**3, x)
def test_LinearPairQ():
assert not LinearPairQ(6*x**2 + 4, 3*x**2 + 2, x)
assert LinearPairQ(6*x + 4, 3*x + 2, x)
assert not LinearPairQ(6*x, 3*x + 2, x)
assert LinearPairQ(6*x, 3*x, x)
def test_LeadTerm():
assert LeadTerm(a*b*c) == a*b*c
assert LeadTerm(a + b + c) == a
def test_RemainingTerms():
assert RemainingTerms(a*b*c) == a*b*c
assert RemainingTerms(a + b + c) == b + c
def test_LeadFactor():
assert LeadFactor(a*b*c) == a
assert LeadFactor(a + b + c) == a + b + c
assert LeadFactor(b*I) == I
assert LeadFactor(c*a**b) == a**b
assert LeadFactor(S(2)) == S(2)
def test_RemainingFactors():
assert RemainingFactors(a*b*c) == b*c
assert RemainingFactors(a + b + c) == 1
assert RemainingFactors(a*I) == a
def test_LeadBase():
assert LeadBase(a**b) == a
assert LeadBase(a**b*c) == a
def test_LeadDegree():
assert LeadDegree(a**b) == b
assert LeadDegree(a**b*c) == b
def test_Numer():
assert Numer(a/b) == a
assert Numer(a**(-2)) == 1
assert Numer(a**(-2)*a/b) == 1
def test_Denom():
assert Denom(a/b) == b
assert Denom(a**(-2)) == a**2
assert Denom(a**(-2)*a/b) == a*b
def test_Coeff():
assert Coeff(7 + 2*x + 4*x**3, x, 1) == 2
assert Coeff(a + b*x + c*x**3, x, 0) == a
assert Coeff(a + b*x + c*x**3, x, 4) == 0
assert Coeff(b*x + c*x**3, x, 3) == c
def test_MergeMonomials():
assert MergeMonomials(x**2*(1 + 1*x)**3*(1 + 1*x)**n, x) == x**2*(x + 1)**(n + 3)
assert MergeMonomials(x**2*(1 + 1*x)**2*(1*(1 + 1*x)**1)**2, x) == x**2*(x + 1)**4
assert MergeMonomials(b**2/a**3, x) == b**2/a**3
def test_RationalFunctionQ():
assert RationalFunctionQ(a, x)
assert RationalFunctionQ(x**2, x)
assert RationalFunctionQ(x**3 + x**4, x)
assert RationalFunctionQ(x**3*S(2), x)
assert not RationalFunctionQ(x**3 + x**(0.5), x)
assert not RationalFunctionQ(x**(S(2)/3)*(a + b*x)**2, x)
def test_Apart():
assert Apart(1/(x**2*(a + b*x)**2), x) == b**2/(a**2*(a + b*x)**2) + 1/(a**2*x**2) + 2*b**2/(a**3*(a + b*x)) - 2*b/(a**3*x)
assert Apart(x**(S(2)/3)*(a + b*x)**2, x) == x**(S(2)/3)*(a + b*x)**2
def test_RationalFunctionFactors():
assert RationalFunctionFactors(a, x) == a
assert RationalFunctionFactors(sqrt(x), x) == 1
assert RationalFunctionFactors(x*x**3, x) == x*x**3
assert RationalFunctionFactors(x*sqrt(x), x) == 1
def test_NonrationalFunctionFactors():
assert NonrationalFunctionFactors(x, x) == 1
assert NonrationalFunctionFactors(sqrt(x), x) == sqrt(x)
assert NonrationalFunctionFactors(sqrt(x)*rubi_log(x), x) == sqrt(x)*rubi_log(x)
def test_Reverse():
assert Reverse([1, 2, 3]) == [3, 2, 1]
assert Reverse(a**b) == b**a
def test_RationalFunctionExponents():
assert RationalFunctionExponents(sqrt(x), x) == [0, 0]
assert RationalFunctionExponents(a, x) == [0, 0]
assert RationalFunctionExponents(x, x) == [1, 0]
assert RationalFunctionExponents(x**(-1), x)== [0, 1]
assert RationalFunctionExponents(x**(-1)*a, x) == [0, 1]
assert RationalFunctionExponents(x**(-1) + a, x) == [1, 1]
def test_PolynomialGCD():
assert PolynomialGCD(x**2 - 1, x**2 - 3*x + 2) == x - 1
def test_PolyGCD():
assert PolyGCD(x**2 - 1, x**2 - 3*x + 2, x) == x - 1
def test_AlgebraicFunctionFactors():
assert AlgebraicFunctionFactors(sin(x)*x, x) == x
assert AlgebraicFunctionFactors(sin(x), x) == 1
assert AlgebraicFunctionFactors(x, x) == x
def test_NonalgebraicFunctionFactors():
assert NonalgebraicFunctionFactors(sin(x)*x, x) == sin(x)
assert NonalgebraicFunctionFactors(sin(x), x) == sin(x)
assert NonalgebraicFunctionFactors(x, x) == 1
def test_QuotientOfLinearsP():
assert QuotientOfLinearsP((a + b*x)/(x), x)
assert QuotientOfLinearsP(x*a, x)
assert not QuotientOfLinearsP(x**2*a, x)
assert not QuotientOfLinearsP(x**2 + a, x)
assert QuotientOfLinearsP(x + a, x)
assert QuotientOfLinearsP(x, x)
assert QuotientOfLinearsP(1 + x, x)
def test_QuotientOfLinearsParts():
assert QuotientOfLinearsParts((b*x)/(c), x) == [0, b/c, 1, 0]
assert QuotientOfLinearsParts((b*x)/(c + x), x) == [0, b, c, 1]
assert QuotientOfLinearsParts((b*x)/(c + d*x), x) == [0, b, c, d]
assert QuotientOfLinearsParts((a + b*x)/(c + d*x), x) == [a, b, c, d]
assert QuotientOfLinearsParts(x**2 + a, x) == [a + x**2, 0, 1, 0]
assert QuotientOfLinearsParts(a/x, x) == [a, 0, 0, 1]
assert QuotientOfLinearsParts(1/x, x) == [1, 0, 0, 1]
assert QuotientOfLinearsParts(a*x + 1, x) == [1, a, 1, 0]
assert QuotientOfLinearsParts(x, x) == [0, 1, 1, 0]
assert QuotientOfLinearsParts(a, x) == [a, 0, 1, 0]
def test_QuotientOfLinearsQ():
assert not QuotientOfLinearsQ((a + x), x)
assert QuotientOfLinearsQ((a + x)/(x), x)
assert QuotientOfLinearsQ((a + b*x)/(x), x)
def test_Flatten():
assert Flatten([a, b, [c, [d, e]]]) == [a, b, c, d, e]
def test_Sort():
assert Sort([b, a, c]) == [a, b, c]
assert Sort([b, a, c], True) == [c, b, a]
def test_AbsurdNumberQ():
assert AbsurdNumberQ(S(1))
assert not AbsurdNumberQ(a*x)
assert not AbsurdNumberQ(a**(S(1)/2))
assert AbsurdNumberQ((S(1)/3)**(S(1)/3))
def test_AbsurdNumberFactors():
assert AbsurdNumberFactors(S(1)) == S(1)
assert AbsurdNumberFactors((S(1)/3)**(S(1)/3)) == S(3)**(S(2)/3)/S(3)
assert AbsurdNumberFactors(a) == S(1)
def test_NonabsurdNumberFactors():
assert NonabsurdNumberFactors(a) == a
assert NonabsurdNumberFactors(S(1)) == S(1)
assert NonabsurdNumberFactors(a*S(2)) == a
def test_NumericFactor():
assert NumericFactor(S(1)) == S(1)
assert NumericFactor(1*I) == S(1)
assert NumericFactor(S(1) + I) == S(1)
assert NumericFactor(a**(S(1)/3)) == S(1)
assert NumericFactor(a*S(3)) == S(3)
assert NumericFactor(a + b) == S(1)
def test_NonnumericFactors():
assert NonnumericFactors(S(3)) == S(1)
assert NonnumericFactors(I) == I
assert NonnumericFactors(S(3) + I) == S(3) + I
assert NonnumericFactors((S(1)/3)**(S(1)/3)) == S(1)
assert NonnumericFactors(rubi_log(a)) == rubi_log(a)
def test_Prepend():
assert Prepend([1, 2, 3], [4, 5]) == [4, 5, 1, 2, 3]
def test_SumSimplerQ():
assert not SumSimplerQ(S(4 + x),S(3 + x**3))
assert SumSimplerQ(S(4 + x), S(3 - x))
def test_SumSimplerAuxQ():
assert SumSimplerAuxQ(S(4 + x), S(3 - x))
assert not SumSimplerAuxQ(S(4), S(3))
def test_SimplerSqrtQ():
assert SimplerSqrtQ(S(2), S(16*x**3))
assert not SimplerSqrtQ(S(x*2), S(16))
assert not SimplerSqrtQ(S(-4), S(16))
assert SimplerSqrtQ(S(4), S(16))
assert not SimplerSqrtQ(S(4), S(0))
def test_TrinomialParts():
assert TrinomialParts((1 + 5*x**3)**2, x) == [1, 10, 25, 3]
assert TrinomialParts(1 + 5*x**3 + 2*x**6, x) == [1, 5, 2, 3]
assert TrinomialParts(((1 + 5*x**3)**2) + 6, x) == [7, 10, 25, 3]
assert not TrinomialParts(1 + 5*x**3 + 2*x**5, x)
def test_TrinomialDegree():
assert TrinomialDegree((7 + 2*x**6)**2, x) == 6
assert TrinomialDegree(1 + 5*x**3 + 2*x**6, x) == 3
assert not TrinomialDegree(1 + 5*x**3 + 2*x**5, x)
def test_CubicMatchQ():
assert not CubicMatchQ(S(3 + x**6), x)
assert CubicMatchQ(S(x**3), x)
assert not CubicMatchQ(S(3), x)
assert CubicMatchQ(S(3 + x**3), x)
assert CubicMatchQ(S(3 + x**3 + 2*x), x)
def test_BinomialMatchQ():
assert BinomialMatchQ(x, x)
assert BinomialMatchQ(2 + 3*x**5, x)
assert BinomialMatchQ(3*x**5, x)
assert BinomialMatchQ(3*x, x)
assert not BinomialMatchQ(x + x**2 + x**3, x)
def test_TrinomialMatchQ():
assert not TrinomialMatchQ((5 + 2*x**6)**2, x)
assert not TrinomialMatchQ((7 + 8*x**6), x)
assert TrinomialMatchQ((7 + 2*x**6 + 3*x**3), x)
assert TrinomialMatchQ(b*x**2 + c*x**4, x)
def test_GeneralizedBinomialMatchQ():
assert not GeneralizedBinomialMatchQ((1 + x**4), x)
assert GeneralizedBinomialMatchQ((3*x + x**7), x)
def test_QuadraticMatchQ():
assert not QuadraticMatchQ((a + b*x)*(c + d*x), x)
assert QuadraticMatchQ(x**2 + x, x)
assert QuadraticMatchQ(x**2+1+x, x)
assert QuadraticMatchQ(x**2, x)
def test_PowerOfLinearMatchQ():
assert PowerOfLinearMatchQ(x, x)
assert not PowerOfLinearMatchQ(S(6)**3, x)
assert not PowerOfLinearMatchQ(S(6 + 3*x**2)**3, x)
assert PowerOfLinearMatchQ(S(6 + 3*x)**3, x)
def test_GeneralizedTrinomialMatchQ():
assert not GeneralizedTrinomialMatchQ(7 + 2*x**6 + 3*x**12, x)
assert not GeneralizedTrinomialMatchQ(7 + 2*x**6 + 3*x**3, x)
assert not GeneralizedTrinomialMatchQ(7 + 2*x**6 + 3*x**5, x)
assert GeneralizedTrinomialMatchQ(x**2 + x**3 + x**4, x)
def test_QuotientOfLinearsMatchQ():
assert QuotientOfLinearsMatchQ((1 + x)*(3 + 4*x**2)/(2 + 4*x), x)
assert not QuotientOfLinearsMatchQ(x*(3 + 4*x**2)/(2 + 4*x**3), x)
assert QuotientOfLinearsMatchQ(x*(3 + 4*x)/(2 + 4*x), x)
assert QuotientOfLinearsMatchQ(2*(3 + 4*x)/(2 + 4*x), x)
def test_PolynomialTermQ():
assert not PolynomialTermQ(S(3), x)
assert PolynomialTermQ(3*x**6, x)
assert not PolynomialTermQ(3*x**6+5*x, x)
def test_PolynomialTerms():
assert PolynomialTerms(x + 6*x**3 + rubi_log(x), x) == 6*x**3 + x
assert PolynomialTerms(x + 6*x**3 + 6*x, x) == 6*x**3 + 7*x
assert PolynomialTerms(x + 6*x**3 + 6, x) == 6*x**3 + x
def test_NonpolynomialTerms():
assert NonpolynomialTerms(x + 6*x**3 + rubi_log(x), x) == rubi_log(x)
assert NonpolynomialTerms(x + 6*x**3 + 6*x, x) == 0
assert NonpolynomialTerms(x + 6*x**3 + 6, x) == 6
def test_PseudoBinomialQ():
assert PseudoBinomialQ(3 + 5*(x)**6, x)
assert PseudoBinomialQ(3 + 5*(2 + 5*x)**6, x)
def test_PseudoBinomialParts():
assert PseudoBinomialParts(3 + 7*(1 + x)**6, x) == [3, 1, 7**(S(1)/S(6)), 7**(S(1)/S(6)), 6]
assert PseudoBinomialParts(3 + 7*(1 + x)**3, x) == [3, 1, 7**(S(1)/S(3)), 7**(S(1)/S(3)), 3]
assert not PseudoBinomialParts(3 + 7*(1 + x)**2, x)
assert PseudoBinomialParts(3 + 7*(x)**5, x) == [3, 1, 0, 7**(S(1)/S(5)), 5]
def test_PseudoBinomialPairQ():
assert not PseudoBinomialPairQ(3 + 5*(x)**6,3 + (x)**6, x)
assert not PseudoBinomialPairQ(3 + 5*(1 + x)**6,3 + (1 + x)**6, x)
def test_NormalizePseudoBinomial():
assert NormalizePseudoBinomial(3 + 5*(1 + x)**6, x) == 3+(5**(S(1)/S(6))+5**(S(1)/S(6))*x)**S(6)
assert NormalizePseudoBinomial(3 + 5*(x)**6, x) == 3+5*x**6
def test_CancelCommonFactors():
assert CancelCommonFactors(S(x*y*S(6))**S(6), S(x*y*S(6))) == [46656*x**6*y**6, 6*x*y]
assert CancelCommonFactors(S(y*6)**S(6), S(x*y*S(6))) == [46656*y**6, 6*x*y]
assert CancelCommonFactors(S(6), S(3)) == [6, 3]
def test_SimplerIntegrandQ():
assert SimplerIntegrandQ(S(5), 4*x, x)
assert not SimplerIntegrandQ(S(x + 5*x**3), S(x**2 + 3*x), x)
assert SimplerIntegrandQ(S(x + 8), S(x**2 + 3*x), x)
def test_Drop():
assert Drop([1, 2, 3, 4, 5, 6], [2, 4]) == [1, 5, 6]
assert Drop([1, 2, 3, 4, 5, 6], -3) == [1, 2, 3]
assert Drop([1, 2, 3, 4, 5, 6], 2) == [3, 4, 5, 6]
assert Drop(a*b*c, 1) == b*c
def test_SubstForInverseFunction():
assert SubstForInverseFunction(x, a, b, x) == b
assert SubstForInverseFunction(a, a, b, x) == a
assert SubstForInverseFunction(x**a, x**a, b, x) == x
assert SubstForInverseFunction(a*x**a, a, b, x) == a*b**a
def test_SubstForFractionalPower():
assert SubstForFractionalPower(a, b, n, c, x) == a
assert SubstForFractionalPower(x, b, n, c, x) == c
assert SubstForFractionalPower(a**(S(1)/2), a, n, b, x) == x**(n/2)
def test_CombineExponents():
assert True
def test_FractionalPowerOfSquareQ():
assert not FractionalPowerOfSquareQ(x)
assert not FractionalPowerOfSquareQ((a + b)**(S(2)/S(3)))
assert not FractionalPowerOfSquareQ((a + b)**(S(2)/S(3))*c)
assert FractionalPowerOfSquareQ(((a + b*x)**(S(2)))**(S(1)/3)) == (a + b*x)**S(2)
def test_FractionalPowerSubexpressionQ():
assert not FractionalPowerSubexpressionQ(x, a, x)
assert FractionalPowerSubexpressionQ(x**(S(2)/S(3)), a, x)
assert not FractionalPowerSubexpressionQ(b*a, a, x)
def test_FactorNumericGcd():
assert FactorNumericGcd(5*a**2*e**4 + 2*a*b*d*e**3 + 2*a*c*d**2*e**2 + b**2*d**2*e**2 - 6*b*c*d**3*e + 21*c**2*d**4) ==\
5*a**2*e**4 + 2*a*b*d*e**3 + 2*a*c*d**2*e**2 + b**2*d**2*e**2 - 6*b*c*d**3*e + 21*c**2*d**4
assert FactorNumericGcd(x**(S(2))) == x**S(2)
assert FactorNumericGcd(rubi_log(x)) == rubi_log(x)
assert FactorNumericGcd(rubi_log(x)*x) == x*rubi_log(x)
assert FactorNumericGcd(rubi_log(x) + x**S(2)) == rubi_log(x) + x**S(2)
def test_Apply():
assert Apply(List, [a, b, c]) == [a, b, c]
def test_TrigSimplify():
assert TrigSimplify(a*sin(x)**2 + a*cos(x)**2 + v) == a + v
assert TrigSimplify(a*sec(x)**2 - a*tan(x)**2 + v) == a + v
assert TrigSimplify(a*csc(x)**2 - a*cot(x)**2 + v) == a + v
assert TrigSimplify(S(1) - sin(x)**2) == cos(x)**2
assert TrigSimplify(1 + tan(x)**2) == sec(x)**2
assert TrigSimplify(1 + cot(x)**2) == csc(x)**2
assert TrigSimplify(-S(1) + sec(x)**2) == tan(x)**2
assert TrigSimplify(-1 + csc(x)**2) == cot(x)**2
def test_MergeFactors():
assert simplify(MergeFactors(b/(a - c)**3 , 8*c**3*(b*x + c)**(3/2)/(3*b**4) - 24*c**2*(b*x + c)**(5/2)/(5*b**4) + \
24*c*(b*x + c)**(7/2)/(7*b**4) - 8*(b*x + c)**(9/2)/(9*b**4)) - (8*c**3*(b*x + c)**1.5/(3*b**3) - 24*c**2*(b*x + c)**2.5/(5*b**3) + \
24*c*(b*x + c)**3.5/(7*b**3) - 8*(b*x + c)**4.5/(9*b**3))/(a - c)**3) == 0
assert MergeFactors(x, x) == x**2
assert MergeFactors(x*y, x) == x**2*y
def test_FactorInteger():
assert FactorInteger(2434500) == [(2, 2), (3, 2), (5, 3), (541, 1)]
def test_ContentFactor():
assert ContentFactor(a*b + a*c) == a*(b + c)
def test_Order():
assert Order(a, b) == 1
assert Order(b, a) == -1
assert Order(a, a) == 0
def test_FactorOrder():
assert FactorOrder(1, 1) == 0
assert FactorOrder(1, 2) == -1
assert FactorOrder(2, 1) == 1
assert FactorOrder(a, b) == 1
def test_Smallest():
assert Smallest([2, 1, 3, 4]) == 1
assert Smallest(1, 2) == 1
assert Smallest(-1, -2) == -2
def test_MostMainFactorPosition():
assert MostMainFactorPosition([S(1), S(2), S(3)]) == 1
assert MostMainFactorPosition([S(1), S(7), S(3), S(4), S(5)]) == 2
def test_OrderedQ():
assert OrderedQ([a, b])
assert not OrderedQ([b, a])
def test_MinimumDegree():
assert MinimumDegree(S(1), S(2)) == 1
assert MinimumDegree(S(1), sqrt(2)) == 1
assert MinimumDegree(sqrt(2), S(1)) == 1
assert MinimumDegree(sqrt(3), sqrt(2)) == sqrt(2)
assert MinimumDegree(sqrt(2), sqrt(2)) == sqrt(2)
def test_PositiveFactors():
assert PositiveFactors(S(0)) == 1
assert PositiveFactors(-S(1)) == S(1)
assert PositiveFactors(sqrt(2)) == sqrt(2)
assert PositiveFactors(-rubi_log(2)) == rubi_log(2)
assert PositiveFactors(sqrt(2)*S(-1)) == sqrt(2)
def test_NonpositiveFactors():
assert NonpositiveFactors(S(0)) == 0
assert NonpositiveFactors(-S(1)) == -1
assert NonpositiveFactors(sqrt(2)) == 1
assert NonpositiveFactors(-rubi_log(2)) == -1
def test_Sign():
assert Sign(S(0)) == 0
assert Sign(S(1)) == 1
assert Sign(-S(1)) == -1
def test_PolynomialInQ():
v = rubi_log(x)
assert PolynomialInQ(S(1), v, x)
assert PolynomialInQ(v, v, x)
assert PolynomialInQ(1 + v**2, v, x)
assert PolynomialInQ(1 + a*v**2, v, x)
assert not PolynomialInQ(sqrt(v), v, x)
def test_ExponentIn():
v = rubi_log(x)
assert ExponentIn(S(1), rubi_log(x), x) == 0
assert ExponentIn(S(1) + v, rubi_log(x), x) == 1
assert ExponentIn(S(1) + v + v**3, rubi_log(x), x) == 3
assert ExponentIn(S(2)*sqrt(v)*v**3, rubi_log(x), x) == 3.5
def test_PolynomialInSubst():
v = rubi_log(x)
assert PolynomialInSubst(S(1) + rubi_log(x)**3, rubi_log(x), x) == 1 + x**3
assert PolynomialInSubst(S(1) + rubi_log(x), rubi_log(x), x) == x + 1
def test_Distrib():
assert Distrib(x, a) == x*a
assert Distrib(x, a + b) == a*x + b*x
def test_DistributeDegree():
assert DistributeDegree(x, m) == x**m
assert DistributeDegree(x**a, m) == x**(a*m)
assert DistributeDegree(a*b, m) == a**m * b**m
def test_FunctionOfPower():
assert FunctionOfPower(a, x) == None
assert FunctionOfPower(x, x) == 1
assert FunctionOfPower(x**3, x) == 3
assert FunctionOfPower(x**3*cos(x**6), x) == 3
def test_DivideDegreesOfFactors():
assert DivideDegreesOfFactors(a**b, S(3)) == a**(b/3)
assert DivideDegreesOfFactors(a**b*c, S(3)) == a**(b/3)*c**(c/3)
def test_MonomialFactor():
assert MonomialFactor(a, x) == [0, a]
assert MonomialFactor(x, x) == [1, 1]
assert MonomialFactor(x + y, x) == [0, x + y]
assert MonomialFactor(rubi_log(x), x) == [0, rubi_log(x)]
assert MonomialFactor(rubi_log(x)*x, x) == [1, rubi_log(x)]
def test_NormalizeIntegrand():
assert NormalizeIntegrand((x**2 + 8), x) == x**2 + 8
assert NormalizeIntegrand((x**2 + 3*x)**2, x) == x**2*(x + 3)**2
assert NormalizeIntegrand(a**2*(a + b*x)**2, x) == a**2*(a + b*x)**2
assert NormalizeIntegrand(b**2/(a**2*(a + b*x)**2), x) == b**2/(a**2*(a + b*x)**2)
def test_NormalizeIntegrandAux():
v = (6*A*a*c - 2*A*b**2 + B*a*b)/(a*x**2) - (6*A*a**2*c**2 - 10*A*a*b**2*c - 8*A*a*b*c**2*x + 2*A*b**4 + 2*A*b**3*c*x + 5*B*a**2*b*c + 4*B*a**2*c**2*x - B*a*b**3 - B*a*b**2*c*x)/(a**2*(a + b*x + c*x**2)) + (-2*A*b + B*a)*(4*a*c - b**2)/(a**2*x)
assert NormalizeIntegrandAux(v, x) == (6*A*a*c - 2*A*b**2 + B*a*b)/(a*x**2) - (6*A*a**2*c**2 - 10*A*a*b**2*c + 2*A*b**4 + 5*B*a**2*b*c - B*a*b**3 + x*(-8*A*a*b*c**2 + 2*A*b**3*c + 4*B*a**2*c**2 - B*a*b**2*c))/(a**2*(a + b*x + c*x**2)) + (-2*A*b + B*a)*(4*a*c - b**2)/(a**2*x)
assert NormalizeIntegrandAux((x**2 + 3*x)**2, x) == x**2*(x + 3)**2
assert NormalizeIntegrandAux((x**2 + 8), x) == x**2 + 8
def test_NormalizeIntegrandFactor():
assert NormalizeIntegrandFactor((3*x + x**3)**2, x) == x**2*(x**2 + 3)**2
assert NormalizeIntegrandFactor((x**2 + 8), x) == x**2 + 8
def test_NormalizeIntegrandFactorBase():
assert NormalizeIntegrandFactorBase((x**2 + 8)**3, x) == (x**2 + 8)**3
assert NormalizeIntegrandFactorBase((x**2 + 8), x) == x**2 + 8
assert NormalizeIntegrandFactorBase(a**2*(a + b*x)**2, x) == a**2*(a + b*x)**2
def test_AbsorbMinusSign():
assert AbsorbMinusSign((x + 2)**5*(x + 3)**5) == (-x - 3)**5*(x + 2)**5
assert AbsorbMinusSign((x + 2)**5*(x + 3)**2) == -(x + 2)**5*(x + 3)**2
def test_NormalizeLeadTermSigns():
assert NormalizeLeadTermSigns((-x + 3)*(x**2 + 3)) == (-x + 3)*(x**2 + 3)
assert NormalizeLeadTermSigns(x + 3) == x + 3
def test_SignOfFactor():
assert SignOfFactor(S(-x + 3)) == [1, -x + 3]
assert SignOfFactor(S(-x)) == [-1, x]
def test_NormalizePowerOfLinear():
assert NormalizePowerOfLinear((x + 3)**5, x) == (x + 3)**5
assert NormalizePowerOfLinear(((x + 3)**2) + 3, x) == x**2 + 6*x + 12
def test_SimplifyIntegrand():
assert SimplifyIntegrand((x**2 + 3)**2, x) == (x**2 + 3)**2
assert SimplifyIntegrand(x**2 + 3 + (x**6) + 6, x) == x**6 + x**2 + 9
def test_SimplifyTerm():
assert SimplifyTerm(a**2/b**2, x) == a**2/b**2
assert SimplifyTerm(-6*x/5 + (5*x + 3)**2/25 - 9/25, x) == x**2
def test_togetherSimplify():
assert TogetherSimplify(-6*x/5 + (5*x + 3)**2/25 - 9/25) == x**2
def test_ExpandToSum():
qq = 6
Pqq = e**3
Pq = (d+e*x**2)**3
aa = 2
nn = 2
cc = 1
pp = -1/2
bb = 3
assert nsimplify(ExpandToSum(Pq - Pqq*x**qq - Pqq*(aa*x**(-2*nn + qq)*(-2*nn + qq + 1) + bb*x**(-nn + qq)*(nn*(pp - 1) + qq + 1))/(cc*(2*nn*pp + qq + 1)), x) - \
(d**3 + x**4*(3*d*e**2 - 2.4*e**3) + x**2*(3*d**2*e - 1.2*e**3))) == 0
assert ExpandToSum(x**2 + 3*x + 3, x**3 + 3, x) == x**3*(x**2 + 3*x + 3) + 3*x**2 + 9*x + 9
assert ExpandToSum(x**3 + 6, x) == x**3 + 6
assert ExpandToSum(S(x**2 + 3*x + 3)*3, x) == 3*x**2 + 9*x + 9
assert ExpandToSum((a + b*x), x) == a + b*x
def test_UnifySum():
assert UnifySum((3 + x + 6*x**3 + sin(x)), x) == 6*x**3 + x + sin(x) + 3
assert UnifySum((3 + x + 6*x**3)*3, x) == 18*x**3 + 3*x + 9
def test_FunctionOfInverseLinear():
assert FunctionOfInverseLinear((x)/(a + b*x), x) == [a, b]
assert FunctionOfInverseLinear((c + d*x)/(a + b*x), x) == [a, b]
assert not FunctionOfInverseLinear(1/(a + b*x), x)
def test_PureFunctionOfSinhQ():
v = rubi_log(x)
f = sinh(v)
assert PureFunctionOfSinhQ(f, v, x)
assert not PureFunctionOfSinhQ(cosh(v), v, x)
assert PureFunctionOfSinhQ(f**2, v, x)
def test_PureFunctionOfTanhQ():
v = rubi_log(x)
f = tanh(v)
assert PureFunctionOfTanhQ(f, v, x)
assert not PureFunctionOfTanhQ(cosh(v), v, x)
assert PureFunctionOfTanhQ(f**2, v, x)
def test_PureFunctionOfCoshQ():
v = rubi_log(x)
f = cosh(v)
assert PureFunctionOfCoshQ(f, v, x)
assert not PureFunctionOfCoshQ(sinh(v), v, x)
assert PureFunctionOfCoshQ(f**2, v, x)
def test_IntegerQuotientQ():
u = S(2)*sin(x)
v = sin(x)
assert IntegerQuotientQ(u, v)
assert IntegerQuotientQ(u, u)
assert not IntegerQuotientQ(S(1), S(2))
def test_OddQuotientQ():
u = S(3)*sin(x)
v = sin(x)
assert OddQuotientQ(u, v)
assert OddQuotientQ(u, u)
assert not OddQuotientQ(S(1), S(2))
def test_EvenQuotientQ():
u = S(2)*sin(x)
v = sin(x)
assert EvenQuotientQ(u, v)
assert not EvenQuotientQ(u, u)
assert not EvenQuotientQ(S(1), S(2))
def test_FunctionOfSinhQ():
v = rubi_log(x)
assert FunctionOfSinhQ(cos(sinh(v)), v, x)
assert FunctionOfSinhQ(sinh(v), v, x)
assert FunctionOfSinhQ(sinh(v)*cos(sinh(v)), v, x)
def test_FunctionOfCoshQ():
v = rubi_log(x)
assert FunctionOfCoshQ(cos(cosh(v)), v, x)
assert FunctionOfCoshQ(cosh(v), v, x)
assert FunctionOfCoshQ(cosh(v)*cos(cosh(v)), v, x)
def test_FunctionOfTanhQ():
v = rubi_log(x)
t = Tanh(v)
c = Coth(v)
assert FunctionOfTanhQ(t, v, x)
assert FunctionOfTanhQ(c, v, x)
assert FunctionOfTanhQ(t + c, v, x)
assert FunctionOfTanhQ(t*c, v, x)
assert not FunctionOfTanhQ(sin(x), v, x)
def test_FunctionOfTanhWeight():
v = rubi_log(x)
t = Tanh(v)
c = Coth(v)
assert FunctionOfTanhWeight(x, v, x) == 0
assert FunctionOfTanhWeight(sinh(v), v, x) == 0
assert FunctionOfTanhWeight(tanh(v), v, x) == 1
assert FunctionOfTanhWeight(coth(v), v, x) == -1
assert FunctionOfTanhWeight(t**2, v, x) == 1
assert FunctionOfTanhWeight(sinh(v)**2, v, x) == -1
assert FunctionOfTanhWeight(coth(v)*sinh(v)**2, v, x) == -2
def test_FunctionOfHyperbolicQ():
v = rubi_log(x)
s = Sinh(v)
t = Tanh(v)
assert not FunctionOfHyperbolicQ(x, v, x)
assert FunctionOfHyperbolicQ(s + t, v, x)
assert FunctionOfHyperbolicQ(sinh(t), v, x)
def test_SmartNumerator():
assert SmartNumerator(x**(-2)) == 1
assert SmartNumerator(x**(2)*a) == x**2*a
def test_SmartDenominator():
assert SmartDenominator(x**(-2)) == x**2
assert SmartDenominator(x**(-2)*1/S(3)) == x**2*3
def test_SubstForAux():
v = rubi_log(x)
assert SubstForAux(v, v, x) == x
assert SubstForAux(v**2, v, x) == x**2
assert SubstForAux(x, v, x) == x
assert SubstForAux(v**2, v**4, x) == sqrt(x)
assert SubstForAux(v**2*v, v, x) == x**3
def test_SubstForTrig():
v = rubi_log(x)
s, c, t = sin(v), cos(v), tan(v)
assert SubstForTrig(cos(a/2 + b*x/2), x/sqrt(x**2 + 1), 1/sqrt(x**2 + 1), a/2 + b*x/2, x) == 1/sqrt(x**2 + 1)
assert SubstForTrig(s, sin, cos, v, x) == sin
assert SubstForTrig(t, sin(v), cos(v), v, x) == sin(rubi_log(x))/cos(rubi_log(x))
assert SubstForTrig(sin(2*v), sin(x), cos(x), v, x) == 2*sin(x)*cos(x)
assert SubstForTrig(s*t, sin(x), cos(x), v, x) == sin(x)**2/cos(x)
def test_SubstForHyperbolic():
v = rubi_log(x)
s, c, t = sinh(v), cosh(v), tanh(v)
assert SubstForHyperbolic(s, sinh(x), cosh(x), v, x) == sinh(x)
assert SubstForHyperbolic(t, sinh(x), cosh(x), v, x) == sinh(x)/cosh(x)
assert SubstForHyperbolic(sinh(2*v), sinh(x), cosh(x), v, x) == 2*sinh(x)*cosh(x)
assert SubstForHyperbolic(s*t, sinh(x), cosh(x), v, x) == sinh(x)**2/cosh(x)
def test_SubstForFractionalPowerOfLinear():
u = a + b*x
assert not SubstForFractionalPowerOfLinear(u, x)
assert not SubstForFractionalPowerOfLinear(u**(S(2)), x)
assert SubstForFractionalPowerOfLinear(u**(S(1)/2), x) == [x**2, 2, a + b*x, 1/b]
def test_InverseFunctionOfLinear():
u = a + b*x
assert InverseFunctionOfLinear(rubi_log(u)*sin(x), x) == rubi_log(u)
assert InverseFunctionOfLinear(rubi_log(u), x) == rubi_log(u)
def test_InertTrigQ():
s = sin(x)
c = cos(x)
assert not InertTrigQ(sin(x), csc(x), cos(h))
assert InertTrigQ(sin(x), csc(x))
assert not InertTrigQ(s, c)
assert InertTrigQ(c)
def test_PowerOfInertTrigSumQ():
func = sin
assert PowerOfInertTrigSumQ((1 + S(2)*(S(3)*func(x**2))**S(5))**3, func, x)
assert PowerOfInertTrigSumQ((1 + 2*(S(3)*func(x**2))**3 + 4*(S(5)*func(x**2))**S(3))**2, func, x)
def test_PiecewiseLinearQ():
assert PiecewiseLinearQ(a + b*x, x)
assert not PiecewiseLinearQ(Log(c*sin(a)**S(3)), x)
assert not PiecewiseLinearQ(x**3, x)
assert PiecewiseLinearQ(atanh(tanh(a + b*x)), x)
assert PiecewiseLinearQ(tanh(atanh(a + b*x)), x)
assert not PiecewiseLinearQ(coth(atanh(a + b*x)), x)
def test_KnownTrigIntegrandQ():
func = sin(a + b*x)
assert KnownTrigIntegrandQ([sin], S(1), x)
assert KnownTrigIntegrandQ([sin], (a + b*func)**m, x)
assert KnownTrigIntegrandQ([sin], (a + b*func)**m*(1 + 2*func), x)
assert KnownTrigIntegrandQ([sin], a + c*func**2, x)
assert KnownTrigIntegrandQ([sin], a + b*func + c*func**2, x)
assert KnownTrigIntegrandQ([sin], (a + b*func)**m*(c + d*func**2), x)
assert KnownTrigIntegrandQ([sin], (a + b*func)**m*(c + d*func + e*func**2), x)
assert not KnownTrigIntegrandQ([cos], (a + b*func)**m, x)
def test_KnownSineIntegrandQ():
assert KnownSineIntegrandQ((a + b*sin(a + b*x))**m, x)
def test_KnownTangentIntegrandQ():
assert KnownTangentIntegrandQ((a + b*tan(a + b*x))**m, x)
def test_KnownCotangentIntegrandQ():
assert KnownCotangentIntegrandQ((a + b*cot(a + b*x))**m, x)
def test_KnownSecantIntegrandQ():
assert KnownSecantIntegrandQ((a + b*sec(a + b*x))**m, x)
def test_TryPureTanSubst():
assert TryPureTanSubst(atan(c*(a + b*tan(a + b*x))), x)
assert TryPureTanSubst(atanh(c*(a + b*cot(a + b*x))), x)
assert not TryPureTanSubst(tan(c*(a + b*cot(a + b*x))), x)
def test_TryPureTanhSubst():
assert not TryPureTanhSubst(rubi_log(x), x)
assert TryPureTanhSubst(sin(x), x)
assert not TryPureTanhSubst(atanh(a*tanh(x)), x)
assert not TryPureTanhSubst((a + b*x)**S(2), x)
def test_TryTanhSubst():
assert not TryTanhSubst(rubi_log(x), x)
assert not TryTanhSubst(a*(b + c)**3, x)
assert not TryTanhSubst(1/(a + b*sinh(x)**S(3)), x)
assert not TryTanhSubst(sinh(S(3)*x)*cosh(S(4)*x), x)
assert not TryTanhSubst(a*(b*sech(x)**3)**c, x)
def test_GeneralizedBinomialQ():
assert GeneralizedBinomialQ(a*x**q + b*x**n, x)
assert not GeneralizedBinomialQ(a*x**q, x)
def test_GeneralizedTrinomialQ():
assert not GeneralizedTrinomialQ(7 + 2*x**6 + 3*x**12, x)
assert not GeneralizedTrinomialQ(a*x**q + c*x**(2*n-q), x)
def test_SubstForFractionalPowerOfQuotientOfLinears():
assert SubstForFractionalPowerOfQuotientOfLinears(((a + b*x)/(c + d*x))**(S(3)/2), x) == [x**4/(b - d*x**2)**2, 2, (a + b*x)/(c + d*x), -a*d + b*c]
def test_SubstForFractionalPowerQ():
assert SubstForFractionalPowerQ(x, sin(x), x)
assert SubstForFractionalPowerQ(x**2, sin(x), x)
assert not SubstForFractionalPowerQ(x**(S(3)/2), sin(x), x)
assert SubstForFractionalPowerQ(sin(x)**(S(3)/2), sin(x), x)
def test_AbsurdNumberGCD():
assert AbsurdNumberGCD(S(4)) == 4
assert AbsurdNumberGCD(S(4), S(8), S(12)) == 4
assert AbsurdNumberGCD(S(2), S(3), S(12)) == 1
def test_TrigReduce():
assert TrigReduce(cos(x)**2) == cos(2*x)/2 + 1/2
assert TrigReduce(cos(x)**2*sin(x)) == sin(x)/4 + sin(3*x)/4
assert TrigReduce(cos(x)**2+sin(x)) == sin(x) + cos(2*x)/2 + 1/2
assert TrigReduce(cos(x)**2*sin(x)**5) == 5*sin(x)/64 + sin(3*x)/64 - 3*sin(5*x)/64 + sin(7*x)/64
assert TrigReduce(2*sin(x)*cos(x) + 2*cos(x)**2) == sin(2*x) + cos(2*x) + 1
assert TrigReduce(sinh(a + b*x)**2) == cosh(2*a + 2*b*x)/2 - 1/2
assert TrigReduce(sinh(a + b*x)*cosh(a + b*x)) == sinh(2*a + 2*b*x)/2
def test_FunctionOfDensePolynomialsQ():
assert FunctionOfDensePolynomialsQ(x**2 + 3, x)
assert not FunctionOfDensePolynomialsQ(x**2, x)
assert not FunctionOfDensePolynomialsQ(x, x)
assert FunctionOfDensePolynomialsQ(S(2), x)
def test_PureFunctionOfSinQ():
v = rubi_log(x)
f = sin(v)
assert PureFunctionOfSinQ(f, v, x)
assert not PureFunctionOfSinQ(cos(v), v, x)
assert PureFunctionOfSinQ(f**2, v, x)
def test_PureFunctionOfTanQ():
v = rubi_log(x)
f = tan(v)
assert PureFunctionOfTanQ(f, v, x)
assert not PureFunctionOfTanQ(cos(v), v, x)
assert PureFunctionOfTanQ(f**2, v, x)
def test_PowerVariableSubst():
assert PowerVariableSubst((2*x)**3, 2, x) == 8*x**(3/2)
assert PowerVariableSubst((2*x)**3, 2, x) == 8*x**(3/2)
assert PowerVariableSubst((2*x), 2, x) == 2*x
assert PowerVariableSubst((2*x)**3, 2, x) == 8*x**(3/2)
assert PowerVariableSubst((2*x)**7, 2, x) == 128*x**(7/2)
assert PowerVariableSubst((6+2*x)**7, 2, x) == (2*x + 6)**7
assert PowerVariableSubst((2*x)**7+3, 2, x) == 128*x**(7/2) + 3
def test_PowerVariableDegree():
assert PowerVariableDegree(S(2), 0, 2*x, x) == [0, 2*x]
assert PowerVariableDegree((2*x)**2, 0, 2*x, x) == [2, 1]
assert PowerVariableDegree(x**2, 0, 2*x, x) == [2, 1]
assert PowerVariableDegree(S(4), 0, 2*x, x) == [0, 2*x]
def test_PowerVariableExpn():
assert not PowerVariableExpn((x)**3, 2, x)
assert not PowerVariableExpn((2*x)**3, 2, x)
assert PowerVariableExpn((2*x)**2, 4, x) == [4*x**3, 2, 1]
def test_FunctionOfQ():
assert FunctionOfQ(x**2, sqrt(-exp(2*x**2) + 1)*exp(x**2),x)
assert not FunctionOfQ(S(x**3), x*2, x)
assert FunctionOfQ(S(a), x*2, x)
assert FunctionOfQ(S(3*x), x*2, x)
def test_ExpandTrigExpand():
assert ExpandTrigExpand(1, cos(x), x**2, 2, 2, x) == 4*cos(x**2)**4 - 4*cos(x**2)**2 + 1
assert ExpandTrigExpand(1, cos(x) + sin(x), x**2, 2, 2, x) == 4*sin(x**2)**2*cos(x**2)**2 + 8*sin(x**2)*cos(x**2)**3 - 4*sin(x**2)*cos(x**2) + 4*cos(x**2)**4 - 4*cos(x**2)**2 + 1
def test_TrigToExp():
from sympy.integrals.rubi.utility_function import rubi_exp as exp
assert TrigToExp(sin(x)) == -I*(exp(I*x) - exp(-I*x))/2
assert TrigToExp(cos(x)) == exp(I*x)/2 + exp(-I*x)/2
assert TrigToExp(cos(x)*tan(x**2)) == I*(exp(I*x)/2 + exp(-I*x)/2)*(-exp(I*x**2) + exp(-I*x**2))/(exp(I*x**2) + exp(-I*x**2))
assert TrigToExp(cos(x) + sin(x)**2) == -(exp(I*x) - exp(-I*x))**2/4 + exp(I*x)/2 + exp(-I*x)/2
assert Simplify(TrigToExp(cos(x)*tan(x**S(2))*sin(x)**S(2))-(-I*(exp(I*x)/S(2) + exp(-I*x)/S(2))*(exp(I*x) - exp(-I*x))**S(2)*(-exp(I*x**S(2)) + exp(-I*x**S(2)))/(S(4)*(exp(I*x**S(2)) + exp(-I*x**S(2)))))) == 0
def test_ExpandTrigReduce():
assert ExpandTrigReduce(2*cos(3 + x)**3, x) == 3*cos(x + 3)/2 + cos(3*x + 9)/2
assert ExpandTrigReduce(2*sin(x)**3+cos(2 + x), x) == 3*sin(x)/2 - sin(3*x)/2 + cos(x + 2)
assert ExpandTrigReduce(cos(x + 3)**2, x) == cos(2*x + 6)/2 + 1/2
def test_NormalizeTrig():
assert NormalizeTrig(S(2*sin(2 + x)), x) == 2*sin(x + 2)
assert NormalizeTrig(S(2*sin(2 + x)**3), x) == 2*sin(x + 2)**3
assert NormalizeTrig(S(2*sin((2 + x)**2)**3), x) == 2*sin(x**2 + 4*x + 4)**3
def test_FunctionOfTrigQ():
v = rubi_log(x)
s = sin(v)
t = tan(v)
assert not FunctionOfTrigQ(x, v, x)
assert FunctionOfTrigQ(s + t, v, x)
assert FunctionOfTrigQ(sin(t), v, x)
def test_RationalFunctionExpand():
assert RationalFunctionExpand(x**S(5)*(e + f*x)**n/(a + b*x**S(3)), x) == -a*x**2*(e + f*x)**n/(b*(a + b*x**3)) +\
e**2*(e + f*x)**n/(b*f**2) - 2*e*(e + f*x)**(n + 1)/(b*f**2) + (e + f*x)**(n + 2)/(b*f**2)
assert RationalFunctionExpand(x**S(3)*(S(2)*x + 2)**S(2)/(2*x**2 + 1), x) == 2*x**3 + 4*x**2 + x + (- x + 2)/(2*x**2 + 1) - 2
assert RationalFunctionExpand((a + b*x + c*x**4)*rubi_log(x)**3, x) == a*rubi_log(x)**3 + b*x*rubi_log(x)**3 + c*x**4*rubi_log(x)**3
assert RationalFunctionExpand(a + b*x + c*x**4, x) == a + b*x + c*x**4
def test_SameQ():
assert SameQ(1, 1, 1)
assert not SameQ(1, 1, 2)
def test_Map2():
assert Map2(Add, [a, b, c], [x, y, z]) == [a + x, b + y, c + z]
def test_ConstantFactor():
assert ConstantFactor(a + a*x**3, x) == [a, x**3 + 1]
assert ConstantFactor(a, x) == [a, 1]
assert ConstantFactor(x, x) == [1, x]
assert ConstantFactor(x**S(3), x) == [1, x**3]
assert ConstantFactor(x**(S(3)/2), x) == [1, x**(3/2)]
assert ConstantFactor(a*x**3, x) == [a, x**3]
assert ConstantFactor(a + x**3, x) == [1, a + x**3]
def test_CommonFactors():
assert CommonFactors([a, a, a]) == [a, 1, 1, 1]
assert CommonFactors([x*S(2), x**S(3)*S(2), sin(x)*x*S(2)]) == [2, x, x**3, x*sin(x)]
assert CommonFactors([x, x**S(3), sin(x)*x]) == [1, x, x**3, x*sin(x)]
assert CommonFactors([S(2), S(4), S(6)]) == [2, 1, 2, 3]
def test_FunctionOfLinear():
f = sin(a + b*x)
assert FunctionOfLinear(f, x) == [sin(x), a, b]
assert FunctionOfLinear(a + b*x, x) == [x, a, b]
assert not FunctionOfLinear(a, x)
def test_FunctionOfExponentialQ():
assert FunctionOfExponentialQ(exp(x + exp(x) + exp(exp(x))), x)
assert FunctionOfExponentialQ(a**(a + b*x), x)
assert FunctionOfExponentialQ(a**(b*x), x)
assert not FunctionOfExponentialQ(a**sin(a + b*x), x)
def test_FunctionOfExponential():
assert FunctionOfExponential(a**(a + b*x), x)
def test_FunctionOfExponentialFunction():
assert FunctionOfExponentialFunction(a**(a + b*x), x) == x
assert FunctionOfExponentialFunction(S(2)*a**(a + b*x), x) == 2*x
def test_FunctionOfTrig():
assert FunctionOfTrig(sin(x + 1), x + 1, x) == x + 1
assert FunctionOfTrig(sin(x), x) == x
assert not FunctionOfTrig(cos(x**2 + 1), x)
assert FunctionOfTrig(sin(a+b*x)**3, x) == a+b*x
def test_AlgebraicTrigFunctionQ():
assert AlgebraicTrigFunctionQ(sin(x + 3), x)
assert AlgebraicTrigFunctionQ(x, x)
assert AlgebraicTrigFunctionQ(x + 1, x)
assert AlgebraicTrigFunctionQ(sinh(x + 1), x)
assert AlgebraicTrigFunctionQ(sinh(x + 1)**2, x)
assert not AlgebraicTrigFunctionQ(sinh(x**2 + 1)**2, x)
def test_FunctionOfHyperbolic():
assert FunctionOfTrig(sin(x + 1), x + 1, x) == x + 1
assert FunctionOfTrig(sin(x), x) == x
assert not FunctionOfTrig(cos(x**2 + 1), x)
def test_FunctionOfExpnQ():
assert FunctionOfExpnQ(x, x, x) == 1
assert FunctionOfExpnQ(x**2, x, x) == 2
assert FunctionOfExpnQ(x**2.1, x, x) == 1
assert not FunctionOfExpnQ(x, x**2, x)
assert not FunctionOfExpnQ(x + 1, (x + 5)**2, x)
assert not FunctionOfExpnQ(x + 1, (x + 1)**2, x)
def test_PureFunctionOfCosQ():
v = rubi_log(x)
f = cos(v)
assert PureFunctionOfCosQ(f, v, x)
assert not PureFunctionOfCosQ(sin(v), v, x)
assert PureFunctionOfCosQ(f**2, v, x)
def test_PureFunctionOfCotQ():
v = rubi_log(x)
f = cot(v)
assert PureFunctionOfCotQ(f, v, x)
assert not PureFunctionOfCotQ(sin(v), v, x)
assert PureFunctionOfCotQ(f**2, v, x)
def test_FunctionOfSinQ():
v = rubi_log(x)
assert FunctionOfSinQ(cos(sin(v)), v, x)
assert FunctionOfSinQ(sin(v), v, x)
assert FunctionOfSinQ(sin(v)*cos(sin(v)), v, x)
def test_FunctionOfCosQ():
v = rubi_log(x)
assert FunctionOfCosQ(cos(cos(v)), v, x)
assert FunctionOfCosQ(cos(v), v, x)
assert FunctionOfCosQ(cos(v)*cos(cos(v)), v, x)
def test_FunctionOfTanQ():
v = rubi_log(x)
t = tan(v)
c = cot(v)
assert FunctionOfTanQ(t, v, x)
assert FunctionOfTanQ(c, v, x)
assert FunctionOfTanQ(t + c, v, x)
assert FunctionOfTanQ(t*c, v, x)
assert not FunctionOfTanQ(sin(x), v, x)
def test_FunctionOfTanWeight():
v = rubi_log(x)
t = tan(v)
c = cot(v)
assert FunctionOfTanWeight(x, v, x) == 0
assert FunctionOfTanWeight(sin(v), v, x) == 0
assert FunctionOfTanWeight(tan(v), v, x) == 1
assert FunctionOfTanWeight(cot(v), v, x) == -1
assert FunctionOfTanWeight(t**2, v, x) == 1
assert FunctionOfTanWeight(sin(v)**2, v, x) == -1
assert FunctionOfTanWeight(cot(v)*sin(v)**2, v, x) == -2
def test_OddTrigPowerQ():
assert not OddTrigPowerQ(sin(x)**3, 1, x)
assert OddTrigPowerQ(sin(3),1,x)
assert OddTrigPowerQ(sin(3*x),x,x)
assert OddTrigPowerQ(sin(3*x)**3,x,x)
def test_FunctionOfLog():
assert not FunctionOfLog(x**2*(a + b*x)**3*exp(-a - b*x) ,False, False, x)
assert FunctionOfLog(rubi_log(2*x**8)*2 + rubi_log(2*x**8) + 1, x) == [3*x + 1, 2*x**8, 8]
assert FunctionOfLog(rubi_log(2*x)**2,x) == [x**2, 2*x, 1]
assert FunctionOfLog(rubi_log(3*x**3)**2 + 1,x) == [x**2 + 1, 3*x**3, 3]
assert FunctionOfLog(rubi_log(2*x**8)*2,x) == [2*x, 2*x**8, 8]
assert not FunctionOfLog(2*sin(x)*2,x)
def test_EulerIntegrandQ():
assert EulerIntegrandQ((2*x + 3*((x + 1)**3)**1.5)**(-3), x)
assert not EulerIntegrandQ((2*x + (2*x**2)**2)**3, x)
assert not EulerIntegrandQ(3*x**2 + 5*x + 1, x)
def test_Divides():
assert not Divides(x, a*x**2, x)
assert Divides(x, a*x, x) == a
def test_EasyDQ():
assert EasyDQ(3*x**2, x)
assert EasyDQ(3*x**3 - 6, x)
assert EasyDQ(x**3, x)
assert EasyDQ(sin(x**rubi_log(3)), x)
def test_ProductOfLinearPowersQ():
assert ProductOfLinearPowersQ(S(1), x)
assert ProductOfLinearPowersQ((x + 1)**3, x)
assert not ProductOfLinearPowersQ((x**2 + 1)**3, x)
assert ProductOfLinearPowersQ(x + 1, x)
def test_Rt():
b = symbols('b')
assert Rt(-b**2, 4) == (-b**2)**(S(1)/S(4))
assert Rt(x**2, 2) == x
assert Rt(S(2 + 3*I), S(8)) == (2 + 3*I)**(1/8)
assert Rt(x**2 + 4 + 4*x, 2) == x + 2
assert Rt(S(8), S(3)) == 2
assert Rt(S(16807), S(5)) == 7
def test_NthRoot():
assert NthRoot(S(14580), S(3)) == 9*2**(S(2)/S(3))*5**(S(1)/S(3))
assert NthRoot(9, 2) == 3.0
assert NthRoot(81, 2) == 9.0
assert NthRoot(81, 4) == 3.0
def test_AtomBaseQ():
assert not AtomBaseQ(x**2)
assert AtomBaseQ(x**3)
assert AtomBaseQ(x)
assert AtomBaseQ(S(2)**3)
assert not AtomBaseQ(sin(x))
def test_SumBaseQ():
assert not SumBaseQ((x + 1)**2)
assert SumBaseQ((x + 1)**3)
assert SumBaseQ(3*x+3)
assert not SumBaseQ(x)
def test_NegSumBaseQ():
assert not NegSumBaseQ(-x + 1)
assert NegSumBaseQ(x - 1)
assert not NegSumBaseQ((x - 1)**2)
assert NegSumBaseQ((x - 1)**3)
def test_AllNegTermQ():
x = Symbol('x', negative=True)
assert AllNegTermQ(x)
assert not AllNegTermQ(x + 2)
assert AllNegTermQ(x - 2)
assert AllNegTermQ((x - 2)**3)
assert not AllNegTermQ((x - 2)**2)
def test_TrigSquareQ():
assert TrigSquareQ(sin(x)**2)
assert TrigSquareQ(cos(x)**2)
assert not TrigSquareQ(tan(x)**2)
def test_Inequality():
assert not Inequality(S('0'), Less, m, LessEqual, S('1'))
assert Inequality(S('0'), Less, S('1'))
assert Inequality(S('0'), Less, S('1'), LessEqual, S('5'))
def test_SplitProduct():
assert SplitProduct(OddQ, S(3)*x) == [3, x]
assert not SplitProduct(OddQ, S(2)*x)
def test_SplitSum():
assert SplitSum(FracPart, sin(x)) == [sin(x), 0]
assert SplitSum(FracPart, sin(x) + S(2)) == [sin(x), S(2)]
def test_Complex():
assert Complex(a, b) == a + I*b
def test_SimpFixFactor():
assert SimpFixFactor((a*c + b*c)**S(4), x) == (a*c + b*c)**4
assert SimpFixFactor((a*Complex(0, c) + b*Complex(0, d))**S(3), x) == -I*(a*c + b*d)**3
assert SimpFixFactor((a*Complex(0, d) + b*Complex(0, e) + c*Complex(0, f))**S(2), x) == -(a*d + b*e + c*f)**2
assert SimpFixFactor((a + b*x**(-1/S(2))*x**S(3))**S(3), x) == (a + b*x**(5/2))**3
assert SimpFixFactor((a*c + b*c**S(2)*x**S(2))**S(3), x) == c**3*(a + b*c*x**2)**3
assert SimpFixFactor((a*c**S(2) + b*c**S(1)*x**S(2))**S(3), x) == c**3*(a*c + b*x**2)**3
assert SimpFixFactor(a*cos(x)**2 + a*sin(x)**2 + v, x) == a*cos(x)**2 + a*sin(x)**2 + v
def test_SimplifyAntiderivative():
assert SimplifyAntiderivative(acoth(coth(x)), x) == x
assert SimplifyAntiderivative(a*x, x) == a*x
assert SimplifyAntiderivative(atanh(cot(x)), x) == atanh(2*sin(x)*cos(x))/2
assert SimplifyAntiderivative(a*cos(x)**2 + a*sin(x)**2 + v, x) == a*cos(x)**2 + a*sin(x)**2
def test_FixSimplify():
assert FixSimplify(x*Complex(0, a)*(v*Complex(0, b) + w)**S(3)) == a*x*(b*v - I*w)**3
def test_TrigSimplifyAux():
assert TrigSimplifyAux(a*cos(x)**2 + a*sin(x)**2 + v) == a + v
assert TrigSimplifyAux(x**2) == x**2
def test_SubstFor():
assert SubstFor(x**2 + 1, tanh(x), x) == tanh(x)
assert SubstFor(x**2, sinh(x), x) == sinh(sqrt(x))
def test_FresnelS():
assert FresnelS(oo) == 1/2
assert FresnelS(0) == 0
def test_FresnelC():
assert FresnelC(0) == 0
assert FresnelC(oo) == 1/2
def test_Erfc():
assert Erfc(0) == 1
assert Erfc(oo) == 0
def test_Erfi():
assert Erfi(oo) is oo
assert Erfi(0) == 0
def test_Gamma():
assert Gamma(u) == gamma(u)
def test_ElementaryFunctionQ():
assert ElementaryFunctionQ(x + y)
assert ElementaryFunctionQ(sin(x + y))
assert ElementaryFunctionQ(E**(x*a))
def test_Util_Part():
from sympy.integrals.rubi.utility_function import Util_Part
assert Util_Part(1, a + b).doit() == a
assert Util_Part(c, a + b).doit() == Util_Part(c, a + b)
def test_Part():
assert Part([1, 2, 3], 1) == 1
assert Part(a*b, 1) == a
def test_PolyLog():
assert PolyLog(a, b) == polylog(a, b)
def test_PureFunctionOfCothQ():
v = rubi_log(x)
assert PureFunctionOfCothQ(coth(v), v, x)
assert PureFunctionOfCothQ(a + coth(v), v, x)
assert not PureFunctionOfCothQ(sin(v), v, x)
def test_ExpandIntegrand():
assert ExpandIntegrand(sqrt(a + b*x**S(2) + c*x**S(4)), (f*x)**(S(3)/2)*(d + e*x**S(2)), x) == \
d*(f*x)**(3/2)*sqrt(a + b*x**2 + c*x**4) + e*(f*x)**(7/2)*sqrt(a + b*x**2 + c*x**4)/f**2
assert ExpandIntegrand((6*A*a*c - 2*A*b**2 + B*a*b - 2*c*x*(A*b - 2*B*a))/(x**2*(a + b*x + c*x**2)), x) == \
(6*A*a*c - 2*A*b**2 + B*a*b)/(a*x**2) + (-6*A*a**2*c**2 + 10*A*a*b**2*c - 2*A*b**4 - 5*B*a**2*b*c + B*a*b**3 + x*(8*A*a*b*c**2 - 2*A*b**3*c - 4*B*a**2*c**2 + B*a*b**2*c))/(a**2*(a + b*x + c*x**2)) + (-2*A*b + B*a)*(4*a*c - b**2)/(a**2*x)
assert ExpandIntegrand(x**2*(e + f*x)**3*F**(a + b*(c + d*x)**1), x) == F**(a + b*(c + d*x))*e**2*(e + f*x)**3/f**2 - 2*F**(a + b*(c + d*x))*e*(e + f*x)**4/f**2 + F**(a + b*(c + d*x))*(e + f*x)**5/f**2
assert ExpandIntegrand((x)*(a + b*x)**2*f**(e*(c + d*x)**n), x) == a**2*f**(e*(c + d*x)**n)*x + 2*a*b*f**(e*(c + d*x)**n)*x**2 + b**2*f**(e*(c + d*x)**n)*x**3
assert ExpandIntegrand(sin(x)**3*(a + b*(1/sin(x)))**2, x) == a**2*sin(x)**3 + 2*a*b*sin(x)**2 + b**2*sin(x)
assert ExpandIntegrand(x*(a + b*ArcSin(c + d*x))**n, x) == -c*(a + b*asin(c + d*x))**n/d + (a + b*asin(c + d*x))**n*(c + d*x)/d
assert ExpandIntegrand((a + b*x)**S(3)*(A + B*x)/(c + d*x), x) == B*(a + b*x)**3/d + b*(a + b*x)**2*(A*d - B*c)/d**2 + b*(a + b*x)*(A*d - B*c)*(a*d - b*c)/d**3 + b*(A*d - B*c)*(a*d - b*c)**2/d**4 + (A*d - B*c)*(a*d - b*c)**3/(d**4*(c + d*x))
assert ExpandIntegrand((x**2)*(S(3)*x)**(S(1)/2), x) ==sqrt(3)*x**(5/2)
assert ExpandIntegrand((x)*(sin(x))**(S(1)/2), x) == x*sqrt(sin(x))
assert ExpandIntegrand(x*(e + f*x)**2*F**(b*(c + d*x)), x) == -F**(b*(c + d*x))*e*(e + f*x)**2/f + F**(b*(c + d*x))*(e + f*x)**3/f
assert ExpandIntegrand(x**m*(e + f*x)**2*F**(b*(c + d*x)**n), x) == F**(b*(c + d*x)**n)*e**2*x**m + 2*F**(b*(c + d*x)**n)*e*f*x*x**m + F**(b*(c + d*x)**n)*f**2*x**2*x**m
assert simplify(ExpandIntegrand((S(1) - S(1)*x**S(2))**(-S(3)), x) - (-S(3)/(8*(x**2 - 1)) + S(3)/(16*(x + 1)**2) + S(1)/(S(8)*(x + 1)**3) + S(3)/(S(16)*(x - 1)**2) - S(1)/(S(8)*(x - 1)**3))) == 0
assert ExpandIntegrand(-S(1), 1/((-q - x)**3*(q - x)**3), x) == 1/(8*q**3*(q + x)**3) - 1/(8*q**3*(-q + x)**3) - 3/(8*q**4*(-q**2 + x**2)) + 3/(16*q**4*(q + x)**2) + 3/(16*q**4*(-q + x)**2)
assert ExpandIntegrand((1 + 1*x)**(3)/(2 + 1*x), x) == x**2 + x + 1 - 1/(x + 2)
assert ExpandIntegrand((c + d*x**1 + e*x**2)/(1 - x**3), x) == (c - (-1)**(S(1)/3)*d + (-1)**(S(2)/3)*e)/(-3*(-1)**(S(2)/3)*x + 3) + (c + (-1)**(S(2)/3)*d - (-1)**(S(1)/3)*e)/(3*(-1)**(S(1)/3)*x + 3) + (c + d + e)/(-3*x + 3)
assert ExpandIntegrand((c + d*x**1 + e*x**2 + f*x**3)/(1 - x**4), x) == (c + I*d - e - I*f)/(4*I*x + 4) + (c - I*d - e + I*f)/(-4*I*x + 4) + (c - d + e - f)/(4*x + 4) + (c + d + e + f)/(-4*x + 4)
assert ExpandIntegrand((d + e*(f + g*x))/(2 + 3*x + 1*x**2), x) == (-2*d - 2*e*f + 4*e*g)/(2*x + 4) + (2*d + 2*e*f - 2*e*g)/(2*x + 2)
assert ExpandIntegrand(x/(a*x**3 + b*Sqrt(c + d*x**6)), x) == a*x**4/(-b**2*c + x**6*(a**2 - b**2*d)) + b*x*sqrt(c + d*x**6)/(b**2*c + x**6*(-a**2 + b**2*d))
assert simplify(ExpandIntegrand(x**1*(1 - x**4)**(-2), x) - (x/(S(4)*(x**2 + 1)) + x/(S(4)*(x**2 + 1)**2) - x/(S(4)*(x**2 - 1)) + x/(S(4)*(x**2 - 1)**2))) == 0
assert simplify(ExpandIntegrand((-1 + x**S(6))**(-3), x) - (S(3)/(S(8)*(x**6 - 1)) - S(3)/(S(16)*(x**S(3) + S(1))**S(2)) - S(1)/(S(8)*(x**S(3) + S(1))**S(3)) - S(3)/(S(16)*(x**S(3) - S(1))**S(2)) + S(1)/(S(8)*(x**S(3) - S(1))**S(3)))) == 0
assert simplify(ExpandIntegrand(u**1*(a + b*u**2 + c*u**4)**(-1), x)) == simplify(1/(2*b*(u + sqrt(-(a + c*u**4)/b))) - 1/(2*b*(-u + sqrt(-(a + c*u**4)/b))))
assert simplify(ExpandIntegrand((1 + 1*u + 1*u**2)**(-2), x) - (S(1)/(S(2)*(-u - 1)*(-u**2 - u - 1)) + S(1)/(S(4)*(-u - 1)*(u + sqrt(-u - 1))**2) + S(1)/(S(4)*(-u - 1)*(u - sqrt(-u - 1))**2))) == 0
assert ExpandIntegrand(x*(a + b*Log(c*(d*(e + f*x)**p)**q))**n, x) == -e*(a + b*rubi_log(c*(d*(e + f*x)**p)**q))**n/f + (a + b*rubi_log(c*(d*(e + f*x)**p)**q))**n*(e + f*x)/f
assert ExpandIntegrand(x*f**(e*(c + d*x)*S(1)), x) == f**(e*(c + d*x))*x
assert simplify(ExpandIntegrand((x)*(a + b*x)**m*Log(c*(d + e*x**n)**p), x) - (-a*(a + b*x)**m*rubi_log(c*(d + e*x**n)**p)/b + (a + b*x)**(m + S(1))*rubi_log(c*(d + e*x**n)**p)/b)) == 0
assert simplify(ExpandIntegrand(u*(a + b*F**v)**S(2)*(c + d*F**v)**S(-3), x) - (b**2*u/(d**2*(F**v*d + c)) + 2*b*u*(a*d - b*c)/(d**2*(F**v*d + c)**2) + u*(a*d - b*c)**2/(d**2*(F**v*d + c)**3))) == 0
assert ExpandIntegrand((S(1) + 1*x)**S(2)*f**(e*(1 + S(1)*x)**n)/(g + h*x), x) == f**(e*(x + 1)**n)*(x + 1)/h + f**(e*(x + 1)**n)*(-g + h)/h**2 + f**(e*(x + 1)**n)*(g - h)**2/(h**2*(g + h*x))
assert ExpandIntegrand((a*c - b*c*x)**2/(a + b*x)**2, x) == 4*a**2*c**2/(a + b*x)**2 - 4*a*c**2/(a + b*x) + c**2
assert simplify(ExpandIntegrand(x**2*(1 - 1*x**2)**(-2), x) - (1/(S(2)*(x**2 - 1)) + 1/(S(4)*(x + 1)**2) + 1/(S(4)*(x - 1)**2))) == 0
assert ExpandIntegrand((a + x)**2, x) == a**2 + 2*a*x + x**2
assert ExpandIntegrand((a + b*x)**S(2)/x**3, x) == a**2/x**3 + 2*a*b/x**2 + b**2/x
assert ExpandIntegrand(1/(x**2*(a + b*x)**2), x) == b**2/(a**2*(a + b*x)**2) + 1/(a**2*x**2) + 2*b**2/(a**3*(a + b*x)) - 2*b/(a**3*x)
assert ExpandIntegrand((1 + x)**3/x, x) == x**2 + 3*x + 3 + 1/x
assert ExpandIntegrand((1 + 2*(3 + 4*x**2))/(2 + 3*x**2 + 1*x**4), x) == 18/(2*x**2 + 4) - 2/(2*x**2 + 2)
assert ExpandIntegrand((c + d*x**2 + e*x**3)/(1 - 1*x**4), x) == (c - d - I*e)/(4*I*x + 4) + (c - d + I*e)/(-4*I*x + 4) + (c + d - e)/(4*x + 4) + (c + d + e)/(-4*x + 4)
assert ExpandIntegrand((a + b*x)**2/(c + d*x), x) == b*(a + b*x)/d + b*(a*d - b*c)/d**2 + (a*d - b*c)**2/(d**2*(c + d*x))
assert ExpandIntegrand(x**2*(a + b*Log(c*(d*(e + f*x)**p)**q))**n, x) == e**2*(a + b*rubi_log(c*(d*(e + f*x)**p)**q))**n/f**2 - 2*e*(a + b*rubi_log(c*(d*(e + f*x)**p)**q))**n*(e + f*x)/f**2 + (a + b*rubi_log(c*(d*(e + f*x)**p)**q))**n*(e + f*x)**2/f**2
assert ExpandIntegrand(x*(1 + 2*x)**3*rubi_log(2*(1 + 1*x**2)**1), x) == 8*x**4*rubi_log(2*x**2 + 2) + 12*x**3*rubi_log(2*x**2 + 2) + 6*x**2*rubi_log(2*x**2 + 2) + x*rubi_log(2*x**2 + 2)
assert ExpandIntegrand((1 + 1*x)**S(3)*f**(e*(1 + 1*x)**n)/(g + h*x), x) == f**(e*(x + 1)**n)*(x + 1)**2/h + f**(e*(x + 1)**n)*(-g + h)*(x + 1)/h**2 + f**(e*(x + 1)**n)*(-g + h)**2/h**3 - f**(e*(x + 1)**n)*(g - h)**3/(h**3*(g + h*x))
def test_Dist():
assert Dist(x, a + b, x) == a*x + b*x
assert Dist(x, Integral(a + b , x), x) == x*Integral(a + b, x)
assert Dist(3*x,(a+b), x) - Dist(2*x, (a+b), x) == a*x + b*x
assert Dist(3*x,(a+b), x) + Dist(2*x, (a+b), x) == 5*a*x + 5*b*x
assert Dist(x, c*Integral((a + b), x), x) == c*x*Integral(a + b, x)
def test_IntegralFreeQ():
assert not IntegralFreeQ(Integral(a, x))
assert IntegralFreeQ(a + b)
def test_OneQ():
from sympy.integrals.rubi.utility_function import OneQ
assert OneQ(S(1))
assert not OneQ(S(2))
def test_DerivativeDivides():
assert not DerivativeDivides(x, x, x)
assert not DerivativeDivides(a, x + y, b)
assert DerivativeDivides(a + x, a, x) == a
assert DerivativeDivides(a + b, x + y, b) == x + y
def test_LogIntegral():
from sympy.integrals.rubi.utility_function import LogIntegral
assert LogIntegral(a) == li(a)
def test_SinIntegral():
from sympy.integrals.rubi.utility_function import SinIntegral
assert SinIntegral(a) == Si(a)
def test_CosIntegral():
from sympy.integrals.rubi.utility_function import CosIntegral
assert CosIntegral(a) == Ci(a)
def test_SinhIntegral():
from sympy.integrals.rubi.utility_function import SinhIntegral
assert SinhIntegral(a) == Shi(a)
def test_CoshIntegral():
from sympy.integrals.rubi.utility_function import CoshIntegral
assert CoshIntegral(a) == Chi(a)
def test_ExpIntegralEi():
from sympy.integrals.rubi.utility_function import ExpIntegralEi
assert ExpIntegralEi(a) == Ei(a)
def test_ExpIntegralE():
from sympy.integrals.rubi.utility_function import ExpIntegralE
assert ExpIntegralE(a, z) == expint(a, z)
def test_LogGamma():
from sympy.integrals.rubi.utility_function import LogGamma
assert LogGamma(a) == loggamma(a)
def test_Factorial():
from sympy.integrals.rubi.utility_function import Factorial
assert Factorial(S(5)) == 120
def test_Zeta():
from sympy.integrals.rubi.utility_function import Zeta
assert Zeta(a, z) == zeta(a, z)
def test_HypergeometricPFQ():
from sympy.integrals.rubi.utility_function import HypergeometricPFQ
assert HypergeometricPFQ([a, b], [c], z) == hyper([a, b], [c], z)
def test_PolyGamma():
assert PolyGamma(S(2), S(3)) == polygamma(2, 3)
def test_ProductLog():
from sympy import N
assert N(ProductLog(S(5.0)), 5) == N(1.32672466524220, 5)
assert N(ProductLog(S(2), S(3.5)), 5) == N(-1.14064876353898 + 10.8912237027092*I, 5)
def test_PolynomialQuotient():
assert PolynomialQuotient(rubi_log((-a*d + b*c)/(b*(c + d*x)))/(c + d*x), a + b*x, e) == rubi_log((-a*d + b*c)/(b*(c + d*x)))/((a + b*x)*(c + d*x))
assert PolynomialQuotient(x**2, x + a, x) == -a + x
def test_PolynomialRemainder():
assert PolynomialRemainder(rubi_log((-a*d + b*c)/(b*(c + d*x)))/(c + d*x), a + b*x, e) == 0
assert PolynomialRemainder(x**2, x + a, x) == a**2
def test_Floor():
assert Floor(S(7.5)) == 7
assert Floor(S(15.5), S(6)) == 12
def test_Factor():
from sympy.integrals.rubi.utility_function import Factor
assert Factor(a*b + a*c) == a*(b + c)
def test_Rule():
from sympy.integrals.rubi.utility_function import Rule
assert Rule(x, S(5)) == {x: 5}
def test_Distribute():
assert Distribute((a + b)*c + (a + b)*d, Add) == c*(a + b) + d*(a + b)
assert Distribute((a + b)*(c + e), Add) == a*c + a*e + b*c + b*e
def test_CoprimeQ():
assert CoprimeQ(S(7), S(5))
assert not CoprimeQ(S(6), S(3))
def test_Discriminant():
from sympy.integrals.rubi.utility_function import Discriminant
assert Discriminant(a*x**2 + b*x + c, x) == b**2 - 4*a*c
assert unchanged(Discriminant, 1/x, x)
def test_Sum_doit():
assert Sum_doit(2*x + 2, [x, 0, 1.7]) == 6
def test_DeactivateTrig():
assert DeactivateTrig(sec(a + b*x), x) == sec(a + b*x)
def test_Negative():
from sympy.integrals.rubi.utility_function import Negative
assert Negative(S(-2))
assert not Negative(S(0))
def test_Quotient():
from sympy.integrals.rubi.utility_function import Quotient
assert Quotient(17, 5) == 3
def test_process_trig():
assert process_trig(x*cot(x)) == x/tan(x)
assert process_trig(coth(x)*csc(x)) == S(1)/(tanh(x)*sin(x))
def test_replace_pow_exp():
assert replace_pow_exp(rubi_exp(S(5))) == exp(S(5))
def test_rubi_unevaluated_expr():
from sympy.integrals.rubi.utility_function import rubi_unevaluated_expr
assert rubi_unevaluated_expr(a)*rubi_unevaluated_expr(b) == rubi_unevaluated_expr(b)*rubi_unevaluated_expr(a)
def test_rubi_exp():
# class name in utility_function is `exp`. To avoid confusion `rubi_exp` has been used here
assert isinstance(rubi_exp(a), Pow)
def test_rubi_log():
# class name in utility_function is `log`. To avoid confusion `rubi_log` has been used here
assert rubi_log(rubi_exp(S(a))) == a
|
2a57012ff499d0bbc4fc08ab620d35f5d7824fa69d5816971eb96ab79641ecf8 | import sys
from sympy.external import import_module
matchpy = import_module("matchpy")
if not matchpy:
#bin/test will not execute any tests now
disabled = True
if sys.version_info[:2] < (3, 6):
disabled = True
from sympy.integrals.rubi.rubi import rubi_integrate
from sympy.functions import log, sqrt, exp, cos, sin, tan, sec, csc, cot
from sympy.functions.elementary.hyperbolic import atanh, asinh, acosh
from sympy.functions.elementary.hyperbolic import atanh as arctanh
from sympy.functions.elementary.hyperbolic import asinh as arcsinh
from sympy.functions.elementary.hyperbolic import acosh as arccosh
from sympy.functions.elementary.trigonometric import atan, asin, acos
from sympy.functions.elementary.trigonometric import atan as arctan
from sympy.functions.elementary.trigonometric import asin as arcsin
from sympy.functions.elementary.trigonometric import acos as arccos
from sympy.integrals.rubi.utility_function import (EllipticE, EllipticF,
hypergeom, rubi_test, AppellF1, EllipticPi, Log, Sqrt, ArcTan, ArcTanh, ArcSin, Hypergeometric2F1)
from sympy import pi as Pi, elliptic_e, elliptic_f, elliptic_pi, Mod
from sympy import S, hyper, I, simplify, exp_polar, symbols, sqrt
from sympy.testing.pytest import SKIP
a, b, c, d, e, f, m, n, x, u , k, p, j, l , i= symbols('a b c d e f m n x u k p j l i1')
A, B, C, a, b, c, d, e, f, g, h, y, z, m, n, p, q, u, v, w, F = symbols('A B C a b c d e f g h y z m n p q u v w F', real=True, imaginary=False)
def test_1():
assert rubi_test(rubi_integrate(x**m*(b*x**S(2) + c*x**S(4)), x), x, b*x**(m + S(3))/(m + S(3)) + c*x**(m + S(5))/(m + S(5)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(b*x**S(2) + c*x**S(4)), x), x, b*x**S(5)/S(5) + c*x**S(7)/S(7), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(b*x**S(2) + c*x**S(4)), x), x, b*x**S(4)/S(4) + c*x**S(6)/S(6), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(b*x**S(2) + c*x**S(4), x), x, b*x**S(3)/S(3) + c*x**S(5)/S(5), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))/x, x), x, b*x**S(2)/S(2) + c*x**S(4)/S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))/x**S(2), x), x, b*x + c*x**S(3)/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))/x**S(3), x), x, b*log(x) + c*x**S(2)/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))/x**S(4), x), x, -b/x + c*x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))/x**S(5), x), x, -b/(S(2)*x**S(2)) + c*log(x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))/x**S(6), x), x, -b/(S(3)*x**S(3)) - c/x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))/x**S(7), x), x, -b/(S(4)*x**S(4)) - c/(S(2)*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))/x**S(8), x), x, -b/(S(5)*x**S(5)) - c/(S(3)*x**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**m*(b*x**S(2) + c*x**S(4))**S(2), x), x, b**S(2)*x**(m + S(5))/(m + S(5)) + S(2)*b*c*x**(m + S(7))/(m + S(7)) + c**S(2)*x**(m + S(9))/(m + S(9)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))**S(2), x), x, b**S(2)*x**S(5)/S(5) + S(2)*b*c*x**S(7)/S(7) + c**S(2)*x**S(9)/S(9), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))**S(2)/x, x), x, b**S(2)*x**S(4)/S(4) + b*c*x**S(6)/S(3) + c**S(2)*x**S(8)/S(8), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))**S(2)/x**S(2), x), x, b**S(2)*x**S(3)/S(3) + S(2)*b*c*x**S(5)/S(5) + c**S(2)*x**S(7)/S(7), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))**S(2)/x**S(3), x), x, (b + c*x**S(2))**S(3)/(S(6)*c), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))**S(2)/x**S(4), x), x, b**S(2)*x + S(2)*b*c*x**S(3)/S(3) + c**S(2)*x**S(5)/S(5), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))**S(2)/x**S(5), x), x, b**S(2)*log(x) + b*c*x**S(2) + c**S(2)*x**S(4)/S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))**S(2)/x**S(6), x), x, -b**S(2)/x + S(2)*b*c*x + c**S(2)*x**S(3)/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))**S(2)/x**S(7), x), x, -b**S(2)/(S(2)*x**S(2)) + S(2)*b*c*log(x) + c**S(2)*x**S(2)/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))**S(2)/x**S(8), x), x, -b**S(2)/(S(3)*x**S(3)) - S(2)*b*c/x + c**S(2)*x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))**S(2)/x**S(9), x), x, -b**S(2)/(S(4)*x**S(4)) - b*c/x**S(2) + c**S(2)*log(x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))**S(2)/x**S(10), x), x, -b**S(2)/(S(5)*x**S(5)) - S(2)*b*c/(S(3)*x**S(3)) - c**S(2)/x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))**S(2)/x**S(11), x), x, -(b + c*x**S(2))**S(3)/(S(6)*b*x**S(6)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))**S(2)/x**S(12), x), x, -b**S(2)/(S(7)*x**S(7)) - S(2)*b*c/(S(5)*x**S(5)) - c**S(2)/(S(3)*x**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**m*(b*x**S(2) + c*x**S(4))**S(3), x), x, b**S(3)*x**(m + S(7))/(m + S(7)) + S(3)*b**S(2)*c*x**(m + S(9))/(m + S(9)) + S(3)*b*c**S(2)*x**(m + S(11))/(m + S(11)) + c**S(3)*x**(m + S(13))/(m + S(13)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))**S(3)/x**S(2), x), x, b**S(3)*x**S(5)/S(5) + S(3)*b**S(2)*c*x**S(7)/S(7) + b*c**S(2)*x**S(9)/S(3) + c**S(3)*x**S(11)/S(11), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))**S(3)/x**S(3), x), x, -b*(b + c*x**S(2))**S(4)/(S(8)*c**S(2)) + (b + c*x**S(2))**S(5)/(S(10)*c**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))**S(3)/x**S(4), x), x, b**S(3)*x**S(3)/S(3) + S(3)*b**S(2)*c*x**S(5)/S(5) + S(3)*b*c**S(2)*x**S(7)/S(7) + c**S(3)*x**S(9)/S(9), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))**S(3)/x**S(5), x), x, (b + c*x**S(2))**S(4)/(S(8)*c), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))**S(3)/x**S(6), x), x, b**S(3)*x + b**S(2)*c*x**S(3) + S(3)*b*c**S(2)*x**S(5)/S(5) + c**S(3)*x**S(7)/S(7), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))**S(3)/x**S(7), x), x, b**S(3)*log(x) + S(3)*b**S(2)*c*x**S(2)/S(2) + S(3)*b*c**S(2)*x**S(4)/S(4) + c**S(3)*x**S(6)/S(6), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))**S(3)/x**S(8), x), x, -b**S(3)/x + S(3)*b**S(2)*c*x + b*c**S(2)*x**S(3) + c**S(3)*x**S(5)/S(5), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))**S(3)/x**S(9), x), x, -b**S(3)/(S(2)*x**S(2)) + S(3)*b**S(2)*c*log(x) + S(3)*b*c**S(2)*x**S(2)/S(2) + c**S(3)*x**S(4)/S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))**S(3)/x**S(10), x), x, -b**S(3)/(S(3)*x**S(3)) - S(3)*b**S(2)*c/x + S(3)*b*c**S(2)*x + c**S(3)*x**S(3)/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))**S(3)/x**S(11), x), x, -b**S(3)/(S(4)*x**S(4)) - S(3)*b**S(2)*c/(S(2)*x**S(2)) + S(3)*b*c**S(2)*log(x) + c**S(3)*x**S(2)/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))**S(3)/x**S(12), x), x, -b**S(3)/(S(5)*x**S(5)) - b**S(2)*c/x**S(3) - S(3)*b*c**S(2)/x + c**S(3)*x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))**S(3)/x**S(13), x), x, -b**S(3)/(S(6)*x**S(6)) - S(3)*b**S(2)*c/(S(4)*x**S(4)) - S(3)*b*c**S(2)/(S(2)*x**S(2)) + c**S(3)*log(x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))**S(3)/x**S(14), x), x, -b**S(3)/(S(7)*x**S(7)) - S(3)*b**S(2)*c/(S(5)*x**S(5)) - b*c**S(2)/x**S(3) - c**S(3)/x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))**S(3)/x**S(15), x), x, -(b + c*x**S(2))**S(4)/(S(8)*b*x**S(8)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))**S(3)/x**S(16), x), x, -b**S(3)/(S(9)*x**S(9)) - S(3)*b**S(2)*c/(S(7)*x**S(7)) - S(3)*b*c**S(2)/(S(5)*x**S(5)) - c**S(3)/(S(3)*x**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))**S(3)/x**S(17), x), x, -b**S(3)/(S(10)*x**S(10)) - S(3)*b**S(2)*c/(S(8)*x**S(8)) - b*c**S(2)/(S(2)*x**S(6)) - c**S(3)/(S(4)*x**S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(10)/(b*x**S(2) + c*x**S(4)), x), x, b**(S(7)/2)*atan(sqrt(c)*x/sqrt(b))/c**(S(9)/2) - b**S(3)*x/c**S(4) + b**S(2)*x**S(3)/(S(3)*c**S(3)) - b*x**S(5)/(S(5)*c**S(2)) + x**S(7)/(S(7)*c), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(9)/(b*x**S(2) + c*x**S(4)), x), x, -b**S(3)*log(b + c*x**S(2))/(S(2)*c**S(4)) + b**S(2)*x**S(2)/(S(2)*c**S(3)) - b*x**S(4)/(S(4)*c**S(2)) + x**S(6)/(S(6)*c), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(8)/(b*x**S(2) + c*x**S(4)), x), x, -b**(S(5)/2)*atan(sqrt(c)*x/sqrt(b))/c**(S(7)/2) + b**S(2)*x/c**S(3) - b*x**S(3)/(S(3)*c**S(2)) + x**S(5)/(S(5)*c), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(7)/(b*x**S(2) + c*x**S(4)), x), x, b**S(2)*log(b + c*x**S(2))/(S(2)*c**S(3)) - b*x**S(2)/(S(2)*c**S(2)) + x**S(4)/(S(4)*c), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(6)/(b*x**S(2) + c*x**S(4)), x), x, b**(S(3)/2)*atan(sqrt(c)*x/sqrt(b))/c**(S(5)/2) - b*x/c**S(2) + x**S(3)/(S(3)*c), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)/(b*x**S(2) + c*x**S(4)), x), x, -b*log(b + c*x**S(2))/(S(2)*c**S(2)) + x**S(2)/(S(2)*c), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)/(b*x**S(2) + c*x**S(4)), x), x, -sqrt(b)*atan(sqrt(c)*x/sqrt(b))/c**(S(3)/2) + x/c, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/(b*x**S(2) + c*x**S(4)), x), x, log(b + c*x**S(2))/(S(2)*c), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/(b*x**S(2) + c*x**S(4)), x), x, atan(sqrt(c)*x/sqrt(b))/(sqrt(b)*sqrt(c)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(b*x**S(2) + c*x**S(4)), x), x, log(x)/b - log(b + c*x**S(2))/(S(2)*b), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(b*x**S(2) + c*x**S(4)), x), x, -S(1)/(b*x) - sqrt(c)*atan(sqrt(c)*x/sqrt(b))/b**(S(3)/2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*(b*x**S(2) + c*x**S(4))), x), x, -S(1)/(S(2)*b*x**S(2)) - c*log(x)/b**S(2) + c*log(b + c*x**S(2))/(S(2)*b**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*(b*x**S(2) + c*x**S(4))), x), x, -S(1)/(S(3)*b*x**S(3)) + c/(b**S(2)*x) + c**(S(3)/2)*atan(sqrt(c)*x/sqrt(b))/b**(S(5)/2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(3)*(b*x**S(2) + c*x**S(4))), x), x, -S(1)/(S(4)*b*x**S(4)) + c/(S(2)*b**S(2)*x**S(2)) + c**S(2)*log(x)/b**S(3) - c**S(2)*log(b + c*x**S(2))/(S(2)*b**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(4)*(b*x**S(2) + c*x**S(4))), x), x, -S(1)/(S(5)*b*x**S(5)) + c/(S(3)*b**S(2)*x**S(3)) - c**S(2)/(b**S(3)*x) - c**(S(5)/2)*atan(sqrt(c)*x/sqrt(b))/b**(S(7)/2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(5)*(b*x**S(2) + c*x**S(4))), x), x, -S(1)/(S(6)*b*x**S(6)) + c/(S(4)*b**S(2)*x**S(4)) - c**S(2)/(S(2)*b**S(3)*x**S(2)) - c**S(3)*log(x)/b**S(4) + c**S(3)*log(b + c*x**S(2))/(S(2)*b**S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(12)/(b*x**S(2) + c*x**S(4))**S(2), x), x, -S(7)*b**(S(5)/2)*atan(sqrt(c)*x/sqrt(b))/(S(2)*c**(S(9)/2)) + S(7)*b**S(2)*x/(S(2)*c**S(4)) - S(7)*b*x**S(3)/(S(6)*c**S(3)) - x**S(7)/(S(2)*c*(b + c*x**S(2))) + S(7)*x**S(5)/(S(10)*c**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(11)/(b*x**S(2) + c*x**S(4))**S(2), x), x, b**S(3)/(S(2)*c**S(4)*(b + c*x**S(2))) + S(3)*b**S(2)*log(b + c*x**S(2))/(S(2)*c**S(4)) - b*x**S(2)/c**S(3) + x**S(4)/(S(4)*c**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(10)/(b*x**S(2) + c*x**S(4))**S(2), x), x, S(5)*b**(S(3)/2)*atan(sqrt(c)*x/sqrt(b))/(S(2)*c**(S(7)/2)) - S(5)*b*x/(S(2)*c**S(3)) - x**S(5)/(S(2)*c*(b + c*x**S(2))) + S(5)*x**S(3)/(S(6)*c**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(9)/(b*x**S(2) + c*x**S(4))**S(2), x), x, -b**S(2)/(S(2)*c**S(3)*(b + c*x**S(2))) - b*log(b + c*x**S(2))/c**S(3) + x**S(2)/(S(2)*c**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(8)/(b*x**S(2) + c*x**S(4))**S(2), x), x, -S(3)*sqrt(b)*atan(sqrt(c)*x/sqrt(b))/(S(2)*c**(S(5)/2)) - x**S(3)/(S(2)*c*(b + c*x**S(2))) + S(3)*x/(S(2)*c**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(7)/(b*x**S(2) + c*x**S(4))**S(2), x), x, b/(S(2)*c**S(2)*(b + c*x**S(2))) + log(b + c*x**S(2))/(S(2)*c**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(6)/(b*x**S(2) + c*x**S(4))**S(2), x), x, -x/(S(2)*c*(b + c*x**S(2))) + atan(sqrt(c)*x/sqrt(b))/(S(2)*sqrt(b)*c**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)/(b*x**S(2) + c*x**S(4))**S(2), x), x, -S(1)/(S(2)*c*(b + c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)/(b*x**S(2) + c*x**S(4))**S(2), x), x, x/(S(2)*b*(b + c*x**S(2))) + atan(sqrt(c)*x/sqrt(b))/(S(2)*b**(S(3)/2)*sqrt(c)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/(b*x**S(2) + c*x**S(4))**S(2), x), x, S(1)/(S(2)*b*(b + c*x**S(2))) + log(x)/b**S(2) - log(b + c*x**S(2))/(S(2)*b**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/(b*x**S(2) + c*x**S(4))**S(2), x), x, S(1)/(S(2)*b*x*(b + c*x**S(2))) - S(3)/(S(2)*b**S(2)*x) - S(3)*sqrt(c)*atan(sqrt(c)*x/sqrt(b))/(S(2)*b**(S(5)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(b*x**S(2) + c*x**S(4))**S(2), x), x, -c/(S(2)*b**S(2)*(b + c*x**S(2))) - S(1)/(S(2)*b**S(2)*x**S(2)) - S(2)*c*log(x)/b**S(3) + c*log(b + c*x**S(2))/b**S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))**(S(-2)), x), x, S(1)/(S(2)*b*x**S(3)*(b + c*x**S(2))) - S(5)/(S(6)*b**S(2)*x**S(3)) + S(5)*c/(S(2)*b**S(3)*x) + S(5)*c**(S(3)/2)*atan(sqrt(c)*x/sqrt(b))/(S(2)*b**(S(7)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*(b*x**S(2) + c*x**S(4))**S(2)), x), x, -S(1)/(S(4)*b**S(2)*x**S(4)) + c**S(2)/(S(2)*b**S(3)*(b + c*x**S(2))) + c/(b**S(3)*x**S(2)) + S(3)*c**S(2)*log(x)/b**S(4) - S(3)*c**S(2)*log(b + c*x**S(2))/(S(2)*b**S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*(b*x**S(2) + c*x**S(4))**S(2)), x), x, S(1)/(S(2)*b*x**S(5)*(b + c*x**S(2))) - S(7)/(S(10)*b**S(2)*x**S(5)) + S(7)*c/(S(6)*b**S(3)*x**S(3)) - S(7)*c**S(2)/(S(2)*b**S(4)*x) - S(7)*c**(S(5)/2)*atan(sqrt(c)*x/sqrt(b))/(S(2)*b**(S(9)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(14)/(b*x**S(2) + c*x**S(4))**S(3), x), x, S(35)*b**(S(3)/2)*atan(sqrt(c)*x/sqrt(b))/(S(8)*c**(S(9)/2)) - S(35)*b*x/(S(8)*c**S(4)) - x**S(7)/(S(4)*c*(b + c*x**S(2))**S(2)) - S(7)*x**S(5)/(S(8)*c**S(2)*(b + c*x**S(2))) + S(35)*x**S(3)/(S(24)*c**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(13)/(b*x**S(2) + c*x**S(4))**S(3), x), x, b**S(3)/(S(4)*c**S(4)*(b + c*x**S(2))**S(2)) - S(3)*b**S(2)/(S(2)*c**S(4)*(b + c*x**S(2))) - S(3)*b*log(b + c*x**S(2))/(S(2)*c**S(4)) + x**S(2)/(S(2)*c**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(12)/(b*x**S(2) + c*x**S(4))**S(3), x), x, -S(15)*sqrt(b)*atan(sqrt(c)*x/sqrt(b))/(S(8)*c**(S(7)/2)) - x**S(5)/(S(4)*c*(b + c*x**S(2))**S(2)) - S(5)*x**S(3)/(S(8)*c**S(2)*(b + c*x**S(2))) + S(15)*x/(S(8)*c**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(11)/(b*x**S(2) + c*x**S(4))**S(3), x), x, -b**S(2)/(S(4)*c**S(3)*(b + c*x**S(2))**S(2)) + b/(c**S(3)*(b + c*x**S(2))) + log(b + c*x**S(2))/(S(2)*c**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(10)/(b*x**S(2) + c*x**S(4))**S(3), x), x, -x**S(3)/(S(4)*c*(b + c*x**S(2))**S(2)) - S(3)*x/(S(8)*c**S(2)*(b + c*x**S(2))) + S(3)*atan(sqrt(c)*x/sqrt(b))/(S(8)*sqrt(b)*c**(S(5)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(9)/(b*x**S(2) + c*x**S(4))**S(3), x), x, x**S(4)/(S(4)*b*(b + c*x**S(2))**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(8)/(b*x**S(2) + c*x**S(4))**S(3), x), x, -x/(S(4)*c*(b + c*x**S(2))**S(2)) + x/(S(8)*b*c*(b + c*x**S(2))) + atan(sqrt(c)*x/sqrt(b))/(S(8)*b**(S(3)/2)*c**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(7)/(b*x**S(2) + c*x**S(4))**S(3), x), x, -S(1)/(S(4)*c*(b + c*x**S(2))**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(6)/(b*x**S(2) + c*x**S(4))**S(3), x), x, x/(S(4)*b*(b + c*x**S(2))**S(2)) + S(3)*x/(S(8)*b**S(2)*(b + c*x**S(2))) + S(3)*atan(sqrt(c)*x/sqrt(b))/(S(8)*b**(S(5)/2)*sqrt(c)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)/(b*x**S(2) + c*x**S(4))**S(3), x), x, S(1)/(S(4)*b*(b + c*x**S(2))**S(2)) + S(1)/(S(2)*b**S(2)*(b + c*x**S(2))) + log(x)/b**S(3) - log(b + c*x**S(2))/(S(2)*b**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)/(b*x**S(2) + c*x**S(4))**S(3), x), x, S(1)/(S(4)*b*x*(b + c*x**S(2))**S(2)) + S(5)/(S(8)*b**S(2)*x*(b + c*x**S(2))) - S(15)/(S(8)*b**S(3)*x) - S(15)*sqrt(c)*atan(sqrt(c)*x/sqrt(b))/(S(8)*b**(S(7)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/(b*x**S(2) + c*x**S(4))**S(3), x), x, -c/(S(4)*b**S(2)*(b + c*x**S(2))**S(2)) - c/(b**S(3)*(b + c*x**S(2))) - S(1)/(S(2)*b**S(3)*x**S(2)) - S(3)*c*log(x)/b**S(4) + S(3)*c*log(b + c*x**S(2))/(S(2)*b**S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/(b*x**S(2) + c*x**S(4))**S(3), x), x, S(1)/(S(4)*b*x**S(3)*(b + c*x**S(2))**S(2)) + S(7)/(S(8)*b**S(2)*x**S(3)*(b + c*x**S(2))) - S(35)/(S(24)*b**S(3)*x**S(3)) + S(35)*c/(S(8)*b**S(4)*x) + S(35)*c**(S(3)/2)*atan(sqrt(c)*x/sqrt(b))/(S(8)*b**(S(9)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(b*x**S(2) + c*x**S(4))**S(3), x), x, c**S(2)/(S(4)*b**S(3)*(b + c*x**S(2))**S(2)) - S(1)/(S(4)*b**S(3)*x**S(4)) + S(3)*c**S(2)/(S(2)*b**S(4)*(b + c*x**S(2))) + S(3)*c/(S(2)*b**S(4)*x**S(2)) + S(6)*c**S(2)*log(x)/b**S(5) - S(3)*c**S(2)*log(b + c*x**S(2))/b**S(5), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))**(S(-3)), x), x, S(1)/(S(4)*b*x**S(5)*(b + c*x**S(2))**S(2)) + S(9)/(S(8)*b**S(2)*x**S(5)*(b + c*x**S(2))) - S(63)/(S(40)*b**S(3)*x**S(5)) + S(21)*c/(S(8)*b**S(4)*x**S(3)) - S(63)*c**S(2)/(S(8)*b**S(5)*x) - S(63)*c**(S(5)/2)*atan(sqrt(c)*x/sqrt(b))/(S(8)*b**(S(11)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*(b*x**S(2) + c*x**S(4))**S(3)), x), x, -S(1)/(S(6)*b**S(3)*x**S(6)) - c**S(3)/(S(4)*b**S(4)*(b + c*x**S(2))**S(2)) + S(3)*c/(S(4)*b**S(4)*x**S(4)) - S(2)*c**S(3)/(b**S(5)*(b + c*x**S(2))) - S(3)*c**S(2)/(b**S(5)*x**S(2)) - S(10)*c**S(3)*log(x)/b**S(6) + S(5)*c**S(3)*log(b + c*x**S(2))/b**S(6), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)*sqrt(b*x**S(2) + c*x**S(4)), x), x, -S(5)*b**S(4)*atanh(sqrt(c)*x**S(2)/sqrt(b*x**S(2) + c*x**S(4)))/(S(128)*c**(S(7)/2)) + S(5)*b**S(2)*(b + S(2)*c*x**S(2))*sqrt(b*x**S(2) + c*x**S(4))/(S(128)*c**S(3)) - S(5)*b*(b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(48)*c**S(2)) + x**S(2)*(b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(8)*c), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*sqrt(b*x**S(2) + c*x**S(4)), x), x, b**S(3)*atanh(sqrt(c)*x**S(2)/sqrt(b*x**S(2) + c*x**S(4)))/(S(16)*c**(S(5)/2)) - b*(b + S(2)*c*x**S(2))*sqrt(b*x**S(2) + c*x**S(4))/(S(16)*c**S(2)) + (b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(6)*c), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*sqrt(b*x**S(2) + c*x**S(4)), x), x, -b**S(2)*atanh(sqrt(c)*x**S(2)/sqrt(b*x**S(2) + c*x**S(4)))/(S(8)*c**(S(3)/2)) + (b + S(2)*c*x**S(2))*sqrt(b*x**S(2) + c*x**S(4))/(S(8)*c), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(b*x**S(2) + c*x**S(4))/x, x), x, b*atanh(sqrt(c)*x**S(2)/sqrt(b*x**S(2) + c*x**S(4)))/(S(2)*sqrt(c)) + sqrt(b*x**S(2) + c*x**S(4))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(b*x**S(2) + c*x**S(4))/x**S(3), x), x, sqrt(c)*atanh(sqrt(c)*x**S(2)/sqrt(b*x**S(2) + c*x**S(4))) - sqrt(b*x**S(2) + c*x**S(4))/x**S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(b*x**S(2) + c*x**S(4))/x**S(5), x), x, -(b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(3)*b*x**S(6)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(b*x**S(2) + c*x**S(4))/x**S(7), x), x, -(b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(5)*b*x**S(8)) + S(2)*c*(b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(15)*b**S(2)*x**S(6)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(b*x**S(2) + c*x**S(4))/x**S(9), x), x, -(b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(7)*b*x**S(10)) + S(4)*c*(b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(35)*b**S(2)*x**S(8)) - S(8)*c**S(2)*(b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(105)*b**S(3)*x**S(6)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(b*x**S(2) + c*x**S(4))/x**S(11), x), x, -(b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(9)*b*x**S(12)) + S(2)*c*(b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(21)*b**S(2)*x**S(10)) - S(8)*c**S(2)*(b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(105)*b**S(3)*x**S(8)) + S(16)*c**S(3)*(b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(315)*b**S(4)*x**S(6)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(b*x**S(2) + c*x**S(4))/x**S(13), x), x, -(b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(11)*b*x**S(14)) + S(8)*c*(b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(99)*b**S(2)*x**S(12)) - S(16)*c**S(2)*(b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(231)*b**S(3)*x**S(10)) + S(64)*c**S(3)*(b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(1155)*b**S(4)*x**S(8)) - S(128)*c**S(4)*(b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(3465)*b**S(5)*x**S(6)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)*sqrt(b*x**S(2) + c*x**S(4)), x), x, S(8)*b**S(2)*(b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(105)*c**S(3)*x**S(3)) - S(4)*b*(b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(35)*c**S(2)*x) + x*(b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(7)*c), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*sqrt(b*x**S(2) + c*x**S(4)), x), x, -S(2)*b*(b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(15)*c**S(2)*x**S(3)) + (b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(5)*c*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(b*x**S(2) + c*x**S(4)), x), x, (b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(3)*c*x**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(b*x**S(2) + c*x**S(4))/x**S(2), x), x, -sqrt(b)*atanh(sqrt(b)*x/sqrt(b*x**S(2) + c*x**S(4))) + sqrt(b*x**S(2) + c*x**S(4))/x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(b*x**S(2) + c*x**S(4))/x**S(4), x), x, -sqrt(b*x**S(2) + c*x**S(4))/(S(2)*x**S(3)) - c*atanh(sqrt(b)*x/sqrt(b*x**S(2) + c*x**S(4)))/(S(2)*sqrt(b)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(b*x**S(2) + c*x**S(4))/x**S(6), x), x, -sqrt(b*x**S(2) + c*x**S(4))/(S(4)*x**S(5)) - c*sqrt(b*x**S(2) + c*x**S(4))/(S(8)*b*x**S(3)) + c**S(2)*atanh(sqrt(b)*x/sqrt(b*x**S(2) + c*x**S(4)))/(S(8)*b**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(b*x**S(2) + c*x**S(4))/x**S(8), x), x, -sqrt(b*x**S(2) + c*x**S(4))/(S(6)*x**S(7)) - c*sqrt(b*x**S(2) + c*x**S(4))/(S(24)*b*x**S(5)) + c**S(2)*sqrt(b*x**S(2) + c*x**S(4))/(S(16)*b**S(2)*x**S(3)) - c**S(3)*atanh(sqrt(b)*x/sqrt(b*x**S(2) + c*x**S(4)))/(S(16)*b**(S(5)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*(b*x**S(2) + c*x**S(4))**(S(3)/2), x), x, -S(3)*b**S(5)*atanh(sqrt(c)*x**S(2)/sqrt(b*x**S(2) + c*x**S(4)))/(S(256)*c**(S(7)/2)) + S(3)*b**S(3)*(b + S(2)*c*x**S(2))*sqrt(b*x**S(2) + c*x**S(4))/(S(256)*c**S(3)) - b*(b + S(2)*c*x**S(2))*(b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(32)*c**S(2)) + (b*x**S(2) + c*x**S(4))**(S(5)/2)/(S(10)*c), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(b*x**S(2) + c*x**S(4))**(S(3)/2), x), x, S(3)*b**S(4)*atanh(sqrt(c)*x**S(2)/sqrt(b*x**S(2) + c*x**S(4)))/(S(128)*c**(S(5)/2)) - S(3)*b**S(2)*(b + S(2)*c*x**S(2))*sqrt(b*x**S(2) + c*x**S(4))/(S(128)*c**S(2)) + (b + S(2)*c*x**S(2))*(b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(16)*c), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))**(S(3)/2)/x, x), x, -b**S(3)*atanh(sqrt(c)*x**S(2)/sqrt(b*x**S(2) + c*x**S(4)))/(S(16)*c**(S(3)/2)) + b*(b + S(2)*c*x**S(2))*sqrt(b*x**S(2) + c*x**S(4))/(S(16)*c) + (b*x**S(2) + c*x**S(4))**(S(3)/2)/S(6), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))**(S(3)/2)/x**S(3), x), x, S(3)*b**S(2)*atanh(sqrt(c)*x**S(2)/sqrt(b*x**S(2) + c*x**S(4)))/(S(8)*sqrt(c)) + S(3)*b*sqrt(b*x**S(2) + c*x**S(4))/S(8) + (b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(4)*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))**(S(3)/2)/x**S(5), x), x, S(3)*b*sqrt(c)*atanh(sqrt(c)*x**S(2)/sqrt(b*x**S(2) + c*x**S(4)))/S(2) + S(3)*c*sqrt(b*x**S(2) + c*x**S(4))/S(2) - (b*x**S(2) + c*x**S(4))**(S(3)/2)/x**S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))**(S(3)/2)/x**S(7), x), x, c**(S(3)/2)*atanh(sqrt(c)*x**S(2)/sqrt(b*x**S(2) + c*x**S(4))) - c*sqrt(b*x**S(2) + c*x**S(4))/x**S(2) - (b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(3)*x**S(6)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))**(S(3)/2)/x**S(9), x), x, -(b*x**S(2) + c*x**S(4))**(S(5)/2)/(S(5)*b*x**S(10)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))**(S(3)/2)/x**S(11), x), x, -(b*x**S(2) + c*x**S(4))**(S(5)/2)/(S(7)*b*x**S(12)) + S(2)*c*(b*x**S(2) + c*x**S(4))**(S(5)/2)/(S(35)*b**S(2)*x**S(10)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))**(S(3)/2)/x**S(13), x), x, -(b*x**S(2) + c*x**S(4))**(S(5)/2)/(S(9)*b*x**S(14)) + S(4)*c*(b*x**S(2) + c*x**S(4))**(S(5)/2)/(S(63)*b**S(2)*x**S(12)) - S(8)*c**S(2)*(b*x**S(2) + c*x**S(4))**(S(5)/2)/(S(315)*b**S(3)*x**S(10)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))**(S(3)/2)/x**S(15), x), x, -(b*x**S(2) + c*x**S(4))**(S(5)/2)/(S(11)*b*x**S(16)) + S(2)*c*(b*x**S(2) + c*x**S(4))**(S(5)/2)/(S(33)*b**S(2)*x**S(14)) - S(8)*c**S(2)*(b*x**S(2) + c*x**S(4))**(S(5)/2)/(S(231)*b**S(3)*x**S(12)) + S(16)*c**S(3)*(b*x**S(2) + c*x**S(4))**(S(5)/2)/(S(1155)*b**S(4)*x**S(10)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))**(S(3)/2)/x**S(17), x), x, -(b*x**S(2) + c*x**S(4))**(S(5)/2)/(S(13)*b*x**S(18)) + S(8)*c*(b*x**S(2) + c*x**S(4))**(S(5)/2)/(S(143)*b**S(2)*x**S(16)) - S(16)*c**S(2)*(b*x**S(2) + c*x**S(4))**(S(5)/2)/(S(429)*b**S(3)*x**S(14)) + S(64)*c**S(3)*(b*x**S(2) + c*x**S(4))**(S(5)/2)/(S(3003)*b**S(4)*x**S(12)) - S(128)*c**S(4)*(b*x**S(2) + c*x**S(4))**(S(5)/2)/(S(15015)*b**S(5)*x**S(10)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(6)*(b*x**S(2) + c*x**S(4))**(S(3)/2), x), x, S(128)*b**S(4)*(b*x**S(2) + c*x**S(4))**(S(5)/2)/(S(15015)*c**S(5)*x**S(5)) - S(64)*b**S(3)*(b*x**S(2) + c*x**S(4))**(S(5)/2)/(S(3003)*c**S(4)*x**S(3)) + S(16)*b**S(2)*(b*x**S(2) + c*x**S(4))**(S(5)/2)/(S(429)*c**S(3)*x) - S(8)*b*x*(b*x**S(2) + c*x**S(4))**(S(5)/2)/(S(143)*c**S(2)) + x**S(3)*(b*x**S(2) + c*x**S(4))**(S(5)/2)/(S(13)*c), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)*(b*x**S(2) + c*x**S(4))**(S(3)/2), x), x, -S(16)*b**S(3)*(b*x**S(2) + c*x**S(4))**(S(5)/2)/(S(1155)*c**S(4)*x**S(5)) + S(8)*b**S(2)*(b*x**S(2) + c*x**S(4))**(S(5)/2)/(S(231)*c**S(3)*x**S(3)) - S(2)*b*(b*x**S(2) + c*x**S(4))**(S(5)/2)/(S(33)*c**S(2)*x) + x*(b*x**S(2) + c*x**S(4))**(S(5)/2)/(S(11)*c), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(b*x**S(2) + c*x**S(4))**(S(3)/2), x), x, S(8)*b**S(2)*(b*x**S(2) + c*x**S(4))**(S(5)/2)/(S(315)*c**S(3)*x**S(5)) - S(4)*b*(b*x**S(2) + c*x**S(4))**(S(5)/2)/(S(63)*c**S(2)*x**S(3)) + (b*x**S(2) + c*x**S(4))**(S(5)/2)/(S(9)*c*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))**(S(3)/2), x), x, -S(2)*b*(b*x**S(2) + c*x**S(4))**(S(5)/2)/(S(35)*c**S(2)*x**S(5)) + (b*x**S(2) + c*x**S(4))**(S(5)/2)/(S(7)*c*x**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))**(S(3)/2)/x**S(2), x), x, (b*x**S(2) + c*x**S(4))**(S(5)/2)/(S(5)*c*x**S(5)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))**(S(3)/2)/x**S(4), x), x, -b**(S(3)/2)*atanh(sqrt(b)*x/sqrt(b*x**S(2) + c*x**S(4))) + b*sqrt(b*x**S(2) + c*x**S(4))/x + (b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(3)*x**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))**(S(3)/2)/x**S(6), x), x, -S(3)*sqrt(b)*c*atanh(sqrt(b)*x/sqrt(b*x**S(2) + c*x**S(4)))/S(2) + S(3)*c*sqrt(b*x**S(2) + c*x**S(4))/(S(2)*x) - (b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(2)*x**S(5)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))**(S(3)/2)/x**S(8), x), x, -S(3)*c*sqrt(b*x**S(2) + c*x**S(4))/(S(8)*x**S(3)) - (b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(4)*x**S(7)) - S(3)*c**S(2)*atanh(sqrt(b)*x/sqrt(b*x**S(2) + c*x**S(4)))/(S(8)*sqrt(b)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))**(S(3)/2)/x**S(10), x), x, -c*sqrt(b*x**S(2) + c*x**S(4))/(S(8)*x**S(5)) - (b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(6)*x**S(9)) - c**S(2)*sqrt(b*x**S(2) + c*x**S(4))/(S(16)*b*x**S(3)) + c**S(3)*atanh(sqrt(b)*x/sqrt(b*x**S(2) + c*x**S(4)))/(S(16)*b**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))**(S(3)/2)/x**S(12), x), x, -c*sqrt(b*x**S(2) + c*x**S(4))/(S(16)*x**S(7)) - (b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(8)*x**S(11)) - c**S(2)*sqrt(b*x**S(2) + c*x**S(4))/(S(64)*b*x**S(5)) + S(3)*c**S(3)*sqrt(b*x**S(2) + c*x**S(4))/(S(128)*b**S(2)*x**S(3)) - S(3)*c**S(4)*atanh(sqrt(b)*x/sqrt(b*x**S(2) + c*x**S(4)))/(S(128)*b**(S(5)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))**(S(3)/2)/x**S(14), x), x, -S(3)*c*sqrt(b*x**S(2) + c*x**S(4))/(S(80)*x**S(9)) - (b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(10)*x**S(13)) - c**S(2)*sqrt(b*x**S(2) + c*x**S(4))/(S(160)*b*x**S(7)) + c**S(3)*sqrt(b*x**S(2) + c*x**S(4))/(S(128)*b**S(2)*x**S(5)) - S(3)*c**S(4)*sqrt(b*x**S(2) + c*x**S(4))/(S(256)*b**S(3)*x**S(3)) + S(3)*c**S(5)*atanh(sqrt(b)*x/sqrt(b*x**S(2) + c*x**S(4)))/(S(256)*b**(S(7)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(7)/sqrt(b*x**S(2) + c*x**S(4)), x), x, -S(5)*b**S(3)*atanh(sqrt(c)*x**S(2)/sqrt(b*x**S(2) + c*x**S(4)))/(S(16)*c**(S(7)/2)) + S(5)*b**S(2)*sqrt(b*x**S(2) + c*x**S(4))/(S(16)*c**S(3)) - S(5)*b*x**S(2)*sqrt(b*x**S(2) + c*x**S(4))/(S(24)*c**S(2)) + x**S(4)*sqrt(b*x**S(2) + c*x**S(4))/(S(6)*c), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)/sqrt(b*x**S(2) + c*x**S(4)), x), x, S(3)*b**S(2)*atanh(sqrt(c)*x**S(2)/sqrt(b*x**S(2) + c*x**S(4)))/(S(8)*c**(S(5)/2)) - S(3)*b*sqrt(b*x**S(2) + c*x**S(4))/(S(8)*c**S(2)) + x**S(2)*sqrt(b*x**S(2) + c*x**S(4))/(S(4)*c), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/sqrt(b*x**S(2) + c*x**S(4)), x), x, -b*atanh(sqrt(c)*x**S(2)/sqrt(b*x**S(2) + c*x**S(4)))/(S(2)*c**(S(3)/2)) + sqrt(b*x**S(2) + c*x**S(4))/(S(2)*c), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/sqrt(b*x**S(2) + c*x**S(4)), x), x, atanh(sqrt(c)*x**S(2)/sqrt(b*x**S(2) + c*x**S(4)))/sqrt(c), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*sqrt(b*x**S(2) + c*x**S(4))), x), x, -sqrt(b*x**S(2) + c*x**S(4))/(b*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(3)*sqrt(b*x**S(2) + c*x**S(4))), x), x, -sqrt(b*x**S(2) + c*x**S(4))/(S(3)*b*x**S(4)) + S(2)*c*sqrt(b*x**S(2) + c*x**S(4))/(S(3)*b**S(2)*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(5)*sqrt(b*x**S(2) + c*x**S(4))), x), x, -sqrt(b*x**S(2) + c*x**S(4))/(S(5)*b*x**S(6)) + S(4)*c*sqrt(b*x**S(2) + c*x**S(4))/(S(15)*b**S(2)*x**S(4)) - S(8)*c**S(2)*sqrt(b*x**S(2) + c*x**S(4))/(S(15)*b**S(3)*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(7)*sqrt(b*x**S(2) + c*x**S(4))), x), x, -sqrt(b*x**S(2) + c*x**S(4))/(S(7)*b*x**S(8)) + S(6)*c*sqrt(b*x**S(2) + c*x**S(4))/(S(35)*b**S(2)*x**S(6)) - S(8)*c**S(2)*sqrt(b*x**S(2) + c*x**S(4))/(S(35)*b**S(3)*x**S(4)) + S(16)*c**S(3)*sqrt(b*x**S(2) + c*x**S(4))/(S(35)*b**S(4)*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)/sqrt(b*x**S(2) + c*x**S(4)), x), x, -S(2)*b*sqrt(b*x**S(2) + c*x**S(4))/(S(3)*c**S(2)*x) + x*sqrt(b*x**S(2) + c*x**S(4))/(S(3)*c), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/sqrt(b*x**S(2) + c*x**S(4)), x), x, sqrt(b*x**S(2) + c*x**S(4))/(c*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(b*x**S(2) + c*x**S(4)), x), x, -atanh(sqrt(b)*x/sqrt(b*x**S(2) + c*x**S(4)))/sqrt(b), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*sqrt(b*x**S(2) + c*x**S(4))), x), x, -sqrt(b*x**S(2) + c*x**S(4))/(S(2)*b*x**S(3)) + c*atanh(sqrt(b)*x/sqrt(b*x**S(2) + c*x**S(4)))/(S(2)*b**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(4)*sqrt(b*x**S(2) + c*x**S(4))), x), x, -sqrt(b*x**S(2) + c*x**S(4))/(S(4)*b*x**S(5)) + S(3)*c*sqrt(b*x**S(2) + c*x**S(4))/(S(8)*b**S(2)*x**S(3)) - S(3)*c**S(2)*atanh(sqrt(b)*x/sqrt(b*x**S(2) + c*x**S(4)))/(S(8)*b**(S(5)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(9)/(b*x**S(2) + c*x**S(4))**(S(3)/2), x), x, S(15)*b**S(2)*atanh(sqrt(c)*x**S(2)/sqrt(b*x**S(2) + c*x**S(4)))/(S(8)*c**(S(7)/2)) - S(15)*b*sqrt(b*x**S(2) + c*x**S(4))/(S(8)*c**S(3)) - x**S(6)/(c*sqrt(b*x**S(2) + c*x**S(4))) + S(5)*x**S(2)*sqrt(b*x**S(2) + c*x**S(4))/(S(4)*c**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(7)/(b*x**S(2) + c*x**S(4))**(S(3)/2), x), x, -S(3)*b*atanh(sqrt(c)*x**S(2)/sqrt(b*x**S(2) + c*x**S(4)))/(S(2)*c**(S(5)/2)) - x**S(4)/(c*sqrt(b*x**S(2) + c*x**S(4))) + S(3)*sqrt(b*x**S(2) + c*x**S(4))/(S(2)*c**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)/(b*x**S(2) + c*x**S(4))**(S(3)/2), x), x, -x**S(2)/(c*sqrt(b*x**S(2) + c*x**S(4))) + atanh(sqrt(c)*x**S(2)/sqrt(b*x**S(2) + c*x**S(4)))/c**(S(3)/2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/(b*x**S(2) + c*x**S(4))**(S(3)/2), x), x, x**S(2)/(b*sqrt(b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(b*x**S(2) + c*x**S(4))**(S(3)/2), x), x, -(b + S(2)*c*x**S(2))/(b**S(2)*sqrt(b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*(b*x**S(2) + c*x**S(4))**(S(3)/2)), x), x, S(1)/(b*x**S(2)*sqrt(b*x**S(2) + c*x**S(4))) - S(4)*sqrt(b*x**S(2) + c*x**S(4))/(S(3)*b**S(2)*x**S(4)) + S(8)*c*sqrt(b*x**S(2) + c*x**S(4))/(S(3)*b**S(3)*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(3)*(b*x**S(2) + c*x**S(4))**(S(3)/2)), x), x, S(1)/(b*x**S(4)*sqrt(b*x**S(2) + c*x**S(4))) - S(6)*sqrt(b*x**S(2) + c*x**S(4))/(S(5)*b**S(2)*x**S(6)) + S(8)*c*sqrt(b*x**S(2) + c*x**S(4))/(S(5)*b**S(3)*x**S(4)) - S(16)*c**S(2)*sqrt(b*x**S(2) + c*x**S(4))/(S(5)*b**S(4)*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(5)*(b*x**S(2) + c*x**S(4))**(S(3)/2)), x), x, S(1)/(b*x**S(6)*sqrt(b*x**S(2) + c*x**S(4))) - S(8)*sqrt(b*x**S(2) + c*x**S(4))/(S(7)*b**S(2)*x**S(8)) + S(48)*c*sqrt(b*x**S(2) + c*x**S(4))/(S(35)*b**S(3)*x**S(6)) - S(64)*c**S(2)*sqrt(b*x**S(2) + c*x**S(4))/(S(35)*b**S(4)*x**S(4)) + S(128)*c**S(3)*sqrt(b*x**S(2) + c*x**S(4))/(S(35)*b**S(5)*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(6)/(b*x**S(2) + c*x**S(4))**(S(3)/2), x), x, -x**S(3)/(c*sqrt(b*x**S(2) + c*x**S(4))) + S(2)*sqrt(b*x**S(2) + c*x**S(4))/(c**S(2)*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)/(b*x**S(2) + c*x**S(4))**(S(3)/2), x), x, -x/(c*sqrt(b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/(b*x**S(2) + c*x**S(4))**(S(3)/2), x), x, x/(b*sqrt(b*x**S(2) + c*x**S(4))) - atanh(sqrt(b)*x/sqrt(b*x**S(2) + c*x**S(4)))/b**(S(3)/2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))**(S(-3)/2), x), x, S(1)/(b*x*sqrt(b*x**S(2) + c*x**S(4))) - S(3)*sqrt(b*x**S(2) + c*x**S(4))/(S(2)*b**S(2)*x**S(3)) + S(3)*c*atanh(sqrt(b)*x/sqrt(b*x**S(2) + c*x**S(4)))/(S(2)*b**(S(5)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*(b*x**S(2) + c*x**S(4))**(S(3)/2)), x), x, S(1)/(b*x**S(3)*sqrt(b*x**S(2) + c*x**S(4))) - S(5)*sqrt(b*x**S(2) + c*x**S(4))/(S(4)*b**S(2)*x**S(5)) + S(15)*c*sqrt(b*x**S(2) + c*x**S(4))/(S(8)*b**S(3)*x**S(3)) - S(15)*c**S(2)*atanh(sqrt(b)*x/sqrt(b*x**S(2) + c*x**S(4)))/(S(8)*b**(S(7)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/sqrt(-S(4)*x**S(4) + S(3)*x**S(2)), x), x, -sqrt(-S(4)*x**S(4) + S(3)*x**S(2))/S(8) + S(3)*asin(S(8)*x**S(2)/S(3) + S(-1))/S(32), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/sqrt(-S(4)*x**S(4) - S(3)*x**S(2)), x), x, -sqrt(-S(4)*x**S(4) - S(3)*x**S(2))/S(8) - S(3)*asin(S(8)*x**S(2)/S(3) + S(1))/S(32), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/sqrt(S(4)*x**S(4) + S(3)*x**S(2)), x), x, sqrt(S(4)*x**S(4) + S(3)*x**S(2))/S(8) - S(3)*atanh(S(2)*x**S(2)/sqrt(S(4)*x**S(4) + S(3)*x**S(2)))/S(16), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/sqrt(S(4)*x**S(4) - S(3)*x**S(2)), x), x, sqrt(S(4)*x**S(4) - S(3)*x**S(2))/S(8) + S(3)*atanh(S(2)*x**S(2)/sqrt(S(4)*x**S(4) - S(3)*x**S(2)))/S(16), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/sqrt(a*x**S(2) + b*x**S(4)), x), x, -a*atanh(sqrt(b)*x**S(2)/sqrt(a*x**S(2) + b*x**S(4)))/(S(2)*b**(S(3)/2)) + sqrt(a*x**S(2) + b*x**S(4))/(S(2)*b), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/sqrt(a*x**S(2) - b*x**S(4)), x), x, a*atan(sqrt(b)*x**S(2)/sqrt(a*x**S(2) - b*x**S(4)))/(S(2)*b**(S(3)/2)) - sqrt(a*x**S(2) - b*x**S(4))/(S(2)*b), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(7)/2)*(b*x**S(2) + c*x**S(4)), x), x, S(2)*b*x**(S(13)/2)/S(13) + S(2)*c*x**(S(17)/2)/S(17), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(5)/2)*(b*x**S(2) + c*x**S(4)), x), x, S(2)*b*x**(S(11)/2)/S(11) + S(2)*c*x**(S(15)/2)/S(15), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(3)/2)*(b*x**S(2) + c*x**S(4)), x), x, S(2)*b*x**(S(9)/2)/S(9) + S(2)*c*x**(S(13)/2)/S(13), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(x)*(b*x**S(2) + c*x**S(4)), x), x, S(2)*b*x**(S(7)/2)/S(7) + S(2)*c*x**(S(11)/2)/S(11), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))/sqrt(x), x), x, S(2)*b*x**(S(5)/2)/S(5) + S(2)*c*x**(S(9)/2)/S(9), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))/x**(S(3)/2), x), x, S(2)*b*x**(S(3)/2)/S(3) + S(2)*c*x**(S(7)/2)/S(7), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))/x**(S(5)/2), x), x, S(2)*b*sqrt(x) + S(2)*c*x**(S(5)/2)/S(5), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))/x**(S(7)/2), x), x, -S(2)*b/sqrt(x) + S(2)*c*x**(S(3)/2)/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(7)/2)*(b*x**S(2) + c*x**S(4))**S(2), x), x, S(2)*b**S(2)*x**(S(17)/2)/S(17) + S(4)*b*c*x**(S(21)/2)/S(21) + S(2)*c**S(2)*x**(S(25)/2)/S(25), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(5)/2)*(b*x**S(2) + c*x**S(4))**S(2), x), x, S(2)*b**S(2)*x**(S(15)/2)/S(15) + S(4)*b*c*x**(S(19)/2)/S(19) + S(2)*c**S(2)*x**(S(23)/2)/S(23), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(3)/2)*(b*x**S(2) + c*x**S(4))**S(2), x), x, S(2)*b**S(2)*x**(S(13)/2)/S(13) + S(4)*b*c*x**(S(17)/2)/S(17) + S(2)*c**S(2)*x**(S(21)/2)/S(21), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(x)*(b*x**S(2) + c*x**S(4))**S(2), x), x, S(2)*b**S(2)*x**(S(11)/2)/S(11) + S(4)*b*c*x**(S(15)/2)/S(15) + S(2)*c**S(2)*x**(S(19)/2)/S(19), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))**S(2)/sqrt(x), x), x, S(2)*b**S(2)*x**(S(9)/2)/S(9) + S(4)*b*c*x**(S(13)/2)/S(13) + S(2)*c**S(2)*x**(S(17)/2)/S(17), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))**S(2)/x**(S(3)/2), x), x, S(2)*b**S(2)*x**(S(7)/2)/S(7) + S(4)*b*c*x**(S(11)/2)/S(11) + S(2)*c**S(2)*x**(S(15)/2)/S(15), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))**S(2)/x**(S(5)/2), x), x, S(2)*b**S(2)*x**(S(5)/2)/S(5) + S(4)*b*c*x**(S(9)/2)/S(9) + S(2)*c**S(2)*x**(S(13)/2)/S(13), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))**S(2)/x**(S(7)/2), x), x, S(2)*b**S(2)*x**(S(3)/2)/S(3) + S(4)*b*c*x**(S(7)/2)/S(7) + S(2)*c**S(2)*x**(S(11)/2)/S(11), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(7)/2)*(b*x**S(2) + c*x**S(4))**S(3), x), x, S(2)*b**S(3)*x**(S(21)/2)/S(21) + S(6)*b**S(2)*c*x**(S(25)/2)/S(25) + S(6)*b*c**S(2)*x**(S(29)/2)/S(29) + S(2)*c**S(3)*x**(S(33)/2)/S(33), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(5)/2)*(b*x**S(2) + c*x**S(4))**S(3), x), x, S(2)*b**S(3)*x**(S(19)/2)/S(19) + S(6)*b**S(2)*c*x**(S(23)/2)/S(23) + S(2)*b*c**S(2)*x**(S(27)/2)/S(9) + S(2)*c**S(3)*x**(S(31)/2)/S(31), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(3)/2)*(b*x**S(2) + c*x**S(4))**S(3), x), x, S(2)*b**S(3)*x**(S(17)/2)/S(17) + S(2)*b**S(2)*c*x**(S(21)/2)/S(7) + S(6)*b*c**S(2)*x**(S(25)/2)/S(25) + S(2)*c**S(3)*x**(S(29)/2)/S(29), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(x)*(b*x**S(2) + c*x**S(4))**S(3), x), x, S(2)*b**S(3)*x**(S(15)/2)/S(15) + S(6)*b**S(2)*c*x**(S(19)/2)/S(19) + S(6)*b*c**S(2)*x**(S(23)/2)/S(23) + S(2)*c**S(3)*x**(S(27)/2)/S(27), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))**S(3)/sqrt(x), x), x, S(2)*b**S(3)*x**(S(13)/2)/S(13) + S(6)*b**S(2)*c*x**(S(17)/2)/S(17) + S(2)*b*c**S(2)*x**(S(21)/2)/S(7) + S(2)*c**S(3)*x**(S(25)/2)/S(25), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))**S(3)/x**(S(3)/2), x), x, S(2)*b**S(3)*x**(S(11)/2)/S(11) + S(2)*b**S(2)*c*x**(S(15)/2)/S(5) + S(6)*b*c**S(2)*x**(S(19)/2)/S(19) + S(2)*c**S(3)*x**(S(23)/2)/S(23), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))**S(3)/x**(S(5)/2), x), x, S(2)*b**S(3)*x**(S(9)/2)/S(9) + S(6)*b**S(2)*c*x**(S(13)/2)/S(13) + S(6)*b*c**S(2)*x**(S(17)/2)/S(17) + S(2)*c**S(3)*x**(S(21)/2)/S(21), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))**S(3)/x**(S(7)/2), x), x, S(2)*b**S(3)*x**(S(7)/2)/S(7) + S(6)*b**S(2)*c*x**(S(11)/2)/S(11) + S(2)*b*c**S(2)*x**(S(15)/2)/S(5) + S(2)*c**S(3)*x**(S(19)/2)/S(19), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(13)/2)/(b*x**S(2) + c*x**S(4)), x), x, sqrt(S(2))*b**(S(7)/4)*log(-sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(4)*c**(S(11)/4)) - sqrt(S(2))*b**(S(7)/4)*log(sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(4)*c**(S(11)/4)) - sqrt(S(2))*b**(S(7)/4)*atan(S(1) - sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(2)*c**(S(11)/4)) + sqrt(S(2))*b**(S(7)/4)*atan(S(1) + sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(2)*c**(S(11)/4)) - S(2)*b*x**(S(3)/2)/(S(3)*c**S(2)) + S(2)*x**(S(7)/2)/(S(7)*c), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(11)/2)/(b*x**S(2) + c*x**S(4)), x), x, -sqrt(S(2))*b**(S(5)/4)*log(-sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(4)*c**(S(9)/4)) + sqrt(S(2))*b**(S(5)/4)*log(sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(4)*c**(S(9)/4)) - sqrt(S(2))*b**(S(5)/4)*atan(S(1) - sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(2)*c**(S(9)/4)) + sqrt(S(2))*b**(S(5)/4)*atan(S(1) + sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(2)*c**(S(9)/4)) - S(2)*b*sqrt(x)/c**S(2) + S(2)*x**(S(5)/2)/(S(5)*c), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(9)/2)/(b*x**S(2) + c*x**S(4)), x), x, -sqrt(S(2))*b**(S(3)/4)*log(-sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(4)*c**(S(7)/4)) + sqrt(S(2))*b**(S(3)/4)*log(sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(4)*c**(S(7)/4)) + sqrt(S(2))*b**(S(3)/4)*atan(S(1) - sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(2)*c**(S(7)/4)) - sqrt(S(2))*b**(S(3)/4)*atan(S(1) + sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(2)*c**(S(7)/4)) + S(2)*x**(S(3)/2)/(S(3)*c), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(7)/2)/(b*x**S(2) + c*x**S(4)), x), x, sqrt(S(2))*b**(S(1)/4)*log(-sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(4)*c**(S(5)/4)) - sqrt(S(2))*b**(S(1)/4)*log(sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(4)*c**(S(5)/4)) + sqrt(S(2))*b**(S(1)/4)*atan(S(1) - sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(2)*c**(S(5)/4)) - sqrt(S(2))*b**(S(1)/4)*atan(S(1) + sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(2)*c**(S(5)/4)) + S(2)*sqrt(x)/c, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(5)/2)/(b*x**S(2) + c*x**S(4)), x), x, sqrt(S(2))*log(-sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(4)*b**(S(1)/4)*c**(S(3)/4)) - sqrt(S(2))*log(sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(4)*b**(S(1)/4)*c**(S(3)/4)) - sqrt(S(2))*atan(S(1) - sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(2)*b**(S(1)/4)*c**(S(3)/4)) + sqrt(S(2))*atan(S(1) + sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(2)*b**(S(1)/4)*c**(S(3)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(3)/2)/(b*x**S(2) + c*x**S(4)), x), x, -sqrt(S(2))*log(-sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(4)*b**(S(3)/4)*c**(S(1)/4)) + sqrt(S(2))*log(sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(4)*b**(S(3)/4)*c**(S(1)/4)) - sqrt(S(2))*atan(S(1) - sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(2)*b**(S(3)/4)*c**(S(1)/4)) + sqrt(S(2))*atan(S(1) + sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(2)*b**(S(3)/4)*c**(S(1)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(x)/(b*x**S(2) + c*x**S(4)), x), x, -S(2)/(b*sqrt(x)) - sqrt(S(2))*c**(S(1)/4)*log(-sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(4)*b**(S(5)/4)) + sqrt(S(2))*c**(S(1)/4)*log(sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(4)*b**(S(5)/4)) + sqrt(S(2))*c**(S(1)/4)*atan(S(1) - sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(2)*b**(S(5)/4)) - sqrt(S(2))*c**(S(1)/4)*atan(S(1) + sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(2)*b**(S(5)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(sqrt(x)*(b*x**S(2) + c*x**S(4))), x), x, -S(2)/(S(3)*b*x**(S(3)/2)) + sqrt(S(2))*c**(S(3)/4)*log(-sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(4)*b**(S(7)/4)) - sqrt(S(2))*c**(S(3)/4)*log(sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(4)*b**(S(7)/4)) + sqrt(S(2))*c**(S(3)/4)*atan(S(1) - sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(2)*b**(S(7)/4)) - sqrt(S(2))*c**(S(3)/4)*atan(S(1) + sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(2)*b**(S(7)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**(S(3)/2)*(b*x**S(2) + c*x**S(4))), x), x, -S(2)/(S(5)*b*x**(S(5)/2)) + S(2)*c/(b**S(2)*sqrt(x)) + sqrt(S(2))*c**(S(5)/4)*log(-sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(4)*b**(S(9)/4)) - sqrt(S(2))*c**(S(5)/4)*log(sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(4)*b**(S(9)/4)) - sqrt(S(2))*c**(S(5)/4)*atan(S(1) - sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(2)*b**(S(9)/4)) + sqrt(S(2))*c**(S(5)/4)*atan(S(1) + sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(2)*b**(S(9)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**(S(5)/2)*(b*x**S(2) + c*x**S(4))), x), x, -S(2)/(S(7)*b*x**(S(7)/2)) + S(2)*c/(S(3)*b**S(2)*x**(S(3)/2)) - sqrt(S(2))*c**(S(7)/4)*log(-sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(4)*b**(S(11)/4)) + sqrt(S(2))*c**(S(7)/4)*log(sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(4)*b**(S(11)/4)) - sqrt(S(2))*c**(S(7)/4)*atan(S(1) - sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(2)*b**(S(11)/4)) + sqrt(S(2))*c**(S(7)/4)*atan(S(1) + sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(2)*b**(S(11)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**(S(7)/2)*(b*x**S(2) + c*x**S(4))), x), x, -S(2)/(S(9)*b*x**(S(9)/2)) + S(2)*c/(S(5)*b**S(2)*x**(S(5)/2)) - S(2)*c**S(2)/(b**S(3)*sqrt(x)) - sqrt(S(2))*c**(S(9)/4)*log(-sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(4)*b**(S(13)/4)) + sqrt(S(2))*c**(S(9)/4)*log(sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(4)*b**(S(13)/4)) + sqrt(S(2))*c**(S(9)/4)*atan(S(1) - sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(2)*b**(S(13)/4)) - sqrt(S(2))*c**(S(9)/4)*atan(S(1) + sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(2)*b**(S(13)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(19)/2)/(b*x**S(2) + c*x**S(4))**S(2), x), x, -S(9)*sqrt(S(2))*b**(S(5)/4)*log(-sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(16)*c**(S(13)/4)) + S(9)*sqrt(S(2))*b**(S(5)/4)*log(sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(16)*c**(S(13)/4)) - S(9)*sqrt(S(2))*b**(S(5)/4)*atan(S(1) - sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(8)*c**(S(13)/4)) + S(9)*sqrt(S(2))*b**(S(5)/4)*atan(S(1) + sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(8)*c**(S(13)/4)) - S(9)*b*sqrt(x)/(S(2)*c**S(3)) - x**(S(9)/2)/(S(2)*c*(b + c*x**S(2))) + S(9)*x**(S(5)/2)/(S(10)*c**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(17)/2)/(b*x**S(2) + c*x**S(4))**S(2), x), x, -S(7)*sqrt(S(2))*b**(S(3)/4)*log(-sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(16)*c**(S(11)/4)) + S(7)*sqrt(S(2))*b**(S(3)/4)*log(sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(16)*c**(S(11)/4)) + S(7)*sqrt(S(2))*b**(S(3)/4)*atan(S(1) - sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(8)*c**(S(11)/4)) - S(7)*sqrt(S(2))*b**(S(3)/4)*atan(S(1) + sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(8)*c**(S(11)/4)) - x**(S(7)/2)/(S(2)*c*(b + c*x**S(2))) + S(7)*x**(S(3)/2)/(S(6)*c**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(15)/2)/(b*x**S(2) + c*x**S(4))**S(2), x), x, S(5)*sqrt(S(2))*b**(S(1)/4)*log(-sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(16)*c**(S(9)/4)) - S(5)*sqrt(S(2))*b**(S(1)/4)*log(sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(16)*c**(S(9)/4)) + S(5)*sqrt(S(2))*b**(S(1)/4)*atan(S(1) - sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(8)*c**(S(9)/4)) - S(5)*sqrt(S(2))*b**(S(1)/4)*atan(S(1) + sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(8)*c**(S(9)/4)) - x**(S(5)/2)/(S(2)*c*(b + c*x**S(2))) + S(5)*sqrt(x)/(S(2)*c**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(13)/2)/(b*x**S(2) + c*x**S(4))**S(2), x), x, -x**(S(3)/2)/(S(2)*c*(b + c*x**S(2))) + S(3)*sqrt(S(2))*log(-sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(16)*b**(S(1)/4)*c**(S(7)/4)) - S(3)*sqrt(S(2))*log(sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(16)*b**(S(1)/4)*c**(S(7)/4)) - S(3)*sqrt(S(2))*atan(S(1) - sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(8)*b**(S(1)/4)*c**(S(7)/4)) + S(3)*sqrt(S(2))*atan(S(1) + sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(8)*b**(S(1)/4)*c**(S(7)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(11)/2)/(b*x**S(2) + c*x**S(4))**S(2), x), x, -sqrt(x)/(S(2)*c*(b + c*x**S(2))) - sqrt(S(2))*log(-sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(16)*b**(S(3)/4)*c**(S(5)/4)) + sqrt(S(2))*log(sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(16)*b**(S(3)/4)*c**(S(5)/4)) - sqrt(S(2))*atan(S(1) - sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(8)*b**(S(3)/4)*c**(S(5)/4)) + sqrt(S(2))*atan(S(1) + sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(8)*b**(S(3)/4)*c**(S(5)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(9)/2)/(b*x**S(2) + c*x**S(4))**S(2), x), x, x**(S(3)/2)/(S(2)*b*(b + c*x**S(2))) + sqrt(S(2))*log(-sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(16)*b**(S(5)/4)*c**(S(3)/4)) - sqrt(S(2))*log(sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(16)*b**(S(5)/4)*c**(S(3)/4)) - sqrt(S(2))*atan(S(1) - sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(8)*b**(S(5)/4)*c**(S(3)/4)) + sqrt(S(2))*atan(S(1) + sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(8)*b**(S(5)/4)*c**(S(3)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(7)/2)/(b*x**S(2) + c*x**S(4))**S(2), x), x, sqrt(x)/(S(2)*b*(b + c*x**S(2))) - S(3)*sqrt(S(2))*log(-sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(16)*b**(S(7)/4)*c**(S(1)/4)) + S(3)*sqrt(S(2))*log(sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(16)*b**(S(7)/4)*c**(S(1)/4)) - S(3)*sqrt(S(2))*atan(S(1) - sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(8)*b**(S(7)/4)*c**(S(1)/4)) + S(3)*sqrt(S(2))*atan(S(1) + sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(8)*b**(S(7)/4)*c**(S(1)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(5)/2)/(b*x**S(2) + c*x**S(4))**S(2), x), x, S(1)/(S(2)*b*sqrt(x)*(b + c*x**S(2))) - S(5)/(S(2)*b**S(2)*sqrt(x)) - S(5)*sqrt(S(2))*c**(S(1)/4)*log(-sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(16)*b**(S(9)/4)) + S(5)*sqrt(S(2))*c**(S(1)/4)*log(sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(16)*b**(S(9)/4)) + S(5)*sqrt(S(2))*c**(S(1)/4)*atan(S(1) - sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(8)*b**(S(9)/4)) - S(5)*sqrt(S(2))*c**(S(1)/4)*atan(S(1) + sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(8)*b**(S(9)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(3)/2)/(b*x**S(2) + c*x**S(4))**S(2), x), x, S(1)/(S(2)*b*x**(S(3)/2)*(b + c*x**S(2))) - S(7)/(S(6)*b**S(2)*x**(S(3)/2)) + S(7)*sqrt(S(2))*c**(S(3)/4)*log(-sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(16)*b**(S(11)/4)) - S(7)*sqrt(S(2))*c**(S(3)/4)*log(sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(16)*b**(S(11)/4)) + S(7)*sqrt(S(2))*c**(S(3)/4)*atan(S(1) - sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(8)*b**(S(11)/4)) - S(7)*sqrt(S(2))*c**(S(3)/4)*atan(S(1) + sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(8)*b**(S(11)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(x)/(b*x**S(2) + c*x**S(4))**S(2), x), x, S(1)/(S(2)*b*x**(S(5)/2)*(b + c*x**S(2))) - S(9)/(S(10)*b**S(2)*x**(S(5)/2)) + S(9)*c/(S(2)*b**S(3)*sqrt(x)) + S(9)*sqrt(S(2))*c**(S(5)/4)*log(-sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(16)*b**(S(13)/4)) - S(9)*sqrt(S(2))*c**(S(5)/4)*log(sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(16)*b**(S(13)/4)) - S(9)*sqrt(S(2))*c**(S(5)/4)*atan(S(1) - sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(8)*b**(S(13)/4)) + S(9)*sqrt(S(2))*c**(S(5)/4)*atan(S(1) + sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(8)*b**(S(13)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(sqrt(x)*(b*x**S(2) + c*x**S(4))**S(2)), x), x, S(1)/(S(2)*b*x**(S(7)/2)*(b + c*x**S(2))) - S(11)/(S(14)*b**S(2)*x**(S(7)/2)) + S(11)*c/(S(6)*b**S(3)*x**(S(3)/2)) - S(11)*sqrt(S(2))*c**(S(7)/4)*log(-sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(16)*b**(S(15)/4)) + S(11)*sqrt(S(2))*c**(S(7)/4)*log(sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(16)*b**(S(15)/4)) - S(11)*sqrt(S(2))*c**(S(7)/4)*atan(S(1) - sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(8)*b**(S(15)/4)) + S(11)*sqrt(S(2))*c**(S(7)/4)*atan(S(1) + sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(8)*b**(S(15)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**(S(3)/2)*(b*x**S(2) + c*x**S(4))**S(2)), x), x, S(1)/(S(2)*b*x**(S(9)/2)*(b + c*x**S(2))) - S(13)/(S(18)*b**S(2)*x**(S(9)/2)) + S(13)*c/(S(10)*b**S(3)*x**(S(5)/2)) - S(13)*c**S(2)/(S(2)*b**S(4)*sqrt(x)) - S(13)*sqrt(S(2))*c**(S(9)/4)*log(-sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(16)*b**(S(17)/4)) + S(13)*sqrt(S(2))*c**(S(9)/4)*log(sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(16)*b**(S(17)/4)) + S(13)*sqrt(S(2))*c**(S(9)/4)*atan(S(1) - sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(8)*b**(S(17)/4)) - S(13)*sqrt(S(2))*c**(S(9)/4)*atan(S(1) + sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(8)*b**(S(17)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(23)/2)/(b*x**S(2) + c*x**S(4))**S(3), x), x, S(45)*sqrt(S(2))*b**(S(1)/4)*log(-sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(128)*c**(S(13)/4)) - S(45)*sqrt(S(2))*b**(S(1)/4)*log(sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(128)*c**(S(13)/4)) + S(45)*sqrt(S(2))*b**(S(1)/4)*atan(S(1) - sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(64)*c**(S(13)/4)) - S(45)*sqrt(S(2))*b**(S(1)/4)*atan(S(1) + sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(64)*c**(S(13)/4)) - x**(S(9)/2)/(S(4)*c*(b + c*x**S(2))**S(2)) - S(9)*x**(S(5)/2)/(S(16)*c**S(2)*(b + c*x**S(2))) + S(45)*sqrt(x)/(S(16)*c**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(21)/2)/(b*x**S(2) + c*x**S(4))**S(3), x), x, -x**(S(7)/2)/(S(4)*c*(b + c*x**S(2))**S(2)) - S(7)*x**(S(3)/2)/(S(16)*c**S(2)*(b + c*x**S(2))) + S(21)*sqrt(S(2))*log(-sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(128)*b**(S(1)/4)*c**(S(11)/4)) - S(21)*sqrt(S(2))*log(sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(128)*b**(S(1)/4)*c**(S(11)/4)) - S(21)*sqrt(S(2))*atan(S(1) - sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(64)*b**(S(1)/4)*c**(S(11)/4)) + S(21)*sqrt(S(2))*atan(S(1) + sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(64)*b**(S(1)/4)*c**(S(11)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(19)/2)/(b*x**S(2) + c*x**S(4))**S(3), x), x, -x**(S(5)/2)/(S(4)*c*(b + c*x**S(2))**S(2)) - S(5)*sqrt(x)/(S(16)*c**S(2)*(b + c*x**S(2))) - S(5)*sqrt(S(2))*log(-sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(128)*b**(S(3)/4)*c**(S(9)/4)) + S(5)*sqrt(S(2))*log(sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(128)*b**(S(3)/4)*c**(S(9)/4)) - S(5)*sqrt(S(2))*atan(S(1) - sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(64)*b**(S(3)/4)*c**(S(9)/4)) + S(5)*sqrt(S(2))*atan(S(1) + sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(64)*b**(S(3)/4)*c**(S(9)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(17)/2)/(b*x**S(2) + c*x**S(4))**S(3), x), x, -x**(S(3)/2)/(S(4)*c*(b + c*x**S(2))**S(2)) + S(3)*x**(S(3)/2)/(S(16)*b*c*(b + c*x**S(2))) + S(3)*sqrt(S(2))*log(-sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(128)*b**(S(5)/4)*c**(S(7)/4)) - S(3)*sqrt(S(2))*log(sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(128)*b**(S(5)/4)*c**(S(7)/4)) - S(3)*sqrt(S(2))*atan(S(1) - sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(64)*b**(S(5)/4)*c**(S(7)/4)) + S(3)*sqrt(S(2))*atan(S(1) + sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(64)*b**(S(5)/4)*c**(S(7)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(15)/2)/(b*x**S(2) + c*x**S(4))**S(3), x), x, -sqrt(x)/(S(4)*c*(b + c*x**S(2))**S(2)) + sqrt(x)/(S(16)*b*c*(b + c*x**S(2))) - S(3)*sqrt(S(2))*log(-sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(128)*b**(S(7)/4)*c**(S(5)/4)) + S(3)*sqrt(S(2))*log(sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(128)*b**(S(7)/4)*c**(S(5)/4)) - S(3)*sqrt(S(2))*atan(S(1) - sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(64)*b**(S(7)/4)*c**(S(5)/4)) + S(3)*sqrt(S(2))*atan(S(1) + sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(64)*b**(S(7)/4)*c**(S(5)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(13)/2)/(b*x**S(2) + c*x**S(4))**S(3), x), x, x**(S(3)/2)/(S(4)*b*(b + c*x**S(2))**S(2)) + S(5)*x**(S(3)/2)/(S(16)*b**S(2)*(b + c*x**S(2))) + S(5)*sqrt(S(2))*log(-sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(128)*b**(S(9)/4)*c**(S(3)/4)) - S(5)*sqrt(S(2))*log(sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(128)*b**(S(9)/4)*c**(S(3)/4)) - S(5)*sqrt(S(2))*atan(S(1) - sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(64)*b**(S(9)/4)*c**(S(3)/4)) + S(5)*sqrt(S(2))*atan(S(1) + sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(64)*b**(S(9)/4)*c**(S(3)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(11)/2)/(b*x**S(2) + c*x**S(4))**S(3), x), x, sqrt(x)/(S(4)*b*(b + c*x**S(2))**S(2)) + S(7)*sqrt(x)/(S(16)*b**S(2)*(b + c*x**S(2))) - S(21)*sqrt(S(2))*log(-sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(128)*b**(S(11)/4)*c**(S(1)/4)) + S(21)*sqrt(S(2))*log(sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(128)*b**(S(11)/4)*c**(S(1)/4)) - S(21)*sqrt(S(2))*atan(S(1) - sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(64)*b**(S(11)/4)*c**(S(1)/4)) + S(21)*sqrt(S(2))*atan(S(1) + sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(64)*b**(S(11)/4)*c**(S(1)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(9)/2)/(b*x**S(2) + c*x**S(4))**S(3), x), x, S(1)/(S(4)*b*sqrt(x)*(b + c*x**S(2))**S(2)) + S(9)/(S(16)*b**S(2)*sqrt(x)*(b + c*x**S(2))) - S(45)/(S(16)*b**S(3)*sqrt(x)) - S(45)*sqrt(S(2))*c**(S(1)/4)*log(-sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(128)*b**(S(13)/4)) + S(45)*sqrt(S(2))*c**(S(1)/4)*log(sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(128)*b**(S(13)/4)) + S(45)*sqrt(S(2))*c**(S(1)/4)*atan(S(1) - sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(64)*b**(S(13)/4)) - S(45)*sqrt(S(2))*c**(S(1)/4)*atan(S(1) + sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(64)*b**(S(13)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(7)/2)/(b*x**S(2) + c*x**S(4))**S(3), x), x, S(1)/(S(4)*b*x**(S(3)/2)*(b + c*x**S(2))**S(2)) + S(11)/(S(16)*b**S(2)*x**(S(3)/2)*(b + c*x**S(2))) - S(77)/(S(48)*b**S(3)*x**(S(3)/2)) + S(77)*sqrt(S(2))*c**(S(3)/4)*log(-sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(128)*b**(S(15)/4)) - S(77)*sqrt(S(2))*c**(S(3)/4)*log(sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(128)*b**(S(15)/4)) + S(77)*sqrt(S(2))*c**(S(3)/4)*atan(S(1) - sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(64)*b**(S(15)/4)) - S(77)*sqrt(S(2))*c**(S(3)/4)*atan(S(1) + sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(64)*b**(S(15)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(5)/2)/(b*x**S(2) + c*x**S(4))**S(3), x), x, S(1)/(S(4)*b*x**(S(5)/2)*(b + c*x**S(2))**S(2)) + S(13)/(S(16)*b**S(2)*x**(S(5)/2)*(b + c*x**S(2))) - S(117)/(S(80)*b**S(3)*x**(S(5)/2)) + S(117)*c/(S(16)*b**S(4)*sqrt(x)) + S(117)*sqrt(S(2))*c**(S(5)/4)*log(-sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(128)*b**(S(17)/4)) - S(117)*sqrt(S(2))*c**(S(5)/4)*log(sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(128)*b**(S(17)/4)) - S(117)*sqrt(S(2))*c**(S(5)/4)*atan(S(1) - sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(64)*b**(S(17)/4)) + S(117)*sqrt(S(2))*c**(S(5)/4)*atan(S(1) + sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(64)*b**(S(17)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(3)/2)/(b*x**S(2) + c*x**S(4))**S(3), x), x, S(1)/(S(4)*b*x**(S(7)/2)*(b + c*x**S(2))**S(2)) + S(15)/(S(16)*b**S(2)*x**(S(7)/2)*(b + c*x**S(2))) - S(165)/(S(112)*b**S(3)*x**(S(7)/2)) + S(55)*c/(S(16)*b**S(4)*x**(S(3)/2)) - S(165)*sqrt(S(2))*c**(S(7)/4)*log(-sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(128)*b**(S(19)/4)) + S(165)*sqrt(S(2))*c**(S(7)/4)*log(sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(128)*b**(S(19)/4)) - S(165)*sqrt(S(2))*c**(S(7)/4)*atan(S(1) - sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(64)*b**(S(19)/4)) + S(165)*sqrt(S(2))*c**(S(7)/4)*atan(S(1) + sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(64)*b**(S(19)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(x)/(b*x**S(2) + c*x**S(4))**S(3), x), x, S(1)/(S(4)*b*x**(S(9)/2)*(b + c*x**S(2))**S(2)) + S(17)/(S(16)*b**S(2)*x**(S(9)/2)*(b + c*x**S(2))) - S(221)/(S(144)*b**S(3)*x**(S(9)/2)) + S(221)*c/(S(80)*b**S(4)*x**(S(5)/2)) - S(221)*c**S(2)/(S(16)*b**S(5)*sqrt(x)) - S(221)*sqrt(S(2))*c**(S(9)/4)*log(-sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(128)*b**(S(21)/4)) + S(221)*sqrt(S(2))*c**(S(9)/4)*log(sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(128)*b**(S(21)/4)) + S(221)*sqrt(S(2))*c**(S(9)/4)*atan(S(1) - sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(64)*b**(S(21)/4)) - S(221)*sqrt(S(2))*c**(S(9)/4)*atan(S(1) + sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(64)*b**(S(21)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(sqrt(x)*(b*x**S(2) + c*x**S(4))**S(3)), x), x, S(1)/(S(4)*b*x**(S(11)/2)*(b + c*x**S(2))**S(2)) + S(19)/(S(16)*b**S(2)*x**(S(11)/2)*(b + c*x**S(2))) - S(285)/(S(176)*b**S(3)*x**(S(11)/2)) + S(285)*c/(S(112)*b**S(4)*x**(S(7)/2)) - S(95)*c**S(2)/(S(16)*b**S(5)*x**(S(3)/2)) + S(285)*sqrt(S(2))*c**(S(11)/4)*log(-sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(128)*b**(S(23)/4)) - S(285)*sqrt(S(2))*c**(S(11)/4)*log(sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*sqrt(x) + sqrt(b) + sqrt(c)*x)/(S(128)*b**(S(23)/4)) + S(285)*sqrt(S(2))*c**(S(11)/4)*atan(S(1) - sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(64)*b**(S(23)/4)) - S(285)*sqrt(S(2))*c**(S(11)/4)*atan(S(1) + sqrt(S(2))*c**(S(1)/4)*sqrt(x)/b**(S(1)/4))/(S(64)*b**(S(23)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(7)/2)*sqrt(b*x**S(2) + c*x**S(4)), x), x, -S(28)*b**(S(13)/4)*x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_e(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(S(195)*c**(S(11)/4)*sqrt(b*x**S(2) + c*x**S(4))) + S(14)*b**(S(13)/4)*x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_f(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(S(195)*c**(S(11)/4)*sqrt(b*x**S(2) + c*x**S(4))) + S(28)*b**S(3)*x**(S(3)/2)*(b + c*x**S(2))/(S(195)*c**(S(5)/2)*(sqrt(b) + sqrt(c)*x)*sqrt(b*x**S(2) + c*x**S(4))) - S(28)*b**S(2)*sqrt(x)*sqrt(b*x**S(2) + c*x**S(4))/(S(585)*c**S(2)) + S(4)*b*x**(S(5)/2)*sqrt(b*x**S(2) + c*x**S(4))/(S(117)*c) + S(2)*x**(S(9)/2)*sqrt(b*x**S(2) + c*x**S(4))/S(13), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(5)/2)*sqrt(b*x**S(2) + c*x**S(4)), x), x, S(10)*b**(S(11)/4)*x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_f(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(S(231)*c**(S(9)/4)*sqrt(b*x**S(2) + c*x**S(4))) - S(20)*b**S(2)*sqrt(b*x**S(2) + c*x**S(4))/(S(231)*c**S(2)*sqrt(x)) + S(4)*b*x**(S(3)/2)*sqrt(b*x**S(2) + c*x**S(4))/(S(77)*c) + S(2)*x**(S(7)/2)*sqrt(b*x**S(2) + c*x**S(4))/S(11), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(3)/2)*sqrt(b*x**S(2) + c*x**S(4)), x), x, S(4)*b**(S(9)/4)*x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_e(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(S(15)*c**(S(7)/4)*sqrt(b*x**S(2) + c*x**S(4))) - S(2)*b**(S(9)/4)*x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_f(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(S(15)*c**(S(7)/4)*sqrt(b*x**S(2) + c*x**S(4))) - S(4)*b**S(2)*x**(S(3)/2)*(b + c*x**S(2))/(S(15)*c**(S(3)/2)*(sqrt(b) + sqrt(c)*x)*sqrt(b*x**S(2) + c*x**S(4))) + S(4)*b*sqrt(x)*sqrt(b*x**S(2) + c*x**S(4))/(S(45)*c) + S(2)*x**(S(5)/2)*sqrt(b*x**S(2) + c*x**S(4))/S(9), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(x)*sqrt(b*x**S(2) + c*x**S(4)), x), x, -S(2)*b**(S(7)/4)*x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_f(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(S(21)*c**(S(5)/4)*sqrt(b*x**S(2) + c*x**S(4))) + S(4)*b*sqrt(b*x**S(2) + c*x**S(4))/(S(21)*c*sqrt(x)) + S(2)*x**(S(3)/2)*sqrt(b*x**S(2) + c*x**S(4))/S(7), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(b*x**S(2) + c*x**S(4))/sqrt(x), x), x, -S(4)*b**(S(5)/4)*x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_e(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(S(5)*c**(S(3)/4)*sqrt(b*x**S(2) + c*x**S(4))) + S(2)*b**(S(5)/4)*x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_f(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(S(5)*c**(S(3)/4)*sqrt(b*x**S(2) + c*x**S(4))) + S(4)*b*x**(S(3)/2)*(b + c*x**S(2))/(S(5)*sqrt(c)*(sqrt(b) + sqrt(c)*x)*sqrt(b*x**S(2) + c*x**S(4))) + S(2)*sqrt(x)*sqrt(b*x**S(2) + c*x**S(4))/S(5), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(b*x**S(2) + c*x**S(4))/x**(S(3)/2), x), x, S(2)*b**(S(3)/4)*x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_f(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(S(3)*c**(S(1)/4)*sqrt(b*x**S(2) + c*x**S(4))) + S(2)*sqrt(b*x**S(2) + c*x**S(4))/(S(3)*sqrt(x)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(b*x**S(2) + c*x**S(4))/x**(S(5)/2), x), x, -S(4)*b**(S(1)/4)*c**(S(1)/4)*x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_e(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/sqrt(b*x**S(2) + c*x**S(4)) + S(2)*b**(S(1)/4)*c**(S(1)/4)*x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_f(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/sqrt(b*x**S(2) + c*x**S(4)) + S(4)*sqrt(c)*x**(S(3)/2)*(b + c*x**S(2))/((sqrt(b) + sqrt(c)*x)*sqrt(b*x**S(2) + c*x**S(4))) - S(2)*sqrt(b*x**S(2) + c*x**S(4))/x**(S(3)/2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(b*x**S(2) + c*x**S(4))/x**(S(7)/2), x), x, -S(2)*sqrt(b*x**S(2) + c*x**S(4))/(S(3)*x**(S(5)/2)) + S(2)*c**(S(3)/4)*x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_f(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(S(3)*b**(S(1)/4)*sqrt(b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(b*x**S(2) + c*x**S(4))/x**(S(9)/2), x), x, -S(2)*sqrt(b*x**S(2) + c*x**S(4))/(S(5)*x**(S(7)/2)) + S(4)*c**(S(3)/2)*x**(S(3)/2)*(b + c*x**S(2))/(S(5)*b*(sqrt(b) + sqrt(c)*x)*sqrt(b*x**S(2) + c*x**S(4))) - S(4)*c*sqrt(b*x**S(2) + c*x**S(4))/(S(5)*b*x**(S(3)/2)) - S(4)*c**(S(5)/4)*x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_e(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(S(5)*b**(S(3)/4)*sqrt(b*x**S(2) + c*x**S(4))) + S(2)*c**(S(5)/4)*x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_f(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(S(5)*b**(S(3)/4)*sqrt(b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(b*x**S(2) + c*x**S(4))/x**(S(11)/2), x), x, -S(2)*sqrt(b*x**S(2) + c*x**S(4))/(S(7)*x**(S(9)/2)) - S(4)*c*sqrt(b*x**S(2) + c*x**S(4))/(S(21)*b*x**(S(5)/2)) - S(2)*c**(S(7)/4)*x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_f(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(S(21)*b**(S(5)/4)*sqrt(b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(b*x**S(2) + c*x**S(4))/x**(S(13)/2), x), x, -S(2)*sqrt(b*x**S(2) + c*x**S(4))/(S(9)*x**(S(11)/2)) - S(4)*c*sqrt(b*x**S(2) + c*x**S(4))/(S(45)*b*x**(S(7)/2)) - S(4)*c**(S(5)/2)*x**(S(3)/2)*(b + c*x**S(2))/(S(15)*b**S(2)*(sqrt(b) + sqrt(c)*x)*sqrt(b*x**S(2) + c*x**S(4))) + S(4)*c**S(2)*sqrt(b*x**S(2) + c*x**S(4))/(S(15)*b**S(2)*x**(S(3)/2)) + S(4)*c**(S(9)/4)*x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_e(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(S(15)*b**(S(7)/4)*sqrt(b*x**S(2) + c*x**S(4))) - S(2)*c**(S(9)/4)*x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_f(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(S(15)*b**(S(7)/4)*sqrt(b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(b*x**S(2) + c*x**S(4))/x**(S(15)/2), x), x, -S(2)*sqrt(b*x**S(2) + c*x**S(4))/(S(11)*x**(S(13)/2)) - S(4)*c*sqrt(b*x**S(2) + c*x**S(4))/(S(77)*b*x**(S(9)/2)) + S(20)*c**S(2)*sqrt(b*x**S(2) + c*x**S(4))/(S(231)*b**S(2)*x**(S(5)/2)) + S(10)*c**(S(11)/4)*x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_f(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(S(231)*b**(S(9)/4)*sqrt(b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(3)/2)*(b*x**S(2) + c*x**S(4))**(S(3)/2), x), x, -S(56)*b**(S(17)/4)*x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_e(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(S(1105)*c**(S(11)/4)*sqrt(b*x**S(2) + c*x**S(4))) + S(28)*b**(S(17)/4)*x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_f(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(S(1105)*c**(S(11)/4)*sqrt(b*x**S(2) + c*x**S(4))) + S(56)*b**S(4)*x**(S(3)/2)*(b + c*x**S(2))/(S(1105)*c**(S(5)/2)*(sqrt(b) + sqrt(c)*x)*sqrt(b*x**S(2) + c*x**S(4))) - S(56)*b**S(3)*sqrt(x)*sqrt(b*x**S(2) + c*x**S(4))/(S(3315)*c**S(2)) + S(8)*b**S(2)*x**(S(5)/2)*sqrt(b*x**S(2) + c*x**S(4))/(S(663)*c) + S(12)*b*x**(S(9)/2)*sqrt(b*x**S(2) + c*x**S(4))/S(221) + S(2)*x**(S(5)/2)*(b*x**S(2) + c*x**S(4))**(S(3)/2)/S(17), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(x)*(b*x**S(2) + c*x**S(4))**(S(3)/2), x), x, S(4)*b**(S(15)/4)*x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_f(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(S(231)*c**(S(9)/4)*sqrt(b*x**S(2) + c*x**S(4))) - S(8)*b**S(3)*sqrt(b*x**S(2) + c*x**S(4))/(S(231)*c**S(2)*sqrt(x)) + S(8)*b**S(2)*x**(S(3)/2)*sqrt(b*x**S(2) + c*x**S(4))/(S(385)*c) + S(4)*b*x**(S(7)/2)*sqrt(b*x**S(2) + c*x**S(4))/S(55) + S(2)*x**(S(3)/2)*(b*x**S(2) + c*x**S(4))**(S(3)/2)/S(15), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))**(S(3)/2)/sqrt(x), x), x, S(8)*b**(S(13)/4)*x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_e(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(S(65)*c**(S(7)/4)*sqrt(b*x**S(2) + c*x**S(4))) - S(4)*b**(S(13)/4)*x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_f(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(S(65)*c**(S(7)/4)*sqrt(b*x**S(2) + c*x**S(4))) - S(8)*b**S(3)*x**(S(3)/2)*(b + c*x**S(2))/(S(65)*c**(S(3)/2)*(sqrt(b) + sqrt(c)*x)*sqrt(b*x**S(2) + c*x**S(4))) + S(8)*b**S(2)*sqrt(x)*sqrt(b*x**S(2) + c*x**S(4))/(S(195)*c) + S(4)*b*x**(S(5)/2)*sqrt(b*x**S(2) + c*x**S(4))/S(39) + S(2)*sqrt(x)*(b*x**S(2) + c*x**S(4))**(S(3)/2)/S(13), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))**(S(3)/2)/x**(S(3)/2), x), x, -S(4)*b**(S(11)/4)*x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_f(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(S(77)*c**(S(5)/4)*sqrt(b*x**S(2) + c*x**S(4))) + S(8)*b**S(2)*sqrt(b*x**S(2) + c*x**S(4))/(S(77)*c*sqrt(x)) + S(12)*b*x**(S(3)/2)*sqrt(b*x**S(2) + c*x**S(4))/S(77) + S(2)*(b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(11)*sqrt(x)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))**(S(3)/2)/x**(S(5)/2), x), x, -S(8)*b**(S(9)/4)*x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_e(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(S(15)*c**(S(3)/4)*sqrt(b*x**S(2) + c*x**S(4))) + S(4)*b**(S(9)/4)*x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_f(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(S(15)*c**(S(3)/4)*sqrt(b*x**S(2) + c*x**S(4))) + S(8)*b**S(2)*x**(S(3)/2)*(b + c*x**S(2))/(S(15)*sqrt(c)*(sqrt(b) + sqrt(c)*x)*sqrt(b*x**S(2) + c*x**S(4))) + S(4)*b*sqrt(x)*sqrt(b*x**S(2) + c*x**S(4))/S(15) + S(2)*(b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(9)*x**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))**(S(3)/2)/x**(S(7)/2), x), x, S(4)*b**(S(7)/4)*x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_f(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(S(7)*c**(S(1)/4)*sqrt(b*x**S(2) + c*x**S(4))) + S(4)*b*sqrt(b*x**S(2) + c*x**S(4))/(S(7)*sqrt(x)) + S(2)*(b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(7)*x**(S(5)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))**(S(3)/2)/x**(S(9)/2), x), x, -S(24)*b**(S(5)/4)*c**(S(1)/4)*x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_e(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(S(5)*sqrt(b*x**S(2) + c*x**S(4))) + S(12)*b**(S(5)/4)*c**(S(1)/4)*x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_f(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(S(5)*sqrt(b*x**S(2) + c*x**S(4))) + S(24)*b*sqrt(c)*x**(S(3)/2)*(b + c*x**S(2))/((S(5)*sqrt(b) + S(5)*sqrt(c)*x)*sqrt(b*x**S(2) + c*x**S(4))) + S(12)*c*sqrt(x)*sqrt(b*x**S(2) + c*x**S(4))/S(5) - S(2)*(b*x**S(2) + c*x**S(4))**(S(3)/2)/x**(S(7)/2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))**(S(3)/2)/x**(S(11)/2), x), x, S(4)*b**(S(3)/4)*c**(S(3)/4)*x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_f(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(S(3)*sqrt(b*x**S(2) + c*x**S(4))) + S(4)*c*sqrt(b*x**S(2) + c*x**S(4))/(S(3)*sqrt(x)) - S(2)*(b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(3)*x**(S(9)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))**(S(3)/2)/x**(S(13)/2), x), x, -S(24)*b**(S(1)/4)*c**(S(5)/4)*x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_e(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(S(5)*sqrt(b*x**S(2) + c*x**S(4))) + S(12)*b**(S(1)/4)*c**(S(5)/4)*x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_f(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(S(5)*sqrt(b*x**S(2) + c*x**S(4))) + S(24)*c**(S(3)/2)*x**(S(3)/2)*(b + c*x**S(2))/((S(5)*sqrt(b) + S(5)*sqrt(c)*x)*sqrt(b*x**S(2) + c*x**S(4))) - S(12)*c*sqrt(b*x**S(2) + c*x**S(4))/(S(5)*x**(S(3)/2)) - S(2)*(b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(5)*x**(S(11)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))**(S(3)/2)/x**(S(15)/2), x), x, -S(4)*c*sqrt(b*x**S(2) + c*x**S(4))/(S(7)*x**(S(5)/2)) - S(2)*(b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(7)*x**(S(13)/2)) + S(4)*c**(S(7)/4)*x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_f(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(S(7)*b**(S(1)/4)*sqrt(b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))**(S(3)/2)/x**(S(17)/2), x), x, -S(4)*c*sqrt(b*x**S(2) + c*x**S(4))/(S(15)*x**(S(7)/2)) - S(2)*(b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(9)*x**(S(15)/2)) + S(8)*c**(S(5)/2)*x**(S(3)/2)*(b + c*x**S(2))/(S(15)*b*(sqrt(b) + sqrt(c)*x)*sqrt(b*x**S(2) + c*x**S(4))) - S(8)*c**S(2)*sqrt(b*x**S(2) + c*x**S(4))/(S(15)*b*x**(S(3)/2)) - S(8)*c**(S(9)/4)*x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_e(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(S(15)*b**(S(3)/4)*sqrt(b*x**S(2) + c*x**S(4))) + S(4)*c**(S(9)/4)*x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_f(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(S(15)*b**(S(3)/4)*sqrt(b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))**(S(3)/2)/x**(S(19)/2), x), x, -S(12)*c*sqrt(b*x**S(2) + c*x**S(4))/(S(77)*x**(S(9)/2)) - S(2)*(b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(11)*x**(S(17)/2)) - S(8)*c**S(2)*sqrt(b*x**S(2) + c*x**S(4))/(S(77)*b*x**(S(5)/2)) - S(4)*c**(S(11)/4)*x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_f(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(S(77)*b**(S(5)/4)*sqrt(b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))**(S(3)/2)/x**(S(21)/2), x), x, -S(4)*c*sqrt(b*x**S(2) + c*x**S(4))/(S(39)*x**(S(11)/2)) - S(2)*(b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(13)*x**(S(19)/2)) - S(8)*c**S(2)*sqrt(b*x**S(2) + c*x**S(4))/(S(195)*b*x**(S(7)/2)) - S(8)*c**(S(7)/2)*x**(S(3)/2)*(b + c*x**S(2))/(S(65)*b**S(2)*(sqrt(b) + sqrt(c)*x)*sqrt(b*x**S(2) + c*x**S(4))) + S(8)*c**S(3)*sqrt(b*x**S(2) + c*x**S(4))/(S(65)*b**S(2)*x**(S(3)/2)) + S(8)*c**(S(13)/4)*x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_e(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(S(65)*b**(S(7)/4)*sqrt(b*x**S(2) + c*x**S(4))) - S(4)*c**(S(13)/4)*x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_f(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(S(65)*b**(S(7)/4)*sqrt(b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + c*x**S(4))**(S(3)/2)/x**(S(23)/2), x), x, -S(4)*c*sqrt(b*x**S(2) + c*x**S(4))/(S(55)*x**(S(13)/2)) - S(2)*(b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(15)*x**(S(21)/2)) - S(8)*c**S(2)*sqrt(b*x**S(2) + c*x**S(4))/(S(385)*b*x**(S(9)/2)) + S(8)*c**S(3)*sqrt(b*x**S(2) + c*x**S(4))/(S(231)*b**S(2)*x**(S(5)/2)) + S(4)*c**(S(15)/4)*x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_f(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(S(231)*b**(S(9)/4)*sqrt(b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(13)/2)/sqrt(b*x**S(2) + c*x**S(4)), x), x, -S(15)*b**(S(11)/4)*x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_f(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(S(77)*c**(S(13)/4)*sqrt(b*x**S(2) + c*x**S(4))) + S(30)*b**S(2)*sqrt(b*x**S(2) + c*x**S(4))/(S(77)*c**S(3)*sqrt(x)) - S(18)*b*x**(S(3)/2)*sqrt(b*x**S(2) + c*x**S(4))/(S(77)*c**S(2)) + S(2)*x**(S(7)/2)*sqrt(b*x**S(2) + c*x**S(4))/(S(11)*c), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(11)/2)/sqrt(b*x**S(2) + c*x**S(4)), x), x, -S(14)*b**(S(9)/4)*x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_e(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(S(15)*c**(S(11)/4)*sqrt(b*x**S(2) + c*x**S(4))) + S(7)*b**(S(9)/4)*x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_f(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(S(15)*c**(S(11)/4)*sqrt(b*x**S(2) + c*x**S(4))) + S(14)*b**S(2)*x**(S(3)/2)*(b + c*x**S(2))/(S(15)*c**(S(5)/2)*(sqrt(b) + sqrt(c)*x)*sqrt(b*x**S(2) + c*x**S(4))) - S(14)*b*sqrt(x)*sqrt(b*x**S(2) + c*x**S(4))/(S(45)*c**S(2)) + S(2)*x**(S(5)/2)*sqrt(b*x**S(2) + c*x**S(4))/(S(9)*c), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(9)/2)/sqrt(b*x**S(2) + c*x**S(4)), x), x, S(5)*b**(S(7)/4)*x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_f(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(S(21)*c**(S(9)/4)*sqrt(b*x**S(2) + c*x**S(4))) - S(10)*b*sqrt(b*x**S(2) + c*x**S(4))/(S(21)*c**S(2)*sqrt(x)) + S(2)*x**(S(3)/2)*sqrt(b*x**S(2) + c*x**S(4))/(S(7)*c), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(7)/2)/sqrt(b*x**S(2) + c*x**S(4)), x), x, S(6)*b**(S(5)/4)*x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_e(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(S(5)*c**(S(7)/4)*sqrt(b*x**S(2) + c*x**S(4))) - S(3)*b**(S(5)/4)*x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_f(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(S(5)*c**(S(7)/4)*sqrt(b*x**S(2) + c*x**S(4))) - S(6)*b*x**(S(3)/2)*(b + c*x**S(2))/(S(5)*c**(S(3)/2)*(sqrt(b) + sqrt(c)*x)*sqrt(b*x**S(2) + c*x**S(4))) + S(2)*sqrt(x)*sqrt(b*x**S(2) + c*x**S(4))/(S(5)*c), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(5)/2)/sqrt(b*x**S(2) + c*x**S(4)), x), x, -b**(S(3)/4)*x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_f(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(S(3)*c**(S(5)/4)*sqrt(b*x**S(2) + c*x**S(4))) + S(2)*sqrt(b*x**S(2) + c*x**S(4))/(S(3)*c*sqrt(x)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(3)/2)/sqrt(b*x**S(2) + c*x**S(4)), x), x, -S(2)*b**(S(1)/4)*x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_e(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(c**(S(3)/4)*sqrt(b*x**S(2) + c*x**S(4))) + b**(S(1)/4)*x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_f(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(c**(S(3)/4)*sqrt(b*x**S(2) + c*x**S(4))) + S(2)*x**(S(3)/2)*(b + c*x**S(2))/(sqrt(c)*(sqrt(b) + sqrt(c)*x)*sqrt(b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(x)/sqrt(b*x**S(2) + c*x**S(4)), x), x, x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_f(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(b**(S(1)/4)*c**(S(1)/4)*sqrt(b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(sqrt(x)*sqrt(b*x**S(2) + c*x**S(4))), x), x, S(2)*sqrt(c)*x**(S(3)/2)*(b + c*x**S(2))/(b*(sqrt(b) + sqrt(c)*x)*sqrt(b*x**S(2) + c*x**S(4))) - S(2)*sqrt(b*x**S(2) + c*x**S(4))/(b*x**(S(3)/2)) - S(2)*c**(S(1)/4)*x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_e(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(b**(S(3)/4)*sqrt(b*x**S(2) + c*x**S(4))) + c**(S(1)/4)*x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_f(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(b**(S(3)/4)*sqrt(b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**(S(3)/2)*sqrt(b*x**S(2) + c*x**S(4))), x), x, -S(2)*sqrt(b*x**S(2) + c*x**S(4))/(S(3)*b*x**(S(5)/2)) - c**(S(3)/4)*x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_f(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(S(3)*b**(S(5)/4)*sqrt(b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**(S(5)/2)*sqrt(b*x**S(2) + c*x**S(4))), x), x, -S(2)*sqrt(b*x**S(2) + c*x**S(4))/(S(5)*b*x**(S(7)/2)) - S(6)*c**(S(3)/2)*x**(S(3)/2)*(b + c*x**S(2))/(S(5)*b**S(2)*(sqrt(b) + sqrt(c)*x)*sqrt(b*x**S(2) + c*x**S(4))) + S(6)*c*sqrt(b*x**S(2) + c*x**S(4))/(S(5)*b**S(2)*x**(S(3)/2)) + S(6)*c**(S(5)/4)*x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_e(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(S(5)*b**(S(7)/4)*sqrt(b*x**S(2) + c*x**S(4))) - S(3)*c**(S(5)/4)*x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_f(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(S(5)*b**(S(7)/4)*sqrt(b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**(S(7)/2)*sqrt(b*x**S(2) + c*x**S(4))), x), x, -S(2)*sqrt(b*x**S(2) + c*x**S(4))/(S(7)*b*x**(S(9)/2)) + S(10)*c*sqrt(b*x**S(2) + c*x**S(4))/(S(21)*b**S(2)*x**(S(5)/2)) + S(5)*c**(S(7)/4)*x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_f(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(S(21)*b**(S(9)/4)*sqrt(b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**(S(9)/2)*sqrt(b*x**S(2) + c*x**S(4))), x), x, -S(2)*sqrt(b*x**S(2) + c*x**S(4))/(S(9)*b*x**(S(11)/2)) + S(14)*c*sqrt(b*x**S(2) + c*x**S(4))/(S(45)*b**S(2)*x**(S(7)/2)) + S(14)*c**(S(5)/2)*x**(S(3)/2)*(b + c*x**S(2))/(S(15)*b**S(3)*(sqrt(b) + sqrt(c)*x)*sqrt(b*x**S(2) + c*x**S(4))) - S(14)*c**S(2)*sqrt(b*x**S(2) + c*x**S(4))/(S(15)*b**S(3)*x**(S(3)/2)) - S(14)*c**(S(9)/4)*x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_e(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(S(15)*b**(S(11)/4)*sqrt(b*x**S(2) + c*x**S(4))) + S(7)*c**(S(9)/4)*x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_f(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(S(15)*b**(S(11)/4)*sqrt(b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**(S(11)/2)*sqrt(b*x**S(2) + c*x**S(4))), x), x, -S(2)*sqrt(b*x**S(2) + c*x**S(4))/(S(11)*b*x**(S(13)/2)) + S(18)*c*sqrt(b*x**S(2) + c*x**S(4))/(S(77)*b**S(2)*x**(S(9)/2)) - S(30)*c**S(2)*sqrt(b*x**S(2) + c*x**S(4))/(S(77)*b**S(3)*x**(S(5)/2)) - S(15)*c**(S(11)/4)*x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_f(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(S(77)*b**(S(13)/4)*sqrt(b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(17)/2)/(b*x**S(2) + c*x**S(4))**(S(3)/2), x), x, S(15)*b**(S(7)/4)*x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_f(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(S(14)*c**(S(13)/4)*sqrt(b*x**S(2) + c*x**S(4))) - S(15)*b*sqrt(b*x**S(2) + c*x**S(4))/(S(7)*c**S(3)*sqrt(x)) - x**(S(11)/2)/(c*sqrt(b*x**S(2) + c*x**S(4))) + S(9)*x**(S(3)/2)*sqrt(b*x**S(2) + c*x**S(4))/(S(7)*c**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(15)/2)/(b*x**S(2) + c*x**S(4))**(S(3)/2), x), x, S(21)*b**(S(5)/4)*x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_e(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(S(5)*c**(S(11)/4)*sqrt(b*x**S(2) + c*x**S(4))) - S(21)*b**(S(5)/4)*x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_f(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(S(10)*c**(S(11)/4)*sqrt(b*x**S(2) + c*x**S(4))) - S(21)*b*x**(S(3)/2)*(b + c*x**S(2))/(S(5)*c**(S(5)/2)*(sqrt(b) + sqrt(c)*x)*sqrt(b*x**S(2) + c*x**S(4))) - x**(S(9)/2)/(c*sqrt(b*x**S(2) + c*x**S(4))) + S(7)*sqrt(x)*sqrt(b*x**S(2) + c*x**S(4))/(S(5)*c**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(13)/2)/(b*x**S(2) + c*x**S(4))**(S(3)/2), x), x, -S(5)*b**(S(3)/4)*x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_f(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(S(6)*c**(S(9)/4)*sqrt(b*x**S(2) + c*x**S(4))) - x**(S(7)/2)/(c*sqrt(b*x**S(2) + c*x**S(4))) + S(5)*sqrt(b*x**S(2) + c*x**S(4))/(S(3)*c**S(2)*sqrt(x)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(11)/2)/(b*x**S(2) + c*x**S(4))**(S(3)/2), x), x, -S(3)*b**(S(1)/4)*x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_e(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(c**(S(7)/4)*sqrt(b*x**S(2) + c*x**S(4))) + S(3)*b**(S(1)/4)*x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_f(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(S(2)*c**(S(7)/4)*sqrt(b*x**S(2) + c*x**S(4))) - x**(S(5)/2)/(c*sqrt(b*x**S(2) + c*x**S(4))) + S(3)*x**(S(3)/2)*(b + c*x**S(2))/(c**(S(3)/2)*(sqrt(b) + sqrt(c)*x)*sqrt(b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(9)/2)/(b*x**S(2) + c*x**S(4))**(S(3)/2), x), x, -x**(S(3)/2)/(c*sqrt(b*x**S(2) + c*x**S(4))) + x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_f(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(S(2)*b**(S(1)/4)*c**(S(5)/4)*sqrt(b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(7)/2)/(b*x**S(2) + c*x**S(4))**(S(3)/2), x), x, x**(S(5)/2)/(b*sqrt(b*x**S(2) + c*x**S(4))) - x**(S(3)/2)*(b + c*x**S(2))/(b*sqrt(c)*(sqrt(b) + sqrt(c)*x)*sqrt(b*x**S(2) + c*x**S(4))) + x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_e(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(b**(S(3)/4)*c**(S(3)/4)*sqrt(b*x**S(2) + c*x**S(4))) - x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_f(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(S(2)*b**(S(3)/4)*c**(S(3)/4)*sqrt(b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(5)/2)/(b*x**S(2) + c*x**S(4))**(S(3)/2), x), x, x**(S(3)/2)/(b*sqrt(b*x**S(2) + c*x**S(4))) + x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_f(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(S(2)*b**(S(5)/4)*c**(S(1)/4)*sqrt(b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(3)/2)/(b*x**S(2) + c*x**S(4))**(S(3)/2), x), x, sqrt(x)/(b*sqrt(b*x**S(2) + c*x**S(4))) + S(3)*sqrt(c)*x**(S(3)/2)*(b + c*x**S(2))/(b**S(2)*(sqrt(b) + sqrt(c)*x)*sqrt(b*x**S(2) + c*x**S(4))) - S(3)*sqrt(b*x**S(2) + c*x**S(4))/(b**S(2)*x**(S(3)/2)) - S(3)*c**(S(1)/4)*x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_e(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(b**(S(7)/4)*sqrt(b*x**S(2) + c*x**S(4))) + S(3)*c**(S(1)/4)*x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_f(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(S(2)*b**(S(7)/4)*sqrt(b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(x)/(b*x**S(2) + c*x**S(4))**(S(3)/2), x), x, S(1)/(b*sqrt(x)*sqrt(b*x**S(2) + c*x**S(4))) - S(5)*sqrt(b*x**S(2) + c*x**S(4))/(S(3)*b**S(2)*x**(S(5)/2)) - S(5)*c**(S(3)/4)*x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_f(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(S(6)*b**(S(9)/4)*sqrt(b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(sqrt(x)*(b*x**S(2) + c*x**S(4))**(S(3)/2)), x), x, S(1)/(b*x**(S(3)/2)*sqrt(b*x**S(2) + c*x**S(4))) - S(7)*sqrt(b*x**S(2) + c*x**S(4))/(S(5)*b**S(2)*x**(S(7)/2)) - S(21)*c**(S(3)/2)*x**(S(3)/2)*(b + c*x**S(2))/(S(5)*b**S(3)*(sqrt(b) + sqrt(c)*x)*sqrt(b*x**S(2) + c*x**S(4))) + S(21)*c*sqrt(b*x**S(2) + c*x**S(4))/(S(5)*b**S(3)*x**(S(3)/2)) + S(21)*c**(S(5)/4)*x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_e(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(S(5)*b**(S(11)/4)*sqrt(b*x**S(2) + c*x**S(4))) - S(21)*c**(S(5)/4)*x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_f(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(S(10)*b**(S(11)/4)*sqrt(b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**(S(3)/2)*(b*x**S(2) + c*x**S(4))**(S(3)/2)), x), x, S(1)/(b*x**(S(5)/2)*sqrt(b*x**S(2) + c*x**S(4))) - S(9)*sqrt(b*x**S(2) + c*x**S(4))/(S(7)*b**S(2)*x**(S(9)/2)) + S(15)*c*sqrt(b*x**S(2) + c*x**S(4))/(S(7)*b**S(3)*x**(S(5)/2)) + S(15)*c**(S(7)/4)*x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_f(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(S(14)*b**(S(13)/4)*sqrt(b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**(S(5)/2)*(b*x**S(2) + c*x**S(4))**(S(3)/2)), x), x, S(1)/(b*x**(S(7)/2)*sqrt(b*x**S(2) + c*x**S(4))) - S(11)*sqrt(b*x**S(2) + c*x**S(4))/(S(9)*b**S(2)*x**(S(11)/2)) + S(77)*c*sqrt(b*x**S(2) + c*x**S(4))/(S(45)*b**S(3)*x**(S(7)/2)) + S(77)*c**(S(5)/2)*x**(S(3)/2)*(b + c*x**S(2))/(S(15)*b**S(4)*(sqrt(b) + sqrt(c)*x)*sqrt(b*x**S(2) + c*x**S(4))) - S(77)*c**S(2)*sqrt(b*x**S(2) + c*x**S(4))/(S(15)*b**S(4)*x**(S(3)/2)) - S(77)*c**(S(9)/4)*x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_e(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(S(15)*b**(S(15)/4)*sqrt(b*x**S(2) + c*x**S(4))) + S(77)*c**(S(9)/4)*x*sqrt((b + c*x**S(2))/(sqrt(b) + sqrt(c)*x)**S(2))*(sqrt(b) + sqrt(c)*x)*elliptic_f(S(2)*atan(c**(S(1)/4)*sqrt(x)/b**(S(1)/4)), S(1)/2)/(S(30)*b**(S(15)/4)*sqrt(b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**m*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4)), x), x, a**S(2)*(d*x)**(m + S(1))/(d*(m + S(1))) + S(2)*a*b*(d*x)**(m + S(3))/(d**S(3)*(m + S(3))) + b**S(2)*(d*x)**(m + S(5))/(d**S(5)*(m + S(5))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4)), x), x, a**S(2)*x**S(4)/S(4) + a*b*x**S(6)/S(3) + b**S(2)*x**S(8)/S(8), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4)), x), x, a**S(2)*x**S(3)/S(3) + S(2)*a*b*x**S(5)/S(5) + b**S(2)*x**S(7)/S(7), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4)), x), x, a**S(2)*x**S(2)/S(2) + a*b*x**S(4)/S(2) + b**S(2)*x**S(6)/S(6), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4), x), x, a**S(2)*x + S(2)*a*b*x**S(3)/S(3) + b**S(2)*x**S(5)/S(5), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/x, x), x, a**S(2)*log(x) + a*b*x**S(2) + b**S(2)*x**S(4)/S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/x**S(2), x), x, -a**S(2)/x + S(2)*a*b*x + b**S(2)*x**S(3)/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/x**S(3), x), x, -a**S(2)/(S(2)*x**S(2)) + S(2)*a*b*log(x) + b**S(2)*x**S(2)/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/x**S(4), x), x, -a**S(2)/(S(3)*x**S(3)) - S(2)*a*b/x + b**S(2)*x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/x**S(5), x), x, -a**S(2)/(S(4)*x**S(4)) - a*b/x**S(2) + b**S(2)*log(x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/x**S(6), x), x, -a**S(2)/(S(5)*x**S(5)) - S(2)*a*b/(S(3)*x**S(3)) - b**S(2)/x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/x**S(7), x), x, -a**S(2)/(S(6)*x**S(6)) - a*b/(S(2)*x**S(4)) - b**S(2)/(S(2)*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/x**S(8), x), x, -a**S(2)/(S(7)*x**S(7)) - S(2)*a*b/(S(5)*x**S(5)) - b**S(2)/(S(3)*x**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**m*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(2), x), x, a**S(4)*(d*x)**(m + S(1))/(d*(m + S(1))) + S(4)*a**S(3)*b*(d*x)**(m + S(3))/(d**S(3)*(m + S(3))) + S(6)*a**S(2)*b**S(2)*(d*x)**(m + S(5))/(d**S(5)*(m + S(5))) + S(4)*a*b**S(3)*(d*x)**(m + S(7))/(d**S(7)*(m + S(7))) + b**S(4)*(d*x)**(m + S(9))/(d**S(9)*(m + S(9))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(6)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(2), x), x, a**S(4)*x**S(7)/S(7) + S(4)*a**S(3)*b*x**S(9)/S(9) + S(6)*a**S(2)*b**S(2)*x**S(11)/S(11) + S(4)*a*b**S(3)*x**S(13)/S(13) + b**S(4)*x**S(15)/S(15), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(2), x), x, a**S(4)*x**S(6)/S(6) + a**S(3)*b*x**S(8)/S(2) + S(3)*a**S(2)*b**S(2)*x**S(10)/S(5) + a*b**S(3)*x**S(12)/S(3) + b**S(4)*x**S(14)/S(14), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(2), x), x, a**S(4)*x**S(5)/S(5) + S(4)*a**S(3)*b*x**S(7)/S(7) + S(2)*a**S(2)*b**S(2)*x**S(9)/S(3) + S(4)*a*b**S(3)*x**S(11)/S(11) + b**S(4)*x**S(13)/S(13), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(2), x), x, -a*(a + b*x**S(2))**S(5)/(S(10)*b**S(2)) + (a + b*x**S(2))**S(6)/(S(12)*b**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(2), x), x, a**S(4)*x**S(3)/S(3) + S(4)*a**S(3)*b*x**S(5)/S(5) + S(6)*a**S(2)*b**S(2)*x**S(7)/S(7) + S(4)*a*b**S(3)*x**S(9)/S(9) + b**S(4)*x**S(11)/S(11), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(2), x), x, (a + b*x**S(2))**S(5)/(S(10)*b), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(2), x), x, a**S(4)*x + S(4)*a**S(3)*b*x**S(3)/S(3) + S(6)*a**S(2)*b**S(2)*x**S(5)/S(5) + S(4)*a*b**S(3)*x**S(7)/S(7) + b**S(4)*x**S(9)/S(9), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(2)/x, x), x, a**S(4)*log(x) + S(2)*a**S(3)*b*x**S(2) + S(3)*a**S(2)*b**S(2)*x**S(4)/S(2) + S(2)*a*b**S(3)*x**S(6)/S(3) + b**S(4)*x**S(8)/S(8), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(2)/x**S(2), x), x, -a**S(4)/x + S(4)*a**S(3)*b*x + S(2)*a**S(2)*b**S(2)*x**S(3) + S(4)*a*b**S(3)*x**S(5)/S(5) + b**S(4)*x**S(7)/S(7), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(2)/x**S(3), x), x, -a**S(4)/(S(2)*x**S(2)) + S(4)*a**S(3)*b*log(x) + S(3)*a**S(2)*b**S(2)*x**S(2) + a*b**S(3)*x**S(4) + b**S(4)*x**S(6)/S(6), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(2)/x**S(4), x), x, -a**S(4)/(S(3)*x**S(3)) - S(4)*a**S(3)*b/x + S(6)*a**S(2)*b**S(2)*x + S(4)*a*b**S(3)*x**S(3)/S(3) + b**S(4)*x**S(5)/S(5), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(2)/x**S(5), x), x, -a**S(4)/(S(4)*x**S(4)) - S(2)*a**S(3)*b/x**S(2) + S(6)*a**S(2)*b**S(2)*log(x) + S(2)*a*b**S(3)*x**S(2) + b**S(4)*x**S(4)/S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(2)/x**S(6), x), x, -a**S(4)/(S(5)*x**S(5)) - S(4)*a**S(3)*b/(S(3)*x**S(3)) - S(6)*a**S(2)*b**S(2)/x + S(4)*a*b**S(3)*x + b**S(4)*x**S(3)/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(2)/x**S(7), x), x, -a**S(4)/(S(6)*x**S(6)) - a**S(3)*b/x**S(4) - S(3)*a**S(2)*b**S(2)/x**S(2) + S(4)*a*b**S(3)*log(x) + b**S(4)*x**S(2)/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(2)/x**S(8), x), x, -a**S(4)/(S(7)*x**S(7)) - S(4)*a**S(3)*b/(S(5)*x**S(5)) - S(2)*a**S(2)*b**S(2)/x**S(3) - S(4)*a*b**S(3)/x + b**S(4)*x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(2)/x**S(9), x), x, -a**S(4)/(S(8)*x**S(8)) - S(2)*a**S(3)*b/(S(3)*x**S(6)) - S(3)*a**S(2)*b**S(2)/(S(2)*x**S(4)) - S(2)*a*b**S(3)/x**S(2) + b**S(4)*log(x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(2)/x**S(10), x), x, -a**S(4)/(S(9)*x**S(9)) - S(4)*a**S(3)*b/(S(7)*x**S(7)) - S(6)*a**S(2)*b**S(2)/(S(5)*x**S(5)) - S(4)*a*b**S(3)/(S(3)*x**S(3)) - b**S(4)/x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(2)/x**S(11), x), x, -(a + b*x**S(2))**S(5)/(S(10)*a*x**S(10)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(2)/x**S(12), x), x, -a**S(4)/(S(11)*x**S(11)) - S(4)*a**S(3)*b/(S(9)*x**S(9)) - S(6)*a**S(2)*b**S(2)/(S(7)*x**S(7)) - S(4)*a*b**S(3)/(S(5)*x**S(5)) - b**S(4)/(S(3)*x**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(2)/x**S(13), x), x, -(a + b*x**S(2))**S(5)/(S(12)*a*x**S(12)) + b*(a + b*x**S(2))**S(5)/(S(60)*a**S(2)*x**S(10)), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(2)/x**S(13), x), x, -a**S(4)/(S(12)*x**S(12)) - S(2)*a**S(3)*b/(S(5)*x**S(10)) - S(3)*a**S(2)*b**S(2)/(S(4)*x**S(8)) - S(2)*a*b**S(3)/(S(3)*x**S(6)) - b**S(4)/(S(4)*x**S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(2)/x**S(14), x), x, -a**S(4)/(S(13)*x**S(13)) - S(4)*a**S(3)*b/(S(11)*x**S(11)) - S(2)*a**S(2)*b**S(2)/(S(3)*x**S(9)) - S(4)*a*b**S(3)/(S(7)*x**S(7)) - b**S(4)/(S(5)*x**S(5)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(2)/x**S(15), x), x, -a**S(4)/(S(14)*x**S(14)) - a**S(3)*b/(S(3)*x**S(12)) - S(3)*a**S(2)*b**S(2)/(S(5)*x**S(10)) - a*b**S(3)/(S(2)*x**S(8)) - b**S(4)/(S(6)*x**S(6)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(2)/x**S(16), x), x, -a**S(4)/(S(15)*x**S(15)) - S(4)*a**S(3)*b/(S(13)*x**S(13)) - S(6)*a**S(2)*b**S(2)/(S(11)*x**S(11)) - S(4)*a*b**S(3)/(S(9)*x**S(9)) - b**S(4)/(S(7)*x**S(7)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**m*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3), x), x, a**S(6)*(d*x)**(m + S(1))/(d*(m + S(1))) + S(6)*a**S(5)*b*(d*x)**(m + S(3))/(d**S(3)*(m + S(3))) + S(15)*a**S(4)*b**S(2)*(d*x)**(m + S(5))/(d**S(5)*(m + S(5))) + S(20)*a**S(3)*b**S(3)*(d*x)**(m + S(7))/(d**S(7)*(m + S(7))) + S(15)*a**S(2)*b**S(4)*(d*x)**(m + S(9))/(d**S(9)*(m + S(9))) + S(6)*a*b**S(5)*(d*x)**(m + S(11))/(d**S(11)*(m + S(11))) + b**S(6)*(d*x)**(m + S(13))/(d**S(13)*(m + S(13))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(8)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3), x), x, a**S(6)*x**S(9)/S(9) + S(6)*a**S(5)*b*x**S(11)/S(11) + S(15)*a**S(4)*b**S(2)*x**S(13)/S(13) + S(4)*a**S(3)*b**S(3)*x**S(15)/S(3) + S(15)*a**S(2)*b**S(4)*x**S(17)/S(17) + S(6)*a*b**S(5)*x**S(19)/S(19) + b**S(6)*x**S(21)/S(21), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(7)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3), x), x, a**S(6)*x**S(8)/S(8) + S(3)*a**S(5)*b*x**S(10)/S(5) + S(5)*a**S(4)*b**S(2)*x**S(12)/S(4) + S(10)*a**S(3)*b**S(3)*x**S(14)/S(7) + S(15)*a**S(2)*b**S(4)*x**S(16)/S(16) + a*b**S(5)*x**S(18)/S(3) + b**S(6)*x**S(20)/S(20), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(6)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3), x), x, a**S(6)*x**S(7)/S(7) + S(2)*a**S(5)*b*x**S(9)/S(3) + S(15)*a**S(4)*b**S(2)*x**S(11)/S(11) + S(20)*a**S(3)*b**S(3)*x**S(13)/S(13) + a**S(2)*b**S(4)*x**S(15) + S(6)*a*b**S(5)*x**S(17)/S(17) + b**S(6)*x**S(19)/S(19), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3), x), x, a**S(2)*(a + b*x**S(2))**S(7)/(S(14)*b**S(3)) - a*(a + b*x**S(2))**S(8)/(S(8)*b**S(3)) + (a + b*x**S(2))**S(9)/(S(18)*b**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3), x), x, a**S(6)*x**S(5)/S(5) + S(6)*a**S(5)*b*x**S(7)/S(7) + S(5)*a**S(4)*b**S(2)*x**S(9)/S(3) + S(20)*a**S(3)*b**S(3)*x**S(11)/S(11) + S(15)*a**S(2)*b**S(4)*x**S(13)/S(13) + S(2)*a*b**S(5)*x**S(15)/S(5) + b**S(6)*x**S(17)/S(17), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3), x), x, -a*(a + b*x**S(2))**S(7)/(S(14)*b**S(2)) + (a + b*x**S(2))**S(8)/(S(16)*b**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3), x), x, a**S(6)*x**S(3)/S(3) + S(6)*a**S(5)*b*x**S(5)/S(5) + S(15)*a**S(4)*b**S(2)*x**S(7)/S(7) + S(20)*a**S(3)*b**S(3)*x**S(9)/S(9) + S(15)*a**S(2)*b**S(4)*x**S(11)/S(11) + S(6)*a*b**S(5)*x**S(13)/S(13) + b**S(6)*x**S(15)/S(15), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3), x), x, (a + b*x**S(2))**S(7)/(S(14)*b), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3), x), x, a**S(6)*x + S(2)*a**S(5)*b*x**S(3) + S(3)*a**S(4)*b**S(2)*x**S(5) + S(20)*a**S(3)*b**S(3)*x**S(7)/S(7) + S(5)*a**S(2)*b**S(4)*x**S(9)/S(3) + S(6)*a*b**S(5)*x**S(11)/S(11) + b**S(6)*x**S(13)/S(13), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3)/x, x), x, a**S(6)*log(x) + S(3)*a**S(5)*b*x**S(2) + S(15)*a**S(4)*b**S(2)*x**S(4)/S(4) + S(10)*a**S(3)*b**S(3)*x**S(6)/S(3) + S(15)*a**S(2)*b**S(4)*x**S(8)/S(8) + S(3)*a*b**S(5)*x**S(10)/S(5) + b**S(6)*x**S(12)/S(12), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3)/x**S(2), x), x, -a**S(6)/x + S(6)*a**S(5)*b*x + S(5)*a**S(4)*b**S(2)*x**S(3) + S(4)*a**S(3)*b**S(3)*x**S(5) + S(15)*a**S(2)*b**S(4)*x**S(7)/S(7) + S(2)*a*b**S(5)*x**S(9)/S(3) + b**S(6)*x**S(11)/S(11), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3)/x**S(3), x), x, -a**S(6)/(S(2)*x**S(2)) + S(6)*a**S(5)*b*log(x) + S(15)*a**S(4)*b**S(2)*x**S(2)/S(2) + S(5)*a**S(3)*b**S(3)*x**S(4) + S(5)*a**S(2)*b**S(4)*x**S(6)/S(2) + S(3)*a*b**S(5)*x**S(8)/S(4) + b**S(6)*x**S(10)/S(10), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3)/x**S(4), x), x, -a**S(6)/(S(3)*x**S(3)) - S(6)*a**S(5)*b/x + S(15)*a**S(4)*b**S(2)*x + S(20)*a**S(3)*b**S(3)*x**S(3)/S(3) + S(3)*a**S(2)*b**S(4)*x**S(5) + S(6)*a*b**S(5)*x**S(7)/S(7) + b**S(6)*x**S(9)/S(9), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3)/x**S(5), x), x, -a**S(6)/(S(4)*x**S(4)) - S(3)*a**S(5)*b/x**S(2) + S(15)*a**S(4)*b**S(2)*log(x) + S(10)*a**S(3)*b**S(3)*x**S(2) + S(15)*a**S(2)*b**S(4)*x**S(4)/S(4) + a*b**S(5)*x**S(6) + b**S(6)*x**S(8)/S(8), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3)/x**S(6), x), x, -a**S(6)/(S(5)*x**S(5)) - S(2)*a**S(5)*b/x**S(3) - S(15)*a**S(4)*b**S(2)/x + S(20)*a**S(3)*b**S(3)*x + S(5)*a**S(2)*b**S(4)*x**S(3) + S(6)*a*b**S(5)*x**S(5)/S(5) + b**S(6)*x**S(7)/S(7), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3)/x**S(7), x), x, -a**S(6)/(S(6)*x**S(6)) - S(3)*a**S(5)*b/(S(2)*x**S(4)) - S(15)*a**S(4)*b**S(2)/(S(2)*x**S(2)) + S(20)*a**S(3)*b**S(3)*log(x) + S(15)*a**S(2)*b**S(4)*x**S(2)/S(2) + S(3)*a*b**S(5)*x**S(4)/S(2) + b**S(6)*x**S(6)/S(6), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3)/x**S(8), x), x, -a**S(6)/(S(7)*x**S(7)) - S(6)*a**S(5)*b/(S(5)*x**S(5)) - S(5)*a**S(4)*b**S(2)/x**S(3) - S(20)*a**S(3)*b**S(3)/x + S(15)*a**S(2)*b**S(4)*x + S(2)*a*b**S(5)*x**S(3) + b**S(6)*x**S(5)/S(5), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3)/x**S(9), x), x, -a**S(6)/(S(8)*x**S(8)) - a**S(5)*b/x**S(6) - S(15)*a**S(4)*b**S(2)/(S(4)*x**S(4)) - S(10)*a**S(3)*b**S(3)/x**S(2) + S(15)*a**S(2)*b**S(4)*log(x) + S(3)*a*b**S(5)*x**S(2) + b**S(6)*x**S(4)/S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3)/x**S(10), x), x, -a**S(6)/(S(9)*x**S(9)) - S(6)*a**S(5)*b/(S(7)*x**S(7)) - S(3)*a**S(4)*b**S(2)/x**S(5) - S(20)*a**S(3)*b**S(3)/(S(3)*x**S(3)) - S(15)*a**S(2)*b**S(4)/x + S(6)*a*b**S(5)*x + b**S(6)*x**S(3)/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3)/x**S(11), x), x, -a**S(6)/(S(10)*x**S(10)) - S(3)*a**S(5)*b/(S(4)*x**S(8)) - S(5)*a**S(4)*b**S(2)/(S(2)*x**S(6)) - S(5)*a**S(3)*b**S(3)/x**S(4) - S(15)*a**S(2)*b**S(4)/(S(2)*x**S(2)) + S(6)*a*b**S(5)*log(x) + b**S(6)*x**S(2)/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3)/x**S(12), x), x, -a**S(6)/(S(11)*x**S(11)) - S(2)*a**S(5)*b/(S(3)*x**S(9)) - S(15)*a**S(4)*b**S(2)/(S(7)*x**S(7)) - S(4)*a**S(3)*b**S(3)/x**S(5) - S(5)*a**S(2)*b**S(4)/x**S(3) - S(6)*a*b**S(5)/x + b**S(6)*x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3)/x**S(13), x), x, -a**S(6)/(S(12)*x**S(12)) - S(3)*a**S(5)*b/(S(5)*x**S(10)) - S(15)*a**S(4)*b**S(2)/(S(8)*x**S(8)) - S(10)*a**S(3)*b**S(3)/(S(3)*x**S(6)) - S(15)*a**S(2)*b**S(4)/(S(4)*x**S(4)) - S(3)*a*b**S(5)/x**S(2) + b**S(6)*log(x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3)/x**S(14), x), x, -a**S(6)/(S(13)*x**S(13)) - S(6)*a**S(5)*b/(S(11)*x**S(11)) - S(5)*a**S(4)*b**S(2)/(S(3)*x**S(9)) - S(20)*a**S(3)*b**S(3)/(S(7)*x**S(7)) - S(3)*a**S(2)*b**S(4)/x**S(5) - S(2)*a*b**S(5)/x**S(3) - b**S(6)/x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3)/x**S(15), x), x, -(a + b*x**S(2))**S(7)/(S(14)*a*x**S(14)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3)/x**S(16), x), x, -a**S(6)/(S(15)*x**S(15)) - S(6)*a**S(5)*b/(S(13)*x**S(13)) - S(15)*a**S(4)*b**S(2)/(S(11)*x**S(11)) - S(20)*a**S(3)*b**S(3)/(S(9)*x**S(9)) - S(15)*a**S(2)*b**S(4)/(S(7)*x**S(7)) - S(6)*a*b**S(5)/(S(5)*x**S(5)) - b**S(6)/(S(3)*x**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3)/x**S(17), x), x, -(a + b*x**S(2))**S(7)/(S(16)*a*x**S(16)) + b*(a + b*x**S(2))**S(7)/(S(112)*a**S(2)*x**S(14)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3)/x**S(18), x), x, -a**S(6)/(S(17)*x**S(17)) - S(2)*a**S(5)*b/(S(5)*x**S(15)) - S(15)*a**S(4)*b**S(2)/(S(13)*x**S(13)) - S(20)*a**S(3)*b**S(3)/(S(11)*x**S(11)) - S(5)*a**S(2)*b**S(4)/(S(3)*x**S(9)) - S(6)*a*b**S(5)/(S(7)*x**S(7)) - b**S(6)/(S(5)*x**S(5)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3)/x**S(19), x), x, -(a + b*x**S(2))**S(7)/(S(18)*a*x**S(18)) + b*(a + b*x**S(2))**S(7)/(S(72)*a**S(2)*x**S(16)) - b**S(2)*(a + b*x**S(2))**S(7)/(S(504)*a**S(3)*x**S(14)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3)/x**S(20), x), x, -a**S(6)/(S(19)*x**S(19)) - S(6)*a**S(5)*b/(S(17)*x**S(17)) - a**S(4)*b**S(2)/x**S(15) - S(20)*a**S(3)*b**S(3)/(S(13)*x**S(13)) - S(15)*a**S(2)*b**S(4)/(S(11)*x**S(11)) - S(2)*a*b**S(5)/(S(3)*x**S(9)) - b**S(6)/(S(7)*x**S(7)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3)/x**S(21), x), x, -a**S(6)/(S(20)*x**S(20)) - a**S(5)*b/(S(3)*x**S(18)) - S(15)*a**S(4)*b**S(2)/(S(16)*x**S(16)) - S(10)*a**S(3)*b**S(3)/(S(7)*x**S(14)) - S(5)*a**S(2)*b**S(4)/(S(4)*x**S(12)) - S(3)*a*b**S(5)/(S(5)*x**S(10)) - b**S(6)/(S(8)*x**S(8)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3)/x**S(22), x), x, -a**S(6)/(S(21)*x**S(21)) - S(6)*a**S(5)*b/(S(19)*x**S(19)) - S(15)*a**S(4)*b**S(2)/(S(17)*x**S(17)) - S(4)*a**S(3)*b**S(3)/(S(3)*x**S(15)) - S(15)*a**S(2)*b**S(4)/(S(13)*x**S(13)) - S(6)*a*b**S(5)/(S(11)*x**S(11)) - b**S(6)/(S(9)*x**S(9)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**m/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4)), x), x, (d*x)**(m + S(1))*hyper((S(2), m/S(2) + S(1)/2), (m/S(2) + S(3)/2,), -b*x**S(2)/a)/(a**S(2)*d*(m + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(11)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4)), x), x, a**S(5)/(S(2)*b**S(6)*(a + b*x**S(2))) + S(5)*a**S(4)*log(a + b*x**S(2))/(S(2)*b**S(6)) - S(2)*a**S(3)*x**S(2)/b**S(5) + S(3)*a**S(2)*x**S(4)/(S(4)*b**S(4)) - a*x**S(6)/(S(3)*b**S(3)) + x**S(8)/(S(8)*b**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(9)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4)), x), x, -a**S(4)/(S(2)*b**S(5)*(a + b*x**S(2))) - S(2)*a**S(3)*log(a + b*x**S(2))/b**S(5) + S(3)*a**S(2)*x**S(2)/(S(2)*b**S(4)) - a*x**S(4)/(S(2)*b**S(3)) + x**S(6)/(S(6)*b**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(7)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4)), x), x, a**S(3)/(S(2)*b**S(4)*(a + b*x**S(2))) + S(3)*a**S(2)*log(a + b*x**S(2))/(S(2)*b**S(4)) - a*x**S(2)/b**S(3) + x**S(4)/(S(4)*b**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4)), x), x, -a**S(2)/(S(2)*b**S(3)*(a + b*x**S(2))) - a*log(a + b*x**S(2))/b**S(3) + x**S(2)/(S(2)*b**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4)), x), x, a/(S(2)*b**S(2)*(a + b*x**S(2))) + log(a + b*x**S(2))/(S(2)*b**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4)), x), x, -S(1)/(S(2)*b*(a + b*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), x), x, S(1)/(S(2)*a*(a + b*x**S(2))) + log(x)/a**S(2) - log(a + b*x**S(2))/(S(2)*a**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(3)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), x), x, -b/(S(2)*a**S(2)*(a + b*x**S(2))) - S(1)/(S(2)*a**S(2)*x**S(2)) - S(2)*b*log(x)/a**S(3) + b*log(a + b*x**S(2))/a**S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(5)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), x), x, -S(1)/(S(4)*a**S(2)*x**S(4)) + b**S(2)/(S(2)*a**S(3)*(a + b*x**S(2))) + b/(a**S(3)*x**S(2)) + S(3)*b**S(2)*log(x)/a**S(4) - S(3)*b**S(2)*log(a + b*x**S(2))/(S(2)*a**S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(10)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4)), x), x, S(9)*a**(S(7)/2)*atan(sqrt(b)*x/sqrt(a))/(S(2)*b**(S(11)/2)) - S(9)*a**S(3)*x/(S(2)*b**S(5)) + S(3)*a**S(2)*x**S(3)/(S(2)*b**S(4)) - S(9)*a*x**S(5)/(S(10)*b**S(3)) - x**S(9)/(S(2)*b*(a + b*x**S(2))) + S(9)*x**S(7)/(S(14)*b**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(8)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4)), x), x, -S(7)*a**(S(5)/2)*atan(sqrt(b)*x/sqrt(a))/(S(2)*b**(S(9)/2)) + S(7)*a**S(2)*x/(S(2)*b**S(4)) - S(7)*a*x**S(3)/(S(6)*b**S(3)) - x**S(7)/(S(2)*b*(a + b*x**S(2))) + S(7)*x**S(5)/(S(10)*b**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(6)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4)), x), x, S(5)*a**(S(3)/2)*atan(sqrt(b)*x/sqrt(a))/(S(2)*b**(S(7)/2)) - S(5)*a*x/(S(2)*b**S(3)) - x**S(5)/(S(2)*b*(a + b*x**S(2))) + S(5)*x**S(3)/(S(6)*b**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4)), x), x, -S(3)*sqrt(a)*atan(sqrt(b)*x/sqrt(a))/(S(2)*b**(S(5)/2)) - x**S(3)/(S(2)*b*(a + b*x**S(2))) + S(3)*x/(S(2)*b**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4)), x), x, -x/(S(2)*b*(a + b*x**S(2))) + atan(sqrt(b)*x/sqrt(a))/(S(2)*sqrt(a)*b**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4)), x), x, x/(S(2)*a*(a + b*x**S(2))) + atan(sqrt(b)*x/sqrt(a))/(S(2)*a**(S(3)/2)*sqrt(b)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), x), x, S(1)/(S(2)*a*x*(a + b*x**S(2))) - S(3)/(S(2)*a**S(2)*x) - S(3)*sqrt(b)*atan(sqrt(b)*x/sqrt(a))/(S(2)*a**(S(5)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(4)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), x), x, S(1)/(S(2)*a*x**S(3)*(a + b*x**S(2))) - S(5)/(S(6)*a**S(2)*x**S(3)) + S(5)*b/(S(2)*a**S(3)*x) + S(5)*b**(S(3)/2)*atan(sqrt(b)*x/sqrt(a))/(S(2)*a**(S(7)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(6)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), x), x, S(1)/(S(2)*a*x**S(5)*(a + b*x**S(2))) - S(7)/(S(10)*a**S(2)*x**S(5)) + S(7)*b/(S(6)*a**S(3)*x**S(3)) - S(7)*b**S(2)/(S(2)*a**S(4)*x) - S(7)*b**(S(5)/2)*atan(sqrt(b)*x/sqrt(a))/(S(2)*a**(S(9)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**m/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(2), x), x, (d*x)**(m + S(1))*hyper((S(4), m/S(2) + S(1)/2), (m/S(2) + S(3)/2,), -b*x**S(2)/a)/(a**S(4)*d*(m + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(11)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(2), x), x, a**S(5)/(S(6)*b**S(6)*(a + b*x**S(2))**S(3)) - S(5)*a**S(4)/(S(4)*b**S(6)*(a + b*x**S(2))**S(2)) + S(5)*a**S(3)/(b**S(6)*(a + b*x**S(2))) + S(5)*a**S(2)*log(a + b*x**S(2))/b**S(6) - S(2)*a*x**S(2)/b**S(5) + x**S(4)/(S(4)*b**S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(9)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(2), x), x, -a**S(4)/(S(6)*b**S(5)*(a + b*x**S(2))**S(3)) + a**S(3)/(b**S(5)*(a + b*x**S(2))**S(2)) - S(3)*a**S(2)/(b**S(5)*(a + b*x**S(2))) - S(2)*a*log(a + b*x**S(2))/b**S(5) + x**S(2)/(S(2)*b**S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(7)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(2), x), x, a**S(3)/(S(6)*b**S(4)*(a + b*x**S(2))**S(3)) - S(3)*a**S(2)/(S(4)*b**S(4)*(a + b*x**S(2))**S(2)) + S(3)*a/(S(2)*b**S(4)*(a + b*x**S(2))) + log(a + b*x**S(2))/(S(2)*b**S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(2), x), x, x**S(6)/(S(6)*a*(a + b*x**S(2))**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(2), x), x, a/(S(6)*b**S(2)*(a + b*x**S(2))**S(3)) - S(1)/(S(4)*b**S(2)*(a + b*x**S(2))**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(2), x), x, -S(1)/(S(6)*b*(a + b*x**S(2))**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(2)), x), x, S(1)/(S(6)*a*(a + b*x**S(2))**S(3)) + S(1)/(S(4)*a**S(2)*(a + b*x**S(2))**S(2)) + S(1)/(S(2)*a**S(3)*(a + b*x**S(2))) + log(x)/a**S(4) - log(a + b*x**S(2))/(S(2)*a**S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(3)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(2)), x), x, -b/(S(6)*a**S(2)*(a + b*x**S(2))**S(3)) - b/(S(2)*a**S(3)*(a + b*x**S(2))**S(2)) - S(3)*b/(S(2)*a**S(4)*(a + b*x**S(2))) - S(1)/(S(2)*a**S(4)*x**S(2)) - S(4)*b*log(x)/a**S(5) + S(2)*b*log(a + b*x**S(2))/a**S(5), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(5)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(2)), x), x, b**S(2)/(S(6)*a**S(3)*(a + b*x**S(2))**S(3)) + S(3)*b**S(2)/(S(4)*a**S(4)*(a + b*x**S(2))**S(2)) - S(1)/(S(4)*a**S(4)*x**S(4)) + S(3)*b**S(2)/(a**S(5)*(a + b*x**S(2))) + S(2)*b/(a**S(5)*x**S(2)) + S(10)*b**S(2)*log(x)/a**S(6) - S(5)*b**S(2)*log(a + b*x**S(2))/a**S(6), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(12)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(2), x), x, -S(231)*a**(S(5)/2)*atan(sqrt(b)*x/sqrt(a))/(S(16)*b**(S(13)/2)) + S(231)*a**S(2)*x/(S(16)*b**S(6)) - S(77)*a*x**S(3)/(S(16)*b**S(5)) - x**S(11)/(S(6)*b*(a + b*x**S(2))**S(3)) - S(11)*x**S(9)/(S(24)*b**S(2)*(a + b*x**S(2))**S(2)) - S(33)*x**S(7)/(S(16)*b**S(3)*(a + b*x**S(2))) + S(231)*x**S(5)/(S(80)*b**S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(10)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(2), x), x, S(105)*a**(S(3)/2)*atan(sqrt(b)*x/sqrt(a))/(S(16)*b**(S(11)/2)) - S(105)*a*x/(S(16)*b**S(5)) - x**S(9)/(S(6)*b*(a + b*x**S(2))**S(3)) - S(3)*x**S(7)/(S(8)*b**S(2)*(a + b*x**S(2))**S(2)) - S(21)*x**S(5)/(S(16)*b**S(3)*(a + b*x**S(2))) + S(35)*x**S(3)/(S(16)*b**S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(8)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(2), x), x, -S(35)*sqrt(a)*atan(sqrt(b)*x/sqrt(a))/(S(16)*b**(S(9)/2)) - x**S(7)/(S(6)*b*(a + b*x**S(2))**S(3)) - S(7)*x**S(5)/(S(24)*b**S(2)*(a + b*x**S(2))**S(2)) - S(35)*x**S(3)/(S(48)*b**S(3)*(a + b*x**S(2))) + S(35)*x/(S(16)*b**S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(6)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(2), x), x, -x**S(5)/(S(6)*b*(a + b*x**S(2))**S(3)) - S(5)*x**S(3)/(S(24)*b**S(2)*(a + b*x**S(2))**S(2)) - S(5)*x/(S(16)*b**S(3)*(a + b*x**S(2))) + S(5)*atan(sqrt(b)*x/sqrt(a))/(S(16)*sqrt(a)*b**(S(7)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(2), x), x, -x**S(3)/(S(6)*b*(a + b*x**S(2))**S(3)) - x/(S(8)*b**S(2)*(a + b*x**S(2))**S(2)) + x/(S(16)*a*b**S(2)*(a + b*x**S(2))) + atan(sqrt(b)*x/sqrt(a))/(S(16)*a**(S(3)/2)*b**(S(5)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(2), x), x, -x/(S(6)*b*(a + b*x**S(2))**S(3)) + x/(S(24)*a*b*(a + b*x**S(2))**S(2)) + x/(S(16)*a**S(2)*b*(a + b*x**S(2))) + atan(sqrt(b)*x/sqrt(a))/(S(16)*a**(S(5)/2)*b**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(-2)), x), x, x/(S(6)*a*(a + b*x**S(2))**S(3)) + S(5)*x/(S(24)*a**S(2)*(a + b*x**S(2))**S(2)) + S(5)*x/(S(16)*a**S(3)*(a + b*x**S(2))) + S(5)*atan(sqrt(b)*x/sqrt(a))/(S(16)*a**(S(7)/2)*sqrt(b)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(2)), x), x, S(1)/(S(6)*a*x*(a + b*x**S(2))**S(3)) + S(7)/(S(24)*a**S(2)*x*(a + b*x**S(2))**S(2)) + S(35)/(S(48)*a**S(3)*x*(a + b*x**S(2))) - S(35)/(S(16)*a**S(4)*x) - S(35)*sqrt(b)*atan(sqrt(b)*x/sqrt(a))/(S(16)*a**(S(9)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(4)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(2)), x), x, S(1)/(S(6)*a*x**S(3)*(a + b*x**S(2))**S(3)) + S(3)/(S(8)*a**S(2)*x**S(3)*(a + b*x**S(2))**S(2)) + S(21)/(S(16)*a**S(3)*x**S(3)*(a + b*x**S(2))) - S(35)/(S(16)*a**S(4)*x**S(3)) + S(105)*b/(S(16)*a**S(5)*x) + S(105)*b**(S(3)/2)*atan(sqrt(b)*x/sqrt(a))/(S(16)*a**(S(11)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(6)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(2)), x), x, S(1)/(S(6)*a*x**S(5)*(a + b*x**S(2))**S(3)) + S(11)/(S(24)*a**S(2)*x**S(5)*(a + b*x**S(2))**S(2)) + S(33)/(S(16)*a**S(3)*x**S(5)*(a + b*x**S(2))) - S(231)/(S(80)*a**S(4)*x**S(5)) + S(77)*b/(S(16)*a**S(5)*x**S(3)) - S(231)*b**S(2)/(S(16)*a**S(6)*x) - S(231)*b**(S(5)/2)*atan(sqrt(b)*x/sqrt(a))/(S(16)*a**(S(13)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**m/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3), x), x, (d*x)**(m + S(1))*hyper((S(6), m/S(2) + S(1)/2), (m/S(2) + S(3)/2,), -b*x**S(2)/a)/(a**S(6)*d*(m + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(15)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3), x), x, a**S(7)/(S(10)*b**S(8)*(a + b*x**S(2))**S(5)) - S(7)*a**S(6)/(S(8)*b**S(8)*(a + b*x**S(2))**S(4)) + S(7)*a**S(5)/(S(2)*b**S(8)*(a + b*x**S(2))**S(3)) - S(35)*a**S(4)/(S(4)*b**S(8)*(a + b*x**S(2))**S(2)) + S(35)*a**S(3)/(S(2)*b**S(8)*(a + b*x**S(2))) + S(21)*a**S(2)*log(a + b*x**S(2))/(S(2)*b**S(8)) - S(3)*a*x**S(2)/b**S(7) + x**S(4)/(S(4)*b**S(6)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(13)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3), x), x, -a**S(6)/(S(10)*b**S(7)*(a + b*x**S(2))**S(5)) + S(3)*a**S(5)/(S(4)*b**S(7)*(a + b*x**S(2))**S(4)) - S(5)*a**S(4)/(S(2)*b**S(7)*(a + b*x**S(2))**S(3)) + S(5)*a**S(3)/(b**S(7)*(a + b*x**S(2))**S(2)) - S(15)*a**S(2)/(S(2)*b**S(7)*(a + b*x**S(2))) - S(3)*a*log(a + b*x**S(2))/b**S(7) + x**S(2)/(S(2)*b**S(6)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(11)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3), x), x, a**S(5)/(S(10)*b**S(6)*(a + b*x**S(2))**S(5)) - S(5)*a**S(4)/(S(8)*b**S(6)*(a + b*x**S(2))**S(4)) + S(5)*a**S(3)/(S(3)*b**S(6)*(a + b*x**S(2))**S(3)) - S(5)*a**S(2)/(S(2)*b**S(6)*(a + b*x**S(2))**S(2)) + S(5)*a/(S(2)*b**S(6)*(a + b*x**S(2))) + log(a + b*x**S(2))/(S(2)*b**S(6)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(9)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3), x), x, x**S(10)/(S(10)*a*(a + b*x**S(2))**S(5)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(7)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3), x), x, x**S(8)/(S(10)*a*(a + b*x**S(2))**S(5)) + x**S(8)/(S(40)*a**S(2)*(a + b*x**S(2))**S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3), x), x, -a**S(2)/(S(10)*b**S(3)*(a + b*x**S(2))**S(5)) + a/(S(4)*b**S(3)*(a + b*x**S(2))**S(4)) - S(1)/(S(6)*b**S(3)*(a + b*x**S(2))**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3), x), x, a/(S(10)*b**S(2)*(a + b*x**S(2))**S(5)) - S(1)/(S(8)*b**S(2)*(a + b*x**S(2))**S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3), x), x, -S(1)/(S(10)*b*(a + b*x**S(2))**S(5)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3)), x), x, S(1)/(S(10)*a*(a + b*x**S(2))**S(5)) + S(1)/(S(8)*a**S(2)*(a + b*x**S(2))**S(4)) + S(1)/(S(6)*a**S(3)*(a + b*x**S(2))**S(3)) + S(1)/(S(4)*a**S(4)*(a + b*x**S(2))**S(2)) + S(1)/(S(2)*a**S(5)*(a + b*x**S(2))) + log(x)/a**S(6) - log(a + b*x**S(2))/(S(2)*a**S(6)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(3)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3)), x), x, -b/(S(10)*a**S(2)*(a + b*x**S(2))**S(5)) - b/(S(4)*a**S(3)*(a + b*x**S(2))**S(4)) - b/(S(2)*a**S(4)*(a + b*x**S(2))**S(3)) - b/(a**S(5)*(a + b*x**S(2))**S(2)) - S(5)*b/(S(2)*a**S(6)*(a + b*x**S(2))) - S(1)/(S(2)*a**S(6)*x**S(2)) - S(6)*b*log(x)/a**S(7) + S(3)*b*log(a + b*x**S(2))/a**S(7), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(5)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3)), x), x, b**S(2)/(S(10)*a**S(3)*(a + b*x**S(2))**S(5)) + S(3)*b**S(2)/(S(8)*a**S(4)*(a + b*x**S(2))**S(4)) + b**S(2)/(a**S(5)*(a + b*x**S(2))**S(3)) + S(5)*b**S(2)/(S(2)*a**S(6)*(a + b*x**S(2))**S(2)) - S(1)/(S(4)*a**S(6)*x**S(4)) + S(15)*b**S(2)/(S(2)*a**S(7)*(a + b*x**S(2))) + S(3)*b/(a**S(7)*x**S(2)) + S(21)*b**S(2)*log(x)/a**S(8) - S(21)*b**S(2)*log(a + b*x**S(2))/(S(2)*a**S(8)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(16)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3), x), x, -S(9009)*a**(S(5)/2)*atan(sqrt(b)*x/sqrt(a))/(S(256)*b**(S(17)/2)) + S(9009)*a**S(2)*x/(S(256)*b**S(8)) - S(3003)*a*x**S(3)/(S(256)*b**S(7)) - x**S(15)/(S(10)*b*(a + b*x**S(2))**S(5)) - S(3)*x**S(13)/(S(16)*b**S(2)*(a + b*x**S(2))**S(4)) - S(13)*x**S(11)/(S(32)*b**S(3)*(a + b*x**S(2))**S(3)) - S(143)*x**S(9)/(S(128)*b**S(4)*(a + b*x**S(2))**S(2)) - S(1287)*x**S(7)/(S(256)*b**S(5)*(a + b*x**S(2))) + S(9009)*x**S(5)/(S(1280)*b**S(6)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(14)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3), x), x, S(3003)*a**(S(3)/2)*atan(sqrt(b)*x/sqrt(a))/(S(256)*b**(S(15)/2)) - S(3003)*a*x/(S(256)*b**S(7)) - x**S(13)/(S(10)*b*(a + b*x**S(2))**S(5)) - S(13)*x**S(11)/(S(80)*b**S(2)*(a + b*x**S(2))**S(4)) - S(143)*x**S(9)/(S(480)*b**S(3)*(a + b*x**S(2))**S(3)) - S(429)*x**S(7)/(S(640)*b**S(4)*(a + b*x**S(2))**S(2)) - S(3003)*x**S(5)/(S(1280)*b**S(5)*(a + b*x**S(2))) + S(1001)*x**S(3)/(S(256)*b**S(6)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(12)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3), x), x, -S(693)*sqrt(a)*atan(sqrt(b)*x/sqrt(a))/(S(256)*b**(S(13)/2)) - x**S(11)/(S(10)*b*(a + b*x**S(2))**S(5)) - S(11)*x**S(9)/(S(80)*b**S(2)*(a + b*x**S(2))**S(4)) - S(33)*x**S(7)/(S(160)*b**S(3)*(a + b*x**S(2))**S(3)) - S(231)*x**S(5)/(S(640)*b**S(4)*(a + b*x**S(2))**S(2)) - S(231)*x**S(3)/(S(256)*b**S(5)*(a + b*x**S(2))) + S(693)*x/(S(256)*b**S(6)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(10)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3), x), x, -x**S(9)/(S(10)*b*(a + b*x**S(2))**S(5)) - S(9)*x**S(7)/(S(80)*b**S(2)*(a + b*x**S(2))**S(4)) - S(21)*x**S(5)/(S(160)*b**S(3)*(a + b*x**S(2))**S(3)) - S(21)*x**S(3)/(S(128)*b**S(4)*(a + b*x**S(2))**S(2)) - S(63)*x/(S(256)*b**S(5)*(a + b*x**S(2))) + S(63)*atan(sqrt(b)*x/sqrt(a))/(S(256)*sqrt(a)*b**(S(11)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(8)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3), x), x, -x**S(7)/(S(10)*b*(a + b*x**S(2))**S(5)) - S(7)*x**S(5)/(S(80)*b**S(2)*(a + b*x**S(2))**S(4)) - S(7)*x**S(3)/(S(96)*b**S(3)*(a + b*x**S(2))**S(3)) - S(7)*x/(S(128)*b**S(4)*(a + b*x**S(2))**S(2)) + S(7)*x/(S(256)*a*b**S(4)*(a + b*x**S(2))) + S(7)*atan(sqrt(b)*x/sqrt(a))/(S(256)*a**(S(3)/2)*b**(S(9)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(6)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3), x), x, -x**S(5)/(S(10)*b*(a + b*x**S(2))**S(5)) - x**S(3)/(S(16)*b**S(2)*(a + b*x**S(2))**S(4)) - x/(S(32)*b**S(3)*(a + b*x**S(2))**S(3)) + x/(S(128)*a*b**S(3)*(a + b*x**S(2))**S(2)) + S(3)*x/(S(256)*a**S(2)*b**S(3)*(a + b*x**S(2))) + S(3)*atan(sqrt(b)*x/sqrt(a))/(S(256)*a**(S(5)/2)*b**(S(7)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3), x), x, -x**S(3)/(S(10)*b*(a + b*x**S(2))**S(5)) - S(3)*x/(S(80)*b**S(2)*(a + b*x**S(2))**S(4)) + x/(S(160)*a*b**S(2)*(a + b*x**S(2))**S(3)) + x/(S(128)*a**S(2)*b**S(2)*(a + b*x**S(2))**S(2)) + S(3)*x/(S(256)*a**S(3)*b**S(2)*(a + b*x**S(2))) + S(3)*atan(sqrt(b)*x/sqrt(a))/(S(256)*a**(S(7)/2)*b**(S(5)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3), x), x, -x/(S(10)*b*(a + b*x**S(2))**S(5)) + x/(S(80)*a*b*(a + b*x**S(2))**S(4)) + S(7)*x/(S(480)*a**S(2)*b*(a + b*x**S(2))**S(3)) + S(7)*x/(S(384)*a**S(3)*b*(a + b*x**S(2))**S(2)) + S(7)*x/(S(256)*a**S(4)*b*(a + b*x**S(2))) + S(7)*atan(sqrt(b)*x/sqrt(a))/(S(256)*a**(S(9)/2)*b**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(-3)), x), x, x/(S(10)*a*(a + b*x**S(2))**S(5)) + S(9)*x/(S(80)*a**S(2)*(a + b*x**S(2))**S(4)) + S(21)*x/(S(160)*a**S(3)*(a + b*x**S(2))**S(3)) + S(21)*x/(S(128)*a**S(4)*(a + b*x**S(2))**S(2)) + S(63)*x/(S(256)*a**S(5)*(a + b*x**S(2))) + S(63)*atan(sqrt(b)*x/sqrt(a))/(S(256)*a**(S(11)/2)*sqrt(b)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3)), x), x, S(1)/(S(10)*a*x*(a + b*x**S(2))**S(5)) + S(11)/(S(80)*a**S(2)*x*(a + b*x**S(2))**S(4)) + S(33)/(S(160)*a**S(3)*x*(a + b*x**S(2))**S(3)) + S(231)/(S(640)*a**S(4)*x*(a + b*x**S(2))**S(2)) + S(231)/(S(256)*a**S(5)*x*(a + b*x**S(2))) - S(693)/(S(256)*a**S(6)*x) - S(693)*sqrt(b)*atan(sqrt(b)*x/sqrt(a))/(S(256)*a**(S(13)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(4)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3)), x), x, S(1)/(S(10)*a*x**S(3)*(a + b*x**S(2))**S(5)) + S(13)/(S(80)*a**S(2)*x**S(3)*(a + b*x**S(2))**S(4)) + S(143)/(S(480)*a**S(3)*x**S(3)*(a + b*x**S(2))**S(3)) + S(429)/(S(640)*a**S(4)*x**S(3)*(a + b*x**S(2))**S(2)) + S(3003)/(S(1280)*a**S(5)*x**S(3)*(a + b*x**S(2))) - S(1001)/(S(256)*a**S(6)*x**S(3)) + S(3003)*b/(S(256)*a**S(7)*x) + S(3003)*b**(S(3)/2)*atan(sqrt(b)*x/sqrt(a))/(S(256)*a**(S(15)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(6)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3)), x), x, S(1)/(S(10)*a*x**S(5)*(a + b*x**S(2))**S(5)) + S(3)/(S(16)*a**S(2)*x**S(5)*(a + b*x**S(2))**S(4)) + S(13)/(S(32)*a**S(3)*x**S(5)*(a + b*x**S(2))**S(3)) + S(143)/(S(128)*a**S(4)*x**S(5)*(a + b*x**S(2))**S(2)) + S(1287)/(S(256)*a**S(5)*x**S(5)*(a + b*x**S(2))) - S(9009)/(S(1280)*a**S(6)*x**S(5)) + S(3003)*b/(S(256)*a**S(7)*x**S(3)) - S(9009)*b**S(2)/(S(256)*a**S(8)*x) - S(9009)*b**(S(5)/2)*atan(sqrt(b)*x/sqrt(a))/(S(256)*a**(S(17)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(4) + S(2)*x**S(2) + S(1)), x), x, x/(S(2)*x**S(2) + S(2)) + atan(x)/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(x**S(4) + S(2)*x**S(2) + S(1)), x), x, -S(1)/(S(2)*x**S(2) + S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/(x**S(4) + S(2)*x**S(2) + S(1)), x), x, -x/(S(2)*x**S(2) + S(2)) + atan(x)/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/(x**S(4) + S(2)*x**S(2) + S(1)), x), x, log(x**S(2) + S(1))/S(2) + S(1)/(S(2)*x**S(2) + S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(x**S(4) - S(18)*x**S(2) + S(81)), x), x, S(1)/(-S(2)*x**S(2) + S(18)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/(x**S(4) - S(8)*x**S(2) + S(16)), x), x, log(-x**S(2) + S(4))/S(2) + S(2)/(-x**S(2) + S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**m*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4)), x), x, S(2)*a*(d*x)**(m + S(1))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(d*(a + b*x**S(2))*(m**S(2) + S(4)*m + S(3))) + (d*x)**(m + S(1))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(d*(m + S(3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4)), x), x, a*x**S(6)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(24)*a + S(24)*b*x**S(2)) + x**S(6)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/S(8), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4)), x), x, S(2)*a*x**S(5)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(35)*a + S(35)*b*x**S(2)) + x**S(5)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/S(7), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4)), x), x, a*x**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(12)*a + S(12)*b*x**S(2)) + x**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/S(6), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4)), x), x, S(2)*a*x**S(3)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(15)*a + S(15)*b*x**S(2)) + x**S(3)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/S(5), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4)), x), x, (a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(4)*b), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4)), x), x, S(2)*a*x*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(3)*a + S(3)*b*x**S(2)) + x*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/x, x), x, a*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))*log(x)/(a + b*x**S(2)) + sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/x**S(2), x), x, -S(2)*a*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(x*(a + b*x**S(2))) + sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/x**S(3), x), x, -a*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(2)*x**S(2)*(a + b*x**S(2))) + b*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))*log(x)/(a + b*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/x**S(4), x), x, S(2)*a*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(3)*x**S(3)*(a + b*x**S(2))) - sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/x**S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/x**S(5), x), x, -(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(4)*a*x**S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/x**S(6), x), x, S(2)*a*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(15)*x**S(5)*(a + b*x**S(2))) - sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(3)*x**S(5)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/x**S(7), x), x, a*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(12)*x**S(6)*(a + b*x**S(2))) - sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(4)*x**S(6)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/x**S(8), x), x, S(2)*a*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(35)*x**S(7)*(a + b*x**S(2))) - sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(5)*x**S(7)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/x**S(9), x), x, a*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(24)*x**S(8)*(a + b*x**S(2))) - sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(6)*x**S(8)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/x**S(10), x), x, S(2)*a*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(63)*x**S(9)*(a + b*x**S(2))) - sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(7)*x**S(9)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/x**S(11), x), x, a*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(40)*x**S(10)*(a + b*x**S(2))) - sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(8)*x**S(10)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(9)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2), x), x, a**S(3)*x**S(10)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(560)*a + S(560)*b*x**S(2)) + a**S(2)*x**S(10)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/S(112) + S(3)*a*x**S(10)*(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/S(112) + x**S(10)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/S(16), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(8)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2), x), x, S(16)*a**S(3)*x**S(9)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(6435)*a + S(6435)*b*x**S(2)) + S(8)*a**S(2)*x**S(9)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/S(715) + S(2)*a*x**S(9)*(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/S(65) + x**S(9)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/S(15), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(7)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2), x), x, a**S(3)*x**S(8)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(280)*a + S(280)*b*x**S(2)) + a**S(2)*x**S(8)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/S(70) + a*x**S(8)*(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/S(28) + x**S(8)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/S(14), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(6)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2), x), x, S(16)*a**S(3)*x**S(7)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(3003)*a + S(3003)*b*x**S(2)) + S(8)*a**S(2)*x**S(7)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/S(429) + S(6)*a*x**S(7)*(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/S(143) + x**S(7)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/S(13), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2), x), x, a**S(2)*(a + b*x**S(2))*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(24)*b**S(3)) - a*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/(S(30)*b**S(3)) + x**S(4)*(a + b*x**S(2))*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(12)*b), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2), x), x, S(16)*a**S(3)*x**S(5)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(1155)*a + S(1155)*b*x**S(2)) + S(8)*a**S(2)*x**S(5)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/S(231) + S(2)*a*x**S(5)*(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/S(33) + x**S(5)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/S(11), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2), x), x, -a*(a + b*x**S(2))*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(8)*b**S(2)) + (a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/(S(10)*b**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2), x), x, S(16)*a**S(3)*x**S(3)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(315)*a + S(315)*b*x**S(2)) + S(8)*a**S(2)*x**S(3)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/S(105) + S(2)*a*x**S(3)*(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/S(21) + x**S(3)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/S(9), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2), x), x, (a + b*x**S(2))*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(8)*b), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2), x), x, S(16)*a**S(3)*x*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(35)*a + S(35)*b*x**S(2)) + S(8)*a**S(2)*x*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/S(35) + S(6)*a*x*(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/S(35) + x*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/S(7), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/x, x), x, a**S(3)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))*log(x)/(a + b*x**S(2)) + a**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/S(2) + a*(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/S(4) + (a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/S(6), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/x**S(2), x), x, -S(16)*a**S(3)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(5)*x*(a + b*x**S(2))) + S(8)*a**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(5)*x) + S(2)*a*(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(5)*x) + (a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(5)*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/x**S(3), x), x, S(3)*a**S(2)*b*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))*log(x)/(a + b*x**S(2)) + S(3)*a*b*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/S(2) - S(3)*a*(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(4)*x**S(2)) + (a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(4)*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/x**S(4), x), x, S(16)*a*b**S(2)*x*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(3)*a + S(3)*b*x**S(2)) + S(2)*a*(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/x**S(3) + S(8)*b**S(2)*x*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/S(3) - S(7)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(3)*x**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/x**S(5), x), x, S(3)*a*b**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))*log(x)/(a + b*x**S(2)) + S(3)*a*(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(4)*x**S(4)) + S(3)*b**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/S(2) - (a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/x**S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/x**S(6), x), x, -S(16)*a*b**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(5)*x*(a + b*x**S(2))) + S(2)*a*(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(5)*x**S(5)) + S(8)*b**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(5)*x) - S(3)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(5)*x**S(5)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/x**S(7), x), x, -a*b**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(2)*x**S(2)*(a + b*x**S(2))) + a*(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(4)*x**S(6)) + b**S(3)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))*log(x)/(a + b*x**S(2)) - S(5)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(12)*x**S(6)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/x**S(8), x), x, S(16)*a*b**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(35)*x**S(3)*(a + b*x**S(2))) + S(6)*a*(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(35)*x**S(7)) - S(24)*b**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(35)*x**S(3)) - S(11)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(35)*x**S(7)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/x**S(9), x), x, -(a + b*x**S(2))*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(8)*a*x**S(8)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/x**S(10), x), x, S(16)*a*b**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(315)*x**S(5)*(a + b*x**S(2))) + S(2)*a*(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(21)*x**S(9)) - S(8)*b**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(63)*x**S(5)) - S(13)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(63)*x**S(9)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/x**S(11), x), x, -(a + b*x**S(2))*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(8)*a*x**S(10)) + (a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/(S(40)*a**S(2)*x**S(10)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/x**S(12), x), x, S(16)*a*b**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(1155)*x**S(7)*(a + b*x**S(2))) + S(2)*a*(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(33)*x**S(11)) - S(8)*b**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(165)*x**S(7)) - S(5)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(33)*x**S(11)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/x**S(13), x), x, -(a + b*x**S(2))*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(12)*a*x**S(12)) + b*(a + b*x**S(2))*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(24)*a**S(2)*x**S(10)) - b*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/(S(120)*a**S(3)*x**S(10)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/x**S(14), x), x, S(16)*a*b**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(3003)*x**S(9)*(a + b*x**S(2))) + S(6)*a*(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(143)*x**S(13)) - S(24)*b**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(1001)*x**S(9)) - S(17)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(143)*x**S(13)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/x**S(15), x), x, a*b**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(280)*x**S(10)*(a + b*x**S(2))) + a*(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(28)*x**S(14)) - b**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(56)*x**S(10)) - S(3)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(28)*x**S(14)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/x**S(16), x), x, S(16)*a*b**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(6435)*x**S(11)*(a + b*x**S(2))) + S(2)*a*(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(65)*x**S(15)) - S(8)*b**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(585)*x**S(11)) - S(19)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(195)*x**S(15)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/x**S(17), x), x, a*b**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(560)*x**S(12)*(a + b*x**S(2))) + S(3)*a*(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(112)*x**S(16)) - S(3)*b**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(280)*x**S(12)) - S(5)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(56)*x**S(16)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(13)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2), x), x, a**S(5)*x**S(14)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(11088)*a + S(11088)*b*x**S(2)) + a**S(4)*x**S(14)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/S(1584) + a**S(3)*x**S(14)*(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/S(396) + a**S(2)*x**S(14)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/S(132) + S(5)*a*x**S(14)*(a + b*x**S(2))*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/S(264) + x**S(14)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/S(24), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(12)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2), x), x, S(256)*a**S(5)*x**S(13)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(2028117)*a + S(2028117)*b*x**S(2)) + S(128)*a**S(4)*x**S(13)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/S(156009) + S(160)*a**S(3)*x**S(13)*(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/S(52003) + S(80)*a**S(2)*x**S(13)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/S(9177) + S(10)*a*x**S(13)*(a + b*x**S(2))*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/S(483) + x**S(13)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/S(23), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(11)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2), x), x, a**S(5)*x**S(12)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(5544)*a + S(5544)*b*x**S(2)) + a**S(4)*x**S(12)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/S(924) + a**S(3)*x**S(12)*(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/S(264) + a**S(2)*x**S(12)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/S(99) + a*x**S(12)*(a + b*x**S(2))*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/S(44) + x**S(12)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/S(22), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(10)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2), x), x, S(256)*a**S(5)*x**S(11)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(969969)*a + S(969969)*b*x**S(2)) + S(128)*a**S(4)*x**S(11)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/S(88179) + S(32)*a**S(3)*x**S(11)*(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/S(6783) + S(80)*a**S(2)*x**S(11)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/S(6783) + S(10)*a*x**S(11)*(a + b*x**S(2))*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/S(399) + x**S(11)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/S(21), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(9)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2), x), x, a**S(4)*(a + b*x**S(2))*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/(S(360)*b**S(5)) - a**S(3)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(7)/2)/(S(420)*b**S(5)) + a**S(2)*x**S(4)*(a + b*x**S(2))*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/(S(120)*b**S(3)) - a*x**S(6)*(a + b*x**S(2))*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/(S(45)*b**S(2)) + x**S(8)*(a + b*x**S(2))*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/(S(20)*b), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(8)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2), x), x, S(256)*a**S(5)*x**S(9)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(415701)*a + S(415701)*b*x**S(2)) + S(128)*a**S(4)*x**S(9)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/S(46189) + S(32)*a**S(3)*x**S(9)*(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/S(4199) + S(16)*a**S(2)*x**S(9)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/S(969) + S(10)*a*x**S(9)*(a + b*x**S(2))*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/S(323) + x**S(9)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/S(19), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(7)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2), x), x, -a**S(3)*(a + b*x**S(2))*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/(S(144)*b**S(4)) + a**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(7)/2)/(S(168)*b**S(4)) - a*x**S(4)*(a + b*x**S(2))*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/(S(48)*b**S(2)) + x**S(6)*(a + b*x**S(2))*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/(S(18)*b), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(6)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2), x), x, S(256)*a**S(5)*x**S(7)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(153153)*a + S(153153)*b*x**S(2)) + S(128)*a**S(4)*x**S(7)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/S(21879) + S(32)*a**S(3)*x**S(7)*(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/S(2431) + S(16)*a**S(2)*x**S(7)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/S(663) + S(2)*a*x**S(7)*(a + b*x**S(2))*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/S(51) + x**S(7)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/S(17), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2), x), x, a**S(2)*(a + b*x**S(2))*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/(S(48)*b**S(3)) - a*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(7)/2)/(S(56)*b**S(3)) + x**S(4)*(a + b*x**S(2))*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/(S(16)*b), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2), x), x, S(256)*a**S(5)*x**S(5)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(45045)*a + S(45045)*b*x**S(2)) + S(128)*a**S(4)*x**S(5)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/S(9009) + S(32)*a**S(3)*x**S(5)*(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/S(1287) + S(16)*a**S(2)*x**S(5)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/S(429) + S(2)*a*x**S(5)*(a + b*x**S(2))*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/S(39) + x**S(5)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/S(15), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2), x), x, -a*(a + b*x**S(2))*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/(S(12)*b**S(2)) + (a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(7)/2)/(S(14)*b**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2), x), x, S(256)*a**S(5)*x**S(3)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(9009)*a + S(9009)*b*x**S(2)) + S(128)*a**S(4)*x**S(3)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/S(3003) + S(160)*a**S(3)*x**S(3)*(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/S(3003) + S(80)*a**S(2)*x**S(3)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/S(1287) + S(10)*a*x**S(3)*(a + b*x**S(2))*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/S(143) + x**S(3)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/S(13), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2), x), x, (a + b*x**S(2))*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/(S(12)*b), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2), x), x, S(256)*a**S(5)*x*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(693)*a + S(693)*b*x**S(2)) + S(128)*a**S(4)*x*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/S(693) + S(32)*a**S(3)*x*(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/S(231) + S(80)*a**S(2)*x*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/S(693) + S(10)*a*x*(a + b*x**S(2))*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/S(99) + x*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/S(11), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/x, x), x, a**S(5)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))*log(x)/(a + b*x**S(2)) + a**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/S(2) + a**S(3)*(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/S(4) + a**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/S(6) + a*(a + b*x**S(2))*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/S(8) + (a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/S(10), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/x**S(2), x), x, -S(256)*a**S(5)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(63)*x*(a + b*x**S(2))) + S(128)*a**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(63)*x) + S(32)*a**S(3)*(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(63)*x) + S(16)*a**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(63)*x) + S(10)*a*(a + b*x**S(2))*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(63)*x) + (a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/(S(9)*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/x**S(3), x), x, S(5)*a**S(4)*b*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))*log(x)/(a + b*x**S(2)) + S(5)*a**S(3)*b*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/S(2) + S(5)*a**S(2)*b*(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/S(4) + S(5)*a*b*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/S(6) - S(5)*a*(a + b*x**S(2))*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(8)*x**S(2)) + (a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/(S(8)*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/x**S(4), x), x, S(256)*a**S(3)*b**S(2)*x*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(21)*a + S(21)*b*x**S(2)) + S(128)*a**S(2)*b**S(2)*x*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/S(21) + S(32)*a*b**S(2)*x*(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/S(7) + S(10)*a*(a + b*x**S(2))*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(3)*x**S(3)) + S(80)*b**S(2)*x*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/S(21) - S(11)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/(S(3)*x**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/x**S(5), x), x, S(10)*a**S(3)*b**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))*log(x)/(a + b*x**S(2)) + S(5)*a**S(2)*b**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4)) + S(5)*a*b**S(2)*(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/S(2) + S(5)*a*(a + b*x**S(2))*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(4)*x**S(4)) + S(5)*b**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/S(3) - S(3)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/(S(2)*x**S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/x**S(6), x), x, -S(256)*a**S(3)*b**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(15)*x*(a + b*x**S(2))) + S(128)*a**S(2)*b**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(15)*x) + S(32)*a*b**S(2)*(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(15)*x) + S(2)*a*(a + b*x**S(2))*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(3)*x**S(5)) + S(16)*b**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(15)*x) - S(13)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/(S(15)*x**S(5)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/x**S(7), x), x, S(10)*a**S(2)*b**S(3)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))*log(x)/(a + b*x**S(2)) + S(5)*a*b**S(3)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4)) - S(5)*a*b**S(2)*(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(2)*x**S(2)) + S(5)*a*(a + b*x**S(2))*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(12)*x**S(6)) + S(5)*b**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(6)*x**S(2)) - S(7)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/(S(12)*x**S(6)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/x**S(8), x), x, S(256)*a*b**S(4)*x*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(21)*a + S(21)*b*x**S(2)) + S(32)*a*b**S(2)*(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(7)*x**S(3)) + S(2)*a*(a + b*x**S(2))*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(7)*x**S(7)) + S(128)*b**S(4)*x*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/S(21) - S(16)*b**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(3)*x**S(3)) - S(3)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/(S(7)*x**S(7)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/x**S(9), x), x, S(5)*a*b**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))*log(x)/(a + b*x**S(2)) + S(5)*a*b**S(2)*(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(4)*x**S(4)) + S(5)*a*(a + b*x**S(2))*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(24)*x**S(8)) + S(5)*b**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/S(2) - S(5)*b**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(3)*x**S(4)) - (a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/(S(3)*x**S(8)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/x**S(10), x), x, -S(256)*a*b**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(63)*x*(a + b*x**S(2))) + S(32)*a*b**S(2)*(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(63)*x**S(5)) + S(10)*a*(a + b*x**S(2))*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(63)*x**S(9)) + S(128)*b**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(63)*x) - S(16)*b**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(21)*x**S(5)) - S(17)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/(S(63)*x**S(9)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/x**S(11), x), x, -a*b**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(2)*x**S(2)*(a + b*x**S(2))) + a*b**S(2)*(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(4)*x**S(6)) + a*(a + b*x**S(2))*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(8)*x**S(10)) + b**S(5)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))*log(x)/(a + b*x**S(2)) - S(5)*b**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(12)*x**S(6)) - S(9)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/(S(40)*x**S(10)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/x**S(12), x), x, S(256)*a*b**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(693)*x**S(3)*(a + b*x**S(2))) + S(32)*a*b**S(2)*(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(231)*x**S(7)) + S(10)*a*(a + b*x**S(2))*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(99)*x**S(11)) - S(128)*b**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(231)*x**S(3)) - S(16)*b**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(63)*x**S(7)) - S(19)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/(S(99)*x**S(11)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/x**S(13), x), x, -(a + b*x**S(2))*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/(S(12)*a*x**S(12)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/x**S(14), x), x, S(256)*a*b**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(9009)*x**S(5)*(a + b*x**S(2))) + S(160)*a*b**S(2)*(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(3003)*x**S(9)) + S(10)*a*(a + b*x**S(2))*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(143)*x**S(13)) - S(640)*b**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(9009)*x**S(5)) - S(80)*b**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(693)*x**S(9)) - S(21)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/(S(143)*x**S(13)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/x**S(15), x), x, -(a + b*x**S(2))*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/(S(12)*a*x**S(14)) + (a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(7)/2)/(S(84)*a**S(2)*x**S(14)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/x**S(16), x), x, S(256)*a*b**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(45045)*x**S(7)*(a + b*x**S(2))) + S(32)*a*b**S(2)*(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(1287)*x**S(11)) + S(2)*a*(a + b*x**S(2))*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(39)*x**S(15)) - S(128)*b**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(6435)*x**S(7)) - S(80)*b**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(1287)*x**S(11)) - S(23)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/(S(195)*x**S(15)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/x**S(17), x), x, -(a + b*x**S(2))*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/(S(16)*a*x**S(16)) + b*(a + b*x**S(2))*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/(S(48)*a**S(2)*x**S(14)) - b*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(7)/2)/(S(336)*a**S(3)*x**S(14)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/x**S(18), x), x, S(256)*a*b**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(153153)*x**S(9)*(a + b*x**S(2))) + S(32)*a*b**S(2)*(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(2431)*x**S(13)) + S(2)*a*(a + b*x**S(2))*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(51)*x**S(17)) - S(128)*b**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(17017)*x**S(9)) - S(16)*b**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(429)*x**S(13)) - S(5)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/(S(51)*x**S(17)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/x**S(19), x), x, -(a + b*x**S(2))*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/(S(18)*a*x**S(18)) + b*(a + b*x**S(2))*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/(S(48)*a**S(2)*x**S(16)) - b**S(2)*(a + b*x**S(2))*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/(S(144)*a**S(3)*x**S(14)) + b**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(7)/2)/(S(1008)*a**S(4)*x**S(14)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/x**S(20), x), x, S(256)*a*b**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(415701)*x**S(11)*(a + b*x**S(2))) + S(32)*a*b**S(2)*(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(4199)*x**S(15)) + S(10)*a*(a + b*x**S(2))*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(323)*x**S(19)) - S(128)*b**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(37791)*x**S(11)) - S(16)*b**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(663)*x**S(15)) - S(27)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/(S(323)*x**S(19)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/x**S(21), x), x, a*b**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(2520)*x**S(12)*(a + b*x**S(2))) + a*b**S(2)*(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(168)*x**S(16)) + a*(a + b*x**S(2))*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(36)*x**S(20)) - b**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(420)*x**S(12)) - S(5)*b**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(252)*x**S(16)) - S(7)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/(S(90)*x**S(20)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/x**S(22), x), x, S(256)*a*b**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(969969)*x**S(13)*(a + b*x**S(2))) + S(32)*a*b**S(2)*(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(6783)*x**S(17)) + S(10)*a*(a + b*x**S(2))*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(399)*x**S(21)) - S(128)*b**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(74613)*x**S(13)) - S(16)*b**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(969)*x**S(17)) - S(29)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/(S(399)*x**S(21)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/x**S(23), x), x, a*b**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(5544)*x**S(14)*(a + b*x**S(2))) + a*b**S(2)*(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(264)*x**S(18)) + a*(a + b*x**S(2))*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(44)*x**S(22)) - b**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(792)*x**S(14)) - b**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(72)*x**S(18)) - S(3)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/(S(44)*x**S(22)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/x**S(24), x), x, S(256)*a*b**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(2028117)*x**S(15)*(a + b*x**S(2))) + S(160)*a*b**S(2)*(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(52003)*x**S(19)) + S(10)*a*(a + b*x**S(2))*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(483)*x**S(23)) - S(640)*b**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(676039)*x**S(15)) - S(80)*b**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(6783)*x**S(19)) - S(31)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/(S(483)*x**S(23)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/x**S(25), x), x, a*b**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(11088)*x**S(16)*(a + b*x**S(2))) + a*b**S(2)*(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(396)*x**S(20)) + S(5)*a*(a + b*x**S(2))*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(264)*x**S(24)) - b**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(1386)*x**S(16)) - b**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(99)*x**S(20)) - S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/(S(33)*x**S(24)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**m/sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4)), x), x, (d*x)**(m + S(1))*(a + b*x**S(2))*hyper((S(1), m/S(2) + S(1)/2), (m/S(2) + S(3)/2,), -b*x**S(2)/a)/(a*d*(m + S(1))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)/sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4)), x), x, a**(S(3)/2)*(a + b*x**S(2))*atan(sqrt(b)*x/sqrt(a))/(b**(S(5)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - a*x*(a + b*x**S(2))/(b**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + x**S(3)*(a + b*x**S(2))/(S(3)*b*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4)), x), x, -a*(a + b*x**S(2))*log(a + b*x**S(2))/(S(2)*b**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(2)*b**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4)), x), x, -sqrt(a)*(a + b*x**S(2))*atan(sqrt(b)*x/sqrt(a))/(b**(S(3)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + x*(a + b*x**S(2))/(b*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4)), x), x, (a + b*x**S(2))*log(a + b*x**S(2))/(S(2)*b*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4)), x), x, (a + b*x**S(2))*atan(sqrt(b)*x/sqrt(a))/(sqrt(a)*sqrt(b)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), x), x, (a + b*x**S(2))*log(x)/(a*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - (a + b*x**S(2))*log(a + b*x**S(2))/(S(2)*a*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), x), x, -(a + b*x**S(2))/(a*x*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - sqrt(b)*(a + b*x**S(2))*atan(sqrt(b)*x/sqrt(a))/(a**(S(3)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(3)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), x), x, -b*(a + b*x**S(2))*log(x)/(a**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + b*(a + b*x**S(2))*log(a + b*x**S(2))/(S(2)*a**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(2)*a**S(2)*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), x), x, -(a + b*x**S(2))/(S(3)*a*x**S(3)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + b*(a + b*x**S(2))/(a**S(2)*x*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + b**(S(3)/2)*(a + b*x**S(2))*atan(sqrt(b)*x/sqrt(a))/(a**(S(5)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**m/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2), x), x, (d*x)**(m + S(1))*(a + b*x**S(2))*hyper((S(3), m/S(2) + S(1)/2), (m/S(2) + S(3)/2,), -b*x**S(2)/a)/(a**S(3)*d*(m + S(1))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2), x), x, a*x*(a + b*x**S(2))/(S(4)*b**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)) - S(5)*x/(S(8)*b**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + (S(3)*a + S(3)*b*x**S(2))*atan(sqrt(b)*x/sqrt(a))/(S(8)*sqrt(a)*b**(S(5)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2), x), x, x**S(4)*(a + b*x**S(2))/(S(4)*a*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2), x), x, x**S(3)*(a + b*x**S(2))/(S(4)*a*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)) - x/(S(8)*a*b*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + (a + b*x**S(2))*atan(sqrt(b)*x/sqrt(a))/(S(8)*a**(S(3)/2)*b**(S(3)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2), x), x, -(a + b*x**S(2))/(S(4)*b*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(-3)/2), x), x, x*(a + b*x**S(2))/(S(4)*a*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)) + S(3)*x/(S(8)*a**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + (S(3)*a + S(3)*b*x**S(2))*atan(sqrt(b)*x/sqrt(a))/(S(8)*a**(S(5)/2)*sqrt(b)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)), x), x, (a + b*x**S(2))/(S(4)*a*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)) + S(1)/(S(2)*a**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + (a + b*x**S(2))*log(x)/(a**S(3)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - (a + b*x**S(2))*log(a + b*x**S(2))/(S(2)*a**S(3)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)), x), x, (a + b*x**S(2))/(S(4)*a*x*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)) + S(5)/(S(8)*a**S(2)*x*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - (S(15)*a + S(15)*b*x**S(2))/(S(8)*a**S(3)*x*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - S(15)*sqrt(b)*(a + b*x**S(2))*atan(sqrt(b)*x/sqrt(a))/(S(8)*a**(S(7)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(3)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)), x), x, (a + b*x**S(2))/(S(4)*a*x**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)) + S(3)/(S(4)*a**S(2)*x**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - S(3)*b*(a + b*x**S(2))*log(x)/(a**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + S(3)*b*(a + b*x**S(2))*log(a + b*x**S(2))/(S(2)*a**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - S(3)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(2)*a**S(4)*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(4)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)), x), x, (a + b*x**S(2))/(S(4)*a*x**S(3)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)) + S(7)/(S(8)*a**S(2)*x**S(3)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - (S(35)*a + S(35)*b*x**S(2))/(S(24)*a**S(3)*x**S(3)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + S(35)*b*(a + b*x**S(2))/(S(8)*a**S(4)*x*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + S(35)*b**(S(3)/2)*(a + b*x**S(2))*atan(sqrt(b)*x/sqrt(a))/(S(8)*a**(S(9)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**m/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2), x), x, (d*x)**(m + S(1))*(a + b*x**S(2))*hyper((S(5), m/S(2) + S(1)/2), (m/S(2) + S(3)/2,), -b*x**S(2)/a)/(a**S(5)*d*(m + S(1))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(6)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2), x), x, a*x**S(3)*(a + b*x**S(2))/(S(8)*b**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)) - S(11)*x**S(3)/(S(48)*b**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)) + S(5)*x**S(3)*(a + b*x**S(2))/(S(64)*a*b**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)) - S(5)*x/(S(128)*a*b**S(3)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + (S(5)*a + S(5)*b*x**S(2))*atan(sqrt(b)*x/sqrt(a))/(S(128)*a**(S(3)/2)*b**(S(7)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2), x), x, x**S(6)*(a + b*x**S(2))/(S(8)*a*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)) + x**S(6)/(S(24)*a**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2), x), x, a*x*(a + b*x**S(2))/(S(8)*b**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)) - S(3)*x/(S(16)*b**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)) + x*(a + b*x**S(2))/(S(64)*a*b**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)) + S(3)*x/(S(128)*a**S(2)*b**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + (S(3)*a + S(3)*b*x**S(2))*atan(sqrt(b)*x/sqrt(a))/(S(128)*a**(S(5)/2)*b**(S(5)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2), x), x, a*(a + b*x**S(2))/(S(8)*b**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)) - S(1)/(S(6)*b**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2), x), x, x**S(3)*(a + b*x**S(2))/(S(8)*a*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)) - S(5)*x/(S(48)*a*b*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)) + S(5)*x*(a + b*x**S(2))/(S(192)*a**S(2)*b*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)) + S(5)*x/(S(128)*a**S(3)*b*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + (S(5)*a + S(5)*b*x**S(2))*atan(sqrt(b)*x/sqrt(a))/(S(128)*a**(S(7)/2)*b**(S(3)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2), x), x, -(a + b*x**S(2))/(S(8)*b*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(-5)/2), x), x, x*(a + b*x**S(2))/(S(8)*a*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)) + S(7)*x/(S(48)*a**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)) + S(35)*x*(a + b*x**S(2))/(S(192)*a**S(3)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)) + S(35)*x/(S(128)*a**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + (S(35)*a + S(35)*b*x**S(2))*atan(sqrt(b)*x/sqrt(a))/(S(128)*a**(S(9)/2)*sqrt(b)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)), x), x, (a + b*x**S(2))/(S(8)*a*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)) + S(1)/(S(6)*a**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)) + (a + b*x**S(2))/(S(4)*a**S(3)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)) + S(1)/(S(2)*a**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + (a + b*x**S(2))*log(x)/(a**S(5)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - (a + b*x**S(2))*log(a + b*x**S(2))/(S(2)*a**S(5)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)), x), x, (a + b*x**S(2))/(S(8)*a*x*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)) + S(3)/(S(16)*a**S(2)*x*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)) + (S(21)*a + S(21)*b*x**S(2))/(S(64)*a**S(3)*x*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)) + S(105)/(S(128)*a**S(4)*x*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - (S(315)*a + S(315)*b*x**S(2))/(S(128)*a**S(5)*x*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - S(315)*sqrt(b)*(a + b*x**S(2))*atan(sqrt(b)*x/sqrt(a))/(S(128)*a**(S(11)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(3)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)), x), x, (a + b*x**S(2))/(S(8)*a*x**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)) + S(5)/(S(24)*a**S(2)*x**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)) + (S(5)*a + S(5)*b*x**S(2))/(S(12)*a**S(3)*x**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)) + S(5)/(S(4)*a**S(4)*x**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - S(5)*b*(a + b*x**S(2))*log(x)/(a**S(6)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + S(5)*b*(a + b*x**S(2))*log(a + b*x**S(2))/(S(2)*a**S(6)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - S(5)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(2)*a**S(6)*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(4)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)), x), x, (a + b*x**S(2))/(S(8)*a*x**S(3)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)) + S(11)/(S(48)*a**S(2)*x**S(3)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)) + (S(33)*a + S(33)*b*x**S(2))/(S(64)*a**S(3)*x**S(3)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)) + S(231)/(S(128)*a**S(4)*x**S(3)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - (S(385)*a + S(385)*b*x**S(2))/(S(128)*a**S(5)*x**S(3)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + S(1155)*b*(a + b*x**S(2))/(S(128)*a**S(6)*x*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + S(1155)*b**(S(3)/2)*(a + b*x**S(2))*atan(sqrt(b)*x/sqrt(a))/(S(128)*a**(S(13)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**(S(5)/2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4)), x), x, S(2)*a**S(2)*(d*x)**(S(7)/2)/(S(7)*d) + S(4)*a*b*(d*x)**(S(11)/2)/(S(11)*d**S(3)) + S(2)*b**S(2)*(d*x)**(S(15)/2)/(S(15)*d**S(5)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**(S(3)/2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4)), x), x, S(2)*a**S(2)*(d*x)**(S(5)/2)/(S(5)*d) + S(4)*a*b*(d*x)**(S(9)/2)/(S(9)*d**S(3)) + S(2)*b**S(2)*(d*x)**(S(13)/2)/(S(13)*d**S(5)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(d*x)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4)), x), x, S(2)*a**S(2)*(d*x)**(S(3)/2)/(S(3)*d) + S(4)*a*b*(d*x)**(S(7)/2)/(S(7)*d**S(3)) + S(2)*b**S(2)*(d*x)**(S(11)/2)/(S(11)*d**S(5)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/sqrt(d*x), x), x, S(2)*a**S(2)*sqrt(d*x)/d + S(4)*a*b*(d*x)**(S(5)/2)/(S(5)*d**S(3)) + S(2)*b**S(2)*(d*x)**(S(9)/2)/(S(9)*d**S(5)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(d*x)**(S(3)/2), x), x, -S(2)*a**S(2)/(d*sqrt(d*x)) + S(4)*a*b*(d*x)**(S(3)/2)/(S(3)*d**S(3)) + S(2)*b**S(2)*(d*x)**(S(7)/2)/(S(7)*d**S(5)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(d*x)**(S(5)/2), x), x, -S(2)*a**S(2)/(S(3)*d*(d*x)**(S(3)/2)) + S(4)*a*b*sqrt(d*x)/d**S(3) + S(2)*b**S(2)*(d*x)**(S(5)/2)/(S(5)*d**S(5)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(d*x)**(S(7)/2), x), x, -S(2)*a**S(2)/(S(5)*d*(d*x)**(S(5)/2)) - S(4)*a*b/(d**S(3)*sqrt(d*x)) + S(2)*b**S(2)*(d*x)**(S(3)/2)/(S(3)*d**S(5)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**(S(5)/2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(2), x), x, S(2)*a**S(4)*(d*x)**(S(7)/2)/(S(7)*d) + S(8)*a**S(3)*b*(d*x)**(S(11)/2)/(S(11)*d**S(3)) + S(4)*a**S(2)*b**S(2)*(d*x)**(S(15)/2)/(S(5)*d**S(5)) + S(8)*a*b**S(3)*(d*x)**(S(19)/2)/(S(19)*d**S(7)) + S(2)*b**S(4)*(d*x)**(S(23)/2)/(S(23)*d**S(9)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**(S(3)/2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(2), x), x, S(2)*a**S(4)*(d*x)**(S(5)/2)/(S(5)*d) + S(8)*a**S(3)*b*(d*x)**(S(9)/2)/(S(9)*d**S(3)) + S(12)*a**S(2)*b**S(2)*(d*x)**(S(13)/2)/(S(13)*d**S(5)) + S(8)*a*b**S(3)*(d*x)**(S(17)/2)/(S(17)*d**S(7)) + S(2)*b**S(4)*(d*x)**(S(21)/2)/(S(21)*d**S(9)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(d*x)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(2), x), x, S(2)*a**S(4)*(d*x)**(S(3)/2)/(S(3)*d) + S(8)*a**S(3)*b*(d*x)**(S(7)/2)/(S(7)*d**S(3)) + S(12)*a**S(2)*b**S(2)*(d*x)**(S(11)/2)/(S(11)*d**S(5)) + S(8)*a*b**S(3)*(d*x)**(S(15)/2)/(S(15)*d**S(7)) + S(2)*b**S(4)*(d*x)**(S(19)/2)/(S(19)*d**S(9)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(2)/sqrt(d*x), x), x, S(2)*a**S(4)*sqrt(d*x)/d + S(8)*a**S(3)*b*(d*x)**(S(5)/2)/(S(5)*d**S(3)) + S(4)*a**S(2)*b**S(2)*(d*x)**(S(9)/2)/(S(3)*d**S(5)) + S(8)*a*b**S(3)*(d*x)**(S(13)/2)/(S(13)*d**S(7)) + S(2)*b**S(4)*(d*x)**(S(17)/2)/(S(17)*d**S(9)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(2)/(d*x)**(S(3)/2), x), x, -S(2)*a**S(4)/(d*sqrt(d*x)) + S(8)*a**S(3)*b*(d*x)**(S(3)/2)/(S(3)*d**S(3)) + S(12)*a**S(2)*b**S(2)*(d*x)**(S(7)/2)/(S(7)*d**S(5)) + S(8)*a*b**S(3)*(d*x)**(S(11)/2)/(S(11)*d**S(7)) + S(2)*b**S(4)*(d*x)**(S(15)/2)/(S(15)*d**S(9)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(2)/(d*x)**(S(5)/2), x), x, -S(2)*a**S(4)/(S(3)*d*(d*x)**(S(3)/2)) + S(8)*a**S(3)*b*sqrt(d*x)/d**S(3) + S(12)*a**S(2)*b**S(2)*(d*x)**(S(5)/2)/(S(5)*d**S(5)) + S(8)*a*b**S(3)*(d*x)**(S(9)/2)/(S(9)*d**S(7)) + S(2)*b**S(4)*(d*x)**(S(13)/2)/(S(13)*d**S(9)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(2)/(d*x)**(S(7)/2), x), x, -S(2)*a**S(4)/(S(5)*d*(d*x)**(S(5)/2)) - S(8)*a**S(3)*b/(d**S(3)*sqrt(d*x)) + S(4)*a**S(2)*b**S(2)*(d*x)**(S(3)/2)/d**S(5) + S(8)*a*b**S(3)*(d*x)**(S(7)/2)/(S(7)*d**S(7)) + S(2)*b**S(4)*(d*x)**(S(11)/2)/(S(11)*d**S(9)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**(S(5)/2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3), x), x, S(2)*a**S(6)*(d*x)**(S(7)/2)/(S(7)*d) + S(12)*a**S(5)*b*(d*x)**(S(11)/2)/(S(11)*d**S(3)) + S(2)*a**S(4)*b**S(2)*(d*x)**(S(15)/2)/d**S(5) + S(40)*a**S(3)*b**S(3)*(d*x)**(S(19)/2)/(S(19)*d**S(7)) + S(30)*a**S(2)*b**S(4)*(d*x)**(S(23)/2)/(S(23)*d**S(9)) + S(4)*a*b**S(5)*(d*x)**(S(27)/2)/(S(9)*d**S(11)) + S(2)*b**S(6)*(d*x)**(S(31)/2)/(S(31)*d**S(13)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**(S(3)/2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3), x), x, S(2)*a**S(6)*(d*x)**(S(5)/2)/(S(5)*d) + S(4)*a**S(5)*b*(d*x)**(S(9)/2)/(S(3)*d**S(3)) + S(30)*a**S(4)*b**S(2)*(d*x)**(S(13)/2)/(S(13)*d**S(5)) + S(40)*a**S(3)*b**S(3)*(d*x)**(S(17)/2)/(S(17)*d**S(7)) + S(10)*a**S(2)*b**S(4)*(d*x)**(S(21)/2)/(S(7)*d**S(9)) + S(12)*a*b**S(5)*(d*x)**(S(25)/2)/(S(25)*d**S(11)) + S(2)*b**S(6)*(d*x)**(S(29)/2)/(S(29)*d**S(13)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(d*x)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3), x), x, S(2)*a**S(6)*(d*x)**(S(3)/2)/(S(3)*d) + S(12)*a**S(5)*b*(d*x)**(S(7)/2)/(S(7)*d**S(3)) + S(30)*a**S(4)*b**S(2)*(d*x)**(S(11)/2)/(S(11)*d**S(5)) + S(8)*a**S(3)*b**S(3)*(d*x)**(S(15)/2)/(S(3)*d**S(7)) + S(30)*a**S(2)*b**S(4)*(d*x)**(S(19)/2)/(S(19)*d**S(9)) + S(12)*a*b**S(5)*(d*x)**(S(23)/2)/(S(23)*d**S(11)) + S(2)*b**S(6)*(d*x)**(S(27)/2)/(S(27)*d**S(13)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3)/sqrt(d*x), x), x, S(2)*a**S(6)*sqrt(d*x)/d + S(12)*a**S(5)*b*(d*x)**(S(5)/2)/(S(5)*d**S(3)) + S(10)*a**S(4)*b**S(2)*(d*x)**(S(9)/2)/(S(3)*d**S(5)) + S(40)*a**S(3)*b**S(3)*(d*x)**(S(13)/2)/(S(13)*d**S(7)) + S(30)*a**S(2)*b**S(4)*(d*x)**(S(17)/2)/(S(17)*d**S(9)) + S(4)*a*b**S(5)*(d*x)**(S(21)/2)/(S(7)*d**S(11)) + S(2)*b**S(6)*(d*x)**(S(25)/2)/(S(25)*d**S(13)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3)/(d*x)**(S(3)/2), x), x, -S(2)*a**S(6)/(d*sqrt(d*x)) + S(4)*a**S(5)*b*(d*x)**(S(3)/2)/d**S(3) + S(30)*a**S(4)*b**S(2)*(d*x)**(S(7)/2)/(S(7)*d**S(5)) + S(40)*a**S(3)*b**S(3)*(d*x)**(S(11)/2)/(S(11)*d**S(7)) + S(2)*a**S(2)*b**S(4)*(d*x)**(S(15)/2)/d**S(9) + S(12)*a*b**S(5)*(d*x)**(S(19)/2)/(S(19)*d**S(11)) + S(2)*b**S(6)*(d*x)**(S(23)/2)/(S(23)*d**S(13)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3)/(d*x)**(S(5)/2), x), x, -S(2)*a**S(6)/(S(3)*d*(d*x)**(S(3)/2)) + S(12)*a**S(5)*b*sqrt(d*x)/d**S(3) + S(6)*a**S(4)*b**S(2)*(d*x)**(S(5)/2)/d**S(5) + S(40)*a**S(3)*b**S(3)*(d*x)**(S(9)/2)/(S(9)*d**S(7)) + S(30)*a**S(2)*b**S(4)*(d*x)**(S(13)/2)/(S(13)*d**S(9)) + S(12)*a*b**S(5)*(d*x)**(S(17)/2)/(S(17)*d**S(11)) + S(2)*b**S(6)*(d*x)**(S(21)/2)/(S(21)*d**S(13)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3)/(d*x)**(S(7)/2), x), x, -S(2)*a**S(6)/(S(5)*d*(d*x)**(S(5)/2)) - S(12)*a**S(5)*b/(d**S(3)*sqrt(d*x)) + S(10)*a**S(4)*b**S(2)*(d*x)**(S(3)/2)/d**S(5) + S(40)*a**S(3)*b**S(3)*(d*x)**(S(7)/2)/(S(7)*d**S(7)) + S(30)*a**S(2)*b**S(4)*(d*x)**(S(11)/2)/(S(11)*d**S(9)) + S(4)*a*b**S(5)*(d*x)**(S(15)/2)/(S(5)*d**S(11)) + S(2)*b**S(6)*(d*x)**(S(19)/2)/(S(19)*d**S(13)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**(S(11)/2)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4)), x), x, -S(9)*sqrt(S(2))*a**(S(5)/4)*d**(S(11)/2)*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(16)*b**(S(13)/4)) + S(9)*sqrt(S(2))*a**(S(5)/4)*d**(S(11)/2)*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(16)*b**(S(13)/4)) - S(9)*sqrt(S(2))*a**(S(5)/4)*d**(S(11)/2)*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(8)*b**(S(13)/4)) + S(9)*sqrt(S(2))*a**(S(5)/4)*d**(S(11)/2)*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(8)*b**(S(13)/4)) - S(9)*a*d**S(5)*sqrt(d*x)/(S(2)*b**S(3)) - d*(d*x)**(S(9)/2)/(S(2)*b*(a + b*x**S(2))) + S(9)*d**S(3)*(d*x)**(S(5)/2)/(S(10)*b**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**(S(9)/2)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4)), x), x, -S(7)*sqrt(S(2))*a**(S(3)/4)*d**(S(9)/2)*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(16)*b**(S(11)/4)) + S(7)*sqrt(S(2))*a**(S(3)/4)*d**(S(9)/2)*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(16)*b**(S(11)/4)) + S(7)*sqrt(S(2))*a**(S(3)/4)*d**(S(9)/2)*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(8)*b**(S(11)/4)) - S(7)*sqrt(S(2))*a**(S(3)/4)*d**(S(9)/2)*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(8)*b**(S(11)/4)) - d*(d*x)**(S(7)/2)/(S(2)*b*(a + b*x**S(2))) + S(7)*d**S(3)*(d*x)**(S(3)/2)/(S(6)*b**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**(S(7)/2)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4)), x), x, S(5)*sqrt(S(2))*a**(S(1)/4)*d**(S(7)/2)*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(16)*b**(S(9)/4)) - S(5)*sqrt(S(2))*a**(S(1)/4)*d**(S(7)/2)*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(16)*b**(S(9)/4)) + S(5)*sqrt(S(2))*a**(S(1)/4)*d**(S(7)/2)*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(8)*b**(S(9)/4)) - S(5)*sqrt(S(2))*a**(S(1)/4)*d**(S(7)/2)*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(8)*b**(S(9)/4)) - d*(d*x)**(S(5)/2)/(S(2)*b*(a + b*x**S(2))) + S(5)*d**S(3)*sqrt(d*x)/(S(2)*b**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**(S(5)/2)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4)), x), x, -d*(d*x)**(S(3)/2)/(S(2)*b*(a + b*x**S(2))) + S(3)*sqrt(S(2))*d**(S(5)/2)*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(16)*a**(S(1)/4)*b**(S(7)/4)) - S(3)*sqrt(S(2))*d**(S(5)/2)*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(16)*a**(S(1)/4)*b**(S(7)/4)) - S(3)*sqrt(S(2))*d**(S(5)/2)*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(8)*a**(S(1)/4)*b**(S(7)/4)) + S(3)*sqrt(S(2))*d**(S(5)/2)*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(8)*a**(S(1)/4)*b**(S(7)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**(S(3)/2)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4)), x), x, -d*sqrt(d*x)/(S(2)*b*(a + b*x**S(2))) - sqrt(S(2))*d**(S(3)/2)*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(16)*a**(S(3)/4)*b**(S(5)/4)) + sqrt(S(2))*d**(S(3)/2)*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(16)*a**(S(3)/4)*b**(S(5)/4)) - sqrt(S(2))*d**(S(3)/2)*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(8)*a**(S(3)/4)*b**(S(5)/4)) + sqrt(S(2))*d**(S(3)/2)*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(8)*a**(S(3)/4)*b**(S(5)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(d*x)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4)), x), x, (d*x)**(S(3)/2)/(S(2)*a*d*(a + b*x**S(2))) + sqrt(S(2))*sqrt(d)*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(16)*a**(S(5)/4)*b**(S(3)/4)) - sqrt(S(2))*sqrt(d)*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(16)*a**(S(5)/4)*b**(S(3)/4)) - sqrt(S(2))*sqrt(d)*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(8)*a**(S(5)/4)*b**(S(3)/4)) + sqrt(S(2))*sqrt(d)*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(8)*a**(S(5)/4)*b**(S(3)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(sqrt(d*x)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), x), x, sqrt(d*x)/(S(2)*a*d*(a + b*x**S(2))) - S(3)*sqrt(S(2))*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(16)*a**(S(7)/4)*b**(S(1)/4)*sqrt(d)) + S(3)*sqrt(S(2))*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(16)*a**(S(7)/4)*b**(S(1)/4)*sqrt(d)) - S(3)*sqrt(S(2))*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(8)*a**(S(7)/4)*b**(S(1)/4)*sqrt(d)) + S(3)*sqrt(S(2))*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(8)*a**(S(7)/4)*b**(S(1)/4)*sqrt(d)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((d*x)**(S(3)/2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), x), x, S(1)/(S(2)*a*d*sqrt(d*x)*(a + b*x**S(2))) - S(5)/(S(2)*a**S(2)*d*sqrt(d*x)) - S(5)*sqrt(S(2))*b**(S(1)/4)*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(16)*a**(S(9)/4)*d**(S(3)/2)) + S(5)*sqrt(S(2))*b**(S(1)/4)*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(16)*a**(S(9)/4)*d**(S(3)/2)) + S(5)*sqrt(S(2))*b**(S(1)/4)*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(8)*a**(S(9)/4)*d**(S(3)/2)) - S(5)*sqrt(S(2))*b**(S(1)/4)*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(8)*a**(S(9)/4)*d**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((d*x)**(S(5)/2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), x), x, S(1)/(S(2)*a*d*(d*x)**(S(3)/2)*(a + b*x**S(2))) - S(7)/(S(6)*a**S(2)*d*(d*x)**(S(3)/2)) + S(7)*sqrt(S(2))*b**(S(3)/4)*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(16)*a**(S(11)/4)*d**(S(5)/2)) - S(7)*sqrt(S(2))*b**(S(3)/4)*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(16)*a**(S(11)/4)*d**(S(5)/2)) + S(7)*sqrt(S(2))*b**(S(3)/4)*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(8)*a**(S(11)/4)*d**(S(5)/2)) - S(7)*sqrt(S(2))*b**(S(3)/4)*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(8)*a**(S(11)/4)*d**(S(5)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((d*x)**(S(7)/2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), x), x, S(1)/(S(2)*a*d*(d*x)**(S(5)/2)*(a + b*x**S(2))) - S(9)/(S(10)*a**S(2)*d*(d*x)**(S(5)/2)) + S(9)*b/(S(2)*a**S(3)*d**S(3)*sqrt(d*x)) + S(9)*sqrt(S(2))*b**(S(5)/4)*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(16)*a**(S(13)/4)*d**(S(7)/2)) - S(9)*sqrt(S(2))*b**(S(5)/4)*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(16)*a**(S(13)/4)*d**(S(7)/2)) - S(9)*sqrt(S(2))*b**(S(5)/4)*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(8)*a**(S(13)/4)*d**(S(7)/2)) + S(9)*sqrt(S(2))*b**(S(5)/4)*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(8)*a**(S(13)/4)*d**(S(7)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**(S(19)/2)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(2), x), x, -S(663)*sqrt(S(2))*a**(S(5)/4)*d**(S(19)/2)*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(512)*b**(S(21)/4)) + S(663)*sqrt(S(2))*a**(S(5)/4)*d**(S(19)/2)*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(512)*b**(S(21)/4)) - S(663)*sqrt(S(2))*a**(S(5)/4)*d**(S(19)/2)*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(256)*b**(S(21)/4)) + S(663)*sqrt(S(2))*a**(S(5)/4)*d**(S(19)/2)*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(256)*b**(S(21)/4)) - S(663)*a*d**S(9)*sqrt(d*x)/(S(64)*b**S(5)) - d*(d*x)**(S(17)/2)/(S(6)*b*(a + b*x**S(2))**S(3)) - S(17)*d**S(3)*(d*x)**(S(13)/2)/(S(48)*b**S(2)*(a + b*x**S(2))**S(2)) - S(221)*d**S(5)*(d*x)**(S(9)/2)/(S(192)*b**S(3)*(a + b*x**S(2))) + S(663)*d**S(7)*(d*x)**(S(5)/2)/(S(320)*b**S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**(S(17)/2)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(2), x), x, -S(385)*sqrt(S(2))*a**(S(3)/4)*d**(S(17)/2)*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(512)*b**(S(19)/4)) + S(385)*sqrt(S(2))*a**(S(3)/4)*d**(S(17)/2)*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(512)*b**(S(19)/4)) + S(385)*sqrt(S(2))*a**(S(3)/4)*d**(S(17)/2)*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(256)*b**(S(19)/4)) - S(385)*sqrt(S(2))*a**(S(3)/4)*d**(S(17)/2)*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(256)*b**(S(19)/4)) - d*(d*x)**(S(15)/2)/(S(6)*b*(a + b*x**S(2))**S(3)) - S(5)*d**S(3)*(d*x)**(S(11)/2)/(S(16)*b**S(2)*(a + b*x**S(2))**S(2)) - S(55)*d**S(5)*(d*x)**(S(7)/2)/(S(64)*b**S(3)*(a + b*x**S(2))) + S(385)*d**S(7)*(d*x)**(S(3)/2)/(S(192)*b**S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**(S(15)/2)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(2), x), x, S(195)*sqrt(S(2))*a**(S(1)/4)*d**(S(15)/2)*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(512)*b**(S(17)/4)) - S(195)*sqrt(S(2))*a**(S(1)/4)*d**(S(15)/2)*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(512)*b**(S(17)/4)) + S(195)*sqrt(S(2))*a**(S(1)/4)*d**(S(15)/2)*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(256)*b**(S(17)/4)) - S(195)*sqrt(S(2))*a**(S(1)/4)*d**(S(15)/2)*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(256)*b**(S(17)/4)) - d*(d*x)**(S(13)/2)/(S(6)*b*(a + b*x**S(2))**S(3)) - S(13)*d**S(3)*(d*x)**(S(9)/2)/(S(48)*b**S(2)*(a + b*x**S(2))**S(2)) - S(39)*d**S(5)*(d*x)**(S(5)/2)/(S(64)*b**S(3)*(a + b*x**S(2))) + S(195)*d**S(7)*sqrt(d*x)/(S(64)*b**S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**(S(13)/2)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(2), x), x, -d*(d*x)**(S(11)/2)/(S(6)*b*(a + b*x**S(2))**S(3)) - S(11)*d**S(3)*(d*x)**(S(7)/2)/(S(48)*b**S(2)*(a + b*x**S(2))**S(2)) - S(77)*d**S(5)*(d*x)**(S(3)/2)/(S(192)*b**S(3)*(a + b*x**S(2))) + S(77)*sqrt(S(2))*d**(S(13)/2)*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(512)*a**(S(1)/4)*b**(S(15)/4)) - S(77)*sqrt(S(2))*d**(S(13)/2)*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(512)*a**(S(1)/4)*b**(S(15)/4)) - S(77)*sqrt(S(2))*d**(S(13)/2)*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(256)*a**(S(1)/4)*b**(S(15)/4)) + S(77)*sqrt(S(2))*d**(S(13)/2)*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(256)*a**(S(1)/4)*b**(S(15)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**(S(11)/2)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(2), x), x, -d*(d*x)**(S(9)/2)/(S(6)*b*(a + b*x**S(2))**S(3)) - S(3)*d**S(3)*(d*x)**(S(5)/2)/(S(16)*b**S(2)*(a + b*x**S(2))**S(2)) - S(15)*d**S(5)*sqrt(d*x)/(S(64)*b**S(3)*(a + b*x**S(2))) - S(15)*sqrt(S(2))*d**(S(11)/2)*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(512)*a**(S(3)/4)*b**(S(13)/4)) + S(15)*sqrt(S(2))*d**(S(11)/2)*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(512)*a**(S(3)/4)*b**(S(13)/4)) - S(15)*sqrt(S(2))*d**(S(11)/2)*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(256)*a**(S(3)/4)*b**(S(13)/4)) + S(15)*sqrt(S(2))*d**(S(11)/2)*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(256)*a**(S(3)/4)*b**(S(13)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**(S(9)/2)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(2), x), x, -d*(d*x)**(S(7)/2)/(S(6)*b*(a + b*x**S(2))**S(3)) - S(7)*d**S(3)*(d*x)**(S(3)/2)/(S(48)*b**S(2)*(a + b*x**S(2))**S(2)) + S(7)*d**S(3)*(d*x)**(S(3)/2)/(S(64)*a*b**S(2)*(a + b*x**S(2))) + S(7)*sqrt(S(2))*d**(S(9)/2)*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(512)*a**(S(5)/4)*b**(S(11)/4)) - S(7)*sqrt(S(2))*d**(S(9)/2)*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(512)*a**(S(5)/4)*b**(S(11)/4)) - S(7)*sqrt(S(2))*d**(S(9)/2)*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(256)*a**(S(5)/4)*b**(S(11)/4)) + S(7)*sqrt(S(2))*d**(S(9)/2)*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(256)*a**(S(5)/4)*b**(S(11)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**(S(7)/2)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(2), x), x, -d*(d*x)**(S(5)/2)/(S(6)*b*(a + b*x**S(2))**S(3)) - S(5)*d**S(3)*sqrt(d*x)/(S(48)*b**S(2)*(a + b*x**S(2))**S(2)) + S(5)*d**S(3)*sqrt(d*x)/(S(192)*a*b**S(2)*(a + b*x**S(2))) - S(5)*sqrt(S(2))*d**(S(7)/2)*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(512)*a**(S(7)/4)*b**(S(9)/4)) + S(5)*sqrt(S(2))*d**(S(7)/2)*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(512)*a**(S(7)/4)*b**(S(9)/4)) - S(5)*sqrt(S(2))*d**(S(7)/2)*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(256)*a**(S(7)/4)*b**(S(9)/4)) + S(5)*sqrt(S(2))*d**(S(7)/2)*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(256)*a**(S(7)/4)*b**(S(9)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**(S(5)/2)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(2), x), x, -d*(d*x)**(S(3)/2)/(S(6)*b*(a + b*x**S(2))**S(3)) + d*(d*x)**(S(3)/2)/(S(16)*a*b*(a + b*x**S(2))**S(2)) + S(5)*d*(d*x)**(S(3)/2)/(S(64)*a**S(2)*b*(a + b*x**S(2))) + S(5)*sqrt(S(2))*d**(S(5)/2)*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(512)*a**(S(9)/4)*b**(S(7)/4)) - S(5)*sqrt(S(2))*d**(S(5)/2)*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(512)*a**(S(9)/4)*b**(S(7)/4)) - S(5)*sqrt(S(2))*d**(S(5)/2)*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(256)*a**(S(9)/4)*b**(S(7)/4)) + S(5)*sqrt(S(2))*d**(S(5)/2)*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(256)*a**(S(9)/4)*b**(S(7)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**(S(3)/2)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(2), x), x, -d*sqrt(d*x)/(S(6)*b*(a + b*x**S(2))**S(3)) + d*sqrt(d*x)/(S(48)*a*b*(a + b*x**S(2))**S(2)) + S(7)*d*sqrt(d*x)/(S(192)*a**S(2)*b*(a + b*x**S(2))) - S(7)*sqrt(S(2))*d**(S(3)/2)*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(512)*a**(S(11)/4)*b**(S(5)/4)) + S(7)*sqrt(S(2))*d**(S(3)/2)*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(512)*a**(S(11)/4)*b**(S(5)/4)) - S(7)*sqrt(S(2))*d**(S(3)/2)*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(256)*a**(S(11)/4)*b**(S(5)/4)) + S(7)*sqrt(S(2))*d**(S(3)/2)*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(256)*a**(S(11)/4)*b**(S(5)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(d*x)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(2), x), x, (d*x)**(S(3)/2)/(S(6)*a*d*(a + b*x**S(2))**S(3)) + S(3)*(d*x)**(S(3)/2)/(S(16)*a**S(2)*d*(a + b*x**S(2))**S(2)) + S(15)*(d*x)**(S(3)/2)/(S(64)*a**S(3)*d*(a + b*x**S(2))) + S(15)*sqrt(S(2))*sqrt(d)*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(512)*a**(S(13)/4)*b**(S(3)/4)) - S(15)*sqrt(S(2))*sqrt(d)*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(512)*a**(S(13)/4)*b**(S(3)/4)) - S(15)*sqrt(S(2))*sqrt(d)*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(256)*a**(S(13)/4)*b**(S(3)/4)) + S(15)*sqrt(S(2))*sqrt(d)*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(256)*a**(S(13)/4)*b**(S(3)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(sqrt(d*x)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(2)), x), x, sqrt(d*x)/(S(6)*a*d*(a + b*x**S(2))**S(3)) + S(11)*sqrt(d*x)/(S(48)*a**S(2)*d*(a + b*x**S(2))**S(2)) + S(77)*sqrt(d*x)/(S(192)*a**S(3)*d*(a + b*x**S(2))) - S(77)*sqrt(S(2))*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(512)*a**(S(15)/4)*b**(S(1)/4)*sqrt(d)) + S(77)*sqrt(S(2))*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(512)*a**(S(15)/4)*b**(S(1)/4)*sqrt(d)) - S(77)*sqrt(S(2))*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(256)*a**(S(15)/4)*b**(S(1)/4)*sqrt(d)) + S(77)*sqrt(S(2))*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(256)*a**(S(15)/4)*b**(S(1)/4)*sqrt(d)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((d*x)**(S(3)/2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(2)), x), x, S(1)/(S(6)*a*d*sqrt(d*x)*(a + b*x**S(2))**S(3)) + S(13)/(S(48)*a**S(2)*d*sqrt(d*x)*(a + b*x**S(2))**S(2)) + S(39)/(S(64)*a**S(3)*d*sqrt(d*x)*(a + b*x**S(2))) - S(195)/(S(64)*a**S(4)*d*sqrt(d*x)) - S(195)*sqrt(S(2))*b**(S(1)/4)*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(512)*a**(S(17)/4)*d**(S(3)/2)) + S(195)*sqrt(S(2))*b**(S(1)/4)*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(512)*a**(S(17)/4)*d**(S(3)/2)) + S(195)*sqrt(S(2))*b**(S(1)/4)*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(256)*a**(S(17)/4)*d**(S(3)/2)) - S(195)*sqrt(S(2))*b**(S(1)/4)*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(256)*a**(S(17)/4)*d**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((d*x)**(S(5)/2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(2)), x), x, S(1)/(S(6)*a*d*(d*x)**(S(3)/2)*(a + b*x**S(2))**S(3)) + S(5)/(S(16)*a**S(2)*d*(d*x)**(S(3)/2)*(a + b*x**S(2))**S(2)) + S(55)/(S(64)*a**S(3)*d*(d*x)**(S(3)/2)*(a + b*x**S(2))) - S(385)/(S(192)*a**S(4)*d*(d*x)**(S(3)/2)) + S(385)*sqrt(S(2))*b**(S(3)/4)*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(512)*a**(S(19)/4)*d**(S(5)/2)) - S(385)*sqrt(S(2))*b**(S(3)/4)*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(512)*a**(S(19)/4)*d**(S(5)/2)) + S(385)*sqrt(S(2))*b**(S(3)/4)*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(256)*a**(S(19)/4)*d**(S(5)/2)) - S(385)*sqrt(S(2))*b**(S(3)/4)*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(256)*a**(S(19)/4)*d**(S(5)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((d*x)**(S(7)/2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(2)), x), x, S(1)/(S(6)*a*d*(d*x)**(S(5)/2)*(a + b*x**S(2))**S(3)) + S(17)/(S(48)*a**S(2)*d*(d*x)**(S(5)/2)*(a + b*x**S(2))**S(2)) + S(221)/(S(192)*a**S(3)*d*(d*x)**(S(5)/2)*(a + b*x**S(2))) - S(663)/(S(320)*a**S(4)*d*(d*x)**(S(5)/2)) + S(663)*b/(S(64)*a**S(5)*d**S(3)*sqrt(d*x)) + S(663)*sqrt(S(2))*b**(S(5)/4)*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(512)*a**(S(21)/4)*d**(S(7)/2)) - S(663)*sqrt(S(2))*b**(S(5)/4)*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(512)*a**(S(21)/4)*d**(S(7)/2)) - S(663)*sqrt(S(2))*b**(S(5)/4)*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(256)*a**(S(21)/4)*d**(S(7)/2)) + S(663)*sqrt(S(2))*b**(S(5)/4)*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(256)*a**(S(21)/4)*d**(S(7)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**(S(27)/2)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3), x), x, -S(69615)*sqrt(S(2))*a**(S(5)/4)*d**(S(27)/2)*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(32768)*b**(S(29)/4)) + S(69615)*sqrt(S(2))*a**(S(5)/4)*d**(S(27)/2)*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(32768)*b**(S(29)/4)) - S(69615)*sqrt(S(2))*a**(S(5)/4)*d**(S(27)/2)*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(16384)*b**(S(29)/4)) + S(69615)*sqrt(S(2))*a**(S(5)/4)*d**(S(27)/2)*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(16384)*b**(S(29)/4)) - S(69615)*a*d**S(13)*sqrt(d*x)/(S(4096)*b**S(7)) - d*(d*x)**(S(25)/2)/(S(10)*b*(a + b*x**S(2))**S(5)) - S(5)*d**S(3)*(d*x)**(S(21)/2)/(S(32)*b**S(2)*(a + b*x**S(2))**S(4)) - S(35)*d**S(5)*(d*x)**(S(17)/2)/(S(128)*b**S(3)*(a + b*x**S(2))**S(3)) - S(595)*d**S(7)*(d*x)**(S(13)/2)/(S(1024)*b**S(4)*(a + b*x**S(2))**S(2)) - S(7735)*d**S(9)*(d*x)**(S(9)/2)/(S(4096)*b**S(5)*(a + b*x**S(2))) + S(13923)*d**S(11)*(d*x)**(S(5)/2)/(S(4096)*b**S(6)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**(S(25)/2)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3), x), x, -S(33649)*sqrt(S(2))*a**(S(3)/4)*d**(S(25)/2)*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(32768)*b**(S(27)/4)) + S(33649)*sqrt(S(2))*a**(S(3)/4)*d**(S(25)/2)*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(32768)*b**(S(27)/4)) + S(33649)*sqrt(S(2))*a**(S(3)/4)*d**(S(25)/2)*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(16384)*b**(S(27)/4)) - S(33649)*sqrt(S(2))*a**(S(3)/4)*d**(S(25)/2)*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(16384)*b**(S(27)/4)) - d*(d*x)**(S(23)/2)/(S(10)*b*(a + b*x**S(2))**S(5)) - S(23)*d**S(3)*(d*x)**(S(19)/2)/(S(160)*b**S(2)*(a + b*x**S(2))**S(4)) - S(437)*d**S(5)*(d*x)**(S(15)/2)/(S(1920)*b**S(3)*(a + b*x**S(2))**S(3)) - S(437)*d**S(7)*(d*x)**(S(11)/2)/(S(1024)*b**S(4)*(a + b*x**S(2))**S(2)) - S(4807)*d**S(9)*(d*x)**(S(7)/2)/(S(4096)*b**S(5)*(a + b*x**S(2))) + S(33649)*d**S(11)*(d*x)**(S(3)/2)/(S(12288)*b**S(6)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**(S(23)/2)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3), x), x, S(13923)*sqrt(S(2))*a**(S(1)/4)*d**(S(23)/2)*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(32768)*b**(S(25)/4)) - S(13923)*sqrt(S(2))*a**(S(1)/4)*d**(S(23)/2)*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(32768)*b**(S(25)/4)) + S(13923)*sqrt(S(2))*a**(S(1)/4)*d**(S(23)/2)*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(16384)*b**(S(25)/4)) - S(13923)*sqrt(S(2))*a**(S(1)/4)*d**(S(23)/2)*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(16384)*b**(S(25)/4)) - d*(d*x)**(S(21)/2)/(S(10)*b*(a + b*x**S(2))**S(5)) - S(21)*d**S(3)*(d*x)**(S(17)/2)/(S(160)*b**S(2)*(a + b*x**S(2))**S(4)) - S(119)*d**S(5)*(d*x)**(S(13)/2)/(S(640)*b**S(3)*(a + b*x**S(2))**S(3)) - S(1547)*d**S(7)*(d*x)**(S(9)/2)/(S(5120)*b**S(4)*(a + b*x**S(2))**S(2)) - S(13923)*d**S(9)*(d*x)**(S(5)/2)/(S(20480)*b**S(5)*(a + b*x**S(2))) + S(13923)*d**S(11)*sqrt(d*x)/(S(4096)*b**S(6)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**(S(21)/2)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3), x), x, -d*(d*x)**(S(19)/2)/(S(10)*b*(a + b*x**S(2))**S(5)) - S(19)*d**S(3)*(d*x)**(S(15)/2)/(S(160)*b**S(2)*(a + b*x**S(2))**S(4)) - S(19)*d**S(5)*(d*x)**(S(11)/2)/(S(128)*b**S(3)*(a + b*x**S(2))**S(3)) - S(209)*d**S(7)*(d*x)**(S(7)/2)/(S(1024)*b**S(4)*(a + b*x**S(2))**S(2)) - S(1463)*d**S(9)*(d*x)**(S(3)/2)/(S(4096)*b**S(5)*(a + b*x**S(2))) + S(4389)*sqrt(S(2))*d**(S(21)/2)*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(32768)*a**(S(1)/4)*b**(S(23)/4)) - S(4389)*sqrt(S(2))*d**(S(21)/2)*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(32768)*a**(S(1)/4)*b**(S(23)/4)) - S(4389)*sqrt(S(2))*d**(S(21)/2)*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(16384)*a**(S(1)/4)*b**(S(23)/4)) + S(4389)*sqrt(S(2))*d**(S(21)/2)*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(16384)*a**(S(1)/4)*b**(S(23)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**(S(19)/2)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3), x), x, -d*(d*x)**(S(17)/2)/(S(10)*b*(a + b*x**S(2))**S(5)) - S(17)*d**S(3)*(d*x)**(S(13)/2)/(S(160)*b**S(2)*(a + b*x**S(2))**S(4)) - S(221)*d**S(5)*(d*x)**(S(9)/2)/(S(1920)*b**S(3)*(a + b*x**S(2))**S(3)) - S(663)*d**S(7)*(d*x)**(S(5)/2)/(S(5120)*b**S(4)*(a + b*x**S(2))**S(2)) - S(663)*d**S(9)*sqrt(d*x)/(S(4096)*b**S(5)*(a + b*x**S(2))) - S(663)*sqrt(S(2))*d**(S(19)/2)*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(32768)*a**(S(3)/4)*b**(S(21)/4)) + S(663)*sqrt(S(2))*d**(S(19)/2)*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(32768)*a**(S(3)/4)*b**(S(21)/4)) - S(663)*sqrt(S(2))*d**(S(19)/2)*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(16384)*a**(S(3)/4)*b**(S(21)/4)) + S(663)*sqrt(S(2))*d**(S(19)/2)*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(16384)*a**(S(3)/4)*b**(S(21)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**(S(17)/2)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3), x), x, -d*(d*x)**(S(15)/2)/(S(10)*b*(a + b*x**S(2))**S(5)) - S(3)*d**S(3)*(d*x)**(S(11)/2)/(S(32)*b**S(2)*(a + b*x**S(2))**S(4)) - S(11)*d**S(5)*(d*x)**(S(7)/2)/(S(128)*b**S(3)*(a + b*x**S(2))**S(3)) - S(77)*d**S(7)*(d*x)**(S(3)/2)/(S(1024)*b**S(4)*(a + b*x**S(2))**S(2)) + S(231)*d**S(7)*(d*x)**(S(3)/2)/(S(4096)*a*b**S(4)*(a + b*x**S(2))) + S(231)*sqrt(S(2))*d**(S(17)/2)*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(32768)*a**(S(5)/4)*b**(S(19)/4)) - S(231)*sqrt(S(2))*d**(S(17)/2)*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(32768)*a**(S(5)/4)*b**(S(19)/4)) - S(231)*sqrt(S(2))*d**(S(17)/2)*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(16384)*a**(S(5)/4)*b**(S(19)/4)) + S(231)*sqrt(S(2))*d**(S(17)/2)*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(16384)*a**(S(5)/4)*b**(S(19)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**(S(15)/2)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3), x), x, -d*(d*x)**(S(13)/2)/(S(10)*b*(a + b*x**S(2))**S(5)) - S(13)*d**S(3)*(d*x)**(S(9)/2)/(S(160)*b**S(2)*(a + b*x**S(2))**S(4)) - S(39)*d**S(5)*(d*x)**(S(5)/2)/(S(640)*b**S(3)*(a + b*x**S(2))**S(3)) - S(39)*d**S(7)*sqrt(d*x)/(S(1024)*b**S(4)*(a + b*x**S(2))**S(2)) + S(39)*d**S(7)*sqrt(d*x)/(S(4096)*a*b**S(4)*(a + b*x**S(2))) - S(117)*sqrt(S(2))*d**(S(15)/2)*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(32768)*a**(S(7)/4)*b**(S(17)/4)) + S(117)*sqrt(S(2))*d**(S(15)/2)*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(32768)*a**(S(7)/4)*b**(S(17)/4)) - S(117)*sqrt(S(2))*d**(S(15)/2)*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(16384)*a**(S(7)/4)*b**(S(17)/4)) + S(117)*sqrt(S(2))*d**(S(15)/2)*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(16384)*a**(S(7)/4)*b**(S(17)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**(S(13)/2)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3), x), x, -d*(d*x)**(S(11)/2)/(S(10)*b*(a + b*x**S(2))**S(5)) - S(11)*d**S(3)*(d*x)**(S(7)/2)/(S(160)*b**S(2)*(a + b*x**S(2))**S(4)) - S(77)*d**S(5)*(d*x)**(S(3)/2)/(S(1920)*b**S(3)*(a + b*x**S(2))**S(3)) + S(77)*d**S(5)*(d*x)**(S(3)/2)/(S(5120)*a*b**S(3)*(a + b*x**S(2))**S(2)) + S(77)*d**S(5)*(d*x)**(S(3)/2)/(S(4096)*a**S(2)*b**S(3)*(a + b*x**S(2))) + S(77)*sqrt(S(2))*d**(S(13)/2)*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(32768)*a**(S(9)/4)*b**(S(15)/4)) - S(77)*sqrt(S(2))*d**(S(13)/2)*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(32768)*a**(S(9)/4)*b**(S(15)/4)) - S(77)*sqrt(S(2))*d**(S(13)/2)*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(16384)*a**(S(9)/4)*b**(S(15)/4)) + S(77)*sqrt(S(2))*d**(S(13)/2)*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(16384)*a**(S(9)/4)*b**(S(15)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**(S(11)/2)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3), x), x, -d*(d*x)**(S(9)/2)/(S(10)*b*(a + b*x**S(2))**S(5)) - S(9)*d**S(3)*(d*x)**(S(5)/2)/(S(160)*b**S(2)*(a + b*x**S(2))**S(4)) - S(3)*d**S(5)*sqrt(d*x)/(S(128)*b**S(3)*(a + b*x**S(2))**S(3)) + S(3)*d**S(5)*sqrt(d*x)/(S(1024)*a*b**S(3)*(a + b*x**S(2))**S(2)) + S(21)*d**S(5)*sqrt(d*x)/(S(4096)*a**S(2)*b**S(3)*(a + b*x**S(2))) - S(63)*sqrt(S(2))*d**(S(11)/2)*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(32768)*a**(S(11)/4)*b**(S(13)/4)) + S(63)*sqrt(S(2))*d**(S(11)/2)*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(32768)*a**(S(11)/4)*b**(S(13)/4)) - S(63)*sqrt(S(2))*d**(S(11)/2)*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(16384)*a**(S(11)/4)*b**(S(13)/4)) + S(63)*sqrt(S(2))*d**(S(11)/2)*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(16384)*a**(S(11)/4)*b**(S(13)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**(S(9)/2)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3), x), x, -d*(d*x)**(S(7)/2)/(S(10)*b*(a + b*x**S(2))**S(5)) - S(7)*d**S(3)*(d*x)**(S(3)/2)/(S(160)*b**S(2)*(a + b*x**S(2))**S(4)) + S(7)*d**S(3)*(d*x)**(S(3)/2)/(S(640)*a*b**S(2)*(a + b*x**S(2))**S(3)) + S(63)*d**S(3)*(d*x)**(S(3)/2)/(S(5120)*a**S(2)*b**S(2)*(a + b*x**S(2))**S(2)) + S(63)*d**S(3)*(d*x)**(S(3)/2)/(S(4096)*a**S(3)*b**S(2)*(a + b*x**S(2))) + S(63)*sqrt(S(2))*d**(S(9)/2)*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(32768)*a**(S(13)/4)*b**(S(11)/4)) - S(63)*sqrt(S(2))*d**(S(9)/2)*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(32768)*a**(S(13)/4)*b**(S(11)/4)) - S(63)*sqrt(S(2))*d**(S(9)/2)*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(16384)*a**(S(13)/4)*b**(S(11)/4)) + S(63)*sqrt(S(2))*d**(S(9)/2)*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(16384)*a**(S(13)/4)*b**(S(11)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**(S(7)/2)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3), x), x, -d*(d*x)**(S(5)/2)/(S(10)*b*(a + b*x**S(2))**S(5)) - d**S(3)*sqrt(d*x)/(S(32)*b**S(2)*(a + b*x**S(2))**S(4)) + d**S(3)*sqrt(d*x)/(S(384)*a*b**S(2)*(a + b*x**S(2))**S(3)) + S(11)*d**S(3)*sqrt(d*x)/(S(3072)*a**S(2)*b**S(2)*(a + b*x**S(2))**S(2)) + S(77)*d**S(3)*sqrt(d*x)/(S(12288)*a**S(3)*b**S(2)*(a + b*x**S(2))) - S(77)*sqrt(S(2))*d**(S(7)/2)*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(32768)*a**(S(15)/4)*b**(S(9)/4)) + S(77)*sqrt(S(2))*d**(S(7)/2)*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(32768)*a**(S(15)/4)*b**(S(9)/4)) - S(77)*sqrt(S(2))*d**(S(7)/2)*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(16384)*a**(S(15)/4)*b**(S(9)/4)) + S(77)*sqrt(S(2))*d**(S(7)/2)*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(16384)*a**(S(15)/4)*b**(S(9)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**(S(5)/2)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3), x), x, -d*(d*x)**(S(3)/2)/(S(10)*b*(a + b*x**S(2))**S(5)) + S(3)*d*(d*x)**(S(3)/2)/(S(160)*a*b*(a + b*x**S(2))**S(4)) + S(13)*d*(d*x)**(S(3)/2)/(S(640)*a**S(2)*b*(a + b*x**S(2))**S(3)) + S(117)*d*(d*x)**(S(3)/2)/(S(5120)*a**S(3)*b*(a + b*x**S(2))**S(2)) + S(117)*d*(d*x)**(S(3)/2)/(S(4096)*a**S(4)*b*(a + b*x**S(2))) + S(117)*sqrt(S(2))*d**(S(5)/2)*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(32768)*a**(S(17)/4)*b**(S(7)/4)) - S(117)*sqrt(S(2))*d**(S(5)/2)*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(32768)*a**(S(17)/4)*b**(S(7)/4)) - S(117)*sqrt(S(2))*d**(S(5)/2)*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(16384)*a**(S(17)/4)*b**(S(7)/4)) + S(117)*sqrt(S(2))*d**(S(5)/2)*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(16384)*a**(S(17)/4)*b**(S(7)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**(S(3)/2)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3), x), x, -d*sqrt(d*x)/(S(10)*b*(a + b*x**S(2))**S(5)) + d*sqrt(d*x)/(S(160)*a*b*(a + b*x**S(2))**S(4)) + d*sqrt(d*x)/(S(128)*a**S(2)*b*(a + b*x**S(2))**S(3)) + S(11)*d*sqrt(d*x)/(S(1024)*a**S(3)*b*(a + b*x**S(2))**S(2)) + S(77)*d*sqrt(d*x)/(S(4096)*a**S(4)*b*(a + b*x**S(2))) - S(231)*sqrt(S(2))*d**(S(3)/2)*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(32768)*a**(S(19)/4)*b**(S(5)/4)) + S(231)*sqrt(S(2))*d**(S(3)/2)*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(32768)*a**(S(19)/4)*b**(S(5)/4)) - S(231)*sqrt(S(2))*d**(S(3)/2)*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(16384)*a**(S(19)/4)*b**(S(5)/4)) + S(231)*sqrt(S(2))*d**(S(3)/2)*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(16384)*a**(S(19)/4)*b**(S(5)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(d*x)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3), x), x, (d*x)**(S(3)/2)/(S(10)*a*d*(a + b*x**S(2))**S(5)) + S(17)*(d*x)**(S(3)/2)/(S(160)*a**S(2)*d*(a + b*x**S(2))**S(4)) + S(221)*(d*x)**(S(3)/2)/(S(1920)*a**S(3)*d*(a + b*x**S(2))**S(3)) + S(663)*(d*x)**(S(3)/2)/(S(5120)*a**S(4)*d*(a + b*x**S(2))**S(2)) + S(663)*(d*x)**(S(3)/2)/(S(4096)*a**S(5)*d*(a + b*x**S(2))) + S(663)*sqrt(S(2))*sqrt(d)*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(32768)*a**(S(21)/4)*b**(S(3)/4)) - S(663)*sqrt(S(2))*sqrt(d)*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(32768)*a**(S(21)/4)*b**(S(3)/4)) - S(663)*sqrt(S(2))*sqrt(d)*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(16384)*a**(S(21)/4)*b**(S(3)/4)) + S(663)*sqrt(S(2))*sqrt(d)*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(16384)*a**(S(21)/4)*b**(S(3)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(sqrt(d*x)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3)), x), x, sqrt(d*x)/(S(10)*a*d*(a + b*x**S(2))**S(5)) + S(19)*sqrt(d*x)/(S(160)*a**S(2)*d*(a + b*x**S(2))**S(4)) + S(19)*sqrt(d*x)/(S(128)*a**S(3)*d*(a + b*x**S(2))**S(3)) + S(209)*sqrt(d*x)/(S(1024)*a**S(4)*d*(a + b*x**S(2))**S(2)) + S(1463)*sqrt(d*x)/(S(4096)*a**S(5)*d*(a + b*x**S(2))) - S(4389)*sqrt(S(2))*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(32768)*a**(S(23)/4)*b**(S(1)/4)*sqrt(d)) + S(4389)*sqrt(S(2))*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(32768)*a**(S(23)/4)*b**(S(1)/4)*sqrt(d)) - S(4389)*sqrt(S(2))*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(16384)*a**(S(23)/4)*b**(S(1)/4)*sqrt(d)) + S(4389)*sqrt(S(2))*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(16384)*a**(S(23)/4)*b**(S(1)/4)*sqrt(d)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((d*x)**(S(3)/2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3)), x), x, S(1)/(S(10)*a*d*sqrt(d*x)*(a + b*x**S(2))**S(5)) + S(21)/(S(160)*a**S(2)*d*sqrt(d*x)*(a + b*x**S(2))**S(4)) + S(119)/(S(640)*a**S(3)*d*sqrt(d*x)*(a + b*x**S(2))**S(3)) + S(1547)/(S(5120)*a**S(4)*d*sqrt(d*x)*(a + b*x**S(2))**S(2)) + S(13923)/(S(20480)*a**S(5)*d*sqrt(d*x)*(a + b*x**S(2))) - S(13923)/(S(4096)*a**S(6)*d*sqrt(d*x)) - S(13923)*sqrt(S(2))*b**(S(1)/4)*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(32768)*a**(S(25)/4)*d**(S(3)/2)) + S(13923)*sqrt(S(2))*b**(S(1)/4)*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(32768)*a**(S(25)/4)*d**(S(3)/2)) + S(13923)*sqrt(S(2))*b**(S(1)/4)*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(16384)*a**(S(25)/4)*d**(S(3)/2)) - S(13923)*sqrt(S(2))*b**(S(1)/4)*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(16384)*a**(S(25)/4)*d**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((d*x)**(S(5)/2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3)), x), x, S(1)/(S(10)*a*d*(d*x)**(S(3)/2)*(a + b*x**S(2))**S(5)) + S(23)/(S(160)*a**S(2)*d*(d*x)**(S(3)/2)*(a + b*x**S(2))**S(4)) + S(437)/(S(1920)*a**S(3)*d*(d*x)**(S(3)/2)*(a + b*x**S(2))**S(3)) + S(437)/(S(1024)*a**S(4)*d*(d*x)**(S(3)/2)*(a + b*x**S(2))**S(2)) + S(4807)/(S(4096)*a**S(5)*d*(d*x)**(S(3)/2)*(a + b*x**S(2))) - S(33649)/(S(12288)*a**S(6)*d*(d*x)**(S(3)/2)) + S(33649)*sqrt(S(2))*b**(S(3)/4)*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(32768)*a**(S(27)/4)*d**(S(5)/2)) - S(33649)*sqrt(S(2))*b**(S(3)/4)*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(32768)*a**(S(27)/4)*d**(S(5)/2)) + S(33649)*sqrt(S(2))*b**(S(3)/4)*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(16384)*a**(S(27)/4)*d**(S(5)/2)) - S(33649)*sqrt(S(2))*b**(S(3)/4)*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(16384)*a**(S(27)/4)*d**(S(5)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((d*x)**(S(7)/2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**S(3)), x), x, S(1)/(S(10)*a*d*(d*x)**(S(5)/2)*(a + b*x**S(2))**S(5)) + S(5)/(S(32)*a**S(2)*d*(d*x)**(S(5)/2)*(a + b*x**S(2))**S(4)) + S(35)/(S(128)*a**S(3)*d*(d*x)**(S(5)/2)*(a + b*x**S(2))**S(3)) + S(595)/(S(1024)*a**S(4)*d*(d*x)**(S(5)/2)*(a + b*x**S(2))**S(2)) + S(7735)/(S(4096)*a**S(5)*d*(d*x)**(S(5)/2)*(a + b*x**S(2))) - S(13923)/(S(4096)*a**S(6)*d*(d*x)**(S(5)/2)) + S(69615)*b/(S(4096)*a**S(7)*d**S(3)*sqrt(d*x)) + S(69615)*sqrt(S(2))*b**(S(5)/4)*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(32768)*a**(S(29)/4)*d**(S(7)/2)) - S(69615)*sqrt(S(2))*b**(S(5)/4)*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(32768)*a**(S(29)/4)*d**(S(7)/2)) - S(69615)*sqrt(S(2))*b**(S(5)/4)*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(16384)*a**(S(29)/4)*d**(S(7)/2)) + S(69615)*sqrt(S(2))*b**(S(5)/4)*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(16384)*a**(S(29)/4)*d**(S(7)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**(S(5)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4)), x), x, S(8)*a*(d*x)**(S(7)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(77)*d*(a + b*x**S(2))) + S(2)*(d*x)**(S(7)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(11)*d), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**(S(3)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4)), x), x, S(8)*a*(d*x)**(S(5)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(45)*d*(a + b*x**S(2))) + S(2)*(d*x)**(S(5)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(9)*d), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(d*x)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4)), x), x, S(8)*a*(d*x)**(S(3)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(21)*d*(a + b*x**S(2))) + S(2)*(d*x)**(S(3)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(7)*d), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/sqrt(d*x), x), x, S(8)*a*sqrt(d*x)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(5)*d*(a + b*x**S(2))) + S(2)*sqrt(d*x)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(5)*d), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(d*x)**(S(3)/2), x), x, -S(8)*a*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(3)*d*sqrt(d*x)*(a + b*x**S(2))) + S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(3)*d*sqrt(d*x)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(d*x)**(S(5)/2), x), x, -S(8)*a*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(3)*d*(d*x)**(S(3)/2)*(a + b*x**S(2))) + S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(d*(d*x)**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(d*x)**(S(7)/2), x), x, S(8)*a*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(5)*d*(d*x)**(S(5)/2)*(a + b*x**S(2))) - S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(d*(d*x)**(S(5)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**(S(5)/2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2), x), x, S(256)*a**S(3)*(d*x)**(S(7)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(7315)*d*(a + b*x**S(2))) + S(64)*a**S(2)*(d*x)**(S(7)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(1045)*d) + S(8)*a*(d*x)**(S(7)/2)*(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(95)*d) + S(2)*(d*x)**(S(7)/2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(19)*d), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**(S(3)/2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2), x), x, S(256)*a**S(3)*(d*x)**(S(5)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(3315)*d*(a + b*x**S(2))) + S(64)*a**S(2)*(d*x)**(S(5)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(663)*d) + S(24)*a*(d*x)**(S(5)/2)*(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(221)*d) + S(2)*(d*x)**(S(5)/2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(17)*d), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(d*x)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2), x), x, S(256)*a**S(3)*(d*x)**(S(3)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(1155)*d*(a + b*x**S(2))) + S(64)*a**S(2)*(d*x)**(S(3)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(385)*d) + S(8)*a*(d*x)**(S(3)/2)*(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(55)*d) + S(2)*(d*x)**(S(3)/2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(15)*d), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/sqrt(d*x), x), x, S(256)*a**S(3)*sqrt(d*x)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(195)*d*(a + b*x**S(2))) + S(64)*a**S(2)*sqrt(d*x)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(195)*d) + S(8)*a*sqrt(d*x)*(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(39)*d) + S(2)*sqrt(d*x)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(13)*d), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(d*x)**(S(3)/2), x), x, -S(256)*a**S(3)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(77)*d*sqrt(d*x)*(a + b*x**S(2))) + S(64)*a**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(77)*d*sqrt(d*x)) + S(24)*a*(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(77)*d*sqrt(d*x)) + S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(11)*d*sqrt(d*x)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(d*x)**(S(5)/2), x), x, -S(256)*a**S(3)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(45)*d*(d*x)**(S(3)/2)*(a + b*x**S(2))) + S(64)*a**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(15)*d*(d*x)**(S(3)/2)) + S(8)*a*(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(15)*d*(d*x)**(S(3)/2)) + S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(9)*d*(d*x)**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(d*x)**(S(7)/2), x), x, S(256)*a**S(3)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(35)*d*(d*x)**(S(5)/2)*(a + b*x**S(2))) - S(64)*a**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(7)*d*(d*x)**(S(5)/2)) + S(8)*a*(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(7)*d*(d*x)**(S(5)/2)) + S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(7)*d*(d*x)**(S(5)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**(S(5)/2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2), x), x, S(16384)*a**S(5)*(d*x)**(S(7)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(908523)*d*(a + b*x**S(2))) + S(4096)*a**S(4)*(d*x)**(S(7)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(129789)*d) + S(512)*a**S(3)*(d*x)**(S(7)/2)*(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(11799)*d) + S(640)*a**S(2)*(d*x)**(S(7)/2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(11799)*d) + S(40)*a*(d*x)**(S(7)/2)*(a + b*x**S(2))*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(621)*d) + S(2)*(d*x)**(S(7)/2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/(S(27)*d), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**(S(3)/2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2), x), x, S(16384)*a**S(5)*(d*x)**(S(5)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(348075)*d*(a + b*x**S(2))) + S(4096)*a**S(4)*(d*x)**(S(5)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(69615)*d) + S(512)*a**S(3)*(d*x)**(S(5)/2)*(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(7735)*d) + S(128)*a**S(2)*(d*x)**(S(5)/2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(1785)*d) + S(8)*a*(d*x)**(S(5)/2)*(a + b*x**S(2))*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(105)*d) + S(2)*(d*x)**(S(5)/2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/(S(25)*d), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(d*x)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2), x), x, S(16384)*a**S(5)*(d*x)**(S(3)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(100947)*d*(a + b*x**S(2))) + S(4096)*a**S(4)*(d*x)**(S(3)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(33649)*d) + S(512)*a**S(3)*(d*x)**(S(3)/2)*(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(4807)*d) + S(128)*a**S(2)*(d*x)**(S(3)/2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(1311)*d) + S(40)*a*(d*x)**(S(3)/2)*(a + b*x**S(2))*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(437)*d) + S(2)*(d*x)**(S(3)/2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/(S(23)*d), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/sqrt(d*x), x), x, S(16384)*a**S(5)*sqrt(d*x)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(13923)*d*(a + b*x**S(2))) + S(4096)*a**S(4)*sqrt(d*x)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(13923)*d) + S(2560)*a**S(3)*sqrt(d*x)*(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(13923)*d) + S(640)*a**S(2)*sqrt(d*x)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(4641)*d) + S(40)*a*sqrt(d*x)*(a + b*x**S(2))*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(357)*d) + S(2)*sqrt(d*x)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/(S(21)*d), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/(d*x)**(S(3)/2), x), x, -S(16384)*a**S(5)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(4389)*d*sqrt(d*x)*(a + b*x**S(2))) + S(4096)*a**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(4389)*d*sqrt(d*x)) + S(512)*a**S(3)*(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(1463)*d*sqrt(d*x)) + S(128)*a**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(627)*d*sqrt(d*x)) + S(8)*a*(a + b*x**S(2))*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(57)*d*sqrt(d*x)) + S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/(S(19)*d*sqrt(d*x)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/(d*x)**(S(5)/2), x), x, -S(16384)*a**S(5)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(1989)*d*(d*x)**(S(3)/2)*(a + b*x**S(2))) + S(4096)*a**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(663)*d*(d*x)**(S(3)/2)) + S(512)*a**S(3)*(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(663)*d*(d*x)**(S(3)/2)) + S(640)*a**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(1989)*d*(d*x)**(S(3)/2)) + S(40)*a*(a + b*x**S(2))*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(221)*d*(d*x)**(S(3)/2)) + S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/(S(17)*d*(d*x)**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/(d*x)**(S(7)/2), x), x, S(16384)*a**S(5)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(1155)*d*(d*x)**(S(5)/2)*(a + b*x**S(2))) - S(4096)*a**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(231)*d*(d*x)**(S(5)/2)) + S(512)*a**S(3)*(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(231)*d*(d*x)**(S(5)/2)) + S(128)*a**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(231)*d*(d*x)**(S(5)/2)) + S(8)*a*(a + b*x**S(2))*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)/(S(33)*d*(d*x)**(S(5)/2)) + S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)/(S(15)*d*(d*x)**(S(5)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**(S(7)/2)/sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4)), x), x, -sqrt(S(2))*a**(S(5)/4)*d**(S(7)/2)*(a + b*x**S(2))*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(4)*b**(S(9)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + sqrt(S(2))*a**(S(5)/4)*d**(S(7)/2)*(a + b*x**S(2))*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(4)*b**(S(9)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - sqrt(S(2))*a**(S(5)/4)*d**(S(7)/2)*(a + b*x**S(2))*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(2)*b**(S(9)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + sqrt(S(2))*a**(S(5)/4)*d**(S(7)/2)*(a + b*x**S(2))*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(2)*b**(S(9)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - S(2)*a*d**S(3)*sqrt(d*x)*(a + b*x**S(2))/(b**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + S(2)*d*(d*x)**(S(5)/2)*(a + b*x**S(2))/(S(5)*b*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**(S(5)/2)/sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4)), x), x, -sqrt(S(2))*a**(S(3)/4)*d**(S(5)/2)*(a + b*x**S(2))*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(4)*b**(S(7)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + sqrt(S(2))*a**(S(3)/4)*d**(S(5)/2)*(a + b*x**S(2))*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(4)*b**(S(7)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + sqrt(S(2))*a**(S(3)/4)*d**(S(5)/2)*(a + b*x**S(2))*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(2)*b**(S(7)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - sqrt(S(2))*a**(S(3)/4)*d**(S(5)/2)*(a + b*x**S(2))*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(2)*b**(S(7)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + S(2)*d*(d*x)**(S(3)/2)*(a + b*x**S(2))/(S(3)*b*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**(S(3)/2)/sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4)), x), x, sqrt(S(2))*a**(S(1)/4)*d**(S(3)/2)*(a + b*x**S(2))*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(4)*b**(S(5)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - sqrt(S(2))*a**(S(1)/4)*d**(S(3)/2)*(a + b*x**S(2))*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(4)*b**(S(5)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + sqrt(S(2))*a**(S(1)/4)*d**(S(3)/2)*(a + b*x**S(2))*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(2)*b**(S(5)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - sqrt(S(2))*a**(S(1)/4)*d**(S(3)/2)*(a + b*x**S(2))*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(2)*b**(S(5)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + S(2)*d*sqrt(d*x)*(a + b*x**S(2))/(b*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(d*x)/sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4)), x), x, sqrt(S(2))*sqrt(d)*(a + b*x**S(2))*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(4)*a**(S(1)/4)*b**(S(3)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - sqrt(S(2))*sqrt(d)*(a + b*x**S(2))*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(4)*a**(S(1)/4)*b**(S(3)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - sqrt(S(2))*sqrt(d)*(a + b*x**S(2))*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(2)*a**(S(1)/4)*b**(S(3)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + sqrt(S(2))*sqrt(d)*(a + b*x**S(2))*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(2)*a**(S(1)/4)*b**(S(3)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(sqrt(d*x)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), x), x, -sqrt(S(2))*(a + b*x**S(2))*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(4)*a**(S(3)/4)*b**(S(1)/4)*sqrt(d)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + sqrt(S(2))*(a + b*x**S(2))*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(4)*a**(S(3)/4)*b**(S(1)/4)*sqrt(d)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - sqrt(S(2))*(a + b*x**S(2))*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(2)*a**(S(3)/4)*b**(S(1)/4)*sqrt(d)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + sqrt(S(2))*(a + b*x**S(2))*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(2)*a**(S(3)/4)*b**(S(1)/4)*sqrt(d)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((d*x)**(S(3)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), x), x, (-S(2)*a - S(2)*b*x**S(2))/(a*d*sqrt(d*x)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - sqrt(S(2))*b**(S(1)/4)*(a + b*x**S(2))*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(4)*a**(S(5)/4)*d**(S(3)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + sqrt(S(2))*b**(S(1)/4)*(a + b*x**S(2))*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(4)*a**(S(5)/4)*d**(S(3)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + sqrt(S(2))*b**(S(1)/4)*(a + b*x**S(2))*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(2)*a**(S(5)/4)*d**(S(3)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - sqrt(S(2))*b**(S(1)/4)*(a + b*x**S(2))*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(2)*a**(S(5)/4)*d**(S(3)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((d*x)**(S(5)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), x), x, (-S(2)*a - S(2)*b*x**S(2))/(S(3)*a*d*(d*x)**(S(3)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + sqrt(S(2))*b**(S(3)/4)*(a + b*x**S(2))*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(4)*a**(S(7)/4)*d**(S(5)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - sqrt(S(2))*b**(S(3)/4)*(a + b*x**S(2))*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(4)*a**(S(7)/4)*d**(S(5)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + sqrt(S(2))*b**(S(3)/4)*(a + b*x**S(2))*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(2)*a**(S(7)/4)*d**(S(5)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - sqrt(S(2))*b**(S(3)/4)*(a + b*x**S(2))*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(2)*a**(S(7)/4)*d**(S(5)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((d*x)**(S(7)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), x), x, (-S(2)*a - S(2)*b*x**S(2))/(S(5)*a*d*(d*x)**(S(5)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + S(2)*b*(a + b*x**S(2))/(a**S(2)*d**S(3)*sqrt(d*x)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + sqrt(S(2))*b**(S(5)/4)*(a + b*x**S(2))*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(4)*a**(S(9)/4)*d**(S(7)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - sqrt(S(2))*b**(S(5)/4)*(a + b*x**S(2))*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(4)*a**(S(9)/4)*d**(S(7)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - sqrt(S(2))*b**(S(5)/4)*(a + b*x**S(2))*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(2)*a**(S(9)/4)*d**(S(7)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + sqrt(S(2))*b**(S(5)/4)*(a + b*x**S(2))*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(2)*a**(S(9)/4)*d**(S(7)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**(S(15)/2)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2), x), x, -S(117)*sqrt(S(2))*a**(S(5)/4)*d**(S(15)/2)*(a + b*x**S(2))*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(128)*b**(S(17)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + S(117)*sqrt(S(2))*a**(S(5)/4)*d**(S(15)/2)*(a + b*x**S(2))*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(128)*b**(S(17)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - S(117)*sqrt(S(2))*a**(S(5)/4)*d**(S(15)/2)*(a + b*x**S(2))*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(64)*b**(S(17)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + S(117)*sqrt(S(2))*a**(S(5)/4)*d**(S(15)/2)*(a + b*x**S(2))*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(64)*b**(S(17)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + a*d**S(3)*(d*x)**(S(9)/2)*(a + b*x**S(2))/(S(4)*b**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)) - S(117)*a*d**S(7)*sqrt(d*x)*(a + b*x**S(2))/(S(16)*b**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - S(17)*d**S(3)*(d*x)**(S(9)/2)/(S(16)*b**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + S(117)*d**S(5)*(d*x)**(S(5)/2)*(a + b*x**S(2))/(S(80)*b**S(3)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**(S(13)/2)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2), x), x, -S(77)*sqrt(S(2))*a**(S(3)/4)*d**(S(13)/2)*(a + b*x**S(2))*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(128)*b**(S(15)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + S(77)*sqrt(S(2))*a**(S(3)/4)*d**(S(13)/2)*(a + b*x**S(2))*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(128)*b**(S(15)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + S(77)*sqrt(S(2))*a**(S(3)/4)*d**(S(13)/2)*(a + b*x**S(2))*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(64)*b**(S(15)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - S(77)*sqrt(S(2))*a**(S(3)/4)*d**(S(13)/2)*(a + b*x**S(2))*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(64)*b**(S(15)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + a*d**S(3)*(d*x)**(S(7)/2)*(a + b*x**S(2))/(S(4)*b**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)) - S(15)*d**S(3)*(d*x)**(S(7)/2)/(S(16)*b**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + S(77)*d**S(5)*(d*x)**(S(3)/2)*(a + b*x**S(2))/(S(48)*b**S(3)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**(S(11)/2)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2), x), x, S(45)*sqrt(S(2))*a**(S(1)/4)*d**(S(11)/2)*(a + b*x**S(2))*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(128)*b**(S(13)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - S(45)*sqrt(S(2))*a**(S(1)/4)*d**(S(11)/2)*(a + b*x**S(2))*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(128)*b**(S(13)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + S(45)*sqrt(S(2))*a**(S(1)/4)*d**(S(11)/2)*(a + b*x**S(2))*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(64)*b**(S(13)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - S(45)*sqrt(S(2))*a**(S(1)/4)*d**(S(11)/2)*(a + b*x**S(2))*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(64)*b**(S(13)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + a*d**S(3)*(d*x)**(S(5)/2)*(a + b*x**S(2))/(S(4)*b**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)) - S(13)*d**S(3)*(d*x)**(S(5)/2)/(S(16)*b**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + S(45)*d**S(5)*sqrt(d*x)*(a + b*x**S(2))/(S(16)*b**S(3)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**(S(9)/2)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2), x), x, a*d**S(3)*(d*x)**(S(3)/2)*(a + b*x**S(2))/(S(4)*b**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)) - S(11)*d**S(3)*(d*x)**(S(3)/2)/(S(16)*b**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + S(21)*sqrt(S(2))*d**(S(9)/2)*(a + b*x**S(2))*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(128)*a**(S(1)/4)*b**(S(11)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - S(21)*sqrt(S(2))*d**(S(9)/2)*(a + b*x**S(2))*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(128)*a**(S(1)/4)*b**(S(11)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - S(21)*sqrt(S(2))*d**(S(9)/2)*(a + b*x**S(2))*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(64)*a**(S(1)/4)*b**(S(11)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + S(21)*sqrt(S(2))*d**(S(9)/2)*(a + b*x**S(2))*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(64)*a**(S(1)/4)*b**(S(11)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**(S(7)/2)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2), x), x, a*d**S(3)*sqrt(d*x)*(a + b*x**S(2))/(S(4)*b**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)) - S(9)*d**S(3)*sqrt(d*x)/(S(16)*b**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - S(5)*sqrt(S(2))*d**(S(7)/2)*(a + b*x**S(2))*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(128)*a**(S(3)/4)*b**(S(9)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + S(5)*sqrt(S(2))*d**(S(7)/2)*(a + b*x**S(2))*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(128)*a**(S(3)/4)*b**(S(9)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - S(5)*sqrt(S(2))*d**(S(7)/2)*(a + b*x**S(2))*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(64)*a**(S(3)/4)*b**(S(9)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + S(5)*sqrt(S(2))*d**(S(7)/2)*(a + b*x**S(2))*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(64)*a**(S(3)/4)*b**(S(9)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**(S(5)/2)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2), x), x, (d*x)**(S(7)/2)*(a + b*x**S(2))/(S(4)*a*d*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)) - d*(d*x)**(S(3)/2)/(S(16)*a*b*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + S(3)*sqrt(S(2))*d**(S(5)/2)*(a + b*x**S(2))*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(128)*a**(S(5)/4)*b**(S(7)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - S(3)*sqrt(S(2))*d**(S(5)/2)*(a + b*x**S(2))*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(128)*a**(S(5)/4)*b**(S(7)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - S(3)*sqrt(S(2))*d**(S(5)/2)*(a + b*x**S(2))*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(64)*a**(S(5)/4)*b**(S(7)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + S(3)*sqrt(S(2))*d**(S(5)/2)*(a + b*x**S(2))*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(64)*a**(S(5)/4)*b**(S(7)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**(S(3)/2)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2), x), x, (d*x)**(S(5)/2)*(a + b*x**S(2))/(S(4)*a*d*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)) - S(3)*d*sqrt(d*x)/(S(16)*a*b*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - S(3)*sqrt(S(2))*d**(S(3)/2)*(a + b*x**S(2))*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(128)*a**(S(7)/4)*b**(S(5)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + S(3)*sqrt(S(2))*d**(S(3)/2)*(a + b*x**S(2))*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(128)*a**(S(7)/4)*b**(S(5)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - S(3)*sqrt(S(2))*d**(S(3)/2)*(a + b*x**S(2))*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(64)*a**(S(7)/4)*b**(S(5)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + S(3)*sqrt(S(2))*d**(S(3)/2)*(a + b*x**S(2))*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(64)*a**(S(7)/4)*b**(S(5)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(d*x)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2), x), x, (d*x)**(S(3)/2)*(a + b*x**S(2))/(S(4)*a*d*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)) + S(5)*(d*x)**(S(3)/2)/(S(16)*a**S(2)*d*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + S(5)*sqrt(S(2))*sqrt(d)*(a + b*x**S(2))*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(128)*a**(S(9)/4)*b**(S(3)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - S(5)*sqrt(S(2))*sqrt(d)*(a + b*x**S(2))*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(128)*a**(S(9)/4)*b**(S(3)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - S(5)*sqrt(S(2))*sqrt(d)*(a + b*x**S(2))*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(64)*a**(S(9)/4)*b**(S(3)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + S(5)*sqrt(S(2))*sqrt(d)*(a + b*x**S(2))*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(64)*a**(S(9)/4)*b**(S(3)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(sqrt(d*x)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)), x), x, sqrt(d*x)*(a + b*x**S(2))/(S(4)*a*d*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)) + S(7)*sqrt(d*x)/(S(16)*a**S(2)*d*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - sqrt(S(2))*(S(21)*a + S(21)*b*x**S(2))*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(128)*a**(S(11)/4)*b**(S(1)/4)*sqrt(d)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + sqrt(S(2))*(S(21)*a + S(21)*b*x**S(2))*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(128)*a**(S(11)/4)*b**(S(1)/4)*sqrt(d)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - sqrt(S(2))*(S(21)*a + S(21)*b*x**S(2))*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(64)*a**(S(11)/4)*b**(S(1)/4)*sqrt(d)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + sqrt(S(2))*(S(21)*a + S(21)*b*x**S(2))*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(64)*a**(S(11)/4)*b**(S(1)/4)*sqrt(d)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((d*x)**(S(3)/2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)), x), x, (a + b*x**S(2))/(S(4)*a*d*sqrt(d*x)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)) + S(9)/(S(16)*a**S(2)*d*sqrt(d*x)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - (S(45)*a + S(45)*b*x**S(2))/(S(16)*a**S(3)*d*sqrt(d*x)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - S(45)*sqrt(S(2))*b**(S(1)/4)*(a + b*x**S(2))*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(128)*a**(S(13)/4)*d**(S(3)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + S(45)*sqrt(S(2))*b**(S(1)/4)*(a + b*x**S(2))*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(128)*a**(S(13)/4)*d**(S(3)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + S(45)*sqrt(S(2))*b**(S(1)/4)*(a + b*x**S(2))*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(64)*a**(S(13)/4)*d**(S(3)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - S(45)*sqrt(S(2))*b**(S(1)/4)*(a + b*x**S(2))*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(64)*a**(S(13)/4)*d**(S(3)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((d*x)**(S(5)/2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)), x), x, (a + b*x**S(2))/(S(4)*a*d*(d*x)**(S(3)/2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)) + S(11)/(S(16)*a**S(2)*d*(d*x)**(S(3)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - (S(77)*a + S(77)*b*x**S(2))/(S(48)*a**S(3)*d*(d*x)**(S(3)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + S(77)*sqrt(S(2))*b**(S(3)/4)*(a + b*x**S(2))*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(128)*a**(S(15)/4)*d**(S(5)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - S(77)*sqrt(S(2))*b**(S(3)/4)*(a + b*x**S(2))*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(128)*a**(S(15)/4)*d**(S(5)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + S(77)*sqrt(S(2))*b**(S(3)/4)*(a + b*x**S(2))*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(64)*a**(S(15)/4)*d**(S(5)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - S(77)*sqrt(S(2))*b**(S(3)/4)*(a + b*x**S(2))*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(64)*a**(S(15)/4)*d**(S(5)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((d*x)**(S(7)/2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)), x), x, (a + b*x**S(2))/(S(4)*a*d*(d*x)**(S(5)/2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)) + S(13)/(S(16)*a**S(2)*d*(d*x)**(S(5)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - (S(117)*a + S(117)*b*x**S(2))/(S(80)*a**S(3)*d*(d*x)**(S(5)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + S(117)*b*(a + b*x**S(2))/(S(16)*a**S(4)*d**S(3)*sqrt(d*x)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + S(117)*sqrt(S(2))*b**(S(5)/4)*(a + b*x**S(2))*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(128)*a**(S(17)/4)*d**(S(7)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - S(117)*sqrt(S(2))*b**(S(5)/4)*(a + b*x**S(2))*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(128)*a**(S(17)/4)*d**(S(7)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - S(117)*sqrt(S(2))*b**(S(5)/4)*(a + b*x**S(2))*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(64)*a**(S(17)/4)*d**(S(7)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + S(117)*sqrt(S(2))*b**(S(5)/4)*(a + b*x**S(2))*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(64)*a**(S(17)/4)*d**(S(7)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**(S(23)/2)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2), x), x, -S(13923)*sqrt(S(2))*a**(S(5)/4)*d**(S(23)/2)*(a + b*x**S(2))*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(8192)*b**(S(25)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + S(13923)*sqrt(S(2))*a**(S(5)/4)*d**(S(23)/2)*(a + b*x**S(2))*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(8192)*b**(S(25)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - S(13923)*sqrt(S(2))*a**(S(5)/4)*d**(S(23)/2)*(a + b*x**S(2))*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(4096)*b**(S(25)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + S(13923)*sqrt(S(2))*a**(S(5)/4)*d**(S(23)/2)*(a + b*x**S(2))*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(4096)*b**(S(25)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + a*d**S(3)*(d*x)**(S(17)/2)*(a + b*x**S(2))/(S(8)*b**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)) + S(119)*a*d**S(7)*(d*x)**(S(9)/2)*(a + b*x**S(2))/(S(256)*b**S(4)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)) - S(13923)*a*d**S(11)*sqrt(d*x)*(a + b*x**S(2))/(S(1024)*b**S(6)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - S(11)*d**S(3)*(d*x)**(S(17)/2)/(S(32)*b**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)) - S(2023)*d**S(7)*(d*x)**(S(9)/2)/(S(1024)*b**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + S(13923)*d**S(9)*(d*x)**(S(5)/2)*(a + b*x**S(2))/(S(5120)*b**S(5)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**(S(21)/2)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2), x), x, -S(7315)*sqrt(S(2))*a**(S(3)/4)*d**(S(21)/2)*(a + b*x**S(2))*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(8192)*b**(S(23)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + S(7315)*sqrt(S(2))*a**(S(3)/4)*d**(S(21)/2)*(a + b*x**S(2))*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(8192)*b**(S(23)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + S(7315)*sqrt(S(2))*a**(S(3)/4)*d**(S(21)/2)*(a + b*x**S(2))*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(4096)*b**(S(23)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - S(7315)*sqrt(S(2))*a**(S(3)/4)*d**(S(21)/2)*(a + b*x**S(2))*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(4096)*b**(S(23)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + a*d**S(3)*(d*x)**(S(15)/2)*(a + b*x**S(2))/(S(8)*b**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)) + S(95)*a*d**S(7)*(d*x)**(S(7)/2)*(a + b*x**S(2))/(S(256)*b**S(4)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)) - S(31)*d**S(3)*(d*x)**(S(15)/2)/(S(96)*b**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)) - S(1425)*d**S(7)*(d*x)**(S(7)/2)/(S(1024)*b**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + S(7315)*d**S(9)*(d*x)**(S(3)/2)*(a + b*x**S(2))/(S(3072)*b**S(5)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**(S(19)/2)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2), x), x, S(3315)*sqrt(S(2))*a**(S(1)/4)*d**(S(19)/2)*(a + b*x**S(2))*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(8192)*b**(S(21)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - S(3315)*sqrt(S(2))*a**(S(1)/4)*d**(S(19)/2)*(a + b*x**S(2))*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(8192)*b**(S(21)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + S(3315)*sqrt(S(2))*a**(S(1)/4)*d**(S(19)/2)*(a + b*x**S(2))*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(4096)*b**(S(21)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - S(3315)*sqrt(S(2))*a**(S(1)/4)*d**(S(19)/2)*(a + b*x**S(2))*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(4096)*b**(S(21)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + a*d**S(3)*(d*x)**(S(13)/2)*(a + b*x**S(2))/(S(8)*b**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)) + S(221)*a*d**S(7)*(d*x)**(S(5)/2)*(a + b*x**S(2))/(S(768)*b**S(4)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)) - S(29)*d**S(3)*(d*x)**(S(13)/2)/(S(96)*b**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)) - S(2873)*d**S(7)*(d*x)**(S(5)/2)/(S(3072)*b**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + S(3315)*d**S(9)*sqrt(d*x)*(a + b*x**S(2))/(S(1024)*b**S(5)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**(S(17)/2)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2), x), x, a*d**S(3)*(d*x)**(S(11)/2)*(a + b*x**S(2))/(S(8)*b**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)) + S(55)*a*d**S(7)*(d*x)**(S(3)/2)*(a + b*x**S(2))/(S(256)*b**S(4)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)) - S(9)*d**S(3)*(d*x)**(S(11)/2)/(S(32)*b**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)) - S(605)*d**S(7)*(d*x)**(S(3)/2)/(S(1024)*b**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + S(1155)*sqrt(S(2))*d**(S(17)/2)*(a + b*x**S(2))*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(8192)*a**(S(1)/4)*b**(S(19)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - S(1155)*sqrt(S(2))*d**(S(17)/2)*(a + b*x**S(2))*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(8192)*a**(S(1)/4)*b**(S(19)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - S(1155)*sqrt(S(2))*d**(S(17)/2)*(a + b*x**S(2))*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(4096)*a**(S(1)/4)*b**(S(19)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + S(1155)*sqrt(S(2))*d**(S(17)/2)*(a + b*x**S(2))*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(4096)*a**(S(1)/4)*b**(S(19)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**(S(15)/2)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2), x), x, a*d**S(3)*(d*x)**(S(9)/2)*(a + b*x**S(2))/(S(8)*b**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)) + S(39)*a*d**S(7)*sqrt(d*x)*(a + b*x**S(2))/(S(256)*b**S(4)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)) - S(25)*d**S(3)*(d*x)**(S(9)/2)/(S(96)*b**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)) - S(351)*d**S(7)*sqrt(d*x)/(S(1024)*b**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - S(195)*sqrt(S(2))*d**(S(15)/2)*(a + b*x**S(2))*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(8192)*a**(S(3)/4)*b**(S(17)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + S(195)*sqrt(S(2))*d**(S(15)/2)*(a + b*x**S(2))*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(8192)*a**(S(3)/4)*b**(S(17)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - S(195)*sqrt(S(2))*d**(S(15)/2)*(a + b*x**S(2))*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(4096)*a**(S(3)/4)*b**(S(17)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + S(195)*sqrt(S(2))*d**(S(15)/2)*(a + b*x**S(2))*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(4096)*a**(S(3)/4)*b**(S(17)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**(S(13)/2)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2), x), x, a*d**S(3)*(d*x)**(S(7)/2)*(a + b*x**S(2))/(S(8)*b**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)) - S(23)*d**S(3)*(d*x)**(S(7)/2)/(S(96)*b**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)) + S(77)*d**S(3)*(d*x)**(S(7)/2)*(a + b*x**S(2))/(S(768)*a*b**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)) - S(77)*d**S(5)*(d*x)**(S(3)/2)/(S(3072)*a*b**S(3)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + S(77)*sqrt(S(2))*d**(S(13)/2)*(a + b*x**S(2))*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(8192)*a**(S(5)/4)*b**(S(15)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - S(77)*sqrt(S(2))*d**(S(13)/2)*(a + b*x**S(2))*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(8192)*a**(S(5)/4)*b**(S(15)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - S(77)*sqrt(S(2))*d**(S(13)/2)*(a + b*x**S(2))*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(4096)*a**(S(5)/4)*b**(S(15)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + S(77)*sqrt(S(2))*d**(S(13)/2)*(a + b*x**S(2))*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(4096)*a**(S(5)/4)*b**(S(15)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**(S(11)/2)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2), x), x, a*d**S(3)*(d*x)**(S(5)/2)*(a + b*x**S(2))/(S(8)*b**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)) - S(7)*d**S(3)*(d*x)**(S(5)/2)/(S(32)*b**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)) + S(15)*d**S(3)*(d*x)**(S(5)/2)*(a + b*x**S(2))/(S(256)*a*b**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)) - S(45)*d**S(5)*sqrt(d*x)/(S(1024)*a*b**S(3)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - S(45)*sqrt(S(2))*d**(S(11)/2)*(a + b*x**S(2))*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(8192)*a**(S(7)/4)*b**(S(13)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + S(45)*sqrt(S(2))*d**(S(11)/2)*(a + b*x**S(2))*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(8192)*a**(S(7)/4)*b**(S(13)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - S(45)*sqrt(S(2))*d**(S(11)/2)*(a + b*x**S(2))*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(4096)*a**(S(7)/4)*b**(S(13)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + S(45)*sqrt(S(2))*d**(S(11)/2)*(a + b*x**S(2))*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(4096)*a**(S(7)/4)*b**(S(13)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**(S(9)/2)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2), x), x, a*d**S(3)*(d*x)**(S(3)/2)*(a + b*x**S(2))/(S(8)*b**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)) - S(19)*d**S(3)*(d*x)**(S(3)/2)/(S(96)*b**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)) + S(7)*d**S(3)*(d*x)**(S(3)/2)*(a + b*x**S(2))/(S(256)*a*b**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)) + S(35)*d**S(3)*(d*x)**(S(3)/2)/(S(1024)*a**S(2)*b**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + S(35)*sqrt(S(2))*d**(S(9)/2)*(a + b*x**S(2))*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(8192)*a**(S(9)/4)*b**(S(11)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - S(35)*sqrt(S(2))*d**(S(9)/2)*(a + b*x**S(2))*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(8192)*a**(S(9)/4)*b**(S(11)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - S(35)*sqrt(S(2))*d**(S(9)/2)*(a + b*x**S(2))*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(4096)*a**(S(9)/4)*b**(S(11)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + S(35)*sqrt(S(2))*d**(S(9)/2)*(a + b*x**S(2))*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(4096)*a**(S(9)/4)*b**(S(11)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**(S(7)/2)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2), x), x, a*d**S(3)*sqrt(d*x)*(a + b*x**S(2))/(S(8)*b**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)) - S(17)*d**S(3)*sqrt(d*x)/(S(96)*b**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)) + S(5)*d**S(3)*sqrt(d*x)*(a + b*x**S(2))/(S(768)*a*b**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)) + S(35)*d**S(3)*sqrt(d*x)/(S(3072)*a**S(2)*b**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - S(35)*sqrt(S(2))*d**(S(7)/2)*(a + b*x**S(2))*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(8192)*a**(S(11)/4)*b**(S(9)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + S(35)*sqrt(S(2))*d**(S(7)/2)*(a + b*x**S(2))*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(8192)*a**(S(11)/4)*b**(S(9)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - S(35)*sqrt(S(2))*d**(S(7)/2)*(a + b*x**S(2))*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(4096)*a**(S(11)/4)*b**(S(9)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + S(35)*sqrt(S(2))*d**(S(7)/2)*(a + b*x**S(2))*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(4096)*a**(S(11)/4)*b**(S(9)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**(S(5)/2)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2), x), x, (d*x)**(S(7)/2)*(a + b*x**S(2))/(S(8)*a*d*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)) - S(3)*d*(d*x)**(S(3)/2)/(S(32)*a*b*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)) + S(9)*d*(d*x)**(S(3)/2)*(a + b*x**S(2))/(S(256)*a**S(2)*b*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)) + S(45)*d*(d*x)**(S(3)/2)/(S(1024)*a**S(3)*b*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + S(45)*sqrt(S(2))*d**(S(5)/2)*(a + b*x**S(2))*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(8192)*a**(S(13)/4)*b**(S(7)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - S(45)*sqrt(S(2))*d**(S(5)/2)*(a + b*x**S(2))*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(8192)*a**(S(13)/4)*b**(S(7)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - S(45)*sqrt(S(2))*d**(S(5)/2)*(a + b*x**S(2))*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(4096)*a**(S(13)/4)*b**(S(7)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + S(45)*sqrt(S(2))*d**(S(5)/2)*(a + b*x**S(2))*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(4096)*a**(S(13)/4)*b**(S(7)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**(S(3)/2)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2), x), x, (d*x)**(S(5)/2)*(a + b*x**S(2))/(S(8)*a*d*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)) - S(11)*d*sqrt(d*x)/(S(96)*a*b*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)) + S(11)*d*sqrt(d*x)*(a + b*x**S(2))/(S(768)*a**S(2)*b*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)) + S(77)*d*sqrt(d*x)/(S(3072)*a**S(3)*b*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - S(77)*sqrt(S(2))*d**(S(3)/2)*(a + b*x**S(2))*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(8192)*a**(S(15)/4)*b**(S(5)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + S(77)*sqrt(S(2))*d**(S(3)/2)*(a + b*x**S(2))*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(8192)*a**(S(15)/4)*b**(S(5)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - S(77)*sqrt(S(2))*d**(S(3)/2)*(a + b*x**S(2))*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(4096)*a**(S(15)/4)*b**(S(5)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + S(77)*sqrt(S(2))*d**(S(3)/2)*(a + b*x**S(2))*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(4096)*a**(S(15)/4)*b**(S(5)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(d*x)/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2), x), x, (d*x)**(S(3)/2)*(a + b*x**S(2))/(S(8)*a*d*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)) + S(13)*(d*x)**(S(3)/2)/(S(96)*a**S(2)*d*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)) + S(39)*(d*x)**(S(3)/2)*(a + b*x**S(2))/(S(256)*a**S(3)*d*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)) + S(195)*(d*x)**(S(3)/2)/(S(1024)*a**S(4)*d*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + S(195)*sqrt(S(2))*sqrt(d)*(a + b*x**S(2))*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(8192)*a**(S(17)/4)*b**(S(3)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - S(195)*sqrt(S(2))*sqrt(d)*(a + b*x**S(2))*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(8192)*a**(S(17)/4)*b**(S(3)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - S(195)*sqrt(S(2))*sqrt(d)*(a + b*x**S(2))*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(4096)*a**(S(17)/4)*b**(S(3)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + S(195)*sqrt(S(2))*sqrt(d)*(a + b*x**S(2))*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(4096)*a**(S(17)/4)*b**(S(3)/4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(sqrt(d*x)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)), x), x, sqrt(d*x)*(a + b*x**S(2))/(S(8)*a*d*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)) + S(5)*sqrt(d*x)/(S(32)*a**S(2)*d*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)) + S(55)*sqrt(d*x)*(a + b*x**S(2))/(S(256)*a**S(3)*d*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)) + S(385)*sqrt(d*x)/(S(1024)*a**S(4)*d*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - sqrt(S(2))*(S(1155)*a + S(1155)*b*x**S(2))*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(8192)*a**(S(19)/4)*b**(S(1)/4)*sqrt(d)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + sqrt(S(2))*(S(1155)*a + S(1155)*b*x**S(2))*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(8192)*a**(S(19)/4)*b**(S(1)/4)*sqrt(d)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - sqrt(S(2))*(S(1155)*a + S(1155)*b*x**S(2))*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(4096)*a**(S(19)/4)*b**(S(1)/4)*sqrt(d)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + sqrt(S(2))*(S(1155)*a + S(1155)*b*x**S(2))*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(4096)*a**(S(19)/4)*b**(S(1)/4)*sqrt(d)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((d*x)**(S(3)/2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)), x), x, (a + b*x**S(2))/(S(8)*a*d*sqrt(d*x)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)) + S(17)/(S(96)*a**S(2)*d*sqrt(d*x)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)) + (S(221)*a + S(221)*b*x**S(2))/(S(768)*a**S(3)*d*sqrt(d*x)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)) + S(663)/(S(1024)*a**S(4)*d*sqrt(d*x)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - (S(3315)*a + S(3315)*b*x**S(2))/(S(1024)*a**S(5)*d*sqrt(d*x)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - S(3315)*sqrt(S(2))*b**(S(1)/4)*(a + b*x**S(2))*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(8192)*a**(S(21)/4)*d**(S(3)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + S(3315)*sqrt(S(2))*b**(S(1)/4)*(a + b*x**S(2))*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(8192)*a**(S(21)/4)*d**(S(3)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + S(3315)*sqrt(S(2))*b**(S(1)/4)*(a + b*x**S(2))*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(4096)*a**(S(21)/4)*d**(S(3)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - S(3315)*sqrt(S(2))*b**(S(1)/4)*(a + b*x**S(2))*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(4096)*a**(S(21)/4)*d**(S(3)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((d*x)**(S(5)/2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)), x), x, (a + b*x**S(2))/(S(8)*a*d*(d*x)**(S(3)/2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)) + S(19)/(S(96)*a**S(2)*d*(d*x)**(S(3)/2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)) + (S(95)*a + S(95)*b*x**S(2))/(S(256)*a**S(3)*d*(d*x)**(S(3)/2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)) + S(1045)/(S(1024)*a**S(4)*d*(d*x)**(S(3)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - (S(7315)*a + S(7315)*b*x**S(2))/(S(3072)*a**S(5)*d*(d*x)**(S(3)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + S(7315)*sqrt(S(2))*b**(S(3)/4)*(a + b*x**S(2))*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(8192)*a**(S(23)/4)*d**(S(5)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - S(7315)*sqrt(S(2))*b**(S(3)/4)*(a + b*x**S(2))*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(8192)*a**(S(23)/4)*d**(S(5)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + S(7315)*sqrt(S(2))*b**(S(3)/4)*(a + b*x**S(2))*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(4096)*a**(S(23)/4)*d**(S(5)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - S(7315)*sqrt(S(2))*b**(S(3)/4)*(a + b*x**S(2))*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(4096)*a**(S(23)/4)*d**(S(5)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((d*x)**(S(7)/2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)), x), x, (a + b*x**S(2))/(S(8)*a*d*(d*x)**(S(5)/2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(5)/2)) + S(7)/(S(32)*a**S(2)*d*(d*x)**(S(5)/2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)) + (S(119)*a + S(119)*b*x**S(2))/(S(256)*a**S(3)*d*(d*x)**(S(5)/2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)) + S(1547)/(S(1024)*a**S(4)*d*(d*x)**(S(5)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - (S(13923)*a + S(13923)*b*x**S(2))/(S(5120)*a**S(5)*d*(d*x)**(S(5)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + S(13923)*b*(a + b*x**S(2))/(S(1024)*a**S(6)*d**S(3)*sqrt(d*x)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + S(13923)*sqrt(S(2))*b**(S(5)/4)*(a + b*x**S(2))*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(8192)*a**(S(25)/4)*d**(S(7)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - S(13923)*sqrt(S(2))*b**(S(5)/4)*(a + b*x**S(2))*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*sqrt(d*x) + sqrt(a)*sqrt(d) + sqrt(b)*sqrt(d)*x)/(S(8192)*a**(S(25)/4)*d**(S(7)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - S(13923)*sqrt(S(2))*b**(S(5)/4)*(a + b*x**S(2))*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(4096)*a**(S(25)/4)*d**(S(7)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + S(13923)*sqrt(S(2))*b**(S(5)/4)*(a + b*x**S(2))*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*sqrt(d*x)/(a**(S(1)/4)*sqrt(d)))/(S(4096)*a**(S(25)/4)*d**(S(7)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(4)/3)), x), x, S(3)/(S(10)*a*x*(a + b*x**S(2))*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(1)/3)) + S(39)/(S(40)*a**S(2)*x*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(1)/3)) - (S(91)*a + S(91)*b*x**S(2))/(S(40)*a**S(3)*x*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(1)/3)) + S(91)*S(3)**(S(3)/4)*sqrt((a**(S(2)/3)*b**(S(2)/3) + a**(S(1)/3)*b**(S(1)/3)*(a*b + b**S(2)*x**S(2))**(S(1)/3) + (a*b + b**S(2)*x**S(2))**(S(2)/3))/(a**(S(1)/3)*b**(S(1)/3)*(-sqrt(S(3)) + S(1)) - (a*b + b**S(2)*x**S(2))**(S(1)/3))**S(2))*sqrt(-sqrt(S(3)) + S(2))*(a**(S(1)/3)*b**(S(1)/3) - (a*b + b**S(2)*x**S(2))**(S(1)/3))*(a*b + b**S(2)*x**S(2))**(S(2)/3)*elliptic_f(asin((a**(S(1)/3)*b**(S(1)/3)*(S(1) + sqrt(S(3))) - (a*b + b**S(2)*x**S(2))**(S(1)/3))/(a**(S(1)/3)*b**(S(1)/3)*(-sqrt(S(3)) + S(1)) - (a*b + b**S(2)*x**S(2))**(S(1)/3))), S(-7) + S(4)*sqrt(S(3)))/(S(120)*a**S(3)*b*x*sqrt(-a**(S(1)/3)*b**(S(1)/3)*(a**(S(1)/3)*b**(S(1)/3) - (a*b + b**S(2)*x**S(2))**(S(1)/3))/(a**(S(1)/3)*b**(S(1)/3)*(-sqrt(S(3)) + S(1)) - (a*b + b**S(2)*x**S(2))**(S(1)/3))**S(2))*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(1)/3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**m*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**p, x), x, (d*x)**(m + S(1))*(a + b*x**S(2))*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**p*hyper((S(1), m/S(2) + S(2)*p + S(3)/2), (m/S(2) + S(3)/2,), -b*x**S(2)/a)/(a*d*(m + S(1))), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate((d*x)**m*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**p, x), x, (d*x)**(m + S(1))*(S(1) + b*x**S(2)/a)**(-S(2)*p)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**p*hyper((m/S(2) + S(1)/2, -S(2)*p), (m/S(2) + S(3)/2,), -b*x**S(2)/a)/(d*(m + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**p, x), x, -a*(a + b*x**S(2))*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**p/(S(2)*b**S(2)*(S(2)*p + S(1))) + (a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(p + S(1))/(S(4)*b**S(2)*(p + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**p, x), x, (a + b*x**S(2))*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**p/(S(2)*b*(S(2)*p + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**p/x, x), x, -(a + b*x**S(2))*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**p*hyper((S(1), S(2)*p + S(1)), (S(2)*p + S(2),), S(1) + b*x**S(2)/a)/(S(2)*a*(S(2)*p + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**p/x**S(3), x), x, b*(a + b*x**S(2))*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**p*hyper((S(2), S(2)*p + S(1)), (S(2)*p + S(2),), S(1) + b*x**S(2)/a)/(S(2)*a**S(2)*(S(2)*p + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**p, x), x, x**S(5)*(S(1) + b*x**S(2)/a)**(-S(2)*p)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**p*hyper((S(5)/2, -S(2)*p), (S(7)/2,), -b*x**S(2)/a)/S(5), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**p, x), x, x**S(3)*(S(1) + b*x**S(2)/a)**(-S(2)*p)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**p*hyper((S(3)/2, -S(2)*p), (S(5)/2,), -b*x**S(2)/a)/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**p, x), x, x*(S(1) + b*x**S(2)/a)**(-S(2)*p)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**p*hyper((S(1)/2, -S(2)*p), (S(3)/2,), -b*x**S(2)/a), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**p/x**S(2), x), x, -(S(1) + b*x**S(2)/a)**(-S(2)*p)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**p*hyper((S(-1)/2, -S(2)*p), (S(1)/2,), -b*x**S(2)/a)/x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**p/x**S(4), x), x, -(S(1) + b*x**S(2)/a)**(-S(2)*p)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**p*hyper((S(-3)/2, -S(2)*p), (S(-1)/2,), -b*x**S(2)/a)/(S(3)*x**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**(S(3)/2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**p, x), x, S(2)*(d*x)**(S(5)/2)*(S(1) + b*x**S(2)/a)**(-S(2)*p)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**p*hyper((S(5)/4, -S(2)*p), (S(9)/4,), -b*x**S(2)/a)/(S(5)*d), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(d*x)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**p, x), x, S(2)*(d*x)**(S(3)/2)*(S(1) + b*x**S(2)/a)**(-S(2)*p)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**p*hyper((S(3)/4, -S(2)*p), (S(7)/4,), -b*x**S(2)/a)/(S(3)*d), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**p/sqrt(d*x), x), x, S(2)*sqrt(d*x)*(S(1) + b*x**S(2)/a)**(-S(2)*p)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**p*hyper((S(1)/4, -S(2)*p), (S(5)/4,), -b*x**S(2)/a)/d, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**p/(d*x)**(S(3)/2), x), x, -S(2)*(S(1) + b*x**S(2)/a)**(-S(2)*p)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**p*hyper((S(-1)/4, -S(2)*p), (S(3)/4,), -b*x**S(2)/a)/(d*sqrt(d*x)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**p/(d*x)**(S(5)/2), x), x, -S(2)*(S(1) + b*x**S(2)/a)**(-S(2)*p)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**p*hyper((S(-3)/4, -S(2)*p), (S(1)/4,), -b*x**S(2)/a)/(S(3)*d*(d*x)**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(a + b*x**S(2) + c*x**S(4)), x), x, a*x**S(3)/S(3) + b*x**S(5)/S(5) + c*x**S(7)/S(7), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(a + b*x**S(2) + c*x**S(4)), x), x, a*x**S(2)/S(2) + b*x**S(4)/S(4) + c*x**S(6)/S(6), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(a + b*x**S(2) + c*x**S(4), x), x, a*x + b*x**S(3)/S(3) + c*x**S(5)/S(5), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))/x, x), x, a*log(x) + b*x**S(2)/S(2) + c*x**S(4)/S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))/x**S(2), x), x, -a/x + b*x + c*x**S(3)/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))/x**S(3), x), x, -a/(S(2)*x**S(2)) + b*log(x) + c*x**S(2)/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))/x**S(4), x), x, -a/(S(3)*x**S(3)) - b/x + c*x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))/x**S(5), x), x, -a/(S(4)*x**S(4)) - b/(S(2)*x**S(2)) + c*log(x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))/x**S(6), x), x, -a/(S(5)*x**S(5)) - b/(S(3)*x**S(3)) - c/x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))/x**S(7), x), x, -a/(S(6)*x**S(6)) - b/(S(4)*x**S(4)) - c/(S(2)*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))/x**S(8), x), x, -a/(S(7)*x**S(7)) - b/(S(5)*x**S(5)) - c/(S(3)*x**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(a + b*x**S(2) + c*x**S(4))**S(2), x), x, a**S(2)*x**S(3)/S(3) + S(2)*a*b*x**S(5)/S(5) + S(2)*b*c*x**S(9)/S(9) + c**S(2)*x**S(11)/S(11) + x**S(7)*(S(2)*a*c/S(7) + b**S(2)/S(7)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(a + b*x**S(2) + c*x**S(4))**S(2), x), x, a**S(2)*x**S(2)/S(2) + a*b*x**S(4)/S(2) + b*c*x**S(8)/S(4) + c**S(2)*x**S(10)/S(10) + x**S(6)*(a*c/S(3) + b**S(2)/S(6)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))**S(2), x), x, a**S(2)*x + S(2)*a*b*x**S(3)/S(3) + S(2)*b*c*x**S(7)/S(7) + c**S(2)*x**S(9)/S(9) + x**S(5)*(S(2)*a*c/S(5) + b**S(2)/S(5)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))**S(2)/x, x), x, a**S(2)*log(x) + a*b*x**S(2) + b*c*x**S(6)/S(3) + c**S(2)*x**S(8)/S(8) + x**S(4)*(a*c/S(2) + b**S(2)/S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))**S(2)/x**S(2), x), x, -a**S(2)/x + S(2)*a*b*x + S(2)*b*c*x**S(5)/S(5) + c**S(2)*x**S(7)/S(7) + x**S(3)*(S(2)*a*c/S(3) + b**S(2)/S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))**S(2)/x**S(3), x), x, -a**S(2)/(S(2)*x**S(2)) + S(2)*a*b*log(x) + b*c*x**S(4)/S(2) + c**S(2)*x**S(6)/S(6) + x**S(2)*(a*c + b**S(2)/S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))**S(2)/x**S(4), x), x, -a**S(2)/(S(3)*x**S(3)) - S(2)*a*b/x + S(2)*b*c*x**S(3)/S(3) + c**S(2)*x**S(5)/S(5) + x*(S(2)*a*c + b**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))**S(2)/x**S(5), x), x, -a**S(2)/(S(4)*x**S(4)) - a*b/x**S(2) + b*c*x**S(2) + c**S(2)*x**S(4)/S(4) + (S(2)*a*c + b**S(2))*log(x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))**S(2)/x**S(6), x), x, -a**S(2)/(S(5)*x**S(5)) - S(2)*a*b/(S(3)*x**S(3)) + S(2)*b*c*x + c**S(2)*x**S(3)/S(3) - (S(2)*a*c + b**S(2))/x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))**S(2)/x**S(7), x), x, -a**S(2)/(S(6)*x**S(6)) - a*b/(S(2)*x**S(4)) + S(2)*b*c*log(x) + c**S(2)*x**S(2)/S(2) - (S(2)*a*c + b**S(2))/(S(2)*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))**S(2)/x**S(8), x), x, -a**S(2)/(S(7)*x**S(7)) - S(2)*a*b/(S(5)*x**S(5)) - S(2)*b*c/x + c**S(2)*x - (S(2)*a*c + b**S(2))/(S(3)*x**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))**S(2)/x**S(9), x), x, -a**S(2)/(S(8)*x**S(8)) - a*b/(S(3)*x**S(6)) - b*c/x**S(2) + c**S(2)*log(x) - (S(2)*a*c + b**S(2))/(S(4)*x**S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))**S(2)/x**S(10), x), x, -a**S(2)/(S(9)*x**S(9)) - S(2)*a*b/(S(7)*x**S(7)) - S(2)*b*c/(S(3)*x**S(3)) - c**S(2)/x - (S(2)*a*c + b**S(2))/(S(5)*x**S(5)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))**S(2)/x**S(11), x), x, -a**S(2)/(S(10)*x**S(10)) - a*b/(S(4)*x**S(8)) - b*c/(S(2)*x**S(4)) - c**S(2)/(S(2)*x**S(2)) - (S(2)*a*c + b**S(2))/(S(6)*x**S(6)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))**S(2)/x**S(12), x), x, -a**S(2)/(S(11)*x**S(11)) - S(2)*a*b/(S(9)*x**S(9)) - S(2)*b*c/(S(5)*x**S(5)) - c**S(2)/(S(3)*x**S(3)) - (S(2)*a*c + b**S(2))/(S(7)*x**S(7)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))**S(2)/x**S(13), x), x, -a**S(2)/(S(12)*x**S(12)) - a*b/(S(5)*x**S(10)) - b*c/(S(3)*x**S(6)) - c**S(2)/(S(4)*x**S(4)) - (S(2)*a*c + b**S(2))/(S(8)*x**S(8)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(a + b*x**S(2) + c*x**S(4))**S(3), x), x, a**S(3)*x**S(3)/S(3) + S(3)*a**S(2)*b*x**S(5)/S(5) + S(3)*a*x**S(7)*(a*c + b**S(2))/S(7) + S(3)*b*c**S(2)*x**S(13)/S(13) + b*x**S(9)*(S(6)*a*c + b**S(2))/S(9) + c**S(3)*x**S(15)/S(15) + S(3)*c*x**S(11)*(a*c + b**S(2))/S(11), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(a + b*x**S(2) + c*x**S(4))**S(3), x), x, a**S(3)*x**S(2)/S(2) + S(3)*a**S(2)*b*x**S(4)/S(4) + a*x**S(6)*(a*c + b**S(2))/S(2) + b*c**S(2)*x**S(12)/S(4) + b*x**S(8)*(S(6)*a*c + b**S(2))/S(8) + c**S(3)*x**S(14)/S(14) + S(3)*c*x**S(10)*(a*c + b**S(2))/S(10), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))**S(3), x), x, a**S(3)*x + a**S(2)*b*x**S(3) + S(3)*a*x**S(5)*(a*c + b**S(2))/S(5) + S(3)*b*c**S(2)*x**S(11)/S(11) + b*x**S(7)*(S(6)*a*c + b**S(2))/S(7) + c**S(3)*x**S(13)/S(13) + c*x**S(9)*(a*c + b**S(2))/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))**S(3)/x, x), x, a**S(3)*log(x) + S(3)*a**S(2)*b*x**S(2)/S(2) + S(3)*a*x**S(4)*(a*c + b**S(2))/S(4) + S(3)*b*c**S(2)*x**S(10)/S(10) + b*x**S(6)*(S(6)*a*c + b**S(2))/S(6) + c**S(3)*x**S(12)/S(12) + S(3)*c*x**S(8)*(a*c + b**S(2))/S(8), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))**S(3)/x**S(2), x), x, -a**S(3)/x + S(3)*a**S(2)*b*x + a*x**S(3)*(a*c + b**S(2)) + b*c**S(2)*x**S(9)/S(3) + b*x**S(5)*(S(6)*a*c + b**S(2))/S(5) + c**S(3)*x**S(11)/S(11) + S(3)*c*x**S(7)*(a*c + b**S(2))/S(7), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))**S(3)/x**S(3), x), x, -a**S(3)/(S(2)*x**S(2)) + S(3)*a**S(2)*b*log(x) + S(3)*a*x**S(2)*(a*c + b**S(2))/S(2) + S(3)*b*c**S(2)*x**S(8)/S(8) + b*x**S(4)*(S(6)*a*c + b**S(2))/S(4) + c**S(3)*x**S(10)/S(10) + c*x**S(6)*(a*c + b**S(2))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))**S(3)/x**S(4), x), x, -a**S(3)/(S(3)*x**S(3)) - S(3)*a**S(2)*b/x + S(3)*a*x*(a*c + b**S(2)) + S(3)*b*c**S(2)*x**S(7)/S(7) + b*x**S(3)*(S(6)*a*c + b**S(2))/S(3) + c**S(3)*x**S(9)/S(9) + S(3)*c*x**S(5)*(a*c + b**S(2))/S(5), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(7)/(a + b*x**S(2) + c*x**S(4)), x), x, -b*x**S(2)/(S(2)*c**S(2)) + b*(-S(3)*a*c + b**S(2))*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*c**S(3)*sqrt(-S(4)*a*c + b**S(2))) + x**S(4)/(S(4)*c) + (-a*c + b**S(2))*log(a + b*x**S(2) + c*x**S(4))/(S(4)*c**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)/(a + b*x**S(2) + c*x**S(4)), x), x, -b*log(a + b*x**S(2) + c*x**S(4))/(S(4)*c**S(2)) + x**S(2)/(S(2)*c) - (-S(2)*a*c + b**S(2))*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*c**S(2)*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/(a + b*x**S(2) + c*x**S(4)), x), x, b*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*c*sqrt(-S(4)*a*c + b**S(2))) + log(a + b*x**S(2) + c*x**S(4))/(S(4)*c), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(a + b*x**S(2) + c*x**S(4)), x), x, -atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/sqrt(-S(4)*a*c + b**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*(a + b*x**S(2) + c*x**S(4))), x), x, b*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*a*sqrt(-S(4)*a*c + b**S(2))) + log(x)/a - log(a + b*x**S(2) + c*x**S(4))/(S(4)*a), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(3)*(a + b*x**S(2) + c*x**S(4))), x), x, -S(1)/(S(2)*a*x**S(2)) - b*log(x)/a**S(2) + b*log(a + b*x**S(2) + c*x**S(4))/(S(4)*a**S(2)) - (-S(2)*a*c + b**S(2))*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*a**S(2)*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(5)*(a + b*x**S(2) + c*x**S(4))), x), x, -S(1)/(S(4)*a*x**S(4)) + b/(S(2)*a**S(2)*x**S(2)) + b*(-S(3)*a*c + b**S(2))*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*a**S(3)*sqrt(-S(4)*a*c + b**S(2))) + (-a*c + b**S(2))*log(x)/a**S(3) - (-a*c + b**S(2))*log(a + b*x**S(2) + c*x**S(4))/(S(4)*a**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(6)/(a + b*x**S(2) + c*x**S(4)), x), x, -b*x/c**S(2) + x**S(3)/(S(3)*c) + sqrt(S(2))*(-a*c + b**S(2) + b*(-S(3)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*c**(S(5)/2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))) + sqrt(S(2))*(-a*c + b**S(2) - b*(-S(3)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*c**(S(5)/2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)/(a + b*x**S(2) + c*x**S(4)), x), x, x/c - sqrt(S(2))*(b - (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*c**(S(3)/2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))) - sqrt(S(2))*(b + (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*c**(S(3)/2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/(a + b*x**S(2) + c*x**S(4)), x), x, -sqrt(S(2))*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*sqrt(c)*sqrt(-S(4)*a*c + b**S(2))) + sqrt(S(2))*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*sqrt(c)*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(a + b*x**S(2) + c*x**S(4)), x), x, -sqrt(S(2))*sqrt(c)*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*sqrt(-S(4)*a*c + b**S(2))) + sqrt(S(2))*sqrt(c)*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*(a + b*x**S(2) + c*x**S(4))), x), x, -sqrt(S(2))*sqrt(c)*(-b/sqrt(-S(4)*a*c + b**S(2)) + S(1))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*a*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))) - sqrt(S(2))*sqrt(c)*(b/sqrt(-S(4)*a*c + b**S(2)) + S(1))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*a*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))) - S(1)/(a*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(4)*(a + b*x**S(2) + c*x**S(4))), x), x, -S(1)/(S(3)*a*x**S(3)) + b/(a**S(2)*x) + sqrt(S(2))*sqrt(c)*(b - (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*a**S(2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))) + sqrt(S(2))*sqrt(c)*(b + (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*a**S(2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(7)/(a + b*x**S(2) + c*x**S(4))**S(2), x), x, -b*x**S(2)/(S(2)*c*(-S(4)*a*c + b**S(2))) + b*(-S(6)*a*c + b**S(2))*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*c**S(2)*(-S(4)*a*c + b**S(2))**(S(3)/2)) + x**S(4)*(S(2)*a + b*x**S(2))/((-S(8)*a*c + S(2)*b**S(2))*(a + b*x**S(2) + c*x**S(4))) + log(a + b*x**S(2) + c*x**S(4))/(S(4)*c**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)/(a + b*x**S(2) + c*x**S(4))**S(2), x), x, S(2)*a*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(-S(4)*a*c + b**S(2))**(S(3)/2) + x**S(2)*(S(2)*a + b*x**S(2))/((-S(8)*a*c + S(2)*b**S(2))*(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/(a + b*x**S(2) + c*x**S(4))**S(2), x), x, -b*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(-S(4)*a*c + b**S(2))**(S(3)/2) + (S(2)*a + b*x**S(2))/((-S(8)*a*c + S(2)*b**S(2))*(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(a + b*x**S(2) + c*x**S(4))**S(2), x), x, S(2)*c*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(-S(4)*a*c + b**S(2))**(S(3)/2) - (b + S(2)*c*x**S(2))/((-S(8)*a*c + S(2)*b**S(2))*(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*(a + b*x**S(2) + c*x**S(4))**S(2)), x), x, (-S(2)*a*c + b**S(2) + b*c*x**S(2))/(S(2)*a*(-S(4)*a*c + b**S(2))*(a + b*x**S(2) + c*x**S(4))) + b*(-S(6)*a*c + b**S(2))*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*a**S(2)*(-S(4)*a*c + b**S(2))**(S(3)/2)) + log(x)/a**S(2) - log(a + b*x**S(2) + c*x**S(4))/(S(4)*a**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(3)*(a + b*x**S(2) + c*x**S(4))**S(2)), x), x, (-S(2)*a*c + b**S(2) + b*c*x**S(2))/(S(2)*a*x**S(2)*(-S(4)*a*c + b**S(2))*(a + b*x**S(2) + c*x**S(4))) - (-S(3)*a*c + b**S(2))/(a**S(2)*x**S(2)*(-S(4)*a*c + b**S(2))) - S(2)*b*log(x)/a**S(3) + b*log(a + b*x**S(2) + c*x**S(4))/(S(2)*a**S(3)) - (S(6)*a**S(2)*c**S(2) - S(6)*a*b**S(2)*c + b**S(4))*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(a**S(3)*(-S(4)*a*c + b**S(2))**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(8)/(a + b*x**S(2) + c*x**S(4))**S(2), x), x, -b*x**S(3)/(S(2)*c*(-S(4)*a*c + b**S(2))) + x**S(5)*(S(2)*a + b*x**S(2))/((-S(8)*a*c + S(2)*b**S(2))*(a + b*x**S(2) + c*x**S(4))) + x*(-S(10)*a*c + S(3)*b**S(2))/(S(2)*c**S(2)*(-S(4)*a*c + b**S(2))) - sqrt(S(2))*(-S(13)*a*b*c + S(3)*b**S(3) + (S(20)*a**S(2)*c**S(2) - S(19)*a*b**S(2)*c + S(3)*b**S(4))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(4)*c**(S(5)/2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))) - sqrt(S(2))*(-S(13)*a*b*c + S(3)*b**S(3) - (S(20)*a**S(2)*c**S(2) - S(19)*a*b**S(2)*c + S(3)*b**S(4))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(4)*c**(S(5)/2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(6)/(a + b*x**S(2) + c*x**S(4))**S(2), x), x, -b*x/(S(2)*c*(-S(4)*a*c + b**S(2))) + x**S(3)*(S(2)*a + b*x**S(2))/((-S(8)*a*c + S(2)*b**S(2))*(a + b*x**S(2) + c*x**S(4))) + sqrt(S(2))*(-S(6)*a*c + b**S(2) + b*(-S(8)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(4)*c**(S(3)/2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))) + sqrt(S(2))*(-S(6)*a*c + b**S(2) - b*(-S(8)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(4)*c**(S(3)/2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)/(a + b*x**S(2) + c*x**S(4))**S(2), x), x, x*(S(2)*a + b*x**S(2))/((-S(8)*a*c + S(2)*b**S(2))*(a + b*x**S(2) + c*x**S(4))) + sqrt(S(2))*(b - (S(4)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(4)*sqrt(c)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))) + sqrt(S(2))*(S(4)*a*c + b**S(2) + b*sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(4)*sqrt(c)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/(a + b*x**S(2) + c*x**S(4))**S(2), x), x, -sqrt(S(2))*sqrt(c)*(S(2)*b + sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)) + sqrt(S(2))*sqrt(c)*(S(2)*b - sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)) - x*(b + S(2)*c*x**S(2))/((-S(8)*a*c + S(2)*b**S(2))*(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))**(S(-2)), x), x, -sqrt(S(2))*sqrt(c)*(-S(12)*a*c + b**S(2) - b*sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(4)*a*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)) + sqrt(S(2))*sqrt(c)*(-S(12)*a*c + b**S(2) + b*sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(4)*a*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)) + x*(-S(2)*a*c + b**S(2) + b*c*x**S(2))/(S(2)*a*(-S(4)*a*c + b**S(2))*(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*(a + b*x**S(2) + c*x**S(4))**S(2)), x), x, (-S(2)*a*c + b**S(2) + b*c*x**S(2))/(S(2)*a*x*(-S(4)*a*c + b**S(2))*(a + b*x**S(2) + c*x**S(4))) + sqrt(S(2))*sqrt(c)*(-S(16)*a*b*c + S(3)*b**S(3) - (-S(10)*a*c + S(3)*b**S(2))*sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(4)*a**S(2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)) - sqrt(S(2))*sqrt(c)*(-S(16)*a*b*c + S(3)*b**S(3) + (-S(10)*a*c + S(3)*b**S(2))*sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(4)*a**S(2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)) - (-S(10)*a*c + S(3)*b**S(2))/(S(2)*a**S(2)*x*(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(11)/(a + b*x**S(2) + c*x**S(4))**S(3), x), x, -b*x**S(2)*(-S(7)*a*c + b**S(2))/(S(2)*c**S(2)*(-S(4)*a*c + b**S(2))**S(2)) + b*(S(30)*a**S(2)*c**S(2) - S(10)*a*b**S(2)*c + b**S(4))*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*c**S(3)*(-S(4)*a*c + b**S(2))**(S(5)/2)) + x**S(8)*(S(2)*a + b*x**S(2))/((-S(16)*a*c + S(4)*b**S(2))*(a + b*x**S(2) + c*x**S(4))**S(2)) + x**S(4)*(a*(-S(16)*a*c + b**S(2)) + b*x**S(2)*(-S(10)*a*c + b**S(2)))/(S(4)*c*(-S(4)*a*c + b**S(2))**S(2)*(a + b*x**S(2) + c*x**S(4))) + log(a + b*x**S(2) + c*x**S(4))/(S(4)*c**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(9)/(a + b*x**S(2) + c*x**S(4))**S(3), x), x, -S(6)*a**S(2)*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(-S(4)*a*c + b**S(2))**(S(5)/2) - S(3)*a*x**S(2)*(S(2)*a + b*x**S(2))/(S(2)*(-S(4)*a*c + b**S(2))**S(2)*(a + b*x**S(2) + c*x**S(4))) + x**S(6)*(S(2)*a + b*x**S(2))/((-S(16)*a*c + S(4)*b**S(2))*(a + b*x**S(2) + c*x**S(4))**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(7)/(a + b*x**S(2) + c*x**S(4))**S(3), x), x, S(3)*a*b*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(-S(4)*a*c + b**S(2))**(S(5)/2) + S(3)*b*x**S(2)*(S(2)*a + b*x**S(2))/(S(4)*(-S(4)*a*c + b**S(2))**S(2)*(a + b*x**S(2) + c*x**S(4))) - x**S(6)*(b + S(2)*c*x**S(2))/((-S(16)*a*c + S(4)*b**S(2))*(a + b*x**S(2) + c*x**S(4))**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)/(a + b*x**S(2) + c*x**S(4))**S(3), x), x, x**S(2)*(S(2)*a + b*x**S(2))/((-S(16)*a*c + S(4)*b**S(2))*(a + b*x**S(2) + c*x**S(4))**S(2)) + (S(3)*a*b + x**S(2)*(S(2)*a*c + b**S(2)))/(S(2)*(-S(4)*a*c + b**S(2))**S(2)*(a + b*x**S(2) + c*x**S(4))) - (S(2)*a*c + b**S(2))*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(-S(4)*a*c + b**S(2))**(S(5)/2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/(a + b*x**S(2) + c*x**S(4))**S(3), x), x, S(3)*b*c*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(-S(4)*a*c + b**S(2))**(S(5)/2) - S(3)*b*(b + S(2)*c*x**S(2))/(S(4)*(-S(4)*a*c + b**S(2))**S(2)*(a + b*x**S(2) + c*x**S(4))) + (S(2)*a + b*x**S(2))/((-S(16)*a*c + S(4)*b**S(2))*(a + b*x**S(2) + c*x**S(4))**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(a + b*x**S(2) + c*x**S(4))**S(3), x), x, -S(6)*c**S(2)*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(-S(4)*a*c + b**S(2))**(S(5)/2) + S(3)*c*(b + S(2)*c*x**S(2))/(S(2)*(-S(4)*a*c + b**S(2))**S(2)*(a + b*x**S(2) + c*x**S(4))) - (b + S(2)*c*x**S(2))/((-S(16)*a*c + S(4)*b**S(2))*(a + b*x**S(2) + c*x**S(4))**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*(a + b*x**S(2) + c*x**S(4))**S(3)), x), x, (-S(2)*a*c + b**S(2) + b*c*x**S(2))/(S(4)*a*(-S(4)*a*c + b**S(2))*(a + b*x**S(2) + c*x**S(4))**S(2)) + (S(16)*a**S(2)*c**S(2) - S(15)*a*b**S(2)*c + S(2)*b**S(4) + S(2)*b*c*x**S(2)*(-S(7)*a*c + b**S(2)))/(S(4)*a**S(2)*(-S(4)*a*c + b**S(2))**S(2)*(a + b*x**S(2) + c*x**S(4))) + b*(S(30)*a**S(2)*c**S(2) - S(10)*a*b**S(2)*c + b**S(4))*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*a**S(3)*(-S(4)*a*c + b**S(2))**(S(5)/2)) + log(x)/a**S(3) - log(a + b*x**S(2) + c*x**S(4))/(S(4)*a**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(3)*(a + b*x**S(2) + c*x**S(4))**S(3)), x), x, (-S(2)*a*c + b**S(2) + b*c*x**S(2))/(S(4)*a*x**S(2)*(-S(4)*a*c + b**S(2))*(a + b*x**S(2) + c*x**S(4))**S(2)) + (S(20)*a**S(2)*c**S(2) - S(20)*a*b**S(2)*c + S(3)*b**S(4) + S(3)*b*c*x**S(2)*(-S(6)*a*c + b**S(2)))/(S(4)*a**S(2)*x**S(2)*(-S(4)*a*c + b**S(2))**S(2)*(a + b*x**S(2) + c*x**S(4))) - (S(30)*a**S(2)*c**S(2) - S(21)*a*b**S(2)*c + S(3)*b**S(4))/(S(2)*a**S(3)*x**S(2)*(-S(4)*a*c + b**S(2))**S(2)) - S(3)*b*log(x)/a**S(4) + S(3)*b*log(a + b*x**S(2) + c*x**S(4))/(S(4)*a**S(4)) - (-S(60)*a**S(3)*c**S(3) + S(90)*a**S(2)*b**S(2)*c**S(2) - S(30)*a*b**S(4)*c + S(3)*b**S(6))*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*a**S(4)*(-S(4)*a*c + b**S(2))**(S(5)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(10)/(a + b*x**S(2) + c*x**S(4))**S(3), x), x, -S(3)*b*x*(-S(8)*a*c + b**S(2))/(S(8)*c**S(2)*(-S(4)*a*c + b**S(2))**S(2)) + x**S(7)*(S(2)*a + b*x**S(2))/((-S(16)*a*c + S(4)*b**S(2))*(a + b*x**S(2) + c*x**S(4))**S(2)) + x**S(5)*(S(12)*a*b - x**S(2)*(-S(28)*a*c + b**S(2)))/(S(8)*(-S(4)*a*c + b**S(2))**S(2)*(a + b*x**S(2) + c*x**S(4))) + x**S(3)*(-S(28)*a*c + b**S(2))/(S(8)*c*(-S(4)*a*c + b**S(2))**S(2)) + sqrt(S(2))*(S(84)*a**S(2)*c**S(2) - S(27)*a*b**S(2)*c + S(3)*b**S(4) + S(3)*(S(44)*a**S(2)*b*c**S(2) - S(11)*a*b**S(3)*c + b**S(5))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(16)*c**(S(5)/2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**S(2)) + sqrt(S(2))*(S(84)*a**S(2)*c**S(2) - S(27)*a*b**S(2)*c + S(3)*b**S(4) - S(3)*b*(S(44)*a**S(2)*c**S(2) - S(11)*a*b**S(2)*c + b**S(4))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(16)*c**(S(5)/2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(8)/(a + b*x**S(2) + c*x**S(4))**S(3), x), x, x**S(5)*(S(2)*a + b*x**S(2))/((-S(16)*a*c + S(4)*b**S(2))*(a + b*x**S(2) + c*x**S(4))**S(2)) + x**S(3)*(S(12)*a*b + x**S(2)*(S(20)*a*c + b**S(2)))/(S(8)*(-S(4)*a*c + b**S(2))**S(2)*(a + b*x**S(2) + c*x**S(4))) - x*(S(20)*a*c + b**S(2))/(S(8)*c*(-S(4)*a*c + b**S(2))**S(2)) + sqrt(S(2))*(-S(16)*a*b*c + b**S(3) + (-S(40)*a**S(2)*c**S(2) - S(18)*a*b**S(2)*c + b**S(4))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(16)*c**(S(3)/2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**S(2)) + sqrt(S(2))*(-S(16)*a*b*c + b**S(3) - (-S(40)*a**S(2)*c**S(2) - S(18)*a*b**S(2)*c + b**S(4))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(16)*c**(S(3)/2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(6)/(a + b*x**S(2) + c*x**S(4))**S(3), x), x, x**S(3)*(S(2)*a + b*x**S(2))/((-S(16)*a*c + S(4)*b**S(2))*(a + b*x**S(2) + c*x**S(4))**S(2)) + S(3)*x*(S(4)*a*b + x**S(2)*(S(4)*a*c + b**S(2)))/(S(8)*(-S(4)*a*c + b**S(2))**S(2)*(a + b*x**S(2) + c*x**S(4))) + sqrt(S(2))*(S(12)*a*c + S(3)*b**S(2) + S(3)*b*(S(12)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(16)*sqrt(c)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**S(2)) + sqrt(S(2))*(S(12)*a*c + S(3)*b**S(2) - S(3)*b*(S(12)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(16)*sqrt(c)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)/(a + b*x**S(2) + c*x**S(4))**S(3), x), x, -S(3)*sqrt(S(2))*sqrt(c)*(S(4)*a*c + S(3)*b**S(2) + S(2)*b*sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(8)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(5)/2)) + S(3)*sqrt(S(2))*sqrt(c)*(S(4)*a*c + S(3)*b**S(2) - S(2)*b*sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(8)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(5)/2)) + x*(S(2)*a + b*x**S(2))/((-S(16)*a*c + S(4)*b**S(2))*(a + b*x**S(2) + c*x**S(4))**S(2)) - x*(-S(4)*a*c + S(7)*b**S(2) + S(12)*b*c*x**S(2))/(S(8)*(-S(4)*a*c + b**S(2))**S(2)*(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/(a + b*x**S(2) + c*x**S(4))**S(3), x), x, -x*(b + S(2)*c*x**S(2))/((-S(16)*a*c + S(4)*b**S(2))*(a + b*x**S(2) + c*x**S(4))**S(2)) + sqrt(S(2))*sqrt(c)*(S(20)*a*c + b**S(2) - b*(-S(52)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(16)*a*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**S(2)) + sqrt(S(2))*sqrt(c)*(S(20)*a*c + b**S(2) + b*(-S(52)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(16)*a*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**S(2)) + x*(b*(S(8)*a*c + b**S(2)) + c*x**S(2)*(S(20)*a*c + b**S(2)))/(S(8)*a*(-S(4)*a*c + b**S(2))**S(2)*(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))**(S(-3)), x), x, x*(-S(2)*a*c + b**S(2) + b*c*x**S(2))/(S(4)*a*(-S(4)*a*c + b**S(2))*(a + b*x**S(2) + c*x**S(4))**S(2)) + S(3)*sqrt(S(2))*sqrt(c)*(-S(8)*a*b*c + b**S(3) - (S(56)*a**S(2)*c**S(2) - S(10)*a*b**S(2)*c + b**S(4))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(16)*a**S(2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**S(2)) + S(3)*sqrt(S(2))*sqrt(c)*(S(56)*a**S(2)*c**S(2) - S(10)*a*b**S(2)*c + b**S(4) + b*(-S(8)*a*c + b**S(2))*sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(16)*a**S(2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(5)/2)) + x*(S(3)*b*c*x**S(2)*(-S(8)*a*c + b**S(2)) + (-S(7)*a*c + b**S(2))*(-S(4)*a*c + S(3)*b**S(2)))/(S(8)*a**S(2)*(-S(4)*a*c + b**S(2))**S(2)*(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*(a + b*x**S(2) + c*x**S(4))**S(3)), x), x, (-S(2)*a*c + b**S(2) + b*c*x**S(2))/(S(4)*a*x*(-S(4)*a*c + b**S(2))*(a + b*x**S(2) + c*x**S(4))**S(2)) + (S(36)*a**S(2)*c**S(2) - S(35)*a*b**S(2)*c + S(5)*b**S(4) + b*c*x**S(2)*(-S(32)*a*c + S(5)*b**S(2)))/(S(8)*a**S(2)*x*(-S(4)*a*c + b**S(2))**S(2)*(a + b*x**S(2) + c*x**S(4))) - S(3)*sqrt(S(2))*sqrt(c)*((-S(12)*a*c + S(5)*b**S(2))*(-S(5)*a*c + b**S(2)) - (S(124)*a**S(2)*b*c**S(2) - S(47)*a*b**S(3)*c + S(5)*b**S(5))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(16)*a**S(3)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**S(2)) - S(3)*sqrt(S(2))*sqrt(c)*(b*(S(124)*a**S(2)*c**S(2) - S(47)*a*b**S(2)*c + S(5)*b**S(4))/sqrt(-S(4)*a*c + b**S(2)) + (-S(12)*a*c + S(5)*b**S(2))*(-S(5)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(16)*a**S(3)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**S(2)) - (-S(36)*a*c + S(15)*b**S(2))*(-S(5)*a*c + b**S(2))/(S(8)*a**S(3)*x*(-S(4)*a*c + b**S(2))**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)/(a - b*x**S(2) + c*x**S(4)), x), x, b*log(a - b*x**S(2) + c*x**S(4))/(S(4)*c**S(2)) + x**S(2)/(S(2)*c) + (-S(2)*a*c + b**S(2))*atanh((b - S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*c**S(2)*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/(a - b*x**S(2) + c*x**S(4)), x), x, b*atanh((b - S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*c*sqrt(-S(4)*a*c + b**S(2))) + log(a - b*x**S(2) + c*x**S(4))/(S(4)*c), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(a - b*x**S(2) + c*x**S(4)), x), x, atanh((b - S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/sqrt(-S(4)*a*c + b**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*(a - b*x**S(2) + c*x**S(4))), x), x, b*atanh((b - S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*a*sqrt(-S(4)*a*c + b**S(2))) + log(x)/a - log(a - b*x**S(2) + c*x**S(4))/(S(4)*a), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(3)*(a - b*x**S(2) + c*x**S(4))), x), x, -S(1)/(S(2)*a*x**S(2)) + b*log(x)/a**S(2) - b*log(a - b*x**S(2) + c*x**S(4))/(S(4)*a**S(2)) + (-S(2)*a*c + b**S(2))*atanh((b - S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*a**S(2)*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)/(a - b*x**S(2) + c*x**S(4)), x), x, x/c - sqrt(S(2))*(b - (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atanh(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*c**(S(3)/2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))) - sqrt(S(2))*(b + (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atanh(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*c**(S(3)/2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/(a - b*x**S(2) + c*x**S(4)), x), x, sqrt(S(2))*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*atanh(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*sqrt(c)*sqrt(-S(4)*a*c + b**S(2))) - sqrt(S(2))*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*atanh(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*sqrt(c)*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(a - b*x**S(2) + c*x**S(4)), x), x, -sqrt(S(2))*sqrt(c)*atanh(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*sqrt(-S(4)*a*c + b**S(2))) + sqrt(S(2))*sqrt(c)*atanh(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*(a - b*x**S(2) + c*x**S(4))), x), x, sqrt(S(2))*sqrt(c)*(-b/sqrt(-S(4)*a*c + b**S(2)) + S(1))*atanh(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*a*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))) + sqrt(S(2))*sqrt(c)*(b/sqrt(-S(4)*a*c + b**S(2)) + S(1))*atanh(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*a*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))) - S(1)/(a*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)/(a*x**S(4) + S(2)*a*x**S(2) + a + b), x), x, x**S(2)/(S(2)*a) - log(a*x**S(4) + S(2)*a*x**S(2) + a + b)/(S(2)*a) + (a - b)*atan(sqrt(a)*(x**S(2) + S(1))/sqrt(b))/(S(2)*a**(S(3)/2)*sqrt(b)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/(a*x**S(4) + S(2)*a*x**S(2) + a + b), x), x, log(a*x**S(4) + S(2)*a*x**S(2) + a + b)/(S(4)*a) - atan(sqrt(a)*(x**S(2) + S(1))/sqrt(b))/(S(2)*sqrt(a)*sqrt(b)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(a*x**S(4) + S(2)*a*x**S(2) + a + b), x), x, atan(sqrt(a)*(x**S(2) + S(1))/sqrt(b))/(S(2)*sqrt(a)*sqrt(b)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*(a*x**S(4) + S(2)*a*x**S(2) + a + b)), x), x, -sqrt(a)*atan(sqrt(a)*(x**S(2) + S(1))/sqrt(b))/(S(2)*sqrt(b)*(a + b)) - log(a*x**S(4) + S(2)*a*x**S(2) + a + b)/(S(4)*a + S(4)*b) + log(x)/(a + b), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(3)*(a*x**S(4) + S(2)*a*x**S(2) + a + b)), x), x, sqrt(a)*(a - b)*atan(sqrt(a)*(x**S(2) + S(1))/sqrt(b))/(S(2)*sqrt(b)*(a + b)**S(2)) - S(2)*a*log(x)/(a + b)**S(2) + a*log(a*x**S(4) + S(2)*a*x**S(2) + a + b)/(S(2)*(a + b)**S(2)) - S(1)/(x**S(2)*(S(2)*a + S(2)*b)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)/(a*x**S(4) + S(2)*a*x**S(2) + a + b), x), x, (S(2)*sqrt(-a) + (a - b)/sqrt(b))*atan(x*(-a)**(S(1)/4)/sqrt(-sqrt(b) + sqrt(-a)))/(S(2)*(-a)**(S(5)/4)*sqrt(-sqrt(b) + sqrt(-a))) - (a - S(2)*sqrt(b)*sqrt(-a) - b)*atan(x*(-a)**(S(1)/4)/sqrt(sqrt(b) + sqrt(-a)))/(S(2)*sqrt(b)*(-a)**(S(5)/4)*sqrt(sqrt(b) + sqrt(-a))) + x/a, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/(a*x**S(4) + S(2)*a*x**S(2) + a + b), x), x, sqrt(-sqrt(b) + sqrt(-a))*atan(x*(-a)**(S(1)/4)/sqrt(-sqrt(b) + sqrt(-a)))/(S(2)*sqrt(b)*(-a)**(S(3)/4)) - sqrt(sqrt(b) + sqrt(-a))*atan(x*(-a)**(S(1)/4)/sqrt(sqrt(b) + sqrt(-a)))/(S(2)*sqrt(b)*(-a)**(S(3)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(a*x**S(4) + S(2)*a*x**S(2) + a + b), x), x, atan(x*(-a)**(S(1)/4)/sqrt(sqrt(b) + sqrt(-a)))/(S(2)*sqrt(b)*(-a)**(S(1)/4)*sqrt(sqrt(b) + sqrt(-a))) - atan(x*(-a)**(S(1)/4)/sqrt(-sqrt(b) + sqrt(-a)))/(S(2)*sqrt(b)*(-a)**(S(1)/4)*sqrt(-sqrt(b) + sqrt(-a))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*(a*x**S(4) + S(2)*a*x**S(2) + a + b)), x), x, -S(1)/(x*(a + b)) + (-a)**(S(1)/4)*(-sqrt(b) + sqrt(-a))*atan(x*(-a)**(S(1)/4)/sqrt(sqrt(b) + sqrt(-a)))/(S(2)*sqrt(b)*(a + b)*sqrt(sqrt(b) + sqrt(-a))) - (-a)**(S(1)/4)*(sqrt(b) + sqrt(-a))*atan(x*(-a)**(S(1)/4)/sqrt(-sqrt(b) + sqrt(-a)))/(S(2)*sqrt(b)*(a + b)*sqrt(-sqrt(b) + sqrt(-a))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(a**S(2) + S(2)*a*x**S(2) + b + x**S(4)), x), x, -atan(x/sqrt(a + sqrt(-b)))/(S(2)*sqrt(-b)*sqrt(a + sqrt(-b))) + atan(x/sqrt(a - sqrt(-b)))/(S(2)*sqrt(-b)*sqrt(a - sqrt(-b))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(a**S(2) + S(2)*a*x**S(2) + x**S(4) + S(-1)), x), x, -atan(x/sqrt(a + S(1)))/(S(2)*sqrt(a + S(1))) - atanh(x/sqrt(-a + S(1)))/(S(2)*sqrt(-a + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(a**S(2) + S(2)*a*x**S(2) + x**S(4) + S(1)), x), x, -sqrt(S(2))*atan((-sqrt(S(2))*x + sqrt(-a + sqrt(a**S(2) + S(1))))/sqrt(a + sqrt(a**S(2) + S(1))))/(S(4)*sqrt(a + sqrt(a**S(2) + S(1)))*sqrt(a**S(2) + S(1))) + sqrt(S(2))*atan((sqrt(S(2))*x + sqrt(-a + sqrt(a**S(2) + S(1))))/sqrt(a + sqrt(a**S(2) + S(1))))/(S(4)*sqrt(a + sqrt(a**S(2) + S(1)))*sqrt(a**S(2) + S(1))) - sqrt(S(2))*log(x**S(2) - sqrt(S(2))*x*sqrt(-a + sqrt(a**S(2) + S(1))) + sqrt(a**S(2) + S(1)))/(S(8)*sqrt(-a + sqrt(a**S(2) + S(1)))*sqrt(a**S(2) + S(1))) + sqrt(S(2))*log(x**S(2) + sqrt(S(2))*x*sqrt(-a + sqrt(a**S(2) + S(1))) + sqrt(a**S(2) + S(1)))/(S(8)*sqrt(-a + sqrt(a**S(2) + S(1)))*sqrt(a**S(2) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(4) - S(5)*x**S(2) + S(4)), x), x, -atanh(x/S(2))/S(6) + atanh(x)/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(4) + S(4)*x**S(2) + S(3)), x), x, atan(x)/S(2) - sqrt(S(3))*atan(sqrt(S(3))*x/S(3))/S(6), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(4) + S(5)*x**S(2) + S(9)), x), x, -log(x**S(2) - x + S(3))/S(12) + log(x**S(2) + x + S(3))/S(12) - sqrt(S(11))*atan(sqrt(S(11))*(-S(2)*x + S(1))/S(11))/S(66) + sqrt(S(11))*atan(sqrt(S(11))*(S(2)*x + S(1))/S(11))/S(66), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(4) - x**S(2) + S(1)), x), x, -sqrt(S(3))*log(x**S(2) - sqrt(S(3))*x + S(1))/S(12) + sqrt(S(3))*log(x**S(2) + sqrt(S(3))*x + S(1))/S(12) + atan(S(2)*x - sqrt(S(3)))/S(2) + atan(S(2)*x + sqrt(S(3)))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(4) + S(2)*x**S(2) + S(2)), x), x, -log(x**S(2) - x*sqrt(S(-2) + S(2)*sqrt(S(2))) + sqrt(S(2)))/(S(8)*sqrt(S(-1) + sqrt(S(2)))) + log(x**S(2) + x*sqrt(S(-2) + S(2)*sqrt(S(2))) + sqrt(S(2)))/(S(8)*sqrt(S(-1) + sqrt(S(2)))) - sqrt(S(-1) + sqrt(S(2)))*atan((-S(2)*x + sqrt(S(-2) + S(2)*sqrt(S(2))))/sqrt(S(2) + S(2)*sqrt(S(2))))/S(4) + sqrt(S(-1) + sqrt(S(2)))*atan((S(2)*x + sqrt(S(-2) + S(2)*sqrt(S(2))))/sqrt(S(2) + S(2)*sqrt(S(2))))/S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(x**S(4) + x**S(2) + S(1)), x), x, sqrt(S(3))*atan(sqrt(S(3))*(S(2)*x**S(2) + S(1))/S(3))/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(x**S(4) + S(2)*x**S(2) + S(10)), x), x, atan(x**S(2)/S(3) + S(1)/3)/S(6), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/(x**S(4) + S(9)*x**S(2) + S(20)), x), x, -S(2)*atan(x/S(2)) + sqrt(S(5))*atan(sqrt(S(5))*x/S(5)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/(x**S(4) - x**S(2) + S(1)), x), x, sqrt(S(3))*log(x**S(2) - sqrt(S(3))*x + S(1))/S(12) - sqrt(S(3))*log(x**S(2) + sqrt(S(3))*x + S(1))/S(12) + atan(S(2)*x - sqrt(S(3)))/S(2) + atan(S(2)*x + sqrt(S(3)))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/(x**S(4) - S(2)*x**S(2) + S(2)), x), x, log(x**S(2) - x*sqrt(S(2) + S(2)*sqrt(S(2))) + sqrt(S(2)))/(S(4)*sqrt(S(2) + S(2)*sqrt(S(2)))) - log(x**S(2) + x*sqrt(S(2) + S(2)*sqrt(S(2))) + sqrt(S(2)))/(S(4)*sqrt(S(2) + S(2)*sqrt(S(2)))) - sqrt(S(1)/2 + sqrt(S(2))/S(2))*atan((-S(2)*x + sqrt(S(2) + S(2)*sqrt(S(2))))/sqrt(S(-2) + S(2)*sqrt(S(2))))/S(2) + sqrt(S(1)/2 + sqrt(S(2))/S(2))*atan((S(2)*x + sqrt(S(2) + S(2)*sqrt(S(2))))/sqrt(S(-2) + S(2)*sqrt(S(2))))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(7)*sqrt(a + b*x**S(2) + c*x**S(4)), x), x, -b*(b + S(2)*c*x**S(2))*(-S(12)*a*c + S(7)*b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))/(S(256)*c**S(4)) + b*(-S(12)*a*c + S(7)*b**S(2))*(-S(4)*a*c + b**S(2))*atanh((b + S(2)*c*x**S(2))/(S(2)*sqrt(c)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(512)*c**(S(9)/2)) + x**S(4)*(a + b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(10)*c) + (a + b*x**S(2) + c*x**S(4))**(S(3)/2)*(-S(32)*a*c + S(35)*b**S(2) - S(42)*b*c*x**S(2))/(S(480)*c**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)*sqrt(a + b*x**S(2) + c*x**S(4)), x), x, -S(5)*b*(a + b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(48)*c**S(2)) + x**S(2)*(a + b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(8)*c) + (b + S(2)*c*x**S(2))*(-S(4)*a*c + S(5)*b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))/(S(128)*c**S(3)) - (-S(4)*a*c + b**S(2))*(-S(4)*a*c + S(5)*b**S(2))*atanh((b + S(2)*c*x**S(2))/(S(2)*sqrt(c)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(256)*c**(S(7)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*sqrt(a + b*x**S(2) + c*x**S(4)), x), x, -b*(b + S(2)*c*x**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))/(S(16)*c**S(2)) + b*(-S(4)*a*c + b**S(2))*atanh((b + S(2)*c*x**S(2))/(S(2)*sqrt(c)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(32)*c**(S(5)/2)) + (a + b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(6)*c), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*sqrt(a + b*x**S(2) + c*x**S(4)), x), x, (b + S(2)*c*x**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))/(S(8)*c) - (-S(4)*a*c + b**S(2))*atanh((b + S(2)*c*x**S(2))/(S(2)*sqrt(c)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(16)*c**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a + b*x**S(2) + c*x**S(4))/x, x), x, -sqrt(a)*atanh((S(2)*a + b*x**S(2))/(S(2)*sqrt(a)*sqrt(a + b*x**S(2) + c*x**S(4))))/S(2) + b*atanh((b + S(2)*c*x**S(2))/(S(2)*sqrt(c)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(4)*sqrt(c)) + sqrt(a + b*x**S(2) + c*x**S(4))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a + b*x**S(2) + c*x**S(4))/x**S(3), x), x, sqrt(c)*atanh((b + S(2)*c*x**S(2))/(S(2)*sqrt(c)*sqrt(a + b*x**S(2) + c*x**S(4))))/S(2) - sqrt(a + b*x**S(2) + c*x**S(4))/(S(2)*x**S(2)) - b*atanh((S(2)*a + b*x**S(2))/(S(2)*sqrt(a)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(4)*sqrt(a)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a + b*x**S(2) + c*x**S(4))/x**S(5), x), x, -(S(2)*a + b*x**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))/(S(8)*a*x**S(4)) + (-S(4)*a*c + b**S(2))*atanh((S(2)*a + b*x**S(2))/(S(2)*sqrt(a)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(16)*a**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a + b*x**S(2) + c*x**S(4))/x**S(7), x), x, -(a + b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(6)*a*x**S(6)) + b*(S(2)*a + b*x**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))/(S(16)*a**S(2)*x**S(4)) - b*(-S(4)*a*c + b**S(2))*atanh((S(2)*a + b*x**S(2))/(S(2)*sqrt(a)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(32)*a**(S(5)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a + b*x**S(2) + c*x**S(4))/x**S(9), x), x, -(a + b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(8)*a*x**S(8)) + S(5)*b*(a + b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(48)*a**S(2)*x**S(6)) - (S(2)*a + b*x**S(2))*(-S(4)*a*c + S(5)*b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))/(S(128)*a**S(3)*x**S(4)) + (-S(4)*a*c + b**S(2))*(-S(4)*a*c + S(5)*b**S(2))*atanh((S(2)*a + b*x**S(2))/(S(2)*sqrt(a)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(256)*a**(S(7)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a + b*x**S(2) + c*x**S(4))/x**S(11), x), x, -(a + b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(10)*a*x**S(10)) + S(7)*b*(a + b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(80)*a**S(2)*x**S(8)) - (-S(32)*a*c + S(35)*b**S(2))*(a + b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(480)*a**S(3)*x**S(6)) + b*(S(2)*a + b*x**S(2))*(-S(12)*a*c + S(7)*b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))/(S(256)*a**S(4)*x**S(4)) - b*(-S(12)*a*c + S(7)*b**S(2))*(-S(4)*a*c + b**S(2))*atanh((S(2)*a + b*x**S(2))/(S(2)*sqrt(a)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(512)*a**(S(9)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)*sqrt(a + b*x**S(2) + c*x**S(4)), x), x, -a**(S(1)/4)*b*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(-S(29)*a*c + S(8)*b**S(2))*elliptic_e(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(105)*c**(S(11)/4)*sqrt(a + b*x**S(2) + c*x**S(4))) + a**(S(1)/4)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(S(2)*sqrt(a)*sqrt(c)*(-S(5)*a*c + S(2)*b**S(2)) - S(29)*a*b*c + S(8)*b**S(3))*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(210)*c**(S(11)/4)*sqrt(a + b*x**S(2) + c*x**S(4))) + b*x*(-S(29)*a*c + S(8)*b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))/(S(105)*c**(S(5)/2)*(sqrt(a) + sqrt(c)*x**S(2))) + x**S(3)*(b + S(5)*c*x**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))/(S(35)*c) - x*(-S(10)*a*c + S(4)*b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))/(S(105)*c**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*sqrt(a + b*x**S(2) + c*x**S(4)), x), x, S(2)*a**(S(1)/4)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(-S(3)*a*c + b**S(2))*elliptic_e(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(15)*c**(S(7)/4)*sqrt(a + b*x**S(2) + c*x**S(4))) - a**(S(1)/4)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(sqrt(a)*b*sqrt(c) - S(6)*a*c + S(2)*b**S(2))*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(30)*c**(S(7)/4)*sqrt(a + b*x**S(2) + c*x**S(4))) + x*(b + S(3)*c*x**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))/(S(15)*c) - x*(-S(6)*a*c + S(2)*b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))/(S(15)*c**(S(3)/2)*(sqrt(a) + sqrt(c)*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a + b*x**S(2) + c*x**S(4)), x), x, -a**(S(1)/4)*b*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*elliptic_e(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(3)*c**(S(3)/4)*sqrt(a + b*x**S(2) + c*x**S(4))) + a**(S(1)/4)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(S(2)*sqrt(a)*sqrt(c) + b)*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(6)*c**(S(3)/4)*sqrt(a + b*x**S(2) + c*x**S(4))) + b*x*sqrt(a + b*x**S(2) + c*x**S(4))/(S(3)*sqrt(c)*(sqrt(a) + sqrt(c)*x**S(2))) + x*sqrt(a + b*x**S(2) + c*x**S(4))/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a + b*x**S(2) + c*x**S(4))/x**S(2), x), x, -S(2)*a**(S(1)/4)*c**(S(1)/4)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*elliptic_e(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/sqrt(a + b*x**S(2) + c*x**S(4)) + S(2)*sqrt(c)*x*sqrt(a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2)) - sqrt(a + b*x**S(2) + c*x**S(4))/x + sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(S(2)*sqrt(a)*sqrt(c) + b)*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(2)*a**(S(1)/4)*c**(S(1)/4)*sqrt(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a + b*x**S(2) + c*x**S(4))/x**S(4), x), x, -sqrt(a + b*x**S(2) + c*x**S(4))/(S(3)*x**S(3)) + b*sqrt(c)*x*sqrt(a + b*x**S(2) + c*x**S(4))/(S(3)*a*(sqrt(a) + sqrt(c)*x**S(2))) - b*sqrt(a + b*x**S(2) + c*x**S(4))/(S(3)*a*x) - b*c**(S(1)/4)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*elliptic_e(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(3)*a**(S(3)/4)*sqrt(a + b*x**S(2) + c*x**S(4))) + c**(S(1)/4)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(S(2)*sqrt(a)*sqrt(c) + b)*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(6)*a**(S(3)/4)*sqrt(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a + b*x**S(2) + c*x**S(4))/x**S(6), x), x, -sqrt(a + b*x**S(2) + c*x**S(4))/(S(5)*x**S(5)) - b*sqrt(a + b*x**S(2) + c*x**S(4))/(S(15)*a*x**S(3)) - S(2)*sqrt(c)*x*(-S(3)*a*c + b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))/(S(15)*a**S(2)*(sqrt(a) + sqrt(c)*x**S(2))) + (-S(6)*a*c + S(2)*b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))/(S(15)*a**S(2)*x) + S(2)*c**(S(1)/4)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(-S(3)*a*c + b**S(2))*elliptic_e(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(15)*a**(S(7)/4)*sqrt(a + b*x**S(2) + c*x**S(4))) - c**(S(1)/4)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(sqrt(a)*b*sqrt(c) - S(6)*a*c + S(2)*b**S(2))*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(30)*a**(S(7)/4)*sqrt(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(7)*(a + b*x**S(2) + c*x**S(4))**(S(3)/2), x), x, -b*(b + S(2)*c*x**S(2))*(-S(4)*a*c + S(3)*b**S(2))*(a + b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(256)*c**S(4)) + S(3)*b*(b + S(2)*c*x**S(2))*(-S(4)*a*c + b**S(2))*(-S(4)*a*c + S(3)*b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))/(S(2048)*c**S(5)) - S(3)*b*(-S(4)*a*c + b**S(2))**S(2)*(-S(4)*a*c + S(3)*b**S(2))*atanh((b + S(2)*c*x**S(2))/(S(2)*sqrt(c)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(4096)*c**(S(11)/2)) + x**S(4)*(a + b*x**S(2) + c*x**S(4))**(S(5)/2)/(S(14)*c) + (a + b*x**S(2) + c*x**S(4))**(S(5)/2)*(-S(16)*a*c + S(21)*b**S(2) - S(30)*b*c*x**S(2))/(S(560)*c**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)*(a + b*x**S(2) + c*x**S(4))**(S(3)/2), x), x, -S(7)*b*(a + b*x**S(2) + c*x**S(4))**(S(5)/2)/(S(120)*c**S(2)) + x**S(2)*(a + b*x**S(2) + c*x**S(4))**(S(5)/2)/(S(12)*c) + (b + S(2)*c*x**S(2))*(-S(4)*a*c + S(7)*b**S(2))*(a + b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(384)*c**S(3)) - (b + S(2)*c*x**S(2))*(-S(4)*a*c + b**S(2))*(-S(4)*a*c + S(7)*b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))/(S(1024)*c**S(4)) + (-S(4)*a*c + b**S(2))**S(2)*(-S(4)*a*c + S(7)*b**S(2))*atanh((b + S(2)*c*x**S(2))/(S(2)*sqrt(c)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(2048)*c**(S(9)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*(a + b*x**S(2) + c*x**S(4))**(S(3)/2), x), x, -b*(b + S(2)*c*x**S(2))*(a + b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(32)*c**S(2)) + S(3)*b*(b + S(2)*c*x**S(2))*(-S(4)*a*c + b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))/(S(256)*c**S(3)) - S(3)*b*(-S(4)*a*c + b**S(2))**S(2)*atanh((b + S(2)*c*x**S(2))/(S(2)*sqrt(c)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(512)*c**(S(7)/2)) + (a + b*x**S(2) + c*x**S(4))**(S(5)/2)/(S(10)*c), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(a + b*x**S(2) + c*x**S(4))**(S(3)/2), x), x, (b + S(2)*c*x**S(2))*(a + b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(16)*c) - (b + S(2)*c*x**S(2))*(-S(12)*a*c + S(3)*b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))/(S(128)*c**S(2)) + S(3)*(-S(4)*a*c + b**S(2))**S(2)*atanh((b + S(2)*c*x**S(2))/(S(2)*sqrt(c)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(256)*c**(S(5)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))**(S(3)/2)/x, x), x, -a**(S(3)/2)*atanh((S(2)*a + b*x**S(2))/(S(2)*sqrt(a)*sqrt(a + b*x**S(2) + c*x**S(4))))/S(2) - b*(-S(12)*a*c + b**S(2))*atanh((b + S(2)*c*x**S(2))/(S(2)*sqrt(c)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(32)*c**(S(3)/2)) + (a + b*x**S(2) + c*x**S(4))**(S(3)/2)/S(6) + sqrt(a + b*x**S(2) + c*x**S(4))*(S(8)*a*c + b**S(2) + S(2)*b*c*x**S(2))/(S(16)*c), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))**(S(3)/2)/x**S(3), x), x, -S(3)*sqrt(a)*b*atanh((S(2)*a + b*x**S(2))/(S(2)*sqrt(a)*sqrt(a + b*x**S(2) + c*x**S(4))))/S(4) + (S(9)*b/S(8) + S(3)*c*x**S(2)/S(4))*sqrt(a + b*x**S(2) + c*x**S(4)) - (a + b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(2)*x**S(2)) + (S(12)*a*c + S(3)*b**S(2))*atanh((b + S(2)*c*x**S(2))/(S(2)*sqrt(c)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(16)*sqrt(c)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))**(S(3)/2)/x**S(5), x), x, S(3)*b*sqrt(c)*atanh((b + S(2)*c*x**S(2))/(S(2)*sqrt(c)*sqrt(a + b*x**S(2) + c*x**S(4))))/S(4) - (S(3)*b - S(6)*c*x**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))/(S(8)*x**S(2)) - (a + b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(4)*x**S(4)) - (S(12)*a*c + S(3)*b**S(2))*atanh((S(2)*a + b*x**S(2))/(S(2)*sqrt(a)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(16)*sqrt(a)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))**(S(3)/2)/x**S(7), x), x, c**(S(3)/2)*atanh((b + S(2)*c*x**S(2))/(S(2)*sqrt(c)*sqrt(a + b*x**S(2) + c*x**S(4))))/S(2) - (a + b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(6)*x**S(6)) - (S(2)*a*b + x**S(2)*(S(8)*a*c + b**S(2)))*sqrt(a + b*x**S(2) + c*x**S(4))/(S(16)*a*x**S(4)) + b*(-S(12)*a*c + b**S(2))*atanh((S(2)*a + b*x**S(2))/(S(2)*sqrt(a)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(32)*a**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))**(S(3)/2)/x**S(9), x), x, -(S(2)*a + b*x**S(2))*(a + b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(16)*a*x**S(8)) + (S(2)*a + b*x**S(2))*(-S(12)*a*c + S(3)*b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))/(S(128)*a**S(2)*x**S(4)) - S(3)*(-S(4)*a*c + b**S(2))**S(2)*atanh((S(2)*a + b*x**S(2))/(S(2)*sqrt(a)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(256)*a**(S(5)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))**(S(3)/2)/x**S(11), x), x, -(a + b*x**S(2) + c*x**S(4))**(S(5)/2)/(S(10)*a*x**S(10)) + b*(S(2)*a + b*x**S(2))*(a + b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(32)*a**S(2)*x**S(8)) - S(3)*b*(S(2)*a + b*x**S(2))*(-S(4)*a*c + b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))/(S(256)*a**S(3)*x**S(4)) + S(3)*b*(-S(4)*a*c + b**S(2))**S(2)*atanh((S(2)*a + b*x**S(2))/(S(2)*sqrt(a)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(512)*a**(S(7)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))**(S(3)/2)/x**S(13), x), x, -(a + b*x**S(2) + c*x**S(4))**(S(5)/2)/(S(12)*a*x**S(12)) + S(7)*b*(a + b*x**S(2) + c*x**S(4))**(S(5)/2)/(S(120)*a**S(2)*x**S(10)) - (S(2)*a + b*x**S(2))*(-S(4)*a*c + S(7)*b**S(2))*(a + b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(384)*a**S(3)*x**S(8)) + (S(2)*a + b*x**S(2))*(-S(4)*a*c + b**S(2))*(-S(4)*a*c + S(7)*b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))/(S(1024)*a**S(4)*x**S(4)) - (-S(4)*a*c + b**S(2))**S(2)*(-S(4)*a*c + S(7)*b**S(2))*atanh((S(2)*a + b*x**S(2))/(S(2)*sqrt(a)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(2048)*a**(S(9)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)*(a + b*x**S(2) + c*x**S(4))**(S(3)/2), x), x, S(8)*a**(S(1)/4)*b*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(-S(9)*a*c + S(2)*b**S(2))*(-S(3)*a*c + b**S(2))*elliptic_e(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(1155)*c**(S(15)/4)*sqrt(a + b*x**S(2) + c*x**S(4))) - a**(S(1)/4)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(sqrt(a)*sqrt(c)*(S(60)*a**S(2)*c**S(2) - S(51)*a*b**S(2)*c + S(8)*b**S(4)) + S(8)*b*(-S(9)*a*c + S(2)*b**S(2))*(-S(3)*a*c + b**S(2)))*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(2310)*c**(S(15)/4)*sqrt(a + b*x**S(2) + c*x**S(4))) - S(8)*b*x*(-S(9)*a*c + S(2)*b**S(2))*(-S(3)*a*c + b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))/(S(1155)*c**(S(7)/2)*(sqrt(a) + sqrt(c)*x**S(2))) + x**S(3)*(b + S(3)*c*x**S(2))*(a + b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(33)*c) - x**S(3)*(b*(a*c + S(2)*b**S(2)) + S(10)*c*x**S(2)*(-S(3)*a*c + b**S(2)))*sqrt(a + b*x**S(2) + c*x**S(4))/(S(385)*c**S(2)) + x*sqrt(a + b*x**S(2) + c*x**S(4))*(S(60)*a**S(2)*c**S(2) - S(51)*a*b**S(2)*c + S(8)*b**S(4))/(S(1155)*c**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(a + b*x**S(2) + c*x**S(4))**(S(3)/2), x), x, -a**(S(1)/4)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(S(84)*a**S(2)*c**S(2) - S(57)*a*b**S(2)*c + S(8)*b**S(4))*elliptic_e(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(315)*c**(S(11)/4)*sqrt(a + b*x**S(2) + c*x**S(4))) + a**(S(1)/4)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(S(4)*sqrt(a)*b*sqrt(c)*(-S(6)*a*c + b**S(2)) + S(84)*a**S(2)*c**S(2) - S(57)*a*b**S(2)*c + S(8)*b**S(4))*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(630)*c**(S(11)/4)*sqrt(a + b*x**S(2) + c*x**S(4))) + x*(S(3)*b + S(7)*c*x**S(2))*(a + b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(63)*c) - x*(b*(-S(9)*a*c + S(4)*b**S(2)) + S(6)*c*x**S(2)*(-S(7)*a*c + S(2)*b**S(2)))*sqrt(a + b*x**S(2) + c*x**S(4))/(S(315)*c**S(2)) + x*sqrt(a + b*x**S(2) + c*x**S(4))*(S(84)*a**S(2)*c**S(2) - S(57)*a*b**S(2)*c + S(8)*b**S(4))/(S(315)*c**(S(5)/2)*(sqrt(a) + sqrt(c)*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))**(S(3)/2), x), x, S(2)*a**(S(1)/4)*b*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(-S(8)*a*c + b**S(2))*elliptic_e(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(35)*c**(S(7)/4)*sqrt(a + b*x**S(2) + c*x**S(4))) - a**(S(1)/4)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(sqrt(a)*sqrt(c)*(-S(20)*a*c + b**S(2)) + S(2)*b*(-S(8)*a*c + b**S(2)))*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(70)*c**(S(7)/4)*sqrt(a + b*x**S(2) + c*x**S(4))) - S(2)*b*x*(-S(8)*a*c + b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))/(S(35)*c**(S(3)/2)*(sqrt(a) + sqrt(c)*x**S(2))) + x*(a + b*x**S(2) + c*x**S(4))**(S(3)/2)/S(7) + x*sqrt(a + b*x**S(2) + c*x**S(4))*(S(10)*a*c + b**S(2) + S(3)*b*c*x**S(2))/(S(35)*c), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))**(S(3)/2)/x**S(2), x), x, -a**(S(1)/4)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(S(12)*a*c + b**S(2))*elliptic_e(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(5)*c**(S(3)/4)*sqrt(a + b*x**S(2) + c*x**S(4))) + a**(S(1)/4)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(S(8)*sqrt(a)*b*sqrt(c) + S(12)*a*c + b**S(2))*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(10)*c**(S(3)/4)*sqrt(a + b*x**S(2) + c*x**S(4))) + x*(S(7)*b + S(6)*c*x**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))/S(5) - (a + b*x**S(2) + c*x**S(4))**(S(3)/2)/x + x*(S(12)*a*c + b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))/(S(5)*sqrt(c)*(sqrt(a) + sqrt(c)*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))**(S(3)/2)/x**S(4), x), x, -S(8)*a**(S(1)/4)*b*c**(S(1)/4)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*elliptic_e(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(3)*sqrt(a + b*x**S(2) + c*x**S(4))) + S(8)*b*sqrt(c)*x*sqrt(a + b*x**S(2) + c*x**S(4))/(S(3)*sqrt(a) + S(3)*sqrt(c)*x**S(2)) - (S(3)*b - S(2)*c*x**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))/(S(3)*x) - (a + b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(3)*x**S(3)) + sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(S(8)*sqrt(a)*b*sqrt(c) + S(4)*a*c + S(3)*b**S(2))*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(6)*a**(S(1)/4)*c**(S(1)/4)*sqrt(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))**(S(3)/2)/x**S(6), x), x, -(b - S(6)*c*x**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))/(S(5)*x**S(3)) - (a + b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(5)*x**S(5)) + sqrt(c)*x*(S(12)*a*c + b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))/(S(5)*a*(sqrt(a) + sqrt(c)*x**S(2))) - (S(12)*a*c + b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))/(S(5)*a*x) - c**(S(1)/4)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(S(12)*a*c + b**S(2))*elliptic_e(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(5)*a**(S(3)/4)*sqrt(a + b*x**S(2) + c*x**S(4))) + c**(S(1)/4)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(S(8)*sqrt(a)*b*sqrt(c) + S(12)*a*c + b**S(2))*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(10)*a**(S(3)/4)*sqrt(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))**(S(3)/2)/x**S(8), x), x, -(S(3)*b + S(30)*c*x**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))/(S(35)*x**S(5)) - (a + b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(7)*x**S(7)) - (-S(20)*a*c + b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))/(S(35)*a*x**S(3)) - S(2)*b*sqrt(c)*x*(-S(8)*a*c + b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))/(S(35)*a**S(2)*(sqrt(a) + sqrt(c)*x**S(2))) + S(2)*b*(-S(8)*a*c + b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))/(S(35)*a**S(2)*x) + S(2)*b*c**(S(1)/4)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(-S(8)*a*c + b**S(2))*elliptic_e(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(35)*a**(S(7)/4)*sqrt(a + b*x**S(2) + c*x**S(4))) - c**(S(1)/4)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(sqrt(a)*sqrt(c)*(-S(20)*a*c + b**S(2)) + S(2)*b*(-S(8)*a*c + b**S(2)))*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(70)*a**(S(7)/4)*sqrt(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(-x**S(4) - S(2)*x**S(2) + S(3)), x), x, x*sqrt(-x**S(4) - S(2)*x**S(2) + S(3))/S(3) - S(2)*sqrt(S(3))*elliptic_e(asin(x), S(-1)/3)/S(3) + S(4)*sqrt(S(3))*elliptic_f(asin(x), S(-1)/3)/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(7)/sqrt(a + b*x**S(2) + c*x**S(4)), x), x, -b*(-S(12)*a*c + S(5)*b**S(2))*atanh((b + S(2)*c*x**S(2))/(S(2)*sqrt(c)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(32)*c**(S(7)/2)) + x**S(4)*sqrt(a + b*x**S(2) + c*x**S(4))/(S(6)*c) + sqrt(a + b*x**S(2) + c*x**S(4))*(-S(16)*a*c + S(15)*b**S(2) - S(10)*b*c*x**S(2))/(S(48)*c**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)/sqrt(a + b*x**S(2) + c*x**S(4)), x), x, -S(3)*b*sqrt(a + b*x**S(2) + c*x**S(4))/(S(8)*c**S(2)) + x**S(2)*sqrt(a + b*x**S(2) + c*x**S(4))/(S(4)*c) + (-S(4)*a*c + S(3)*b**S(2))*atanh((b + S(2)*c*x**S(2))/(S(2)*sqrt(c)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(16)*c**(S(5)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/sqrt(a + b*x**S(2) + c*x**S(4)), x), x, -b*atanh((b + S(2)*c*x**S(2))/(S(2)*sqrt(c)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(4)*c**(S(3)/2)) + sqrt(a + b*x**S(2) + c*x**S(4))/(S(2)*c), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/sqrt(a + b*x**S(2) + c*x**S(4)), x), x, atanh((b + S(2)*c*x**S(2))/(S(2)*sqrt(c)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(2)*sqrt(c)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*sqrt(a + b*x**S(2) + c*x**S(4))), x), x, -atanh((S(2)*a + b*x**S(2))/(S(2)*sqrt(a)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(2)*sqrt(a)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(3)*sqrt(a + b*x**S(2) + c*x**S(4))), x), x, -sqrt(a + b*x**S(2) + c*x**S(4))/(S(2)*a*x**S(2)) + b*atanh((S(2)*a + b*x**S(2))/(S(2)*sqrt(a)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(4)*a**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(5)*sqrt(a + b*x**S(2) + c*x**S(4))), x), x, -sqrt(a + b*x**S(2) + c*x**S(4))/(S(4)*a*x**S(4)) + S(3)*b*sqrt(a + b*x**S(2) + c*x**S(4))/(S(8)*a**S(2)*x**S(2)) - (-S(4)*a*c + S(3)*b**S(2))*atanh((S(2)*a + b*x**S(2))/(S(2)*sqrt(a)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(16)*a**(S(5)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(7)*sqrt(a + b*x**S(2) + c*x**S(4))), x), x, -sqrt(a + b*x**S(2) + c*x**S(4))/(S(6)*a*x**S(6)) + S(5)*b*sqrt(a + b*x**S(2) + c*x**S(4))/(S(24)*a**S(2)*x**S(4)) - (-S(16)*a*c + S(15)*b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))/(S(48)*a**S(3)*x**S(2)) + b*(-S(12)*a*c + S(5)*b**S(2))*atanh((S(2)*a + b*x**S(2))/(S(2)*sqrt(a)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(32)*a**(S(7)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)/sqrt(a + b*x**S(2) + c*x**S(4)), x), x, S(2)*a**(S(1)/4)*b*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*elliptic_e(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(3)*c**(S(7)/4)*sqrt(a + b*x**S(2) + c*x**S(4))) - a**(S(1)/4)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(sqrt(a)*sqrt(c) + S(2)*b)*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(6)*c**(S(7)/4)*sqrt(a + b*x**S(2) + c*x**S(4))) - S(2)*b*x*sqrt(a + b*x**S(2) + c*x**S(4))/(S(3)*c**(S(3)/2)*(sqrt(a) + sqrt(c)*x**S(2))) + x*sqrt(a + b*x**S(2) + c*x**S(4))/(S(3)*c), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/sqrt(a + b*x**S(2) + c*x**S(4)), x), x, -a**(S(1)/4)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*elliptic_e(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(c**(S(3)/4)*sqrt(a + b*x**S(2) + c*x**S(4))) + a**(S(1)/4)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(2)*c**(S(3)/4)*sqrt(a + b*x**S(2) + c*x**S(4))) + x*sqrt(a + b*x**S(2) + c*x**S(4))/(sqrt(c)*(sqrt(a) + sqrt(c)*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(a + b*x**S(2) + c*x**S(4)), x), x, sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(2)*a**(S(1)/4)*c**(S(1)/4)*sqrt(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*sqrt(a + b*x**S(2) + c*x**S(4))), x), x, sqrt(c)*x*sqrt(a + b*x**S(2) + c*x**S(4))/(a*(sqrt(a) + sqrt(c)*x**S(2))) - sqrt(a + b*x**S(2) + c*x**S(4))/(a*x) - c**(S(1)/4)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*elliptic_e(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(a**(S(3)/4)*sqrt(a + b*x**S(2) + c*x**S(4))) + c**(S(1)/4)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(2)*a**(S(3)/4)*sqrt(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(4)*sqrt(a + b*x**S(2) + c*x**S(4))), x), x, -sqrt(a + b*x**S(2) + c*x**S(4))/(S(3)*a*x**S(3)) - S(2)*b*sqrt(c)*x*sqrt(a + b*x**S(2) + c*x**S(4))/(S(3)*a**S(2)*(sqrt(a) + sqrt(c)*x**S(2))) + S(2)*b*sqrt(a + b*x**S(2) + c*x**S(4))/(S(3)*a**S(2)*x) + S(2)*b*c**(S(1)/4)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*elliptic_e(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(3)*a**(S(7)/4)*sqrt(a + b*x**S(2) + c*x**S(4))) - c**(S(1)/4)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(sqrt(a)*sqrt(c) + S(2)*b)*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(6)*a**(S(7)/4)*sqrt(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(7)/sqrt(a + b*x**S(2) - c*x**S(4)), x), x, -b*(S(12)*a*c + S(5)*b**S(2))*atan((b - S(2)*c*x**S(2))/(S(2)*sqrt(c)*sqrt(a + b*x**S(2) - c*x**S(4))))/(S(32)*c**(S(7)/2)) - x**S(4)*sqrt(a + b*x**S(2) - c*x**S(4))/(S(6)*c) - sqrt(a + b*x**S(2) - c*x**S(4))*(S(16)*a*c + S(15)*b**S(2) + S(10)*b*c*x**S(2))/(S(48)*c**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)/sqrt(a + b*x**S(2) - c*x**S(4)), x), x, -S(3)*b*sqrt(a + b*x**S(2) - c*x**S(4))/(S(8)*c**S(2)) - x**S(2)*sqrt(a + b*x**S(2) - c*x**S(4))/(S(4)*c) - (S(4)*a*c + S(3)*b**S(2))*atan((b - S(2)*c*x**S(2))/(S(2)*sqrt(c)*sqrt(a + b*x**S(2) - c*x**S(4))))/(S(16)*c**(S(5)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/sqrt(a + b*x**S(2) - c*x**S(4)), x), x, -b*atan((b - S(2)*c*x**S(2))/(S(2)*sqrt(c)*sqrt(a + b*x**S(2) - c*x**S(4))))/(S(4)*c**(S(3)/2)) - sqrt(a + b*x**S(2) - c*x**S(4))/(S(2)*c), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/sqrt(a + b*x**S(2) - c*x**S(4)), x), x, -atan((b - S(2)*c*x**S(2))/(S(2)*sqrt(c)*sqrt(a + b*x**S(2) - c*x**S(4))))/(S(2)*sqrt(c)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*sqrt(-a + b*x**S(2) + c*x**S(4))), x), x, -atan((S(2)*a - b*x**S(2))/(S(2)*sqrt(a)*sqrt(-a + b*x**S(2) + c*x**S(4))))/(S(2)*sqrt(a)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(3)*sqrt(-a + b*x**S(2) + c*x**S(4))), x), x, sqrt(-a + b*x**S(2) + c*x**S(4))/(S(2)*a*x**S(2)) - b*atan((S(2)*a - b*x**S(2))/(S(2)*sqrt(a)*sqrt(-a + b*x**S(2) + c*x**S(4))))/(S(4)*a**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(5)*sqrt(-a + b*x**S(2) + c*x**S(4))), x), x, sqrt(-a + b*x**S(2) + c*x**S(4))/(S(4)*a*x**S(4)) + S(3)*b*sqrt(-a + b*x**S(2) + c*x**S(4))/(S(8)*a**S(2)*x**S(2)) - (S(4)*a*c + S(3)*b**S(2))*atan((S(2)*a - b*x**S(2))/(S(2)*sqrt(a)*sqrt(-a + b*x**S(2) + c*x**S(4))))/(S(16)*a**(S(5)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(7)*sqrt(-a + b*x**S(2) + c*x**S(4))), x), x, sqrt(-a + b*x**S(2) + c*x**S(4))/(S(6)*a*x**S(6)) + S(5)*b*sqrt(-a + b*x**S(2) + c*x**S(4))/(S(24)*a**S(2)*x**S(4)) + (S(16)*a*c + S(15)*b**S(2))*sqrt(-a + b*x**S(2) + c*x**S(4))/(S(48)*a**S(3)*x**S(2)) - b*(S(12)*a*c + S(5)*b**S(2))*atan((S(2)*a - b*x**S(2))/(S(2)*sqrt(a)*sqrt(-a + b*x**S(2) + c*x**S(4))))/(S(32)*a**(S(7)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)/sqrt(a + b*x**S(2) - c*x**S(4)), x), x, -sqrt(S(2))*b*(b - sqrt(S(4)*a*c + b**S(2)))*sqrt(b + sqrt(S(4)*a*c + b**S(2)))*sqrt(-S(2)*c*x**S(2)/(b - sqrt(S(4)*a*c + b**S(2))) + S(1))*sqrt(-S(2)*c*x**S(2)/(b + sqrt(S(4)*a*c + b**S(2))) + S(1))*elliptic_e(asin(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(S(4)*a*c + b**S(2)))), (b + sqrt(S(4)*a*c + b**S(2)))/(b - sqrt(S(4)*a*c + b**S(2))))/(S(6)*c**(S(5)/2)*sqrt(a + b*x**S(2) - c*x**S(4))) - x*sqrt(a + b*x**S(2) - c*x**S(4))/(S(3)*c) + sqrt(S(2))*sqrt(b + sqrt(S(4)*a*c + b**S(2)))*sqrt(-S(2)*c*x**S(2)/(b - sqrt(S(4)*a*c + b**S(2))) + S(1))*sqrt(-S(2)*c*x**S(2)/(b + sqrt(S(4)*a*c + b**S(2))) + S(1))*(a*c + b**S(2) - b*sqrt(S(4)*a*c + b**S(2)))*elliptic_f(asin(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(S(4)*a*c + b**S(2)))), (b + sqrt(S(4)*a*c + b**S(2)))/(b - sqrt(S(4)*a*c + b**S(2))))/(S(6)*c**(S(5)/2)*sqrt(a + b*x**S(2) - c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/sqrt(a + b*x**S(2) - c*x**S(4)), x), x, -sqrt(S(2))*(b - sqrt(S(4)*a*c + b**S(2)))*sqrt(b + sqrt(S(4)*a*c + b**S(2)))*sqrt(-S(2)*c*x**S(2)/(b - sqrt(S(4)*a*c + b**S(2))) + S(1))*sqrt(-S(2)*c*x**S(2)/(b + sqrt(S(4)*a*c + b**S(2))) + S(1))*elliptic_e(asin(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(S(4)*a*c + b**S(2)))), (b + sqrt(S(4)*a*c + b**S(2)))/(b - sqrt(S(4)*a*c + b**S(2))))/(S(4)*c**(S(3)/2)*sqrt(a + b*x**S(2) - c*x**S(4))) + sqrt(S(2))*(b - sqrt(S(4)*a*c + b**S(2)))*sqrt(b + sqrt(S(4)*a*c + b**S(2)))*sqrt(-S(2)*c*x**S(2)/(b - sqrt(S(4)*a*c + b**S(2))) + S(1))*sqrt(-S(2)*c*x**S(2)/(b + sqrt(S(4)*a*c + b**S(2))) + S(1))*elliptic_f(asin(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(S(4)*a*c + b**S(2)))), (b + sqrt(S(4)*a*c + b**S(2)))/(b - sqrt(S(4)*a*c + b**S(2))))/(S(4)*c**(S(3)/2)*sqrt(a + b*x**S(2) - c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(a + b*x**S(2) - c*x**S(4)), x), x, sqrt(S(2))*sqrt(b + sqrt(S(4)*a*c + b**S(2)))*sqrt(-S(2)*c*x**S(2)/(b - sqrt(S(4)*a*c + b**S(2))) + S(1))*sqrt(-S(2)*c*x**S(2)/(b + sqrt(S(4)*a*c + b**S(2))) + S(1))*elliptic_f(asin(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(S(4)*a*c + b**S(2)))), (b + sqrt(S(4)*a*c + b**S(2)))/(b - sqrt(S(4)*a*c + b**S(2))))/(S(2)*sqrt(c)*sqrt(a + b*x**S(2) - c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*sqrt(a + b*x**S(2) - c*x**S(4))), x), x, -sqrt(a + b*x**S(2) - c*x**S(4))/(a*x) + sqrt(S(2))*(b - sqrt(S(4)*a*c + b**S(2)))*sqrt(b + sqrt(S(4)*a*c + b**S(2)))*sqrt(-S(2)*c*x**S(2)/(b - sqrt(S(4)*a*c + b**S(2))) + S(1))*sqrt(-S(2)*c*x**S(2)/(b + sqrt(S(4)*a*c + b**S(2))) + S(1))*elliptic_e(asin(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(S(4)*a*c + b**S(2)))), (b + sqrt(S(4)*a*c + b**S(2)))/(b - sqrt(S(4)*a*c + b**S(2))))/(S(4)*a*sqrt(c)*sqrt(a + b*x**S(2) - c*x**S(4))) - sqrt(S(2))*(b - sqrt(S(4)*a*c + b**S(2)))*sqrt(b + sqrt(S(4)*a*c + b**S(2)))*sqrt(-S(2)*c*x**S(2)/(b - sqrt(S(4)*a*c + b**S(2))) + S(1))*sqrt(-S(2)*c*x**S(2)/(b + sqrt(S(4)*a*c + b**S(2))) + S(1))*elliptic_f(asin(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(S(4)*a*c + b**S(2)))), (b + sqrt(S(4)*a*c + b**S(2)))/(b - sqrt(S(4)*a*c + b**S(2))))/(S(4)*a*sqrt(c)*sqrt(a + b*x**S(2) - c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(4)*sqrt(a + b*x**S(2) - c*x**S(4))), x), x, -sqrt(a + b*x**S(2) - c*x**S(4))/(S(3)*a*x**S(3)) + S(2)*b*sqrt(a + b*x**S(2) - c*x**S(4))/(S(3)*a**S(2)*x) - sqrt(S(2))*b*(b - sqrt(S(4)*a*c + b**S(2)))*sqrt(b + sqrt(S(4)*a*c + b**S(2)))*sqrt(-S(2)*c*x**S(2)/(b - sqrt(S(4)*a*c + b**S(2))) + S(1))*sqrt(-S(2)*c*x**S(2)/(b + sqrt(S(4)*a*c + b**S(2))) + S(1))*elliptic_e(asin(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(S(4)*a*c + b**S(2)))), (b + sqrt(S(4)*a*c + b**S(2)))/(b - sqrt(S(4)*a*c + b**S(2))))/(S(6)*a**S(2)*sqrt(c)*sqrt(a + b*x**S(2) - c*x**S(4))) + sqrt(S(2))*sqrt(b + sqrt(S(4)*a*c + b**S(2)))*sqrt(-S(2)*c*x**S(2)/(b - sqrt(S(4)*a*c + b**S(2))) + S(1))*sqrt(-S(2)*c*x**S(2)/(b + sqrt(S(4)*a*c + b**S(2))) + S(1))*(a*c + b**S(2) - b*sqrt(S(4)*a*c + b**S(2)))*elliptic_f(asin(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(S(4)*a*c + b**S(2)))), (b + sqrt(S(4)*a*c + b**S(2)))/(b - sqrt(S(4)*a*c + b**S(2))))/(S(6)*a**S(2)*sqrt(c)*sqrt(a + b*x**S(2) - c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(9)/(a + b*x**S(2) + c*x**S(4))**(S(3)/2), x), x, -b*x**S(4)*sqrt(a + b*x**S(2) + c*x**S(4))/(c*(-S(4)*a*c + b**S(2))) + x**S(6)*(S(2)*a + b*x**S(2))/((-S(4)*a*c + b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))) - (b*(-S(52)*a*c + S(15)*b**S(2)) - S(2)*c*x**S(2)*(-S(12)*a*c + S(5)*b**S(2)))*sqrt(a + b*x**S(2) + c*x**S(4))/(S(8)*c**S(3)*(-S(4)*a*c + b**S(2))) + (-S(12)*a*c + S(15)*b**S(2))*atanh((b + S(2)*c*x**S(2))/(S(2)*sqrt(c)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(16)*c**(S(7)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(7)/(a + b*x**S(2) + c*x**S(4))**(S(3)/2), x), x, -S(3)*b*atanh((b + S(2)*c*x**S(2))/(S(2)*sqrt(c)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(4)*c**(S(5)/2)) + x**S(4)*(S(2)*a + b*x**S(2))/((-S(4)*a*c + b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))) + sqrt(a + b*x**S(2) + c*x**S(4))*(-S(8)*a*c + S(3)*b**S(2) - S(2)*b*c*x**S(2))/(S(2)*c**S(2)*(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)/(a + b*x**S(2) + c*x**S(4))**(S(3)/2), x), x, -b*sqrt(a + b*x**S(2) + c*x**S(4))/(c*(-S(4)*a*c + b**S(2))) + x**S(2)*(S(2)*a + b*x**S(2))/((-S(4)*a*c + b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))) + atanh((b + S(2)*c*x**S(2))/(S(2)*sqrt(c)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(2)*c**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/(a + b*x**S(2) + c*x**S(4))**(S(3)/2), x), x, (S(2)*a + b*x**S(2))/((-S(4)*a*c + b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(a + b*x**S(2) + c*x**S(4))**(S(3)/2), x), x, -(b + S(2)*c*x**S(2))/((-S(4)*a*c + b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*(a + b*x**S(2) + c*x**S(4))**(S(3)/2)), x), x, (-S(2)*a*c + b**S(2) + b*c*x**S(2))/(a*(-S(4)*a*c + b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))) - atanh((S(2)*a + b*x**S(2))/(S(2)*sqrt(a)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(2)*a**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(3)*(a + b*x**S(2) + c*x**S(4))**(S(3)/2)), x), x, (-S(2)*a*c + b**S(2) + b*c*x**S(2))/(a*x**S(2)*(-S(4)*a*c + b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))) - (-S(8)*a*c + S(3)*b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))/(S(2)*a**S(2)*x**S(2)*(-S(4)*a*c + b**S(2))) + S(3)*b*atanh((S(2)*a + b*x**S(2))/(S(2)*sqrt(a)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(4)*a**(S(5)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(5)*(a + b*x**S(2) + c*x**S(4))**(S(3)/2)), x), x, (-S(2)*a*c + b**S(2) + b*c*x**S(2))/(a*x**S(4)*(-S(4)*a*c + b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))) - (-S(12)*a*c + S(5)*b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))/(S(4)*a**S(2)*x**S(4)*(-S(4)*a*c + b**S(2))) + b*(-S(52)*a*c + S(15)*b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))/(S(8)*a**S(3)*x**S(2)*(-S(4)*a*c + b**S(2))) - (-S(12)*a*c + S(15)*b**S(2))*atanh((S(2)*a + b*x**S(2))/(S(2)*sqrt(a)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(16)*a**(S(7)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(6)/(a + b*x**S(2) + c*x**S(4))**(S(3)/2), x), x, -S(2)*a**(S(1)/4)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(-S(3)*a*c + b**S(2))*elliptic_e(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(c**(S(7)/4)*(-S(4)*a*c + b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))) + a**(S(1)/4)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(sqrt(a)*b*sqrt(c) - S(6)*a*c + S(2)*b**S(2))*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(2)*c**(S(7)/4)*(-S(4)*a*c + b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))) - b*x*sqrt(a + b*x**S(2) + c*x**S(4))/(c*(-S(4)*a*c + b**S(2))) + x**S(3)*(S(2)*a + b*x**S(2))/((-S(4)*a*c + b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))) + x*(-S(6)*a*c + S(2)*b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))/(c**(S(3)/2)*(sqrt(a) + sqrt(c)*x**S(2))*(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)/(a + b*x**S(2) + c*x**S(4))**(S(3)/2), x), x, a**(S(1)/4)*b*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*elliptic_e(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(c**(S(3)/4)*(-S(4)*a*c + b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))) - a**(S(1)/4)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(c**(S(3)/4)*(-S(4)*sqrt(a)*sqrt(c) + S(2)*b)*sqrt(a + b*x**S(2) + c*x**S(4))) - b*x*sqrt(a + b*x**S(2) + c*x**S(4))/(sqrt(c)*(sqrt(a) + sqrt(c)*x**S(2))*(-S(4)*a*c + b**S(2))) + x*(S(2)*a + b*x**S(2))/((-S(4)*a*c + b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/(a + b*x**S(2) + c*x**S(4))**(S(3)/2), x), x, -S(2)*a**(S(1)/4)*c**(S(1)/4)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*elliptic_e(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/((-S(4)*a*c + b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))) + S(2)*sqrt(c)*x*sqrt(a + b*x**S(2) + c*x**S(4))/((sqrt(a) + sqrt(c)*x**S(2))*(-S(4)*a*c + b**S(2))) - x*(b + S(2)*c*x**S(2))/((-S(4)*a*c + b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))) + sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(2)*a**(S(1)/4)*c**(S(1)/4)*(-S(2)*sqrt(a)*sqrt(c) + b)*sqrt(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))**(S(-3)/2), x), x, -b*sqrt(c)*x*sqrt(a + b*x**S(2) + c*x**S(4))/(a*(sqrt(a) + sqrt(c)*x**S(2))*(-S(4)*a*c + b**S(2))) + x*(-S(2)*a*c + b**S(2) + b*c*x**S(2))/(a*(-S(4)*a*c + b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))) + b*c**(S(1)/4)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*elliptic_e(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(a**(S(3)/4)*(-S(4)*a*c + b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))) - c**(S(1)/4)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(2)*a**(S(3)/4)*(-S(2)*sqrt(a)*sqrt(c) + b)*sqrt(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*(a + b*x**S(2) + c*x**S(4))**(S(3)/2)), x), x, (-S(2)*a*c + b**S(2) + b*c*x**S(2))/(a*x*(-S(4)*a*c + b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))) + S(2)*sqrt(c)*x*(-S(3)*a*c + b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))/(a**S(2)*(sqrt(a) + sqrt(c)*x**S(2))*(-S(4)*a*c + b**S(2))) - (-S(6)*a*c + S(2)*b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))/(a**S(2)*x*(-S(4)*a*c + b**S(2))) - S(2)*c**(S(1)/4)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(-S(3)*a*c + b**S(2))*elliptic_e(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(a**(S(7)/4)*(-S(4)*a*c + b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))) + c**(S(1)/4)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(sqrt(a)*b*sqrt(c) - S(6)*a*c + S(2)*b**S(2))*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(2)*a**(S(7)/4)*(-S(4)*a*c + b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(-S(3)*x**S(4) + S(5)*x**S(2) + S(2)), x), x, elliptic_f(asin(sqrt(S(2))*x/S(2)), S(-6)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(-S(3)*x**S(4) + S(4)*x**S(2) + S(2)), x), x, sqrt(S(1)/3 + sqrt(S(10))/S(6))*elliptic_f(asin(x*sqrt(S(-1) + sqrt(S(10))/S(2))), S(-7)/3 - S(2)*sqrt(S(10))/S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(-S(3)*x**S(4) + S(3)*x**S(2) + S(2)), x), x, sqrt(S(2))*elliptic_f(asin(sqrt(S(6))*x/sqrt(S(3) + sqrt(S(33)))), S(-7)/4 - sqrt(S(33))/S(4))/sqrt(S(-3) + sqrt(S(33))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(-S(3)*x**S(4) + S(2)*x**S(2) + S(2)), x), x, elliptic_f(asin(sqrt(S(3))*x/sqrt(S(1) + sqrt(S(7)))), S(-4)/3 - sqrt(S(7))/S(3))/sqrt(S(-1) + sqrt(S(7))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(-S(3)*x**S(4) + x**S(2) + S(2)), x), x, sqrt(S(2))*elliptic_f(asin(x), S(-3)/2)/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(-S(3)*x**S(4) + S(2)), x), x, S(6)**(S(3)/4)*elliptic_f(asin(S(2)**(S(3)/4)*S(3)**(S(1)/4)*x/S(2)), S(-1))/S(6), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(-S(3)*x**S(4) - x**S(2) + S(2)), x), x, sqrt(S(3))*elliptic_f(asin(sqrt(S(6))*x/S(2)), S(-2)/3)/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(-S(3)*x**S(4) - S(2)*x**S(2) + S(2)), x), x, elliptic_f(asin(sqrt(S(3))*x/sqrt(S(-1) + sqrt(S(7)))), S(-4)/3 + sqrt(S(7))/S(3))/sqrt(S(1) + sqrt(S(7))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(-S(3)*x**S(4) - S(3)*x**S(2) + S(2)), x), x, sqrt(S(2))*elliptic_f(asin(sqrt(S(6))*x/sqrt(S(-3) + sqrt(S(33)))), S(-7)/4 + sqrt(S(33))/S(4))/sqrt(S(3) + sqrt(S(33))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(-S(3)*x**S(4) - S(4)*x**S(2) + S(2)), x), x, sqrt(S(-1)/3 + sqrt(S(10))/S(6))*elliptic_f(asin(x*sqrt(S(1) + sqrt(S(10))/S(2))), S(-7)/3 + S(2)*sqrt(S(10))/S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(-S(3)*x**S(4) - S(5)*x**S(2) + S(2)), x), x, sqrt(S(6))*elliptic_f(asin(sqrt(S(3))*x), S(-1)/6)/S(6), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(-S(2)*x**S(4) + S(7)*x**S(2) + S(3)), x), x, sqrt(S(2))*elliptic_f(asin(S(2)*x/sqrt(S(7) + sqrt(S(73)))), S(-61)/12 - S(7)*sqrt(S(73))/S(12))/sqrt(S(-7) + sqrt(S(73))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(-S(2)*x**S(4) + S(6)*x**S(2) + S(3)), x), x, sqrt(S(1)/2 + sqrt(S(15))/S(6))*elliptic_f(asin(x*sqrt(S(-1) + sqrt(S(15))/S(3))), S(-4) - sqrt(S(15))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(-S(2)*x**S(4) + S(5)*x**S(2) + S(3)), x), x, elliptic_f(asin(sqrt(S(3))*x/S(3)), S(-6)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(-S(2)*x**S(4) + S(4)*x**S(2) + S(3)), x), x, elliptic_f(asin(sqrt(S(2))*x/sqrt(S(2) + sqrt(S(10)))), S(-7)/3 - S(2)*sqrt(S(10))/S(3))/sqrt(S(-2) + sqrt(S(10))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(-S(2)*x**S(4) + S(3)*x**S(2) + S(3)), x), x, sqrt(S(2))*elliptic_f(asin(S(2)*x/sqrt(S(3) + sqrt(S(33)))), S(-7)/4 - sqrt(S(33))/S(4))/sqrt(S(-3) + sqrt(S(33))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(-S(2)*x**S(4) + S(2)*x**S(2) + S(3)), x), x, elliptic_f(asin(sqrt(S(2))*x/sqrt(S(1) + sqrt(S(7)))), S(-4)/3 - sqrt(S(7))/S(3))/sqrt(S(-1) + sqrt(S(7))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(-S(2)*x**S(4) + x**S(2) + S(3)), x), x, sqrt(S(2))*elliptic_f(asin(sqrt(S(6))*x/S(3)), S(-3)/2)/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(-S(2)*x**S(4) + S(3)), x), x, S(6)**(S(3)/4)*elliptic_f(asin(S(2)**(S(1)/4)*S(3)**(S(3)/4)*x/S(3)), S(-1))/S(6), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(-S(2)*x**S(4) - x**S(2) + S(3)), x), x, sqrt(S(3))*elliptic_f(asin(x), S(-2)/3)/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(-S(2)*x**S(4) - S(2)*x**S(2) + S(3)), x), x, elliptic_f(asin(sqrt(S(2))*x/sqrt(S(-1) + sqrt(S(7)))), S(-4)/3 + sqrt(S(7))/S(3))/sqrt(S(1) + sqrt(S(7))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(-S(2)*x**S(4) - S(3)*x**S(2) + S(3)), x), x, sqrt(S(2))*elliptic_f(asin(S(2)*x/sqrt(S(-3) + sqrt(S(33)))), S(-7)/4 + sqrt(S(33))/S(4))/sqrt(S(3) + sqrt(S(33))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(-S(2)*x**S(4) - S(4)*x**S(2) + S(3)), x), x, elliptic_f(asin(sqrt(S(2))*x/sqrt(S(-2) + sqrt(S(10)))), S(-7)/3 + S(2)*sqrt(S(10))/S(3))/sqrt(S(2) + sqrt(S(10))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(-S(2)*x**S(4) - S(5)*x**S(2) + S(3)), x), x, sqrt(S(6))*elliptic_f(asin(sqrt(S(2))*x), S(-1)/6)/S(6), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(-S(2)*x**S(4) - S(6)*x**S(2) + S(3)), x), x, sqrt(S(-1)/2 + sqrt(S(15))/S(6))*elliptic_f(asin(x*sqrt(S(1) + sqrt(S(15))/S(3))), S(-4) + sqrt(S(15))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(-S(2)*x**S(4) - S(7)*x**S(2) + S(3)), x), x, sqrt(S(2))*elliptic_f(asin(S(2)*x/sqrt(S(-7) + sqrt(S(73)))), S(-61)/12 + S(7)*sqrt(S(73))/S(12))/sqrt(S(7) + sqrt(S(73))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(S(3)*x**S(4) + S(5)*x**S(2) + S(-2)), x), x, sqrt(S(7))*sqrt(x**S(2) + S(2))*sqrt(S(3)*x**S(2) + S(-1))*elliptic_f(asin(sqrt(S(14))*x/(S(2)*sqrt(S(3)*x**S(2) + S(-1)))), S(6)/7)/(S(7)*sqrt(S(3)*x**S(4) + S(5)*x**S(2) + S(-2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(S(3)*x**S(4) + S(4)*x**S(2) + S(-2)), x), x, S(10)**(S(3)/4)*sqrt((-x**S(2)*(-sqrt(S(10)) + S(2)) + S(2))/(-x**S(2)*(S(2) + sqrt(S(10))) + S(2)))*sqrt(x**S(2)*(S(2) + sqrt(S(10))) + S(-2))*elliptic_f(asin(S(2)**(S(3)/4)*S(5)**(S(1)/4)*x/sqrt(x**S(2)*(S(2) + sqrt(S(10))) + S(-2))), sqrt(S(10))/S(10) + S(1)/2)/(S(20)*sqrt(S(3)*x**S(4) + S(4)*x**S(2) + S(-2))*sqrt(S(1)/(-x**S(2)*(S(2) + sqrt(S(10))) + S(2)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(S(3)*x**S(4) + S(3)*x**S(2) + S(-2)), x), x, sqrt(S(2))*S(33)**(S(3)/4)*sqrt((-x**S(2)*(-sqrt(S(33)) + S(3)) + S(4))/(-x**S(2)*(S(3) + sqrt(S(33))) + S(4)))*sqrt(x**S(2)*(S(3) + sqrt(S(33))) + S(-4))*elliptic_f(asin(sqrt(S(2))*S(33)**(S(1)/4)*x/sqrt(x**S(2)*(S(3) + sqrt(S(33))) + S(-4))), sqrt(S(33))/S(22) + S(1)/2)/(S(132)*sqrt(S(3)*x**S(4) + S(3)*x**S(2) + S(-2))*sqrt(S(1)/(-x**S(2)*(S(3) + sqrt(S(33))) + S(4)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(S(3)*x**S(4) + S(2)*x**S(2) + S(-2)), x), x, S(7)**(S(3)/4)*sqrt((-x**S(2)*(-sqrt(S(7)) + S(1)) + S(2))/(-x**S(2)*(S(1) + sqrt(S(7))) + S(2)))*sqrt(x**S(2)*(S(1) + sqrt(S(7))) + S(-2))*elliptic_f(asin(sqrt(S(2))*S(7)**(S(1)/4)*x/sqrt(x**S(2)*(S(1) + sqrt(S(7))) + S(-2))), sqrt(S(7))/S(14) + S(1)/2)/(S(14)*sqrt(S(3)*x**S(4) + S(2)*x**S(2) + S(-2))*sqrt(S(1)/(-x**S(2)*(S(1) + sqrt(S(7))) + S(2)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(S(3)*x**S(4) + x**S(2) + S(-2)), x), x, sqrt(S(5))*sqrt(x**S(2) + S(1))*sqrt(S(3)*x**S(2) + S(-2))*elliptic_f(asin(sqrt(S(5))*x/sqrt(S(3)*x**S(2) + S(-2))), S(3)/5)/(S(5)*sqrt(S(3)*x**S(4) + x**S(2) + S(-2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(S(3)*x**S(4) + S(-2)), x), x, S(6)**(S(3)/4)*sqrt((sqrt(S(6))*x**S(2) + S(2))/(-sqrt(S(6))*x**S(2) + S(2)))*sqrt(sqrt(S(6))*x**S(2) + S(-2))*elliptic_f(asin(S(2)**(S(3)/4)*S(3)**(S(1)/4)*x/sqrt(sqrt(S(6))*x**S(2) + S(-2))), S(1)/2)/(S(12)*sqrt(S(3)*x**S(4) + S(-2))*sqrt(S(1)/(-sqrt(S(6))*x**S(2) + S(2)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(S(3)*x**S(4) - x**S(2) + S(-2)), x), x, sqrt(S(5))*sqrt(x**S(2) + S(-1))*sqrt(S(3)*x**S(2) + S(2))*elliptic_f(asin(sqrt(S(10))*x/(S(2)*sqrt(x**S(2) + S(-1)))), S(2)/5)/(S(5)*sqrt(S(3)*x**S(4) - x**S(2) + S(-2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(S(3)*x**S(4) - S(2)*x**S(2) + S(-2)), x), x, S(7)**(S(3)/4)*sqrt((x**S(2)*(S(1) + sqrt(S(7))) + S(2))/(x**S(2)*(-sqrt(S(7)) + S(1)) + S(2)))*sqrt(-x**S(2)*(-sqrt(S(7)) + S(1)) + S(-2))*elliptic_f(asin(sqrt(S(2))*S(7)**(S(1)/4)*x/sqrt(-x**S(2)*(-sqrt(S(7)) + S(1)) + S(-2))), -sqrt(S(7))/S(14) + S(1)/2)/(S(14)*sqrt(S(3)*x**S(4) - S(2)*x**S(2) + S(-2))*sqrt(S(1)/(x**S(2)*(-sqrt(S(7)) + S(1)) + S(2)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(S(3)*x**S(4) - S(3)*x**S(2) + S(-2)), x), x, sqrt(S(2))*S(33)**(S(3)/4)*sqrt((x**S(2)*(S(3) + sqrt(S(33))) + S(4))/(x**S(2)*(-sqrt(S(33)) + S(3)) + S(4)))*sqrt(-x**S(2)*(-sqrt(S(33)) + S(3)) + S(-4))*elliptic_f(asin(sqrt(S(2))*S(33)**(S(1)/4)*x/sqrt(-x**S(2)*(-sqrt(S(33)) + S(3)) + S(-4))), -sqrt(S(33))/S(22) + S(1)/2)/(S(132)*sqrt(S(3)*x**S(4) - S(3)*x**S(2) + S(-2))*sqrt(S(1)/(x**S(2)*(-sqrt(S(33)) + S(3)) + S(4)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(S(3)*x**S(4) - S(4)*x**S(2) + S(-2)), x), x, S(10)**(S(3)/4)*sqrt((x**S(2)*(S(2) + sqrt(S(10))) + S(2))/(x**S(2)*(-sqrt(S(10)) + S(2)) + S(2)))*sqrt(-x**S(2)*(-sqrt(S(10)) + S(2)) + S(-2))*elliptic_f(asin(S(2)**(S(3)/4)*S(5)**(S(1)/4)*x/sqrt(-x**S(2)*(-sqrt(S(10)) + S(2)) + S(-2))), -sqrt(S(10))/S(10) + S(1)/2)/(S(20)*sqrt(S(3)*x**S(4) - S(4)*x**S(2) + S(-2))*sqrt(S(1)/(x**S(2)*(-sqrt(S(10)) + S(2)) + S(2)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(S(3)*x**S(4) - S(5)*x**S(2) + S(-2)), x), x, sqrt(S(7))*sqrt(x**S(2) + S(-2))*sqrt(S(3)*x**S(2) + S(1))*elliptic_f(asin(sqrt(S(7))*x/sqrt(x**S(2) + S(-2))), S(1)/7)/(S(7)*sqrt(S(3)*x**S(4) - S(5)*x**S(2) + S(-2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(S(2)*x**S(4) + S(7)*x**S(2) + S(-3)), x), x, sqrt(S(3))*S(73)**(S(3)/4)*sqrt((-x**S(2)*(-sqrt(S(73)) + S(7)) + S(6))/(-x**S(2)*(S(7) + sqrt(S(73))) + S(6)))*sqrt(x**S(2)*(S(7) + sqrt(S(73))) + S(-6))*elliptic_f(asin(sqrt(S(2))*S(73)**(S(1)/4)*x/sqrt(x**S(2)*(S(7) + sqrt(S(73))) + S(-6))), S(7)*sqrt(S(73))/S(146) + S(1)/2)/(S(438)*sqrt(S(2)*x**S(4) + S(7)*x**S(2) + S(-3))*sqrt(S(1)/(-x**S(2)*(S(7) + sqrt(S(73))) + S(6)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(S(2)*x**S(4) + S(6)*x**S(2) + S(-3)), x), x, sqrt(S(2))*S(3)**(S(1)/4)*S(5)**(S(3)/4)*sqrt((-x**S(2)*(-sqrt(S(15)) + S(3)) + S(3))/(-x**S(2)*(S(3) + sqrt(S(15))) + S(3)))*sqrt(x**S(2)*(S(3) + sqrt(S(15))) + S(-3))*elliptic_f(asin(S(15)**(S(1)/4)*sqrt(S(2))*x/sqrt(x**S(2)*(S(3) + sqrt(S(15))) + S(-3))), sqrt(S(15))/S(10) + S(1)/2)/(S(30)*sqrt(S(2)*x**S(4) + S(6)*x**S(2) + S(-3))*sqrt(S(1)/(-x**S(2)*(S(3) + sqrt(S(15))) + S(3)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(S(2)*x**S(4) + S(5)*x**S(2) + S(-3)), x), x, sqrt(S(7))*sqrt(x**S(2) + S(3))*sqrt(S(2)*x**S(2) + S(-1))*elliptic_f(asin(sqrt(S(21))*x/(S(3)*sqrt(S(2)*x**S(2) + S(-1)))), S(6)/7)/(S(7)*sqrt(S(2)*x**S(4) + S(5)*x**S(2) + S(-3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(S(2)*x**S(4) + S(4)*x**S(2) + S(-3)), x), x, S(2)**(S(1)/4)*sqrt(S(3))*S(5)**(S(3)/4)*sqrt((-x**S(2)*(-sqrt(S(10)) + S(2)) + S(3))/(-x**S(2)*(S(2) + sqrt(S(10))) + S(3)))*sqrt(x**S(2)*(S(2) + sqrt(S(10))) + S(-3))*elliptic_f(asin(S(2)**(S(3)/4)*S(5)**(S(1)/4)*x/sqrt(x**S(2)*(S(2) + sqrt(S(10))) + S(-3))), sqrt(S(10))/S(10) + S(1)/2)/(S(30)*sqrt(S(2)*x**S(4) + S(4)*x**S(2) + S(-3))*sqrt(S(1)/(-x**S(2)*(S(2) + sqrt(S(10))) + S(3)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(S(2)*x**S(4) + S(3)*x**S(2) + S(-3)), x), x, S(11)**(S(3)/4)*S(3)**(S(1)/4)*sqrt((-x**S(2)*(-sqrt(S(33)) + S(3)) + S(6))/(-x**S(2)*(S(3) + sqrt(S(33))) + S(6)))*sqrt(x**S(2)*(S(3) + sqrt(S(33))) + S(-6))*elliptic_f(asin(sqrt(S(2))*S(33)**(S(1)/4)*x/sqrt(x**S(2)*(S(3) + sqrt(S(33))) + S(-6))), sqrt(S(33))/S(22) + S(1)/2)/(S(66)*sqrt(S(2)*x**S(4) + S(3)*x**S(2) + S(-3))*sqrt(S(1)/(-x**S(2)*(S(3) + sqrt(S(33))) + S(6)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(-3)), x), x, sqrt(S(6))*S(7)**(S(3)/4)*sqrt((-x**S(2)*(-sqrt(S(7)) + S(1)) + S(3))/(-x**S(2)*(S(1) + sqrt(S(7))) + S(3)))*sqrt(x**S(2)*(S(1) + sqrt(S(7))) + S(-3))*elliptic_f(asin(sqrt(S(2))*S(7)**(S(1)/4)*x/sqrt(x**S(2)*(S(1) + sqrt(S(7))) + S(-3))), sqrt(S(7))/S(14) + S(1)/2)/(S(42)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(-3))*sqrt(S(1)/(-x**S(2)*(S(1) + sqrt(S(7))) + S(3)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(S(2)*x**S(4) + x**S(2) + S(-3)), x), x, sqrt(S(5))*sqrt(x**S(2) + S(-1))*sqrt(S(2)*x**S(2) + S(3))*elliptic_f(asin(sqrt(S(15))*x/(S(3)*sqrt(x**S(2) + S(-1)))), S(3)/5)/(S(5)*sqrt(S(2)*x**S(4) + x**S(2) + S(-3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(S(2)*x**S(4) + S(-3)), x), x, S(6)**(S(1)/4)*sqrt((sqrt(S(6))*x**S(2) + S(3))/(-sqrt(S(6))*x**S(2) + S(3)))*sqrt(sqrt(S(6))*x**S(2) + S(-3))*elliptic_f(asin(S(2)**(S(3)/4)*S(3)**(S(1)/4)*x/sqrt(sqrt(S(6))*x**S(2) + S(-3))), S(1)/2)/(S(6)*sqrt(S(2)*x**S(4) + S(-3))*sqrt(S(1)/(-sqrt(S(6))*x**S(2) + S(3)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(S(2)*x**S(4) - x**S(2) + S(-3)), x), x, sqrt(S(5))*sqrt(x**S(2) + S(1))*sqrt(S(2)*x**S(2) + S(-3))*elliptic_f(asin(sqrt(S(5))*x/sqrt(S(2)*x**S(2) + S(-3))), S(2)/5)/(S(5)*sqrt(S(2)*x**S(4) - x**S(2) + S(-3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(S(2)*x**S(4) - S(2)*x**S(2) + S(-3)), x), x, sqrt(S(6))*S(7)**(S(3)/4)*sqrt((x**S(2)*(S(1) + sqrt(S(7))) + S(3))/(x**S(2)*(-sqrt(S(7)) + S(1)) + S(3)))*sqrt(-x**S(2)*(-sqrt(S(7)) + S(1)) + S(-3))*elliptic_f(asin(sqrt(S(2))*S(7)**(S(1)/4)*x/sqrt(-x**S(2)*(-sqrt(S(7)) + S(1)) + S(-3))), -sqrt(S(7))/S(14) + S(1)/2)/(S(42)*sqrt(S(2)*x**S(4) - S(2)*x**S(2) + S(-3))*sqrt(S(1)/(x**S(2)*(-sqrt(S(7)) + S(1)) + S(3)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(S(2)*x**S(4) - S(3)*x**S(2) + S(-3)), x), x, S(11)**(S(3)/4)*S(3)**(S(1)/4)*sqrt((x**S(2)*(S(3) + sqrt(S(33))) + S(6))/(x**S(2)*(-sqrt(S(33)) + S(3)) + S(6)))*sqrt(-x**S(2)*(-sqrt(S(33)) + S(3)) + S(-6))*elliptic_f(asin(sqrt(S(2))*S(33)**(S(1)/4)*x/sqrt(-x**S(2)*(-sqrt(S(33)) + S(3)) + S(-6))), -sqrt(S(33))/S(22) + S(1)/2)/(S(66)*sqrt(S(2)*x**S(4) - S(3)*x**S(2) + S(-3))*sqrt(S(1)/(x**S(2)*(-sqrt(S(33)) + S(3)) + S(6)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(S(2)*x**S(4) - S(4)*x**S(2) + S(-3)), x), x, S(2)**(S(1)/4)*sqrt(S(3))*S(5)**(S(3)/4)*sqrt((x**S(2)*(S(2) + sqrt(S(10))) + S(3))/(x**S(2)*(-sqrt(S(10)) + S(2)) + S(3)))*sqrt(-x**S(2)*(-sqrt(S(10)) + S(2)) + S(-3))*elliptic_f(asin(S(2)**(S(3)/4)*S(5)**(S(1)/4)*x/sqrt(-x**S(2)*(-sqrt(S(10)) + S(2)) + S(-3))), -sqrt(S(10))/S(10) + S(1)/2)/(S(30)*sqrt(S(2)*x**S(4) - S(4)*x**S(2) + S(-3))*sqrt(S(1)/(x**S(2)*(-sqrt(S(10)) + S(2)) + S(3)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(S(2)*x**S(4) - S(5)*x**S(2) + S(-3)), x), x, sqrt(S(7))*sqrt(x**S(2) + S(-3))*sqrt(S(2)*x**S(2) + S(1))*elliptic_f(asin(sqrt(S(7))*x/sqrt(x**S(2) + S(-3))), S(1)/7)/(S(7)*sqrt(S(2)*x**S(4) - S(5)*x**S(2) + S(-3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(S(3)*x**S(4) + S(5)*x**S(2) + S(2)), x), x, sqrt(S(2))*sqrt((S(3)*x**S(2) + S(2))/(x**S(2) + S(1)))*(x**S(2) + S(1))*elliptic_f(atan(x), S(-1)/2)/(S(2)*sqrt(S(3)*x**S(4) + S(5)*x**S(2) + S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(S(3)*x**S(4) + S(4)*x**S(2) + S(2)), x), x, S(6)**(S(3)/4)*sqrt((S(3)*x**S(4) + S(4)*x**S(2) + S(2))/(sqrt(S(6))*x**S(2) + S(2))**S(2))*(sqrt(S(6))*x**S(2) + S(2))*elliptic_f(S(2)*atan(S(2)**(S(3)/4)*S(3)**(S(1)/4)*x/S(2)), -sqrt(S(6))/S(6) + S(1)/2)/(S(12)*sqrt(S(3)*x**S(4) + S(4)*x**S(2) + S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(S(3)*x**S(4) + S(3)*x**S(2) + S(2)), x), x, S(6)**(S(3)/4)*sqrt((S(3)*x**S(4) + S(3)*x**S(2) + S(2))/(sqrt(S(6))*x**S(2) + S(2))**S(2))*(sqrt(S(6))*x**S(2) + S(2))*elliptic_f(S(2)*atan(S(2)**(S(3)/4)*S(3)**(S(1)/4)*x/S(2)), -sqrt(S(6))/S(8) + S(1)/2)/(S(12)*sqrt(S(3)*x**S(4) + S(3)*x**S(2) + S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(S(3)*x**S(4) + S(2)*x**S(2) + S(2)), x), x, S(6)**(S(3)/4)*sqrt((S(3)*x**S(4) + S(2)*x**S(2) + S(2))/(sqrt(S(6))*x**S(2) + S(2))**S(2))*(sqrt(S(6))*x**S(2) + S(2))*elliptic_f(S(2)*atan(S(2)**(S(3)/4)*S(3)**(S(1)/4)*x/S(2)), -sqrt(S(6))/S(12) + S(1)/2)/(S(12)*sqrt(S(3)*x**S(4) + S(2)*x**S(2) + S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(S(3)*x**S(4) + x**S(2) + S(2)), x), x, S(6)**(S(3)/4)*sqrt((S(3)*x**S(4) + x**S(2) + S(2))/(sqrt(S(6))*x**S(2) + S(2))**S(2))*(sqrt(S(6))*x**S(2) + S(2))*elliptic_f(S(2)*atan(S(2)**(S(3)/4)*S(3)**(S(1)/4)*x/S(2)), -sqrt(S(6))/S(24) + S(1)/2)/(S(12)*sqrt(S(3)*x**S(4) + x**S(2) + S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(S(3)*x**S(4) + S(2)), x), x, S(6)**(S(3)/4)*sqrt((S(3)*x**S(4) + S(2))/(sqrt(S(6))*x**S(2) + S(2))**S(2))*(sqrt(S(6))*x**S(2) + S(2))*elliptic_f(S(2)*atan(S(2)**(S(3)/4)*S(3)**(S(1)/4)*x/S(2)), S(1)/2)/(S(12)*sqrt(S(3)*x**S(4) + S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(S(3)*x**S(4) - x**S(2) + S(2)), x), x, S(6)**(S(3)/4)*sqrt((S(3)*x**S(4) - x**S(2) + S(2))/(sqrt(S(6))*x**S(2) + S(2))**S(2))*(sqrt(S(6))*x**S(2) + S(2))*elliptic_f(S(2)*atan(S(2)**(S(3)/4)*S(3)**(S(1)/4)*x/S(2)), sqrt(S(6))/S(24) + S(1)/2)/(S(12)*sqrt(S(3)*x**S(4) - x**S(2) + S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(S(3)*x**S(4) - S(2)*x**S(2) + S(2)), x), x, S(6)**(S(3)/4)*sqrt((S(3)*x**S(4) - S(2)*x**S(2) + S(2))/(sqrt(S(6))*x**S(2) + S(2))**S(2))*(sqrt(S(6))*x**S(2) + S(2))*elliptic_f(S(2)*atan(S(2)**(S(3)/4)*S(3)**(S(1)/4)*x/S(2)), sqrt(S(6))/S(12) + S(1)/2)/(S(12)*sqrt(S(3)*x**S(4) - S(2)*x**S(2) + S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(S(3)*x**S(4) - S(3)*x**S(2) + S(2)), x), x, S(6)**(S(3)/4)*sqrt((S(3)*x**S(4) - S(3)*x**S(2) + S(2))/(sqrt(S(6))*x**S(2) + S(2))**S(2))*(sqrt(S(6))*x**S(2) + S(2))*elliptic_f(S(2)*atan(S(2)**(S(3)/4)*S(3)**(S(1)/4)*x/S(2)), sqrt(S(6))/S(8) + S(1)/2)/(S(12)*sqrt(S(3)*x**S(4) - S(3)*x**S(2) + S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(S(3)*x**S(4) - S(4)*x**S(2) + S(2)), x), x, S(6)**(S(3)/4)*sqrt((S(3)*x**S(4) - S(4)*x**S(2) + S(2))/(sqrt(S(6))*x**S(2) + S(2))**S(2))*(sqrt(S(6))*x**S(2) + S(2))*elliptic_f(S(2)*atan(S(2)**(S(3)/4)*S(3)**(S(1)/4)*x/S(2)), sqrt(S(6))/S(6) + S(1)/2)/(S(12)*sqrt(S(3)*x**S(4) - S(4)*x**S(2) + S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(S(3)*x**S(4) - S(5)*x**S(2) + S(2)), x), x, S(6)**(S(3)/4)*sqrt((S(3)*x**S(4) - S(5)*x**S(2) + S(2))/(sqrt(S(6))*x**S(2) + S(2))**S(2))*(sqrt(S(6))*x**S(2) + S(2))*elliptic_f(S(2)*atan(S(2)**(S(3)/4)*S(3)**(S(1)/4)*x/S(2)), S(1)/2 + S(5)*sqrt(S(6))/S(24))/(S(12)*sqrt(S(3)*x**S(4) - S(5)*x**S(2) + S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(S(3)*x**S(4) - S(6)*x**S(2) + S(2)), x), x, S(6)**(S(3)/4)*sqrt((S(3)*x**S(4) - S(6)*x**S(2) + S(2))/(sqrt(S(6))*x**S(2) + S(2))**S(2))*(sqrt(S(6))*x**S(2) + S(2))*elliptic_f(S(2)*atan(S(2)**(S(3)/4)*S(3)**(S(1)/4)*x/S(2)), S(1)/2 + sqrt(S(6))/S(4))/(S(12)*sqrt(S(3)*x**S(4) - S(6)*x**S(2) + S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(S(2)*x**S(4) + S(9)*x**S(2) + S(3)), x), x, sqrt((x**S(2)*(-sqrt(S(57)) + S(9)) + S(6))/(x**S(2)*(sqrt(S(57)) + S(9)) + S(6)))*(x**S(2)*(sqrt(S(57)) + S(9)) + S(6))*elliptic_f(atan(x*sqrt(sqrt(S(57))/S(6) + S(3)/2)), S(-19)/4 + S(3)*sqrt(S(57))/S(4))/(sqrt(S(6)*sqrt(S(57)) + S(54))*sqrt(S(2)*x**S(4) + S(9)*x**S(2) + S(3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(S(2)*x**S(4) + S(8)*x**S(2) + S(3)), x), x, sqrt((x**S(2)*(-sqrt(S(10)) + S(4)) + S(3))/(x**S(2)*(sqrt(S(10)) + S(4)) + S(3)))*(x**S(2)*(sqrt(S(10)) + S(4)) + S(3))*elliptic_f(atan(x*sqrt(sqrt(S(10))/S(3) + S(4)/3)), S(-10)/3 + S(4)*sqrt(S(10))/S(3))/(sqrt(S(3)*sqrt(S(10)) + S(12))*sqrt(S(2)*x**S(4) + S(8)*x**S(2) + S(3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(S(2)*x**S(4) + S(7)*x**S(2) + S(3)), x), x, sqrt(S(6))*sqrt((x**S(2) + S(3))/(S(2)*x**S(2) + S(1)))*(S(2)*x**S(2) + S(1))*elliptic_f(atan(sqrt(S(2))*x), S(5)/6)/(S(6)*sqrt(S(2)*x**S(4) + S(7)*x**S(2) + S(3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(S(2)*x**S(4) + S(6)*x**S(2) + S(3)), x), x, sqrt((x**S(2)*(-sqrt(S(3)) + S(3)) + S(3))/(x**S(2)*(sqrt(S(3)) + S(3)) + S(3)))*(x**S(2)*(sqrt(S(3)) + S(3)) + S(3))*elliptic_f(atan(x*sqrt(sqrt(S(3))/S(3) + S(1))), S(-1) + sqrt(S(3)))/(sqrt(S(3)*sqrt(S(3)) + S(9))*sqrt(S(2)*x**S(4) + S(6)*x**S(2) + S(3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(S(2)*x**S(4) + S(5)*x**S(2) + S(3)), x), x, sqrt(S(3))*sqrt((S(2)*x**S(2) + S(3))/(x**S(2) + S(1)))*(x**S(2) + S(1))*elliptic_f(atan(x), S(1)/3)/(S(3)*sqrt(S(2)*x**S(4) + S(5)*x**S(2) + S(3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(S(2)*x**S(4) + S(4)*x**S(2) + S(3)), x), x, S(6)**(S(3)/4)*sqrt((S(2)*x**S(4) + S(4)*x**S(2) + S(3))/(sqrt(S(6))*x**S(2) + S(3))**S(2))*(sqrt(S(6))*x**S(2) + S(3))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*S(3)**(S(3)/4)*x/S(3)), -sqrt(S(6))/S(6) + S(1)/2)/(S(12)*sqrt(S(2)*x**S(4) + S(4)*x**S(2) + S(3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(S(2)*x**S(4) + S(3)*x**S(2) + S(3)), x), x, S(6)**(S(3)/4)*sqrt((S(2)*x**S(4) + S(3)*x**S(2) + S(3))/(sqrt(S(6))*x**S(2) + S(3))**S(2))*(sqrt(S(6))*x**S(2) + S(3))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*S(3)**(S(3)/4)*x/S(3)), -sqrt(S(6))/S(8) + S(1)/2)/(S(12)*sqrt(S(2)*x**S(4) + S(3)*x**S(2) + S(3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(3)), x), x, S(6)**(S(3)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(3))/(sqrt(S(6))*x**S(2) + S(3))**S(2))*(sqrt(S(6))*x**S(2) + S(3))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*S(3)**(S(3)/4)*x/S(3)), -sqrt(S(6))/S(12) + S(1)/2)/(S(12)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(S(2)*x**S(4) + x**S(2) + S(3)), x), x, S(6)**(S(3)/4)*sqrt((S(2)*x**S(4) + x**S(2) + S(3))/(sqrt(S(6))*x**S(2) + S(3))**S(2))*(sqrt(S(6))*x**S(2) + S(3))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*S(3)**(S(3)/4)*x/S(3)), -sqrt(S(6))/S(24) + S(1)/2)/(S(12)*sqrt(S(2)*x**S(4) + x**S(2) + S(3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(S(2)*x**S(4) + S(3)), x), x, S(6)**(S(3)/4)*sqrt((S(2)*x**S(4) + S(3))/(sqrt(S(6))*x**S(2) + S(3))**S(2))*(sqrt(S(6))*x**S(2) + S(3))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*S(3)**(S(3)/4)*x/S(3)), S(1)/2)/(S(12)*sqrt(S(2)*x**S(4) + S(3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(S(2)*x**S(4) - x**S(2) + S(3)), x), x, S(6)**(S(3)/4)*sqrt((S(2)*x**S(4) - x**S(2) + S(3))/(sqrt(S(6))*x**S(2) + S(3))**S(2))*(sqrt(S(6))*x**S(2) + S(3))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*S(3)**(S(3)/4)*x/S(3)), sqrt(S(6))/S(24) + S(1)/2)/(S(12)*sqrt(S(2)*x**S(4) - x**S(2) + S(3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(S(2)*x**S(4) - S(2)*x**S(2) + S(3)), x), x, S(6)**(S(3)/4)*sqrt((S(2)*x**S(4) - S(2)*x**S(2) + S(3))/(sqrt(S(6))*x**S(2) + S(3))**S(2))*(sqrt(S(6))*x**S(2) + S(3))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*S(3)**(S(3)/4)*x/S(3)), sqrt(S(6))/S(12) + S(1)/2)/(S(12)*sqrt(S(2)*x**S(4) - S(2)*x**S(2) + S(3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(S(2)*x**S(4) - S(3)*x**S(2) + S(3)), x), x, S(6)**(S(3)/4)*sqrt((S(2)*x**S(4) - S(3)*x**S(2) + S(3))/(sqrt(S(6))*x**S(2) + S(3))**S(2))*(sqrt(S(6))*x**S(2) + S(3))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*S(3)**(S(3)/4)*x/S(3)), sqrt(S(6))/S(8) + S(1)/2)/(S(12)*sqrt(S(2)*x**S(4) - S(3)*x**S(2) + S(3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(S(2)*x**S(4) - S(4)*x**S(2) + S(3)), x), x, S(6)**(S(3)/4)*sqrt((S(2)*x**S(4) - S(4)*x**S(2) + S(3))/(sqrt(S(6))*x**S(2) + S(3))**S(2))*(sqrt(S(6))*x**S(2) + S(3))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*S(3)**(S(3)/4)*x/S(3)), sqrt(S(6))/S(6) + S(1)/2)/(S(12)*sqrt(S(2)*x**S(4) - S(4)*x**S(2) + S(3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(S(2)*x**S(4) - S(5)*x**S(2) + S(3)), x), x, S(6)**(S(3)/4)*sqrt((S(2)*x**S(4) - S(5)*x**S(2) + S(3))/(sqrt(S(6))*x**S(2) + S(3))**S(2))*(sqrt(S(6))*x**S(2) + S(3))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*S(3)**(S(3)/4)*x/S(3)), S(1)/2 + S(5)*sqrt(S(6))/S(24))/(S(12)*sqrt(S(2)*x**S(4) - S(5)*x**S(2) + S(3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(S(2)*x**S(4) - S(6)*x**S(2) + S(3)), x), x, S(6)**(S(3)/4)*sqrt((S(2)*x**S(4) - S(6)*x**S(2) + S(3))/(sqrt(S(6))*x**S(2) + S(3))**S(2))*(sqrt(S(6))*x**S(2) + S(3))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*S(3)**(S(3)/4)*x/S(3)), S(1)/2 + sqrt(S(6))/S(4))/(S(12)*sqrt(S(2)*x**S(4) - S(6)*x**S(2) + S(3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(S(2)*x**S(4) - S(7)*x**S(2) + S(3)), x), x, S(6)**(S(3)/4)*sqrt((S(2)*x**S(4) - S(7)*x**S(2) + S(3))/(sqrt(S(6))*x**S(2) + S(3))**S(2))*(sqrt(S(6))*x**S(2) + S(3))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*S(3)**(S(3)/4)*x/S(3)), S(1)/2 + S(7)*sqrt(S(6))/S(24))/(S(12)*sqrt(S(2)*x**S(4) - S(7)*x**S(2) + S(3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(-S(2)*x**S(4) + S(7)*x**S(2) + S(-3)), x), x, -sqrt(S(5))*elliptic_f(acos(sqrt(S(3))*x/S(3)), S(6)/5)/S(5), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(-S(2)*x**S(4) + S(6)*x**S(2) + S(-3)), x), x, -sqrt(S(2))*S(3)**(S(3)/4)*elliptic_f(acos(x*sqrt(-sqrt(S(3))/S(3) + S(1))), S(1)/2 + sqrt(S(3))/S(2))/S(6), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(-S(2)*x**S(4) + S(5)*x**S(2) + S(-3)), x), x, -elliptic_f(acos(sqrt(S(6))*x/S(3)), S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(-S(2)*x**S(4) + S(4)*x**S(2) + S(-3)), x), x, S(6)**(S(3)/4)*sqrt((S(2)*x**S(4) - S(4)*x**S(2) + S(3))/(sqrt(S(6))*x**S(2) + S(3))**S(2))*(sqrt(S(6))*x**S(2) + S(3))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*S(3)**(S(3)/4)*x/S(3)), sqrt(S(6))/S(6) + S(1)/2)/(S(12)*sqrt(-S(2)*x**S(4) + S(4)*x**S(2) + S(-3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(-S(2)*x**S(4) + S(3)*x**S(2) + S(-3)), x), x, S(6)**(S(3)/4)*sqrt((S(2)*x**S(4) - S(3)*x**S(2) + S(3))/(sqrt(S(6))*x**S(2) + S(3))**S(2))*(sqrt(S(6))*x**S(2) + S(3))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*S(3)**(S(3)/4)*x/S(3)), sqrt(S(6))/S(8) + S(1)/2)/(S(12)*sqrt(-S(2)*x**S(4) + S(3)*x**S(2) + S(-3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(-S(2)*x**S(4) + S(2)*x**S(2) + S(-3)), x), x, S(6)**(S(3)/4)*sqrt((S(2)*x**S(4) - S(2)*x**S(2) + S(3))/(sqrt(S(6))*x**S(2) + S(3))**S(2))*(sqrt(S(6))*x**S(2) + S(3))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*S(3)**(S(3)/4)*x/S(3)), sqrt(S(6))/S(12) + S(1)/2)/(S(12)*sqrt(-S(2)*x**S(4) + S(2)*x**S(2) + S(-3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(-S(2)*x**S(4) + x**S(2) + S(-3)), x), x, S(6)**(S(3)/4)*sqrt((S(2)*x**S(4) - x**S(2) + S(3))/(sqrt(S(6))*x**S(2) + S(3))**S(2))*(sqrt(S(6))*x**S(2) + S(3))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*S(3)**(S(3)/4)*x/S(3)), sqrt(S(6))/S(24) + S(1)/2)/(S(12)*sqrt(-S(2)*x**S(4) + x**S(2) + S(-3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(-S(2)*x**S(4) + S(-3)), x), x, S(6)**(S(3)/4)*sqrt((S(2)*x**S(4) + S(3))/(sqrt(S(6))*x**S(2) + S(3))**S(2))*(sqrt(S(6))*x**S(2) + S(3))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*S(3)**(S(3)/4)*x/S(3)), S(1)/2)/(S(12)*sqrt(-S(2)*x**S(4) + S(-3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(-S(2)*x**S(4) - x**S(2) + S(-3)), x), x, S(6)**(S(3)/4)*sqrt((S(2)*x**S(4) + x**S(2) + S(3))/(sqrt(S(6))*x**S(2) + S(3))**S(2))*(sqrt(S(6))*x**S(2) + S(3))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*S(3)**(S(3)/4)*x/S(3)), -sqrt(S(6))/S(24) + S(1)/2)/(S(12)*sqrt(-S(2)*x**S(4) - x**S(2) + S(-3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(-S(2)*x**S(4) - S(2)*x**S(2) + S(-3)), x), x, S(6)**(S(3)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(3))/(sqrt(S(6))*x**S(2) + S(3))**S(2))*(sqrt(S(6))*x**S(2) + S(3))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*S(3)**(S(3)/4)*x/S(3)), -sqrt(S(6))/S(12) + S(1)/2)/(S(12)*sqrt(-S(2)*x**S(4) - S(2)*x**S(2) + S(-3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(-S(2)*x**S(4) - S(3)*x**S(2) + S(-3)), x), x, S(6)**(S(3)/4)*sqrt((S(2)*x**S(4) + S(3)*x**S(2) + S(3))/(sqrt(S(6))*x**S(2) + S(3))**S(2))*(sqrt(S(6))*x**S(2) + S(3))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*S(3)**(S(3)/4)*x/S(3)), -sqrt(S(6))/S(8) + S(1)/2)/(S(12)*sqrt(-S(2)*x**S(4) - S(3)*x**S(2) + S(-3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(-S(2)*x**S(4) - S(4)*x**S(2) + S(-3)), x), x, S(6)**(S(3)/4)*sqrt((S(2)*x**S(4) + S(4)*x**S(2) + S(3))/(sqrt(S(6))*x**S(2) + S(3))**S(2))*(sqrt(S(6))*x**S(2) + S(3))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*S(3)**(S(3)/4)*x/S(3)), -sqrt(S(6))/S(6) + S(1)/2)/(S(12)*sqrt(-S(2)*x**S(4) - S(4)*x**S(2) + S(-3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(-S(2)*x**S(4) - S(5)*x**S(2) + S(-3)), x), x, sqrt(S(3))*sqrt(S(2)*x**S(2) + S(3))*elliptic_f(atan(x), S(1)/3)/(S(3)*sqrt((S(2)*x**S(2) + S(3))/(x**S(2) + S(1)))*sqrt(-x**S(2) + S(-1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(-S(3)*x**S(4) + S(6)*x**S(2) + S(-2)), x), x, -sqrt(S(2))*S(3)**(S(3)/4)*elliptic_f(acos(sqrt(S(3))*x/sqrt(sqrt(S(3)) + S(3))), S(1)/2 + sqrt(S(3))/S(2))/S(6), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(-S(3)*x**S(4) + S(5)*x**S(2) + S(-2)), x), x, -elliptic_f(acos(x), S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(-S(3)*x**S(4) + S(4)*x**S(2) + S(-2)), x), x, S(6)**(S(3)/4)*sqrt((S(3)*x**S(4) - S(4)*x**S(2) + S(2))/(sqrt(S(6))*x**S(2) + S(2))**S(2))*(sqrt(S(6))*x**S(2) + S(2))*elliptic_f(S(2)*atan(S(2)**(S(3)/4)*S(3)**(S(1)/4)*x/S(2)), sqrt(S(6))/S(6) + S(1)/2)/(S(12)*sqrt(-S(3)*x**S(4) + S(4)*x**S(2) + S(-2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(-S(3)*x**S(4) + S(3)*x**S(2) + S(-2)), x), x, S(6)**(S(3)/4)*sqrt((S(3)*x**S(4) - S(3)*x**S(2) + S(2))/(sqrt(S(6))*x**S(2) + S(2))**S(2))*(sqrt(S(6))*x**S(2) + S(2))*elliptic_f(S(2)*atan(S(2)**(S(3)/4)*S(3)**(S(1)/4)*x/S(2)), sqrt(S(6))/S(8) + S(1)/2)/(S(12)*sqrt(-S(3)*x**S(4) + S(3)*x**S(2) + S(-2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(-S(3)*x**S(4) + S(2)*x**S(2) + S(-2)), x), x, S(6)**(S(3)/4)*sqrt((S(3)*x**S(4) - S(2)*x**S(2) + S(2))/(sqrt(S(6))*x**S(2) + S(2))**S(2))*(sqrt(S(6))*x**S(2) + S(2))*elliptic_f(S(2)*atan(S(2)**(S(3)/4)*S(3)**(S(1)/4)*x/S(2)), sqrt(S(6))/S(12) + S(1)/2)/(S(12)*sqrt(-S(3)*x**S(4) + S(2)*x**S(2) + S(-2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(-S(3)*x**S(4) + x**S(2) + S(-2)), x), x, S(6)**(S(3)/4)*sqrt((S(3)*x**S(4) - x**S(2) + S(2))/(sqrt(S(6))*x**S(2) + S(2))**S(2))*(sqrt(S(6))*x**S(2) + S(2))*elliptic_f(S(2)*atan(S(2)**(S(3)/4)*S(3)**(S(1)/4)*x/S(2)), sqrt(S(6))/S(24) + S(1)/2)/(S(12)*sqrt(-S(3)*x**S(4) + x**S(2) + S(-2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(-S(3)*x**S(4) + S(-2)), x), x, S(6)**(S(3)/4)*sqrt((S(3)*x**S(4) + S(2))/(sqrt(S(6))*x**S(2) + S(2))**S(2))*(sqrt(S(6))*x**S(2) + S(2))*elliptic_f(S(2)*atan(S(2)**(S(3)/4)*S(3)**(S(1)/4)*x/S(2)), S(1)/2)/(S(12)*sqrt(-S(3)*x**S(4) + S(-2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(-S(3)*x**S(4) - x**S(2) + S(-2)), x), x, S(6)**(S(3)/4)*sqrt((S(3)*x**S(4) + x**S(2) + S(2))/(sqrt(S(6))*x**S(2) + S(2))**S(2))*(sqrt(S(6))*x**S(2) + S(2))*elliptic_f(S(2)*atan(S(2)**(S(3)/4)*S(3)**(S(1)/4)*x/S(2)), -sqrt(S(6))/S(24) + S(1)/2)/(S(12)*sqrt(-S(3)*x**S(4) - x**S(2) + S(-2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(-S(3)*x**S(4) - S(2)*x**S(2) + S(-2)), x), x, S(6)**(S(3)/4)*sqrt((S(3)*x**S(4) + S(2)*x**S(2) + S(2))/(sqrt(S(6))*x**S(2) + S(2))**S(2))*(sqrt(S(6))*x**S(2) + S(2))*elliptic_f(S(2)*atan(S(2)**(S(3)/4)*S(3)**(S(1)/4)*x/S(2)), -sqrt(S(6))/S(12) + S(1)/2)/(S(12)*sqrt(-S(3)*x**S(4) - S(2)*x**S(2) + S(-2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(-S(3)*x**S(4) - S(3)*x**S(2) + S(-2)), x), x, S(6)**(S(3)/4)*sqrt((S(3)*x**S(4) + S(3)*x**S(2) + S(2))/(sqrt(S(6))*x**S(2) + S(2))**S(2))*(sqrt(S(6))*x**S(2) + S(2))*elliptic_f(S(2)*atan(S(2)**(S(3)/4)*S(3)**(S(1)/4)*x/S(2)), -sqrt(S(6))/S(8) + S(1)/2)/(S(12)*sqrt(-S(3)*x**S(4) - S(3)*x**S(2) + S(-2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(-S(3)*x**S(4) - S(4)*x**S(2) + S(-2)), x), x, S(6)**(S(3)/4)*sqrt((S(3)*x**S(4) + S(4)*x**S(2) + S(2))/(sqrt(S(6))*x**S(2) + S(2))**S(2))*(sqrt(S(6))*x**S(2) + S(2))*elliptic_f(S(2)*atan(S(2)**(S(3)/4)*S(3)**(S(1)/4)*x/S(2)), -sqrt(S(6))/S(6) + S(1)/2)/(S(12)*sqrt(-S(3)*x**S(4) - S(4)*x**S(2) + S(-2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(-S(3)*x**S(4) - S(5)*x**S(2) + S(-2)), x), x, -sqrt(S(2))*sqrt(-S(3)*x**S(2) + S(-2))*elliptic_f(atan(x), S(-1)/2)/(S(2)*sqrt((S(3)*x**S(2) + S(2))/(x**S(2) + S(1)))*sqrt(x**S(2) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(S(5)*x**S(4) + S(5)*x**S(2) + S(2)), x), x, S(10)**(S(3)/4)*sqrt((S(5)*x**S(4) + S(5)*x**S(2) + S(2))/(sqrt(S(10))*x**S(2) + S(2))**S(2))*(sqrt(S(10))*x**S(2) + S(2))*elliptic_f(S(2)*atan(S(2)**(S(3)/4)*S(5)**(S(1)/4)*x/S(2)), -sqrt(S(10))/S(8) + S(1)/2)/(S(20)*sqrt(S(5)*x**S(4) + S(5)*x**S(2) + S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(S(4)*x**S(4) + S(5)*x**S(2) + S(2)), x), x, S(2)**(S(1)/4)*sqrt((S(4)*x**S(4) + S(5)*x**S(2) + S(2))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*x), -S(5)*sqrt(S(2))/S(16) + S(1)/2)/(S(4)*sqrt(S(4)*x**S(4) + S(5)*x**S(2) + S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(S(3)*x**S(4) + S(5)*x**S(2) + S(2)), x), x, sqrt(S(2))*sqrt((S(3)*x**S(2) + S(2))/(x**S(2) + S(1)))*(x**S(2) + S(1))*elliptic_f(atan(x), S(-1)/2)/(S(2)*sqrt(S(3)*x**S(4) + S(5)*x**S(2) + S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(S(2)*x**S(4) + S(5)*x**S(2) + S(2)), x), x, sqrt((x**S(2) + S(2))/(S(2)*x**S(2) + S(1)))*(S(2)*x**S(2) + S(1))*elliptic_f(atan(sqrt(S(2))*x), S(3)/4)/(S(2)*sqrt(S(2)*x**S(4) + S(5)*x**S(2) + S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(x**S(4) + S(5)*x**S(2) + S(2)), x), x, sqrt((x**S(2)*(-sqrt(S(17)) + S(5)) + S(4))/(x**S(2)*(sqrt(S(17)) + S(5)) + S(4)))*(x**S(2)*(sqrt(S(17)) + S(5)) + S(4))*elliptic_f(atan(x*sqrt(sqrt(S(17)) + S(5))/S(2)), S(-17)/4 + S(5)*sqrt(S(17))/S(4))/(S(2)*sqrt(sqrt(S(17)) + S(5))*sqrt(x**S(4) + S(5)*x**S(2) + S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(-x**S(4) + S(5)*x**S(2) + S(2)), x), x, sqrt(S(2))*elliptic_f(asin(sqrt(S(2))*x/sqrt(S(5) + sqrt(S(33)))), S(-29)/4 - S(5)*sqrt(S(33))/S(4))/sqrt(S(-5) + sqrt(S(33))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(-S(2)*x**S(4) + S(5)*x**S(2) + S(2)), x), x, sqrt(S(2))*elliptic_f(asin(S(2)*x/sqrt(S(5) + sqrt(S(41)))), S(-33)/8 - S(5)*sqrt(S(41))/S(8))/sqrt(S(-5) + sqrt(S(41))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(-S(3)*x**S(4) + S(5)*x**S(2) + S(2)), x), x, elliptic_f(asin(sqrt(S(2))*x/S(2)), S(-6)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(-S(4)*x**S(4) + S(5)*x**S(2) + S(2)), x), x, sqrt(S(2))*elliptic_f(asin(S(2)*sqrt(S(2))*x/sqrt(S(5) + sqrt(S(57)))), S(-41)/16 - S(5)*sqrt(S(57))/S(16))/sqrt(S(-5) + sqrt(S(57))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(-S(5)*x**S(4) + S(5)*x**S(2) + S(2)), x), x, sqrt(S(2))*elliptic_f(asin(sqrt(S(10))*x/sqrt(S(5) + sqrt(S(65)))), S(-9)/4 - sqrt(S(65))/S(4))/sqrt(S(-5) + sqrt(S(65))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(-S(6)*x**S(4) + S(5)*x**S(2) + S(2)), x), x, sqrt(S(2))*elliptic_f(asin(S(2)*sqrt(S(3))*x/sqrt(S(5) + sqrt(S(73)))), S(-49)/24 - S(5)*sqrt(S(73))/S(24))/sqrt(S(-5) + sqrt(S(73))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(-S(7)*x**S(4) + S(5)*x**S(2) + S(2)), x), x, sqrt(S(2))*elliptic_f(asin(x), S(-7)/2)/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(-S(8)*x**S(4) + S(5)*x**S(2) + S(2)), x), x, sqrt(S(2))*elliptic_f(asin(S(4)*x/sqrt(S(5) + sqrt(S(89)))), S(-57)/32 - S(5)*sqrt(S(89))/S(32))/sqrt(S(-5) + sqrt(S(89))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(-S(9)*x**S(4) + S(5)*x**S(2) + S(2)), x), x, sqrt(S(2))*elliptic_f(asin(S(3)*sqrt(S(2))*x/sqrt(S(5) + sqrt(S(97)))), S(-61)/36 - S(5)*sqrt(S(97))/S(36))/sqrt(S(-5) + sqrt(S(97))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)/sqrt(b*x**S(2) + c*x**S(4)), x), x, -S(2)*b*sqrt(b*x**S(2) + c*x**S(4))/(S(3)*c**S(2)*x) + x*sqrt(b*x**S(2) + c*x**S(4))/(S(3)*c), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/sqrt(b*x**S(2) + c*x**S(4)), x), x, -b*atanh(sqrt(c)*x**S(2)/sqrt(b*x**S(2) + c*x**S(4)))/(S(2)*c**(S(3)/2)) + sqrt(b*x**S(2) + c*x**S(4))/(S(2)*c), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/sqrt(b*x**S(2) + c*x**S(4)), x), x, sqrt(b*x**S(2) + c*x**S(4))/(c*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/sqrt(b*x**S(2) + c*x**S(4)), x), x, atanh(sqrt(c)*x**S(2)/sqrt(b*x**S(2) + c*x**S(4)))/sqrt(c), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(b*x**S(2) + c*x**S(4)), x), x, -atanh(sqrt(b)*x/sqrt(b*x**S(2) + c*x**S(4)))/sqrt(b), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*sqrt(b*x**S(2) + c*x**S(4))), x), x, -sqrt(b*x**S(2) + c*x**S(4))/(b*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*sqrt(b*x**S(2) + c*x**S(4))), x), x, -sqrt(b*x**S(2) + c*x**S(4))/(S(2)*b*x**S(3)) + c*atanh(sqrt(b)*x/sqrt(b*x**S(2) + c*x**S(4)))/(S(2)*b**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(3)*sqrt(b*x**S(2) + c*x**S(4))), x), x, -sqrt(b*x**S(2) + c*x**S(4))/(S(3)*b*x**S(4)) + S(2)*c*sqrt(b*x**S(2) + c*x**S(4))/(S(3)*b**S(2)*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(4)*sqrt(b*x**S(2) + c*x**S(4))), x), x, -sqrt(b*x**S(2) + c*x**S(4))/(S(4)*b*x**S(5)) + S(3)*c*sqrt(b*x**S(2) + c*x**S(4))/(S(8)*b**S(2)*x**S(3)) - S(3)*c**S(2)*atanh(sqrt(b)*x/sqrt(b*x**S(2) + c*x**S(4)))/(S(8)*b**(S(5)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)/sqrt(a + c*x**S(4)), x), x, -a**(S(3)/4)*sqrt((a + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2)/(S(6)*c**(S(5)/4)*sqrt(a + c*x**S(4))) + x*sqrt(a + c*x**S(4))/(S(3)*c), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/sqrt(a + c*x**S(4)), x), x, sqrt(a + c*x**S(4))/(S(2)*c), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/sqrt(a + c*x**S(4)), x), x, -a**(S(1)/4)*sqrt((a + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*elliptic_e(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2)/(c**(S(3)/4)*sqrt(a + c*x**S(4))) + a**(S(1)/4)*sqrt((a + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2)/(S(2)*c**(S(3)/4)*sqrt(a + c*x**S(4))) + x*sqrt(a + c*x**S(4))/(sqrt(c)*(sqrt(a) + sqrt(c)*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/sqrt(a + c*x**S(4)), x), x, atanh(sqrt(c)*x**S(2)/sqrt(a + c*x**S(4)))/(S(2)*sqrt(c)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(a + c*x**S(4)), x), x, sqrt((a + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2)/(S(2)*a**(S(1)/4)*c**(S(1)/4)*sqrt(a + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*sqrt(a + c*x**S(4))), x), x, -atanh(sqrt(a + c*x**S(4))/sqrt(a))/(S(2)*sqrt(a)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*sqrt(a + c*x**S(4))), x), x, sqrt(c)*x*sqrt(a + c*x**S(4))/(a*(sqrt(a) + sqrt(c)*x**S(2))) - sqrt(a + c*x**S(4))/(a*x) - c**(S(1)/4)*sqrt((a + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*elliptic_e(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2)/(a**(S(3)/4)*sqrt(a + c*x**S(4))) + c**(S(1)/4)*sqrt((a + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2)/(S(2)*a**(S(3)/4)*sqrt(a + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(3)*sqrt(a + c*x**S(4))), x), x, -sqrt(a + c*x**S(4))/(S(2)*a*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(4)*sqrt(a + c*x**S(4))), x), x, -sqrt(a + c*x**S(4))/(S(3)*a*x**S(3)) - c**(S(3)/4)*sqrt((a + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2)/(S(6)*a**(S(5)/4)*sqrt(a + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)/sqrt(a + b*x**S(2)), x), x, S(3)*a**S(2)*atanh(sqrt(b)*x/sqrt(a + b*x**S(2)))/(S(8)*b**(S(5)/2)) - S(3)*a*x*sqrt(a + b*x**S(2))/(S(8)*b**S(2)) + x**S(3)*sqrt(a + b*x**S(2))/(S(4)*b), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/sqrt(a + b*x**S(2)), x), x, -a*sqrt(a + b*x**S(2))/b**S(2) + (a + b*x**S(2))**(S(3)/2)/(S(3)*b**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/sqrt(a + b*x**S(2)), x), x, -a*atanh(sqrt(b)*x/sqrt(a + b*x**S(2)))/(S(2)*b**(S(3)/2)) + x*sqrt(a + b*x**S(2))/(S(2)*b), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/sqrt(a + b*x**S(2)), x), x, sqrt(a + b*x**S(2))/b, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(a + b*x**S(2)), x), x, atanh(sqrt(b)*x/sqrt(a + b*x**S(2)))/sqrt(b), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*sqrt(a + b*x**S(2))), x), x, -atanh(sqrt(a + b*x**S(2))/sqrt(a))/sqrt(a), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*sqrt(a + b*x**S(2))), x), x, -sqrt(a + b*x**S(2))/(a*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(3)*sqrt(a + b*x**S(2))), x), x, -sqrt(a + b*x**S(2))/(S(2)*a*x**S(2)) + b*atanh(sqrt(a + b*x**S(2))/sqrt(a))/(S(2)*a**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(4)*sqrt(a + b*x**S(2))), x), x, -sqrt(a + b*x**S(2))/(S(3)*a*x**S(3)) + S(2)*b*sqrt(a + b*x**S(2))/(S(3)*a**S(2)*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)/sqrt(c*x**S(4)), x), x, x*sqrt(c*x**S(4))/(S(3)*c), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/sqrt(c*x**S(4)), x), x, sqrt(c*x**S(4))/(S(2)*c), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/sqrt(c*x**S(4)), x), x, x**S(3)/sqrt(c*x**S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/sqrt(c*x**S(4)), x), x, x**S(2)*log(x)/sqrt(c*x**S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(c*x**S(4)), x), x, -x/sqrt(c*x**S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*sqrt(c*x**S(4))), x), x, -S(1)/(S(2)*sqrt(c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*sqrt(c*x**S(4))), x), x, -S(1)/(S(3)*x*sqrt(c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(3)*sqrt(c*x**S(4))), x), x, -S(1)/(S(4)*x**S(2)*sqrt(c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(4)*sqrt(c*x**S(4))), x), x, -S(1)/(S(5)*x**S(3)*sqrt(c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)/sqrt(a), x), x, x**S(5)/(S(5)*sqrt(a)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/sqrt(a), x), x, x**S(4)/(S(4)*sqrt(a)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/sqrt(a), x), x, x**S(3)/(S(3)*sqrt(a)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/sqrt(a), x), x, x**S(2)/(S(2)*sqrt(a)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(a), x), x, x/sqrt(a), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(sqrt(a)*x), x), x, log(x)/sqrt(a), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(sqrt(a)*x**S(2)), x), x, -S(1)/(sqrt(a)*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(sqrt(a)*x**S(3)), x), x, -S(1)/(S(2)*sqrt(a)*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(sqrt(a)*x**S(4)), x), x, -S(1)/(S(3)*sqrt(a)*x**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(-x**S(4) - S(2)*x**S(2) + S(3)), x), x, sqrt(S(3))*elliptic_f(asin(x), S(-1)/3)/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(-x**S(4) + S(5)*x**S(2) + S(-1)), x), x, -S(21)**(S(3)/4)*elliptic_f(acos(sqrt(S(2))*x/sqrt(sqrt(S(21)) + S(5))), S(1)/2 + S(5)*sqrt(S(21))/S(42))/S(21), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(5)/2)*(a + b*x**S(2) + c*x**S(4)), x), x, S(2)*a*x**(S(7)/2)/S(7) + S(2)*b*x**(S(11)/2)/S(11) + S(2)*c*x**(S(15)/2)/S(15), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(3)/2)*(a + b*x**S(2) + c*x**S(4)), x), x, S(2)*a*x**(S(5)/2)/S(5) + S(2)*b*x**(S(9)/2)/S(9) + S(2)*c*x**(S(13)/2)/S(13), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(x)*(a + b*x**S(2) + c*x**S(4)), x), x, S(2)*a*x**(S(3)/2)/S(3) + S(2)*b*x**(S(7)/2)/S(7) + S(2)*c*x**(S(11)/2)/S(11), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))/sqrt(x), x), x, S(2)*a*sqrt(x) + S(2)*b*x**(S(5)/2)/S(5) + S(2)*c*x**(S(9)/2)/S(9), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))/x**(S(3)/2), x), x, -S(2)*a/sqrt(x) + S(2)*b*x**(S(3)/2)/S(3) + S(2)*c*x**(S(7)/2)/S(7), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))/x**(S(5)/2), x), x, -S(2)*a/(S(3)*x**(S(3)/2)) + S(2)*b*sqrt(x) + S(2)*c*x**(S(5)/2)/S(5), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))/x**(S(7)/2), x), x, -S(2)*a/(S(5)*x**(S(5)/2)) - S(2)*b/sqrt(x) + S(2)*c*x**(S(3)/2)/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(5)/2)*(a + b*x**S(2) + c*x**S(4))**S(2), x), x, S(2)*a**S(2)*x**(S(7)/2)/S(7) + S(4)*a*b*x**(S(11)/2)/S(11) + S(4)*b*c*x**(S(19)/2)/S(19) + S(2)*c**S(2)*x**(S(23)/2)/S(23) + x**(S(15)/2)*(S(4)*a*c/S(15) + S(2)*b**S(2)/S(15)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(3)/2)*(a + b*x**S(2) + c*x**S(4))**S(2), x), x, S(2)*a**S(2)*x**(S(5)/2)/S(5) + S(4)*a*b*x**(S(9)/2)/S(9) + S(4)*b*c*x**(S(17)/2)/S(17) + S(2)*c**S(2)*x**(S(21)/2)/S(21) + x**(S(13)/2)*(S(4)*a*c/S(13) + S(2)*b**S(2)/S(13)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(x)*(a + b*x**S(2) + c*x**S(4))**S(2), x), x, S(2)*a**S(2)*x**(S(3)/2)/S(3) + S(4)*a*b*x**(S(7)/2)/S(7) + S(4)*b*c*x**(S(15)/2)/S(15) + S(2)*c**S(2)*x**(S(19)/2)/S(19) + x**(S(11)/2)*(S(4)*a*c/S(11) + S(2)*b**S(2)/S(11)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))**S(2)/sqrt(x), x), x, S(2)*a**S(2)*sqrt(x) + S(4)*a*b*x**(S(5)/2)/S(5) + S(4)*b*c*x**(S(13)/2)/S(13) + S(2)*c**S(2)*x**(S(17)/2)/S(17) + x**(S(9)/2)*(S(4)*a*c/S(9) + S(2)*b**S(2)/S(9)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))**S(2)/x**(S(3)/2), x), x, -S(2)*a**S(2)/sqrt(x) + S(4)*a*b*x**(S(3)/2)/S(3) + S(4)*b*c*x**(S(11)/2)/S(11) + S(2)*c**S(2)*x**(S(15)/2)/S(15) + x**(S(7)/2)*(S(4)*a*c/S(7) + S(2)*b**S(2)/S(7)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))**S(2)/x**(S(5)/2), x), x, -S(2)*a**S(2)/(S(3)*x**(S(3)/2)) + S(4)*a*b*sqrt(x) + S(4)*b*c*x**(S(9)/2)/S(9) + S(2)*c**S(2)*x**(S(13)/2)/S(13) + x**(S(5)/2)*(S(4)*a*c/S(5) + S(2)*b**S(2)/S(5)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))**S(2)/x**(S(7)/2), x), x, -S(2)*a**S(2)/(S(5)*x**(S(5)/2)) - S(4)*a*b/sqrt(x) + S(4)*b*c*x**(S(7)/2)/S(7) + S(2)*c**S(2)*x**(S(11)/2)/S(11) + x**(S(3)/2)*(S(4)*a*c/S(3) + S(2)*b**S(2)/S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(5)/2)*(a + b*x**S(2) + c*x**S(4))**S(3), x), x, S(2)*a**S(3)*x**(S(7)/2)/S(7) + S(6)*a**S(2)*b*x**(S(11)/2)/S(11) + S(2)*a*x**(S(15)/2)*(a*c + b**S(2))/S(5) + S(2)*b*c**S(2)*x**(S(27)/2)/S(9) + S(2)*b*x**(S(19)/2)*(S(6)*a*c + b**S(2))/S(19) + S(2)*c**S(3)*x**(S(31)/2)/S(31) + S(6)*c*x**(S(23)/2)*(a*c + b**S(2))/S(23), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(3)/2)*(a + b*x**S(2) + c*x**S(4))**S(3), x), x, S(2)*a**S(3)*x**(S(5)/2)/S(5) + S(2)*a**S(2)*b*x**(S(9)/2)/S(3) + S(6)*a*x**(S(13)/2)*(a*c + b**S(2))/S(13) + S(6)*b*c**S(2)*x**(S(25)/2)/S(25) + S(2)*b*x**(S(17)/2)*(S(6)*a*c + b**S(2))/S(17) + S(2)*c**S(3)*x**(S(29)/2)/S(29) + S(2)*c*x**(S(21)/2)*(a*c + b**S(2))/S(7), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(x)*(a + b*x**S(2) + c*x**S(4))**S(3), x), x, S(2)*a**S(3)*x**(S(3)/2)/S(3) + S(6)*a**S(2)*b*x**(S(7)/2)/S(7) + S(6)*a*x**(S(11)/2)*(a*c + b**S(2))/S(11) + S(6)*b*c**S(2)*x**(S(23)/2)/S(23) + S(2)*b*x**(S(15)/2)*(S(6)*a*c + b**S(2))/S(15) + S(2)*c**S(3)*x**(S(27)/2)/S(27) + S(6)*c*x**(S(19)/2)*(a*c + b**S(2))/S(19), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))**S(3)/sqrt(x), x), x, S(2)*a**S(3)*sqrt(x) + S(6)*a**S(2)*b*x**(S(5)/2)/S(5) + S(2)*a*x**(S(9)/2)*(a*c + b**S(2))/S(3) + S(2)*b*c**S(2)*x**(S(21)/2)/S(7) + S(2)*b*x**(S(13)/2)*(S(6)*a*c + b**S(2))/S(13) + S(2)*c**S(3)*x**(S(25)/2)/S(25) + S(6)*c*x**(S(17)/2)*(a*c + b**S(2))/S(17), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))**S(3)/x**(S(3)/2), x), x, -S(2)*a**S(3)/sqrt(x) + S(2)*a**S(2)*b*x**(S(3)/2) + S(6)*a*x**(S(7)/2)*(a*c + b**S(2))/S(7) + S(6)*b*c**S(2)*x**(S(19)/2)/S(19) + S(2)*b*x**(S(11)/2)*(S(6)*a*c + b**S(2))/S(11) + S(2)*c**S(3)*x**(S(23)/2)/S(23) + S(2)*c*x**(S(15)/2)*(a*c + b**S(2))/S(5), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))**S(3)/x**(S(5)/2), x), x, -S(2)*a**S(3)/(S(3)*x**(S(3)/2)) + S(6)*a**S(2)*b*sqrt(x) + S(6)*a*x**(S(5)/2)*(a*c + b**S(2))/S(5) + S(6)*b*c**S(2)*x**(S(17)/2)/S(17) + S(2)*b*x**(S(9)/2)*(S(6)*a*c + b**S(2))/S(9) + S(2)*c**S(3)*x**(S(21)/2)/S(21) + S(6)*c*x**(S(13)/2)*(a*c + b**S(2))/S(13), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))**S(3)/x**(S(7)/2), x), x, -S(2)*a**S(3)/(S(5)*x**(S(5)/2)) - S(6)*a**S(2)*b/sqrt(x) + S(2)*a*x**(S(3)/2)*(a*c + b**S(2)) + S(2)*b*c**S(2)*x**(S(15)/2)/S(5) + S(2)*b*x**(S(7)/2)*(S(6)*a*c + b**S(2))/S(7) + S(2)*c**S(3)*x**(S(19)/2)/S(19) + S(6)*c*x**(S(11)/2)*(a*c + b**S(2))/S(11), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(9)/2)/(a + b*x**S(2) + c*x**S(4)), x), x, S(2)*x**(S(3)/2)/(S(3)*c) - S(2)**(S(1)/4)*(b - (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(2)*c**(S(7)/4)*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)) + S(2)**(S(1)/4)*(b - (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(2)*c**(S(7)/4)*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)) - S(2)**(S(1)/4)*(b + (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(2)*c**(S(7)/4)*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)) + S(2)**(S(1)/4)*(b + (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(2)*c**(S(7)/4)*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(7)/2)/(a + b*x**S(2) + c*x**S(4)), x), x, S(2)*sqrt(x)/c + S(2)**(S(3)/4)*(b - (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(2)*c**(S(5)/4)*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)) + S(2)**(S(3)/4)*(b - (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(2)*c**(S(5)/4)*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)) + S(2)**(S(3)/4)*(b + (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(2)*c**(S(5)/4)*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)) + S(2)**(S(3)/4)*(b + (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(2)*c**(S(5)/4)*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(5)/2)/(a + b*x**S(2) + c*x**S(4)), x), x, -S(2)**(S(1)/4)*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)*atan(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(2)*c**(S(3)/4)*sqrt(-S(4)*a*c + b**S(2))) + S(2)**(S(1)/4)*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(2)*c**(S(3)/4)*sqrt(-S(4)*a*c + b**S(2))) + S(2)**(S(1)/4)*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)*atan(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(2)*c**(S(3)/4)*sqrt(-S(4)*a*c + b**S(2))) - S(2)**(S(1)/4)*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(2)*c**(S(3)/4)*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(3)/2)/(a + b*x**S(2) + c*x**S(4)), x), x, S(2)**(S(3)/4)*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)*atan(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(2)*c**(S(1)/4)*sqrt(-S(4)*a*c + b**S(2))) + S(2)**(S(3)/4)*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(2)*c**(S(1)/4)*sqrt(-S(4)*a*c + b**S(2))) - S(2)**(S(3)/4)*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)*atan(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(2)*c**(S(1)/4)*sqrt(-S(4)*a*c + b**S(2))) - S(2)**(S(3)/4)*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(2)*c**(S(1)/4)*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(x)/(a + b*x**S(2) + c*x**S(4)), x), x, S(2)**(S(1)/4)*c**(S(1)/4)*atan(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/((-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)*sqrt(-S(4)*a*c + b**S(2))) - S(2)**(S(1)/4)*c**(S(1)/4)*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/((-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)*sqrt(-S(4)*a*c + b**S(2))) - S(2)**(S(1)/4)*c**(S(1)/4)*atan(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/((-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)*sqrt(-S(4)*a*c + b**S(2))) + S(2)**(S(1)/4)*c**(S(1)/4)*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/((-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(sqrt(x)*(a + b*x**S(2) + c*x**S(4))), x), x, -S(2)**(S(3)/4)*c**(S(3)/4)*atan(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/((-b + sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)*sqrt(-S(4)*a*c + b**S(2))) - S(2)**(S(3)/4)*c**(S(3)/4)*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/((-b + sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)*sqrt(-S(4)*a*c + b**S(2))) + S(2)**(S(3)/4)*c**(S(3)/4)*atan(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/((-b - sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)*sqrt(-S(4)*a*c + b**S(2))) + S(2)**(S(3)/4)*c**(S(3)/4)*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/((-b - sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**(S(3)/2)*(a + b*x**S(2) + c*x**S(4))), x), x, -S(2)**(S(1)/4)*c**(S(1)/4)*(b/sqrt(-S(4)*a*c + b**S(2)) + S(1))*atan(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(2)*a*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)) + S(2)**(S(1)/4)*c**(S(1)/4)*(b/sqrt(-S(4)*a*c + b**S(2)) + S(1))*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(2)*a*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)) - S(2)**(S(1)/4)*c**(S(1)/4)*(-b/sqrt(-S(4)*a*c + b**S(2)) + S(1))*atan(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(2)*a*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)) + S(2)**(S(1)/4)*c**(S(1)/4)*(-b/sqrt(-S(4)*a*c + b**S(2)) + S(1))*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(2)*a*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)) - S(2)/(a*sqrt(x)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**(S(5)/2)*(a + b*x**S(2) + c*x**S(4))), x), x, S(2)**(S(3)/4)*c**(S(3)/4)*(b/sqrt(-S(4)*a*c + b**S(2)) + S(1))*atan(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(2)*a*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)) + S(2)**(S(3)/4)*c**(S(3)/4)*(b/sqrt(-S(4)*a*c + b**S(2)) + S(1))*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(2)*a*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)) + S(2)**(S(3)/4)*c**(S(3)/4)*(-b/sqrt(-S(4)*a*c + b**S(2)) + S(1))*atan(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(2)*a*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)) + S(2)**(S(3)/4)*c**(S(3)/4)*(-b/sqrt(-S(4)*a*c + b**S(2)) + S(1))*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(2)*a*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)) - S(2)/(S(3)*a*x**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**(S(7)/2)*(a + b*x**S(2) + c*x**S(4))), x), x, -S(2)/(S(5)*a*x**(S(5)/2)) + S(2)*b/(a**S(2)*sqrt(x)) + S(2)**(S(1)/4)*c**(S(1)/4)*(b + (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(2)*a**S(2)*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)) - S(2)**(S(1)/4)*c**(S(1)/4)*(b + (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(2)*a**S(2)*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)) + S(2)**(S(1)/4)*c**(S(1)/4)*(b - (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(2)*a**S(2)*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)) - S(2)**(S(1)/4)*c**(S(1)/4)*(b - (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(2)*a**S(2)*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(13)/2)/(a + b*x**S(2) + c*x**S(4))**S(2), x), x, -b*x**(S(3)/2)/(S(2)*c*(-S(4)*a*c + b**S(2))) + x**(S(7)/2)*(S(2)*a + b*x**S(2))/((-S(8)*a*c + S(2)*b**S(2))*(a + b*x**S(2) + c*x**S(4))) - S(2)**(S(1)/4)*(-S(20)*a*b*c + S(3)*b**S(3) - (-S(14)*a*c + S(3)*b**S(2))*sqrt(-S(4)*a*c + b**S(2)))*atan(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(8)*c**(S(7)/4)*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)*(-S(4)*a*c + b**S(2))**(S(3)/2)) + S(2)**(S(1)/4)*(-S(20)*a*b*c + S(3)*b**S(3) - (-S(14)*a*c + S(3)*b**S(2))*sqrt(-S(4)*a*c + b**S(2)))*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(8)*c**(S(7)/4)*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)*(-S(4)*a*c + b**S(2))**(S(3)/2)) + S(2)**(S(1)/4)*(-S(20)*a*b*c + S(3)*b**S(3) + (-S(14)*a*c + S(3)*b**S(2))*sqrt(-S(4)*a*c + b**S(2)))*atan(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(8)*c**(S(7)/4)*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)*(-S(4)*a*c + b**S(2))**(S(3)/2)) - S(2)**(S(1)/4)*(-S(20)*a*b*c + S(3)*b**S(3) + (-S(14)*a*c + S(3)*b**S(2))*sqrt(-S(4)*a*c + b**S(2)))*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(8)*c**(S(7)/4)*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)*(-S(4)*a*c + b**S(2))**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(11)/2)/(a + b*x**S(2) + c*x**S(4))**S(2), x), x, -b*sqrt(x)/(S(2)*c*(-S(4)*a*c + b**S(2))) + x**(S(5)/2)*(S(2)*a + b*x**S(2))/((-S(8)*a*c + S(2)*b**S(2))*(a + b*x**S(2) + c*x**S(4))) - S(2)**(S(3)/4)*(-S(10)*a*c + b**S(2) - b*(-S(12)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(8)*c**(S(5)/4)*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)*(-S(4)*a*c + b**S(2))) - S(2)**(S(3)/4)*(-S(10)*a*c + b**S(2) - b*(-S(12)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(8)*c**(S(5)/4)*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)*(-S(4)*a*c + b**S(2))) - S(2)**(S(3)/4)*(-S(10)*a*c + b**S(2) + b*(-S(12)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(8)*c**(S(5)/4)*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)*(-S(4)*a*c + b**S(2))) - S(2)**(S(3)/4)*(-S(10)*a*c + b**S(2) + b*(-S(12)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(8)*c**(S(5)/4)*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)*(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(9)/2)/(a + b*x**S(2) + c*x**S(4))**S(2), x), x, x**(S(3)/2)*(S(2)*a + b*x**S(2))/((-S(8)*a*c + S(2)*b**S(2))*(a + b*x**S(2) + c*x**S(4))) + S(2)**(S(1)/4)*(b - (S(12)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(8)*c**(S(3)/4)*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)*(-S(4)*a*c + b**S(2))) - S(2)**(S(1)/4)*(b - (S(12)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(8)*c**(S(3)/4)*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)*(-S(4)*a*c + b**S(2))) + S(2)**(S(1)/4)*(S(12)*a*c + b**S(2) + b*sqrt(-S(4)*a*c + b**S(2)))*atan(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(8)*c**(S(3)/4)*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)*(-S(4)*a*c + b**S(2))**(S(3)/2)) - S(2)**(S(1)/4)*(S(12)*a*c + b**S(2) + b*sqrt(-S(4)*a*c + b**S(2)))*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(8)*c**(S(3)/4)*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)*(-S(4)*a*c + b**S(2))**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(7)/2)/(a + b*x**S(2) + c*x**S(4))**S(2), x), x, sqrt(x)*(S(2)*a + b*x**S(2))/((-S(8)*a*c + S(2)*b**S(2))*(a + b*x**S(2) + c*x**S(4))) + S(2)**(S(3)/4)*(S(4)*a*c + S(3)*b**S(2) - S(3)*b*sqrt(-S(4)*a*c + b**S(2)))*atan(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(8)*c**(S(1)/4)*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)*(-S(4)*a*c + b**S(2))**(S(3)/2)) + S(2)**(S(3)/4)*(S(4)*a*c + S(3)*b**S(2) - S(3)*b*sqrt(-S(4)*a*c + b**S(2)))*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(8)*c**(S(1)/4)*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)*(-S(4)*a*c + b**S(2))**(S(3)/2)) - S(2)**(S(3)/4)*(S(4)*a*c + S(3)*b**S(2) + S(3)*b*sqrt(-S(4)*a*c + b**S(2)))*atan(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(8)*c**(S(1)/4)*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)*(-S(4)*a*c + b**S(2))**(S(3)/2)) - S(2)**(S(3)/4)*(S(4)*a*c + S(3)*b**S(2) + S(3)*b*sqrt(-S(4)*a*c + b**S(2)))*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(8)*c**(S(1)/4)*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)*(-S(4)*a*c + b**S(2))**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(5)/2)/(a + b*x**S(2) + c*x**S(4))**S(2), x), x, S(2)**(S(1)/4)*c**(S(1)/4)*(S(4)*b - sqrt(-S(4)*a*c + b**S(2)))*atan(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(4)*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)*(-S(4)*a*c + b**S(2))**(S(3)/2)) - S(2)**(S(1)/4)*c**(S(1)/4)*(S(4)*b - sqrt(-S(4)*a*c + b**S(2)))*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(4)*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)*(-S(4)*a*c + b**S(2))**(S(3)/2)) - S(2)**(S(1)/4)*c**(S(1)/4)*(S(4)*b + sqrt(-S(4)*a*c + b**S(2)))*atan(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(4)*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)*(-S(4)*a*c + b**S(2))**(S(3)/2)) + S(2)**(S(1)/4)*c**(S(1)/4)*(S(4)*b + sqrt(-S(4)*a*c + b**S(2)))*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(4)*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)*(-S(4)*a*c + b**S(2))**(S(3)/2)) - x**(S(3)/2)*(b + S(2)*c*x**S(2))/((-S(8)*a*c + S(2)*b**S(2))*(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(3)/2)/(a + b*x**S(2) + c*x**S(4))**S(2), x), x, S(2)**(S(3)/4)*c**(S(3)/4)*(-S(4)*b/sqrt(-S(4)*a*c + b**S(2)) + S(3))*atan(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(4)*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)*(-S(4)*a*c + b**S(2))) + S(2)**(S(3)/4)*c**(S(3)/4)*(-S(4)*b/sqrt(-S(4)*a*c + b**S(2)) + S(3))*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(4)*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)*(-S(4)*a*c + b**S(2))) + S(2)**(S(3)/4)*c**(S(3)/4)*(S(4)*b/sqrt(-S(4)*a*c + b**S(2)) + S(3))*atan(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(4)*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)*(-S(4)*a*c + b**S(2))) + S(2)**(S(3)/4)*c**(S(3)/4)*(S(4)*b/sqrt(-S(4)*a*c + b**S(2)) + S(3))*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(4)*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)*(-S(4)*a*c + b**S(2))) - sqrt(x)*(b + S(2)*c*x**S(2))/((-S(8)*a*c + S(2)*b**S(2))*(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(x)/(a + b*x**S(2) + c*x**S(4))**S(2), x), x, S(2)**(S(1)/4)*c**(S(1)/4)*(b + (-S(20)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(8)*a*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)*(-S(4)*a*c + b**S(2))) - S(2)**(S(1)/4)*c**(S(1)/4)*(b + (-S(20)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(8)*a*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)*(-S(4)*a*c + b**S(2))) + S(2)**(S(1)/4)*c**(S(1)/4)*(b - (-S(20)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(8)*a*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)*(-S(4)*a*c + b**S(2))) - S(2)**(S(1)/4)*c**(S(1)/4)*(b - (-S(20)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(8)*a*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)*(-S(4)*a*c + b**S(2))) + x**(S(3)/2)*(-S(2)*a*c + b**S(2) + b*c*x**S(2))/(S(2)*a*(-S(4)*a*c + b**S(2))*(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(sqrt(x)*(a + b*x**S(2) + c*x**S(4))**S(2)), x), x, -S(2)**(S(3)/4)*c**(S(3)/4)*(-S(28)*a*c + S(3)*b**S(2) + S(3)*b*sqrt(-S(4)*a*c + b**S(2)))*atan(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(8)*a*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)*(-S(4)*a*c + b**S(2))**(S(3)/2)) - S(2)**(S(3)/4)*c**(S(3)/4)*(-S(28)*a*c + S(3)*b**S(2) + S(3)*b*sqrt(-S(4)*a*c + b**S(2)))*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(8)*a*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)*(-S(4)*a*c + b**S(2))**(S(3)/2)) + S(2)**(S(3)/4)*c**(S(3)/4)*(-S(28)*a*c + S(3)*b**S(2) - S(3)*b*sqrt(-S(4)*a*c + b**S(2)))*atan(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(8)*a*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)*(-S(4)*a*c + b**S(2))**(S(3)/2)) + S(2)**(S(3)/4)*c**(S(3)/4)*(-S(28)*a*c + S(3)*b**S(2) - S(3)*b*sqrt(-S(4)*a*c + b**S(2)))*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(8)*a*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)*(-S(4)*a*c + b**S(2))**(S(3)/2)) + sqrt(x)*(-S(2)*a*c + b**S(2) + b*c*x**S(2))/(S(2)*a*(-S(4)*a*c + b**S(2))*(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**(S(3)/2)*(a + b*x**S(2) + c*x**S(4))**S(2)), x), x, (-S(2)*a*c + b**S(2) + b*c*x**S(2))/(S(2)*a*sqrt(x)*(-S(4)*a*c + b**S(2))*(a + b*x**S(2) + c*x**S(4))) - S(2)**(S(1)/4)*c**(S(1)/4)*(-S(28)*a*b*c + S(5)*b**S(3) + (-S(18)*a*c + S(5)*b**S(2))*sqrt(-S(4)*a*c + b**S(2)))*atan(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(8)*a**S(2)*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)*(-S(4)*a*c + b**S(2))**(S(3)/2)) + S(2)**(S(1)/4)*c**(S(1)/4)*(-S(28)*a*b*c + S(5)*b**S(3) + (-S(18)*a*c + S(5)*b**S(2))*sqrt(-S(4)*a*c + b**S(2)))*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(8)*a**S(2)*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)*(-S(4)*a*c + b**S(2))**(S(3)/2)) + S(2)**(S(1)/4)*c**(S(1)/4)*(-S(28)*a*b*c + S(5)*b**S(3) - (-S(18)*a*c + S(5)*b**S(2))*sqrt(-S(4)*a*c + b**S(2)))*atan(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(8)*a**S(2)*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)*(-S(4)*a*c + b**S(2))**(S(3)/2)) - S(2)**(S(1)/4)*c**(S(1)/4)*(-S(28)*a*b*c + S(5)*b**S(3) - (-S(18)*a*c + S(5)*b**S(2))*sqrt(-S(4)*a*c + b**S(2)))*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(8)*a**S(2)*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)*(-S(4)*a*c + b**S(2))**(S(3)/2)) - (-S(18)*a*c + S(5)*b**S(2))/(S(2)*a**S(2)*sqrt(x)*(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(15)/2)/(a + b*x**S(2) + c*x**S(4))**S(3), x), x, x**(S(9)/2)*(S(2)*a + b*x**S(2))/((-S(16)*a*c + S(4)*b**S(2))*(a + b*x**S(2) + c*x**S(4))**S(2)) + S(3)*x**(S(5)/2)*(S(8)*a*b + x**S(2)*(S(12)*a*c + b**S(2)))/(S(16)*(-S(4)*a*c + b**S(2))**S(2)*(a + b*x**S(2) + c*x**S(4))) - sqrt(x)*(S(36)*a*c + S(3)*b**S(2))/(S(16)*c*(-S(4)*a*c + b**S(2))**S(2)) - S(2)**(S(3)/4)*(-S(84)*a*b*c + S(3)*b**S(3) - S(3)*(-S(24)*a**S(2)*c**S(2) - S(30)*a*b**S(2)*c + b**S(4))/sqrt(-S(4)*a*c + b**S(2)))*atan(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(64)*c**(S(5)/4)*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)*(-S(4)*a*c + b**S(2))**S(2)) - S(2)**(S(3)/4)*(-S(84)*a*b*c + S(3)*b**S(3) - S(3)*(-S(24)*a**S(2)*c**S(2) - S(30)*a*b**S(2)*c + b**S(4))/sqrt(-S(4)*a*c + b**S(2)))*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(64)*c**(S(5)/4)*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)*(-S(4)*a*c + b**S(2))**S(2)) - S(2)**(S(3)/4)*(-S(84)*a*b*c + S(3)*b**S(3) + S(3)*(-S(24)*a**S(2)*c**S(2) - S(30)*a*b**S(2)*c + b**S(4))/sqrt(-S(4)*a*c + b**S(2)))*atan(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(64)*c**(S(5)/4)*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)*(-S(4)*a*c + b**S(2))**S(2)) - S(2)**(S(3)/4)*(-S(84)*a*b*c + S(3)*b**S(3) + S(3)*(-S(24)*a**S(2)*c**S(2) - S(30)*a*b**S(2)*c + b**S(4))/sqrt(-S(4)*a*c + b**S(2)))*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(64)*c**(S(5)/4)*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)*(-S(4)*a*c + b**S(2))**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(13)/2)/(a + b*x**S(2) + c*x**S(4))**S(3), x), x, x**(S(7)/2)*(S(2)*a + b*x**S(2))/((-S(16)*a*c + S(4)*b**S(2))*(a + b*x**S(2) + c*x**S(4))**S(2)) + x**(S(3)/2)*(S(24)*a*b + x**S(2)*(S(28)*a*c + S(5)*b**S(2)))/(S(16)*(-S(4)*a*c + b**S(2))**S(2)*(a + b*x**S(2) + c*x**S(4))) + S(2)**(S(1)/4)*(S(28)*a*c + S(5)*b**S(2) - (S(172)*a*b*c + S(5)*b**S(3))/sqrt(-S(4)*a*c + b**S(2)))*atan(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(64)*c**(S(3)/4)*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)*(-S(4)*a*c + b**S(2))**S(2)) - S(2)**(S(1)/4)*(S(28)*a*c + S(5)*b**S(2) - (S(172)*a*b*c + S(5)*b**S(3))/sqrt(-S(4)*a*c + b**S(2)))*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(64)*c**(S(3)/4)*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)*(-S(4)*a*c + b**S(2))**S(2)) + S(2)**(S(1)/4)*(S(172)*a*b*c + S(5)*b**S(3) + sqrt(-S(4)*a*c + b**S(2))*(S(28)*a*c + S(5)*b**S(2)))*atan(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(64)*c**(S(3)/4)*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)*(-S(4)*a*c + b**S(2))**(S(5)/2)) - S(2)**(S(1)/4)*(S(172)*a*b*c + S(5)*b**S(3) + sqrt(-S(4)*a*c + b**S(2))*(S(28)*a*c + S(5)*b**S(2)))*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(64)*c**(S(3)/4)*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)*(-S(4)*a*c + b**S(2))**(S(5)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(11)/2)/(a + b*x**S(2) + c*x**S(4))**S(3), x), x, x**(S(5)/2)*(S(2)*a + b*x**S(2))/((-S(16)*a*c + S(4)*b**S(2))*(a + b*x**S(2) + c*x**S(4))**S(2)) + sqrt(x)*(S(24)*a*b + x**S(2)*(S(20)*a*c + S(7)*b**S(2)))/(S(16)*(-S(4)*a*c + b**S(2))**S(2)*(a + b*x**S(2) + c*x**S(4))) - S(2)**(S(3)/4)*(S(60)*a*c + S(21)*b**S(2) - S(3)*(S(36)*a*b*c + S(7)*b**S(3))/sqrt(-S(4)*a*c + b**S(2)))*atan(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(64)*c**(S(1)/4)*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)*(-S(4)*a*c + b**S(2))**S(2)) - S(2)**(S(3)/4)*(S(60)*a*c + S(21)*b**S(2) - S(3)*(S(36)*a*b*c + S(7)*b**S(3))/sqrt(-S(4)*a*c + b**S(2)))*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(64)*c**(S(1)/4)*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)*(-S(4)*a*c + b**S(2))**S(2)) - S(2)**(S(3)/4)*(S(108)*a*b*c + S(21)*b**S(3) + S(3)*sqrt(-S(4)*a*c + b**S(2))*(S(20)*a*c + S(7)*b**S(2)))*atan(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(64)*c**(S(1)/4)*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)*(-S(4)*a*c + b**S(2))**(S(5)/2)) - S(2)**(S(3)/4)*(S(108)*a*b*c + S(21)*b**S(3) + S(3)*sqrt(-S(4)*a*c + b**S(2))*(S(20)*a*c + S(7)*b**S(2)))*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(64)*c**(S(1)/4)*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)*(-S(4)*a*c + b**S(2))**(S(5)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(9)/2)/(a + b*x**S(2) + c*x**S(4))**S(3), x), x, S(3)*S(2)**(S(1)/4)*c**(S(1)/4)*(S(20)*a*c + S(11)*b**S(2) - S(4)*b*sqrt(-S(4)*a*c + b**S(2)))*atan(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(32)*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)*(-S(4)*a*c + b**S(2))**(S(5)/2)) - S(3)*S(2)**(S(1)/4)*c**(S(1)/4)*(S(20)*a*c + S(11)*b**S(2) - S(4)*b*sqrt(-S(4)*a*c + b**S(2)))*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(32)*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)*(-S(4)*a*c + b**S(2))**(S(5)/2)) - S(3)*S(2)**(S(1)/4)*c**(S(1)/4)*(S(20)*a*c + S(11)*b**S(2) + S(4)*b*sqrt(-S(4)*a*c + b**S(2)))*atan(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(32)*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)*(-S(4)*a*c + b**S(2))**(S(5)/2)) + S(3)*S(2)**(S(1)/4)*c**(S(1)/4)*(S(20)*a*c + S(11)*b**S(2) + S(4)*b*sqrt(-S(4)*a*c + b**S(2)))*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(32)*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)*(-S(4)*a*c + b**S(2))**(S(5)/2)) + x**(S(3)/2)*(S(2)*a + b*x**S(2))/((-S(16)*a*c + S(4)*b**S(2))*(a + b*x**S(2) + c*x**S(4))**S(2)) - S(3)*x**(S(3)/2)*(-S(4)*a*c + S(5)*b**S(2) + S(8)*b*c*x**S(2))/(S(16)*(-S(4)*a*c + b**S(2))**S(2)*(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(7)/2)/(a + b*x**S(2) + c*x**S(4))**S(3), x), x, -S(2)**(S(3)/4)*c**(S(3)/4)*(S(28)*a*c + S(41)*b**S(2) - S(36)*b*sqrt(-S(4)*a*c + b**S(2)))*atan(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(32)*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)*(-S(4)*a*c + b**S(2))**(S(5)/2)) - S(2)**(S(3)/4)*c**(S(3)/4)*(S(28)*a*c + S(41)*b**S(2) - S(36)*b*sqrt(-S(4)*a*c + b**S(2)))*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(32)*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)*(-S(4)*a*c + b**S(2))**(S(5)/2)) + S(2)**(S(3)/4)*c**(S(3)/4)*(S(28)*a*c + S(41)*b**S(2) + S(36)*b*sqrt(-S(4)*a*c + b**S(2)))*atan(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(32)*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)*(-S(4)*a*c + b**S(2))**(S(5)/2)) + S(2)**(S(3)/4)*c**(S(3)/4)*(S(28)*a*c + S(41)*b**S(2) + S(36)*b*sqrt(-S(4)*a*c + b**S(2)))*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(32)*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)*(-S(4)*a*c + b**S(2))**(S(5)/2)) + sqrt(x)*(S(2)*a + b*x**S(2))/((-S(16)*a*c + S(4)*b**S(2))*(a + b*x**S(2) + c*x**S(4))**S(2)) - sqrt(x)*(-S(4)*a*c + S(13)*b**S(2) + S(24)*b*c*x**S(2))/(S(16)*(-S(4)*a*c + b**S(2))**S(2)*(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(5)/2)/(a + b*x**S(2) + c*x**S(4))**S(3), x), x, -x**(S(3)/2)*(b + S(2)*c*x**S(2))/((-S(16)*a*c + S(4)*b**S(2))*(a + b*x**S(2) + c*x**S(4))**S(2)) + S(3)*S(2)**(S(1)/4)*c**(S(1)/4)*(-S(68)*a*b*c + b**S(3) + sqrt(-S(4)*a*c + b**S(2))*(S(12)*a*c + b**S(2)))*atan(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(64)*a*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)*(-S(4)*a*c + b**S(2))**(S(5)/2)) - S(3)*S(2)**(S(1)/4)*c**(S(1)/4)*(-S(68)*a*b*c + b**S(3) + sqrt(-S(4)*a*c + b**S(2))*(S(12)*a*c + b**S(2)))*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(64)*a*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)*(-S(4)*a*c + b**S(2))**(S(5)/2)) + S(3)*S(2)**(S(1)/4)*c**(S(1)/4)*(S(68)*a*b*c/sqrt(-S(4)*a*c + b**S(2)) + S(12)*a*c - b**S(3)/sqrt(-S(4)*a*c + b**S(2)) + b**S(2))*atan(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(64)*a*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)*(-S(4)*a*c + b**S(2))**S(2)) - S(3)*S(2)**(S(1)/4)*c**(S(1)/4)*(S(68)*a*b*c/sqrt(-S(4)*a*c + b**S(2)) + S(12)*a*c - b**S(3)/sqrt(-S(4)*a*c + b**S(2)) + b**S(2))*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(64)*a*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)*(-S(4)*a*c + b**S(2))**S(2)) + S(3)*x**(S(3)/2)*(b*(S(4)*a*c + b**S(2)) + c*x**S(2)*(S(12)*a*c + b**S(2)))/(S(16)*a*(-S(4)*a*c + b**S(2))**S(2)*(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(3)/2)/(a + b*x**S(2) + c*x**S(4))**S(3), x), x, -sqrt(x)*(b + S(2)*c*x**S(2))/((-S(16)*a*c + S(4)*b**S(2))*(a + b*x**S(2) + c*x**S(4))**S(2)) - S(3)*S(2)**(S(3)/4)*c**(S(3)/4)*(-S(68)*a*b*c + b**S(3) + sqrt(-S(4)*a*c + b**S(2))*(S(44)*a*c + b**S(2)))*atan(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(64)*a*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)*(-S(4)*a*c + b**S(2))**(S(5)/2)) - S(3)*S(2)**(S(3)/4)*c**(S(3)/4)*(-S(68)*a*b*c + b**S(3) + sqrt(-S(4)*a*c + b**S(2))*(S(44)*a*c + b**S(2)))*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(64)*a*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)*(-S(4)*a*c + b**S(2))**(S(5)/2)) - S(3)*S(2)**(S(3)/4)*c**(S(3)/4)*(S(68)*a*b*c/sqrt(-S(4)*a*c + b**S(2)) + S(44)*a*c - b**S(3)/sqrt(-S(4)*a*c + b**S(2)) + b**S(2))*atan(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(64)*a*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)*(-S(4)*a*c + b**S(2))**S(2)) - S(3)*S(2)**(S(3)/4)*c**(S(3)/4)*(S(68)*a*b*c/sqrt(-S(4)*a*c + b**S(2)) + S(44)*a*c - b**S(3)/sqrt(-S(4)*a*c + b**S(2)) + b**S(2))*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(64)*a*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)*(-S(4)*a*c + b**S(2))**S(2)) + sqrt(x)*(b*(S(20)*a*c + b**S(2)) + c*x**S(2)*(S(44)*a*c + b**S(2)))/(S(16)*a*(-S(4)*a*c + b**S(2))**S(2)*(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(x)/(a + b*x**S(2) + c*x**S(4))**S(3), x), x, x**(S(3)/2)*(-S(2)*a*c + b**S(2) + b*c*x**S(2))/(S(4)*a*(-S(4)*a*c + b**S(2))*(a + b*x**S(2) + c*x**S(4))**S(2)) + S(2)**(S(1)/4)*c**(S(1)/4)*(S(520)*a**S(2)*c**S(2) - S(54)*a*b**S(2)*c + S(5)*b**S(4) + b*(-S(44)*a*c + S(5)*b**S(2))*sqrt(-S(4)*a*c + b**S(2)))*atan(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(64)*a**S(2)*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)*(-S(4)*a*c + b**S(2))**(S(5)/2)) - S(2)**(S(1)/4)*c**(S(1)/4)*(S(520)*a**S(2)*c**S(2) - S(54)*a*b**S(2)*c + S(5)*b**S(4) + b*(-S(44)*a*c + S(5)*b**S(2))*sqrt(-S(4)*a*c + b**S(2)))*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(64)*a**S(2)*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)*(-S(4)*a*c + b**S(2))**(S(5)/2)) - S(2)**(S(1)/4)*c**(S(1)/4)*(S(520)*a**S(2)*c**S(2) - S(54)*a*b**S(2)*c + S(5)*b**S(4) - b*(-S(44)*a*c + S(5)*b**S(2))*sqrt(-S(4)*a*c + b**S(2)))*atan(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(64)*a**S(2)*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)*(-S(4)*a*c + b**S(2))**(S(5)/2)) + S(2)**(S(1)/4)*c**(S(1)/4)*(S(520)*a**S(2)*c**S(2) - S(54)*a*b**S(2)*c + S(5)*b**S(4) - b*(-S(44)*a*c + S(5)*b**S(2))*sqrt(-S(4)*a*c + b**S(2)))*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(64)*a**S(2)*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)*(-S(4)*a*c + b**S(2))**(S(5)/2)) + x**(S(3)/2)*(S(52)*a**S(2)*c**S(2) - S(45)*a*b**S(2)*c + S(5)*b**S(4) + b*c*x**S(2)*(-S(44)*a*c + S(5)*b**S(2)))/(S(16)*a**S(2)*(-S(4)*a*c + b**S(2))**S(2)*(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(sqrt(x)*(a + b*x**S(2) + c*x**S(4))**S(3)), x), x, sqrt(x)*(-S(2)*a*c + b**S(2) + b*c*x**S(2))/(S(4)*a*(-S(4)*a*c + b**S(2))*(a + b*x**S(2) + c*x**S(4))**S(2)) - S(3)*S(2)**(S(3)/4)*c**(S(3)/4)*(S(280)*a**S(2)*c**S(2) - S(66)*a*b**S(2)*c + S(7)*b**S(4) + b*(-S(52)*a*c + S(7)*b**S(2))*sqrt(-S(4)*a*c + b**S(2)))*atan(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(64)*a**S(2)*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)*(-S(4)*a*c + b**S(2))**(S(5)/2)) - S(3)*S(2)**(S(3)/4)*c**(S(3)/4)*(S(280)*a**S(2)*c**S(2) - S(66)*a*b**S(2)*c + S(7)*b**S(4) + b*(-S(52)*a*c + S(7)*b**S(2))*sqrt(-S(4)*a*c + b**S(2)))*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(64)*a**S(2)*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)*(-S(4)*a*c + b**S(2))**(S(5)/2)) + S(3)*S(2)**(S(3)/4)*c**(S(3)/4)*(S(280)*a**S(2)*c**S(2) - S(66)*a*b**S(2)*c + S(7)*b**S(4) - b*(-S(52)*a*c + S(7)*b**S(2))*sqrt(-S(4)*a*c + b**S(2)))*atan(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(64)*a**S(2)*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)*(-S(4)*a*c + b**S(2))**(S(5)/2)) + S(3)*S(2)**(S(3)/4)*c**(S(3)/4)*(S(280)*a**S(2)*c**S(2) - S(66)*a*b**S(2)*c + S(7)*b**S(4) - b*(-S(52)*a*c + S(7)*b**S(2))*sqrt(-S(4)*a*c + b**S(2)))*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(x)/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(64)*a**S(2)*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)*(-S(4)*a*c + b**S(2))**(S(5)/2)) + sqrt(x)*(S(60)*a**S(2)*c**S(2) - S(55)*a*b**S(2)*c + S(7)*b**S(4) + b*c*x**S(2)*(-S(52)*a*c + S(7)*b**S(2)))/(S(16)*a**S(2)*(-S(4)*a*c + b**S(2))**S(2)*(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**(S(3)/2)*sqrt(a + b*x**S(2) + c*x**S(4)), x), x, S(2)*(d*x)**(S(5)/2)*sqrt(a + b*x**S(2) + c*x**S(4))*AppellF1(S(5)/4, S(-1)/2, S(-1)/2, S(9)/4, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(5)*d*sqrt(S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(d*x)*sqrt(a + b*x**S(2) + c*x**S(4)), x), x, S(2)*(d*x)**(S(3)/2)*sqrt(a + b*x**S(2) + c*x**S(4))*AppellF1(S(3)/4, S(-1)/2, S(-1)/2, S(7)/4, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(3)*d*sqrt(S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a + b*x**S(2) + c*x**S(4))/sqrt(d*x), x), x, S(2)*sqrt(d*x)*sqrt(a + b*x**S(2) + c*x**S(4))*AppellF1(S(1)/4, S(-1)/2, S(-1)/2, S(5)/4, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/(d*sqrt(S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a + b*x**S(2) + c*x**S(4))/(d*x)**(S(3)/2), x), x, -S(2)*sqrt(a + b*x**S(2) + c*x**S(4))*AppellF1(S(-1)/4, S(-1)/2, S(-1)/2, S(3)/4, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/(d*sqrt(d*x)*sqrt(S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**(S(3)/2)*(a + b*x**S(2) + c*x**S(4))**(S(3)/2), x), x, S(2)*a*(d*x)**(S(5)/2)*sqrt(a + b*x**S(2) + c*x**S(4))*AppellF1(S(5)/4, S(-3)/2, S(-3)/2, S(9)/4, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(5)*d*sqrt(S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(d*x)*(a + b*x**S(2) + c*x**S(4))**(S(3)/2), x), x, S(2)*a*(d*x)**(S(3)/2)*sqrt(a + b*x**S(2) + c*x**S(4))*AppellF1(S(3)/4, S(-3)/2, S(-3)/2, S(7)/4, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(3)*d*sqrt(S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))**(S(3)/2)/sqrt(d*x), x), x, S(2)*a*sqrt(d*x)*sqrt(a + b*x**S(2) + c*x**S(4))*AppellF1(S(1)/4, S(-3)/2, S(-3)/2, S(5)/4, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/(d*sqrt(S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))**(S(3)/2)/(d*x)**(S(3)/2), x), x, -S(2)*a*sqrt(a + b*x**S(2) + c*x**S(4))*AppellF1(S(-1)/4, S(-3)/2, S(-3)/2, S(3)/4, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/(d*sqrt(d*x)*sqrt(S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**(S(3)/2)/sqrt(a + b*x**S(2) + c*x**S(4)), x), x, S(2)*(d*x)**(S(5)/2)*sqrt(S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))*AppellF1(S(5)/4, S(1)/2, S(1)/2, S(9)/4, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(5)*d*sqrt(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(d*x)/sqrt(a + b*x**S(2) + c*x**S(4)), x), x, S(2)*(d*x)**(S(3)/2)*sqrt(S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))*AppellF1(S(3)/4, S(1)/2, S(1)/2, S(7)/4, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(3)*d*sqrt(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(sqrt(d*x)*sqrt(a + b*x**S(2) + c*x**S(4))), x), x, S(2)*sqrt(d*x)*sqrt(S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))*AppellF1(S(1)/4, S(1)/2, S(1)/2, S(5)/4, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/(d*sqrt(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((d*x)**(S(3)/2)*sqrt(a + b*x**S(2) + c*x**S(4))), x), x, -S(2)*sqrt(S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))*AppellF1(S(-1)/4, S(1)/2, S(1)/2, S(3)/4, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/(d*sqrt(d*x)*sqrt(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**(S(3)/2)/(a + b*x**S(2) + c*x**S(4))**(S(3)/2), x), x, S(2)*(d*x)**(S(5)/2)*sqrt(S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))*AppellF1(S(5)/4, S(3)/2, S(3)/2, S(9)/4, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(5)*a*d*sqrt(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(d*x)/(a + b*x**S(2) + c*x**S(4))**(S(3)/2), x), x, S(2)*(d*x)**(S(3)/2)*sqrt(S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))*AppellF1(S(3)/4, S(3)/2, S(3)/2, S(7)/4, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(3)*a*d*sqrt(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(sqrt(d*x)*(a + b*x**S(2) + c*x**S(4))**(S(3)/2)), x), x, S(2)*sqrt(d*x)*sqrt(S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))*AppellF1(S(1)/4, S(3)/2, S(3)/2, S(5)/4, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/(a*d*sqrt(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((d*x)**(S(3)/2)*(a + b*x**S(2) + c*x**S(4))**(S(3)/2)), x), x, -S(2)*sqrt(S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))*AppellF1(S(-1)/4, S(3)/2, S(3)/2, S(3)/4, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/(a*d*sqrt(d*x)*sqrt(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**m*(a + b*x**S(2) + c*x**S(4))**S(3), x), x, a**S(3)*(d*x)**(m + S(1))/(d*(m + S(1))) + S(3)*a**S(2)*b*(d*x)**(m + S(3))/(d**S(3)*(m + S(3))) + S(3)*a*(d*x)**(m + S(5))*(a*c + b**S(2))/(d**S(5)*(m + S(5))) + S(3)*b*c**S(2)*(d*x)**(m + S(11))/(d**S(11)*(m + S(11))) + b*(d*x)**(m + S(7))*(S(6)*a*c + b**S(2))/(d**S(7)*(m + S(7))) + c**S(3)*(d*x)**(m + S(13))/(d**S(13)*(m + S(13))) + S(3)*c*(d*x)**(m + S(9))*(a*c + b**S(2))/(d**S(9)*(m + S(9))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**m*(a + b*x**S(2) + c*x**S(4))**S(2), x), x, a**S(2)*(d*x)**(m + S(1))/(d*(m + S(1))) + S(2)*a*b*(d*x)**(m + S(3))/(d**S(3)*(m + S(3))) + S(2)*b*c*(d*x)**(m + S(7))/(d**S(7)*(m + S(7))) + c**S(2)*(d*x)**(m + S(9))/(d**S(9)*(m + S(9))) + (d*x)**(m + S(5))*(S(2)*a*c + b**S(2))/(d**S(5)*(m + S(5))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**m*(a + b*x**S(2) + c*x**S(4)), x), x, a*(d*x)**(m + S(1))/(d*(m + S(1))) + b*(d*x)**(m + S(3))/(d**S(3)*(m + S(3))) + c*(d*x)**(m + S(5))/(d**S(5)*(m + S(5))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**m/(a + b*x**S(2) + c*x**S(4)), x), x, -S(2)*c*(d*x)**(m + S(1))*hyper((S(1), m/S(2) + S(1)/2), (m/S(2) + S(3)/2,), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/(d*(b + sqrt(-S(4)*a*c + b**S(2)))*(m + S(1))*sqrt(-S(4)*a*c + b**S(2))) + S(2)*c*(d*x)**(m + S(1))*hyper((S(1), m/S(2) + S(1)/2), (m/S(2) + S(3)/2,), -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))))/(d*(b - sqrt(-S(4)*a*c + b**S(2)))*(m + S(1))*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**m/(a + b*x**S(2) + c*x**S(4))**S(2), x), x, -c*(d*x)**(m + S(1))*(-S(4)*a*c*(-m + S(3)) + b**S(2)*(-m + S(1)) - b*(-m + S(1))*sqrt(-S(4)*a*c + b**S(2)))*hyper((S(1), m/S(2) + S(1)/2), (m/S(2) + S(3)/2,), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*a*d*(b + sqrt(-S(4)*a*c + b**S(2)))*(m + S(1))*(-S(4)*a*c + b**S(2))**(S(3)/2)) + c*(d*x)**(m + S(1))*(-S(4)*a*c*(-m + S(3)) + b**S(2)*(-m + S(1)) + b*(-m + S(1))*sqrt(-S(4)*a*c + b**S(2)))*hyper((S(1), m/S(2) + S(1)/2), (m/S(2) + S(3)/2,), -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*a*d*(b - sqrt(-S(4)*a*c + b**S(2)))*(m + S(1))*(-S(4)*a*c + b**S(2))**(S(3)/2)) + (d*x)**(m + S(1))*(-S(2)*a*c + b**S(2) + b*c*x**S(2))/(S(2)*a*d*(-S(4)*a*c + b**S(2))*(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))**p/x, x), x, S(4)**(p + S(-1))*((b + S(2)*c*x**S(2) - sqrt(-S(4)*a*c + b**S(2)))/(c*x**S(2)))**(-p)*((b + S(2)*c*x**S(2) + sqrt(-S(4)*a*c + b**S(2)))/(c*x**S(2)))**(-p)*(a + b*x**S(2) + c*x**S(4))**p*AppellF1(-S(2)*p, -p, -p, -S(2)*p + S(1), -(b - sqrt(-S(4)*a*c + b**S(2)))/(S(2)*c*x**S(2)), -(b + sqrt(-S(4)*a*c + b**S(2)))/(S(2)*c*x**S(2)))/p, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))**p/x**S(3), x), x, -S(2)**(S(2)*p + S(-1))*((b + S(2)*c*x**S(2) - sqrt(-S(4)*a*c + b**S(2)))/(c*x**S(2)))**(-p)*((b + S(2)*c*x**S(2) + sqrt(-S(4)*a*c + b**S(2)))/(c*x**S(2)))**(-p)*(a + b*x**S(2) + c*x**S(4))**p*AppellF1(-S(2)*p + S(1), -p, -p, -S(2)*p + S(2), -(b - sqrt(-S(4)*a*c + b**S(2)))/(S(2)*c*x**S(2)), -(b + sqrt(-S(4)*a*c + b**S(2)))/(S(2)*c*x**S(2)))/(x**S(2)*(-S(2)*p + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))**p/x**S(5), x), x, -S(4)**(p + S(-1))*((b + S(2)*c*x**S(2) - sqrt(-S(4)*a*c + b**S(2)))/(c*x**S(2)))**(-p)*((b + S(2)*c*x**S(2) + sqrt(-S(4)*a*c + b**S(2)))/(c*x**S(2)))**(-p)*(a + b*x**S(2) + c*x**S(4))**p*AppellF1(-S(2)*p + S(2), -p, -p, -S(2)*p + S(3), -(b - sqrt(-S(4)*a*c + b**S(2)))/(S(2)*c*x**S(2)), -(b + sqrt(-S(4)*a*c + b**S(2)))/(S(2)*c*x**S(2)))/(x**S(4)*(-p + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)*(a + b*x**S(2) + c*x**S(4))**p, x), x, x**S(5)*(S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))**(-p)*(S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))**(-p)*(a + b*x**S(2) + c*x**S(4))**p*AppellF1(S(5)/2, -p, -p, S(7)/2, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/S(5), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(a + b*x**S(2) + c*x**S(4))**p, x), x, x**S(3)*(S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))**(-p)*(S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))**(-p)*(a + b*x**S(2) + c*x**S(4))**p*AppellF1(S(3)/2, -p, -p, S(5)/2, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))**p, x), x, x*(S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))**(-p)*(S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))**(-p)*(a + b*x**S(2) + c*x**S(4))**p*AppellF1(S(1)/2, -p, -p, S(3)/2, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))**p/x**S(2), x), x, -(S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))**(-p)*(S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))**(-p)*(a + b*x**S(2) + c*x**S(4))**p*AppellF1(S(-1)/2, -p, -p, S(1)/2, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))**p/x**S(4), x), x, -(S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))**(-p)*(S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))**(-p)*(a + b*x**S(2) + c*x**S(4))**p*AppellF1(S(-3)/2, -p, -p, S(-1)/2, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(3)*x**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**m*(a + b*x**S(2) + c*x**S(4))**(S(3)/2), x), x, a*(d*x)**(m + S(1))*sqrt(a + b*x**S(2) + c*x**S(4))*AppellF1(m/S(2) + S(1)/2, S(-3)/2, S(-3)/2, m/S(2) + S(3)/2, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/(d*(m + S(1))*sqrt(S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**m*sqrt(a + b*x**S(2) + c*x**S(4)), x), x, (d*x)**(m + S(1))*sqrt(a + b*x**S(2) + c*x**S(4))*AppellF1(m/S(2) + S(1)/2, S(-1)/2, S(-1)/2, m/S(2) + S(3)/2, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/(d*(m + S(1))*sqrt(S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**m/sqrt(a + b*x**S(2) + c*x**S(4)), x), x, (d*x)**(m + S(1))*sqrt(S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))*AppellF1(m/S(2) + S(1)/2, S(1)/2, S(1)/2, m/S(2) + S(3)/2, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/(d*(m + S(1))*sqrt(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**m/(a + b*x**S(2) + c*x**S(4))**(S(3)/2), x), x, (d*x)**(m + S(1))*sqrt(S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))*AppellF1(m/S(2) + S(1)/2, S(3)/2, S(3)/2, m/S(2) + S(3)/2, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/(a*d*(m + S(1))*sqrt(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**m*(a + b*x**S(2) + c*x**S(4))**p, x), x, (d*x)**(m + S(1))*(S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))**(-p)*(S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))**(-p)*(a + b*x**S(2) + c*x**S(4))**p*AppellF1(m/S(2) + S(1)/2, -p, -p, m/S(2) + S(3)/2, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/(d*(m + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*(a + b*x**S(2) + c*x**S(4))**p, x), x, S(2)**(p + S(-1))*b*(-(b + S(2)*c*x**S(2) - sqrt(-S(4)*a*c + b**S(2)))/sqrt(-S(4)*a*c + b**S(2)))**(-p + S(-1))*(a + b*x**S(2) + c*x**S(4))**(p + S(1))*hyper((-p, p + S(1)), (p + S(2),), (b + S(2)*c*x**S(2) + sqrt(-S(4)*a*c + b**S(2)))/(S(2)*sqrt(-S(4)*a*c + b**S(2))))/(c*(p + S(1))*sqrt(-S(4)*a*c + b**S(2))) + (a + b*x**S(2) + c*x**S(4))**(p + S(1))/(S(4)*c*(p + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(a + b*x**S(2) + c*x**S(4))**p, x), x, -S(2)**p*(-(b + S(2)*c*x**S(2) - sqrt(-S(4)*a*c + b**S(2)))/sqrt(-S(4)*a*c + b**S(2)))**(-p + S(-1))*(a + b*x**S(2) + c*x**S(4))**(p + S(1))*hyper((-p, p + S(1)), (p + S(2),), (b + S(2)*c*x**S(2) + sqrt(-S(4)*a*c + b**S(2)))/(S(2)*sqrt(-S(4)*a*c + b**S(2))))/((p + S(1))*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a*x**S(3) + b*x**S(6))**(S(5)/3), x), x, -S(3)*a*(a*x**S(3) + b*x**S(6))**(S(8)/3)/(S(88)*b**S(2)*x**S(8)) + (a*x**S(3) + b*x**S(6))**(S(8)/3)/(S(11)*b*x**S(5)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a*x**S(3) + b*x**S(6))**(S(2)/3), x), x, (a*x**S(3) + b*x**S(6))**(S(5)/3)/(S(5)*b*x**S(5)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a*x**S(3) + b*x**S(6))**(S(-2)/3), x), x, -(a*x**S(3) + b*x**S(6))**(S(1)/3)/(a*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a*x**S(3) + b*x**S(6))**(S(-5)/3), x), x, S(1)/(S(2)*a*x**S(2)*(a*x**S(3) + b*x**S(6))**(S(2)/3)) - S(3)*(a*x**S(3) + b*x**S(6))**(S(1)/3)/(S(4)*a**S(2)*x**S(5)) + S(9)*b*(a*x**S(3) + b*x**S(6))**(S(1)/3)/(S(4)*a**S(3)*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(6) - x**S(3)), x), x, log(-x + S(1))/S(3) - log(x**S(2) + x + S(1))/S(6) - sqrt(S(3))*atan(sqrt(S(3))*(S(2)*x + S(1))/S(3))/S(3) + S(1)/(S(2)*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**m*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6)), x), x, S(3)*a*x**(m + S(1))*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/((a + b*x**S(3))*(m**S(2) + S(5)*m + S(4))) + x**(m + S(1))*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(m + S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6)), x), x, a*x**S(6)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(18)*a + S(18)*b*x**S(3)) + x**S(6)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/S(9), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6)), x), x, S(3)*a*x**S(5)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(40)*a + S(40)*b*x**S(3)) + x**S(5)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/S(8), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6)), x), x, S(3)*a*x**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(28)*a + S(28)*b*x**S(3)) + x**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/S(7), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6)), x), x, (a + b*x**S(3))*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(6)*b), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6)), x), x, S(3)*a*x**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(10)*a + S(10)*b*x**S(3)) + x**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/S(5), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6)), x), x, S(3)*a*x*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(4)*a + S(4)*b*x**S(3)) + x*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/x, x), x, a*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))*log(x)/(a + b*x**S(3)) + sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/x**S(2), x), x, -S(3)*a*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(2)*x*(a + b*x**S(3))) + sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(2)*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/x**S(3), x), x, -S(3)*a*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(2)*x**S(2)*(a + b*x**S(3))) + sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/x**S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/x**S(4), x), x, -a*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(3)*x**S(3)*(a + b*x**S(3))) + b*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))*log(x)/(a + b*x**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/x**S(5), x), x, S(3)*a*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(4)*x**S(4)*(a + b*x**S(3))) - sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/x**S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/x**S(6), x), x, S(3)*a*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(10)*x**S(5)*(a + b*x**S(3))) - sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(2)*x**S(5)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/x**S(7), x), x, -(a + b*x**S(3))*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(6)*a*x**S(6)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/x**S(8), x), x, S(3)*a*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(28)*x**S(7)*(a + b*x**S(3))) - sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(4)*x**S(7)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/x**S(9), x), x, S(3)*a*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(40)*x**S(8)*(a + b*x**S(3))) - sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(5)*x**S(8)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/x**S(10), x), x, a*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(18)*x**S(9)*(a + b*x**S(3))) - sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(6)*x**S(9)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/x**S(11), x), x, S(3)*a*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(70)*x**S(10)*(a + b*x**S(3))) - sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(7)*x**S(10)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**m*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2), x), x, S(162)*a**S(3)*x**(m + S(1))*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/((a + b*x**S(3))*(m + S(7))*(m + S(10))*(m**S(2) + S(5)*m + S(4))) + S(54)*a**S(2)*x**(m + S(1))*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/((m + S(4))*(m + S(7))*(m + S(10))) + S(9)*a*x**(m + S(1))*(a + b*x**S(3))*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(m**S(2) + S(17)*m + S(70)) + x**(m + S(1))*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/(m + S(10)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(9)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2), x), x, S(81)*a**S(3)*x**S(10)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(19760)*a + S(19760)*b*x**S(3)) + S(27)*a**S(2)*x**S(10)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/S(1976) + S(9)*a*x**S(10)*(a + b*x**S(3))*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/S(304) + x**S(10)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/S(19), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(8)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2), x), x, a**S(2)*(a + b*x**S(3))*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/(S(36)*b**S(3)) - a*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/(S(45)*b**S(3)) + x**S(6)*(a + b*x**S(3))*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/(S(18)*b), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(7)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2), x), x, S(81)*a**S(3)*x**S(8)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(10472)*a + S(10472)*b*x**S(3)) + S(27)*a**S(2)*x**S(8)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/S(1309) + S(9)*a*x**S(8)*(a + b*x**S(3))*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/S(238) + x**S(8)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/S(17), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(6)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2), x), x, S(81)*a**S(3)*x**S(7)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(7280)*a + S(7280)*b*x**S(3)) + S(27)*a**S(2)*x**S(7)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/S(1040) + S(9)*a*x**S(7)*(a + b*x**S(3))*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/S(208) + x**S(7)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/S(16), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2), x), x, -a*(a + b*x**S(3))*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/(S(12)*b**S(2)) + (a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/(S(15)*b**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2), x), x, S(81)*a**S(3)*x**S(5)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(3080)*a + S(3080)*b*x**S(3)) + S(27)*a**S(2)*x**S(5)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/S(616) + S(9)*a*x**S(5)*(a + b*x**S(3))*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/S(154) + x**S(5)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/S(14), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2), x), x, S(81)*a**S(3)*x**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(1820)*a + S(1820)*b*x**S(3)) + S(27)*a**S(2)*x**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/S(455) + S(9)*a*x**S(4)*(a + b*x**S(3))*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/S(130) + x**S(4)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/S(13), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2), x), x, (a + b*x**S(3))*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/(S(12)*b), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2), x), x, S(81)*a**S(3)*x**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(440)*a + S(440)*b*x**S(3)) + S(27)*a**S(2)*x**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/S(220) + S(9)*a*x**S(2)*(a + b*x**S(3))*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/S(88) + x**S(2)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/S(11), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2), x), x, S(81)*a**S(3)*x*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(140)*a + S(140)*b*x**S(3)) + S(27)*a**S(2)*x*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/S(140) + S(9)*a*x*(a + b*x**S(3))*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/S(70) + x*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/S(10), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/x, x), x, a**S(3)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))*log(x)/(a + b*x**S(3)) + a**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/S(3) + a*(a + b*x**S(3))*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/S(6) + (a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/S(9), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/x**S(2), x), x, -S(81)*a**S(3)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(40)*x*(a + b*x**S(3))) + S(27)*a**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(40)*x) + S(9)*a*(a + b*x**S(3))*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(40)*x) + (a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/(S(8)*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/x**S(3), x), x, -S(81)*a**S(3)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(28)*x**S(2)*(a + b*x**S(3))) + S(27)*a**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(14)*x**S(2)) + S(9)*a*(a + b*x**S(3))*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(28)*x**S(2)) + (a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/(S(7)*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/x**S(4), x), x, S(3)*a**S(2)*b*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))*log(x)/(a + b*x**S(3)) + a*b*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6)) - a*(a + b*x**S(3))*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(2)*x**S(3)) + (a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/(S(6)*x**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/x**S(5), x), x, S(81)*a*b**S(2)*x**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(20)*a + S(20)*b*x**S(3)) + S(9)*a*(a + b*x**S(3))*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(4)*x**S(4)) + S(27)*b**S(2)*x**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/S(10) - S(5)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/(S(2)*x**S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/x**S(6), x), x, S(81)*a*b**S(2)*x*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(20)*a + S(20)*b*x**S(3)) + S(9)*a*(a + b*x**S(3))*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(10)*x**S(5)) + S(27)*b**S(2)*x*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/S(20) - S(11)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/(S(10)*x**S(5)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/x**S(7), x), x, S(3)*a*b**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))*log(x)/(a + b*x**S(3)) + a*(a + b*x**S(3))*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(2)*x**S(6)) + b**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6)) - S(2)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/(S(3)*x**S(6)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/x**S(8), x), x, -S(81)*a*b**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(28)*x*(a + b*x**S(3))) + S(9)*a*(a + b*x**S(3))*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(28)*x**S(7)) + S(27)*b**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(28)*x) - S(13)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/(S(28)*x**S(7)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/x**S(9), x), x, -S(81)*a*b**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(40)*x**S(2)*(a + b*x**S(3))) + S(9)*a*(a + b*x**S(3))*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(40)*x**S(8)) + S(27)*b**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(20)*x**S(2)) - S(7)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/(S(20)*x**S(8)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/x**S(10), x), x, -a*b**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(3)*x**S(3)*(a + b*x**S(3))) + a*(a + b*x**S(3))*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(6)*x**S(9)) + b**S(3)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))*log(x)/(a + b*x**S(3)) - S(5)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/(S(18)*x**S(9)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/x**S(11), x), x, S(81)*a*b**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(140)*x**S(4)*(a + b*x**S(3))) + S(9)*a*(a + b*x**S(3))*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(70)*x**S(10)) - S(27)*b**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(35)*x**S(4)) - S(8)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/(S(35)*x**S(10)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/x**S(12), x), x, S(81)*a*b**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(440)*x**S(5)*(a + b*x**S(3))) + S(9)*a*(a + b*x**S(3))*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(88)*x**S(11)) - S(27)*b**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(88)*x**S(5)) - S(17)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/(S(88)*x**S(11)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/x**S(13), x), x, -(a + b*x**S(3))*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/(S(12)*a*x**S(12)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/x**S(14), x), x, S(81)*a*b**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(1820)*x**S(7)*(a + b*x**S(3))) + S(9)*a*(a + b*x**S(3))*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(130)*x**S(13)) - S(27)*b**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(260)*x**S(7)) - S(19)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/(S(130)*x**S(13)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/x**S(15), x), x, S(81)*a*b**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(3080)*x**S(8)*(a + b*x**S(3))) + S(9)*a*(a + b*x**S(3))*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(154)*x**S(14)) - S(27)*b**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(385)*x**S(8)) - S(10)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/(S(77)*x**S(14)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/x**S(16), x), x, -(a + b*x**S(3))*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/(S(12)*a*x**S(15)) + (a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/(S(60)*a**S(2)*x**S(15)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/x**S(17), x), x, S(81)*a*b**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(7280)*x**S(10)*(a + b*x**S(3))) + S(9)*a*(a + b*x**S(3))*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(208)*x**S(16)) - S(27)*b**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(728)*x**S(10)) - S(11)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/(S(104)*x**S(16)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**m*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2), x), x, S(29160)*a**S(5)*x**(m + S(1))*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/((a + b*x**S(3))*(m + S(7))*(m + S(10))*(m + S(13))*(m + S(16))*(m**S(2) + S(5)*m + S(4))) + S(9720)*a**S(4)*x**(m + S(1))*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/((m + S(4))*(m + S(7))*(m + S(10))*(m + S(13))*(m + S(16))) + S(1620)*a**S(3)*x**(m + S(1))*(a + b*x**S(3))*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/((m + S(13))*(m + S(16))*(m**S(2) + S(17)*m + S(70))) + S(180)*a**S(2)*x**(m + S(1))*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/((m + S(10))*(m + S(13))*(m + S(16))) + S(15)*a*x**(m + S(1))*(a + b*x**S(3))*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/(m**S(2) + S(29)*m + S(208)) + x**(m + S(1))*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/(m + S(16)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(13)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2), x), x, S(729)*a**S(5)*x**S(14)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(2063698)*a + S(2063698)*b*x**S(3)) + S(243)*a**S(4)*x**S(14)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/S(147407) + S(81)*a**S(3)*x**S(14)*(a + b*x**S(3))*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/S(17342) + S(90)*a**S(2)*x**S(14)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/S(8671) + S(15)*a*x**S(14)*(a + b*x**S(3))*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/S(754) + x**S(14)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/S(29), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(12)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2), x), x, S(729)*a**S(5)*x**S(13)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(1521520)*a + S(1521520)*b*x**S(3)) + S(243)*a**S(4)*x**S(13)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/S(117040) + S(81)*a**S(3)*x**S(13)*(a + b*x**S(3))*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/S(14630) + S(9)*a**S(2)*x**S(13)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/S(770) + S(3)*a*x**S(13)*(a + b*x**S(3))*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/S(140) + x**S(13)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/S(28), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(11)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2), x), x, -a**S(3)*(a + b*x**S(3))*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/(S(216)*b**S(4)) + a**S(2)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(7)/2)/(S(252)*b**S(4)) - a*x**S(6)*(a + b*x**S(3))*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/(S(72)*b**S(2)) + x**S(9)*(a + b*x**S(3))*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/(S(27)*b), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(10)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2), x), x, S(729)*a**S(5)*x**S(11)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(782782)*a + S(782782)*b*x**S(3)) + S(243)*a**S(4)*x**S(11)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/S(71162) + S(81)*a**S(3)*x**S(11)*(a + b*x**S(3))*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/S(10166) + S(9)*a**S(2)*x**S(11)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/S(598) + S(15)*a*x**S(11)*(a + b*x**S(3))*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/S(598) + x**S(11)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/S(26), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(9)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2), x), x, S(729)*a**S(5)*x**S(10)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(543400)*a + S(543400)*b*x**S(3)) + S(243)*a**S(4)*x**S(10)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/S(54340) + S(81)*a**S(3)*x**S(10)*(a + b*x**S(3))*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/S(8360) + S(18)*a**S(2)*x**S(10)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/S(1045) + S(3)*a*x**S(10)*(a + b*x**S(3))*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/S(110) + x**S(10)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/S(25), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(8)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2), x), x, a**S(2)*(a + b*x**S(3))*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/(S(72)*b**S(3)) - a*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(7)/2)/(S(84)*b**S(3)) + x**S(6)*(a + b*x**S(3))*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/(S(24)*b), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(7)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2), x), x, S(729)*a**S(5)*x**S(8)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(240856)*a + S(240856)*b*x**S(3)) + S(243)*a**S(4)*x**S(8)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/S(30107) + S(81)*a**S(3)*x**S(8)*(a + b*x**S(3))*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/S(5474) + S(9)*a**S(2)*x**S(8)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/S(391) + S(3)*a*x**S(8)*(a + b*x**S(3))*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/S(92) + x**S(8)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/S(23), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(6)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2), x), x, S(729)*a**S(5)*x**S(7)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(152152)*a + S(152152)*b*x**S(3)) + S(243)*a**S(4)*x**S(7)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/S(21736) + S(405)*a**S(3)*x**S(7)*(a + b*x**S(3))*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/S(21736) + S(45)*a**S(2)*x**S(7)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/S(1672) + S(15)*a*x**S(7)*(a + b*x**S(3))*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/S(418) + x**S(7)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/S(22), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2), x), x, -a*(a + b*x**S(3))*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/(S(18)*b**S(2)) + (a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(7)/2)/(S(21)*b**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2), x), x, S(729)*a**S(5)*x**S(5)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(52360)*a + S(52360)*b*x**S(3)) + S(243)*a**S(4)*x**S(5)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/S(10472) + S(81)*a**S(3)*x**S(5)*(a + b*x**S(3))*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/S(2618) + S(9)*a**S(2)*x**S(5)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/S(238) + S(3)*a*x**S(5)*(a + b*x**S(3))*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/S(68) + x**S(5)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/S(20), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2), x), x, S(729)*a**S(5)*x**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(27664)*a + S(27664)*b*x**S(3)) + S(243)*a**S(4)*x**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/S(6916) + S(81)*a**S(3)*x**S(4)*(a + b*x**S(3))*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/S(1976) + S(45)*a**S(2)*x**S(4)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/S(988) + S(15)*a*x**S(4)*(a + b*x**S(3))*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/S(304) + x**S(4)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/S(19), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2), x), x, (a + b*x**S(3))*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/(S(18)*b), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2), x), x, S(729)*a**S(5)*x**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(5236)*a + S(5236)*b*x**S(3)) + S(243)*a**S(4)*x**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/S(2618) + S(405)*a**S(3)*x**S(2)*(a + b*x**S(3))*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/S(5236) + S(90)*a**S(2)*x**S(2)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/S(1309) + S(15)*a*x**S(2)*(a + b*x**S(3))*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/S(238) + x**S(2)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/S(17), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2), x), x, S(729)*a**S(5)*x*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(1456)*a + S(1456)*b*x**S(3)) + S(243)*a**S(4)*x*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/S(1456) + S(81)*a**S(3)*x*(a + b*x**S(3))*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/S(728) + S(9)*a**S(2)*x*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/S(104) + S(15)*a*x*(a + b*x**S(3))*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/S(208) + x*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/S(16), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/x, x), x, a**S(5)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))*log(x)/(a + b*x**S(3)) + a**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/S(3) + a**S(3)*(a + b*x**S(3))*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/S(6) + a**S(2)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/S(9) + a*(a + b*x**S(3))*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/S(12) + (a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/S(15), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/x**S(2), x), x, -S(729)*a**S(5)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(308)*x*(a + b*x**S(3))) + S(243)*a**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(308)*x) + S(81)*a**S(3)*(a + b*x**S(3))*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(308)*x) + S(45)*a**S(2)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/(S(308)*x) + S(15)*a*(a + b*x**S(3))*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/(S(154)*x) + (a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/(S(14)*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/x**S(3), x), x, -S(729)*a**S(5)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(182)*x**S(2)*(a + b*x**S(3))) + S(243)*a**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(91)*x**S(2)) + S(81)*a**S(3)*(a + b*x**S(3))*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(182)*x**S(2)) + S(18)*a**S(2)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/(S(91)*x**S(2)) + S(3)*a*(a + b*x**S(3))*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/(S(26)*x**S(2)) + (a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/(S(13)*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/x**S(4), x), x, S(5)*a**S(4)*b*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))*log(x)/(a + b*x**S(3)) + S(5)*a**S(3)*b*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/S(3) + S(5)*a**S(2)*b*(a + b*x**S(3))*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/S(6) + S(5)*a*b*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/S(9) - S(5)*a*(a + b*x**S(3))*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/(S(12)*x**S(3)) + (a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/(S(12)*x**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/x**S(5), x), x, S(729)*a**S(3)*b**S(2)*x**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(88)*a + S(88)*b*x**S(3)) + S(243)*a**S(2)*b**S(2)*x**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/S(44) + S(405)*a*b**S(2)*x**S(2)*(a + b*x**S(3))*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/S(88) + S(15)*a*(a + b*x**S(3))*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/(S(4)*x**S(4)) + S(45)*b**S(2)*x**S(2)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/S(11) - S(4)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/x**S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/x**S(6), x), x, S(729)*a**S(3)*b**S(2)*x*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(70)*a + S(70)*b*x**S(3)) + S(243)*a**S(2)*b**S(2)*x*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/S(70) + S(81)*a*b**S(2)*x*(a + b*x**S(3))*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/S(35) + S(3)*a*(a + b*x**S(3))*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/(S(2)*x**S(5)) + S(9)*b**S(2)*x*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/S(5) - S(17)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/(S(10)*x**S(5)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/x**S(7), x), x, S(10)*a**S(3)*b**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))*log(x)/(a + b*x**S(3)) + S(10)*a**S(2)*b**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/S(3) + S(5)*a*b**S(2)*(a + b*x**S(3))*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/S(3) + S(5)*a*(a + b*x**S(3))*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/(S(6)*x**S(6)) + S(10)*b**S(2)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/S(9) - (a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/x**S(6), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/x**S(8), x), x, -S(729)*a**S(3)*b**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(56)*x*(a + b*x**S(3))) + S(243)*a**S(2)*b**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(56)*x) + S(81)*a*b**S(2)*(a + b*x**S(3))*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(56)*x) + S(15)*a*(a + b*x**S(3))*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/(S(28)*x**S(7)) + S(45)*b**S(2)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/(S(56)*x) - S(19)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/(S(28)*x**S(7)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/x**S(9), x), x, -S(729)*a**S(3)*b**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(56)*x**S(2)*(a + b*x**S(3))) + S(243)*a**S(2)*b**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(28)*x**S(2)) + S(81)*a*b**S(2)*(a + b*x**S(3))*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(56)*x**S(2)) + S(3)*a*(a + b*x**S(3))*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/(S(8)*x**S(8)) + S(9)*b**S(2)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/(S(14)*x**S(2)) - (a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/(S(2)*x**S(8)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/x**S(10), x), x, S(10)*a**S(2)*b**S(3)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))*log(x)/(a + b*x**S(3)) + S(10)*a*b**S(3)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/S(3) - S(5)*a*b**S(2)*(a + b*x**S(3))*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(3)*x**S(3)) + S(5)*a*(a + b*x**S(3))*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/(S(18)*x**S(9)) + S(5)*b**S(2)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/(S(9)*x**S(3)) - S(7)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/(S(18)*x**S(9)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/x**S(11), x), x, S(729)*a*b**S(4)*x**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(70)*a + S(70)*b*x**S(3)) + S(81)*a*b**S(2)*(a + b*x**S(3))*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(14)*x**S(4)) + S(3)*a*(a + b*x**S(3))*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/(S(14)*x**S(10)) + S(243)*b**S(4)*x**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/S(35) - S(45)*b**S(2)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/(S(7)*x**S(4)) - S(11)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/(S(35)*x**S(10)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/x**S(12), x), x, S(729)*a*b**S(4)*x*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(88)*a + S(88)*b*x**S(3)) + S(81)*a*b**S(2)*(a + b*x**S(3))*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(44)*x**S(5)) + S(15)*a*(a + b*x**S(3))*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/(S(88)*x**S(11)) + S(243)*b**S(4)*x*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/S(88) - S(9)*b**S(2)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/(S(4)*x**S(5)) - S(23)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/(S(88)*x**S(11)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/x**S(13), x), x, S(5)*a*b**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))*log(x)/(a + b*x**S(3)) + S(5)*a*b**S(2)*(a + b*x**S(3))*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(6)*x**S(6)) + S(5)*a*(a + b*x**S(3))*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/(S(36)*x**S(12)) + S(5)*b**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/S(3) - S(10)*b**S(2)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/(S(9)*x**S(6)) - S(2)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/(S(9)*x**S(12)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/x**S(14), x), x, -S(729)*a*b**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(182)*x*(a + b*x**S(3))) + S(81)*a*b**S(2)*(a + b*x**S(3))*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(182)*x**S(7)) + S(3)*a*(a + b*x**S(3))*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/(S(26)*x**S(13)) + S(243)*b**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(182)*x) - S(9)*b**S(2)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/(S(14)*x**S(7)) - S(5)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/(S(26)*x**S(13)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/x**S(15), x), x, -S(729)*a*b**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(308)*x**S(2)*(a + b*x**S(3))) + S(81)*a*b**S(2)*(a + b*x**S(3))*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(308)*x**S(8)) + S(15)*a*(a + b*x**S(3))*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/(S(154)*x**S(14)) + S(243)*b**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(154)*x**S(2)) - S(9)*b**S(2)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/(S(22)*x**S(8)) - S(13)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/(S(77)*x**S(14)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/x**S(16), x), x, -a*b**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(3)*x**S(3)*(a + b*x**S(3))) + a*b**S(2)*(a + b*x**S(3))*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(6)*x**S(9)) + a*(a + b*x**S(3))*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/(S(12)*x**S(15)) + b**S(5)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))*log(x)/(a + b*x**S(3)) - S(5)*b**S(2)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/(S(18)*x**S(9)) - S(3)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/(S(20)*x**S(15)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/x**S(17), x), x, S(729)*a*b**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(1456)*x**S(4)*(a + b*x**S(3))) + S(81)*a*b**S(2)*(a + b*x**S(3))*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(728)*x**S(10)) + S(15)*a*(a + b*x**S(3))*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/(S(208)*x**S(16)) - S(243)*b**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(364)*x**S(4)) - S(18)*b**S(2)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/(S(91)*x**S(10)) - S(7)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/(S(52)*x**S(16)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/x**S(18), x), x, S(729)*a*b**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(5236)*x**S(5)*(a + b*x**S(3))) + S(405)*a*b**S(2)*(a + b*x**S(3))*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(5236)*x**S(11)) + S(15)*a*(a + b*x**S(3))*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/(S(238)*x**S(17)) - S(1215)*b**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(5236)*x**S(5)) - S(45)*b**S(2)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/(S(308)*x**S(11)) - S(29)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/(S(238)*x**S(17)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/x**S(19), x), x, -(a + b*x**S(3))*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/(S(18)*a*x**S(18)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/x**S(20), x), x, S(729)*a*b**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(27664)*x**S(7)*(a + b*x**S(3))) + S(81)*a*b**S(2)*(a + b*x**S(3))*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(1976)*x**S(13)) + S(15)*a*(a + b*x**S(3))*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/(S(304)*x**S(19)) - S(243)*b**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(3952)*x**S(7)) - S(9)*b**S(2)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/(S(104)*x**S(13)) - S(31)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/(S(304)*x**S(19)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/x**S(21), x), x, S(729)*a*b**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(52360)*x**S(8)*(a + b*x**S(3))) + S(81)*a*b**S(2)*(a + b*x**S(3))*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(2618)*x**S(14)) + S(3)*a*(a + b*x**S(3))*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/(S(68)*x**S(20)) - S(243)*b**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(6545)*x**S(8)) - S(90)*b**S(2)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/(S(1309)*x**S(14)) - S(8)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/(S(85)*x**S(20)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/x**S(22), x), x, -(a + b*x**S(3))*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/(S(18)*a*x**S(21)) + (a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(7)/2)/(S(126)*a**S(2)*x**S(21)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/x**S(23), x), x, S(729)*a*b**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(152152)*x**S(10)*(a + b*x**S(3))) + S(405)*a*b**S(2)*(a + b*x**S(3))*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(21736)*x**S(16)) + S(15)*a*(a + b*x**S(3))*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/(S(418)*x**S(22)) - S(1215)*b**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(76076)*x**S(10)) - S(45)*b**S(2)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/(S(988)*x**S(16)) - S(17)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/(S(209)*x**S(22)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/x**S(24), x), x, S(729)*a*b**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(240856)*x**S(11)*(a + b*x**S(3))) + S(81)*a*b**S(2)*(a + b*x**S(3))*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(5474)*x**S(17)) + S(3)*a*(a + b*x**S(3))*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/(S(92)*x**S(23)) - S(243)*b**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(21896)*x**S(11)) - S(9)*b**S(2)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)/(S(238)*x**S(17)) - S(7)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/(S(92)*x**S(23)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/x**S(25), x), x, -(a + b*x**S(3))*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/(S(24)*a*x**S(24)) + b*(a + b*x**S(3))*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)/(S(72)*a**S(2)*x**S(21)) - b*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(7)/2)/(S(504)*a**S(3)*x**S(21)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**m/sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6)), x), x, x**(m + S(1))*(a + b*x**S(3))*hyper((S(1), m/S(3) + S(1)/3), (m/S(3) + S(4)/3,), -b*x**S(3)/a)/(a*(m + S(1))*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)/sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6)), x), x, a**(S(2)/3)*(a + b*x**S(3))*log(a**(S(1)/3) + b**(S(1)/3)*x)/(S(3)*b**(S(5)/3)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) - a**(S(2)/3)*(a + b*x**S(3))*log(a**(S(2)/3) - a**(S(1)/3)*b**(S(1)/3)*x + b**(S(2)/3)*x**S(2))/(S(6)*b**(S(5)/3)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) + sqrt(S(3))*a**(S(2)/3)*(a + b*x**S(3))*atan(sqrt(S(3))*(a**(S(1)/3) - S(2)*b**(S(1)/3)*x)/(S(3)*a**(S(1)/3)))/(S(3)*b**(S(5)/3)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) + x**S(2)*(a + b*x**S(3))/(S(2)*b*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6)), x), x, -a**(S(1)/3)*(a + b*x**S(3))*log(a**(S(1)/3) + b**(S(1)/3)*x)/(S(3)*b**(S(4)/3)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) + a**(S(1)/3)*(a + b*x**S(3))*log(a**(S(2)/3) - a**(S(1)/3)*b**(S(1)/3)*x + b**(S(2)/3)*x**S(2))/(S(6)*b**(S(4)/3)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) + sqrt(S(3))*a**(S(1)/3)*(a + b*x**S(3))*atan(sqrt(S(3))*(a**(S(1)/3) - S(2)*b**(S(1)/3)*x)/(S(3)*a**(S(1)/3)))/(S(3)*b**(S(4)/3)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) + x*(a + b*x**S(3))/(b*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6)), x), x, (a + b*x**S(3))*log(a + b*x**S(3))/(S(3)*b*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6)), x), x, -(a + b*x**S(3))*log(a**(S(1)/3) + b**(S(1)/3)*x)/(S(3)*a**(S(1)/3)*b**(S(2)/3)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) + (a + b*x**S(3))*log(a**(S(2)/3) - a**(S(1)/3)*b**(S(1)/3)*x + b**(S(2)/3)*x**S(2))/(S(6)*a**(S(1)/3)*b**(S(2)/3)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) - sqrt(S(3))*(a + b*x**S(3))*atan(sqrt(S(3))*(a**(S(1)/3) - S(2)*b**(S(1)/3)*x)/(S(3)*a**(S(1)/3)))/(S(3)*a**(S(1)/3)*b**(S(2)/3)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6)), x), x, (a + b*x**S(3))*log(a**(S(1)/3) + b**(S(1)/3)*x)/(S(3)*a**(S(2)/3)*b**(S(1)/3)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) - (a + b*x**S(3))*log(a**(S(2)/3) - a**(S(1)/3)*b**(S(1)/3)*x + b**(S(2)/3)*x**S(2))/(S(6)*a**(S(2)/3)*b**(S(1)/3)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) - sqrt(S(3))*(a + b*x**S(3))*atan(sqrt(S(3))*(a**(S(1)/3) - S(2)*b**(S(1)/3)*x)/(S(3)*a**(S(1)/3)))/(S(3)*a**(S(2)/3)*b**(S(1)/3)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))), x), x, (a + b*x**S(3))*log(x)/(a*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) - (a + b*x**S(3))*log(a + b*x**S(3))/(S(3)*a*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))), x), x, -(a + b*x**S(3))/(a*x*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) + b**(S(1)/3)*(a + b*x**S(3))*log(a**(S(1)/3) + b**(S(1)/3)*x)/(S(3)*a**(S(4)/3)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) - b**(S(1)/3)*(a + b*x**S(3))*log(a**(S(2)/3) - a**(S(1)/3)*b**(S(1)/3)*x + b**(S(2)/3)*x**S(2))/(S(6)*a**(S(4)/3)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) + sqrt(S(3))*b**(S(1)/3)*(a + b*x**S(3))*atan(sqrt(S(3))*(a**(S(1)/3) - S(2)*b**(S(1)/3)*x)/(S(3)*a**(S(1)/3)))/(S(3)*a**(S(4)/3)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(3)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))), x), x, (-a - b*x**S(3))/(S(2)*a*x**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) - b**(S(2)/3)*(a + b*x**S(3))*log(a**(S(1)/3) + b**(S(1)/3)*x)/(S(3)*a**(S(5)/3)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) + b**(S(2)/3)*(a + b*x**S(3))*log(a**(S(2)/3) - a**(S(1)/3)*b**(S(1)/3)*x + b**(S(2)/3)*x**S(2))/(S(6)*a**(S(5)/3)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) + sqrt(S(3))*b**(S(2)/3)*(a + b*x**S(3))*atan(sqrt(S(3))*(a**(S(1)/3) - S(2)*b**(S(1)/3)*x)/(S(3)*a**(S(1)/3)))/(S(3)*a**(S(5)/3)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))), x), x, -b*(a + b*x**S(3))*log(x)/(a**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) + b*(a + b*x**S(3))*log(a + b*x**S(3))/(S(3)*a**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) - sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(3)*a**S(2)*x**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**m/(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2), x), x, x**(m + S(1))*(a + b*x**S(3))*hyper((S(3), m/S(3) + S(1)/3), (m/S(3) + S(4)/3,), -b*x**S(3)/a)/(a**S(3)*(m + S(1))*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)/(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2), x), x, x**S(5)*(a + b*x**S(3))/(S(6)*a*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)) - x**S(2)/(S(18)*a*b*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) - (a + b*x**S(3))*log(a**(S(1)/3) + b**(S(1)/3)*x)/(S(27)*a**(S(4)/3)*b**(S(5)/3)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) + (a + b*x**S(3))*log(a**(S(2)/3) - a**(S(1)/3)*b**(S(1)/3)*x + b**(S(2)/3)*x**S(2))/(S(54)*a**(S(4)/3)*b**(S(5)/3)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) - sqrt(S(3))*(a + b*x**S(3))*atan(sqrt(S(3))*(a**(S(1)/3) - S(2)*b**(S(1)/3)*x)/(S(3)*a**(S(1)/3)))/(S(27)*a**(S(4)/3)*b**(S(5)/3)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2), x), x, x**S(4)*(a + b*x**S(3))/(S(6)*a*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)) - x/(S(9)*a*b*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) + (a + b*x**S(3))*log(a**(S(1)/3) + b**(S(1)/3)*x)/(S(27)*a**(S(5)/3)*b**(S(4)/3)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) - (a + b*x**S(3))*log(a**(S(2)/3) - a**(S(1)/3)*b**(S(1)/3)*x + b**(S(2)/3)*x**S(2))/(S(54)*a**(S(5)/3)*b**(S(4)/3)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) - sqrt(S(3))*(a + b*x**S(3))*atan(sqrt(S(3))*(a**(S(1)/3) - S(2)*b**(S(1)/3)*x)/(S(3)*a**(S(1)/3)))/(S(27)*a**(S(5)/3)*b**(S(4)/3)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2), x), x, (-a - b*x**S(3))/(S(6)*b*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2), x), x, x**S(2)*(a + b*x**S(3))/(S(6)*a*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)) + S(2)*x**S(2)/(S(9)*a**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) + (a + b*x**S(3))*log(a**(S(2)/3) - a**(S(1)/3)*b**(S(1)/3)*x + b**(S(2)/3)*x**S(2))/(S(27)*a**(S(7)/3)*b**(S(2)/3)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) - (S(2)*a + S(2)*b*x**S(3))*log(a**(S(1)/3) + b**(S(1)/3)*x)/(S(27)*a**(S(7)/3)*b**(S(2)/3)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) - sqrt(S(3))*(S(2)*a + S(2)*b*x**S(3))*atan(sqrt(S(3))*(a**(S(1)/3) - S(2)*b**(S(1)/3)*x)/(S(3)*a**(S(1)/3)))/(S(27)*a**(S(7)/3)*b**(S(2)/3)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(-3)/2), x), x, x*(a + b*x**S(3))/(S(6)*a*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)) + S(5)*x/(S(18)*a**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) + (S(5)*a + S(5)*b*x**S(3))*log(a**(S(1)/3) + b**(S(1)/3)*x)/(S(27)*a**(S(8)/3)*b**(S(1)/3)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) - (S(5)*a + S(5)*b*x**S(3))*log(a**(S(2)/3) - a**(S(1)/3)*b**(S(1)/3)*x + b**(S(2)/3)*x**S(2))/(S(54)*a**(S(8)/3)*b**(S(1)/3)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) - sqrt(S(3))*(S(5)*a + S(5)*b*x**S(3))*atan(sqrt(S(3))*(a**(S(1)/3) - S(2)*b**(S(1)/3)*x)/(S(3)*a**(S(1)/3)))/(S(27)*a**(S(8)/3)*b**(S(1)/3)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)), x), x, (a + b*x**S(3))/(S(6)*a*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)) + S(1)/(S(3)*a**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) + (a + b*x**S(3))*log(x)/(a**S(3)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) - (a + b*x**S(3))*log(a + b*x**S(3))/(S(3)*a**S(3)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)), x), x, (a + b*x**S(3))/(S(6)*a*x*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)) + S(7)/(S(18)*a**S(2)*x*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) - (S(14)*a + S(14)*b*x**S(3))/(S(9)*a**S(3)*x*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) + S(14)*b**(S(1)/3)*(a + b*x**S(3))*log(a**(S(1)/3) + b**(S(1)/3)*x)/(S(27)*a**(S(10)/3)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) - S(7)*b**(S(1)/3)*(a + b*x**S(3))*log(a**(S(2)/3) - a**(S(1)/3)*b**(S(1)/3)*x + b**(S(2)/3)*x**S(2))/(S(27)*a**(S(10)/3)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) + S(14)*sqrt(S(3))*b**(S(1)/3)*(a + b*x**S(3))*atan(sqrt(S(3))*(a**(S(1)/3) - S(2)*b**(S(1)/3)*x)/(S(3)*a**(S(1)/3)))/(S(27)*a**(S(10)/3)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(3)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)), x), x, (a + b*x**S(3))/(S(6)*a*x**S(2)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)) + S(4)/(S(9)*a**S(2)*x**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) - (S(10)*a + S(10)*b*x**S(3))/(S(9)*a**S(3)*x**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) - S(20)*b**(S(2)/3)*(a + b*x**S(3))*log(a**(S(1)/3) + b**(S(1)/3)*x)/(S(27)*a**(S(11)/3)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) + S(10)*b**(S(2)/3)*(a + b*x**S(3))*log(a**(S(2)/3) - a**(S(1)/3)*b**(S(1)/3)*x + b**(S(2)/3)*x**S(2))/(S(27)*a**(S(11)/3)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) + S(20)*sqrt(S(3))*b**(S(2)/3)*(a + b*x**S(3))*atan(sqrt(S(3))*(a**(S(1)/3) - S(2)*b**(S(1)/3)*x)/(S(3)*a**(S(1)/3)))/(S(27)*a**(S(11)/3)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(4)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)), x), x, (a + b*x**S(3))/(S(6)*a*x**S(3)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)) + S(1)/(S(2)*a**S(2)*x**S(3)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) - S(3)*b*(a + b*x**S(3))*log(x)/(a**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) + b*(a + b*x**S(3))*log(a + b*x**S(3))/(a**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) - sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(a**S(4)*x**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**m/(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2), x), x, x**(m + S(1))*(a + b*x**S(3))*hyper((S(5), m/S(3) + S(1)/3), (m/S(3) + S(4)/3,), -b*x**S(3)/a)/(a**S(5)*(m + S(1))*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(6)/(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2), x), x, a*x*(a + b*x**S(3))/(S(12)*b**S(2)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)) - S(13)*x/(S(108)*b**S(2)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)) + x*(a + b*x**S(3))/(S(162)*a*b**S(2)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)) + S(5)*x/(S(486)*a**S(2)*b**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) + (S(5)*a + S(5)*b*x**S(3))*log(a**(S(1)/3) + b**(S(1)/3)*x)/(S(729)*a**(S(8)/3)*b**(S(7)/3)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) - (S(5)*a + S(5)*b*x**S(3))*log(a**(S(2)/3) - a**(S(1)/3)*b**(S(1)/3)*x + b**(S(2)/3)*x**S(2))/(S(1458)*a**(S(8)/3)*b**(S(7)/3)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) - sqrt(S(3))*(S(5)*a + S(5)*b*x**S(3))*atan(sqrt(S(3))*(a**(S(1)/3) - S(2)*b**(S(1)/3)*x)/(S(3)*a**(S(1)/3)))/(S(729)*a**(S(8)/3)*b**(S(7)/3)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)/(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2), x), x, a*(a + b*x**S(3))/(S(12)*b**S(2)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)) - S(1)/(S(9)*b**S(2)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)/(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2), x), x, x**S(5)*(a + b*x**S(3))/(S(12)*a*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)) - S(7)*x**S(2)/(S(108)*a*b*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)) + S(7)*x**S(2)*(a + b*x**S(3))/(S(324)*a**S(2)*b*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)) + S(7)*x**S(2)/(S(243)*a**S(3)*b*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) - (S(7)*a + S(7)*b*x**S(3))*log(a**(S(1)/3) + b**(S(1)/3)*x)/(S(729)*a**(S(10)/3)*b**(S(5)/3)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) + (S(7)*a + S(7)*b*x**S(3))*log(a**(S(2)/3) - a**(S(1)/3)*b**(S(1)/3)*x + b**(S(2)/3)*x**S(2))/(S(1458)*a**(S(10)/3)*b**(S(5)/3)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) - sqrt(S(3))*(S(7)*a + S(7)*b*x**S(3))*atan(sqrt(S(3))*(a**(S(1)/3) - S(2)*b**(S(1)/3)*x)/(S(3)*a**(S(1)/3)))/(S(729)*a**(S(10)/3)*b**(S(5)/3)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2), x), x, x**S(4)*(a + b*x**S(3))/(S(12)*a*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)) - S(2)*x/(S(27)*a*b*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)) + x*(a + b*x**S(3))/(S(81)*a**S(2)*b*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)) + S(5)*x/(S(243)*a**S(3)*b*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) - (S(5)*a + S(5)*b*x**S(3))*log(a**(S(2)/3) - a**(S(1)/3)*b**(S(1)/3)*x + b**(S(2)/3)*x**S(2))/(S(729)*a**(S(11)/3)*b**(S(4)/3)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) + (S(10)*a + S(10)*b*x**S(3))*log(a**(S(1)/3) + b**(S(1)/3)*x)/(S(729)*a**(S(11)/3)*b**(S(4)/3)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) - sqrt(S(3))*(S(10)*a + S(10)*b*x**S(3))*atan(sqrt(S(3))*(a**(S(1)/3) - S(2)*b**(S(1)/3)*x)/(S(3)*a**(S(1)/3)))/(S(729)*a**(S(11)/3)*b**(S(4)/3)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2), x), x, (-a - b*x**S(3))/(S(12)*b*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2), x), x, x**S(2)*(a + b*x**S(3))/(S(12)*a*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)) + S(5)*x**S(2)/(S(54)*a**S(2)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)) + S(35)*x**S(2)*(a + b*x**S(3))/(S(324)*a**S(3)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)) + S(35)*x**S(2)/(S(243)*a**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) - (S(35)*a + S(35)*b*x**S(3))*log(a**(S(1)/3) + b**(S(1)/3)*x)/(S(729)*a**(S(13)/3)*b**(S(2)/3)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) + (S(35)*a + S(35)*b*x**S(3))*log(a**(S(2)/3) - a**(S(1)/3)*b**(S(1)/3)*x + b**(S(2)/3)*x**S(2))/(S(1458)*a**(S(13)/3)*b**(S(2)/3)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) - sqrt(S(3))*(S(35)*a + S(35)*b*x**S(3))*atan(sqrt(S(3))*(a**(S(1)/3) - S(2)*b**(S(1)/3)*x)/(S(3)*a**(S(1)/3)))/(S(729)*a**(S(13)/3)*b**(S(2)/3)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(-5)/2), x), x, x*(a + b*x**S(3))/(S(12)*a*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)) + S(11)*x/(S(108)*a**S(2)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)) + S(11)*x*(a + b*x**S(3))/(S(81)*a**S(3)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)) + S(55)*x/(S(243)*a**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) - (S(55)*a + S(55)*b*x**S(3))*log(a**(S(2)/3) - a**(S(1)/3)*b**(S(1)/3)*x + b**(S(2)/3)*x**S(2))/(S(729)*a**(S(14)/3)*b**(S(1)/3)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) + (S(110)*a + S(110)*b*x**S(3))*log(a**(S(1)/3) + b**(S(1)/3)*x)/(S(729)*a**(S(14)/3)*b**(S(1)/3)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) - sqrt(S(3))*(S(110)*a + S(110)*b*x**S(3))*atan(sqrt(S(3))*(a**(S(1)/3) - S(2)*b**(S(1)/3)*x)/(S(3)*a**(S(1)/3)))/(S(729)*a**(S(14)/3)*b**(S(1)/3)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)), x), x, (a + b*x**S(3))/(S(12)*a*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)) + S(1)/(S(9)*a**S(2)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)) + (a + b*x**S(3))/(S(6)*a**S(3)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)) + S(1)/(S(3)*a**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) + (a + b*x**S(3))*log(x)/(a**S(5)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) - (a + b*x**S(3))*log(a + b*x**S(3))/(S(3)*a**S(5)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)), x), x, (a + b*x**S(3))/(S(12)*a*x*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)) + S(13)/(S(108)*a**S(2)*x*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)) + (S(65)*a + S(65)*b*x**S(3))/(S(324)*a**S(3)*x*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)) + S(455)/(S(972)*a**S(4)*x*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) - (S(455)*a + S(455)*b*x**S(3))/(S(243)*a**S(5)*x*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) + S(455)*b**(S(1)/3)*(a + b*x**S(3))*log(a**(S(1)/3) + b**(S(1)/3)*x)/(S(729)*a**(S(16)/3)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) - S(455)*b**(S(1)/3)*(a + b*x**S(3))*log(a**(S(2)/3) - a**(S(1)/3)*b**(S(1)/3)*x + b**(S(2)/3)*x**S(2))/(S(1458)*a**(S(16)/3)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) + S(455)*sqrt(S(3))*b**(S(1)/3)*(a + b*x**S(3))*atan(sqrt(S(3))*(a**(S(1)/3) - S(2)*b**(S(1)/3)*x)/(S(3)*a**(S(1)/3)))/(S(729)*a**(S(16)/3)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(3)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)), x), x, (a + b*x**S(3))/(S(12)*a*x**S(2)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)) + S(7)/(S(54)*a**S(2)*x**S(2)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)) + (S(77)*a + S(77)*b*x**S(3))/(S(324)*a**S(3)*x**S(2)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)) + S(154)/(S(243)*a**S(4)*x**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) - (S(385)*a + S(385)*b*x**S(3))/(S(243)*a**S(5)*x**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) - S(770)*b**(S(2)/3)*(a + b*x**S(3))*log(a**(S(1)/3) + b**(S(1)/3)*x)/(S(729)*a**(S(17)/3)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) + S(385)*b**(S(2)/3)*(a + b*x**S(3))*log(a**(S(2)/3) - a**(S(1)/3)*b**(S(1)/3)*x + b**(S(2)/3)*x**S(2))/(S(729)*a**(S(17)/3)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) + S(770)*sqrt(S(3))*b**(S(2)/3)*(a + b*x**S(3))*atan(sqrt(S(3))*(a**(S(1)/3) - S(2)*b**(S(1)/3)*x)/(S(3)*a**(S(1)/3)))/(S(729)*a**(S(17)/3)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(4)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)), x), x, (a + b*x**S(3))/(S(12)*a*x**S(3)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(5)/2)) + S(5)/(S(36)*a**S(2)*x**S(3)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)) + (S(5)*a + S(5)*b*x**S(3))/(S(18)*a**S(3)*x**S(3)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(S(3)/2)) + S(5)/(S(6)*a**S(4)*x**S(3)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) - S(5)*b*(a + b*x**S(3))*log(x)/(a**S(6)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) + S(5)*b*(a + b*x**S(3))*log(a + b*x**S(3))/(S(3)*a**S(6)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))) - S(5)*sqrt(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))/(S(3)*a**S(6)*x**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**m*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**p, x), x, x**(m + S(1))*(a + b*x**S(3))*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**p*hyper((S(1), m/S(3) + S(2)*p + S(4)/3), (m/S(3) + S(4)/3,), -b*x**S(3)/a)/(a*(m + S(1))), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate(x**m*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**p, x), x, x**(m + S(1))*(S(1) + b*x**S(3)/a)**(-S(2)*p)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**p*hyper((m/S(3) + S(1)/3, -S(2)*p), (m/S(3) + S(4)/3,), -b*x**S(3)/a)/(m + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**p, x), x, -a*(a + b*x**S(3))*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**p/(S(3)*b**S(2)*(S(2)*p + S(1))) + (a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**(p + S(1))/(S(6)*b**S(2)*(p + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**p, x), x, x**S(5)*(S(1) + b*x**S(3)/a)**(-S(2)*p)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**p*hyper((S(5)/3, -S(2)*p), (S(8)/3,), -b*x**S(3)/a)/S(5), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**p, x), x, x**S(4)*(S(1) + b*x**S(3)/a)**(-S(2)*p)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**p*hyper((S(4)/3, -S(2)*p), (S(7)/3,), -b*x**S(3)/a)/S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**p, x), x, (a + b*x**S(3))*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**p/(S(3)*b*(S(2)*p + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**p, x), x, x**S(2)*(a + b*x**S(3))*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**p*hyper((S(1), S(2)*p + S(5)/3), (S(5)/3,), -b*x**S(3)/a)/(S(2)*a), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate(x*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**p, x), x, x**S(2)*(S(1) + b*x**S(3)/a)**(-S(2)*p)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**p*hyper((S(2)/3, -S(2)*p), (S(5)/3,), -b*x**S(3)/a)/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**p, x), x, x*(a + b*x**S(3))*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**p*hyper((S(1), S(2)*p + S(4)/3), (S(4)/3,), -b*x**S(3)/a)/a, expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**p, x), x, x*(S(1) + b*x**S(3)/a)**(-S(2)*p)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**p*hyper((S(1)/3, -S(2)*p), (S(4)/3,), -b*x**S(3)/a), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**p/x, x), x, -(a + b*x**S(3))*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**p*hyper((S(1), S(2)*p + S(1)), (S(2)*p + S(2),), S(1) + b*x**S(3)/a)/(S(3)*a*(S(2)*p + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**p/x**S(2), x), x, -(S(1) + b*x**S(3)/a)**(-S(2)*p)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**p*hyper((S(-1)/3, -S(2)*p), (S(2)/3,), -b*x**S(3)/a)/x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**p/x**S(3), x), x, -(S(1) + b*x**S(3)/a)**(-S(2)*p)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**p*hyper((S(-2)/3, -S(2)*p), (S(1)/3,), -b*x**S(3)/a)/(S(2)*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**p/x**S(4), x), x, b*(a + b*x**S(3))*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**p*hyper((S(2), S(2)*p + S(1)), (S(2)*p + S(2),), S(1) + b*x**S(3)/a)/(S(3)*a**S(2)*(S(2)*p + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**p/x**S(5), x), x, -(S(1) + b*x**S(3)/a)**(-S(2)*p)*(a**S(2) + S(2)*a*b*x**S(3) + b**S(2)*x**S(6))**p*hyper((S(-4)/3, -S(2)*p), (S(-1)/3,), -b*x**S(3)/a)/(S(4)*x**S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(8)/(a + b*x**S(3) + c*x**S(6)), x), x, -b*log(a + b*x**S(3) + c*x**S(6))/(S(6)*c**S(2)) + x**S(3)/(S(3)*c) - (-S(2)*a*c + b**S(2))*atanh((b + S(2)*c*x**S(3))/sqrt(-S(4)*a*c + b**S(2)))/(S(3)*c**S(2)*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)/(a + b*x**S(3) + c*x**S(6)), x), x, b*atanh((b + S(2)*c*x**S(3))/sqrt(-S(4)*a*c + b**S(2)))/(S(3)*c*sqrt(-S(4)*a*c + b**S(2))) + log(a + b*x**S(3) + c*x**S(6))/(S(6)*c), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/(a + b*x**S(3) + c*x**S(6)), x), x, -S(2)*atanh((b + S(2)*c*x**S(3))/sqrt(-S(4)*a*c + b**S(2)))/(S(3)*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*(a + b*x**S(3) + c*x**S(6))), x), x, b*atanh((b + S(2)*c*x**S(3))/sqrt(-S(4)*a*c + b**S(2)))/(S(3)*a*sqrt(-S(4)*a*c + b**S(2))) + log(x)/a - log(a + b*x**S(3) + c*x**S(6))/(S(6)*a), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(4)*(a + b*x**S(3) + c*x**S(6))), x), x, -S(1)/(S(3)*a*x**S(3)) - b*log(x)/a**S(2) + b*log(a + b*x**S(3) + c*x**S(6))/(S(6)*a**S(2)) - (-S(2)*a*c + b**S(2))*atanh((b + S(2)*c*x**S(3))/sqrt(-S(4)*a*c + b**S(2)))/(S(3)*a**S(2)*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(7)/(a + b*x**S(3) + c*x**S(6)), x), x, x**S(2)/(S(2)*c) + S(2)**(S(1)/3)*(b - (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*log(S(2)**(S(1)/3)*c**(S(1)/3)*x + (b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3))/(S(6)*c**(S(5)/3)*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3)) - S(2)**(S(1)/3)*(b - (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*log(S(2)**(S(2)/3)*c**(S(2)/3)*x**S(2) - S(2)**(S(1)/3)*c**(S(1)/3)*x*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + (b - sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3))/(S(12)*c**(S(5)/3)*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3)) + S(2)**(S(1)/3)*sqrt(S(3))*(b - (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(3))*(-S(2)*S(2)**(S(1)/3)*c**(S(1)/3)*x/(b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + S(1))/S(3))/(S(6)*c**(S(5)/3)*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3)) + S(2)**(S(1)/3)*(b + (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*log(S(2)**(S(1)/3)*c**(S(1)/3)*x + (b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3))/(S(6)*c**(S(5)/3)*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3)) - S(2)**(S(1)/3)*(b + (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*log(S(2)**(S(2)/3)*c**(S(2)/3)*x**S(2) - S(2)**(S(1)/3)*c**(S(1)/3)*x*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + (b + sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3))/(S(12)*c**(S(5)/3)*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3)) + S(2)**(S(1)/3)*sqrt(S(3))*(b + (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(3))*(-S(2)*S(2)**(S(1)/3)*c**(S(1)/3)*x/(b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + S(1))/S(3))/(S(6)*c**(S(5)/3)*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(6)/(a + b*x**S(3) + c*x**S(6)), x), x, x/c - S(2)**(S(2)/3)*(b - (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*log(S(2)**(S(1)/3)*c**(S(1)/3)*x + (b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3))/(S(6)*c**(S(4)/3)*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)) + S(2)**(S(2)/3)*(b - (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*log(S(2)**(S(2)/3)*c**(S(2)/3)*x**S(2) - S(2)**(S(1)/3)*c**(S(1)/3)*x*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + (b - sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3))/(S(12)*c**(S(4)/3)*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)) + S(2)**(S(2)/3)*sqrt(S(3))*(b - (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(3))*(-S(2)*S(2)**(S(1)/3)*c**(S(1)/3)*x/(b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + S(1))/S(3))/(S(6)*c**(S(4)/3)*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)) - S(2)**(S(2)/3)*(b + (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*log(S(2)**(S(1)/3)*c**(S(1)/3)*x + (b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3))/(S(6)*c**(S(4)/3)*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)) + S(2)**(S(2)/3)*(b + (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*log(S(2)**(S(2)/3)*c**(S(2)/3)*x**S(2) - S(2)**(S(1)/3)*c**(S(1)/3)*x*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + (b + sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3))/(S(12)*c**(S(4)/3)*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)) + S(2)**(S(2)/3)*sqrt(S(3))*(b + (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(3))*(-S(2)*S(2)**(S(1)/3)*c**(S(1)/3)*x/(b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + S(1))/S(3))/(S(6)*c**(S(4)/3)*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)/(a + b*x**S(3) + c*x**S(6)), x), x, S(2)**(S(1)/3)*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)*log(S(2)**(S(1)/3)*c**(S(1)/3)*x + (b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3))/(S(6)*c**(S(2)/3)*sqrt(-S(4)*a*c + b**S(2))) - S(2)**(S(1)/3)*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)*log(S(2)**(S(2)/3)*c**(S(2)/3)*x**S(2) - S(2)**(S(1)/3)*c**(S(1)/3)*x*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + (b - sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3))/(S(12)*c**(S(2)/3)*sqrt(-S(4)*a*c + b**S(2))) + S(2)**(S(1)/3)*sqrt(S(3))*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)*atan(sqrt(S(3))*(-S(2)*S(2)**(S(1)/3)*c**(S(1)/3)*x/(b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + S(1))/S(3))/(S(6)*c**(S(2)/3)*sqrt(-S(4)*a*c + b**S(2))) - S(2)**(S(1)/3)*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)*log(S(2)**(S(1)/3)*c**(S(1)/3)*x + (b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3))/(S(6)*c**(S(2)/3)*sqrt(-S(4)*a*c + b**S(2))) + S(2)**(S(1)/3)*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)*log(S(2)**(S(2)/3)*c**(S(2)/3)*x**S(2) - S(2)**(S(1)/3)*c**(S(1)/3)*x*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + (b + sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3))/(S(12)*c**(S(2)/3)*sqrt(-S(4)*a*c + b**S(2))) - S(2)**(S(1)/3)*sqrt(S(3))*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)*atan(sqrt(S(3))*(-S(2)*S(2)**(S(1)/3)*c**(S(1)/3)*x/(b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + S(1))/S(3))/(S(6)*c**(S(2)/3)*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/(a + b*x**S(3) + c*x**S(6)), x), x, -S(2)**(S(2)/3)*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3)*log(S(2)**(S(1)/3)*c**(S(1)/3)*x + (b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3))/(S(6)*c**(S(1)/3)*sqrt(-S(4)*a*c + b**S(2))) + S(2)**(S(2)/3)*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3)*log(S(2)**(S(2)/3)*c**(S(2)/3)*x**S(2) - S(2)**(S(1)/3)*c**(S(1)/3)*x*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + (b - sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3))/(S(12)*c**(S(1)/3)*sqrt(-S(4)*a*c + b**S(2))) + S(2)**(S(2)/3)*sqrt(S(3))*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3)*atan(sqrt(S(3))*(-S(2)*S(2)**(S(1)/3)*c**(S(1)/3)*x/(b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + S(1))/S(3))/(S(6)*c**(S(1)/3)*sqrt(-S(4)*a*c + b**S(2))) + S(2)**(S(2)/3)*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3)*log(S(2)**(S(1)/3)*c**(S(1)/3)*x + (b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3))/(S(6)*c**(S(1)/3)*sqrt(-S(4)*a*c + b**S(2))) - S(2)**(S(2)/3)*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3)*log(S(2)**(S(2)/3)*c**(S(2)/3)*x**S(2) - S(2)**(S(1)/3)*c**(S(1)/3)*x*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + (b + sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3))/(S(12)*c**(S(1)/3)*sqrt(-S(4)*a*c + b**S(2))) - S(2)**(S(2)/3)*sqrt(S(3))*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3)*atan(sqrt(S(3))*(-S(2)*S(2)**(S(1)/3)*c**(S(1)/3)*x/(b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + S(1))/S(3))/(S(6)*c**(S(1)/3)*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(a + b*x**S(3) + c*x**S(6)), x), x, S(2)**(S(1)/3)*c**(S(1)/3)*log(S(2)**(S(1)/3)*c**(S(1)/3)*x + (b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3))/(S(3)*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3)*sqrt(-S(4)*a*c + b**S(2))) - S(2)**(S(1)/3)*c**(S(1)/3)*log(S(2)**(S(2)/3)*c**(S(2)/3)*x**S(2) - S(2)**(S(1)/3)*c**(S(1)/3)*x*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + (b + sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3))/(S(6)*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3)*sqrt(-S(4)*a*c + b**S(2))) + S(2)**(S(1)/3)*sqrt(S(3))*c**(S(1)/3)*atan(sqrt(S(3))*(-S(2)*S(2)**(S(1)/3)*c**(S(1)/3)*x/(b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + S(1))/S(3))/(S(3)*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3)*sqrt(-S(4)*a*c + b**S(2))) - S(2)**(S(1)/3)*c**(S(1)/3)*log(S(2)**(S(1)/3)*c**(S(1)/3)*x + (b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3))/(S(3)*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3)*sqrt(-S(4)*a*c + b**S(2))) + S(2)**(S(1)/3)*c**(S(1)/3)*log(S(2)**(S(2)/3)*c**(S(2)/3)*x**S(2) - S(2)**(S(1)/3)*c**(S(1)/3)*x*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + (b - sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3))/(S(6)*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3)*sqrt(-S(4)*a*c + b**S(2))) - S(2)**(S(1)/3)*sqrt(S(3))*c**(S(1)/3)*atan(sqrt(S(3))*(-S(2)*S(2)**(S(1)/3)*c**(S(1)/3)*x/(b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + S(1))/S(3))/(S(3)*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3)*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(a + b*x**S(3) + c*x**S(6)), x), x, -S(2)**(S(2)/3)*c**(S(2)/3)*log(S(2)**(S(1)/3)*c**(S(1)/3)*x + (b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3))/(S(3)*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)*sqrt(-S(4)*a*c + b**S(2))) + S(2)**(S(2)/3)*c**(S(2)/3)*log(S(2)**(S(2)/3)*c**(S(2)/3)*x**S(2) - S(2)**(S(1)/3)*c**(S(1)/3)*x*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + (b + sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3))/(S(6)*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)*sqrt(-S(4)*a*c + b**S(2))) + S(2)**(S(2)/3)*sqrt(S(3))*c**(S(2)/3)*atan(sqrt(S(3))*(-S(2)*S(2)**(S(1)/3)*c**(S(1)/3)*x/(b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + S(1))/S(3))/(S(3)*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)*sqrt(-S(4)*a*c + b**S(2))) + S(2)**(S(2)/3)*c**(S(2)/3)*log(S(2)**(S(1)/3)*c**(S(1)/3)*x + (b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3))/(S(3)*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)*sqrt(-S(4)*a*c + b**S(2))) - S(2)**(S(2)/3)*c**(S(2)/3)*log(S(2)**(S(2)/3)*c**(S(2)/3)*x**S(2) - S(2)**(S(1)/3)*c**(S(1)/3)*x*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + (b - sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3))/(S(6)*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)*sqrt(-S(4)*a*c + b**S(2))) - S(2)**(S(2)/3)*sqrt(S(3))*c**(S(2)/3)*atan(sqrt(S(3))*(-S(2)*S(2)**(S(1)/3)*c**(S(1)/3)*x/(b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + S(1))/S(3))/(S(3)*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*(a + b*x**S(3) + c*x**S(6))), x), x, S(2)**(S(1)/3)*c**(S(1)/3)*(-b/sqrt(-S(4)*a*c + b**S(2)) + S(1))*log(S(2)**(S(1)/3)*c**(S(1)/3)*x + (b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3))/(S(6)*a*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3)) - S(2)**(S(1)/3)*c**(S(1)/3)*(-b/sqrt(-S(4)*a*c + b**S(2)) + S(1))*log(S(2)**(S(2)/3)*c**(S(2)/3)*x**S(2) - S(2)**(S(1)/3)*c**(S(1)/3)*x*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + (b + sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3))/(S(12)*a*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3)) + S(2)**(S(1)/3)*sqrt(S(3))*c**(S(1)/3)*(-b/sqrt(-S(4)*a*c + b**S(2)) + S(1))*atan(sqrt(S(3))*(-S(2)*S(2)**(S(1)/3)*c**(S(1)/3)*x/(b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + S(1))/S(3))/(S(6)*a*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3)) + S(2)**(S(1)/3)*c**(S(1)/3)*(b/sqrt(-S(4)*a*c + b**S(2)) + S(1))*log(S(2)**(S(1)/3)*c**(S(1)/3)*x + (b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3))/(S(6)*a*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3)) - S(2)**(S(1)/3)*c**(S(1)/3)*(b/sqrt(-S(4)*a*c + b**S(2)) + S(1))*log(S(2)**(S(2)/3)*c**(S(2)/3)*x**S(2) - S(2)**(S(1)/3)*c**(S(1)/3)*x*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + (b - sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3))/(S(12)*a*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3)) + S(2)**(S(1)/3)*sqrt(S(3))*c**(S(1)/3)*(b/sqrt(-S(4)*a*c + b**S(2)) + S(1))*atan(sqrt(S(3))*(-S(2)*S(2)**(S(1)/3)*c**(S(1)/3)*x/(b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + S(1))/S(3))/(S(6)*a*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3)) - S(1)/(a*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(3)*(a + b*x**S(3) + c*x**S(6))), x), x, -S(2)**(S(2)/3)*c**(S(2)/3)*(-b/sqrt(-S(4)*a*c + b**S(2)) + S(1))*log(S(2)**(S(1)/3)*c**(S(1)/3)*x + (b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3))/(S(6)*a*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)) + S(2)**(S(2)/3)*c**(S(2)/3)*(-b/sqrt(-S(4)*a*c + b**S(2)) + S(1))*log(S(2)**(S(2)/3)*c**(S(2)/3)*x**S(2) - S(2)**(S(1)/3)*c**(S(1)/3)*x*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + (b + sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3))/(S(12)*a*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)) + S(2)**(S(2)/3)*sqrt(S(3))*c**(S(2)/3)*(-b/sqrt(-S(4)*a*c + b**S(2)) + S(1))*atan(sqrt(S(3))*(-S(2)*S(2)**(S(1)/3)*c**(S(1)/3)*x/(b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + S(1))/S(3))/(S(6)*a*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)) - S(2)**(S(2)/3)*c**(S(2)/3)*(b/sqrt(-S(4)*a*c + b**S(2)) + S(1))*log(S(2)**(S(1)/3)*c**(S(1)/3)*x + (b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3))/(S(6)*a*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)) + S(2)**(S(2)/3)*c**(S(2)/3)*(b/sqrt(-S(4)*a*c + b**S(2)) + S(1))*log(S(2)**(S(2)/3)*c**(S(2)/3)*x**S(2) - S(2)**(S(1)/3)*c**(S(1)/3)*x*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + (b - sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3))/(S(12)*a*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)) + S(2)**(S(2)/3)*sqrt(S(3))*c**(S(2)/3)*(b/sqrt(-S(4)*a*c + b**S(2)) + S(1))*atan(sqrt(S(3))*(-S(2)*S(2)**(S(1)/3)*c**(S(1)/3)*x/(b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + S(1))/S(3))/(S(6)*a*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)) - S(1)/(S(2)*a*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(11)/(x**S(6) + S(4)*x**S(3) + S(3)), x), x, x**S(6)/S(6) - S(4)*x**S(3)/S(3) - log(x**S(3) + S(1))/S(6) + S(9)*log(x**S(3) + S(3))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(8)/(x**S(6) + S(4)*x**S(3) + S(3)), x), x, x**S(3)/S(3) + log(x**S(3) + S(1))/S(6) - S(3)*log(x**S(3) + S(3))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)/(x**S(6) + S(4)*x**S(3) + S(3)), x), x, -log(x**S(3) + S(1))/S(6) + log(x**S(3) + S(3))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/(x**S(6) + S(4)*x**S(3) + S(3)), x), x, -atanh(x**S(3) + S(2))/S(3), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate(x**S(2)/(x**S(6) + S(4)*x**S(3) + S(3)), x), x, log(x**S(3) + S(1))/S(6) - log(x**S(3) + S(3))/S(6), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*(x**S(6) + S(4)*x**S(3) + S(3))), x), x, log(x)/S(3) - log(x**S(3) + S(1))/S(6) + log(x**S(3) + S(3))/S(18), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(4)*(x**S(6) + S(4)*x**S(3) + S(3))), x), x, -S(4)*log(x)/S(9) + log(x**S(3) + S(1))/S(6) - log(x**S(3) + S(3))/S(54) - S(1)/(S(9)*x**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(7)*(x**S(6) + S(4)*x**S(3) + S(3))), x), x, S(13)*log(x)/S(27) - log(x**S(3) + S(1))/S(6) + log(x**S(3) + S(3))/S(162) + S(4)/(S(27)*x**S(3)) - S(1)/(S(18)*x**S(6)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(10)/(x**S(6) + S(4)*x**S(3) + S(3)), x), x, x**S(5)/S(5) - S(2)*x**S(2) + log(x + S(1))/S(6) - S(3)*S(3)**(S(2)/3)*log(x + S(3)**(S(1)/3))/S(2) - log(x**S(2) - x + S(1))/S(12) + S(3)*S(3)**(S(2)/3)*log(x**S(2) - S(3)**(S(1)/3)*x + S(3)**(S(2)/3))/S(4) - S(9)*S(3)**(S(1)/6)*atan(S(3)**(S(1)/6)*(-S(2)*x + S(3)**(S(1)/3))/S(3))/S(2) + sqrt(S(3))*atan(sqrt(S(3))*(-S(2)*x + S(1))/S(3))/S(6), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(9)/(x**S(6) + S(4)*x**S(3) + S(3)), x), x, x**S(4)/S(4) - S(4)*x - log(x + S(1))/S(6) + S(3)*S(3)**(S(1)/3)*log(x + S(3)**(S(1)/3))/S(2) + log(x**S(2) - x + S(1))/S(12) - S(3)*S(3)**(S(1)/3)*log(x**S(2) - S(3)**(S(1)/3)*x + S(3)**(S(2)/3))/S(4) - S(3)*S(3)**(S(5)/6)*atan(S(3)**(S(1)/6)*(-S(2)*x + S(3)**(S(1)/3))/S(3))/S(2) + sqrt(S(3))*atan(sqrt(S(3))*(-S(2)*x + S(1))/S(3))/S(6), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(7)/(x**S(6) + S(4)*x**S(3) + S(3)), x), x, x**S(2)/S(2) - log(x + S(1))/S(6) + S(3)**(S(2)/3)*log(x + S(3)**(S(1)/3))/S(2) + log(x**S(2) - x + S(1))/S(12) - S(3)**(S(2)/3)*log(x**S(2) - S(3)**(S(1)/3)*x + S(3)**(S(2)/3))/S(4) + S(3)*S(3)**(S(1)/6)*atan(S(3)**(S(1)/6)*(-S(2)*x + S(3)**(S(1)/3))/S(3))/S(2) - sqrt(S(3))*atan(sqrt(S(3))*(-S(2)*x + S(1))/S(3))/S(6), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(6)/(x**S(6) + S(4)*x**S(3) + S(3)), x), x, x + log(x + S(1))/S(6) - S(3)**(S(1)/3)*log(x + S(3)**(S(1)/3))/S(2) - log(x**S(2) - x + S(1))/S(12) + S(3)**(S(1)/3)*log(x**S(2) - S(3)**(S(1)/3)*x + S(3)**(S(2)/3))/S(4) + S(3)**(S(5)/6)*atan(S(3)**(S(1)/6)*(-S(2)*x + S(3)**(S(1)/3))/S(3))/S(2) - sqrt(S(3))*atan(sqrt(S(3))*(-S(2)*x + S(1))/S(3))/S(6), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)/(x**S(6) + S(4)*x**S(3) + S(3)), x), x, log(x + S(1))/S(6) - S(3)**(S(2)/3)*log(x + S(3)**(S(1)/3))/S(6) - log(x**S(2) - x + S(1))/S(12) + S(3)**(S(2)/3)*log(x**S(2) - S(3)**(S(1)/3)*x + S(3)**(S(2)/3))/S(12) - S(3)**(S(1)/6)*atan(S(3)**(S(1)/6)*(-S(2)*x + S(3)**(S(1)/3))/S(3))/S(2) + sqrt(S(3))*atan(sqrt(S(3))*(-S(2)*x + S(1))/S(3))/S(6), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/(x**S(6) + S(4)*x**S(3) + S(3)), x), x, -log(x + S(1))/S(6) + S(3)**(S(1)/3)*log(x + S(3)**(S(1)/3))/S(6) + log(x**S(2) - x + S(1))/S(12) - S(3)**(S(1)/3)*log(x**S(2) - S(3)**(S(1)/3)*x + S(3)**(S(2)/3))/S(12) - S(3)**(S(5)/6)*atan(S(3)**(S(1)/6)*(-S(2)*x + S(3)**(S(1)/3))/S(3))/S(6) + sqrt(S(3))*atan(sqrt(S(3))*(-S(2)*x + S(1))/S(3))/S(6), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(x**S(6) + S(4)*x**S(3) + S(3)), x), x, -log(x + S(1))/S(6) + S(3)**(S(2)/3)*log(x + S(3)**(S(1)/3))/S(18) + log(x**S(2) - x + S(1))/S(12) - S(3)**(S(2)/3)*log(x**S(2) - S(3)**(S(1)/3)*x + S(3)**(S(2)/3))/S(36) + S(3)**(S(1)/6)*atan(S(3)**(S(1)/6)*(-S(2)*x + S(3)**(S(1)/3))/S(3))/S(6) - sqrt(S(3))*atan(sqrt(S(3))*(-S(2)*x + S(1))/S(3))/S(6), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(6) + S(4)*x**S(3) + S(3)), x), x, log(x + S(1))/S(6) - S(3)**(S(1)/3)*log(x + S(3)**(S(1)/3))/S(18) - log(x**S(2) - x + S(1))/S(12) + S(3)**(S(1)/3)*log(x**S(2) - S(3)**(S(1)/3)*x + S(3)**(S(2)/3))/S(36) + S(3)**(S(5)/6)*atan(S(3)**(S(1)/6)*(-S(2)*x + S(3)**(S(1)/3))/S(3))/S(18) - sqrt(S(3))*atan(sqrt(S(3))*(-S(2)*x + S(1))/S(3))/S(6), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*(x**S(6) + S(4)*x**S(3) + S(3))), x), x, log(x + S(1))/S(6) - S(3)**(S(2)/3)*log(x + S(3)**(S(1)/3))/S(54) - log(x**S(2) - x + S(1))/S(12) + S(3)**(S(2)/3)*log(x**S(2) - S(3)**(S(1)/3)*x + S(3)**(S(2)/3))/S(108) - S(3)**(S(1)/6)*atan(S(3)**(S(1)/6)*(-S(2)*x + S(3)**(S(1)/3))/S(3))/S(18) + sqrt(S(3))*atan(sqrt(S(3))*(-S(2)*x + S(1))/S(3))/S(6) - S(1)/(S(3)*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(3)*(x**S(6) + S(4)*x**S(3) + S(3))), x), x, -log(x + S(1))/S(6) + S(3)**(S(1)/3)*log(x + S(3)**(S(1)/3))/S(54) + log(x**S(2) - x + S(1))/S(12) - S(3)**(S(1)/3)*log(x**S(2) - S(3)**(S(1)/3)*x + S(3)**(S(2)/3))/S(108) - S(3)**(S(5)/6)*atan(S(3)**(S(1)/6)*(-S(2)*x + S(3)**(S(1)/3))/S(3))/S(54) + sqrt(S(3))*atan(sqrt(S(3))*(-S(2)*x + S(1))/S(3))/S(6) - S(1)/(S(6)*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(5)*(x**S(6) + S(4)*x**S(3) + S(3))), x), x, -log(x + S(1))/S(6) + S(3)**(S(2)/3)*log(x + S(3)**(S(1)/3))/S(162) + log(x**S(2) - x + S(1))/S(12) - S(3)**(S(2)/3)*log(x**S(2) - S(3)**(S(1)/3)*x + S(3)**(S(2)/3))/S(324) + S(3)**(S(1)/6)*atan(S(3)**(S(1)/6)*(-S(2)*x + S(3)**(S(1)/3))/S(3))/S(54) - sqrt(S(3))*atan(sqrt(S(3))*(-S(2)*x + S(1))/S(3))/S(6) + S(4)/(S(9)*x) - S(1)/(S(12)*x**S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(6)*(x**S(6) + S(4)*x**S(3) + S(3))), x), x, log(x + S(1))/S(6) - S(3)**(S(1)/3)*log(x + S(3)**(S(1)/3))/S(162) - log(x**S(2) - x + S(1))/S(12) + S(3)**(S(1)/3)*log(x**S(2) - S(3)**(S(1)/3)*x + S(3)**(S(2)/3))/S(324) + S(3)**(S(5)/6)*atan(S(3)**(S(1)/6)*(-S(2)*x + S(3)**(S(1)/3))/S(3))/S(162) - sqrt(S(3))*atan(sqrt(S(3))*(-S(2)*x + S(1))/S(3))/S(6) + S(2)/(S(9)*x**S(2)) - S(1)/(S(15)*x**S(5)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(6)/(x**S(6) - x**S(3) + S(1)), x), x, x + S(2)**(S(2)/3)*(S(3) - sqrt(S(3))*I)*log(-S(2)**(S(1)/3)*x + (S(1) - sqrt(S(3))*I)**(S(1)/3))/(S(18)*(S(1) - sqrt(S(3))*I)**(S(2)/3)) + S(2)**(S(2)/3)*(S(3) + sqrt(S(3))*I)*log(-S(2)**(S(1)/3)*x + (S(1) + sqrt(S(3))*I)**(S(1)/3))/(S(18)*(S(1) + sqrt(S(3))*I)**(S(2)/3)) - S(2)**(S(2)/3)*(S(3) - sqrt(S(3))*I)*log(S(2)**(S(2)/3)*x**S(2) + x*(S(2) - S(2)*sqrt(S(3))*I)**(S(1)/3) + (S(1) - sqrt(S(3))*I)**(S(2)/3))/(S(36)*(S(1) - sqrt(S(3))*I)**(S(2)/3)) - S(2)**(S(2)/3)*(S(3) + sqrt(S(3))*I)*log(S(2)**(S(2)/3)*x**S(2) + x*(S(2) + S(2)*sqrt(S(3))*I)**(S(1)/3) + (S(1) + sqrt(S(3))*I)**(S(2)/3))/(S(36)*(S(1) + sqrt(S(3))*I)**(S(2)/3)) + S(2)**(S(2)/3)*(-sqrt(S(3)) + I)*atan(sqrt(S(3))*(S(2)*x/(S(1)/2 - sqrt(S(3))*I/S(2))**(S(1)/3) + S(1))/S(3))/(S(6)*(S(1) - sqrt(S(3))*I)**(S(2)/3)) - S(2)**(S(2)/3)*(sqrt(S(3)) + I)*atan(sqrt(S(3))*(S(2)*x/(S(1)/2 + sqrt(S(3))*I/S(2))**(S(1)/3) + S(1))/S(3))/(S(6)*(S(1) + sqrt(S(3))*I)**(S(2)/3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)/(x**S(6) - x**S(3) + S(1)), x), x, log(x**S(6) - x**S(3) + S(1))/S(6) - sqrt(S(3))*atan(sqrt(S(3))*(-S(2)*x**S(3) + S(1))/S(3))/S(9), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)/(x**S(6) - x**S(3) + S(1)), x), x, S(2)**(S(1)/3)*(S(3) + sqrt(S(3))*I)*log(-S(2)**(S(1)/3)*x + (S(1) - sqrt(S(3))*I)**(S(1)/3))/(S(18)*(S(1) - sqrt(S(3))*I)**(S(1)/3)) + S(2)**(S(1)/3)*(S(3) - sqrt(S(3))*I)*log(-S(2)**(S(1)/3)*x + (S(1) + sqrt(S(3))*I)**(S(1)/3))/(S(18)*(S(1) + sqrt(S(3))*I)**(S(1)/3)) - S(2)**(S(1)/3)*(S(3) + sqrt(S(3))*I)*log(S(2)**(S(2)/3)*x**S(2) + x*(S(2) - S(2)*sqrt(S(3))*I)**(S(1)/3) + (S(1) - sqrt(S(3))*I)**(S(2)/3))/(S(36)*(S(1) - sqrt(S(3))*I)**(S(1)/3)) - S(2)**(S(1)/3)*(S(3) - sqrt(S(3))*I)*log(S(2)**(S(2)/3)*x**S(2) + x*(S(2) + S(2)*sqrt(S(3))*I)**(S(1)/3) + (S(1) + sqrt(S(3))*I)**(S(2)/3))/(S(36)*(S(1) + sqrt(S(3))*I)**(S(1)/3)) + S(2)**(S(1)/3)*(sqrt(S(3)) + I)*atan(sqrt(S(3))*(S(2)*x/(S(1)/2 - sqrt(S(3))*I/S(2))**(S(1)/3) + S(1))/S(3))/(S(6)*(S(1) - sqrt(S(3))*I)**(S(1)/3)) - S(2)**(S(1)/3)*(-sqrt(S(3)) + I)*atan(sqrt(S(3))*(S(2)*x/(S(1)/2 + sqrt(S(3))*I/S(2))**(S(1)/3) + S(1))/S(3))/(S(6)*(S(1) + sqrt(S(3))*I)**(S(1)/3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/(x**S(6) - x**S(3) + S(1)), x), x, S(2)**(S(2)/3)*(S(3) + sqrt(S(3))*I)*log(-S(2)**(S(1)/3)*x + (S(1) - sqrt(S(3))*I)**(S(1)/3))/(S(18)*(S(1) - sqrt(S(3))*I)**(S(2)/3)) + S(2)**(S(2)/3)*(S(3) - sqrt(S(3))*I)*log(-S(2)**(S(1)/3)*x + (S(1) + sqrt(S(3))*I)**(S(1)/3))/(S(18)*(S(1) + sqrt(S(3))*I)**(S(2)/3)) - S(2)**(S(2)/3)*(S(3) + sqrt(S(3))*I)*log(S(2)**(S(2)/3)*x**S(2) + x*(S(2) - S(2)*sqrt(S(3))*I)**(S(1)/3) + (S(1) - sqrt(S(3))*I)**(S(2)/3))/(S(36)*(S(1) - sqrt(S(3))*I)**(S(2)/3)) - S(2)**(S(2)/3)*(S(3) - sqrt(S(3))*I)*log(S(2)**(S(2)/3)*x**S(2) + x*(S(2) + S(2)*sqrt(S(3))*I)**(S(1)/3) + (S(1) + sqrt(S(3))*I)**(S(2)/3))/(S(36)*(S(1) + sqrt(S(3))*I)**(S(2)/3)) - S(2)**(S(2)/3)*(sqrt(S(3)) + I)*atan(sqrt(S(3))*(S(2)*x/(S(1)/2 - sqrt(S(3))*I/S(2))**(S(1)/3) + S(1))/S(3))/(S(6)*(S(1) - sqrt(S(3))*I)**(S(2)/3)) + S(2)**(S(2)/3)*(-sqrt(S(3)) + I)*atan(sqrt(S(3))*(S(2)*x/(S(1)/2 + sqrt(S(3))*I/S(2))**(S(1)/3) + S(1))/S(3))/(S(6)*(S(1) + sqrt(S(3))*I)**(S(2)/3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/(x**S(6) - x**S(3) + S(1)), x), x, -S(2)*sqrt(S(3))*atan(sqrt(S(3))*(-S(2)*x**S(3) + S(1))/S(3))/S(9), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(x**S(6) - x**S(3) + S(1)), x), x, sqrt(S(3))*I*log(-S(2)**(S(1)/3)*x + (S(1) - sqrt(S(3))*I)**(S(1)/3))/(S(9)*(S(1)/2 - sqrt(S(3))*I/S(2))**(S(1)/3)) - sqrt(S(3))*I*log(-S(2)**(S(1)/3)*x + (S(1) + sqrt(S(3))*I)**(S(1)/3))/(S(9)*(S(1)/2 + sqrt(S(3))*I/S(2))**(S(1)/3)) - S(2)**(S(1)/3)*sqrt(S(3))*I*log(S(2)**(S(2)/3)*x**S(2) + x*(S(2) - S(2)*sqrt(S(3))*I)**(S(1)/3) + (S(1) - sqrt(S(3))*I)**(S(2)/3))/(S(18)*(S(1) - sqrt(S(3))*I)**(S(1)/3)) + S(2)**(S(1)/3)*sqrt(S(3))*I*log(S(2)**(S(2)/3)*x**S(2) + x*(S(2) + S(2)*sqrt(S(3))*I)**(S(1)/3) + (S(1) + sqrt(S(3))*I)**(S(2)/3))/(S(18)*(S(1) + sqrt(S(3))*I)**(S(1)/3)) + I*atan(sqrt(S(3))*(S(2)*x/(S(1)/2 - sqrt(S(3))*I/S(2))**(S(1)/3) + S(1))/S(3))/(S(3)*(S(1)/2 - sqrt(S(3))*I/S(2))**(S(1)/3)) - I*atan(sqrt(S(3))*(S(2)*x/(S(1)/2 + sqrt(S(3))*I/S(2))**(S(1)/3) + S(1))/S(3))/(S(3)*(S(1)/2 + sqrt(S(3))*I/S(2))**(S(1)/3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(6) - x**S(3) + S(1)), x), x, -(S(-1))**(S(5)/18)*sqrt(S(3))*(S(3)*log(-x + (S(-1))**(S(1)/9)) + log(S(2)))/S(27) + (S(-1))**(S(13)/18)*sqrt(S(3))*log(-S(2)**(S(1)/3)*(x + (S(-1))**(S(8)/9)))/S(9) - (S(-1))**(S(13)/18)*sqrt(S(3))*log(-S(2)**(S(2)/3)*(x*(-x + (S(-1))**(S(8)/9)) + (S(-1))**(S(7)/9)))/S(18) + (S(-1))**(S(5)/18)*sqrt(S(3))*log(S(2)**(S(2)/3)*(x*(x + (S(-1))**(S(1)/9)) + (S(-1))**(S(2)/9)))/S(18) - (S(-1))**(S(13)/18)*atan(sqrt(S(3))*(S(2)*(S(-1))**(S(1)/9)*x + S(1))/S(3))/S(3) + (S(-1))**(S(5)/18)*atan(sqrt(S(3))*(-S(2)*(S(-1))**(S(8)/9)*x + S(1))/S(3))/S(3), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate(S(1)/(x**S(6) - x**S(3) + S(1)), x), x, sqrt(S(3))*I*log(-S(2)**(S(1)/3)*x + (S(1) - sqrt(S(3))*I)**(S(1)/3))/(S(9)*(S(1)/2 - sqrt(S(3))*I/S(2))**(S(2)/3)) - sqrt(S(3))*I*log(-S(2)**(S(1)/3)*x + (S(1) + sqrt(S(3))*I)**(S(1)/3))/(S(9)*(S(1)/2 + sqrt(S(3))*I/S(2))**(S(2)/3)) - S(2)**(S(2)/3)*sqrt(S(3))*I*log(S(2)**(S(2)/3)*x**S(2) + x*(S(2) - S(2)*sqrt(S(3))*I)**(S(1)/3) + (S(1) - sqrt(S(3))*I)**(S(2)/3))/(S(18)*(S(1) - sqrt(S(3))*I)**(S(2)/3)) + S(2)**(S(2)/3)*sqrt(S(3))*I*log(S(2)**(S(2)/3)*x**S(2) + x*(S(2) + S(2)*sqrt(S(3))*I)**(S(1)/3) + (S(1) + sqrt(S(3))*I)**(S(2)/3))/(S(18)*(S(1) + sqrt(S(3))*I)**(S(2)/3)) - I*atan(sqrt(S(3))*(S(2)*x/(S(1)/2 - sqrt(S(3))*I/S(2))**(S(1)/3) + S(1))/S(3))/(S(3)*(S(1)/2 - sqrt(S(3))*I/S(2))**(S(2)/3)) + I*atan(sqrt(S(3))*(S(2)*x/(S(1)/2 + sqrt(S(3))*I/S(2))**(S(1)/3) + S(1))/S(3))/(S(3)*(S(1)/2 + sqrt(S(3))*I/S(2))**(S(2)/3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*(x**S(6) - x**S(3) + S(1))), x), x, log(x) - log(x**S(6) - x**S(3) + S(1))/S(6) - sqrt(S(3))*atan(sqrt(S(3))*(-S(2)*x**S(3) + S(1))/S(3))/S(9), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*(x**S(6) - x**S(3) + S(1))), x), x, -S(2)**(S(1)/3)*(S(3) - sqrt(S(3))*I)*log(-S(2)**(S(1)/3)*x + (S(1) - sqrt(S(3))*I)**(S(1)/3))/(S(18)*(S(1) - sqrt(S(3))*I)**(S(1)/3)) - S(2)**(S(1)/3)*(S(3) + sqrt(S(3))*I)*log(-S(2)**(S(1)/3)*x + (S(1) + sqrt(S(3))*I)**(S(1)/3))/(S(18)*(S(1) + sqrt(S(3))*I)**(S(1)/3)) + S(2)**(S(1)/3)*(S(3) - sqrt(S(3))*I)*log(S(2)**(S(2)/3)*x**S(2) + x*(S(2) - S(2)*sqrt(S(3))*I)**(S(1)/3) + (S(1) - sqrt(S(3))*I)**(S(2)/3))/(S(36)*(S(1) - sqrt(S(3))*I)**(S(1)/3)) + S(2)**(S(1)/3)*(S(3) + sqrt(S(3))*I)*log(S(2)**(S(2)/3)*x**S(2) + x*(S(2) + S(2)*sqrt(S(3))*I)**(S(1)/3) + (S(1) + sqrt(S(3))*I)**(S(2)/3))/(S(36)*(S(1) + sqrt(S(3))*I)**(S(1)/3)) + S(2)**(S(1)/3)*(-sqrt(S(3)) + I)*atan(sqrt(S(3))*(S(2)*x/(S(1)/2 - sqrt(S(3))*I/S(2))**(S(1)/3) + S(1))/S(3))/(S(6)*(S(1) - sqrt(S(3))*I)**(S(1)/3)) - S(2)**(S(1)/3)*(sqrt(S(3)) + I)*atan(sqrt(S(3))*(S(2)*x/(S(1)/2 + sqrt(S(3))*I/S(2))**(S(1)/3) + S(1))/S(3))/(S(6)*(S(1) + sqrt(S(3))*I)**(S(1)/3)) - S(1)/x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(3)*(x**S(6) - x**S(3) + S(1))), x), x, -S(2)**(S(2)/3)*(S(3) - sqrt(S(3))*I)*log(-S(2)**(S(1)/3)*x + (S(1) - sqrt(S(3))*I)**(S(1)/3))/(S(18)*(S(1) - sqrt(S(3))*I)**(S(2)/3)) - S(2)**(S(2)/3)*(S(3) + sqrt(S(3))*I)*log(-S(2)**(S(1)/3)*x + (S(1) + sqrt(S(3))*I)**(S(1)/3))/(S(18)*(S(1) + sqrt(S(3))*I)**(S(2)/3)) + S(2)**(S(2)/3)*(S(3) - sqrt(S(3))*I)*log(S(2)**(S(2)/3)*x**S(2) + x*(S(2) - S(2)*sqrt(S(3))*I)**(S(1)/3) + (S(1) - sqrt(S(3))*I)**(S(2)/3))/(S(36)*(S(1) - sqrt(S(3))*I)**(S(2)/3)) + S(2)**(S(2)/3)*(S(3) + sqrt(S(3))*I)*log(S(2)**(S(2)/3)*x**S(2) + x*(S(2) + S(2)*sqrt(S(3))*I)**(S(1)/3) + (S(1) + sqrt(S(3))*I)**(S(2)/3))/(S(36)*(S(1) + sqrt(S(3))*I)**(S(2)/3)) - S(2)**(S(2)/3)*(-sqrt(S(3)) + I)*atan(sqrt(S(3))*(S(2)*x/(S(1)/2 - sqrt(S(3))*I/S(2))**(S(1)/3) + S(1))/S(3))/(S(6)*(S(1) - sqrt(S(3))*I)**(S(2)/3)) + S(2)**(S(2)/3)*(sqrt(S(3)) + I)*atan(sqrt(S(3))*(S(2)*x/(S(1)/2 + sqrt(S(3))*I/S(2))**(S(1)/3) + S(1))/S(3))/(S(6)*(S(1) + sqrt(S(3))*I)**(S(2)/3)) - S(1)/(S(2)*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(4)*(x**S(6) - x**S(3) + S(1))), x), x, log(x) - log(x**S(6) - x**S(3) + S(1))/S(6) + sqrt(S(3))*atan(sqrt(S(3))*(-S(2)*x**S(3) + S(1))/S(3))/S(9) - S(1)/(S(3)*x**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(5)*(x**S(6) - x**S(3) + S(1))), x), x, -S(2)**(S(1)/3)*(S(3) + sqrt(S(3))*I)*log(-S(2)**(S(1)/3)*x + (S(1) - sqrt(S(3))*I)**(S(1)/3))/(S(18)*(S(1) - sqrt(S(3))*I)**(S(1)/3)) - S(2)**(S(1)/3)*(S(3) - sqrt(S(3))*I)*log(-S(2)**(S(1)/3)*x + (S(1) + sqrt(S(3))*I)**(S(1)/3))/(S(18)*(S(1) + sqrt(S(3))*I)**(S(1)/3)) + S(2)**(S(1)/3)*(S(3) + sqrt(S(3))*I)*log(S(2)**(S(2)/3)*x**S(2) + x*(S(2) - S(2)*sqrt(S(3))*I)**(S(1)/3) + (S(1) - sqrt(S(3))*I)**(S(2)/3))/(S(36)*(S(1) - sqrt(S(3))*I)**(S(1)/3)) + S(2)**(S(1)/3)*(S(3) - sqrt(S(3))*I)*log(S(2)**(S(2)/3)*x**S(2) + x*(S(2) + S(2)*sqrt(S(3))*I)**(S(1)/3) + (S(1) + sqrt(S(3))*I)**(S(2)/3))/(S(36)*(S(1) + sqrt(S(3))*I)**(S(1)/3)) - S(2)**(S(1)/3)*(sqrt(S(3)) + I)*atan(sqrt(S(3))*(S(2)*x/(S(1)/2 - sqrt(S(3))*I/S(2))**(S(1)/3) + S(1))/S(3))/(S(6)*(S(1) - sqrt(S(3))*I)**(S(1)/3)) + S(2)**(S(1)/3)*(-sqrt(S(3)) + I)*atan(sqrt(S(3))*(S(2)*x/(S(1)/2 + sqrt(S(3))*I/S(2))**(S(1)/3) + S(1))/S(3))/(S(6)*(S(1) + sqrt(S(3))*I)**(S(1)/3)) - S(1)/x - S(1)/(S(4)*x**S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(6) + x**S(3) + S(2)), x), x, -sqrt(S(7))*I*log(S(2)**(S(1)/3)*x + (S(1) - sqrt(S(7))*I)**(S(1)/3))/(S(21)*(S(1)/2 - sqrt(S(7))*I/S(2))**(S(2)/3)) + sqrt(S(7))*I*log(S(2)**(S(1)/3)*x + (S(1) + sqrt(S(7))*I)**(S(1)/3))/(S(21)*(S(1)/2 + sqrt(S(7))*I/S(2))**(S(2)/3)) + S(2)**(S(2)/3)*sqrt(S(7))*I*log(S(2)**(S(2)/3)*x**S(2) - x*(S(2) - S(2)*sqrt(S(7))*I)**(S(1)/3) + (S(1) - sqrt(S(7))*I)**(S(2)/3))/(S(42)*(S(1) - sqrt(S(7))*I)**(S(2)/3)) - S(2)**(S(2)/3)*sqrt(S(7))*I*log(S(2)**(S(2)/3)*x**S(2) - x*(S(2) + S(2)*sqrt(S(7))*I)**(S(1)/3) + (S(1) + sqrt(S(7))*I)**(S(2)/3))/(S(42)*(S(1) + sqrt(S(7))*I)**(S(2)/3)) + sqrt(S(21))*I*atan(sqrt(S(3))*(-S(2)*x/(S(1)/2 - sqrt(S(7))*I/S(2))**(S(1)/3) + S(1))/S(3))/(S(21)*(S(1)/2 - sqrt(S(7))*I/S(2))**(S(2)/3)) - sqrt(S(21))*I*atan(sqrt(S(3))*(-S(2)*x/(S(1)/2 + sqrt(S(7))*I/S(2))**(S(1)/3) + S(1))/S(3))/(S(21)*(S(1)/2 + sqrt(S(7))*I/S(2))**(S(2)/3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/(x**S(6) + x**S(3) + S(2)), x), x, S(2)*sqrt(S(7))*atan(sqrt(S(7))*(S(2)*x**S(3) + S(1))/S(7))/S(21), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/(x**S(6) + x**S(3) + S(2)), x), x, S(2)**(S(2)/3)*(S(7) + sqrt(S(7))*I)*log(S(2)**(S(1)/3)*x + (S(1) - sqrt(S(7))*I)**(S(1)/3))/(S(42)*(S(1) - sqrt(S(7))*I)**(S(2)/3)) + S(2)**(S(2)/3)*(S(7) - sqrt(S(7))*I)*log(S(2)**(S(1)/3)*x + (S(1) + sqrt(S(7))*I)**(S(1)/3))/(S(42)*(S(1) + sqrt(S(7))*I)**(S(2)/3)) - S(2)**(S(2)/3)*(S(7) + sqrt(S(7))*I)*log(S(2)**(S(2)/3)*x**S(2) - x*(S(2) - S(2)*sqrt(S(7))*I)**(S(1)/3) + (S(1) - sqrt(S(7))*I)**(S(2)/3))/(S(84)*(S(1) - sqrt(S(7))*I)**(S(2)/3)) - S(2)**(S(2)/3)*(S(7) - sqrt(S(7))*I)*log(S(2)**(S(2)/3)*x**S(2) - x*(S(2) + S(2)*sqrt(S(7))*I)**(S(1)/3) + (S(1) + sqrt(S(7))*I)**(S(2)/3))/(S(84)*(S(1) + sqrt(S(7))*I)**(S(2)/3)) - sqrt(S(21))*I*(S(1)/2 - sqrt(S(7))*I/S(2))**(S(1)/3)*atan(sqrt(S(3))*(-S(2)*x/(S(1)/2 - sqrt(S(7))*I/S(2))**(S(1)/3) + S(1))/S(3))/S(21) + sqrt(S(21))*I*(S(1)/2 + sqrt(S(7))*I/S(2))**(S(1)/3)*atan(sqrt(S(3))*(-S(2)*x/(S(1)/2 + sqrt(S(7))*I/S(2))**(S(1)/3) + S(1))/S(3))/S(21), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(14)*sqrt(a + b*x**S(3) + c*x**S(6)), x), x, -b*x**S(6)*(a + b*x**S(3) + c*x**S(6))**(S(3)/2)/(S(20)*c**S(2)) + x**S(9)*(a + b*x**S(3) + c*x**S(6))**(S(3)/2)/(S(18)*c) - (S(7)*b*(-S(28)*a*c + S(15)*b**S(2)) - S(6)*c*x**S(3)*(-S(20)*a*c + S(21)*b**S(2)))*(a + b*x**S(3) + c*x**S(6))**(S(3)/2)/(S(2880)*c**S(4)) + (b + S(2)*c*x**S(3))*sqrt(a + b*x**S(3) + c*x**S(6))*(S(16)*a**S(2)*c**S(2) - S(56)*a*b**S(2)*c + S(21)*b**S(4))/(S(1536)*c**S(5)) - (-S(4)*a*c + b**S(2))*(S(16)*a**S(2)*c**S(2) - S(56)*a*b**S(2)*c + S(21)*b**S(4))*atanh((b + S(2)*c*x**S(3))/(S(2)*sqrt(c)*sqrt(a + b*x**S(3) + c*x**S(6))))/(S(3072)*c**(S(11)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(11)*sqrt(a + b*x**S(3) + c*x**S(6)), x), x, -b*(b + S(2)*c*x**S(3))*(-S(12)*a*c + S(7)*b**S(2))*sqrt(a + b*x**S(3) + c*x**S(6))/(S(384)*c**S(4)) + b*(-S(12)*a*c + S(7)*b**S(2))*(-S(4)*a*c + b**S(2))*atanh((b + S(2)*c*x**S(3))/(S(2)*sqrt(c)*sqrt(a + b*x**S(3) + c*x**S(6))))/(S(768)*c**(S(9)/2)) + x**S(6)*(a + b*x**S(3) + c*x**S(6))**(S(3)/2)/(S(15)*c) + (a + b*x**S(3) + c*x**S(6))**(S(3)/2)*(-S(32)*a*c + S(35)*b**S(2) - S(42)*b*c*x**S(3))/(S(720)*c**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(8)*sqrt(a + b*x**S(3) + c*x**S(6)), x), x, -S(5)*b*(a + b*x**S(3) + c*x**S(6))**(S(3)/2)/(S(72)*c**S(2)) + x**S(3)*(a + b*x**S(3) + c*x**S(6))**(S(3)/2)/(S(12)*c) + (b + S(2)*c*x**S(3))*(-S(4)*a*c + S(5)*b**S(2))*sqrt(a + b*x**S(3) + c*x**S(6))/(S(192)*c**S(3)) - (-S(4)*a*c + b**S(2))*(-S(4)*a*c + S(5)*b**S(2))*atanh((b + S(2)*c*x**S(3))/(S(2)*sqrt(c)*sqrt(a + b*x**S(3) + c*x**S(6))))/(S(384)*c**(S(7)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)*sqrt(a + b*x**S(3) + c*x**S(6)), x), x, -b*(b + S(2)*c*x**S(3))*sqrt(a + b*x**S(3) + c*x**S(6))/(S(24)*c**S(2)) + b*(-S(4)*a*c + b**S(2))*atanh((b + S(2)*c*x**S(3))/(S(2)*sqrt(c)*sqrt(a + b*x**S(3) + c*x**S(6))))/(S(48)*c**(S(5)/2)) + (a + b*x**S(3) + c*x**S(6))**(S(3)/2)/(S(9)*c), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*sqrt(a + b*x**S(3) + c*x**S(6)), x), x, (b + S(2)*c*x**S(3))*sqrt(a + b*x**S(3) + c*x**S(6))/(S(12)*c) - (-S(4)*a*c + b**S(2))*atanh((b + S(2)*c*x**S(3))/(S(2)*sqrt(c)*sqrt(a + b*x**S(3) + c*x**S(6))))/(S(24)*c**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a + b*x**S(3) + c*x**S(6))/x, x), x, -sqrt(a)*atanh((S(2)*a + b*x**S(3))/(S(2)*sqrt(a)*sqrt(a + b*x**S(3) + c*x**S(6))))/S(3) + b*atanh((b + S(2)*c*x**S(3))/(S(2)*sqrt(c)*sqrt(a + b*x**S(3) + c*x**S(6))))/(S(6)*sqrt(c)) + sqrt(a + b*x**S(3) + c*x**S(6))/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a + b*x**S(3) + c*x**S(6))/x**S(4), x), x, sqrt(c)*atanh((b + S(2)*c*x**S(3))/(S(2)*sqrt(c)*sqrt(a + b*x**S(3) + c*x**S(6))))/S(3) - sqrt(a + b*x**S(3) + c*x**S(6))/(S(3)*x**S(3)) - b*atanh((S(2)*a + b*x**S(3))/(S(2)*sqrt(a)*sqrt(a + b*x**S(3) + c*x**S(6))))/(S(6)*sqrt(a)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a + b*x**S(3) + c*x**S(6))/x**S(7), x), x, -(S(2)*a + b*x**S(3))*sqrt(a + b*x**S(3) + c*x**S(6))/(S(12)*a*x**S(6)) + (-S(4)*a*c + b**S(2))*atanh((S(2)*a + b*x**S(3))/(S(2)*sqrt(a)*sqrt(a + b*x**S(3) + c*x**S(6))))/(S(24)*a**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a + b*x**S(3) + c*x**S(6))/x**S(10), x), x, -(a + b*x**S(3) + c*x**S(6))**(S(3)/2)/(S(9)*a*x**S(9)) + b*(S(2)*a + b*x**S(3))*sqrt(a + b*x**S(3) + c*x**S(6))/(S(24)*a**S(2)*x**S(6)) - b*(-S(4)*a*c + b**S(2))*atanh((S(2)*a + b*x**S(3))/(S(2)*sqrt(a)*sqrt(a + b*x**S(3) + c*x**S(6))))/(S(48)*a**(S(5)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a + b*x**S(3) + c*x**S(6))/x**S(13), x), x, -(a + b*x**S(3) + c*x**S(6))**(S(3)/2)/(S(12)*a*x**S(12)) + S(5)*b*(a + b*x**S(3) + c*x**S(6))**(S(3)/2)/(S(72)*a**S(2)*x**S(9)) - (S(2)*a + b*x**S(3))*(-S(4)*a*c + S(5)*b**S(2))*sqrt(a + b*x**S(3) + c*x**S(6))/(S(192)*a**S(3)*x**S(6)) + (-S(4)*a*c + b**S(2))*(-S(4)*a*c + S(5)*b**S(2))*atanh((S(2)*a + b*x**S(3))/(S(2)*sqrt(a)*sqrt(a + b*x**S(3) + c*x**S(6))))/(S(384)*a**(S(7)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a + b*x**S(3) + c*x**S(6))/x**S(16), x), x, -(a + b*x**S(3) + c*x**S(6))**(S(3)/2)/(S(15)*a*x**S(15)) + S(7)*b*(a + b*x**S(3) + c*x**S(6))**(S(3)/2)/(S(120)*a**S(2)*x**S(12)) - (-S(32)*a*c + S(35)*b**S(2))*(a + b*x**S(3) + c*x**S(6))**(S(3)/2)/(S(720)*a**S(3)*x**S(9)) + b*(S(2)*a + b*x**S(3))*(-S(12)*a*c + S(7)*b**S(2))*sqrt(a + b*x**S(3) + c*x**S(6))/(S(384)*a**S(4)*x**S(6)) - b*(-S(12)*a*c + S(7)*b**S(2))*(-S(4)*a*c + b**S(2))*atanh((S(2)*a + b*x**S(3))/(S(2)*sqrt(a)*sqrt(a + b*x**S(3) + c*x**S(6))))/(S(768)*a**(S(9)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*sqrt(a + b*x**S(3) + c*x**S(6)), x), x, x**S(4)*sqrt(a + b*x**S(3) + c*x**S(6))*AppellF1(S(4)/3, S(-1)/2, S(-1)/2, S(7)/3, -S(2)*c*x**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(4)*sqrt(S(2)*c*x**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*sqrt(a + b*x**S(3) + c*x**S(6)), x), x, x**S(2)*sqrt(a + b*x**S(3) + c*x**S(6))*AppellF1(S(2)/3, S(-1)/2, S(-1)/2, S(5)/3, -S(2)*c*x**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*sqrt(S(2)*c*x**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a + b*x**S(3) + c*x**S(6)), x), x, x*sqrt(a + b*x**S(3) + c*x**S(6))*AppellF1(S(1)/3, S(-1)/2, S(-1)/2, S(4)/3, -S(2)*c*x**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))))/(sqrt(S(2)*c*x**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a + b*x**S(3) + c*x**S(6))/x**S(2), x), x, -sqrt(a + b*x**S(3) + c*x**S(6))*AppellF1(S(-1)/3, S(-1)/2, S(-1)/2, S(2)/3, -S(2)*c*x**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))))/(x*sqrt(S(2)*c*x**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a + b*x**S(3) + c*x**S(6))/x**S(3), x), x, -sqrt(a + b*x**S(3) + c*x**S(6))*AppellF1(S(-2)/3, S(-1)/2, S(-1)/2, S(1)/3, -S(2)*c*x**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*x**S(2)*sqrt(S(2)*c*x**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*(a + b*x**S(3) + c*x**S(6))**(S(3)/2), x), x, a*x**S(4)*sqrt(a + b*x**S(3) + c*x**S(6))*AppellF1(S(4)/3, S(-3)/2, S(-3)/2, S(7)/3, -S(2)*c*x**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(4)*sqrt(S(2)*c*x**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(a + b*x**S(3) + c*x**S(6))**(S(3)/2), x), x, a*x**S(2)*sqrt(a + b*x**S(3) + c*x**S(6))*AppellF1(S(2)/3, S(-3)/2, S(-3)/2, S(5)/3, -S(2)*c*x**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*sqrt(S(2)*c*x**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(3) + c*x**S(6))**(S(3)/2), x), x, a*x*sqrt(a + b*x**S(3) + c*x**S(6))*AppellF1(S(1)/3, S(-3)/2, S(-3)/2, S(4)/3, -S(2)*c*x**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))))/(sqrt(S(2)*c*x**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(3) + c*x**S(6))**(S(3)/2)/x**S(2), x), x, -a*sqrt(a + b*x**S(3) + c*x**S(6))*AppellF1(S(-1)/3, S(-3)/2, S(-3)/2, S(2)/3, -S(2)*c*x**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))))/(x*sqrt(S(2)*c*x**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(3) + c*x**S(6))**(S(3)/2)/x**S(3), x), x, -a*sqrt(a + b*x**S(3) + c*x**S(6))*AppellF1(S(-2)/3, S(-3)/2, S(-3)/2, S(1)/3, -S(2)*c*x**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*x**S(2)*sqrt(S(2)*c*x**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/sqrt(a + b*x**S(3) + c*x**S(6)), x), x, x**S(4)*sqrt(S(2)*c*x**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))*AppellF1(S(4)/3, S(1)/2, S(1)/2, S(7)/3, -S(2)*c*x**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(4)*sqrt(a + b*x**S(3) + c*x**S(6))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/sqrt(a + b*x**S(3) + c*x**S(6)), x), x, x**S(2)*sqrt(S(2)*c*x**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))*AppellF1(S(2)/3, S(1)/2, S(1)/2, S(5)/3, -S(2)*c*x**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*sqrt(a + b*x**S(3) + c*x**S(6))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(a + b*x**S(3) + c*x**S(6)), x), x, x*sqrt(S(2)*c*x**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))*AppellF1(S(1)/3, S(1)/2, S(1)/2, S(4)/3, -S(2)*c*x**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))))/sqrt(a + b*x**S(3) + c*x**S(6)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*sqrt(a + b*x**S(3) + c*x**S(6))), x), x, -sqrt(S(2)*c*x**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))*AppellF1(S(-1)/3, S(1)/2, S(1)/2, S(2)/3, -S(2)*c*x**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))))/(x*sqrt(a + b*x**S(3) + c*x**S(6))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(3)*sqrt(a + b*x**S(3) + c*x**S(6))), x), x, -sqrt(S(2)*c*x**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))*AppellF1(S(-2)/3, S(1)/2, S(1)/2, S(1)/3, -S(2)*c*x**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*x**S(2)*sqrt(a + b*x**S(3) + c*x**S(6))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/(a + b*x**S(3) + c*x**S(6))**(S(3)/2), x), x, x**S(4)*sqrt(S(2)*c*x**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))*AppellF1(S(4)/3, S(3)/2, S(3)/2, S(7)/3, -S(2)*c*x**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(4)*a*sqrt(a + b*x**S(3) + c*x**S(6))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(a + b*x**S(3) + c*x**S(6))**(S(3)/2), x), x, x**S(2)*sqrt(S(2)*c*x**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))*AppellF1(S(2)/3, S(3)/2, S(3)/2, S(5)/3, -S(2)*c*x**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*a*sqrt(a + b*x**S(3) + c*x**S(6))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(3) + c*x**S(6))**(S(-3)/2), x), x, x*sqrt(S(2)*c*x**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))*AppellF1(S(1)/3, S(3)/2, S(3)/2, S(4)/3, -S(2)*c*x**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))))/(a*sqrt(a + b*x**S(3) + c*x**S(6))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*(a + b*x**S(3) + c*x**S(6))**(S(3)/2)), x), x, -sqrt(S(2)*c*x**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))*AppellF1(S(-1)/3, S(3)/2, S(3)/2, S(2)/3, -S(2)*c*x**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))))/(a*x*sqrt(a + b*x**S(3) + c*x**S(6))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(3)*(a + b*x**S(3) + c*x**S(6))**(S(3)/2)), x), x, -sqrt(S(2)*c*x**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))*AppellF1(S(-2)/3, S(3)/2, S(3)/2, S(1)/3, -S(2)*c*x**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*a*x**S(2)*sqrt(a + b*x**S(3) + c*x**S(6))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**m*(a + b*x**S(3) + c*x**S(6))**(S(3)/2), x), x, a*(d*x)**(m + S(1))*sqrt(a + b*x**S(3) + c*x**S(6))*AppellF1(m/S(3) + S(1)/3, S(-3)/2, S(-3)/2, m/S(3) + S(4)/3, -S(2)*c*x**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))))/(d*(m + S(1))*sqrt(S(2)*c*x**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**m*sqrt(a + b*x**S(3) + c*x**S(6)), x), x, (d*x)**(m + S(1))*sqrt(a + b*x**S(3) + c*x**S(6))*AppellF1(m/S(3) + S(1)/3, S(-1)/2, S(-1)/2, m/S(3) + S(4)/3, -S(2)*c*x**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))))/(d*(m + S(1))*sqrt(S(2)*c*x**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**m/sqrt(a + b*x**S(3) + c*x**S(6)), x), x, (d*x)**(m + S(1))*sqrt(S(2)*c*x**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))*AppellF1(m/S(3) + S(1)/3, S(1)/2, S(1)/2, m/S(3) + S(4)/3, -S(2)*c*x**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))))/(d*(m + S(1))*sqrt(a + b*x**S(3) + c*x**S(6))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**m/(a + b*x**S(3) + c*x**S(6))**(S(3)/2), x), x, (d*x)**(m + S(1))*sqrt(S(2)*c*x**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))*AppellF1(m/S(3) + S(1)/3, S(3)/2, S(3)/2, m/S(3) + S(4)/3, -S(2)*c*x**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))))/(a*d*(m + S(1))*sqrt(a + b*x**S(3) + c*x**S(6))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**m*(a + b*x**S(3) + c*x**S(6))**p, x), x, (d*x)**(m + S(1))*(S(2)*c*x**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))**(-p)*(S(2)*c*x**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))**(-p)*(a + b*x**S(3) + c*x**S(6))**p*AppellF1(m/S(3) + S(1)/3, -p, -p, m/S(3) + S(4)/3, -S(2)*c*x**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))))/(d*(m + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)*(a + b*x**S(3) + c*x**S(6))**p, x), x, x**S(5)*(S(2)*c*x**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))**(-p)*(S(2)*c*x**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))**(-p)*(a + b*x**S(3) + c*x**S(6))**p*AppellF1(S(5)/3, -p, -p, S(8)/3, -S(2)*c*x**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))))/S(5), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*(a + b*x**S(3) + c*x**S(6))**p, x), x, x**S(4)*(S(2)*c*x**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))**(-p)*(S(2)*c*x**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))**(-p)*(a + b*x**S(3) + c*x**S(6))**p*AppellF1(S(4)/3, -p, -p, S(7)/3, -S(2)*c*x**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))))/S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(a + b*x**S(3) + c*x**S(6))**p, x), x, x**S(2)*(S(2)*c*x**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))**(-p)*(S(2)*c*x**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))**(-p)*(a + b*x**S(3) + c*x**S(6))**p*AppellF1(S(2)/3, -p, -p, S(5)/3, -S(2)*c*x**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(3) + c*x**S(6))**p, x), x, x*(S(2)*c*x**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))**(-p)*(S(2)*c*x**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))**(-p)*(a + b*x**S(3) + c*x**S(6))**p*AppellF1(S(1)/3, -p, -p, S(4)/3, -S(2)*c*x**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(3)/(b + sqrt(-S(4)*a*c + b**S(2)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(3) + c*x**S(6))**p/x, x), x, S(2)**(S(2)*p + S(-1))*((b + S(2)*c*x**S(3) - sqrt(-S(4)*a*c + b**S(2)))/(c*x**S(3)))**(-p)*((b + S(2)*c*x**S(3) + sqrt(-S(4)*a*c + b**S(2)))/(c*x**S(3)))**(-p)*(a + b*x**S(3) + c*x**S(6))**p*AppellF1(-S(2)*p, -p, -p, -S(2)*p + S(1), -(b - sqrt(-S(4)*a*c + b**S(2)))/(S(2)*c*x**S(3)), -(b + sqrt(-S(4)*a*c + b**S(2)))/(S(2)*c*x**S(3)))/(S(3)*p), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(3) + c*x**S(6))**p/x**S(2), x), x, -(S(2)*c*x**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))**(-p)*(S(2)*c*x**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))**(-p)*(a + b*x**S(3) + c*x**S(6))**p*AppellF1(S(-1)/3, -p, -p, S(2)/3, -S(2)*c*x**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))))/x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(3) + c*x**S(6))**p/x**S(3), x), x, -(S(2)*c*x**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))**(-p)*(S(2)*c*x**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))**(-p)*(a + b*x**S(3) + c*x**S(6))**p*AppellF1(S(-2)/3, -p, -p, S(1)/3, -S(2)*c*x**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(3) + c*x**S(6))**p/x**S(4), x), x, -S(4)**p*((b + S(2)*c*x**S(3) - sqrt(-S(4)*a*c + b**S(2)))/(c*x**S(3)))**(-p)*((b + S(2)*c*x**S(3) + sqrt(-S(4)*a*c + b**S(2)))/(c*x**S(3)))**(-p)*(a + b*x**S(3) + c*x**S(6))**p*AppellF1(-S(2)*p + S(1), -p, -p, -S(2)*p + S(2), -(b - sqrt(-S(4)*a*c + b**S(2)))/(S(2)*c*x**S(3)), -(b + sqrt(-S(4)*a*c + b**S(2)))/(S(2)*c*x**S(3)))/(x**S(3)*(-S(6)*p + S(3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(3) + c*x**S(6))**p/x**S(5), x), x, -(S(2)*c*x**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))**(-p)*(S(2)*c*x**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))**(-p)*(a + b*x**S(3) + c*x**S(6))**p*AppellF1(S(-4)/3, -p, -p, S(-1)/3, -S(2)*c*x**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(4)*x**S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(3) + c*x**S(6))**p/x**S(6), x), x, -(S(2)*c*x**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))**(-p)*(S(2)*c*x**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))**(-p)*(a + b*x**S(3) + c*x**S(6))**p*AppellF1(S(-5)/3, -p, -p, S(-2)/3, -S(2)*c*x**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(5)*x**S(5)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(3) + c*x**S(6))**p/x**S(7), x), x, -S(2)**(S(2)*p + S(-1))*((b + S(2)*c*x**S(3) - sqrt(-S(4)*a*c + b**S(2)))/(c*x**S(3)))**(-p)*((b + S(2)*c*x**S(3) + sqrt(-S(4)*a*c + b**S(2)))/(c*x**S(3)))**(-p)*(a + b*x**S(3) + c*x**S(6))**p*AppellF1(-S(2)*p + S(2), -p, -p, -S(2)*p + S(3), -(b - sqrt(-S(4)*a*c + b**S(2)))/(S(2)*c*x**S(3)), -(b + sqrt(-S(4)*a*c + b**S(2)))/(S(2)*c*x**S(3)))/(x**S(6)*(-S(3)*p + S(3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(14)*(a + b*x**S(3) + c*x**S(6))**(S(3)/2), x), x, -S(11)*b*x**S(6)*(a + b*x**S(3) + c*x**S(6))**(S(5)/2)/(S(336)*c**S(2)) + x**S(9)*(a + b*x**S(3) + c*x**S(6))**(S(5)/2)/(S(24)*c) - (S(3)*b*(-S(124)*a*c + S(77)*b**S(2)) - S(10)*c*x**S(3)*(-S(28)*a*c + S(33)*b**S(2)))*(a + b*x**S(3) + c*x**S(6))**(S(5)/2)/(S(13440)*c**S(4)) + (b + S(2)*c*x**S(3))*(a + b*x**S(3) + c*x**S(6))**(S(3)/2)*(S(16)*a**S(2)*c**S(2) - S(72)*a*b**S(2)*c + S(33)*b**S(4))/(S(6144)*c**S(5)) - (b + S(2)*c*x**S(3))*(-S(4)*a*c + b**S(2))*sqrt(a + b*x**S(3) + c*x**S(6))*(S(16)*a**S(2)*c**S(2) - S(72)*a*b**S(2)*c + S(33)*b**S(4))/(S(16384)*c**S(6)) + (-S(4)*a*c + b**S(2))**S(2)*(S(16)*a**S(2)*c**S(2) - S(72)*a*b**S(2)*c + S(33)*b**S(4))*atanh((b + S(2)*c*x**S(3))/(S(2)*sqrt(c)*sqrt(a + b*x**S(3) + c*x**S(6))))/(S(32768)*c**(S(13)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(11)*(a + b*x**S(3) + c*x**S(6))**(S(3)/2), x), x, -b*(b + S(2)*c*x**S(3))*(-S(4)*a*c + S(3)*b**S(2))*(a + b*x**S(3) + c*x**S(6))**(S(3)/2)/(S(384)*c**S(4)) + b*(b + S(2)*c*x**S(3))*(-S(4)*a*c + b**S(2))*(-S(4)*a*c + S(3)*b**S(2))*sqrt(a + b*x**S(3) + c*x**S(6))/(S(1024)*c**S(5)) - b*(-S(4)*a*c + b**S(2))**S(2)*(-S(4)*a*c + S(3)*b**S(2))*atanh((b + S(2)*c*x**S(3))/(S(2)*sqrt(c)*sqrt(a + b*x**S(3) + c*x**S(6))))/(S(2048)*c**(S(11)/2)) + x**S(6)*(a + b*x**S(3) + c*x**S(6))**(S(5)/2)/(S(21)*c) + (a + b*x**S(3) + c*x**S(6))**(S(5)/2)*(-S(16)*a*c + S(21)*b**S(2) - S(30)*b*c*x**S(3))/(S(840)*c**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(8)*(a + b*x**S(3) + c*x**S(6))**(S(3)/2), x), x, -S(7)*b*(a + b*x**S(3) + c*x**S(6))**(S(5)/2)/(S(180)*c**S(2)) + x**S(3)*(a + b*x**S(3) + c*x**S(6))**(S(5)/2)/(S(18)*c) + (b + S(2)*c*x**S(3))*(-S(4)*a*c + S(7)*b**S(2))*(a + b*x**S(3) + c*x**S(6))**(S(3)/2)/(S(576)*c**S(3)) - (b + S(2)*c*x**S(3))*(-S(4)*a*c + b**S(2))*(-S(4)*a*c + S(7)*b**S(2))*sqrt(a + b*x**S(3) + c*x**S(6))/(S(1536)*c**S(4)) + (-S(4)*a*c + b**S(2))**S(2)*(-S(4)*a*c + S(7)*b**S(2))*atanh((b + S(2)*c*x**S(3))/(S(2)*sqrt(c)*sqrt(a + b*x**S(3) + c*x**S(6))))/(S(3072)*c**(S(9)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)*(a + b*x**S(3) + c*x**S(6))**(S(3)/2), x), x, -b*(b + S(2)*c*x**S(3))*(a + b*x**S(3) + c*x**S(6))**(S(3)/2)/(S(48)*c**S(2)) + b*(b + S(2)*c*x**S(3))*(-S(4)*a*c + b**S(2))*sqrt(a + b*x**S(3) + c*x**S(6))/(S(128)*c**S(3)) - b*(-S(4)*a*c + b**S(2))**S(2)*atanh((b + S(2)*c*x**S(3))/(S(2)*sqrt(c)*sqrt(a + b*x**S(3) + c*x**S(6))))/(S(256)*c**(S(7)/2)) + (a + b*x**S(3) + c*x**S(6))**(S(5)/2)/(S(15)*c), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(a + b*x**S(3) + c*x**S(6))**(S(3)/2), x), x, (b + S(2)*c*x**S(3))*(a + b*x**S(3) + c*x**S(6))**(S(3)/2)/(S(24)*c) - (b + S(2)*c*x**S(3))*(-S(4)*a*c + b**S(2))*sqrt(a + b*x**S(3) + c*x**S(6))/(S(64)*c**S(2)) + (-S(4)*a*c + b**S(2))**S(2)*atanh((b + S(2)*c*x**S(3))/(S(2)*sqrt(c)*sqrt(a + b*x**S(3) + c*x**S(6))))/(S(128)*c**(S(5)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(3) + c*x**S(6))**(S(3)/2)/x, x), x, -a**(S(3)/2)*atanh((S(2)*a + b*x**S(3))/(S(2)*sqrt(a)*sqrt(a + b*x**S(3) + c*x**S(6))))/S(3) - b*(-S(12)*a*c + b**S(2))*atanh((b + S(2)*c*x**S(3))/(S(2)*sqrt(c)*sqrt(a + b*x**S(3) + c*x**S(6))))/(S(48)*c**(S(3)/2)) + (a + b*x**S(3) + c*x**S(6))**(S(3)/2)/S(9) + sqrt(a + b*x**S(3) + c*x**S(6))*(S(8)*a*c + b**S(2) + S(2)*b*c*x**S(3))/(S(24)*c), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(3) + c*x**S(6))**(S(3)/2)/x**S(4), x), x, -sqrt(a)*b*atanh((S(2)*a + b*x**S(3))/(S(2)*sqrt(a)*sqrt(a + b*x**S(3) + c*x**S(6))))/S(2) + (S(3)*b/S(4) + c*x**S(3)/S(2))*sqrt(a + b*x**S(3) + c*x**S(6)) - (a + b*x**S(3) + c*x**S(6))**(S(3)/2)/(S(3)*x**S(3)) + (S(4)*a*c + b**S(2))*atanh((b + S(2)*c*x**S(3))/(S(2)*sqrt(c)*sqrt(a + b*x**S(3) + c*x**S(6))))/(S(8)*sqrt(c)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(3) + c*x**S(6))**(S(3)/2)/x**S(7), x), x, b*sqrt(c)*atanh((b + S(2)*c*x**S(3))/(S(2)*sqrt(c)*sqrt(a + b*x**S(3) + c*x**S(6))))/S(2) - (b - S(2)*c*x**S(3))*sqrt(a + b*x**S(3) + c*x**S(6))/(S(4)*x**S(3)) - (a + b*x**S(3) + c*x**S(6))**(S(3)/2)/(S(6)*x**S(6)) - (S(4)*a*c + b**S(2))*atanh((S(2)*a + b*x**S(3))/(S(2)*sqrt(a)*sqrt(a + b*x**S(3) + c*x**S(6))))/(S(8)*sqrt(a)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(3) + c*x**S(6))**(S(3)/2)/x**S(10), x), x, c**(S(3)/2)*atanh((b + S(2)*c*x**S(3))/(S(2)*sqrt(c)*sqrt(a + b*x**S(3) + c*x**S(6))))/S(3) - (a + b*x**S(3) + c*x**S(6))**(S(3)/2)/(S(9)*x**S(9)) - (S(2)*a*b + x**S(3)*(S(8)*a*c + b**S(2)))*sqrt(a + b*x**S(3) + c*x**S(6))/(S(24)*a*x**S(6)) + b*(-S(12)*a*c + b**S(2))*atanh((S(2)*a + b*x**S(3))/(S(2)*sqrt(a)*sqrt(a + b*x**S(3) + c*x**S(6))))/(S(48)*a**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(3) + c*x**S(6))**(S(3)/2)/x**S(13), x), x, -(S(2)*a + b*x**S(3))*(a + b*x**S(3) + c*x**S(6))**(S(3)/2)/(S(24)*a*x**S(12)) + (S(2)*a + b*x**S(3))*(-S(4)*a*c + b**S(2))*sqrt(a + b*x**S(3) + c*x**S(6))/(S(64)*a**S(2)*x**S(6)) - (-S(4)*a*c + b**S(2))**S(2)*atanh((S(2)*a + b*x**S(3))/(S(2)*sqrt(a)*sqrt(a + b*x**S(3) + c*x**S(6))))/(S(128)*a**(S(5)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(3) + c*x**S(6))**(S(3)/2)/x**S(16), x), x, -(a + b*x**S(3) + c*x**S(6))**(S(5)/2)/(S(15)*a*x**S(15)) + b*(S(2)*a + b*x**S(3))*(a + b*x**S(3) + c*x**S(6))**(S(3)/2)/(S(48)*a**S(2)*x**S(12)) - b*(S(2)*a + b*x**S(3))*(-S(4)*a*c + b**S(2))*sqrt(a + b*x**S(3) + c*x**S(6))/(S(128)*a**S(3)*x**S(6)) + b*(-S(4)*a*c + b**S(2))**S(2)*atanh((S(2)*a + b*x**S(3))/(S(2)*sqrt(a)*sqrt(a + b*x**S(3) + c*x**S(6))))/(S(256)*a**(S(7)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(3) + c*x**S(6))**(S(3)/2)/x**S(19), x), x, -(a + b*x**S(3) + c*x**S(6))**(S(5)/2)/(S(18)*a*x**S(18)) + S(7)*b*(a + b*x**S(3) + c*x**S(6))**(S(5)/2)/(S(180)*a**S(2)*x**S(15)) - (S(2)*a + b*x**S(3))*(-S(4)*a*c + S(7)*b**S(2))*(a + b*x**S(3) + c*x**S(6))**(S(3)/2)/(S(576)*a**S(3)*x**S(12)) + (S(2)*a + b*x**S(3))*(-S(4)*a*c + b**S(2))*(-S(4)*a*c + S(7)*b**S(2))*sqrt(a + b*x**S(3) + c*x**S(6))/(S(1536)*a**S(4)*x**S(6)) - (-S(4)*a*c + b**S(2))**S(2)*(-S(4)*a*c + S(7)*b**S(2))*atanh((S(2)*a + b*x**S(3))/(S(2)*sqrt(a)*sqrt(a + b*x**S(3) + c*x**S(6))))/(S(3072)*a**(S(9)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(3) + c*x**S(6))**(S(3)/2)/x**S(22), x), x, -(a + b*x**S(3) + c*x**S(6))**(S(5)/2)/(S(21)*a*x**S(21)) + b*(a + b*x**S(3) + c*x**S(6))**(S(5)/2)/(S(28)*a**S(2)*x**S(18)) - (-S(16)*a*c + S(21)*b**S(2))*(a + b*x**S(3) + c*x**S(6))**(S(5)/2)/(S(840)*a**S(3)*x**S(15)) + b*(S(2)*a + b*x**S(3))*(-S(4)*a*c + S(3)*b**S(2))*(a + b*x**S(3) + c*x**S(6))**(S(3)/2)/(S(384)*a**S(4)*x**S(12)) - b*(S(2)*a + b*x**S(3))*(-S(4)*a*c + b**S(2))*(-S(4)*a*c + S(3)*b**S(2))*sqrt(a + b*x**S(3) + c*x**S(6))/(S(1024)*a**S(5)*x**S(6)) + b*(-S(4)*a*c + b**S(2))**S(2)*(-S(4)*a*c + S(3)*b**S(2))*atanh((S(2)*a + b*x**S(3))/(S(2)*sqrt(a)*sqrt(a + b*x**S(3) + c*x**S(6))))/(S(2048)*a**(S(11)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**m/(x**S(8) + S(2)*x**S(4) + S(1)), x), x, x**(m + S(1))*hyper((S(2), m/S(4) + S(1)/4), (m/S(4) + S(5)/4,), -x**S(4))/(m + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(14)/sqrt(a + b*x**S(3) + c*x**S(6)), x), x, -S(7)*b*x**S(6)*sqrt(a + b*x**S(3) + c*x**S(6))/(S(72)*c**S(2)) + x**S(9)*sqrt(a + b*x**S(3) + c*x**S(6))/(S(12)*c) - (S(5)*b*(-S(44)*a*c + S(21)*b**S(2)) - S(2)*c*x**S(3)*(-S(36)*a*c + S(35)*b**S(2)))*sqrt(a + b*x**S(3) + c*x**S(6))/(S(576)*c**S(4)) + (S(48)*a**S(2)*c**S(2) - S(120)*a*b**S(2)*c + S(35)*b**S(4))*atanh((b + S(2)*c*x**S(3))/(S(2)*sqrt(c)*sqrt(a + b*x**S(3) + c*x**S(6))))/(S(384)*c**(S(9)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(11)/sqrt(a + b*x**S(3) + c*x**S(6)), x), x, -b*(-S(12)*a*c + S(5)*b**S(2))*atanh((b + S(2)*c*x**S(3))/(S(2)*sqrt(c)*sqrt(a + b*x**S(3) + c*x**S(6))))/(S(48)*c**(S(7)/2)) + x**S(6)*sqrt(a + b*x**S(3) + c*x**S(6))/(S(9)*c) + sqrt(a + b*x**S(3) + c*x**S(6))*(-S(16)*a*c + S(15)*b**S(2) - S(10)*b*c*x**S(3))/(S(72)*c**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(8)/sqrt(a + b*x**S(3) + c*x**S(6)), x), x, -b*sqrt(a + b*x**S(3) + c*x**S(6))/(S(4)*c**S(2)) + x**S(3)*sqrt(a + b*x**S(3) + c*x**S(6))/(S(6)*c) + (-S(4)*a*c + S(3)*b**S(2))*atanh((b + S(2)*c*x**S(3))/(S(2)*sqrt(c)*sqrt(a + b*x**S(3) + c*x**S(6))))/(S(24)*c**(S(5)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)/sqrt(a + b*x**S(3) + c*x**S(6)), x), x, -b*atanh((b + S(2)*c*x**S(3))/(S(2)*sqrt(c)*sqrt(a + b*x**S(3) + c*x**S(6))))/(S(6)*c**(S(3)/2)) + sqrt(a + b*x**S(3) + c*x**S(6))/(S(3)*c), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/sqrt(a + b*x**S(3) + c*x**S(6)), x), x, atanh((b + S(2)*c*x**S(3))/(S(2)*sqrt(c)*sqrt(a + b*x**S(3) + c*x**S(6))))/(S(3)*sqrt(c)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*sqrt(a + b*x**S(3) + c*x**S(6))), x), x, -atanh((S(2)*a + b*x**S(3))/(S(2)*sqrt(a)*sqrt(a + b*x**S(3) + c*x**S(6))))/(S(3)*sqrt(a)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(4)*sqrt(a + b*x**S(3) + c*x**S(6))), x), x, -sqrt(a + b*x**S(3) + c*x**S(6))/(S(3)*a*x**S(3)) + b*atanh((S(2)*a + b*x**S(3))/(S(2)*sqrt(a)*sqrt(a + b*x**S(3) + c*x**S(6))))/(S(6)*a**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(7)*sqrt(a + b*x**S(3) + c*x**S(6))), x), x, -sqrt(a + b*x**S(3) + c*x**S(6))/(S(6)*a*x**S(6)) + b*sqrt(a + b*x**S(3) + c*x**S(6))/(S(4)*a**S(2)*x**S(3)) - (-S(4)*a*c + S(3)*b**S(2))*atanh((S(2)*a + b*x**S(3))/(S(2)*sqrt(a)*sqrt(a + b*x**S(3) + c*x**S(6))))/(S(24)*a**(S(5)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(10)*sqrt(a + b*x**S(3) + c*x**S(6))), x), x, -sqrt(a + b*x**S(3) + c*x**S(6))/(S(9)*a*x**S(9)) + S(5)*b*sqrt(a + b*x**S(3) + c*x**S(6))/(S(36)*a**S(2)*x**S(6)) - (-S(16)*a*c + S(15)*b**S(2))*sqrt(a + b*x**S(3) + c*x**S(6))/(S(72)*a**S(3)*x**S(3)) + b*(-S(12)*a*c + S(5)*b**S(2))*atanh((S(2)*a + b*x**S(3))/(S(2)*sqrt(a)*sqrt(a + b*x**S(3) + c*x**S(6))))/(S(48)*a**(S(7)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(13)*sqrt(a + b*x**S(3) + c*x**S(6))), x), x, -sqrt(a + b*x**S(3) + c*x**S(6))/(S(12)*a*x**S(12)) + S(7)*b*sqrt(a + b*x**S(3) + c*x**S(6))/(S(72)*a**S(2)*x**S(9)) - (-S(36)*a*c + S(35)*b**S(2))*sqrt(a + b*x**S(3) + c*x**S(6))/(S(288)*a**S(3)*x**S(6)) + S(5)*b*(-S(44)*a*c + S(21)*b**S(2))*sqrt(a + b*x**S(3) + c*x**S(6))/(S(576)*a**S(4)*x**S(3)) - (S(48)*a**S(2)*c**S(2) - S(120)*a*b**S(2)*c + S(35)*b**S(4))*atanh((S(2)*a + b*x**S(3))/(S(2)*sqrt(a)*sqrt(a + b*x**S(3) + c*x**S(6))))/(S(384)*a**(S(9)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(14)/(a + b*x**S(3) + c*x**S(6))**(S(3)/2), x), x, -S(2)*b*x**S(6)*sqrt(a + b*x**S(3) + c*x**S(6))/(S(3)*c*(-S(4)*a*c + b**S(2))) + S(2)*x**S(9)*(S(2)*a + b*x**S(3))/((-S(12)*a*c + S(3)*b**S(2))*sqrt(a + b*x**S(3) + c*x**S(6))) - (b*(-S(52)*a*c + S(15)*b**S(2)) - S(2)*c*x**S(3)*(-S(12)*a*c + S(5)*b**S(2)))*sqrt(a + b*x**S(3) + c*x**S(6))/(S(12)*c**S(3)*(-S(4)*a*c + b**S(2))) + (-S(4)*a*c + S(5)*b**S(2))*atanh((b + S(2)*c*x**S(3))/(S(2)*sqrt(c)*sqrt(a + b*x**S(3) + c*x**S(6))))/(S(8)*c**(S(7)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(11)/(a + b*x**S(3) + c*x**S(6))**(S(3)/2), x), x, -b*atanh((b + S(2)*c*x**S(3))/(S(2)*sqrt(c)*sqrt(a + b*x**S(3) + c*x**S(6))))/(S(2)*c**(S(5)/2)) + S(2)*x**S(6)*(S(2)*a + b*x**S(3))/((-S(12)*a*c + S(3)*b**S(2))*sqrt(a + b*x**S(3) + c*x**S(6))) + sqrt(a + b*x**S(3) + c*x**S(6))*(-S(8)*a*c + S(3)*b**S(2) - S(2)*b*c*x**S(3))/(S(3)*c**S(2)*(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(8)/(a + b*x**S(3) + c*x**S(6))**(S(3)/2), x), x, -S(2)*b*sqrt(a + b*x**S(3) + c*x**S(6))/(S(3)*c*(-S(4)*a*c + b**S(2))) + S(2)*x**S(3)*(S(2)*a + b*x**S(3))/((-S(12)*a*c + S(3)*b**S(2))*sqrt(a + b*x**S(3) + c*x**S(6))) + atanh((b + S(2)*c*x**S(3))/(S(2)*sqrt(c)*sqrt(a + b*x**S(3) + c*x**S(6))))/(S(3)*c**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)/(a + b*x**S(3) + c*x**S(6))**(S(3)/2), x), x, (S(4)*a + S(2)*b*x**S(3))/((-S(12)*a*c + S(3)*b**S(2))*sqrt(a + b*x**S(3) + c*x**S(6))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/(a + b*x**S(3) + c*x**S(6))**(S(3)/2), x), x, -(S(2)*b + S(4)*c*x**S(3))/((-S(12)*a*c + S(3)*b**S(2))*sqrt(a + b*x**S(3) + c*x**S(6))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*(a + b*x**S(3) + c*x**S(6))**(S(3)/2)), x), x, (-S(4)*a*c + S(2)*b**S(2) + S(2)*b*c*x**S(3))/(S(3)*a*(-S(4)*a*c + b**S(2))*sqrt(a + b*x**S(3) + c*x**S(6))) - atanh((S(2)*a + b*x**S(3))/(S(2)*sqrt(a)*sqrt(a + b*x**S(3) + c*x**S(6))))/(S(3)*a**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(4)*(a + b*x**S(3) + c*x**S(6))**(S(3)/2)), x), x, (-S(4)*a*c + S(2)*b**S(2) + S(2)*b*c*x**S(3))/(S(3)*a*x**S(3)*(-S(4)*a*c + b**S(2))*sqrt(a + b*x**S(3) + c*x**S(6))) - (-S(8)*a*c + S(3)*b**S(2))*sqrt(a + b*x**S(3) + c*x**S(6))/(S(3)*a**S(2)*x**S(3)*(-S(4)*a*c + b**S(2))) + b*atanh((S(2)*a + b*x**S(3))/(S(2)*sqrt(a)*sqrt(a + b*x**S(3) + c*x**S(6))))/(S(2)*a**(S(5)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(7)*(a + b*x**S(3) + c*x**S(6))**(S(3)/2)), x), x, (-S(4)*a*c + S(2)*b**S(2) + S(2)*b*c*x**S(3))/(S(3)*a*x**S(6)*(-S(4)*a*c + b**S(2))*sqrt(a + b*x**S(3) + c*x**S(6))) - (-S(12)*a*c + S(5)*b**S(2))*sqrt(a + b*x**S(3) + c*x**S(6))/(S(6)*a**S(2)*x**S(6)*(-S(4)*a*c + b**S(2))) + b*(-S(52)*a*c + S(15)*b**S(2))*sqrt(a + b*x**S(3) + c*x**S(6))/(S(12)*a**S(3)*x**S(3)*(-S(4)*a*c + b**S(2))) - (-S(4)*a*c + S(5)*b**S(2))*atanh((S(2)*a + b*x**S(3))/(S(2)*sqrt(a)*sqrt(a + b*x**S(3) + c*x**S(6))))/(S(8)*a**(S(7)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(10)*(a + b*x**S(3) + c*x**S(6))**(S(3)/2)), x), x, (-S(4)*a*c + S(2)*b**S(2) + S(2)*b*c*x**S(3))/(S(3)*a*x**S(9)*(-S(4)*a*c + b**S(2))*sqrt(a + b*x**S(3) + c*x**S(6))) - (-S(16)*a*c + S(7)*b**S(2))*sqrt(a + b*x**S(3) + c*x**S(6))/(S(9)*a**S(2)*x**S(9)*(-S(4)*a*c + b**S(2))) + b*(-S(116)*a*c + S(35)*b**S(2))*sqrt(a + b*x**S(3) + c*x**S(6))/(S(36)*a**S(3)*x**S(6)*(-S(4)*a*c + b**S(2))) - sqrt(a + b*x**S(3) + c*x**S(6))*(S(256)*a**S(2)*c**S(2) - S(460)*a*b**S(2)*c + S(105)*b**S(4))/(S(72)*a**S(4)*x**S(3)*(-S(4)*a*c + b**S(2))) + S(5)*b*(-S(12)*a*c + S(7)*b**S(2))*atanh((S(2)*a + b*x**S(3))/(S(2)*sqrt(a)*sqrt(a + b*x**S(3) + c*x**S(6))))/(S(48)*a**(S(9)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**m*(a + b*x**S(3) + c*x**S(6))**S(2), x), x, a**S(2)*(d*x)**(m + S(1))/(d*(m + S(1))) + S(2)*a*b*(d*x)**(m + S(4))/(d**S(4)*(m + S(4))) + S(2)*b*c*(d*x)**(m + S(10))/(d**S(10)*(m + S(10))) + c**S(2)*(d*x)**(m + S(13))/(d**S(13)*(m + S(13))) + (d*x)**(m + S(7))*(S(2)*a*c + b**S(2))/(d**S(7)*(m + S(7))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**m*(a + b*x**S(3) + c*x**S(6)), x), x, a*(d*x)**(m + S(1))/(d*(m + S(1))) + b*(d*x)**(m + S(4))/(d**S(4)*(m + S(4))) + c*(d*x)**(m + S(7))/(d**S(7)*(m + S(7))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**m/(a + b*x**S(3) + c*x**S(6)), x), x, -S(2)*c*(d*x)**(m + S(1))*hyper((S(1), m/S(3) + S(1)/3), (m/S(3) + S(4)/3,), -S(2)*c*x**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))))/(d*(b + sqrt(-S(4)*a*c + b**S(2)))*(m + S(1))*sqrt(-S(4)*a*c + b**S(2))) + S(2)*c*(d*x)**(m + S(1))*hyper((S(1), m/S(3) + S(1)/3), (m/S(3) + S(4)/3,), -S(2)*c*x**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))))/(d*(b - sqrt(-S(4)*a*c + b**S(2)))*(m + S(1))*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**m/(a + b*x**S(3) + c*x**S(6))**S(2), x), x, -c*(d*x)**(m + S(1))*(-S(4)*a*c*(-m + S(5)) + b**S(2)*(-m + S(2)) - b*(-m + S(2))*sqrt(-S(4)*a*c + b**S(2)))*hyper((S(1), m/S(3) + S(1)/3), (m/S(3) + S(4)/3,), -S(2)*c*x**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(3)*a*d*(b + sqrt(-S(4)*a*c + b**S(2)))*(m + S(1))*(-S(4)*a*c + b**S(2))**(S(3)/2)) + c*(d*x)**(m + S(1))*(-S(4)*a*c*(-m + S(5)) + b**S(2)*(-m + S(2)) + b*(-m + S(2))*sqrt(-S(4)*a*c + b**S(2)))*hyper((S(1), m/S(3) + S(1)/3), (m/S(3) + S(4)/3,), -S(2)*c*x**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))))/(S(3)*a*d*(b - sqrt(-S(4)*a*c + b**S(2)))*(m + S(1))*(-S(4)*a*c + b**S(2))**(S(3)/2)) + (d*x)**(m + S(1))*(-S(2)*a*c + b**S(2) + b*c*x**S(3))/(S(3)*a*d*(-S(4)*a*c + b**S(2))*(a + b*x**S(3) + c*x**S(6))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)*(a + b*x**S(3) + c*x**S(6))**p, x), x, S(2)**p*b*(-(b + S(2)*c*x**S(3) - sqrt(-S(4)*a*c + b**S(2)))/sqrt(-S(4)*a*c + b**S(2)))**(-p + S(-1))*(a + b*x**S(3) + c*x**S(6))**(p + S(1))*hyper((-p, p + S(1)), (p + S(2),), (b + S(2)*c*x**S(3) + sqrt(-S(4)*a*c + b**S(2)))/(S(2)*sqrt(-S(4)*a*c + b**S(2))))/(S(3)*c*(p + S(1))*sqrt(-S(4)*a*c + b**S(2))) + (a + b*x**S(3) + c*x**S(6))**(p + S(1))/(S(6)*c*(p + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(a + b*x**S(3) + c*x**S(6))**p, x), x, -S(2)**(p + S(1))*(-(b + S(2)*c*x**S(3) - sqrt(-S(4)*a*c + b**S(2)))/sqrt(-S(4)*a*c + b**S(2)))**(-p + S(-1))*(a + b*x**S(3) + c*x**S(6))**(p + S(1))*hyper((-p, p + S(1)), (p + S(2),), (b + S(2)*c*x**S(3) + sqrt(-S(4)*a*c + b**S(2)))/(S(2)*sqrt(-S(4)*a*c + b**S(2))))/(S(3)*(p + S(1))*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(9)/(x**S(8) + S(2)*x**S(4) + S(1)), x), x, -x**S(6)/(S(4)*x**S(4) + S(4)) + S(3)*x**S(2)/S(4) - S(3)*atan(x**S(2))/S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(7)/(x**S(8) + S(2)*x**S(4) + S(1)), x), x, log(x**S(4) + S(1))/S(4) + S(1)/(S(4)*x**S(4) + S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)/(x**S(8) + S(2)*x**S(4) + S(1)), x), x, -x**S(2)/(S(4)*x**S(4) + S(4)) + atan(x**S(2))/S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/(x**S(8) + S(2)*x**S(4) + S(1)), x), x, -S(1)/(S(4)*x**S(4) + S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(x**S(8) + S(2)*x**S(4) + S(1)), x), x, x**S(2)/(S(4)*x**S(4) + S(4)) + atan(x**S(2))/S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*(x**S(8) + S(2)*x**S(4) + S(1))), x), x, log(x) - log(x**S(4) + S(1))/S(4) + S(1)/(S(4)*x**S(4) + S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(3)*(x**S(8) + S(2)*x**S(4) + S(1))), x), x, -S(3)*atan(x**S(2))/S(4) - S(3)/(S(4)*x**S(2)) + S(1)/(S(4)*x**S(2)*(x**S(4) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(5)*(x**S(8) + S(2)*x**S(4) + S(1))), x), x, -S(2)*log(x) + log(x**S(4) + S(1))/S(2) - S(1)/(S(4)*x**S(4) + S(4)) - S(1)/(S(4)*x**S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(7)*(x**S(8) + S(2)*x**S(4) + S(1))), x), x, S(5)*atan(x**S(2))/S(4) + S(5)/(S(4)*x**S(2)) - S(5)/(S(12)*x**S(6)) + S(1)/(S(4)*x**S(6)*(x**S(4) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(8)/(x**S(8) + S(2)*x**S(4) + S(1)), x), x, -x**S(5)/(S(4)*x**S(4) + S(4)) + S(5)*x/S(4) + S(5)*sqrt(S(2))*log(x**S(2) - sqrt(S(2))*x + S(1))/S(32) - S(5)*sqrt(S(2))*log(x**S(2) + sqrt(S(2))*x + S(1))/S(32) - S(5)*sqrt(S(2))*atan(sqrt(S(2))*x + S(-1))/S(16) - S(5)*sqrt(S(2))*atan(sqrt(S(2))*x + S(1))/S(16), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(6)/(x**S(8) + S(2)*x**S(4) + S(1)), x), x, -x**S(3)/(S(4)*x**S(4) + S(4)) + S(3)*sqrt(S(2))*log(x**S(2) - sqrt(S(2))*x + S(1))/S(32) - S(3)*sqrt(S(2))*log(x**S(2) + sqrt(S(2))*x + S(1))/S(32) + S(3)*sqrt(S(2))*atan(sqrt(S(2))*x + S(-1))/S(16) + S(3)*sqrt(S(2))*atan(sqrt(S(2))*x + S(1))/S(16), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)/(x**S(8) + S(2)*x**S(4) + S(1)), x), x, -x/(S(4)*x**S(4) + S(4)) - sqrt(S(2))*log(x**S(2) - sqrt(S(2))*x + S(1))/S(32) + sqrt(S(2))*log(x**S(2) + sqrt(S(2))*x + S(1))/S(32) + sqrt(S(2))*atan(sqrt(S(2))*x + S(-1))/S(16) + sqrt(S(2))*atan(sqrt(S(2))*x + S(1))/S(16), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/(x**S(8) + S(2)*x**S(4) + S(1)), x), x, x**S(3)/(S(4)*x**S(4) + S(4)) + sqrt(S(2))*log(x**S(2) - sqrt(S(2))*x + S(1))/S(32) - sqrt(S(2))*log(x**S(2) + sqrt(S(2))*x + S(1))/S(32) + sqrt(S(2))*atan(sqrt(S(2))*x + S(-1))/S(16) + sqrt(S(2))*atan(sqrt(S(2))*x + S(1))/S(16), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(8) + S(2)*x**S(4) + S(1)), x), x, x/(S(4)*x**S(4) + S(4)) - S(3)*sqrt(S(2))*log(x**S(2) - sqrt(S(2))*x + S(1))/S(32) + S(3)*sqrt(S(2))*log(x**S(2) + sqrt(S(2))*x + S(1))/S(32) + S(3)*sqrt(S(2))*atan(sqrt(S(2))*x + S(-1))/S(16) + S(3)*sqrt(S(2))*atan(sqrt(S(2))*x + S(1))/S(16), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*(x**S(8) + S(2)*x**S(4) + S(1))), x), x, -S(5)*sqrt(S(2))*log(x**S(2) - sqrt(S(2))*x + S(1))/S(32) + S(5)*sqrt(S(2))*log(x**S(2) + sqrt(S(2))*x + S(1))/S(32) - S(5)*sqrt(S(2))*atan(sqrt(S(2))*x + S(-1))/S(16) - S(5)*sqrt(S(2))*atan(sqrt(S(2))*x + S(1))/S(16) - S(5)/(S(4)*x) + S(1)/(S(4)*x*(x**S(4) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(4)*(x**S(8) + S(2)*x**S(4) + S(1))), x), x, S(7)*sqrt(S(2))*log(x**S(2) - sqrt(S(2))*x + S(1))/S(32) - S(7)*sqrt(S(2))*log(x**S(2) + sqrt(S(2))*x + S(1))/S(32) - S(7)*sqrt(S(2))*atan(sqrt(S(2))*x + S(-1))/S(16) - S(7)*sqrt(S(2))*atan(sqrt(S(2))*x + S(1))/S(16) - S(7)/(S(12)*x**S(3)) + S(1)/(S(4)*x**S(3)*(x**S(4) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(6)*(x**S(8) + S(2)*x**S(4) + S(1))), x), x, S(9)*sqrt(S(2))*log(x**S(2) - sqrt(S(2))*x + S(1))/S(32) - S(9)*sqrt(S(2))*log(x**S(2) + sqrt(S(2))*x + S(1))/S(32) + S(9)*sqrt(S(2))*atan(sqrt(S(2))*x + S(-1))/S(16) + S(9)*sqrt(S(2))*atan(sqrt(S(2))*x + S(1))/S(16) + S(9)/(S(4)*x) - S(9)/(S(20)*x**S(5)) + S(1)/(S(4)*x**S(5)*(x**S(4) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(8)*(x**S(8) + S(2)*x**S(4) + S(1))), x), x, -S(11)*sqrt(S(2))*log(x**S(2) - sqrt(S(2))*x + S(1))/S(32) + S(11)*sqrt(S(2))*log(x**S(2) + sqrt(S(2))*x + S(1))/S(32) + S(11)*sqrt(S(2))*atan(sqrt(S(2))*x + S(-1))/S(16) + S(11)*sqrt(S(2))*atan(sqrt(S(2))*x + S(1))/S(16) + S(11)/(S(12)*x**S(3)) - S(11)/(S(28)*x**S(7)) + S(1)/(S(4)*x**S(7)*(x**S(4) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**m/(x**S(8) - S(2)*x**S(4) + S(1)), x), x, x**(m + S(1))*hyper((S(2), m/S(4) + S(1)/4), (m/S(4) + S(5)/4,), x**S(4))/(m + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(9)/(x**S(8) - S(2)*x**S(4) + S(1)), x), x, x**S(6)/(-S(4)*x**S(4) + S(4)) + S(3)*x**S(2)/S(4) - S(3)*atanh(x**S(2))/S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(7)/(x**S(8) - S(2)*x**S(4) + S(1)), x), x, log(-x**S(4) + S(1))/S(4) + S(1)/(-S(4)*x**S(4) + S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)/(x**S(8) - S(2)*x**S(4) + S(1)), x), x, x**S(2)/(-S(4)*x**S(4) + S(4)) - atanh(x**S(2))/S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/(x**S(8) - S(2)*x**S(4) + S(1)), x), x, S(1)/(-S(4)*x**S(4) + S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(x**S(8) - S(2)*x**S(4) + S(1)), x), x, x**S(2)/(-S(4)*x**S(4) + S(4)) + atanh(x**S(2))/S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*(x**S(8) - S(2)*x**S(4) + S(1))), x), x, log(x) - log(-x**S(4) + S(1))/S(4) + S(1)/(-S(4)*x**S(4) + S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(3)*(x**S(8) - S(2)*x**S(4) + S(1))), x), x, S(3)*atanh(x**S(2))/S(4) - S(3)/(S(4)*x**S(2)) + S(1)/(S(4)*x**S(2)*(-x**S(4) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(5)*(x**S(8) - S(2)*x**S(4) + S(1))), x), x, S(2)*log(x) - log(-x**S(4) + S(1))/S(2) + S(1)/(-S(4)*x**S(4) + S(4)) - S(1)/(S(4)*x**S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(7)*(x**S(8) - S(2)*x**S(4) + S(1))), x), x, S(5)*atanh(x**S(2))/S(4) - S(5)/(S(4)*x**S(2)) - S(5)/(S(12)*x**S(6)) + S(1)/(S(4)*x**S(6)*(-x**S(4) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(8)/(x**S(8) - S(2)*x**S(4) + S(1)), x), x, x**S(5)/(-S(4)*x**S(4) + S(4)) + S(5)*x/S(4) - S(5)*atan(x)/S(8) - S(5)*atanh(x)/S(8), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(6)/(x**S(8) - S(2)*x**S(4) + S(1)), x), x, x**S(3)/(-S(4)*x**S(4) + S(4)) + S(3)*atan(x)/S(8) - S(3)*atanh(x)/S(8), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)/(x**S(8) - S(2)*x**S(4) + S(1)), x), x, x/(-S(4)*x**S(4) + S(4)) - atan(x)/S(8) - atanh(x)/S(8), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/(x**S(8) - S(2)*x**S(4) + S(1)), x), x, x**S(3)/(-S(4)*x**S(4) + S(4)) - atan(x)/S(8) + atanh(x)/S(8), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(8) - S(2)*x**S(4) + S(1)), x), x, x/(-S(4)*x**S(4) + S(4)) + S(3)*atan(x)/S(8) + S(3)*atanh(x)/S(8), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*(x**S(8) - S(2)*x**S(4) + S(1))), x), x, -S(5)*atan(x)/S(8) + S(5)*atanh(x)/S(8) - S(5)/(S(4)*x) + S(1)/(S(4)*x*(-x**S(4) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(4)*(x**S(8) - S(2)*x**S(4) + S(1))), x), x, S(7)*atan(x)/S(8) + S(7)*atanh(x)/S(8) - S(7)/(S(12)*x**S(3)) + S(1)/(S(4)*x**S(3)*(-x**S(4) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(6)*(x**S(8) - S(2)*x**S(4) + S(1))), x), x, -S(9)*atan(x)/S(8) + S(9)*atanh(x)/S(8) - S(9)/(S(4)*x) - S(9)/(S(20)*x**S(5)) + S(1)/(S(4)*x**S(5)*(-x**S(4) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(8)*(x**S(8) - S(2)*x**S(4) + S(1))), x), x, S(11)*atan(x)/S(8) + S(11)*atanh(x)/S(8) - S(11)/(S(12)*x**S(3)) - S(11)/(S(28)*x**S(7)) + S(1)/(S(4)*x**S(7)*(-x**S(4) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**m/(a + b*x**S(4) + c*x**S(8)), x), x, -S(2)*c*x**(m + S(1))*hyper((S(1), m/S(4) + S(1)/4), (m/S(4) + S(5)/4,), -S(2)*c*x**S(4)/(b + sqrt(-S(4)*a*c + b**S(2))))/((b + sqrt(-S(4)*a*c + b**S(2)))*(m + S(1))*sqrt(-S(4)*a*c + b**S(2))) + S(2)*c*x**(m + S(1))*hyper((S(1), m/S(4) + S(1)/4), (m/S(4) + S(5)/4,), -S(2)*c*x**S(4)/(b - sqrt(-S(4)*a*c + b**S(2))))/((b - sqrt(-S(4)*a*c + b**S(2)))*(m + S(1))*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(11)/(a + b*x**S(4) + c*x**S(8)), x), x, -b*log(a + b*x**S(4) + c*x**S(8))/(S(8)*c**S(2)) + x**S(4)/(S(4)*c) - (-S(2)*a*c + b**S(2))*atanh((b + S(2)*c*x**S(4))/sqrt(-S(4)*a*c + b**S(2)))/(S(4)*c**S(2)*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(9)/(a + b*x**S(4) + c*x**S(8)), x), x, x**S(2)/(S(2)*c) - sqrt(S(2))*(b - (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x**S(2)/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(4)*c**(S(3)/2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))) - sqrt(S(2))*(b + (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x**S(2)/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(4)*c**(S(3)/2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(7)/(a + b*x**S(4) + c*x**S(8)), x), x, b*atanh((b + S(2)*c*x**S(4))/sqrt(-S(4)*a*c + b**S(2)))/(S(4)*c*sqrt(-S(4)*a*c + b**S(2))) + log(a + b*x**S(4) + c*x**S(8))/(S(8)*c), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)/(a + b*x**S(4) + c*x**S(8)), x), x, -sqrt(S(2))*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x**S(2)/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(4)*sqrt(c)*sqrt(-S(4)*a*c + b**S(2))) + sqrt(S(2))*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x**S(2)/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(4)*sqrt(c)*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/(a + b*x**S(4) + c*x**S(8)), x), x, -atanh((b + S(2)*c*x**S(4))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(a + b*x**S(4) + c*x**S(8)), x), x, -sqrt(S(2))*sqrt(c)*atan(sqrt(S(2))*sqrt(c)*x**S(2)/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*sqrt(-S(4)*a*c + b**S(2))) + sqrt(S(2))*sqrt(c)*atan(sqrt(S(2))*sqrt(c)*x**S(2)/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*(a + b*x**S(4) + c*x**S(8))), x), x, b*atanh((b + S(2)*c*x**S(4))/sqrt(-S(4)*a*c + b**S(2)))/(S(4)*a*sqrt(-S(4)*a*c + b**S(2))) + log(x)/a - log(a + b*x**S(4) + c*x**S(8))/(S(8)*a), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(3)*(a + b*x**S(4) + c*x**S(8))), x), x, -sqrt(S(2))*sqrt(c)*(-b/sqrt(-S(4)*a*c + b**S(2)) + S(1))*atan(sqrt(S(2))*sqrt(c)*x**S(2)/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(4)*a*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))) - sqrt(S(2))*sqrt(c)*(b/sqrt(-S(4)*a*c + b**S(2)) + S(1))*atan(sqrt(S(2))*sqrt(c)*x**S(2)/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(4)*a*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))) - S(1)/(S(2)*a*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(5)*(a + b*x**S(4) + c*x**S(8))), x), x, -S(1)/(S(4)*a*x**S(4)) - b*log(x)/a**S(2) + b*log(a + b*x**S(4) + c*x**S(8))/(S(8)*a**S(2)) - (-S(2)*a*c + b**S(2))*atanh((b + S(2)*c*x**S(4))/sqrt(-S(4)*a*c + b**S(2)))/(S(4)*a**S(2)*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(10)/(a + b*x**S(4) + c*x**S(8)), x), x, x**S(3)/(S(3)*c) - S(2)**(S(1)/4)*(b - (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(S(2)**(S(1)/4)*c**(S(1)/4)*x/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(4)*c**(S(7)/4)*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)) + S(2)**(S(1)/4)*(b - (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*x/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(4)*c**(S(7)/4)*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)) - S(2)**(S(1)/4)*(b + (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(S(2)**(S(1)/4)*c**(S(1)/4)*x/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(4)*c**(S(7)/4)*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)) + S(2)**(S(1)/4)*(b + (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*x/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(4)*c**(S(7)/4)*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(8)/(a + b*x**S(4) + c*x**S(8)), x), x, x/c + S(2)**(S(3)/4)*(b - (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(S(2)**(S(1)/4)*c**(S(1)/4)*x/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(4)*c**(S(5)/4)*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)) + S(2)**(S(3)/4)*(b - (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*x/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(4)*c**(S(5)/4)*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)) + S(2)**(S(3)/4)*(b + (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(S(2)**(S(1)/4)*c**(S(1)/4)*x/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(4)*c**(S(5)/4)*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)) + S(2)**(S(3)/4)*(b + (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*x/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(4)*c**(S(5)/4)*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(6)/(a + b*x**S(4) + c*x**S(8)), x), x, -S(2)**(S(1)/4)*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)*atan(S(2)**(S(1)/4)*c**(S(1)/4)*x/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(4)*c**(S(3)/4)*sqrt(-S(4)*a*c + b**S(2))) + S(2)**(S(1)/4)*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*x/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(4)*c**(S(3)/4)*sqrt(-S(4)*a*c + b**S(2))) + S(2)**(S(1)/4)*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)*atan(S(2)**(S(1)/4)*c**(S(1)/4)*x/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(4)*c**(S(3)/4)*sqrt(-S(4)*a*c + b**S(2))) - S(2)**(S(1)/4)*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*x/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(4)*c**(S(3)/4)*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)/(a + b*x**S(4) + c*x**S(8)), x), x, S(2)**(S(3)/4)*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)*atan(S(2)**(S(1)/4)*c**(S(1)/4)*x/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(4)*c**(S(1)/4)*sqrt(-S(4)*a*c + b**S(2))) + S(2)**(S(3)/4)*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*x/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(4)*c**(S(1)/4)*sqrt(-S(4)*a*c + b**S(2))) - S(2)**(S(3)/4)*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)*atan(S(2)**(S(1)/4)*c**(S(1)/4)*x/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(4)*c**(S(1)/4)*sqrt(-S(4)*a*c + b**S(2))) - S(2)**(S(3)/4)*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*x/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(4)*c**(S(1)/4)*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/(a + b*x**S(4) + c*x**S(8)), x), x, S(2)**(S(1)/4)*c**(S(1)/4)*atan(S(2)**(S(1)/4)*c**(S(1)/4)*x/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(2)*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)*sqrt(-S(4)*a*c + b**S(2))) - S(2)**(S(1)/4)*c**(S(1)/4)*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*x/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(2)*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)*sqrt(-S(4)*a*c + b**S(2))) - S(2)**(S(1)/4)*c**(S(1)/4)*atan(S(2)**(S(1)/4)*c**(S(1)/4)*x/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(2)*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)*sqrt(-S(4)*a*c + b**S(2))) + S(2)**(S(1)/4)*c**(S(1)/4)*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*x/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(2)*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(a + b*x**S(4) + c*x**S(8)), x), x, -S(2)**(S(3)/4)*c**(S(3)/4)*atan(S(2)**(S(1)/4)*c**(S(1)/4)*x/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(2)*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)*sqrt(-S(4)*a*c + b**S(2))) - S(2)**(S(3)/4)*c**(S(3)/4)*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*x/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(2)*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)*sqrt(-S(4)*a*c + b**S(2))) + S(2)**(S(3)/4)*c**(S(3)/4)*atan(S(2)**(S(1)/4)*c**(S(1)/4)*x/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(2)*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)*sqrt(-S(4)*a*c + b**S(2))) + S(2)**(S(3)/4)*c**(S(3)/4)*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*x/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(2)*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*(a + b*x**S(4) + c*x**S(8))), x), x, -S(2)**(S(1)/4)*c**(S(1)/4)*(b/sqrt(-S(4)*a*c + b**S(2)) + S(1))*atan(S(2)**(S(1)/4)*c**(S(1)/4)*x/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(4)*a*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)) + S(2)**(S(1)/4)*c**(S(1)/4)*(b/sqrt(-S(4)*a*c + b**S(2)) + S(1))*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*x/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(4)*a*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)) - S(2)**(S(1)/4)*c**(S(1)/4)*(-b/sqrt(-S(4)*a*c + b**S(2)) + S(1))*atan(S(2)**(S(1)/4)*c**(S(1)/4)*x/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(4)*a*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)) + S(2)**(S(1)/4)*c**(S(1)/4)*(-b/sqrt(-S(4)*a*c + b**S(2)) + S(1))*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*x/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(4)*a*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)) - S(1)/(a*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(4)*(a + b*x**S(4) + c*x**S(8))), x), x, S(2)**(S(3)/4)*c**(S(3)/4)*(b/sqrt(-S(4)*a*c + b**S(2)) + S(1))*atan(S(2)**(S(1)/4)*c**(S(1)/4)*x/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(4)*a*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)) + S(2)**(S(3)/4)*c**(S(3)/4)*(b/sqrt(-S(4)*a*c + b**S(2)) + S(1))*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*x/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(4)*a*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)) + S(2)**(S(3)/4)*c**(S(3)/4)*(-b/sqrt(-S(4)*a*c + b**S(2)) + S(1))*atan(S(2)**(S(1)/4)*c**(S(1)/4)*x/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(4)*a*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)) + S(2)**(S(3)/4)*c**(S(3)/4)*(-b/sqrt(-S(4)*a*c + b**S(2)) + S(1))*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*x/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(4)*a*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)) - S(1)/(S(3)*a*x**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**m/(x**S(8) + x**S(4) + S(1)), x), x, S(2)*sqrt(S(3))*x**(m + S(1))*hyper((S(1), m/S(4) + S(1)/4), (m/S(4) + S(5)/4,), -S(2)*x**S(4)/(S(1) - sqrt(S(3))*I))/(S(3)*(sqrt(S(3)) + I)*(m + S(1))) - S(2)*sqrt(S(3))*x**(m + S(1))*hyper((S(1), m/S(4) + S(1)/4), (m/S(4) + S(5)/4,), -S(2)*x**S(4)/(S(1) + sqrt(S(3))*I))/(S(3)*(-sqrt(S(3)) + I)*(m + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(11)/(x**S(8) + x**S(4) + S(1)), x), x, x**S(4)/S(4) - log(x**S(8) + x**S(4) + S(1))/S(8) - sqrt(S(3))*atan(sqrt(S(3))*(S(2)*x**S(4) + S(1))/S(3))/S(12), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(9)/(x**S(8) + x**S(4) + S(1)), x), x, x**S(2)/S(2) + sqrt(S(3))*atan(sqrt(S(3))*(-S(2)*x**S(2) + S(1))/S(3))/S(6) - sqrt(S(3))*atan(sqrt(S(3))*(S(2)*x**S(2) + S(1))/S(3))/S(6), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(7)/(x**S(8) + x**S(4) + S(1)), x), x, log(x**S(8) + x**S(4) + S(1))/S(8) - sqrt(S(3))*atan(sqrt(S(3))*(S(2)*x**S(4) + S(1))/S(3))/S(12), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)/(x**S(8) + x**S(4) + S(1)), x), x, log(x**S(4) - x**S(2) + S(1))/S(8) - log(x**S(4) + x**S(2) + S(1))/S(8) - sqrt(S(3))*atan(sqrt(S(3))*(-S(2)*x**S(2) + S(1))/S(3))/S(12) + sqrt(S(3))*atan(sqrt(S(3))*(S(2)*x**S(2) + S(1))/S(3))/S(12), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/(x**S(8) + x**S(4) + S(1)), x), x, sqrt(S(3))*atan(sqrt(S(3))*(S(2)*x**S(4) + S(1))/S(3))/S(6), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(x**S(8) + x**S(4) + S(1)), x), x, -log(x**S(4) - x**S(2) + S(1))/S(8) + log(x**S(4) + x**S(2) + S(1))/S(8) - sqrt(S(3))*atan(sqrt(S(3))*(-S(2)*x**S(2) + S(1))/S(3))/S(12) + sqrt(S(3))*atan(sqrt(S(3))*(S(2)*x**S(2) + S(1))/S(3))/S(12), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*(x**S(8) + x**S(4) + S(1))), x), x, log(x) - log(x**S(8) + x**S(4) + S(1))/S(8) - sqrt(S(3))*atan(sqrt(S(3))*(S(2)*x**S(4) + S(1))/S(3))/S(12), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(3)*(x**S(8) + x**S(4) + S(1))), x), x, sqrt(S(3))*atan(sqrt(S(3))*(-S(2)*x**S(2) + S(1))/S(3))/S(6) - sqrt(S(3))*atan(sqrt(S(3))*(S(2)*x**S(2) + S(1))/S(3))/S(6) - S(1)/(S(2)*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(5)*(x**S(8) + x**S(4) + S(1))), x), x, -log(x) + log(x**S(8) + x**S(4) + S(1))/S(8) - sqrt(S(3))*atan(sqrt(S(3))*(S(2)*x**S(4) + S(1))/S(3))/S(12) - S(1)/(S(4)*x**S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(7)*(x**S(8) + x**S(4) + S(1))), x), x, log(x**S(4) - x**S(2) + S(1))/S(8) - log(x**S(4) + x**S(2) + S(1))/S(8) - sqrt(S(3))*atan(sqrt(S(3))*(-S(2)*x**S(2) + S(1))/S(3))/S(12) + sqrt(S(3))*atan(sqrt(S(3))*(S(2)*x**S(2) + S(1))/S(3))/S(12) + S(1)/(S(2)*x**S(2)) - S(1)/(S(6)*x**S(6)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(8)/(x**S(8) + x**S(4) + S(1)), x), x, x + log(x**S(2) - x + S(1))/S(8) - log(x**S(2) + x + S(1))/S(8) + sqrt(S(3))*log(x**S(2) - sqrt(S(3))*x + S(1))/S(24) - sqrt(S(3))*log(x**S(2) + sqrt(S(3))*x + S(1))/S(24) + sqrt(S(3))*atan(sqrt(S(3))*(-S(2)*x + S(1))/S(3))/S(12) - sqrt(S(3))*atan(sqrt(S(3))*(S(2)*x + S(1))/S(3))/S(12) - atan(S(2)*x - sqrt(S(3)))/S(4) - atan(S(2)*x + sqrt(S(3)))/S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(6)/(x**S(8) + x**S(4) + S(1)), x), x, sqrt(S(3))*log(x**S(2) - sqrt(S(3))*x + S(1))/S(12) - sqrt(S(3))*log(x**S(2) + sqrt(S(3))*x + S(1))/S(12) - sqrt(S(3))*atan(sqrt(S(3))*(-S(2)*x + S(1))/S(3))/S(6) + sqrt(S(3))*atan(sqrt(S(3))*(S(2)*x + S(1))/S(3))/S(6), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)/(x**S(8) + x**S(4) + S(1)), x), x, -log(x**S(2) - x + S(1))/S(8) + log(x**S(2) + x + S(1))/S(8) + sqrt(S(3))*log(x**S(2) - sqrt(S(3))*x + S(1))/S(24) - sqrt(S(3))*log(x**S(2) + sqrt(S(3))*x + S(1))/S(24) + sqrt(S(3))*atan(sqrt(S(3))*(-S(2)*x + S(1))/S(3))/S(12) - sqrt(S(3))*atan(sqrt(S(3))*(S(2)*x + S(1))/S(3))/S(12) + atan(S(2)*x - sqrt(S(3)))/S(4) + atan(S(2)*x + sqrt(S(3)))/S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/(x**S(8) + x**S(4) + S(1)), x), x, log(x**S(2) - x + S(1))/S(8) - log(x**S(2) + x + S(1))/S(8) - sqrt(S(3))*log(x**S(2) - sqrt(S(3))*x + S(1))/S(24) + sqrt(S(3))*log(x**S(2) + sqrt(S(3))*x + S(1))/S(24) + sqrt(S(3))*atan(sqrt(S(3))*(-S(2)*x + S(1))/S(3))/S(12) - sqrt(S(3))*atan(sqrt(S(3))*(S(2)*x + S(1))/S(3))/S(12) + atan(S(2)*x - sqrt(S(3)))/S(4) + atan(S(2)*x + sqrt(S(3)))/S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(8) + x**S(4) + S(1)), x), x, -sqrt(S(3))*log(x**S(2) - sqrt(S(3))*x + S(1))/S(12) + sqrt(S(3))*log(x**S(2) + sqrt(S(3))*x + S(1))/S(12) - sqrt(S(3))*atan(sqrt(S(3))*(-S(2)*x + S(1))/S(3))/S(6) + sqrt(S(3))*atan(sqrt(S(3))*(S(2)*x + S(1))/S(3))/S(6), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*(x**S(8) + x**S(4) + S(1))), x), x, -log(x**S(2) - x + S(1))/S(8) + log(x**S(2) + x + S(1))/S(8) - sqrt(S(3))*log(x**S(2) - sqrt(S(3))*x + S(1))/S(24) + sqrt(S(3))*log(x**S(2) + sqrt(S(3))*x + S(1))/S(24) + sqrt(S(3))*atan(sqrt(S(3))*(-S(2)*x + S(1))/S(3))/S(12) - sqrt(S(3))*atan(sqrt(S(3))*(S(2)*x + S(1))/S(3))/S(12) - atan(S(2)*x - sqrt(S(3)))/S(4) - atan(S(2)*x + sqrt(S(3)))/S(4) - S(1)/x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(4)*(x**S(8) + x**S(4) + S(1))), x), x, log(x**S(2) - x + S(1))/S(8) - log(x**S(2) + x + S(1))/S(8) + sqrt(S(3))*log(x**S(2) - sqrt(S(3))*x + S(1))/S(24) - sqrt(S(3))*log(x**S(2) + sqrt(S(3))*x + S(1))/S(24) + sqrt(S(3))*atan(sqrt(S(3))*(-S(2)*x + S(1))/S(3))/S(12) - sqrt(S(3))*atan(sqrt(S(3))*(S(2)*x + S(1))/S(3))/S(12) - atan(S(2)*x - sqrt(S(3)))/S(4) - atan(S(2)*x + sqrt(S(3)))/S(4) - S(1)/(S(3)*x**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(6)*(x**S(8) + x**S(4) + S(1))), x), x, sqrt(S(3))*log(x**S(2) - sqrt(S(3))*x + S(1))/S(12) - sqrt(S(3))*log(x**S(2) + sqrt(S(3))*x + S(1))/S(12) - sqrt(S(3))*atan(sqrt(S(3))*(-S(2)*x + S(1))/S(3))/S(6) + sqrt(S(3))*atan(sqrt(S(3))*(S(2)*x + S(1))/S(3))/S(6) + S(1)/x - S(1)/(S(5)*x**S(5)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(8)*(x**S(8) + x**S(4) + S(1))), x), x, -log(x**S(2) - x + S(1))/S(8) + log(x**S(2) + x + S(1))/S(8) + sqrt(S(3))*log(x**S(2) - sqrt(S(3))*x + S(1))/S(24) - sqrt(S(3))*log(x**S(2) + sqrt(S(3))*x + S(1))/S(24) + sqrt(S(3))*atan(sqrt(S(3))*(-S(2)*x + S(1))/S(3))/S(12) - sqrt(S(3))*atan(sqrt(S(3))*(S(2)*x + S(1))/S(3))/S(12) + atan(S(2)*x - sqrt(S(3)))/S(4) + atan(S(2)*x + sqrt(S(3)))/S(4) + S(1)/(S(3)*x**S(3)) - S(1)/(S(7)*x**S(7)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**m/(x**S(8) - x**S(4) + S(1)), x), x, S(2)*sqrt(S(3))*x**(m + S(1))*hyper((S(1), m/S(4) + S(1)/4), (m/S(4) + S(5)/4,), S(2)*x**S(4)/(S(1) - sqrt(S(3))*I))/(S(3)*(sqrt(S(3)) + I)*(m + S(1))) - S(2)*sqrt(S(3))*x**(m + S(1))*hyper((S(1), m/S(4) + S(1)/4), (m/S(4) + S(5)/4,), S(2)*x**S(4)/(S(1) + sqrt(S(3))*I))/(S(3)*(-sqrt(S(3)) + I)*(m + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(11)/(x**S(8) - x**S(4) + S(1)), x), x, x**S(4)/S(4) + log(x**S(8) - x**S(4) + S(1))/S(8) + sqrt(S(3))*atan(sqrt(S(3))*(-S(2)*x**S(4) + S(1))/S(3))/S(12), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(9)/(x**S(8) - x**S(4) + S(1)), x), x, x**S(2)/S(2) + sqrt(S(3))*log(x**S(4) - sqrt(S(3))*x**S(2) + S(1))/S(12) - sqrt(S(3))*log(x**S(4) + sqrt(S(3))*x**S(2) + S(1))/S(12), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(7)/(x**S(8) - x**S(4) + S(1)), x), x, log(x**S(8) - x**S(4) + S(1))/S(8) - sqrt(S(3))*atan(sqrt(S(3))*(-S(2)*x**S(4) + S(1))/S(3))/S(12), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)/(x**S(8) - x**S(4) + S(1)), x), x, sqrt(S(3))*log(x**S(4) - sqrt(S(3))*x**S(2) + S(1))/S(24) - sqrt(S(3))*log(x**S(4) + sqrt(S(3))*x**S(2) + S(1))/S(24) + atan(S(2)*x**S(2) - sqrt(S(3)))/S(4) + atan(S(2)*x**S(2) + sqrt(S(3)))/S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/(x**S(8) - x**S(4) + S(1)), x), x, -sqrt(S(3))*atan(sqrt(S(3))*(-S(2)*x**S(4) + S(1))/S(3))/S(6), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(x**S(8) - x**S(4) + S(1)), x), x, -sqrt(S(3))*log(x**S(4) - sqrt(S(3))*x**S(2) + S(1))/S(24) + sqrt(S(3))*log(x**S(4) + sqrt(S(3))*x**S(2) + S(1))/S(24) + atan(S(2)*x**S(2) - sqrt(S(3)))/S(4) + atan(S(2)*x**S(2) + sqrt(S(3)))/S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*(x**S(8) - x**S(4) + S(1))), x), x, log(x) - log(x**S(8) - x**S(4) + S(1))/S(8) - sqrt(S(3))*atan(sqrt(S(3))*(-S(2)*x**S(4) + S(1))/S(3))/S(12), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(3)*(x**S(8) - x**S(4) + S(1))), x), x, -sqrt(S(3))*log(x**S(4) - sqrt(S(3))*x**S(2) + S(1))/S(12) + sqrt(S(3))*log(x**S(4) + sqrt(S(3))*x**S(2) + S(1))/S(12) - S(1)/(S(2)*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(5)*(x**S(8) - x**S(4) + S(1))), x), x, log(x) - log(x**S(8) - x**S(4) + S(1))/S(8) + sqrt(S(3))*atan(sqrt(S(3))*(-S(2)*x**S(4) + S(1))/S(3))/S(12) - S(1)/(S(4)*x**S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(7)*(x**S(8) - x**S(4) + S(1))), x), x, -sqrt(S(3))*log(x**S(4) - sqrt(S(3))*x**S(2) + S(1))/S(24) + sqrt(S(3))*log(x**S(4) + sqrt(S(3))*x**S(2) + S(1))/S(24) - atan(S(2)*x**S(2) - sqrt(S(3)))/S(4) - atan(S(2)*x**S(2) + sqrt(S(3)))/S(4) - S(1)/(S(2)*x**S(2)) - S(1)/(S(6)*x**S(6)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(8)/(x**S(8) - x**S(4) + S(1)), x), x, x - sqrt(-sqrt(S(3))/S(3) + S(2)/3)*log(x**S(2) - x*sqrt(-sqrt(S(3)) + S(2)) + S(1))/S(8) + sqrt(-sqrt(S(3))/S(3) + S(2)/3)*log(x**S(2) + x*sqrt(-sqrt(S(3)) + S(2)) + S(1))/S(8) + sqrt(sqrt(S(3))/S(3) + S(2)/3)*log(x**S(2) - x*sqrt(sqrt(S(3)) + S(2)) + S(1))/S(8) - sqrt(sqrt(S(3))/S(3) + S(2)/3)*log(x**S(2) + x*sqrt(sqrt(S(3)) + S(2)) + S(1))/S(8) - atan((-S(2)*x + sqrt(sqrt(S(3)) + S(2)))/sqrt(-sqrt(S(3)) + S(2)))/(S(4)*sqrt(S(3)*sqrt(S(3)) + S(6))) + atan((S(2)*x + sqrt(sqrt(S(3)) + S(2)))/sqrt(-sqrt(S(3)) + S(2)))/(S(4)*sqrt(S(3)*sqrt(S(3)) + S(6))) + atan((-S(2)*x + sqrt(-sqrt(S(3)) + S(2)))/sqrt(sqrt(S(3)) + S(2)))/(S(4)*sqrt(-S(3)*sqrt(S(3)) + S(6))) - atan((S(2)*x + sqrt(-sqrt(S(3)) + S(2)))/sqrt(sqrt(S(3)) + S(2)))/(S(4)*sqrt(-S(3)*sqrt(S(3)) + S(6))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(6)/(x**S(8) - x**S(4) + S(1)), x), x, sqrt(S(6))*log(x**S(2) - x*sqrt(-sqrt(S(3)) + S(2)) + S(1))/S(24) - sqrt(S(6))*log(x**S(2) + x*sqrt(-sqrt(S(3)) + S(2)) + S(1))/S(24) + sqrt(S(6))*log(x**S(2) - x*sqrt(sqrt(S(3)) + S(2)) + S(1))/S(24) - sqrt(S(6))*log(x**S(2) + x*sqrt(sqrt(S(3)) + S(2)) + S(1))/S(24) - sqrt(S(6))*atan((-S(2)*x + sqrt(sqrt(S(3)) + S(2)))/sqrt(-sqrt(S(3)) + S(2)))/S(12) + sqrt(S(6))*atan((S(2)*x + sqrt(sqrt(S(3)) + S(2)))/sqrt(-sqrt(S(3)) + S(2)))/S(12) - sqrt(S(6))*atan((-S(2)*x + sqrt(-sqrt(S(3)) + S(2)))/sqrt(sqrt(S(3)) + S(2)))/S(12) + sqrt(S(6))*atan((S(2)*x + sqrt(-sqrt(S(3)) + S(2)))/sqrt(sqrt(S(3)) + S(2)))/S(12), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)/(x**S(8) - x**S(4) + S(1)), x), x, -log(x**S(2) - x*sqrt(-sqrt(S(3)) + S(2)) + S(1))/(S(8)*sqrt(-S(3)*sqrt(S(3)) + S(6))) + log(x**S(2) + x*sqrt(-sqrt(S(3)) + S(2)) + S(1))/(S(8)*sqrt(-S(3)*sqrt(S(3)) + S(6))) + log(x**S(2) - x*sqrt(sqrt(S(3)) + S(2)) + S(1))/(S(8)*sqrt(S(3)*sqrt(S(3)) + S(6))) - log(x**S(2) + x*sqrt(sqrt(S(3)) + S(2)) + S(1))/(S(8)*sqrt(S(3)*sqrt(S(3)) + S(6))) - atan((-S(2)*x + sqrt(sqrt(S(3)) + S(2)))/sqrt(-sqrt(S(3)) + S(2)))/(S(4)*sqrt(-S(3)*sqrt(S(3)) + S(6))) + atan((S(2)*x + sqrt(sqrt(S(3)) + S(2)))/sqrt(-sqrt(S(3)) + S(2)))/(S(4)*sqrt(-S(3)*sqrt(S(3)) + S(6))) + atan((-S(2)*x + sqrt(-sqrt(S(3)) + S(2)))/sqrt(sqrt(S(3)) + S(2)))/(S(4)*sqrt(S(3)*sqrt(S(3)) + S(6))) - atan((S(2)*x + sqrt(-sqrt(S(3)) + S(2)))/sqrt(sqrt(S(3)) + S(2)))/(S(4)*sqrt(S(3)*sqrt(S(3)) + S(6))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/(x**S(8) - x**S(4) + S(1)), x), x, log(x**S(2) - x*sqrt(-sqrt(S(3)) + S(2)) + S(1))/(S(8)*sqrt(-S(3)*sqrt(S(3)) + S(6))) - log(x**S(2) + x*sqrt(-sqrt(S(3)) + S(2)) + S(1))/(S(8)*sqrt(-S(3)*sqrt(S(3)) + S(6))) - log(x**S(2) - x*sqrt(sqrt(S(3)) + S(2)) + S(1))/(S(8)*sqrt(S(3)*sqrt(S(3)) + S(6))) + log(x**S(2) + x*sqrt(sqrt(S(3)) + S(2)) + S(1))/(S(8)*sqrt(S(3)*sqrt(S(3)) + S(6))) - sqrt(sqrt(S(3))/S(3) + S(2)/3)*atan((-S(2)*x + sqrt(sqrt(S(3)) + S(2)))/sqrt(-sqrt(S(3)) + S(2)))/S(4) + sqrt(sqrt(S(3))/S(3) + S(2)/3)*atan((S(2)*x + sqrt(sqrt(S(3)) + S(2)))/sqrt(-sqrt(S(3)) + S(2)))/S(4) + sqrt(-sqrt(S(3))/S(3) + S(2)/3)*atan((-S(2)*x + sqrt(-sqrt(S(3)) + S(2)))/sqrt(sqrt(S(3)) + S(2)))/S(4) - sqrt(-sqrt(S(3))/S(3) + S(2)/3)*atan((S(2)*x + sqrt(-sqrt(S(3)) + S(2)))/sqrt(sqrt(S(3)) + S(2)))/S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(8) - x**S(4) + S(1)), x), x, -sqrt(S(6))*log(x**S(2) - x*sqrt(-sqrt(S(3)) + S(2)) + S(1))/S(24) + sqrt(S(6))*log(x**S(2) + x*sqrt(-sqrt(S(3)) + S(2)) + S(1))/S(24) - sqrt(S(6))*log(x**S(2) - x*sqrt(sqrt(S(3)) + S(2)) + S(1))/S(24) + sqrt(S(6))*log(x**S(2) + x*sqrt(sqrt(S(3)) + S(2)) + S(1))/S(24) - sqrt(S(6))*atan((-S(2)*x + sqrt(sqrt(S(3)) + S(2)))/sqrt(-sqrt(S(3)) + S(2)))/S(12) + sqrt(S(6))*atan((S(2)*x + sqrt(sqrt(S(3)) + S(2)))/sqrt(-sqrt(S(3)) + S(2)))/S(12) - sqrt(S(6))*atan((-S(2)*x + sqrt(-sqrt(S(3)) + S(2)))/sqrt(sqrt(S(3)) + S(2)))/S(12) + sqrt(S(6))*atan((S(2)*x + sqrt(-sqrt(S(3)) + S(2)))/sqrt(sqrt(S(3)) + S(2)))/S(12), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*(x**S(8) - x**S(4) + S(1))), x), x, sqrt(-sqrt(S(3))/S(3) + S(2)/3)*log(x**S(2) - x*sqrt(-sqrt(S(3)) + S(2)) + S(1))/S(8) - sqrt(-sqrt(S(3))/S(3) + S(2)/3)*log(x**S(2) + x*sqrt(-sqrt(S(3)) + S(2)) + S(1))/S(8) - sqrt(sqrt(S(3))/S(3) + S(2)/3)*log(x**S(2) - x*sqrt(sqrt(S(3)) + S(2)) + S(1))/S(8) + sqrt(sqrt(S(3))/S(3) + S(2)/3)*log(x**S(2) + x*sqrt(sqrt(S(3)) + S(2)) + S(1))/S(8) - atan((-S(2)*x + sqrt(sqrt(S(3)) + S(2)))/sqrt(-sqrt(S(3)) + S(2)))/(S(4)*sqrt(S(3)*sqrt(S(3)) + S(6))) + atan((S(2)*x + sqrt(sqrt(S(3)) + S(2)))/sqrt(-sqrt(S(3)) + S(2)))/(S(4)*sqrt(S(3)*sqrt(S(3)) + S(6))) + atan((-S(2)*x + sqrt(-sqrt(S(3)) + S(2)))/sqrt(sqrt(S(3)) + S(2)))/(S(4)*sqrt(-S(3)*sqrt(S(3)) + S(6))) - atan((S(2)*x + sqrt(-sqrt(S(3)) + S(2)))/sqrt(sqrt(S(3)) + S(2)))/(S(4)*sqrt(-S(3)*sqrt(S(3)) + S(6))) - S(1)/x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(4)*(x**S(8) - x**S(4) + S(1))), x), x, sqrt(-sqrt(S(3))/S(3) + S(2)/3)*log(x**S(2) - x*sqrt(-sqrt(S(3)) + S(2)) + S(1))/S(8) - sqrt(-sqrt(S(3))/S(3) + S(2)/3)*log(x**S(2) + x*sqrt(-sqrt(S(3)) + S(2)) + S(1))/S(8) - sqrt(sqrt(S(3))/S(3) + S(2)/3)*log(x**S(2) - x*sqrt(sqrt(S(3)) + S(2)) + S(1))/S(8) + sqrt(sqrt(S(3))/S(3) + S(2)/3)*log(x**S(2) + x*sqrt(sqrt(S(3)) + S(2)) + S(1))/S(8) + sqrt(-sqrt(S(3))/S(3) + S(2)/3)*atan((-S(2)*x + sqrt(sqrt(S(3)) + S(2)))/sqrt(-sqrt(S(3)) + S(2)))/S(4) - sqrt(-sqrt(S(3))/S(3) + S(2)/3)*atan((S(2)*x + sqrt(sqrt(S(3)) + S(2)))/sqrt(-sqrt(S(3)) + S(2)))/S(4) - sqrt(sqrt(S(3))/S(3) + S(2)/3)*atan((-S(2)*x + sqrt(-sqrt(S(3)) + S(2)))/sqrt(sqrt(S(3)) + S(2)))/S(4) + sqrt(sqrt(S(3))/S(3) + S(2)/3)*atan((S(2)*x + sqrt(-sqrt(S(3)) + S(2)))/sqrt(sqrt(S(3)) + S(2)))/S(4) - S(1)/(S(3)*x**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(6)*(x**S(8) - x**S(4) + S(1))), x), x, -sqrt(S(6))*log(x**S(2) - x*sqrt(-sqrt(S(3)) + S(2)) + S(1))/S(24) + sqrt(S(6))*log(x**S(2) + x*sqrt(-sqrt(S(3)) + S(2)) + S(1))/S(24) - sqrt(S(6))*log(x**S(2) - x*sqrt(sqrt(S(3)) + S(2)) + S(1))/S(24) + sqrt(S(6))*log(x**S(2) + x*sqrt(sqrt(S(3)) + S(2)) + S(1))/S(24) + sqrt(S(6))*atan((-S(2)*x + sqrt(sqrt(S(3)) + S(2)))/sqrt(-sqrt(S(3)) + S(2)))/S(12) - sqrt(S(6))*atan((S(2)*x + sqrt(sqrt(S(3)) + S(2)))/sqrt(-sqrt(S(3)) + S(2)))/S(12) + sqrt(S(6))*atan((-S(2)*x + sqrt(-sqrt(S(3)) + S(2)))/sqrt(sqrt(S(3)) + S(2)))/S(12) - sqrt(S(6))*atan((S(2)*x + sqrt(-sqrt(S(3)) + S(2)))/sqrt(sqrt(S(3)) + S(2)))/S(12) - S(1)/x - S(1)/(S(5)*x**S(5)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(8)*(x**S(8) - x**S(4) + S(1))), x), x, sqrt(sqrt(S(3))/S(3) + S(2)/3)*log(x**S(2) - x*sqrt(-sqrt(S(3)) + S(2)) + S(1))/S(8) - sqrt(sqrt(S(3))/S(3) + S(2)/3)*log(x**S(2) + x*sqrt(-sqrt(S(3)) + S(2)) + S(1))/S(8) - sqrt(-sqrt(S(3))/S(3) + S(2)/3)*log(x**S(2) - x*sqrt(sqrt(S(3)) + S(2)) + S(1))/S(8) + sqrt(-sqrt(S(3))/S(3) + S(2)/3)*log(x**S(2) + x*sqrt(sqrt(S(3)) + S(2)) + S(1))/S(8) + sqrt(sqrt(S(3))/S(3) + S(2)/3)*atan((-S(2)*x + sqrt(sqrt(S(3)) + S(2)))/sqrt(-sqrt(S(3)) + S(2)))/S(4) - sqrt(sqrt(S(3))/S(3) + S(2)/3)*atan((S(2)*x + sqrt(sqrt(S(3)) + S(2)))/sqrt(-sqrt(S(3)) + S(2)))/S(4) - sqrt(-sqrt(S(3))/S(3) + S(2)/3)*atan((-S(2)*x + sqrt(-sqrt(S(3)) + S(2)))/sqrt(sqrt(S(3)) + S(2)))/S(4) + sqrt(-sqrt(S(3))/S(3) + S(2)/3)*atan((S(2)*x + sqrt(-sqrt(S(3)) + S(2)))/sqrt(sqrt(S(3)) + S(2)))/S(4) - S(1)/(S(3)*x**S(3)) - S(1)/(S(7)*x**S(7)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**m/(x**S(8) + S(3)*x**S(4) + S(1)), x), x, S(2)*sqrt(S(5))*x**(m + S(1))*hyper((S(1), m/S(4) + S(1)/4), (m/S(4) + S(5)/4,), -S(2)*x**S(4)/(-sqrt(S(5)) + S(3)))/(S(5)*(-sqrt(S(5)) + S(3))*(m + S(1))) - S(2)*sqrt(S(5))*x**(m + S(1))*hyper((S(1), m/S(4) + S(1)/4), (m/S(4) + S(5)/4,), -S(2)*x**S(4)/(sqrt(S(5)) + S(3)))/(S(5)*(sqrt(S(5)) + S(3))*(m + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(11)/(x**S(8) + S(3)*x**S(4) + S(1)), x), x, x**S(4)/S(4) - (-S(7)*sqrt(S(5))/S(40) + S(3)/8)*log(S(2)*x**S(4) - sqrt(S(5)) + S(3)) - (S(3)/8 + S(7)*sqrt(S(5))/S(40))*log(S(2)*x**S(4) + sqrt(S(5)) + S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(9)/(x**S(8) + S(3)*x**S(4) + S(1)), x), x, x**S(2)/S(2) + sqrt(-S(4)*sqrt(S(5))/S(5) + S(9)/5)*atan(x**S(2)*sqrt(sqrt(S(5))/S(2) + S(3)/2))/S(2) - sqrt(S(4)*sqrt(S(5))/S(5) + S(9)/5)*atan(sqrt(S(2))*x**S(2)/sqrt(sqrt(S(5)) + S(3)))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(7)/(x**S(8) + S(3)*x**S(4) + S(1)), x), x, (-S(3)*sqrt(S(5))/S(40) + S(1)/8)*log(S(2)*x**S(4) - sqrt(S(5)) + S(3)) + (S(1)/8 + S(3)*sqrt(S(5))/S(40))*log(S(2)*x**S(4) + sqrt(S(5)) + S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)/(x**S(8) + S(3)*x**S(4) + S(1)), x), x, -sqrt(-sqrt(S(5))/S(10) + S(3)/10)*atan(x**S(2)*sqrt(sqrt(S(5))/S(2) + S(3)/2))/S(2) + sqrt(sqrt(S(5))/S(10) + S(3)/10)*atan(sqrt(S(2))*x**S(2)/sqrt(sqrt(S(5)) + S(3)))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/(x**S(8) + S(3)*x**S(4) + S(1)), x), x, -sqrt(S(5))*atanh(sqrt(S(5))*(S(2)*x**S(4) + S(3))/S(5))/S(10), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(x**S(8) + S(3)*x**S(4) + S(1)), x), x, sqrt(sqrt(S(5))/S(10) + S(3)/10)*atan(x**S(2)*sqrt(sqrt(S(5))/S(2) + S(3)/2))/S(2) - atan(sqrt(S(2))*x**S(2)/sqrt(sqrt(S(5)) + S(3)))/sqrt(S(10)*sqrt(S(5)) + S(30)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*(x**S(8) + S(3)*x**S(4) + S(1))), x), x, log(x) - (S(1)/8 + S(3)*sqrt(S(5))/S(40))*log(S(2)*x**S(4) - sqrt(S(5)) + S(3)) - (-S(3)*sqrt(S(5))/S(40) + S(1)/8)*log(S(2)*x**S(4) + sqrt(S(5)) + S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(3)*(x**S(8) + S(3)*x**S(4) + S(1))), x), x, -sqrt(S(10))*(sqrt(S(5)) + S(3))**(S(3)/2)*atan(x**S(2)*sqrt(sqrt(S(5))/S(2) + S(3)/2))/S(40) + sqrt(-S(4)*sqrt(S(5))/S(5) + S(9)/5)*atan(sqrt(S(2))*x**S(2)/sqrt(sqrt(S(5)) + S(3)))/S(2) - S(1)/(S(2)*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(5)*(x**S(8) + S(3)*x**S(4) + S(1))), x), x, -S(3)*log(x) + (S(3)/8 + S(7)*sqrt(S(5))/S(40))*log(S(2)*x**S(4) - sqrt(S(5)) + S(3)) + (-S(7)*sqrt(S(5))/S(40) + S(3)/8)*log(S(2)*x**S(4) + sqrt(S(5)) + S(3)) - S(1)/(S(4)*x**S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(7)*(x**S(8) + S(3)*x**S(4) + S(1))), x), x, sqrt(S(11)*sqrt(S(5))/S(2) + S(123)/10)*atan(x**S(2)*sqrt(sqrt(S(5))/S(2) + S(3)/2))/S(2) - sqrt(-S(11)*sqrt(S(5))/S(2) + S(123)/10)*atan(sqrt(S(2))*x**S(2)/sqrt(sqrt(S(5)) + S(3)))/S(2) + S(3)/(S(2)*x**S(2)) - S(1)/(S(6)*x**S(6)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**m/(x**S(8) - S(3)*x**S(4) + S(1)), x), x, S(2)*sqrt(S(5))*x**(m + S(1))*hyper((S(1), m/S(4) + S(1)/4), (m/S(4) + S(5)/4,), S(2)*x**S(4)/(-sqrt(S(5)) + S(3)))/(S(5)*(-sqrt(S(5)) + S(3))*(m + S(1))) - S(2)*sqrt(S(5))*x**(m + S(1))*hyper((S(1), m/S(4) + S(1)/4), (m/S(4) + S(5)/4,), S(2)*x**S(4)/(sqrt(S(5)) + S(3)))/(S(5)*(sqrt(S(5)) + S(3))*(m + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(11)/(x**S(8) - S(3)*x**S(4) + S(1)), x), x, x**S(4)/S(4) + (-S(7)*sqrt(S(5))/S(40) + S(3)/8)*log(-S(2)*x**S(4) - sqrt(S(5)) + S(3)) + (S(3)/8 + S(7)*sqrt(S(5))/S(40))*log(-S(2)*x**S(4) + sqrt(S(5)) + S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(9)/(x**S(8) - S(3)*x**S(4) + S(1)), x), x, x**S(2)/S(2) + sqrt(-S(4)*sqrt(S(5))/S(5) + S(9)/5)*atanh(x**S(2)*sqrt(sqrt(S(5))/S(2) + S(3)/2))/S(2) - sqrt(S(4)*sqrt(S(5))/S(5) + S(9)/5)*atanh(sqrt(S(2))*x**S(2)/sqrt(sqrt(S(5)) + S(3)))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(7)/(x**S(8) - S(3)*x**S(4) + S(1)), x), x, (-S(3)*sqrt(S(5))/S(40) + S(1)/8)*log(-S(2)*x**S(4) - sqrt(S(5)) + S(3)) + (S(1)/8 + S(3)*sqrt(S(5))/S(40))*log(-S(2)*x**S(4) + sqrt(S(5)) + S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)/(x**S(8) - S(3)*x**S(4) + S(1)), x), x, sqrt(-sqrt(S(5))/S(10) + S(3)/10)*atanh(x**S(2)*sqrt(sqrt(S(5))/S(2) + S(3)/2))/S(2) - sqrt(sqrt(S(5))/S(10) + S(3)/10)*atanh(sqrt(S(2))*x**S(2)/sqrt(sqrt(S(5)) + S(3)))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/(x**S(8) - S(3)*x**S(4) + S(1)), x), x, sqrt(S(5))*atanh(sqrt(S(5))*(-S(2)*x**S(4) + S(3))/S(5))/S(10), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(x**S(8) - S(3)*x**S(4) + S(1)), x), x, sqrt(sqrt(S(5))/S(10) + S(3)/10)*atanh(x**S(2)*sqrt(sqrt(S(5))/S(2) + S(3)/2))/S(2) - atanh(sqrt(S(2))*x**S(2)/sqrt(sqrt(S(5)) + S(3)))/sqrt(S(10)*sqrt(S(5)) + S(30)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*(x**S(8) - S(3)*x**S(4) + S(1))), x), x, log(x) - (S(1)/8 + S(3)*sqrt(S(5))/S(40))*log(-S(2)*x**S(4) - sqrt(S(5)) + S(3)) - (-S(3)*sqrt(S(5))/S(40) + S(1)/8)*log(-S(2)*x**S(4) + sqrt(S(5)) + S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(3)*(x**S(8) - S(3)*x**S(4) + S(1))), x), x, sqrt(S(10))*(sqrt(S(5)) + S(3))**(S(3)/2)*atanh(x**S(2)*sqrt(sqrt(S(5))/S(2) + S(3)/2))/S(40) - sqrt(-S(4)*sqrt(S(5))/S(5) + S(9)/5)*atanh(sqrt(S(2))*x**S(2)/sqrt(sqrt(S(5)) + S(3)))/S(2) - S(1)/(S(2)*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(5)*(x**S(8) - S(3)*x**S(4) + S(1))), x), x, S(3)*log(x) - (S(3)/8 + S(7)*sqrt(S(5))/S(40))*log(-S(2)*x**S(4) - sqrt(S(5)) + S(3)) - (-S(7)*sqrt(S(5))/S(40) + S(3)/8)*log(-S(2)*x**S(4) + sqrt(S(5)) + S(3)) - S(1)/(S(4)*x**S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(7)*(x**S(8) - S(3)*x**S(4) + S(1))), x), x, sqrt(S(11)*sqrt(S(5))/S(2) + S(123)/10)*atanh(x**S(2)*sqrt(sqrt(S(5))/S(2) + S(3)/2))/S(2) - sqrt(-S(11)*sqrt(S(5))/S(2) + S(123)/10)*atanh(sqrt(S(2))*x**S(2)/sqrt(sqrt(S(5)) + S(3)))/S(2) - S(3)/(S(2)*x**S(2)) - S(1)/(S(6)*x**S(6)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(8)/(x**S(8) - S(3)*x**S(4) + S(1)), x), x, x + sqrt(S(5))*(-S(440)*sqrt(S(5)) + S(984))**(S(1)/4)*atan(x*(sqrt(S(5))/S(2) + S(3)/2)**(S(1)/4))/S(20) - sqrt(S(5))*(S(55)*sqrt(S(5))/S(2) + S(123)/2)**(S(1)/4)*atan(S(2)**(S(1)/4)*x/(sqrt(S(5)) + S(3))**(S(1)/4))/S(10) + sqrt(S(5))*(-S(440)*sqrt(S(5)) + S(984))**(S(1)/4)*atanh(x*(sqrt(S(5))/S(2) + S(3)/2)**(S(1)/4))/S(20) - sqrt(S(5))*(S(55)*sqrt(S(5))/S(2) + S(123)/2)**(S(1)/4)*atanh(S(2)**(S(1)/4)*x/(sqrt(S(5)) + S(3))**(S(1)/4))/S(10), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(6)/(x**S(8) - S(3)*x**S(4) + S(1)), x), x, -sqrt(S(5))*(-S(64)*sqrt(S(5)) + S(144))**(S(1)/4)*atan(x*(sqrt(S(5))/S(2) + S(3)/2)**(S(1)/4))/S(20) + S(2)**(S(1)/4)*sqrt(S(5))*(sqrt(S(5)) + S(3))**(S(3)/4)*atan(S(2)**(S(1)/4)*x/(sqrt(S(5)) + S(3))**(S(1)/4))/S(20) + sqrt(S(5))*(-S(64)*sqrt(S(5)) + S(144))**(S(1)/4)*atanh(x*(sqrt(S(5))/S(2) + S(3)/2)**(S(1)/4))/S(20) - S(2)**(S(1)/4)*sqrt(S(5))*(sqrt(S(5)) + S(3))**(S(3)/4)*atanh(S(2)**(S(1)/4)*x/(sqrt(S(5)) + S(3))**(S(1)/4))/S(20), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)/(x**S(8) - S(3)*x**S(4) + S(1)), x), x, sqrt(S(5))*(-sqrt(S(5))/S(2) + S(3)/2)**(S(1)/4)*atan(x*(sqrt(S(5))/S(2) + S(3)/2)**(S(1)/4))/S(10) - sqrt(S(5))*(sqrt(S(5))/S(2) + S(3)/2)**(S(1)/4)*atan(S(2)**(S(1)/4)*x/(sqrt(S(5)) + S(3))**(S(1)/4))/S(10) + sqrt(S(5))*(-sqrt(S(5))/S(2) + S(3)/2)**(S(1)/4)*atanh(x*(sqrt(S(5))/S(2) + S(3)/2)**(S(1)/4))/S(10) - sqrt(S(5))*(sqrt(S(5))/S(2) + S(3)/2)**(S(1)/4)*atanh(S(2)**(S(1)/4)*x/(sqrt(S(5)) + S(3))**(S(1)/4))/S(10), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/(x**S(8) - S(3)*x**S(4) + S(1)), x), x, sqrt(S(-10) + S(10)*sqrt(S(5)))*atan(x*sqrt(S(-2) + S(2)*sqrt(S(5)))/S(2))/S(20) - sqrt(S(10) + S(10)*sqrt(S(5)))*atan(x*sqrt(S(2) + S(2)*sqrt(S(5)))/S(2))/S(20) - sqrt(S(-10) + S(10)*sqrt(S(5)))*atanh(x*sqrt(S(-2) + S(2)*sqrt(S(5)))/S(2))/S(20) + sqrt(S(10) + S(10)*sqrt(S(5)))*atanh(x*sqrt(S(2) + S(2)*sqrt(S(5)))/S(2))/S(20), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate(x**S(2)/(x**S(8) - S(3)*x**S(4) + S(1)), x), x, -sqrt(S(5))*(sqrt(S(5))/S(2) + S(3)/2)**(S(1)/4)*atan(x*(sqrt(S(5))/S(2) + S(3)/2)**(S(1)/4))/S(10) + S(2)**(S(1)/4)*sqrt(S(5))*atan(S(2)**(S(1)/4)*x/(sqrt(S(5)) + S(3))**(S(1)/4))/(S(10)*(sqrt(S(5)) + S(3))**(S(1)/4)) + sqrt(S(5))*(sqrt(S(5))/S(2) + S(3)/2)**(S(1)/4)*atanh(x*(sqrt(S(5))/S(2) + S(3)/2)**(S(1)/4))/S(10) - S(2)**(S(1)/4)*sqrt(S(5))*atanh(S(2)**(S(1)/4)*x/(sqrt(S(5)) + S(3))**(S(1)/4))/(S(10)*(sqrt(S(5)) + S(3))**(S(1)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*(x**S(8) - S(3)*x**S(4) + S(1))), x), x, -S(2)**(S(3)/4)*sqrt(S(5))*(sqrt(S(5)) + S(3))**(S(5)/4)*atan(x*(sqrt(S(5))/S(2) + S(3)/2)**(S(1)/4))/S(40) + sqrt(S(5))*(-S(440)*sqrt(S(5)) + S(984))**(S(1)/4)*atan(S(2)**(S(1)/4)*x/(sqrt(S(5)) + S(3))**(S(1)/4))/S(20) + S(2)**(S(3)/4)*sqrt(S(5))*(sqrt(S(5)) + S(3))**(S(5)/4)*atanh(x*(sqrt(S(5))/S(2) + S(3)/2)**(S(1)/4))/S(40) - sqrt(S(5))*(-S(440)*sqrt(S(5)) + S(984))**(S(1)/4)*atanh(S(2)**(S(1)/4)*x/(sqrt(S(5)) + S(3))**(S(1)/4))/S(20) - S(1)/x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(6)*(x**S(8) - S(3)*x**S(4) + S(1))), x), x, -sqrt(S(5))*(S(1292)*sqrt(S(5)) + S(2889))**(S(1)/4)*atan(x*(sqrt(S(5))/S(2) + S(3)/2)**(S(1)/4))/S(10) + sqrt(S(5))*(-S(1292)*sqrt(S(5)) + S(2889))**(S(1)/4)*atan(S(2)**(S(1)/4)*x/(sqrt(S(5)) + S(3))**(S(1)/4))/S(10) + sqrt(S(5))*(S(1292)*sqrt(S(5)) + S(2889))**(S(1)/4)*atanh(x*(sqrt(S(5))/S(2) + S(3)/2)**(S(1)/4))/S(10) - sqrt(S(5))*(-S(1292)*sqrt(S(5)) + S(2889))**(S(1)/4)*atanh(S(2)**(S(1)/4)*x/(sqrt(S(5)) + S(3))**(S(1)/4))/S(10) - S(3)/x - S(1)/(S(5)*x**S(5)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(8)*(x**S(8) - S(3)*x**S(4) + S(1))), x), x, sqrt(S(5))*(S(17711)*sqrt(S(5))/S(2) + S(39603)/2)**(S(1)/4)*atan(x*(sqrt(S(5))/S(2) + S(3)/2)**(S(1)/4))/S(10) - sqrt(S(5))*(-S(17711)*sqrt(S(5))/S(2) + S(39603)/2)**(S(1)/4)*atan(S(2)**(S(1)/4)*x/(sqrt(S(5)) + S(3))**(S(1)/4))/S(10) + sqrt(S(5))*(S(17711)*sqrt(S(5))/S(2) + S(39603)/2)**(S(1)/4)*atanh(x*(sqrt(S(5))/S(2) + S(3)/2)**(S(1)/4))/S(10) - sqrt(S(5))*(-S(17711)*sqrt(S(5))/S(2) + S(39603)/2)**(S(1)/4)*atanh(S(2)**(S(1)/4)*x/(sqrt(S(5)) + S(3))**(S(1)/4))/S(10) - S(1)/x**S(3) - S(1)/(S(7)*x**S(7)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/(x**S(8) + S(3)*x**S(4) + S(2)), x), x, -atanh(S(2)*x**S(4) + S(3))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(11)/(x**S(8) + S(3)*x**S(4) + S(2)), x), x, x**S(4)/S(4) + log(x**S(4) + S(1))/S(4) - log(x**S(4) + S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(9)/(x**S(10) + x**S(5) + S(2)), x), x, log(x**S(10) + x**S(5) + S(2))/S(10) - sqrt(S(7))*atan(sqrt(S(7))*(S(2)*x**S(5) + S(1))/S(7))/S(35), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)/(x**S(10) + x**S(5) + S(2)), x), x, S(2)*sqrt(S(7))*atan(sqrt(S(7))*(S(2)*x**S(5) + S(1))/S(7))/S(35), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*(x**S(10) + x**S(5) + S(1))), x), x, log(x) - log(x**S(10) + x**S(5) + S(1))/S(10) - sqrt(S(3))*atan(sqrt(S(3))*(S(2)*x**S(5) + S(1))/S(3))/S(15), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(6)*(x**S(10) + x**S(5) + S(1))), x), x, -log(x) + log(x**S(10) + x**S(5) + S(1))/S(10) - sqrt(S(3))*atan(sqrt(S(3))*(S(2)*x**S(5) + S(1))/S(3))/S(15) - S(1)/(S(5)*x**S(5)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(11) + x**S(6) + x), x), x, log(x) - log(x**S(10) + x**S(5) + S(1))/S(10) - sqrt(S(3))*atan(sqrt(S(3))*(S(2)*x**S(5) + S(1))/S(3))/S(15), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/(a/x**S(2) + b/x + c), x), x, -b*x**S(3)/(S(3)*c**S(2)) - b*x*(-S(2)*a*c + b**S(2))/c**S(4) + b*(S(5)*a**S(2)*c**S(2) - S(5)*a*b**S(2)*c + b**S(4))*atanh((b + S(2)*c*x)/sqrt(-S(4)*a*c + b**S(2)))/(c**S(5)*sqrt(-S(4)*a*c + b**S(2))) + x**S(4)/(S(4)*c) + x**S(2)*(-a*c + b**S(2))/(S(2)*c**S(3)) + (a**S(2)*c**S(2) - S(3)*a*b**S(2)*c + b**S(4))*log(a + b*x + c*x**S(2))/(S(2)*c**S(5)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/(a/x**S(2) + b/x + c), x), x, -b*x**S(2)/(S(2)*c**S(2)) - b*(-S(2)*a*c + b**S(2))*log(a + b*x + c*x**S(2))/(S(2)*c**S(4)) + x**S(3)/(S(3)*c) + x*(-a*c + b**S(2))/c**S(3) - (S(2)*a**S(2)*c**S(2) - S(4)*a*b**S(2)*c + b**S(4))*atanh((b + S(2)*c*x)/sqrt(-S(4)*a*c + b**S(2)))/(c**S(4)*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(a/x**S(2) + b/x + c), x), x, -b*x/c**S(2) + b*(-S(3)*a*c + b**S(2))*atanh((b + S(2)*c*x)/sqrt(-S(4)*a*c + b**S(2)))/(c**S(3)*sqrt(-S(4)*a*c + b**S(2))) + x**S(2)/(S(2)*c) + (-a*c + b**S(2))*log(a + b*x + c*x**S(2))/(S(2)*c**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(a/x**S(2) + b/x + c), x), x, -b*log(a + b*x + c*x**S(2))/(S(2)*c**S(2)) + x/c - (-S(2)*a*c + b**S(2))*atanh((b + S(2)*c*x)/sqrt(-S(4)*a*c + b**S(2)))/(c**S(2)*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*(a/x**S(2) + b/x + c)), x), x, b*atanh((b + S(2)*c*x)/sqrt(-S(4)*a*c + b**S(2)))/(c*sqrt(-S(4)*a*c + b**S(2))) + log(a + b*x + c*x**S(2))/(S(2)*c), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*(a/x**S(2) + b/x + c)), x), x, S(2)*atanh((S(2)*a/x + b)/sqrt(-S(4)*a*c + b**S(2)))/sqrt(-S(4)*a*c + b**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(3)*(a/x**S(2) + b/x + c)), x), x, b*atanh((b + S(2)*c*x)/sqrt(-S(4)*a*c + b**S(2)))/(a*sqrt(-S(4)*a*c + b**S(2))) + log(x)/a - log(a + b*x + c*x**S(2))/(S(2)*a), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(4)*(a/x**S(2) + b/x + c)), x), x, -S(1)/(a*x) - b*log(x)/a**S(2) + b*log(a + b*x + c*x**S(2))/(S(2)*a**S(2)) - (-S(2)*a*c + b**S(2))*atanh((b + S(2)*c*x)/sqrt(-S(4)*a*c + b**S(2)))/(a**S(2)*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(5)*(a/x**S(2) + b/x + c)), x), x, -S(1)/(S(2)*a*x**S(2)) + b/(a**S(2)*x) + b*(-S(3)*a*c + b**S(2))*atanh((b + S(2)*c*x)/sqrt(-S(4)*a*c + b**S(2)))/(a**S(3)*sqrt(-S(4)*a*c + b**S(2))) + (-a*c + b**S(2))*log(x)/a**S(3) - (-a*c + b**S(2))*log(a + b*x + c*x**S(2))/(S(2)*a**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(6)*(a/x**S(2) + b/x + c)), x), x, -S(1)/(S(3)*a*x**S(3)) + b/(S(2)*a**S(2)*x**S(2)) - (-a*c + b**S(2))/(a**S(3)*x) - b*(-S(2)*a*c + b**S(2))*log(x)/a**S(4) + b*(-S(2)*a*c + b**S(2))*log(a + b*x + c*x**S(2))/(S(2)*a**S(4)) - (S(2)*a**S(2)*c**S(2) - S(4)*a*b**S(2)*c + b**S(4))*atanh((b + S(2)*c*x)/sqrt(-S(4)*a*c + b**S(2)))/(a**S(4)*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(a/x**S(2) + b/x + c)**S(2), x), x, -b*x**S(3)/(c*(-S(4)*a*c + b**S(2))) - b*x*(-S(11)*a*c + S(3)*b**S(2))/(c**S(3)*(-S(4)*a*c + b**S(2))) + b*(S(30)*a**S(2)*c**S(2) - S(20)*a*b**S(2)*c + S(3)*b**S(4))*atanh((b + S(2)*c*x)/sqrt(-S(4)*a*c + b**S(2)))/(c**S(4)*(-S(4)*a*c + b**S(2))**(S(3)/2)) + x**S(4)*(S(2)*a + b*x)/((-S(4)*a*c + b**S(2))*(a + b*x + c*x**S(2))) + x**S(2)*(-S(8)*a*c + S(3)*b**S(2))/(S(2)*c**S(2)*(-S(4)*a*c + b**S(2))) + (-S(2)*a*c + S(3)*b**S(2))*log(a + b*x + c*x**S(2))/(S(2)*c**S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a/x**S(2) + b/x + c)**(S(-2)), x), x, -b*x**S(2)/(c*(-S(4)*a*c + b**S(2))) - b*log(a + b*x + c*x**S(2))/c**S(3) + x**S(3)*(S(2)*a + b*x)/((-S(4)*a*c + b**S(2))*(a + b*x + c*x**S(2))) + x*(-S(6)*a*c + S(2)*b**S(2))/(c**S(2)*(-S(4)*a*c + b**S(2))) - (S(12)*a**S(2)*c**S(2) - S(12)*a*b**S(2)*c + S(2)*b**S(4))*atanh((b + S(2)*c*x)/sqrt(-S(4)*a*c + b**S(2)))/(c**S(3)*(-S(4)*a*c + b**S(2))**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*(a/x**S(2) + b/x + c)**S(2)), x), x, -b*x/(c*(-S(4)*a*c + b**S(2))) + b*(-S(6)*a*c + b**S(2))*atanh((b + S(2)*c*x)/sqrt(-S(4)*a*c + b**S(2)))/(c**S(2)*(-S(4)*a*c + b**S(2))**(S(3)/2)) + x**S(2)*(S(2)*a + b*x)/((-S(4)*a*c + b**S(2))*(a + b*x + c*x**S(2))) + log(a + b*x + c*x**S(2))/(S(2)*c**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*(a/x**S(2) + b/x + c)**S(2)), x), x, -S(4)*a*atanh((S(2)*a/x + b)/sqrt(-S(4)*a*c + b**S(2)))/(-S(4)*a*c + b**S(2))**(S(3)/2) + (S(2)*a/x + b)/((-S(4)*a*c + b**S(2))*(a/x**S(2) + b/x + c)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(3)*(a/x**S(2) + b/x + c)**S(2)), x), x, -S(2)*b*atanh((b + S(2)*c*x)/sqrt(-S(4)*a*c + b**S(2)))/(-S(4)*a*c + b**S(2))**(S(3)/2) + (S(2)*a + b*x)/((-S(4)*a*c + b**S(2))*(a + b*x + c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(4)*(a/x**S(2) + b/x + c)**S(2)), x), x, S(4)*c*atanh((b + S(2)*c*x)/sqrt(-S(4)*a*c + b**S(2)))/(-S(4)*a*c + b**S(2))**(S(3)/2) - (b + S(2)*c*x)/((-S(4)*a*c + b**S(2))*(a + b*x + c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(5)*(a/x**S(2) + b/x + c)**S(2)), x), x, (-S(2)*a*c + b**S(2) + b*c*x)/(a*(-S(4)*a*c + b**S(2))*(a + b*x + c*x**S(2))) + b*(-S(6)*a*c + b**S(2))*atanh((b + S(2)*c*x)/sqrt(-S(4)*a*c + b**S(2)))/(a**S(2)*(-S(4)*a*c + b**S(2))**(S(3)/2)) + log(x)/a**S(2) - log(a + b*x + c*x**S(2))/(S(2)*a**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(6)*(a/x**S(2) + b/x + c)**S(2)), x), x, (-S(2)*a*c + b**S(2) + b*c*x)/(a*x*(-S(4)*a*c + b**S(2))*(a + b*x + c*x**S(2))) + (S(6)*a*c - S(2)*b**S(2))/(a**S(2)*x*(-S(4)*a*c + b**S(2))) - S(2)*b*log(x)/a**S(3) + b*log(a + b*x + c*x**S(2))/a**S(3) - (S(12)*a**S(2)*c**S(2) - S(12)*a*b**S(2)*c + S(2)*b**S(4))*atanh((b + S(2)*c*x)/sqrt(-S(4)*a*c + b**S(2)))/(a**S(3)*(-S(4)*a*c + b**S(2))**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(7)*(a/x**S(2) + b/x + c)**S(2)), x), x, (-S(2)*a*c + b**S(2) + b*c*x)/(a*x**S(2)*(-S(4)*a*c + b**S(2))*(a + b*x + c*x**S(2))) - (-S(8)*a*c + S(3)*b**S(2))/(S(2)*a**S(2)*x**S(2)*(-S(4)*a*c + b**S(2))) + b*(-S(11)*a*c + S(3)*b**S(2))/(a**S(3)*x*(-S(4)*a*c + b**S(2))) + b*(S(30)*a**S(2)*c**S(2) - S(20)*a*b**S(2)*c + S(3)*b**S(4))*atanh((b + S(2)*c*x)/sqrt(-S(4)*a*c + b**S(2)))/(a**S(4)*(-S(4)*a*c + b**S(2))**(S(3)/2)) + (-S(2)*a*c + S(3)*b**S(2))*log(x)/a**S(4) - (-S(2)*a*c + S(3)*b**S(2))*log(a + b*x + c*x**S(2))/(S(2)*a**S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a/x**S(2) + b/x + c)**(S(-3)), x), x, -S(3)*b*x**S(2)*(-S(6)*a*c + b**S(2))/(S(2)*c**S(2)*(-S(4)*a*c + b**S(2))**S(2)) - S(3)*b*log(a + b*x + c*x**S(2))/(S(2)*c**S(4)) + x**S(5)*(S(2)*a + b*x)/((-S(8)*a*c + S(2)*b**S(2))*(a + b*x + c*x**S(2))**S(2)) + x**S(3)*(a*(-S(10)*a*c + b**S(2)) + b*x*(-S(7)*a*c + b**S(2)))/(c*(-S(4)*a*c + b**S(2))**S(2)*(a + b*x + c*x**S(2))) + x*(S(30)*a**S(2)*c**S(2) - S(21)*a*b**S(2)*c + S(3)*b**S(4))/(c**S(3)*(-S(4)*a*c + b**S(2))**S(2)) - (-S(60)*a**S(3)*c**S(3) + S(90)*a**S(2)*b**S(2)*c**S(2) - S(30)*a*b**S(4)*c + S(3)*b**S(6))*atanh((b + S(2)*c*x)/sqrt(-S(4)*a*c + b**S(2)))/(c**S(4)*(-S(4)*a*c + b**S(2))**(S(5)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*(a/x**S(2) + b/x + c)**S(3)), x), x, -b*x*(-S(7)*a*c + b**S(2))/(c**S(2)*(-S(4)*a*c + b**S(2))**S(2)) + b*(S(30)*a**S(2)*c**S(2) - S(10)*a*b**S(2)*c + b**S(4))*atanh((b + S(2)*c*x)/sqrt(-S(4)*a*c + b**S(2)))/(c**S(3)*(-S(4)*a*c + b**S(2))**(S(5)/2)) + x**S(4)*(S(2)*a + b*x)/((-S(8)*a*c + S(2)*b**S(2))*(a + b*x + c*x**S(2))**S(2)) + x**S(2)*(a*(-S(16)*a*c + b**S(2)) + b*x*(-S(10)*a*c + b**S(2)))/(S(2)*c*(-S(4)*a*c + b**S(2))**S(2)*(a + b*x + c*x**S(2))) + log(a + b*x + c*x**S(2))/(S(2)*c**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*(a/x**S(2) + b/x + c)**S(3)), x), x, S(12)*a**S(2)*atanh((S(2)*a/x + b)/sqrt(-S(4)*a*c + b**S(2)))/(-S(4)*a*c + b**S(2))**(S(5)/2) - S(3)*a*(S(2)*a/x + b)/((-S(4)*a*c + b**S(2))**S(2)*(a/x**S(2) + b/x + c)) + (S(2)*a/x + b)/((-S(8)*a*c + S(2)*b**S(2))*(a/x**S(2) + b/x + c)**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(3)*(a/x**S(2) + b/x + c)**S(3)), x), x, S(6)*a*b*atanh((b + S(2)*c*x)/sqrt(-S(4)*a*c + b**S(2)))/(-S(4)*a*c + b**S(2))**(S(5)/2) + S(3)*b*x*(S(2)*a + b*x)/(S(2)*(-S(4)*a*c + b**S(2))**S(2)*(a + b*x + c*x**S(2))) - x**S(3)*(b + S(2)*c*x)/((-S(8)*a*c + S(2)*b**S(2))*(a + b*x + c*x**S(2))**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(4)*(a/x**S(2) + b/x + c)**S(3)), x), x, x*(S(2)*a + b*x)/((-S(8)*a*c + S(2)*b**S(2))*(a + b*x + c*x**S(2))**S(2)) + (S(3)*a*b + x*(S(2)*a*c + b**S(2)))/((-S(4)*a*c + b**S(2))**S(2)*(a + b*x + c*x**S(2))) - (S(4)*a*c + S(2)*b**S(2))*atanh((b + S(2)*c*x)/sqrt(-S(4)*a*c + b**S(2)))/(-S(4)*a*c + b**S(2))**(S(5)/2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(5)*(a/x**S(2) + b/x + c)**S(3)), x), x, S(6)*b*c*atanh((b + S(2)*c*x)/sqrt(-S(4)*a*c + b**S(2)))/(-S(4)*a*c + b**S(2))**(S(5)/2) - S(3)*b*(b + S(2)*c*x)/(S(2)*(-S(4)*a*c + b**S(2))**S(2)*(a + b*x + c*x**S(2))) + (S(2)*a + b*x)/((-S(8)*a*c + S(2)*b**S(2))*(a + b*x + c*x**S(2))**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(6)*(a/x**S(2) + b/x + c)**S(3)), x), x, -S(12)*c**S(2)*atanh((b + S(2)*c*x)/sqrt(-S(4)*a*c + b**S(2)))/(-S(4)*a*c + b**S(2))**(S(5)/2) + S(3)*c*(b + S(2)*c*x)/((-S(4)*a*c + b**S(2))**S(2)*(a + b*x + c*x**S(2))) + (-b - S(2)*c*x)/((-S(8)*a*c + S(2)*b**S(2))*(a + b*x + c*x**S(2))**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(7)*(a/x**S(2) + b/x + c)**S(3)), x), x, (-S(2)*a*c + b**S(2) + b*c*x)/(S(2)*a*(-S(4)*a*c + b**S(2))*(a + b*x + c*x**S(2))**S(2)) + (S(16)*a**S(2)*c**S(2) - S(15)*a*b**S(2)*c + S(2)*b**S(4) + S(2)*b*c*x*(-S(7)*a*c + b**S(2)))/(S(2)*a**S(2)*(-S(4)*a*c + b**S(2))**S(2)*(a + b*x + c*x**S(2))) + b*(S(30)*a**S(2)*c**S(2) - S(10)*a*b**S(2)*c + b**S(4))*atanh((b + S(2)*c*x)/sqrt(-S(4)*a*c + b**S(2)))/(a**S(3)*(-S(4)*a*c + b**S(2))**(S(5)/2)) + log(x)/a**S(3) - log(a + b*x + c*x**S(2))/(S(2)*a**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(8)*(a/x**S(2) + b/x + c)**S(3)), x), x, (-S(2)*a*c + b**S(2) + b*c*x)/(S(2)*a*x*(-S(4)*a*c + b**S(2))*(a + b*x + c*x**S(2))**S(2)) + (S(20)*a**S(2)*c**S(2) - S(20)*a*b**S(2)*c + S(3)*b**S(4) + S(3)*b*c*x*(-S(6)*a*c + b**S(2)))/(S(2)*a**S(2)*x*(-S(4)*a*c + b**S(2))**S(2)*(a + b*x + c*x**S(2))) - (S(30)*a**S(2)*c**S(2) - S(21)*a*b**S(2)*c + S(3)*b**S(4))/(a**S(3)*x*(-S(4)*a*c + b**S(2))**S(2)) - S(3)*b*log(x)/a**S(4) + S(3)*b*log(a + b*x + c*x**S(2))/(S(2)*a**S(4)) - (-S(60)*a**S(3)*c**S(3) + S(90)*a**S(2)*b**S(2)*c**S(2) - S(30)*a*b**S(4)*c + S(3)*b**S(6))*atanh((b + S(2)*c*x)/sqrt(-S(4)*a*c + b**S(2)))/(a**S(4)*(-S(4)*a*c + b**S(2))**(S(5)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/(S(15) + S(13)/x + S(2)/x**S(2)), x), x, x**S(3)/S(45) - S(13)*x**S(2)/S(450) + S(139)*x/S(3375) - S(16)*log(S(3)*x + S(2))/S(567) + log(S(5)*x + S(1))/S(4375), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(S(15) + S(13)/x + S(2)/x**S(2)), x), x, x**S(2)/S(30) - S(13)*x/S(225) + S(8)*log(S(3)*x + S(2))/S(189) - log(S(5)*x + S(1))/S(875), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(S(15) + S(13)/x + S(2)/x**S(2)), x), x, x/S(15) - S(4)*log(S(3)*x + S(2))/S(63) + log(S(5)*x + S(1))/S(175), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*(S(15) + S(13)/x + S(2)/x**S(2))), x), x, S(2)*log(S(3)*x + S(2))/S(21) - log(S(5)*x + S(1))/S(35), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*(S(15) + S(13)/x + S(2)/x**S(2))), x), x, -log(S(3) + S(2)/x)/S(7) + log(S(5) + S(1)/x)/S(7), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(3)*(S(15) + S(13)/x + S(2)/x**S(2))), x), x, log(x)/S(2) + S(3)*log(S(3)*x + S(2))/S(14) - S(5)*log(S(5)*x + S(1))/S(7), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(4)*(S(15) + S(13)/x + S(2)/x**S(2))), x), x, -S(13)*log(x)/S(4) - S(9)*log(S(3)*x + S(2))/S(28) + S(25)*log(S(5)*x + S(1))/S(7) - S(1)/(S(2)*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(5)*(S(15) + S(13)/x + S(2)/x**S(2))), x), x, S(139)*log(x)/S(8) + S(27)*log(S(3)*x + S(2))/S(56) - S(125)*log(S(5)*x + S(1))/S(7) + S(13)/(S(4)*x) - S(1)/(S(4)*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(6)*(S(15) + S(13)/x + S(2)/x**S(2))), x), x, -S(1417)*log(x)/S(16) - S(81)*log(S(3)*x + S(2))/S(112) + S(625)*log(S(5)*x + S(1))/S(7) - S(139)/(S(8)*x) + S(13)/(S(8)*x**S(2)) - S(1)/(S(6)*x**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b/x + c/x**S(2))**(S(5)/2), x), x, S(5)*a**(S(3)/2)*b*atanh((S(2)*a + b/x)/(S(2)*sqrt(a)*sqrt(a + b/x + c/x**S(2))))/S(2) + x*(a + b/x + c/x**S(2))**(S(5)/2) - S(5)*(S(7)*b + S(6)*c/x)*(a + b/x + c/x**S(2))**(S(3)/2)/S(24) - S(5)*(b*(S(44)*a*c + b**S(2)) + S(2)*c*(S(12)*a*c + b**S(2))/x)*sqrt(a + b/x + c/x**S(2))/(S(64)*c) + (-S(240)*a**S(2)*c**S(2) - S(120)*a*b**S(2)*c + S(5)*b**S(4))*atanh((b + S(2)*c/x)/(S(2)*sqrt(c)*sqrt(a + b/x + c/x**S(2))))/(S(128)*c**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b/x + c/x**S(2))**(S(3)/2), x), x, S(3)*sqrt(a)*b*atanh((S(2)*a + b/x)/(S(2)*sqrt(a)*sqrt(a + b/x + c/x**S(2))))/S(2) + x*(a + b/x + c/x**S(2))**(S(3)/2) - S(3)*(S(3)*b + S(2)*c/x)*sqrt(a + b/x + c/x**S(2))/S(4) - (S(12)*a*c + S(3)*b**S(2))*atanh((b + S(2)*c/x)/(S(2)*sqrt(c)*sqrt(a + b/x + c/x**S(2))))/(S(8)*sqrt(c)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a + b/x + c/x**S(2)), x), x, -sqrt(c)*atanh((b + S(2)*c/x)/(S(2)*sqrt(c)*sqrt(a + b/x + c/x**S(2)))) + x*sqrt(a + b/x + c/x**S(2)) + b*atanh((S(2)*a + b/x)/(S(2)*sqrt(a)*sqrt(a + b/x + c/x**S(2))))/(S(2)*sqrt(a)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(a + b/x + c/x**S(2)), x), x, x*sqrt(a + b/x + c/x**S(2))/a - b*atanh((S(2)*a + b/x)/(S(2)*sqrt(a)*sqrt(a + b/x + c/x**S(2))))/(S(2)*a**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b/x + c/x**S(2))**(S(-3)/2), x), x, -x*(-S(4)*a*c + S(2)*b**S(2) + S(2)*b*c/x)/(a*(-S(4)*a*c + b**S(2))*sqrt(a + b/x + c/x**S(2))) + x*(-S(8)*a*c + S(3)*b**S(2))*sqrt(a + b/x + c/x**S(2))/(a**S(2)*(-S(4)*a*c + b**S(2))) - S(3)*b*atanh((S(2)*a + b/x)/(S(2)*sqrt(a)*sqrt(a + b/x + c/x**S(2))))/(S(2)*a**(S(5)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b/x + c/x**S(2))**(S(-5)/2), x), x, -x*(-S(4)*a*c + S(2)*b**S(2) + S(2)*b*c/x)/(S(3)*a*(-S(4)*a*c + b**S(2))*(a + b/x + c/x**S(2))**(S(3)/2)) - x*(S(64)*a**S(2)*c**S(2) - S(64)*a*b**S(2)*c + S(10)*b**S(4) + S(2)*b*c*(-S(28)*a*c + S(5)*b**S(2))/x)/(S(3)*a**S(2)*(-S(4)*a*c + b**S(2))**S(2)*sqrt(a + b/x + c/x**S(2))) + x*sqrt(a + b/x + c/x**S(2))*(S(128)*a**S(2)*c**S(2) - S(100)*a*b**S(2)*c + S(15)*b**S(4))/(S(3)*a**S(3)*(-S(4)*a*c + b**S(2))**S(2)) - S(5)*b*atanh((S(2)*a + b/x)/(S(2)*sqrt(a)*sqrt(a + b/x + c/x**S(2))))/(S(2)*a**(S(7)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a**S(2) + S(2)*a*b/x + b**S(2)/x**S(2)), x), x, a*x*sqrt(a**S(2) + S(2)*a*b/x + b**S(2)/x**S(2))/(a + b/x) + b*sqrt(a**S(2) + S(2)*a*b/x + b**S(2)/x**S(2))*log(x)/(a + b/x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(a/x**S(4) + b/x**S(2) + c), x), x, x/c - sqrt(S(2))*(b - (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*c**(S(3)/2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))) - sqrt(S(2))*(b + (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*c**(S(3)/2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(a/x**S(6) + b/x**S(3) + c), x), x, x/c - S(2)**(S(2)/3)*(b - (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*log(S(2)**(S(1)/3)*c**(S(1)/3)*x + (b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3))/(S(6)*c**(S(4)/3)*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)) + S(2)**(S(2)/3)*(b - (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*log(S(2)**(S(2)/3)*c**(S(2)/3)*x**S(2) - S(2)**(S(1)/3)*c**(S(1)/3)*x*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + (b - sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3))/(S(12)*c**(S(4)/3)*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)) + S(2)**(S(2)/3)*sqrt(S(3))*(b - (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(3))*(-S(2)*S(2)**(S(1)/3)*c**(S(1)/3)*x/(b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + S(1))/S(3))/(S(6)*c**(S(4)/3)*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)) - S(2)**(S(2)/3)*(b + (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*log(S(2)**(S(1)/3)*c**(S(1)/3)*x + (b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3))/(S(6)*c**(S(4)/3)*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)) + S(2)**(S(2)/3)*(b + (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*log(S(2)**(S(2)/3)*c**(S(2)/3)*x**S(2) - S(2)**(S(1)/3)*c**(S(1)/3)*x*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + (b + sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3))/(S(12)*c**(S(4)/3)*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)) + S(2)**(S(2)/3)*sqrt(S(3))*(b + (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(3))*(-S(2)*S(2)**(S(1)/3)*c**(S(1)/3)*x/(b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + S(1))/S(3))/(S(6)*c**(S(4)/3)*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(a/x**S(8) + b/x**S(4) + c), x), x, x/c + S(2)**(S(3)/4)*(b - (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(S(2)**(S(1)/4)*c**(S(1)/4)*x/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(4)*c**(S(5)/4)*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)) + S(2)**(S(3)/4)*(b - (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*x/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(4)*c**(S(5)/4)*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)) + S(2)**(S(3)/4)*(b + (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(S(2)**(S(1)/4)*c**(S(1)/4)*x/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(4)*c**(S(5)/4)*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)) + S(2)**(S(3)/4)*(b + (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*x/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(4)*c**(S(5)/4)*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a + b*sqrt(x) + c*x)/x, x), x, -S(2)*sqrt(a)*atanh((S(2)*a + b*sqrt(x))/(S(2)*sqrt(a)*sqrt(a + b*sqrt(x) + c*x))) + b*atanh((b + S(2)*c*sqrt(x))/(S(2)*sqrt(c)*sqrt(a + b*sqrt(x) + c*x)))/sqrt(c) + S(2)*sqrt(a + b*sqrt(x) + c*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b**S(2)/(S(4)*c) + b*sqrt(x) + c*x)**S(2), x), x, -b*(b + S(2)*c*sqrt(x))**S(5)/(S(160)*c**S(4)) + (b + S(2)*c*sqrt(x))**S(6)/(S(192)*c**S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(a**S(2) + S(2)*a*b*sqrt(x) + b**S(2)*x), x), x, -S(2)*a*(a + b*sqrt(x))*log(a + b*sqrt(x))/(b**S(2)*sqrt(a**S(2) + S(2)*a*b*sqrt(x) + b**S(2)*x)) + S(2)*sqrt(a**S(2) + S(2)*a*b*sqrt(x) + b**S(2)*x)/b**S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**m*(a**S(2) + S(2)*a*b*x**(S(1)/3) + b**S(2)*x**(S(2)/3))**p, x), x, x*(d*x)**m*(S(1) + b*x**(S(1)/3)/a)**(-S(2)*p)*(a**S(2) + S(2)*a*b*x**(S(1)/3) + b**S(2)*x**(S(2)/3))**p*hyper((S(3)*m + S(3), -S(2)*p), (S(3)*m + S(4),), -b*x**(S(1)/3)/a)/(m + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(a**S(2) + S(2)*a*b*x**(S(1)/3) + b**S(2)*x**(S(2)/3))**p, x), x, S(3)*a**S(8)*(a + b*x**(S(1)/3))*(a**S(2) + S(2)*a*b*x**(S(1)/3) + b**S(2)*x**(S(2)/3))**p/(b**S(9)*(S(2)*p + S(1))) - S(12)*a**S(7)*(a*b + b**S(2)*x**(S(1)/3))**S(2)*(a**S(2) + S(2)*a*b*x**(S(1)/3) + b**S(2)*x**(S(2)/3))**p/(b**S(11)*(p + S(1))) + S(84)*a**S(6)*(a*b + b**S(2)*x**(S(1)/3))**S(3)*(a**S(2) + S(2)*a*b*x**(S(1)/3) + b**S(2)*x**(S(2)/3))**p/(b**S(12)*(S(2)*p + S(3))) - S(84)*a**S(5)*(a*b + b**S(2)*x**(S(1)/3))**S(4)*(a**S(2) + S(2)*a*b*x**(S(1)/3) + b**S(2)*x**(S(2)/3))**p/(b**S(13)*(p + S(2))) + S(210)*a**S(4)*(a*b + b**S(2)*x**(S(1)/3))**S(5)*(a**S(2) + S(2)*a*b*x**(S(1)/3) + b**S(2)*x**(S(2)/3))**p/(b**S(14)*(S(2)*p + S(5))) - S(84)*a**S(3)*(a*b + b**S(2)*x**(S(1)/3))**S(6)*(a**S(2) + S(2)*a*b*x**(S(1)/3) + b**S(2)*x**(S(2)/3))**p/(b**S(15)*(p + S(3))) + S(84)*a**S(2)*(a*b + b**S(2)*x**(S(1)/3))**S(7)*(a**S(2) + S(2)*a*b*x**(S(1)/3) + b**S(2)*x**(S(2)/3))**p/(b**S(16)*(S(2)*p + S(7))) - S(12)*a*(a*b + b**S(2)*x**(S(1)/3))**S(8)*(a**S(2) + S(2)*a*b*x**(S(1)/3) + b**S(2)*x**(S(2)/3))**p/(b**S(17)*(p + S(4))) + S(3)*(a*b + b**S(2)*x**(S(1)/3))**S(9)*(a**S(2) + S(2)*a*b*x**(S(1)/3) + b**S(2)*x**(S(2)/3))**p/(b**S(18)*(S(2)*p + S(9))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(a**S(2) + S(2)*a*b*x**(S(1)/3) + b**S(2)*x**(S(2)/3))**p, x), x, -S(3)*a**S(5)*(a + b*x**(S(1)/3))*(a**S(2) + S(2)*a*b*x**(S(1)/3) + b**S(2)*x**(S(2)/3))**p/(b**S(6)*(S(2)*p + S(1))) + S(15)*a**S(4)*(a*b + b**S(2)*x**(S(1)/3))**S(2)*(a**S(2) + S(2)*a*b*x**(S(1)/3) + b**S(2)*x**(S(2)/3))**p/(S(2)*b**S(8)*(p + S(1))) - S(30)*a**S(3)*(a*b + b**S(2)*x**(S(1)/3))**S(3)*(a**S(2) + S(2)*a*b*x**(S(1)/3) + b**S(2)*x**(S(2)/3))**p/(b**S(9)*(S(2)*p + S(3))) + S(15)*a**S(2)*(a*b + b**S(2)*x**(S(1)/3))**S(4)*(a**S(2) + S(2)*a*b*x**(S(1)/3) + b**S(2)*x**(S(2)/3))**p/(b**S(10)*(p + S(2))) - S(15)*a*(a*b + b**S(2)*x**(S(1)/3))**S(5)*(a**S(2) + S(2)*a*b*x**(S(1)/3) + b**S(2)*x**(S(2)/3))**p/(b**S(11)*(S(2)*p + S(5))) + S(3)*(a*b + b**S(2)*x**(S(1)/3))**S(6)*(a**S(2) + S(2)*a*b*x**(S(1)/3) + b**S(2)*x**(S(2)/3))**p/(S(2)*b**S(12)*(p + S(3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**(S(1)/3) + b**S(2)*x**(S(2)/3))**p/x, x), x, -(S(3)*a + S(3)*b*x**(S(1)/3))*(a**S(2) + S(2)*a*b*x**(S(1)/3) + b**S(2)*x**(S(2)/3))**p*hyper((S(1), S(2)*p + S(1)), (S(2)*p + S(2),), S(1) + b*x**(S(1)/3)/a)/(a*(S(2)*p + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**(S(1)/3) + b**S(2)*x**(S(2)/3))**p/x**S(2), x), x, (S(3)*a*b**S(3) + S(3)*b**S(4)*x**(S(1)/3))*(a**S(2) + S(2)*a*b*x**(S(1)/3) + b**S(2)*x**(S(2)/3))**p*hyper((S(4), S(2)*p + S(1)), (S(2)*p + S(2),), S(1) + b*x**(S(1)/3)/a)/(a**S(4)*(S(2)*p + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**(S(1)/3) + b**S(2)*x**(S(2)/3))**p/x**S(2) - S(2)*b**S(3)*p*(-S(2)*p + S(1))*(-p + S(1))*(a**S(2) + S(2)*a*b*x**(S(1)/3) + b**S(2)*x**(S(2)/3))**p/(S(3)*a**S(3)*x), x), x, -(a + b*x**(S(1)/3))*(a**S(2) + S(2)*a*b*x**(S(1)/3) + b**S(2)*x**(S(2)/3))**p/(a*x) + b*(a + b*x**(S(1)/3))*(-p + S(1))*(a**S(2) + S(2)*a*b*x**(S(1)/3) + b**S(2)*x**(S(2)/3))**p/(a**S(2)*x**(S(2)/3)) - b**S(2)*(a + b*x**(S(1)/3))*(-S(2)*p + S(1))*(-p + S(1))*(a**S(2) + S(2)*a*b*x**(S(1)/3) + b**S(2)*x**(S(2)/3))**p/(a**S(3)*x**(S(1)/3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**(S(1)/4) + b**S(2)*sqrt(x))**(S(-3)/2), x), x, -S(12)*a*(a + b*x**(S(1)/4))*log(a + b*x**(S(1)/4))/(b**S(4)*sqrt(a**S(2) + S(2)*a*b*x**(S(1)/4) + b**S(2)*sqrt(x))) - x**(S(3)/4)*(S(2)*a + S(2)*b*x**(S(1)/4))/(b*(a**S(2) + S(2)*a*b*x**(S(1)/4) + b**S(2)*sqrt(x))**(S(3)/2)) - S(6)*sqrt(x)/(b**S(2)*sqrt(a**S(2) + S(2)*a*b*x**(S(1)/4) + b**S(2)*sqrt(x))) + S(12)*sqrt(a**S(2) + S(2)*a*b*x**(S(1)/4) + b**S(2)*sqrt(x))/b**S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**(S(1)/6) + b**S(2)*x**(S(1)/3))**(S(-5)/2), x), x, -S(30)*a*(a + b*x**(S(1)/6))*log(a + b*x**(S(1)/6))/(b**S(6)*sqrt(a**S(2) + S(2)*a*b*x**(S(1)/6) + b**S(2)*x**(S(1)/3))) - x**(S(5)/6)*(S(3)*a + S(3)*b*x**(S(1)/6))/(S(2)*b*(a**S(2) + S(2)*a*b*x**(S(1)/6) + b**S(2)*x**(S(1)/3))**(S(5)/2)) - S(5)*x**(S(2)/3)/(S(2)*b**S(2)*(a**S(2) + S(2)*a*b*x**(S(1)/6) + b**S(2)*x**(S(1)/3))**(S(3)/2)) - sqrt(x)*(S(5)*a + S(5)*b*x**(S(1)/6))/(b**S(3)*(a**S(2) + S(2)*a*b*x**(S(1)/6) + b**S(2)*x**(S(1)/3))**(S(3)/2)) - S(15)*x**(S(1)/3)/(b**S(4)*sqrt(a**S(2) + S(2)*a*b*x**(S(1)/6) + b**S(2)*x**(S(1)/3))) + S(30)*sqrt(a**S(2) + S(2)*a*b*x**(S(1)/6) + b**S(2)*x**(S(1)/3))/b**S(6), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b/sqrt(x) + b**S(2)/x)**(S(3)/2), x), x, -S(6)*a*b**S(2)*sqrt(a**S(2) + S(2)*a*b/sqrt(x) + b**S(2)/x)*log(S(1)/sqrt(x))/(a + b/sqrt(x)) - S(6)*b**S(2)*sqrt(a**S(2) + S(2)*a*b/sqrt(x) + b**S(2)/x) + S(3)*b*sqrt(x)*(a + b/sqrt(x))*sqrt(a**S(2) + S(2)*a*b/sqrt(x) + b**S(2)/x) + x*(a**S(2) + S(2)*a*b/sqrt(x) + b**S(2)/x)**(S(3)/2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b/x**(S(1)/3) + b**S(2)/x**(S(2)/3))**(S(7)/2), x), x, -S(105)*a**S(4)*b**S(3)*sqrt(a**S(2) + S(2)*a*b/x**(S(1)/3) + b**S(2)/x**(S(2)/3))*log(x**(S(-1)/3))/(a + b/x**(S(1)/3)) - S(105)*a**S(3)*b**S(3)*sqrt(a**S(2) + S(2)*a*b/x**(S(1)/3) + b**S(2)/x**(S(2)/3)) - S(105)*a**S(2)*b**S(3)*(a + b/x**(S(1)/3))*sqrt(a**S(2) + S(2)*a*b/x**(S(1)/3) + b**S(2)/x**(S(2)/3))/S(2) - S(35)*a*b**S(3)*(a**S(2) + S(2)*a*b/x**(S(1)/3) + b**S(2)/x**(S(2)/3))**(S(3)/2) - S(105)*b**S(3)*(a + b/x**(S(1)/3))*(a**S(2) + S(2)*a*b/x**(S(1)/3) + b**S(2)/x**(S(2)/3))**(S(3)/2)/S(4) + S(21)*b**S(2)*x**(S(1)/3)*(a**S(2) + S(2)*a*b/x**(S(1)/3) + b**S(2)/x**(S(2)/3))**(S(5)/2) + S(7)*b*x**(S(2)/3)*(a + b/x**(S(1)/3))*(a**S(2) + S(2)*a*b/x**(S(1)/3) + b**S(2)/x**(S(2)/3))**(S(5)/2)/S(2) + x*(a**S(2) + S(2)*a*b/x**(S(1)/3) + b**S(2)/x**(S(2)/3))**(S(7)/2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b/x**(S(1)/3) + b**S(2)/x**(S(2)/3))**(S(5)/2), x), x, -S(30)*a**S(2)*b**S(3)*sqrt(a**S(2) + S(2)*a*b/x**(S(1)/3) + b**S(2)/x**(S(2)/3))*log(x**(S(-1)/3))/(a + b/x**(S(1)/3)) - S(30)*a*b**S(3)*sqrt(a**S(2) + S(2)*a*b/x**(S(1)/3) + b**S(2)/x**(S(2)/3)) - S(15)*b**S(3)*(a + b/x**(S(1)/3))*sqrt(a**S(2) + S(2)*a*b/x**(S(1)/3) + b**S(2)/x**(S(2)/3)) + S(10)*b**S(2)*x**(S(1)/3)*(a**S(2) + S(2)*a*b/x**(S(1)/3) + b**S(2)/x**(S(2)/3))**(S(3)/2) + S(5)*b*x**(S(2)/3)*(a + b/x**(S(1)/3))*(a**S(2) + S(2)*a*b/x**(S(1)/3) + b**S(2)/x**(S(2)/3))**(S(3)/2)/S(2) + x*(a**S(2) + S(2)*a*b/x**(S(1)/3) + b**S(2)/x**(S(2)/3))**(S(5)/2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b/x**(S(1)/3) + b**S(2)/x**(S(2)/3))**(S(3)/2), x), x, S(3)*a*b**S(2)*x**(S(1)/3)*sqrt(a**S(2) + S(2)*a*b/x**(S(1)/3) + b**S(2)/x**(S(2)/3))/(a + b/x**(S(1)/3)) - S(3)*b**S(3)*sqrt(a**S(2) + S(2)*a*b/x**(S(1)/3) + b**S(2)/x**(S(2)/3))*log(x**(S(-1)/3))/(a + b/x**(S(1)/3)) + S(3)*b*x**(S(2)/3)*(a + b/x**(S(1)/3))*sqrt(a**S(2) + S(2)*a*b/x**(S(1)/3) + b**S(2)/x**(S(2)/3))/S(2) + x*(a**S(2) + S(2)*a*b/x**(S(1)/3) + b**S(2)/x**(S(2)/3))**(S(3)/2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a**S(2) + S(2)*a*b/x**(S(1)/3) + b**S(2)/x**(S(2)/3)), x), x, -a*x*sqrt(a**S(2) + S(2)*a*b/x**(S(1)/3) + b**S(2)/x**(S(2)/3))/(S(2)*a + S(2)*b/x**(S(1)/3)) + S(3)*x*sqrt(a**S(2) + S(2)*a*b/x**(S(1)/3) + b**S(2)/x**(S(2)/3))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(a**S(2) + S(2)*a*b/x**(S(1)/3) + b**S(2)/x**(S(2)/3)), x), x, x*(a + b/x**(S(1)/3))/(a*sqrt(a**S(2) + S(2)*a*b/x**(S(1)/3) + b**S(2)/x**(S(2)/3))) - S(3)*b*x**(S(2)/3)*(a + b/x**(S(1)/3))/(S(2)*a**S(2)*sqrt(a**S(2) + S(2)*a*b/x**(S(1)/3) + b**S(2)/x**(S(2)/3))) + S(3)*b**S(2)*x**(S(1)/3)*(a + b/x**(S(1)/3))/(a**S(3)*sqrt(a**S(2) + S(2)*a*b/x**(S(1)/3) + b**S(2)/x**(S(2)/3))) - S(3)*b**S(3)*(a + b/x**(S(1)/3))*log(a*x**(S(1)/3) + b)/(a**S(4)*sqrt(a**S(2) + S(2)*a*b/x**(S(1)/3) + b**S(2)/x**(S(2)/3))), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate(S(1)/sqrt(a**S(2) + S(2)*a*b/x**(S(1)/3) + b**S(2)/x**(S(2)/3)), x), x, x*(a + b/x**(S(1)/3))/(a*sqrt(a**S(2) + S(2)*a*b/x**(S(1)/3) + b**S(2)/x**(S(2)/3))) - S(3)*b*x**(S(2)/3)*(a + b/x**(S(1)/3))/(S(2)*a**S(2)*sqrt(a**S(2) + S(2)*a*b/x**(S(1)/3) + b**S(2)/x**(S(2)/3))) + S(3)*b**S(3)*(a + b/x**(S(1)/3))*log(x**(S(-1)/3))/(a**S(4)*sqrt(a**S(2) + S(2)*a*b/x**(S(1)/3) + b**S(2)/x**(S(2)/3))) - S(3)*b**S(3)*(a + b/x**(S(1)/3))*log(a + b/x**(S(1)/3))/(a**S(4)*sqrt(a**S(2) + S(2)*a*b/x**(S(1)/3) + b**S(2)/x**(S(2)/3))) + S(3)*b**S(2)*x**(S(1)/3)*sqrt(a**S(2) + S(2)*a*b/x**(S(1)/3) + b**S(2)/x**(S(2)/3))/a**S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**(S(1)/3) + b**S(2)*x**(S(2)/3))**(S(-3)/2), x), x, -x**(S(2)/3)*(S(3)*a + S(3)*b*x**(S(1)/3))/(S(2)*b*(a**S(2) + S(2)*a*b*x**(S(1)/3) + b**S(2)*x**(S(2)/3))**(S(3)/2)) - S(3)*x**(S(1)/3)/(b**S(2)*sqrt(a**S(2) + S(2)*a*b*x**(S(1)/3) + b**S(2)*x**(S(2)/3))) + (S(3)*a + S(3)*b*x**(S(1)/3))*log(a + b*x**(S(1)/3))/(b**S(3)*sqrt(a**S(2) + S(2)*a*b*x**(S(1)/3) + b**S(2)*x**(S(2)/3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**(S(1)/3) + b**S(2)*x**(S(2)/3))**(S(-5)/2), x), x, x*(S(3)*a + S(3)*b*x**(S(1)/3))/(S(4)*a*(a**S(2) + S(2)*a*b*x**(S(1)/3) + b**S(2)*x**(S(2)/3))**(S(5)/2)) + x/(S(4)*a**S(2)*(a**S(2) + S(2)*a*b*x**(S(1)/3) + b**S(2)*x**(S(2)/3))**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**(S(1)/3) + b**S(2)*x**(S(2)/3))**(S(-7)/2), x), x, -x**(S(2)/3)*(a + b*x**(S(1)/3))/(S(2)*b*(a**S(2) + S(2)*a*b*x**(S(1)/3) + b**S(2)*x**(S(2)/3))**(S(7)/2)) - x**(S(1)/3)/(S(5)*b**S(2)*(a**S(2) + S(2)*a*b*x**(S(1)/3) + b**S(2)*x**(S(2)/3))**(S(5)/2)) - (a + b*x**(S(1)/3))/(S(20)*b**S(3)*(a**S(2) + S(2)*a*b*x**(S(1)/3) + b**S(2)*x**(S(2)/3))**(S(5)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**(S(1)/3) + b**S(2)*x**(S(2)/3))**(S(-9)/2), x), x, -x**(S(2)/3)*(S(3)*a + S(3)*b*x**(S(1)/3))/(S(8)*b*(a**S(2) + S(2)*a*b*x**(S(1)/3) + b**S(2)*x**(S(2)/3))**(S(9)/2)) - S(3)*x**(S(1)/3)/(S(28)*b**S(2)*(a**S(2) + S(2)*a*b*x**(S(1)/3) + b**S(2)*x**(S(2)/3))**(S(7)/2)) - (a + b*x**(S(1)/3))/(S(56)*b**S(3)*(a**S(2) + S(2)*a*b*x**(S(1)/3) + b**S(2)*x**(S(2)/3))**(S(7)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**(S(1)/3) + b**S(2)*x**(S(2)/3))**(S(-11)/2), x), x, -x**(S(2)/3)*(S(3)*a + S(3)*b*x**(S(1)/3))/(S(10)*b*(a**S(2) + S(2)*a*b*x**(S(1)/3) + b**S(2)*x**(S(2)/3))**(S(11)/2)) - x**(S(1)/3)/(S(15)*b**S(2)*(a**S(2) + S(2)*a*b*x**(S(1)/3) + b**S(2)*x**(S(2)/3))**(S(9)/2)) - (a + b*x**(S(1)/3))/(S(120)*b**S(3)*(a**S(2) + S(2)*a*b*x**(S(1)/3) + b**S(2)*x**(S(2)/3))**(S(9)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b/x**(S(1)/4) + b**S(2)/sqrt(x))**(S(5)/2), x), x, -S(20)*a*b**S(4)*sqrt(a**S(2) + S(2)*a*b/x**(S(1)/4) + b**S(2)/sqrt(x))*log(x**(S(-1)/4))/(a + b/x**(S(1)/4)) - S(20)*b**S(4)*sqrt(a**S(2) + S(2)*a*b/x**(S(1)/4) + b**S(2)/sqrt(x)) + S(10)*b**S(3)*x**(S(1)/4)*(a + b/x**(S(1)/4))*sqrt(a**S(2) + S(2)*a*b/x**(S(1)/4) + b**S(2)/sqrt(x)) + S(10)*b**S(2)*sqrt(x)*(a**S(2) + S(2)*a*b/x**(S(1)/4) + b**S(2)/sqrt(x))**(S(3)/2)/S(3) + S(5)*b*x**(S(3)/4)*(a + b/x**(S(1)/4))*(a**S(2) + S(2)*a*b/x**(S(1)/4) + b**S(2)/sqrt(x))**(S(3)/2)/S(3) + x*(a**S(2) + S(2)*a*b/x**(S(1)/4) + b**S(2)/sqrt(x))**(S(5)/2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b/x**(S(1)/5) + b**S(2)/x**(S(2)/5))**(S(5)/2), x), x, S(5)*a*b**S(4)*x**(S(1)/5)*sqrt(a**S(2) + S(2)*a*b/x**(S(1)/5) + b**S(2)/x**(S(2)/5))/(a + b/x**(S(1)/5)) - S(5)*b**S(5)*sqrt(a**S(2) + S(2)*a*b/x**(S(1)/5) + b**S(2)/x**(S(2)/5))*log(x**(S(-1)/5))/(a + b/x**(S(1)/5)) + S(5)*b**S(3)*x**(S(2)/5)*(a + b/x**(S(1)/5))*sqrt(a**S(2) + S(2)*a*b/x**(S(1)/5) + b**S(2)/x**(S(2)/5))/S(2) + S(5)*b**S(2)*x**(S(3)/5)*(a**S(2) + S(2)*a*b/x**(S(1)/5) + b**S(2)/x**(S(2)/5))**(S(3)/2)/S(3) + S(5)*b*x**(S(4)/5)*(a + b/x**(S(1)/5))*(a**S(2) + S(2)*a*b/x**(S(1)/5) + b**S(2)/x**(S(2)/5))**(S(3)/2)/S(4) + x*(a**S(2) + S(2)*a*b/x**(S(1)/5) + b**S(2)/x**(S(2)/5))**(S(5)/2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**(S(1)/5) + b**S(2)*x**(S(2)/5))**(S(-5)/2), x), x, -x**(S(4)/5)*(S(5)*a + S(5)*b*x**(S(1)/5))/(S(4)*b*(a**S(2) + S(2)*a*b*x**(S(1)/5) + b**S(2)*x**(S(2)/5))**(S(5)/2)) - S(5)*x**(S(3)/5)/(S(3)*b**S(2)*(a**S(2) + S(2)*a*b*x**(S(1)/5) + b**S(2)*x**(S(2)/5))**(S(3)/2)) - x**(S(2)/5)*(S(5)*a + S(5)*b*x**(S(1)/5))/(S(2)*b**S(3)*(a**S(2) + S(2)*a*b*x**(S(1)/5) + b**S(2)*x**(S(2)/5))**(S(3)/2)) - S(5)*x**(S(1)/5)/(b**S(4)*sqrt(a**S(2) + S(2)*a*b*x**(S(1)/5) + b**S(2)*x**(S(2)/5))) + (S(5)*a + S(5)*b*x**(S(1)/5))*log(a + b*x**(S(1)/5))/(b**S(5)*sqrt(a**S(2) + S(2)*a*b*x**(S(1)/5) + b**S(2)*x**(S(2)/5))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b/x**(S(1)/6) + b**S(2)/x**(S(1)/3))**(S(7)/2), x), x, -S(42)*a*b**S(6)*sqrt(a**S(2) + S(2)*a*b/x**(S(1)/6) + b**S(2)/x**(S(1)/3))*log(x**(S(-1)/6))/(a + b/x**(S(1)/6)) - S(42)*b**S(6)*sqrt(a**S(2) + S(2)*a*b/x**(S(1)/6) + b**S(2)/x**(S(1)/3)) + S(21)*b**S(5)*x**(S(1)/6)*(a + b/x**(S(1)/6))*sqrt(a**S(2) + S(2)*a*b/x**(S(1)/6) + b**S(2)/x**(S(1)/3)) + S(7)*b**S(4)*x**(S(1)/3)*(a**S(2) + S(2)*a*b/x**(S(1)/6) + b**S(2)/x**(S(1)/3))**(S(3)/2) + S(7)*b**S(3)*sqrt(x)*(a + b/x**(S(1)/6))*(a**S(2) + S(2)*a*b/x**(S(1)/6) + b**S(2)/x**(S(1)/3))**(S(3)/2)/S(2) + S(21)*b**S(2)*x**(S(2)/3)*(a**S(2) + S(2)*a*b/x**(S(1)/6) + b**S(2)/x**(S(1)/3))**(S(5)/2)/S(10) + S(7)*b*x**(S(5)/6)*(a + b/x**(S(1)/6))*(a**S(2) + S(2)*a*b/x**(S(1)/6) + b**S(2)/x**(S(1)/3))**(S(5)/2)/S(5) + x*(a**S(2) + S(2)*a*b/x**(S(1)/6) + b**S(2)/x**(S(1)/3))**(S(7)/2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(4)*n + S(-1))/(b*x**n + c*x**(S(2)*n)), x), x, b**S(2)*log(b + c*x**n)/(c**S(3)*n) - b*x**n/(c**S(2)*n) + x**(S(2)*n)/(S(2)*c*n), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(3)*n + S(-1))/(b*x**n + c*x**(S(2)*n)), x), x, -b*log(b + c*x**n)/(c**S(2)*n) + x**n/(c*n), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(2)*n + S(-1))/(b*x**n + c*x**(S(2)*n)), x), x, log(b + c*x**n)/(c*n), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(n + S(-1))/(b*x**n + c*x**(S(2)*n)), x), x, log(x)/b - log(b + c*x**n)/(b*n), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(-n + S(-1))/(b*x**n + c*x**(S(2)*n)), x), x, -x**(-S(2)*n)/(S(2)*b*n) + c*x**(-n)/(b**S(2)*n) + c**S(2)*log(x)/b**S(3) - c**S(2)*log(b + c*x**n)/(b**S(3)*n), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(-S(2)*n + S(-1))/(b*x**n + c*x**(S(2)*n)), x), x, -x**(-S(3)*n)/(S(3)*b*n) + c*x**(-S(2)*n)/(S(2)*b**S(2)*n) - c**S(2)*x**(-n)/(b**S(3)*n) - c**S(3)*log(x)/b**S(4) + c**S(3)*log(b + c*x**n)/(b**S(4)*n), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(-S(3)*n + S(-1))/(b*x**n + c*x**(S(2)*n)), x), x, -x**(-S(4)*n)/(S(4)*b*n) + c*x**(-S(3)*n)/(S(3)*b**S(2)*n) - c**S(2)*x**(-S(2)*n)/(S(2)*b**S(3)*n) + c**S(3)*x**(-n)/(b**S(4)*n) + c**S(4)*log(x)/b**S(5) - c**S(4)*log(b + c*x**n)/(b**S(5)*n), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(n/S(4) + S(-1))/(b*x**n + c*x**(S(2)*n)), x), x, -S(4)*x**(-S(3)*n/S(4))/(S(3)*b*n) + sqrt(S(2))*c**(S(3)/4)*log(-sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*x**(n/S(4)) + sqrt(b) + sqrt(c)*x**(n/S(2)))/(S(2)*b**(S(7)/4)*n) - sqrt(S(2))*c**(S(3)/4)*log(sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*x**(n/S(4)) + sqrt(b) + sqrt(c)*x**(n/S(2)))/(S(2)*b**(S(7)/4)*n) + sqrt(S(2))*c**(S(3)/4)*atan(S(1) - sqrt(S(2))*c**(S(1)/4)*x**(n/S(4))/b**(S(1)/4))/(b**(S(7)/4)*n) - sqrt(S(2))*c**(S(3)/4)*atan(S(1) + sqrt(S(2))*c**(S(1)/4)*x**(n/S(4))/b**(S(1)/4))/(b**(S(7)/4)*n), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(n/S(3) + S(-1))/(b*x**n + c*x**(S(2)*n)), x), x, -S(3)*x**(-S(2)*n/S(3))/(S(2)*b*n) - c**(S(2)/3)*log(b**(S(1)/3) + c**(S(1)/3)*x**(n/S(3)))/(b**(S(5)/3)*n) + c**(S(2)/3)*log(b**(S(2)/3) - b**(S(1)/3)*c**(S(1)/3)*x**(n/S(3)) + c**(S(2)/3)*x**(S(2)*n/S(3)))/(S(2)*b**(S(5)/3)*n) + sqrt(S(3))*c**(S(2)/3)*atan(sqrt(S(3))*(b**(S(1)/3) - S(2)*c**(S(1)/3)*x**(n/S(3)))/(S(3)*b**(S(1)/3)))/(b**(S(5)/3)*n), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(n/S(2) + S(-1))/(b*x**n + c*x**(S(2)*n)), x), x, -S(2)*x**(-n/S(2))/(b*n) + S(2)*sqrt(c)*atan(sqrt(b)*x**(-n/S(2))/sqrt(c))/(b**(S(3)/2)*n), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(-n/S(2) + S(-1))/(b*x**n + c*x**(S(2)*n)), x), x, -S(2)*x**(-S(3)*n/S(2))/(S(3)*b*n) + S(2)*c*x**(-n/S(2))/(b**S(2)*n) - S(2)*c**(S(3)/2)*atan(sqrt(b)*x**(-n/S(2))/sqrt(c))/(b**(S(5)/2)*n), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(-n/S(3) + S(-1))/(b*x**n + c*x**(S(2)*n)), x), x, -S(3)*x**(-S(4)*n/S(3))/(S(4)*b*n) + S(3)*c*x**(-n/S(3))/(b**S(2)*n) - c**(S(4)/3)*log(b**(S(1)/3)*x**(-n/S(3)) + c**(S(1)/3))/(b**(S(7)/3)*n) + c**(S(4)/3)*log(b**(S(2)/3)*x**(-S(2)*n/S(3)) - b**(S(1)/3)*c**(S(1)/3)*x**(-n/S(3)) + c**(S(2)/3))/(S(2)*b**(S(7)/3)*n) + sqrt(S(3))*c**(S(4)/3)*atan(sqrt(S(3))*(-S(2)*b**(S(1)/3)*x**(-n/S(3)) + c**(S(1)/3))/(S(3)*c**(S(1)/3)))/(b**(S(7)/3)*n), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(-n/S(4) + S(-1))/(b*x**n + c*x**(S(2)*n)), x), x, -S(4)*x**(-S(5)*n/S(4))/(S(5)*b*n) + S(4)*c*x**(-n/S(4))/(b**S(2)*n) + sqrt(S(2))*c**(S(5)/4)*log(-sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*x**(-n/S(4)) + sqrt(b)*x**(-n/S(2)) + sqrt(c))/(S(2)*b**(S(9)/4)*n) - sqrt(S(2))*c**(S(5)/4)*log(sqrt(S(2))*b**(S(1)/4)*c**(S(1)/4)*x**(-n/S(4)) + sqrt(b)*x**(-n/S(2)) + sqrt(c))/(S(2)*b**(S(9)/4)*n) - sqrt(S(2))*c**(S(5)/4)*atan(sqrt(S(2))*b**(S(1)/4)*x**(-n/S(4))/c**(S(1)/4) + S(-1))/(b**(S(9)/4)*n) - sqrt(S(2))*c**(S(5)/4)*atan(sqrt(S(2))*b**(S(1)/4)*x**(-n/S(4))/c**(S(1)/4) + S(1))/(b**(S(9)/4)*n), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(-n*(p + S(-1)) + S(-1))*(b*x**n + c*x**(S(2)*n))**p, x), x, x**(-n*(p + S(1)))*(b*x**n + c*x**(S(2)*n))**(p + S(1))/(c*n*(p + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(-n*(S(2)*p + S(1)) + S(-1))*(b*x**n + c*x**(S(2)*n))**p, x), x, -x**(-S(2)*n*(p + S(1)))*(b*x**n + c*x**(S(2)*n))**(p + S(1))/(b*n*(p + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(2)*n + S(-1))*(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))**p, x), x, -a*(a + b*x**n)*(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))**p/(b**S(2)*n*(S(2)*p + S(1))) + (a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))**(p + S(1))/(S(2)*b**S(2)*n*(p + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(2)*n + S(-1))*(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))**(S(5)/2), x), x, -a*(a + b*x**n)*(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))**(S(5)/2)/(S(6)*b**S(2)*n) + (a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))**(S(7)/2)/(S(7)*b**S(2)*n), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(2)*n + S(-1))*(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))**(S(3)/2), x), x, -a*(a + b*x**n)*(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))**(S(3)/2)/(S(4)*b**S(2)*n) + (a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))**(S(5)/2)/(S(5)*b**S(2)*n), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(2)*n + S(-1))*sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n)), x), x, a*x**(S(2)*n)*sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))/(S(6)*n*(a + b*x**n)) + x**(S(2)*n)*sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))/(S(3)*n), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(2)*n + S(-1))/sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n)), x), x, -a*(a + b*x**n)*log(a + b*x**n)/(b**S(2)*n*sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))) + sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))/(b**S(2)*n), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(2)*n + S(-1))/(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))**(S(3)/2), x), x, x**(S(2)*n)*(a + b*x**n)/(S(2)*a*n*(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(2)*n + S(-1))/(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))**(S(5)/2), x), x, a*(a + b*x**n)/(S(4)*b**S(2)*n*(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))**(S(5)/2)) - S(1)/(S(3)*b**S(2)*n*(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(2)*n + S(-1))/(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))**(S(7)/2), x), x, a*(a + b*x**n)/(S(6)*b**S(2)*n*(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))**(S(7)/2)) - S(1)/(S(5)*b**S(2)*n*(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))**(S(5)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**m*sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n)), x), x, a*n*(d*x)**(m + S(1))*sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))/(d*(a + b*x**n)*(m + S(1))*(m + n + S(1))) + (d*x)**(m + S(1))*sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))/(d*(m + n + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n)), x), x, a*n*x**S(3)*sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))/((a + b*x**n)*(S(3)*n + S(9))) + x**S(3)*sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))/(n + S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n)), x), x, a*n*x**S(2)*sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))/((a + b*x**n)*(S(2)*n + S(4))) + x**S(2)*sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))/(n + S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n)), x), x, a*n*x*sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))/((a + b*x**n)*(n + S(1))) + x*sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))/(n + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))/x, x), x, a*sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))*log(x)/(a + b*x**n) + sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))/n, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))/x**S(2), x), x, a*n*sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))/(x*(a + b*x**n)*(-n + S(1))) - sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))/(x*(-n + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))/x**S(3), x), x, a*n*sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))/(x**S(2)*(a + b*x**n)*(-S(2)*n + S(4))) - sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))/(x**S(2)*(-n + S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**m*(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))**(S(3)/2), x), x, a**S(3)*(d*x)**(m + S(1))*sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))/(d*(a + b*x**n)*(m + S(1))) + S(3)*a**S(2)*b**S(2)*x**(n + S(1))*(d*x)**m*sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))/((a*b + b**S(2)*x**n)*(m + n + S(1))) + S(3)*a*b**S(3)*x**(S(2)*n + S(1))*(d*x)**m*sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))/((a*b + b**S(2)*x**n)*(m + S(2)*n + S(1))) + b**S(4)*x**(S(3)*n + S(1))*(d*x)**m*sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))/((a*b + b**S(2)*x**n)*(m + S(3)*n + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))**(S(3)/2), x), x, a**S(3)*x**S(3)*sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))/(S(3)*a + S(3)*b*x**n) + S(3)*a**S(2)*b**S(2)*x**(n + S(3))*sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))/((n + S(3))*(a*b + b**S(2)*x**n)) + S(3)*a*b**S(3)*x**(S(2)*n + S(3))*sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))/((S(2)*n + S(3))*(a*b + b**S(2)*x**n)) + b**S(4)*x**(S(3)*n + S(3))*sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))/((S(3)*n + S(3))*(a*b + b**S(2)*x**n)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))**(S(3)/2), x), x, a**S(3)*x**S(2)*sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))/(S(2)*a + S(2)*b*x**n) + S(3)*a**S(2)*b**S(2)*x**(n + S(2))*sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))/((n + S(2))*(a*b + b**S(2)*x**n)) + S(3)*a*b**S(3)*x**(S(2)*n + S(2))*sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))/((S(2)*n + S(2))*(a*b + b**S(2)*x**n)) + b**S(4)*x**(S(3)*n + S(2))*sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))/((S(3)*n + S(2))*(a*b + b**S(2)*x**n)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))**(S(3)/2), x), x, S(6)*a**S(3)*n**S(3)*x*sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))/((a + b*x**n)*(S(6)*n**S(3) + S(11)*n**S(2) + S(6)*n + S(1))) + S(6)*a**S(2)*n**S(2)*x*sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))/(S(6)*n**S(3) + S(11)*n**S(2) + S(6)*n + S(1)) + S(3)*n*x*(a**S(2) + a*b*x**n)*sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))/(S(6)*n**S(2) + S(5)*n + S(1)) + x*(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))**(S(3)/2)/(S(3)*n + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))**(S(3)/2)/x, x), x, a**S(3)*sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))*log(x)/(a + b*x**n) + a**S(2)*sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))/n + (a**S(2) + a*b*x**n)*sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))/(S(2)*n) + (a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))**(S(3)/2)/(S(3)*n), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))**(S(3)/2)/x**S(2), x), x, -a**S(3)*sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))/(x*(a + b*x**n)) - S(3)*a**S(2)*b**S(2)*x**(n + S(-1))*sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))/((-n + S(1))*(a*b + b**S(2)*x**n)) - S(3)*a*b**S(3)*x**(S(2)*n + S(-1))*sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))/((-S(2)*n + S(1))*(a*b + b**S(2)*x**n)) - b**S(4)*x**(S(3)*n + S(-1))*sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))/((-S(3)*n + S(1))*(a*b + b**S(2)*x**n)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))**(S(3)/2)/x**S(3), x), x, -a**S(3)*sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))/(S(2)*x**S(2)*(a + b*x**n)) - S(3)*a**S(2)*b**S(2)*x**(n + S(-2))*sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))/((-n + S(2))*(a*b + b**S(2)*x**n)) - S(3)*a*b**S(3)*x**(S(2)*n + S(-2))*sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))/((-S(2)*n + S(2))*(a*b + b**S(2)*x**n)) - b**S(4)*x**(S(3)*n + S(-2))*sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))/((-S(3)*n + S(2))*(a*b + b**S(2)*x**n)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**m/sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n)), x), x, (d*x)**(m + S(1))*(a + b*x**n)*hyper((S(1), (m + S(1))/n), ((m + n + S(1))/n,), -b*x**n/a)/(a*d*(m + S(1))*sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n)), x), x, x**S(3)*(a + b*x**n)*hyper((S(1), S(3)/n), ((n + S(3))/n,), -b*x**n/a)/(S(3)*a*sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n)), x), x, x**S(2)*(a + b*x**n)*hyper((S(1), S(2)/n), ((n + S(2))/n,), -b*x**n/a)/(S(2)*a*sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n)), x), x, x*(a + b*x**n)*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -b*x**n/a)/(a*sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))), x), x, (a + b*x**n)*log(x)/(a*sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))) - (a + b*x**n)*log(a + b*x**n)/(a*n*sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))), x), x, -(a + b*x**n)*hyper((S(1), -S(1)/n), (-(-n + S(1))/n,), -b*x**n/a)/(a*x*sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(3)*sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))), x), x, -(a + b*x**n)*hyper((S(1), -S(2)/n), (-(-n + S(2))/n,), -b*x**n/a)/(S(2)*a*x**S(2)*sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**m/(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))**(S(3)/2), x), x, (d*x)**(m + S(1))*(a + b*x**n)*hyper((S(3), (m + S(1))/n), ((m + n + S(1))/n,), -b*x**n/a)/(a**S(3)*d*(m + S(1))*sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))**(S(3)/2), x), x, x**S(3)*(a + b*x**n)*hyper((S(3), S(3)/n), ((n + S(3))/n,), -b*x**n/a)/(S(3)*a**S(3)*sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))**(S(3)/2), x), x, x**S(2)*(a + b*x**n)*hyper((S(3), S(2)/n), ((n + S(2))/n,), -b*x**n/a)/(S(2)*a**S(3)*sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))**(S(-3)/2), x), x, x*(a + b*x**n)*hyper((S(3), S(1)/n), (S(1) + S(1)/n,), -b*x**n/a)/(a**S(3)*sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))**(S(3)/2)), x), x, (a + b*x**n)/(S(2)*a*n*(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))**(S(3)/2)) + S(1)/(a**S(2)*n*sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))) + (a + b*x**n)*log(x)/(a**S(3)*sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))) - (a + b*x**n)*log(a + b*x**n)/(a**S(3)*n*sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))**(S(3)/2)), x), x, -(a + b*x**n)*hyper((S(3), -S(1)/n), (-(-n + S(1))/n,), -b*x**n/a)/(a**S(3)*x*sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(3)*(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))**(S(3)/2)), x), x, -(a + b*x**n)*hyper((S(3), -S(2)/n), (-(-n + S(2))/n,), -b*x**n/a)/(S(2)*a**S(3)*x**S(2)*sqrt(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**(-S(1)/(S(2)*p + S(1))) + b**S(2)*x**(-S(2)/(S(2)*p + S(1))))**p, x), x, x*(a + b*x**(S(1)/(-S(2)*p + S(-1))))*(a**S(2) + S(2)*a*b*x**(S(1)/(-S(2)*p + S(-1))) + b**S(2)*x**(-S(2)/(S(2)*p + S(1))))**p/a, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))**((-n + S(-1))/(S(2)*n)), x), x, x*(a + b*x**n)*(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))**(-(n + S(1))/(S(2)*n))/a, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**(-S(1)/(S(2)*p + S(2))) + b**S(2)*x**(-S(1)/(p + S(1))))**p, x), x, x*(a + b*x**(-S(1)/(S(2)*p + S(2))))*(S(2)*p + S(2))*(a**S(2) + S(2)*a*b*x**(-S(1)/(S(2)*p + S(2))) + b**S(2)*x**(-S(1)/(p + S(1))))**p/(a*(S(2)*p + S(1))) - x*(a**S(2) + S(2)*a*b*x**(-S(1)/(S(2)*p + S(2))) + b**S(2)*x**(-S(1)/(p + S(1))))**(p + S(1))/(a**S(2)*(S(2)*p + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))**((-S(2)*n + S(-1))/(S(2)*n)), x), x, x*(a + b*x**n)*(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))**(S(-1) - S(1)/(S(2)*n))/(a*(n + S(1))) + n*x*(a**S(2) + S(2)*a*b*x**n + b**S(2)*x**(S(2)*n))**(-S(1)/(S(2)*n))/(a**S(2)*(n + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(4)*n + S(-1))/(a + b*x**n + c*x**(S(2)*n)), x), x, -b*x**n/(c**S(2)*n) + b*(-S(3)*a*c + b**S(2))*atanh((b + S(2)*c*x**n)/sqrt(-S(4)*a*c + b**S(2)))/(c**S(3)*n*sqrt(-S(4)*a*c + b**S(2))) + x**(S(2)*n)/(S(2)*c*n) + (-a*c + b**S(2))*log(a + b*x**n + c*x**(S(2)*n))/(S(2)*c**S(3)*n), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(3)*n + S(-1))/(a + b*x**n + c*x**(S(2)*n)), x), x, -b*log(a + b*x**n + c*x**(S(2)*n))/(S(2)*c**S(2)*n) + x**n/(c*n) - (-S(2)*a*c + b**S(2))*atanh((b + S(2)*c*x**n)/sqrt(-S(4)*a*c + b**S(2)))/(c**S(2)*n*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(2)*n + S(-1))/(a + b*x**n + c*x**(S(2)*n)), x), x, b*atanh((b + S(2)*c*x**n)/sqrt(-S(4)*a*c + b**S(2)))/(c*n*sqrt(-S(4)*a*c + b**S(2))) + log(a + b*x**n + c*x**(S(2)*n))/(S(2)*c*n), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(n + S(-1))/(a + b*x**n + c*x**(S(2)*n)), x), x, -S(2)*atanh((b + S(2)*c*x**n)/sqrt(-S(4)*a*c + b**S(2)))/(n*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(-n + S(-1))/(a + b*x**n + c*x**(S(2)*n)), x), x, -x**(-n)/(a*n) - b*log(x)/a**S(2) + b*log(a + b*x**n + c*x**(S(2)*n))/(S(2)*a**S(2)*n) - (-S(2)*a*c + b**S(2))*atanh((b + S(2)*c*x**n)/sqrt(-S(4)*a*c + b**S(2)))/(a**S(2)*n*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(-S(2)*n + S(-1))/(a + b*x**n + c*x**(S(2)*n)), x), x, -x**(-S(2)*n)/(S(2)*a*n) + b*x**(-n)/(a**S(2)*n) + b*(-S(3)*a*c + b**S(2))*atanh((b + S(2)*c*x**n)/sqrt(-S(4)*a*c + b**S(2)))/(a**S(3)*n*sqrt(-S(4)*a*c + b**S(2))) + (-a*c + b**S(2))*log(x)/a**S(3) - (-a*c + b**S(2))*log(a + b*x**n + c*x**(S(2)*n))/(S(2)*a**S(3)*n), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(-S(3)*n + S(-1))/(a + b*x**n + c*x**(S(2)*n)), x), x, -x**(-S(3)*n)/(S(3)*a*n) + b*x**(-S(2)*n)/(S(2)*a**S(2)*n) - x**(-n)*(-a*c + b**S(2))/(a**S(3)*n) - b*(-S(2)*a*c + b**S(2))*log(x)/a**S(4) + b*(-S(2)*a*c + b**S(2))*log(a + b*x**n + c*x**(S(2)*n))/(S(2)*a**S(4)*n) - (S(2)*a**S(2)*c**S(2) - S(4)*a*b**S(2)*c + b**S(4))*atanh((b + S(2)*c*x**n)/sqrt(-S(4)*a*c + b**S(2)))/(a**S(4)*n*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(n/S(4) + S(-1))/(a + b*x**n + c*x**(S(2)*n)), x), x, -S(2)*S(2)**(S(3)/4)*c**(S(3)/4)*atan(S(2)**(S(1)/4)*c**(S(1)/4)*x**(n/S(4))/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(n*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)*sqrt(-S(4)*a*c + b**S(2))) - S(2)*S(2)**(S(3)/4)*c**(S(3)/4)*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*x**(n/S(4))/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(n*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)*sqrt(-S(4)*a*c + b**S(2))) + S(2)*S(2)**(S(3)/4)*c**(S(3)/4)*atan(S(2)**(S(1)/4)*c**(S(1)/4)*x**(n/S(4))/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(n*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)*sqrt(-S(4)*a*c + b**S(2))) + S(2)*S(2)**(S(3)/4)*c**(S(3)/4)*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*x**(n/S(4))/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(n*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(n/S(3) + S(-1))/(a + b*x**n + c*x**(S(2)*n)), x), x, -S(2)**(S(2)/3)*c**(S(2)/3)*log(S(2)**(S(1)/3)*c**(S(1)/3)*x**(n/S(3)) + (b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3))/(n*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)*sqrt(-S(4)*a*c + b**S(2))) + S(2)**(S(2)/3)*c**(S(2)/3)*log(S(2)**(S(2)/3)*c**(S(2)/3)*x**(S(2)*n/S(3)) - S(2)**(S(1)/3)*c**(S(1)/3)*x**(n/S(3))*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + (b + sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3))/(S(2)*n*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)*sqrt(-S(4)*a*c + b**S(2))) + S(2)**(S(2)/3)*sqrt(S(3))*c**(S(2)/3)*atan(sqrt(S(3))*(-S(2)*S(2)**(S(1)/3)*c**(S(1)/3)*x**(n/S(3))/(b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + S(1))/S(3))/(n*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)*sqrt(-S(4)*a*c + b**S(2))) + S(2)**(S(2)/3)*c**(S(2)/3)*log(S(2)**(S(1)/3)*c**(S(1)/3)*x**(n/S(3)) + (b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3))/(n*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)*sqrt(-S(4)*a*c + b**S(2))) - S(2)**(S(2)/3)*c**(S(2)/3)*log(S(2)**(S(2)/3)*c**(S(2)/3)*x**(S(2)*n/S(3)) - S(2)**(S(1)/3)*c**(S(1)/3)*x**(n/S(3))*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + (b - sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3))/(S(2)*n*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)*sqrt(-S(4)*a*c + b**S(2))) - S(2)**(S(2)/3)*sqrt(S(3))*c**(S(2)/3)*atan(sqrt(S(3))*(-S(2)*S(2)**(S(1)/3)*c**(S(1)/3)*x**(n/S(3))/(b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + S(1))/S(3))/(n*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(n/S(2) + S(-1))/(a + b*x**n + c*x**(S(2)*n)), x), x, -S(2)*sqrt(S(2))*sqrt(c)*atan(sqrt(S(2))*sqrt(c)*x**(n/S(2))/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(n*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*sqrt(-S(4)*a*c + b**S(2))) + S(2)*sqrt(S(2))*sqrt(c)*atan(sqrt(S(2))*sqrt(c)*x**(n/S(2))/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(n*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(-n/S(2) + S(-1))/(a + b*x**n + c*x**(S(2)*n)), x), x, -S(2)*x**(-n/S(2))/(a*n) + sqrt(S(2))*(b - (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(a)*x**(-n/S(2))/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(a**(S(3)/2)*n*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))) + sqrt(S(2))*(b + (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(a)*x**(-n/S(2))/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(a**(S(3)/2)*n*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(-n/S(3) + S(-1))/(a + b*x**n + c*x**(S(2)*n)), x), x, -S(3)*x**(-n/S(3))/(a*n) + S(2)**(S(2)/3)*(b - (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*log(S(2)**(S(1)/3)*a**(S(1)/3)*x**(-n/S(3)) + (b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3))/(S(2)*a**(S(4)/3)*n*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)) - S(2)**(S(2)/3)*(b - (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*log(S(2)**(S(2)/3)*a**(S(2)/3)*x**(-S(2)*n/S(3)) - S(2)**(S(1)/3)*a**(S(1)/3)*x**(-n/S(3))*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + (b - sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3))/(S(4)*a**(S(4)/3)*n*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)) - S(2)**(S(2)/3)*sqrt(S(3))*(b - (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(3))*(-S(2)*S(2)**(S(1)/3)*a**(S(1)/3)*x**(-n/S(3))/(b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + S(1))/S(3))/(S(2)*a**(S(4)/3)*n*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)) + S(2)**(S(2)/3)*(b + (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*log(S(2)**(S(1)/3)*a**(S(1)/3)*x**(-n/S(3)) + (b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3))/(S(2)*a**(S(4)/3)*n*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)) - S(2)**(S(2)/3)*(b + (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*log(S(2)**(S(2)/3)*a**(S(2)/3)*x**(-S(2)*n/S(3)) - S(2)**(S(1)/3)*a**(S(1)/3)*x**(-n/S(3))*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + (b + sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3))/(S(4)*a**(S(4)/3)*n*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)) - S(2)**(S(2)/3)*sqrt(S(3))*(b + (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(3))*(-S(2)*S(2)**(S(1)/3)*a**(S(1)/3)*x**(-n/S(3))/(b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + S(1))/S(3))/(S(2)*a**(S(4)/3)*n*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(-n/S(4) + S(-1))/(a + b*x**n + c*x**(S(2)*n)), x), x, -S(4)*x**(-n/S(4))/(a*n) - S(2)**(S(3)/4)*(b - (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(S(2)**(S(1)/4)*a**(S(1)/4)*x**(-n/S(4))/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(a**(S(5)/4)*n*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)) - S(2)**(S(3)/4)*(b - (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atanh(S(2)**(S(1)/4)*a**(S(1)/4)*x**(-n/S(4))/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(a**(S(5)/4)*n*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)) - S(2)**(S(3)/4)*(b + (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(S(2)**(S(1)/4)*a**(S(1)/4)*x**(-n/S(4))/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(a**(S(5)/4)*n*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)) - S(2)**(S(3)/4)*(b + (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atanh(S(2)**(S(1)/4)*a**(S(1)/4)*x**(-n/S(4))/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(a**(S(5)/4)*n*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/(a + b*x**n + c*x**(S(2)*n)), x), x, -S(2)*c*x**S(3)*hyper((S(1), S(3)/n), ((n + S(3))/n,), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(-S(12)*a*c + S(3)*b**S(2) + S(3)*b*sqrt(-S(4)*a*c + b**S(2))) - S(2)*c*x**S(3)*hyper((S(1), S(3)/n), ((n + S(3))/n,), -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))))/(-S(12)*a*c + S(3)*b**S(2) - S(3)*b*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(a + b*x**n + c*x**(S(2)*n)), x), x, -c*x**S(2)*hyper((S(1), S(2)/n), ((n + S(2))/n,), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(-S(4)*a*c + b**S(2) + b*sqrt(-S(4)*a*c + b**S(2))) - c*x**S(2)*hyper((S(1), S(2)/n), ((n + S(2))/n,), -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))))/(-S(4)*a*c + b**S(2) - b*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(a + b*x**n + c*x**(S(2)*n)), x), x, -S(2)*c*x*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(-S(4)*a*c + b**S(2) + b*sqrt(-S(4)*a*c + b**S(2))) - S(2)*c*x*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))))/(-S(4)*a*c + b**S(2) - b*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*(a + b*x**n + c*x**(S(2)*n))), x), x, b*atanh((b + S(2)*c*x**n)/sqrt(-S(4)*a*c + b**S(2)))/(a*n*sqrt(-S(4)*a*c + b**S(2))) + log(x)/a - log(a + b*x**n + c*x**(S(2)*n))/(S(2)*a*n), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*(a + b*x**n + c*x**(S(2)*n))), x), x, S(2)*c*hyper((S(1), -S(1)/n), (-(-n + S(1))/n,), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(x*(-S(4)*a*c + b**S(2) + b*sqrt(-S(4)*a*c + b**S(2)))) + S(2)*c*hyper((S(1), -S(1)/n), (-(-n + S(1))/n,), -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))))/(x*(-S(4)*a*c + b**S(2) - b*sqrt(-S(4)*a*c + b**S(2)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(3)*(a + b*x**n + c*x**(S(2)*n))), x), x, c*hyper((S(1), -S(2)/n), (-(-n + S(2))/n,), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(x**S(2)*(-S(4)*a*c + b**S(2) + b*sqrt(-S(4)*a*c + b**S(2)))) + c*hyper((S(1), -S(2)/n), (-(-n + S(2))/n,), -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))))/(x**S(2)*(-S(4)*a*c + b**S(2) - b*sqrt(-S(4)*a*c + b**S(2)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*sqrt(a + b*x**n + c*x**(S(2)*n)), x), x, x**S(4)*sqrt(a + b*x**n + c*x**(S(2)*n))*AppellF1(S(4)/n, S(-1)/2, S(-1)/2, (n + S(4))/n, -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(4)*sqrt(S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*sqrt(a + b*x**n + c*x**(S(2)*n)), x), x, x**S(3)*sqrt(a + b*x**n + c*x**(S(2)*n))*AppellF1(S(3)/n, S(-1)/2, S(-1)/2, (n + S(3))/n, -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(3)*sqrt(S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*sqrt(a + b*x**n + c*x**(S(2)*n)), x), x, x**S(2)*sqrt(a + b*x**n + c*x**(S(2)*n))*AppellF1(S(2)/n, S(-1)/2, S(-1)/2, (n + S(2))/n, -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*sqrt(S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a + b*x**n + c*x**(S(2)*n)), x), x, x*sqrt(a + b*x**n + c*x**(S(2)*n))*AppellF1(S(1)/n, S(-1)/2, S(-1)/2, S(1) + S(1)/n, -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(sqrt(S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a + b*x**n + c*x**(S(2)*n))/x**S(2), x), x, -sqrt(a + b*x**n + c*x**(S(2)*n))*AppellF1(-S(1)/n, S(-1)/2, S(-1)/2, -(-n + S(1))/n, -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(x*sqrt(S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a + b*x**n + c*x**(S(2)*n))/x**S(3), x), x, -sqrt(a + b*x**n + c*x**(S(2)*n))*AppellF1(-S(2)/n, S(-1)/2, S(-1)/2, -(-n + S(2))/n, -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*x**S(2)*sqrt(S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*(a + b*x**n + c*x**(S(2)*n))**(S(3)/2), x), x, a*x**S(4)*sqrt(a + b*x**n + c*x**(S(2)*n))*AppellF1(S(4)/n, S(-3)/2, S(-3)/2, (n + S(4))/n, -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(4)*sqrt(S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(a + b*x**n + c*x**(S(2)*n))**(S(3)/2), x), x, a*x**S(3)*sqrt(a + b*x**n + c*x**(S(2)*n))*AppellF1(S(3)/n, S(-3)/2, S(-3)/2, (n + S(3))/n, -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(3)*sqrt(S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(a + b*x**n + c*x**(S(2)*n))**(S(3)/2), x), x, a*x**S(2)*sqrt(a + b*x**n + c*x**(S(2)*n))*AppellF1(S(2)/n, S(-3)/2, S(-3)/2, (n + S(2))/n, -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*sqrt(S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**n + c*x**(S(2)*n))**(S(3)/2), x), x, a*x*sqrt(a + b*x**n + c*x**(S(2)*n))*AppellF1(S(1)/n, S(-3)/2, S(-3)/2, S(1) + S(1)/n, -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(sqrt(S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**n + c*x**(S(2)*n))**(S(3)/2)/x**S(2), x), x, -a*sqrt(a + b*x**n + c*x**(S(2)*n))*AppellF1(-S(1)/n, S(-3)/2, S(-3)/2, -(-n + S(1))/n, -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(x*sqrt(S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**n + c*x**(S(2)*n))**(S(3)/2)/x**S(3), x), x, -a*sqrt(a + b*x**n + c*x**(S(2)*n))*AppellF1(-S(2)/n, S(-3)/2, S(-3)/2, -(-n + S(2))/n, -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*x**S(2)*sqrt(S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/sqrt(a + b*x**n + c*x**(S(2)*n)), x), x, x**S(4)*sqrt(S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))*AppellF1(S(4)/n, S(1)/2, S(1)/2, (n + S(4))/n, -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(4)*sqrt(a + b*x**n + c*x**(S(2)*n))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/sqrt(a + b*x**n + c*x**(S(2)*n)), x), x, x**S(3)*sqrt(S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))*AppellF1(S(3)/n, S(1)/2, S(1)/2, (n + S(3))/n, -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(3)*sqrt(a + b*x**n + c*x**(S(2)*n))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/sqrt(a + b*x**n + c*x**(S(2)*n)), x), x, x**S(2)*sqrt(S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))*AppellF1(S(2)/n, S(1)/2, S(1)/2, (n + S(2))/n, -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*sqrt(a + b*x**n + c*x**(S(2)*n))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(a + b*x**n + c*x**(S(2)*n)), x), x, x*sqrt(S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))*AppellF1(S(1)/n, S(1)/2, S(1)/2, S(1) + S(1)/n, -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/sqrt(a + b*x**n + c*x**(S(2)*n)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/(a + b*x**n + c*x**(S(2)*n))**(S(3)/2), x), x, x**S(3)*sqrt(S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))*AppellF1(S(3)/n, S(3)/2, S(3)/2, (n + S(3))/n, -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(3)*a*sqrt(a + b*x**n + c*x**(S(2)*n))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(a + b*x**n + c*x**(S(2)*n))**(S(3)/2), x), x, x**S(2)*sqrt(S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))*AppellF1(S(2)/n, S(3)/2, S(3)/2, (n + S(2))/n, -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*a*sqrt(a + b*x**n + c*x**(S(2)*n))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**n + c*x**(S(2)*n))**(S(-3)/2), x), x, x*sqrt(S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))*AppellF1(S(1)/n, S(3)/2, S(3)/2, S(1) + S(1)/n, -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(a*sqrt(a + b*x**n + c*x**(S(2)*n))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*(a + b*x**n + c*x**(S(2)*n))**(S(3)/2)), x), x, (-S(4)*a*c + S(2)*b**S(2) + S(2)*b*c*x**n)/(a*n*(-S(4)*a*c + b**S(2))*sqrt(a + b*x**n + c*x**(S(2)*n))) - atanh((S(2)*a + b*x**n)/(S(2)*sqrt(a)*sqrt(a + b*x**n + c*x**(S(2)*n))))/(a**(S(3)/2)*n), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*(a + b*x**n + c*x**(S(2)*n))**(S(3)/2)), x), x, -sqrt(S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))*AppellF1(-S(1)/n, S(3)/2, S(3)/2, -(-n + S(1))/n, -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(a*x*sqrt(a + b*x**n + c*x**(S(2)*n))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(3)*(a + b*x**n + c*x**(S(2)*n))**(S(3)/2)), x), x, -sqrt(S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))*AppellF1(-S(2)/n, S(3)/2, S(3)/2, -(-n + S(2))/n, -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*a*x**S(2)*sqrt(a + b*x**n + c*x**(S(2)*n))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*sqrt(a + b*x**n + c*x**(S(2)*n))), x), x, -sqrt(S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))*AppellF1(-S(1)/n, S(1)/2, S(1)/2, -(-n + S(1))/n, -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(x*sqrt(a + b*x**n + c*x**(S(2)*n))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(3)*sqrt(a + b*x**n + c*x**(S(2)*n))), x), x, -sqrt(S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))*AppellF1(-S(2)/n, S(1)/2, S(1)/2, -(-n + S(2))/n, -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*x**S(2)*sqrt(a + b*x**n + c*x**(S(2)*n))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/(a + b*x**n + c*x**(S(2)*n))**(S(3)/2), x), x, x**S(4)*sqrt(S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))*AppellF1(S(4)/n, S(3)/2, S(3)/2, (n + S(4))/n, -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(4)*a*sqrt(a + b*x**n + c*x**(S(2)*n))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**m*(a + b*x**n + c*x**(S(2)*n))**(S(3)/2), x), x, a*(d*x)**(m + S(1))*sqrt(a + b*x**n + c*x**(S(2)*n))*AppellF1((m + S(1))/n, S(-3)/2, S(-3)/2, (m + n + S(1))/n, -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(d*(m + S(1))*sqrt(S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**m*sqrt(a + b*x**n + c*x**(S(2)*n)), x), x, (d*x)**(m + S(1))*sqrt(a + b*x**n + c*x**(S(2)*n))*AppellF1((m + S(1))/n, S(-1)/2, S(-1)/2, (m + n + S(1))/n, -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(d*(m + S(1))*sqrt(S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**m/sqrt(a + b*x**n + c*x**(S(2)*n)), x), x, (d*x)**(m + S(1))*sqrt(S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))*AppellF1((m + S(1))/n, S(1)/2, S(1)/2, (m + n + S(1))/n, -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(d*(m + S(1))*sqrt(a + b*x**n + c*x**(S(2)*n))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**m/(a + b*x**n + c*x**(S(2)*n))**(S(3)/2), x), x, (d*x)**(m + S(1))*sqrt(S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))*AppellF1((m + S(1))/n, S(3)/2, S(3)/2, (m + n + S(1))/n, -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(a*d*(m + S(1))*sqrt(a + b*x**n + c*x**(S(2)*n))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**m*(a + b*x**n + c*x**(S(2)*n))**p, x), x, (d*x)**(m + S(1))*(S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))**(-p)*(S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))**(-p)*(a + b*x**n + c*x**(S(2)*n))**p*AppellF1((m + S(1))/n, -p, -p, (m + n + S(1))/n, -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(d*(m + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/sqrt(a + b*(d + e*x)**S(3) + c*(d + e*x)**S(6)), x), x, -d*(d + e*x)*sqrt(S(2)*c*(d + e*x)**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*(d + e*x)**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))*AppellF1(S(1)/3, S(1)/2, S(1)/2, S(4)/3, -S(2)*c*(d + e*x)**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*(d + e*x)**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))))/(e**S(2)*sqrt(a + b*(d + e*x)**S(3) + c*(d + e*x)**S(6))) + (d + e*x)**S(2)*sqrt(S(2)*c*(d + e*x)**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*(d + e*x)**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))*AppellF1(S(2)/3, S(1)/2, S(1)/2, S(5)/3, -S(2)*c*(d + e*x)**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*(d + e*x)**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*e**S(2)*sqrt(a + b*(d + e*x)**S(3) + c*(d + e*x)**S(6))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/sqrt(a + b*(d + e*x)**S(3) + c*(d + e*x)**S(6)), x), x, d**S(2)*(d + e*x)*sqrt(S(2)*c*(d + e*x)**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*(d + e*x)**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))*AppellF1(S(1)/3, S(1)/2, S(1)/2, S(4)/3, -S(2)*c*(d + e*x)**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*(d + e*x)**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))))/(e**S(3)*sqrt(a + b*(d + e*x)**S(3) + c*(d + e*x)**S(6))) - d*(d + e*x)**S(2)*sqrt(S(2)*c*(d + e*x)**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*(d + e*x)**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))*AppellF1(S(2)/3, S(1)/2, S(1)/2, S(5)/3, -S(2)*c*(d + e*x)**S(3)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*(d + e*x)**S(3)/(b + sqrt(-S(4)*a*c + b**S(2))))/(e**S(3)*sqrt(a + b*(d + e*x)**S(3) + c*(d + e*x)**S(6))) + atanh((b + S(2)*c*(d + e*x)**S(3))/(S(2)*sqrt(c)*sqrt(a + b*(d + e*x)**S(3) + c*(d + e*x)**S(6))))/(S(3)*sqrt(c)*e**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a + b*x**n + c*x**(S(2)*n))/x, x), x, -sqrt(a)*atanh((S(2)*a + b*x**n)/(S(2)*sqrt(a)*sqrt(a + b*x**n + c*x**(S(2)*n))))/n + b*atanh((b + S(2)*c*x**n)/(S(2)*sqrt(c)*sqrt(a + b*x**n + c*x**(S(2)*n))))/(S(2)*sqrt(c)*n) + sqrt(a + b*x**n + c*x**(S(2)*n))/n, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**n + c*x**(S(2)*n))**(S(3)/2)/x, x), x, -a**(S(3)/2)*atanh((S(2)*a + b*x**n)/(S(2)*sqrt(a)*sqrt(a + b*x**n + c*x**(S(2)*n))))/n - b*(-S(12)*a*c + b**S(2))*atanh((b + S(2)*c*x**n)/(S(2)*sqrt(c)*sqrt(a + b*x**n + c*x**(S(2)*n))))/(S(16)*c**(S(3)/2)*n) + (a + b*x**n + c*x**(S(2)*n))**(S(3)/2)/(S(3)*n) + sqrt(a + b*x**n + c*x**(S(2)*n))*(S(8)*a*c + b**S(2) + S(2)*b*c*x**n)/(S(8)*c*n), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*sqrt(a + b*x**n + c*x**(S(2)*n))), x), x, -atanh((S(2)*a + b*x**n)/(S(2)*sqrt(a)*sqrt(a + b*x**n + c*x**(S(2)*n))))/(sqrt(a)*n), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**m*(a + b*x**n + c*x**(S(2)*n))**S(3), x), x, a**S(3)*(d*x)**(m + S(1))/(d*(m + S(1))) + S(3)*a**S(2)*b*x**(n + S(1))*(d*x)**m/(m + n + S(1)) + S(3)*a*x**(S(2)*n + S(1))*(d*x)**m*(a*c + b**S(2))/(m + S(2)*n + S(1)) + S(3)*b*c**S(2)*x**(S(5)*n + S(1))*(d*x)**m/(m + S(5)*n + S(1)) + b*x**(S(3)*n + S(1))*(d*x)**m*(S(6)*a*c + b**S(2))/(m + S(3)*n + S(1)) + c**S(3)*x**(S(6)*n + S(1))*(d*x)**m/(m + S(6)*n + S(1)) + S(3)*c*x**(S(4)*n + S(1))*(d*x)**m*(a*c + b**S(2))/(m + S(4)*n + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**m*(a + b*x**n + c*x**(S(2)*n))**S(2), x), x, a**S(2)*(d*x)**(m + S(1))/(d*(m + S(1))) + S(2)*a*b*x**(n + S(1))*(d*x)**m/(m + n + S(1)) + S(2)*b*c*x**(S(3)*n + S(1))*(d*x)**m/(m + S(3)*n + S(1)) + c**S(2)*x**(S(4)*n + S(1))*(d*x)**m/(m + S(4)*n + S(1)) + x**(S(2)*n + S(1))*(d*x)**m*(S(2)*a*c + b**S(2))/(m + S(2)*n + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**m*(a + b*x**n + c*x**(S(2)*n)), x), x, a*(d*x)**(m + S(1))/(d*(m + S(1))) + b*x**(n + S(1))*(d*x)**m/(m + n + S(1)) + c*x**(S(2)*n + S(1))*(d*x)**m/(m + S(2)*n + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**m/(a + b*x**n + c*x**(S(2)*n)), x), x, -S(2)*c*(d*x)**(m + S(1))*hyper((S(1), (m + S(1))/n), ((m + n + S(1))/n,), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(d*(b + sqrt(-S(4)*a*c + b**S(2)))*(m + S(1))*sqrt(-S(4)*a*c + b**S(2))) + S(2)*c*(d*x)**(m + S(1))*hyper((S(1), (m + S(1))/n), ((m + n + S(1))/n,), -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))))/(d*(b - sqrt(-S(4)*a*c + b**S(2)))*(m + S(1))*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**m/(a + b*x**n + c*x**(S(2)*n))**S(2), x), x, -c*(d*x)**(m + S(1))*(S(4)*a*c*(m - S(2)*n + S(1)) - b**S(2)*(m - n + S(1)) + b*sqrt(-S(4)*a*c + b**S(2))*(m - n + S(1)))*hyper((S(1), (m + S(1))/n), ((m + n + S(1))/n,), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(a*d*n*(b + sqrt(-S(4)*a*c + b**S(2)))*(m + S(1))*(-S(4)*a*c + b**S(2))**(S(3)/2)) + c*(d*x)**(m + S(1))*(-b*(m - n + S(1)) + (S(4)*a*c*(m - S(2)*n + S(1)) - b**S(2)*(m - n + S(1)))/sqrt(-S(4)*a*c + b**S(2)))*hyper((S(1), (m + S(1))/n), ((m + n + S(1))/n,), -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))))/(a*d*n*(b - sqrt(-S(4)*a*c + b**S(2)))*(m + S(1))*(-S(4)*a*c + b**S(2))) + (d*x)**(m + S(1))*(-S(2)*a*c + b**S(2) + b*c*x**n)/(a*d*n*(-S(4)*a*c + b**S(2))*(a + b*x**n + c*x**(S(2)*n))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**m/(a + b*x**n + c*x**(S(2)*n))**S(3), x), x, (d*x)**(m + S(1))*(-S(2)*a*c + b**S(2) + b*c*x**n)/(S(2)*a*d*n*(-S(4)*a*c + b**S(2))*(a + b*x**n + c*x**(S(2)*n))**S(2)) - c*(d*x)**(m + S(1))*(S(8)*a**S(2)*c**S(2)*(m**S(2) + m*(-S(6)*n + S(2)) + S(8)*n**S(2) - S(6)*n + S(1)) - S(6)*a*b**S(2)*c*(m**S(2) + m*(-S(4)*n + S(2)) + S(3)*n**S(2) - S(4)*n + S(1)) + b**S(4)*(m**S(2) + m*(-S(3)*n + S(2)) + S(2)*n**S(2) - S(3)*n + S(1)) + b*sqrt(-S(4)*a*c + b**S(2))*(S(2)*a*c*(S(2)*m - S(7)*n + S(2)) - b**S(2)*(m - S(2)*n + S(1)))*(m - n + S(1)))*hyper((S(1), (m + S(1))/n), ((m + n + S(1))/n,), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*a**S(2)*d*n**S(2)*(b + sqrt(-S(4)*a*c + b**S(2)))*(m + S(1))*(-S(4)*a*c + b**S(2))**(S(5)/2)) - c*(d*x)**(m + S(1))*(-S(8)*a**S(2)*c**S(2)*(m**S(2) + m*(-S(6)*n + S(2)) + S(8)*n**S(2) - S(6)*n + S(1)) + S(6)*a*b**S(2)*c*(m**S(2) + m*(-S(4)*n + S(2)) + S(3)*n**S(2) - S(4)*n + S(1)) - b**S(4)*(m**S(2) + m*(-S(3)*n + S(2)) + S(2)*n**S(2) - S(3)*n + S(1)) + b*sqrt(-S(4)*a*c + b**S(2))*(S(2)*a*c*(S(2)*m - S(7)*n + S(2)) - b**S(2)*(m - S(2)*n + S(1)))*(m - n + S(1)))*hyper((S(1), (m + S(1))/n), ((m + n + S(1))/n,), -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*a**S(2)*d*n**S(2)*(b - sqrt(-S(4)*a*c + b**S(2)))*(m + S(1))*(-S(4)*a*c + b**S(2))**(S(5)/2)) - (d*x)**(m + S(1))*(S(4)*a**S(2)*c**S(2)*(m - S(4)*n + S(1)) - S(5)*a*b**S(2)*c*(m - S(3)*n + S(1)) + b**S(4)*(m - S(2)*n + S(1)) - b*c*x**n*(S(2)*a*c*(S(2)*m - S(7)*n + S(2)) - b**S(2)*(m - S(2)*n + S(1))))/(S(2)*a**S(2)*d*n**S(2)*(-S(4)*a*c + b**S(2))**S(2)*(a + b*x**n + c*x**(S(2)*n))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x)**S(3)*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4)), x), x, a*(d + e*x)**S(4)/(S(4)*e) + b*(d + e*x)**S(6)/(S(6)*e) + c*(d + e*x)**S(8)/(S(8)*e), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x)**S(3)*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))**S(2), x), x, a**S(2)*(d + e*x)**S(4)/(S(4)*e) + a*b*(d + e*x)**S(6)/(S(3)*e) + b*c*(d + e*x)**S(10)/(S(5)*e) + c**S(2)*(d + e*x)**S(12)/(S(12)*e) + (d + e*x)**S(8)*(S(2)*a*c + b**S(2))/(S(8)*e), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x)**S(3)*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))**S(3), x), x, a**S(3)*(d + e*x)**S(4)/(S(4)*e) + a**S(2)*b*(d + e*x)**S(6)/(S(2)*e) + S(3)*a*(d + e*x)**S(8)*(a*c + b**S(2))/(S(8)*e) + S(3)*b*c**S(2)*(d + e*x)**S(14)/(S(14)*e) + b*(d + e*x)**S(10)*(S(6)*a*c + b**S(2))/(S(10)*e) + c**S(3)*(d + e*x)**S(16)/(S(16)*e) + c*(d + e*x)**S(12)*(a*c + b**S(2))/(S(4)*e), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*f + e*f*x)**S(3)*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4)), x), x, a*f**S(3)*(d + e*x)**S(4)/(S(4)*e) + b*f**S(3)*(d + e*x)**S(6)/(S(6)*e) + c*f**S(3)*(d + e*x)**S(8)/(S(8)*e), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*f + e*f*x)**S(3)*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))**S(2), x), x, a**S(2)*f**S(3)*(d + e*x)**S(4)/(S(4)*e) + a*b*f**S(3)*(d + e*x)**S(6)/(S(3)*e) + b*c*f**S(3)*(d + e*x)**S(10)/(S(5)*e) + c**S(2)*f**S(3)*(d + e*x)**S(12)/(S(12)*e) + f**S(3)*(d + e*x)**S(8)*(S(2)*a*c + b**S(2))/(S(8)*e), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*f + e*f*x)**S(3)*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))**S(3), x), x, a**S(3)*f**S(3)*(d + e*x)**S(4)/(S(4)*e) + a**S(2)*b*f**S(3)*(d + e*x)**S(6)/(S(2)*e) + S(3)*a*f**S(3)*(d + e*x)**S(8)*(a*c + b**S(2))/(S(8)*e) + S(3)*b*c**S(2)*f**S(3)*(d + e*x)**S(14)/(S(14)*e) + b*f**S(3)*(d + e*x)**S(10)*(S(6)*a*c + b**S(2))/(S(10)*e) + c**S(3)*f**S(3)*(d + e*x)**S(16)/(S(16)*e) + c*f**S(3)*(d + e*x)**S(12)*(a*c + b**S(2))/(S(4)*e), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x)**S(4)/(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4)), x), x, x/c - sqrt(S(2))*(b - (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*(d + e*x)/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*c**(S(3)/2)*e*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))) - sqrt(S(2))*(b + (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*(d + e*x)/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*c**(S(3)/2)*e*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x)**S(3)/(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4)), x), x, b*atanh((b + S(2)*c*(d + e*x)**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*c*e*sqrt(-S(4)*a*c + b**S(2))) + log(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))/(S(4)*c*e), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x)**S(2)/(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4)), x), x, -sqrt(S(2))*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*(d + e*x)/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*sqrt(c)*e*sqrt(-S(4)*a*c + b**S(2))) + sqrt(S(2))*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*(d + e*x)/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*sqrt(c)*e*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x)/(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4)), x), x, -atanh((b + S(2)*c*(d + e*x)**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(e*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((d + e*x)*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))), x), x, b*atanh((b + S(2)*c*(d + e*x)**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*a*e*sqrt(-S(4)*a*c + b**S(2))) + log(d + e*x)/(a*e) - log(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))/(S(4)*a*e), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((d + e*x)**S(2)*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))), x), x, -sqrt(S(2))*sqrt(c)*(-b/sqrt(-S(4)*a*c + b**S(2)) + S(1))*atan(sqrt(S(2))*sqrt(c)*(d + e*x)/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*a*e*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))) - sqrt(S(2))*sqrt(c)*(b/sqrt(-S(4)*a*c + b**S(2)) + S(1))*atan(sqrt(S(2))*sqrt(c)*(d + e*x)/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*a*e*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))) - S(1)/(a*e*(d + e*x)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((d + e*x)**S(3)*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))), x), x, -S(1)/(S(2)*a*e*(d + e*x)**S(2)) - b*log(d + e*x)/(a**S(2)*e) + b*log(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))/(S(4)*a**S(2)*e) - (-S(2)*a*c + b**S(2))*atanh((b + S(2)*c*(d + e*x)**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*a**S(2)*e*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((d + e*x)**S(4)*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))), x), x, -S(1)/(S(3)*a*e*(d + e*x)**S(3)) + b/(a**S(2)*e*(d + e*x)) + sqrt(S(2))*sqrt(c)*(b - (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*(d + e*x)/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*a**S(2)*e*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))) + sqrt(S(2))*sqrt(c)*(b + (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*(d + e*x)/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*a**S(2)*e*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x)**S(4)/(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))**S(2), x), x, (S(2)*a + b*(d + e*x)**S(2))*(d + e*x)/(e*(-S(8)*a*c + S(2)*b**S(2))*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))) + sqrt(S(2))*(b - (S(4)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*(d + e*x)/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(4)*sqrt(c)*e*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))) + sqrt(S(2))*(S(4)*a*c + b**S(2) + b*sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*(d + e*x)/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(4)*sqrt(c)*e*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x)**S(3)/(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))**S(2), x), x, -b*atanh((b + S(2)*c*(d + e*x)**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(e*(-S(4)*a*c + b**S(2))**(S(3)/2)) + (S(2)*a + b*(d + e*x)**S(2))/(e*(-S(8)*a*c + S(2)*b**S(2))*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x)**S(2)/(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))**S(2), x), x, -sqrt(S(2))*sqrt(c)*(S(2)*b + sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*(d + e*x)/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*e*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)) + sqrt(S(2))*sqrt(c)*(S(2)*b - sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*(d + e*x)/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*e*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)) - (b + S(2)*c*(d + e*x)**S(2))*(d + e*x)/(e*(-S(8)*a*c + S(2)*b**S(2))*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x)/(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))**S(2), x), x, S(2)*c*atanh((b + S(2)*c*(d + e*x)**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(e*(-S(4)*a*c + b**S(2))**(S(3)/2)) + (-b - S(2)*c*(d + e*x)**S(2))/(e*(-S(8)*a*c + S(2)*b**S(2))*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))**(S(-2)), x), x, -sqrt(S(2))*sqrt(c)*(-S(12)*a*c + b**S(2) - b*sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*(d + e*x)/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(4)*a*e*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)) + sqrt(S(2))*sqrt(c)*(-S(12)*a*c + b**S(2) + b*sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*(d + e*x)/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(4)*a*e*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)) + (d + e*x)*(-S(2)*a*c + b**S(2) + b*c*(d + e*x)**S(2))/(S(2)*a*e*(-S(4)*a*c + b**S(2))*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((d + e*x)*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))**S(2)), x), x, (-S(2)*a*c + b**S(2) + b*c*(d + e*x)**S(2))/(S(2)*a*e*(-S(4)*a*c + b**S(2))*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))) + b*(-S(6)*a*c + b**S(2))*atanh((b + S(2)*c*(d + e*x)**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*a**S(2)*e*(-S(4)*a*c + b**S(2))**(S(3)/2)) + log(d + e*x)/(a**S(2)*e) - log(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))/(S(4)*a**S(2)*e), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((d + e*x)**S(2)*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))**S(2)), x), x, (-S(2)*a*c + b**S(2) + b*c*(d + e*x)**S(2))/(S(2)*a*e*(d + e*x)*(-S(4)*a*c + b**S(2))*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))) + sqrt(S(2))*sqrt(c)*(-S(16)*a*b*c + S(3)*b**S(3) - (-S(10)*a*c + S(3)*b**S(2))*sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*(d + e*x)/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(4)*a**S(2)*e*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)) - sqrt(S(2))*sqrt(c)*(-S(16)*a*b*c + S(3)*b**S(3) + (-S(10)*a*c + S(3)*b**S(2))*sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*(d + e*x)/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(4)*a**S(2)*e*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)) - (-S(10)*a*c + S(3)*b**S(2))/(S(2)*a**S(2)*e*(d + e*x)*(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((d + e*x)**S(3)*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))**S(2)), x), x, (-S(2)*a*c + b**S(2) + b*c*(d + e*x)**S(2))/(S(2)*a*e*(d + e*x)**S(2)*(-S(4)*a*c + b**S(2))*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))) - (-S(3)*a*c + b**S(2))/(a**S(2)*e*(d + e*x)**S(2)*(-S(4)*a*c + b**S(2))) - S(2)*b*log(d + e*x)/(a**S(3)*e) + b*log(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))/(S(2)*a**S(3)*e) - (S(6)*a**S(2)*c**S(2) - S(6)*a*b**S(2)*c + b**S(4))*atanh((b + S(2)*c*(d + e*x)**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(a**S(3)*e*(-S(4)*a*c + b**S(2))**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((d + e*x)**S(4)*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))**S(2)), x), x, (-S(2)*a*c + b**S(2) + b*c*(d + e*x)**S(2))/(S(2)*a*e*(d + e*x)**S(3)*(-S(4)*a*c + b**S(2))*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))) - (-S(14)*a*c + S(5)*b**S(2))/(S(6)*a**S(2)*e*(d + e*x)**S(3)*(-S(4)*a*c + b**S(2))) + b*(-S(19)*a*c + S(5)*b**S(2))/(S(2)*a**S(3)*e*(d + e*x)*(-S(4)*a*c + b**S(2))) - sqrt(S(2))*sqrt(c)*(S(28)*a**S(2)*c**S(2) - S(29)*a*b**S(2)*c + S(5)*b**S(4) - b*(-S(19)*a*c + S(5)*b**S(2))*sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*(d + e*x)/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(4)*a**S(3)*e*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)) + sqrt(S(2))*sqrt(c)*(S(28)*a**S(2)*c**S(2) - S(29)*a*b**S(2)*c + S(5)*b**S(4) + b*(-S(19)*a*c + S(5)*b**S(2))*sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*(d + e*x)/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(4)*a**S(3)*e*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x)**S(4)/(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))**S(3), x), x, -S(3)*sqrt(S(2))*sqrt(c)*(S(4)*a*c + S(3)*b**S(2) + S(2)*b*sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*(d + e*x)/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(8)*e*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(5)/2)) + S(3)*sqrt(S(2))*sqrt(c)*(S(4)*a*c + S(3)*b**S(2) - S(2)*b*sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*(d + e*x)/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(8)*e*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(5)/2)) + (S(2)*a + b*(d + e*x)**S(2))*(d + e*x)/(e*(-S(16)*a*c + S(4)*b**S(2))*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))**S(2)) - (d + e*x)*(-S(4)*a*c + S(7)*b**S(2) + S(12)*b*c*(d + e*x)**S(2))/(S(8)*e*(-S(4)*a*c + b**S(2))**S(2)*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x)**S(3)/(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))**S(3), x), x, S(3)*b*c*atanh((b + S(2)*c*(d + e*x)**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(e*(-S(4)*a*c + b**S(2))**(S(5)/2)) - S(3)*b*(b + S(2)*c*(d + e*x)**S(2))/(S(4)*e*(-S(4)*a*c + b**S(2))**S(2)*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))) + (S(2)*a + b*(d + e*x)**S(2))/(e*(-S(16)*a*c + S(4)*b**S(2))*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x)**S(2)/(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))**S(3), x), x, -(b + S(2)*c*(d + e*x)**S(2))*(d + e*x)/(e*(-S(16)*a*c + S(4)*b**S(2))*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))**S(2)) + sqrt(S(2))*sqrt(c)*(S(20)*a*c + b**S(2) - b*(-S(52)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*(d + e*x)/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(16)*a*e*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**S(2)) + sqrt(S(2))*sqrt(c)*(S(20)*a*c + b**S(2) + b*(-S(52)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*(d + e*x)/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(16)*a*e*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**S(2)) + (d + e*x)*(b*(S(8)*a*c + b**S(2)) + c*(d + e*x)**S(2)*(S(20)*a*c + b**S(2)))/(S(8)*a*e*(-S(4)*a*c + b**S(2))**S(2)*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x)/(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))**S(3), x), x, -S(6)*c**S(2)*atanh((b + S(2)*c*(d + e*x)**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(e*(-S(4)*a*c + b**S(2))**(S(5)/2)) + S(3)*c*(b + S(2)*c*(d + e*x)**S(2))/(S(2)*e*(-S(4)*a*c + b**S(2))**S(2)*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))) + (-b - S(2)*c*(d + e*x)**S(2))/(e*(-S(16)*a*c + S(4)*b**S(2))*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))**(S(-3)), x), x, (d + e*x)*(-S(2)*a*c + b**S(2) + b*c*(d + e*x)**S(2))/(S(4)*a*e*(-S(4)*a*c + b**S(2))*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))**S(2)) + S(3)*sqrt(S(2))*sqrt(c)*(-S(8)*a*b*c + b**S(3) - (S(56)*a**S(2)*c**S(2) - S(10)*a*b**S(2)*c + b**S(4))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*(d + e*x)/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(16)*a**S(2)*e*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**S(2)) + S(3)*sqrt(S(2))*sqrt(c)*(S(56)*a**S(2)*c**S(2) - S(10)*a*b**S(2)*c + b**S(4) + b*(-S(8)*a*c + b**S(2))*sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*(d + e*x)/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(16)*a**S(2)*e*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(5)/2)) + (d + e*x)*(S(3)*b*c*(d + e*x)**S(2)*(-S(8)*a*c + b**S(2)) + (-S(7)*a*c + b**S(2))*(-S(4)*a*c + S(3)*b**S(2)))/(S(8)*a**S(2)*e*(-S(4)*a*c + b**S(2))**S(2)*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((d + e*x)*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))**S(3)), x), x, (-S(2)*a*c + b**S(2) + b*c*(d + e*x)**S(2))/(S(4)*a*e*(-S(4)*a*c + b**S(2))*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))**S(2)) + (S(16)*a**S(2)*c**S(2) - S(15)*a*b**S(2)*c + S(2)*b**S(4) + S(2)*b*c*(d + e*x)**S(2)*(-S(7)*a*c + b**S(2)))/(S(4)*a**S(2)*e*(-S(4)*a*c + b**S(2))**S(2)*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))) + b*(S(30)*a**S(2)*c**S(2) - S(10)*a*b**S(2)*c + b**S(4))*atanh((b + S(2)*c*(d + e*x)**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*a**S(3)*e*(-S(4)*a*c + b**S(2))**(S(5)/2)) + log(d + e*x)/(a**S(3)*e) - log(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))/(S(4)*a**S(3)*e), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((d + e*x)**S(2)*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))**S(3)), x), x, (-S(2)*a*c + b**S(2) + b*c*(d + e*x)**S(2))/(S(4)*a*e*(d + e*x)*(-S(4)*a*c + b**S(2))*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))**S(2)) + (S(36)*a**S(2)*c**S(2) - S(35)*a*b**S(2)*c + S(5)*b**S(4) + b*c*(d + e*x)**S(2)*(-S(32)*a*c + S(5)*b**S(2)))/(S(8)*a**S(2)*e*(d + e*x)*(-S(4)*a*c + b**S(2))**S(2)*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))) - S(3)*sqrt(S(2))*sqrt(c)*((-S(12)*a*c + S(5)*b**S(2))*(-S(5)*a*c + b**S(2)) - (S(124)*a**S(2)*b*c**S(2) - S(47)*a*b**S(3)*c + S(5)*b**S(5))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*(d + e*x)/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(16)*a**S(3)*e*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**S(2)) - S(3)*sqrt(S(2))*sqrt(c)*(b*(S(124)*a**S(2)*c**S(2) - S(47)*a*b**S(2)*c + S(5)*b**S(4))/sqrt(-S(4)*a*c + b**S(2)) + (-S(12)*a*c + S(5)*b**S(2))*(-S(5)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*(d + e*x)/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(16)*a**S(3)*e*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**S(2)) - (-S(36)*a*c + S(15)*b**S(2))*(-S(5)*a*c + b**S(2))/(S(8)*a**S(3)*e*(d + e*x)*(-S(4)*a*c + b**S(2))**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((d + e*x)**S(3)*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))**S(3)), x), x, (-S(2)*a*c + b**S(2) + b*c*(d + e*x)**S(2))/(S(4)*a*e*(d + e*x)**S(2)*(-S(4)*a*c + b**S(2))*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))**S(2)) + (S(20)*a**S(2)*c**S(2) - S(20)*a*b**S(2)*c + S(3)*b**S(4) + S(3)*b*c*(d + e*x)**S(2)*(-S(6)*a*c + b**S(2)))/(S(4)*a**S(2)*e*(d + e*x)**S(2)*(-S(4)*a*c + b**S(2))**S(2)*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))) - (S(30)*a**S(2)*c**S(2) - S(21)*a*b**S(2)*c + S(3)*b**S(4))/(S(2)*a**S(3)*e*(d + e*x)**S(2)*(-S(4)*a*c + b**S(2))**S(2)) - S(3)*b*log(d + e*x)/(a**S(4)*e) + S(3)*b*log(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))/(S(4)*a**S(4)*e) - (-S(60)*a**S(3)*c**S(3) + S(90)*a**S(2)*b**S(2)*c**S(2) - S(30)*a*b**S(4)*c + S(3)*b**S(6))*atanh((b + S(2)*c*(d + e*x)**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*a**S(4)*e*(-S(4)*a*c + b**S(2))**(S(5)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*f + e*f*x)**S(4)/(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4)), x), x, f**S(4)*x/c - sqrt(S(2))*f**S(4)*(b - (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*(d + e*x)/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*c**(S(3)/2)*e*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))) - sqrt(S(2))*f**S(4)*(b + (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*(d + e*x)/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*c**(S(3)/2)*e*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*f + e*f*x)**S(3)/(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4)), x), x, b*f**S(3)*atanh((b + S(2)*c*(d + e*x)**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*c*e*sqrt(-S(4)*a*c + b**S(2))) + f**S(3)*log(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))/(S(4)*c*e), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*f + e*f*x)**S(2)/(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4)), x), x, -sqrt(S(2))*f**S(2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*(d + e*x)/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*sqrt(c)*e*sqrt(-S(4)*a*c + b**S(2))) + sqrt(S(2))*f**S(2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*(d + e*x)/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*sqrt(c)*e*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*f + e*f*x)/(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4)), x), x, -f*atanh((b + S(2)*c*(d + e*x)**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(e*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((d*f + e*f*x)*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))), x), x, b*atanh((b + S(2)*c*(d + e*x)**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*a*e*f*sqrt(-S(4)*a*c + b**S(2))) + log(d + e*x)/(a*e*f) - log(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))/(S(4)*a*e*f), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((d*f + e*f*x)**S(2)*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))), x), x, -sqrt(S(2))*sqrt(c)*(-b/sqrt(-S(4)*a*c + b**S(2)) + S(1))*atan(sqrt(S(2))*sqrt(c)*(d + e*x)/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*a*e*f**S(2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))) - sqrt(S(2))*sqrt(c)*(b/sqrt(-S(4)*a*c + b**S(2)) + S(1))*atan(sqrt(S(2))*sqrt(c)*(d + e*x)/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*a*e*f**S(2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))) - S(1)/(a*e*f**S(2)*(d + e*x)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((d*f + e*f*x)**S(3)*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))), x), x, -S(1)/(S(2)*a*e*f**S(3)*(d + e*x)**S(2)) - b*log(d + e*x)/(a**S(2)*e*f**S(3)) + b*log(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))/(S(4)*a**S(2)*e*f**S(3)) - (-S(2)*a*c + b**S(2))*atanh((b + S(2)*c*(d + e*x)**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*a**S(2)*e*f**S(3)*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((d*f + e*f*x)**S(4)*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))), x), x, -S(1)/(S(3)*a*e*f**S(4)*(d + e*x)**S(3)) + b/(a**S(2)*e*f**S(4)*(d + e*x)) + sqrt(S(2))*sqrt(c)*(b - (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*(d + e*x)/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*a**S(2)*e*f**S(4)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))) + sqrt(S(2))*sqrt(c)*(b + (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*(d + e*x)/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*a**S(2)*e*f**S(4)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*f + e*f*x)**S(4)/(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))**S(2), x), x, f**S(4)*(S(2)*a + b*(d + e*x)**S(2))*(d + e*x)/(e*(-S(8)*a*c + S(2)*b**S(2))*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))) + sqrt(S(2))*f**S(4)*(b - (S(4)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*(d + e*x)/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(4)*sqrt(c)*e*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))) + sqrt(S(2))*f**S(4)*(S(4)*a*c + b**S(2) + b*sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*(d + e*x)/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(4)*sqrt(c)*e*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*f + e*f*x)**S(3)/(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))**S(2), x), x, -b*f**S(3)*atanh((b + S(2)*c*(d + e*x)**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(e*(-S(4)*a*c + b**S(2))**(S(3)/2)) + f**S(3)*(S(2)*a + b*(d + e*x)**S(2))/(e*(-S(8)*a*c + S(2)*b**S(2))*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*f + e*f*x)**S(2)/(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))**S(2), x), x, -sqrt(S(2))*sqrt(c)*f**S(2)*(S(2)*b + sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*(d + e*x)/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*e*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)) + sqrt(S(2))*sqrt(c)*f**S(2)*(S(2)*b - sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*(d + e*x)/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*e*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)) - f**S(2)*(b + S(2)*c*(d + e*x)**S(2))*(d + e*x)/(e*(-S(8)*a*c + S(2)*b**S(2))*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*f + e*f*x)/(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))**S(2), x), x, S(2)*c*f*atanh((b + S(2)*c*(d + e*x)**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(e*(-S(4)*a*c + b**S(2))**(S(3)/2)) - f*(b + S(2)*c*(d + e*x)**S(2))/(e*(-S(8)*a*c + S(2)*b**S(2))*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((d*f + e*f*x)*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))**S(2)), x), x, (-S(2)*a*c + b**S(2) + b*c*(d + e*x)**S(2))/(S(2)*a*e*f*(-S(4)*a*c + b**S(2))*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))) + b*(-S(6)*a*c + b**S(2))*atanh((b + S(2)*c*(d + e*x)**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*a**S(2)*e*f*(-S(4)*a*c + b**S(2))**(S(3)/2)) + log(d + e*x)/(a**S(2)*e*f) - log(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))/(S(4)*a**S(2)*e*f), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((d*f + e*f*x)**S(2)*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))**S(2)), x), x, (-S(2)*a*c + b**S(2) + b*c*(d + e*x)**S(2))/(S(2)*a*e*f**S(2)*(d + e*x)*(-S(4)*a*c + b**S(2))*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))) + sqrt(S(2))*sqrt(c)*(-S(16)*a*b*c + S(3)*b**S(3) - (-S(10)*a*c + S(3)*b**S(2))*sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*(d + e*x)/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(4)*a**S(2)*e*f**S(2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)) - sqrt(S(2))*sqrt(c)*(-S(16)*a*b*c + S(3)*b**S(3) + (-S(10)*a*c + S(3)*b**S(2))*sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*(d + e*x)/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(4)*a**S(2)*e*f**S(2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)) - (-S(10)*a*c + S(3)*b**S(2))/(S(2)*a**S(2)*e*f**S(2)*(d + e*x)*(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((d*f + e*f*x)**S(3)*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))**S(2)), x), x, (-S(2)*a*c + b**S(2) + b*c*(d + e*x)**S(2))/(S(2)*a*e*f**S(3)*(d + e*x)**S(2)*(-S(4)*a*c + b**S(2))*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))) - (-S(3)*a*c + b**S(2))/(a**S(2)*e*f**S(3)*(d + e*x)**S(2)*(-S(4)*a*c + b**S(2))) - S(2)*b*log(d + e*x)/(a**S(3)*e*f**S(3)) + b*log(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))/(S(2)*a**S(3)*e*f**S(3)) - (S(6)*a**S(2)*c**S(2) - S(6)*a*b**S(2)*c + b**S(4))*atanh((b + S(2)*c*(d + e*x)**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(a**S(3)*e*f**S(3)*(-S(4)*a*c + b**S(2))**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((d*f + e*f*x)**S(4)*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))**S(2)), x), x, (-S(2)*a*c + b**S(2) + b*c*(d + e*x)**S(2))/(S(2)*a*e*f**S(4)*(d + e*x)**S(3)*(-S(4)*a*c + b**S(2))*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))) - (-S(14)*a*c + S(5)*b**S(2))/(S(6)*a**S(2)*e*f**S(4)*(d + e*x)**S(3)*(-S(4)*a*c + b**S(2))) + b*(-S(19)*a*c + S(5)*b**S(2))/(S(2)*a**S(3)*e*f**S(4)*(d + e*x)*(-S(4)*a*c + b**S(2))) - sqrt(S(2))*sqrt(c)*(S(28)*a**S(2)*c**S(2) - S(29)*a*b**S(2)*c + S(5)*b**S(4) - b*(-S(19)*a*c + S(5)*b**S(2))*sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*(d + e*x)/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(4)*a**S(3)*e*f**S(4)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)) + sqrt(S(2))*sqrt(c)*(S(28)*a**S(2)*c**S(2) - S(29)*a*b**S(2)*c + S(5)*b**S(4) + b*(-S(19)*a*c + S(5)*b**S(2))*sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*(d + e*x)/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(4)*a**S(3)*e*f**S(4)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*f + e*f*x)**S(4)/(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))**S(3), x), x, -S(3)*sqrt(S(2))*sqrt(c)*f**S(4)*(S(4)*a*c + S(3)*b**S(2) + S(2)*b*sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*(d + e*x)/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(8)*e*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(5)/2)) + S(3)*sqrt(S(2))*sqrt(c)*f**S(4)*(S(4)*a*c + S(3)*b**S(2) - S(2)*b*sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*(d + e*x)/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(8)*e*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(5)/2)) + f**S(4)*(S(2)*a + b*(d + e*x)**S(2))*(d + e*x)/(e*(-S(16)*a*c + S(4)*b**S(2))*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))**S(2)) - f**S(4)*(d + e*x)*(-S(4)*a*c + S(7)*b**S(2) + S(12)*b*c*(d + e*x)**S(2))/(S(8)*e*(-S(4)*a*c + b**S(2))**S(2)*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*f + e*f*x)**S(3)/(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))**S(3), x), x, S(3)*b*c*f**S(3)*atanh((b + S(2)*c*(d + e*x)**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(e*(-S(4)*a*c + b**S(2))**(S(5)/2)) - S(3)*b*f**S(3)*(b + S(2)*c*(d + e*x)**S(2))/(S(4)*e*(-S(4)*a*c + b**S(2))**S(2)*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))) + f**S(3)*(S(2)*a + b*(d + e*x)**S(2))/(e*(-S(16)*a*c + S(4)*b**S(2))*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*f + e*f*x)**S(2)/(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))**S(3), x), x, -f**S(2)*(b + S(2)*c*(d + e*x)**S(2))*(d + e*x)/(e*(-S(16)*a*c + S(4)*b**S(2))*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))**S(2)) + sqrt(S(2))*sqrt(c)*f**S(2)*(S(20)*a*c + b**S(2) - b*(-S(52)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*(d + e*x)/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(16)*a*e*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**S(2)) + sqrt(S(2))*sqrt(c)*f**S(2)*(S(20)*a*c + b**S(2) + b*(-S(52)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*(d + e*x)/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(16)*a*e*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**S(2)) + f**S(2)*(d + e*x)*(b*(S(8)*a*c + b**S(2)) + c*(d + e*x)**S(2)*(S(20)*a*c + b**S(2)))/(S(8)*a*e*(-S(4)*a*c + b**S(2))**S(2)*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*f + e*f*x)/(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))**S(3), x), x, -S(6)*c**S(2)*f*atanh((b + S(2)*c*(d + e*x)**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(e*(-S(4)*a*c + b**S(2))**(S(5)/2)) + S(3)*c*f*(b + S(2)*c*(d + e*x)**S(2))/(S(2)*e*(-S(4)*a*c + b**S(2))**S(2)*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))) - f*(b + S(2)*c*(d + e*x)**S(2))/(e*(-S(16)*a*c + S(4)*b**S(2))*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((d*f + e*f*x)*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))**S(3)), x), x, (-S(2)*a*c + b**S(2) + b*c*(d + e*x)**S(2))/(S(4)*a*e*f*(-S(4)*a*c + b**S(2))*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))**S(2)) + (S(16)*a**S(2)*c**S(2) - S(15)*a*b**S(2)*c + S(2)*b**S(4) + S(2)*b*c*(d + e*x)**S(2)*(-S(7)*a*c + b**S(2)))/(S(4)*a**S(2)*e*f*(-S(4)*a*c + b**S(2))**S(2)*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))) + b*(S(30)*a**S(2)*c**S(2) - S(10)*a*b**S(2)*c + b**S(4))*atanh((b + S(2)*c*(d + e*x)**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*a**S(3)*e*f*(-S(4)*a*c + b**S(2))**(S(5)/2)) + log(d + e*x)/(a**S(3)*e*f) - log(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))/(S(4)*a**S(3)*e*f), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((d*f + e*f*x)**S(2)*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))**S(3)), x), x, (-S(2)*a*c + b**S(2) + b*c*(d + e*x)**S(2))/(S(4)*a*e*f**S(2)*(d + e*x)*(-S(4)*a*c + b**S(2))*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))**S(2)) + (S(36)*a**S(2)*c**S(2) - S(35)*a*b**S(2)*c + S(5)*b**S(4) + b*c*(d + e*x)**S(2)*(-S(32)*a*c + S(5)*b**S(2)))/(S(8)*a**S(2)*e*f**S(2)*(d + e*x)*(-S(4)*a*c + b**S(2))**S(2)*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))) - S(3)*sqrt(S(2))*sqrt(c)*((-S(12)*a*c + S(5)*b**S(2))*(-S(5)*a*c + b**S(2)) - (S(124)*a**S(2)*b*c**S(2) - S(47)*a*b**S(3)*c + S(5)*b**S(5))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*(d + e*x)/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(16)*a**S(3)*e*f**S(2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**S(2)) - S(3)*sqrt(S(2))*sqrt(c)*(b*(S(124)*a**S(2)*c**S(2) - S(47)*a*b**S(2)*c + S(5)*b**S(4))/sqrt(-S(4)*a*c + b**S(2)) + (-S(12)*a*c + S(5)*b**S(2))*(-S(5)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*(d + e*x)/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(16)*a**S(3)*e*f**S(2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**S(2)) - (-S(36)*a*c + S(15)*b**S(2))*(-S(5)*a*c + b**S(2))/(S(8)*a**S(3)*e*f**S(2)*(d + e*x)*(-S(4)*a*c + b**S(2))**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((d*f + e*f*x)**S(3)*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))**S(3)), x), x, (-S(2)*a*c + b**S(2) + b*c*(d + e*x)**S(2))/(S(4)*a*e*f**S(3)*(d + e*x)**S(2)*(-S(4)*a*c + b**S(2))*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))**S(2)) + (S(20)*a**S(2)*c**S(2) - S(20)*a*b**S(2)*c + S(3)*b**S(4) + S(3)*b*c*(d + e*x)**S(2)*(-S(6)*a*c + b**S(2)))/(S(4)*a**S(2)*e*f**S(3)*(d + e*x)**S(2)*(-S(4)*a*c + b**S(2))**S(2)*(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))) - (S(30)*a**S(2)*c**S(2) - S(21)*a*b**S(2)*c + S(3)*b**S(4))/(S(2)*a**S(3)*e*f**S(3)*(d + e*x)**S(2)*(-S(4)*a*c + b**S(2))**S(2)) - S(3)*b*log(d + e*x)/(a**S(4)*e*f**S(3)) + S(3)*b*log(a + b*(d + e*x)**S(2) + c*(d + e*x)**S(4))/(S(4)*a**S(4)*e*f**S(3)) - (-S(60)*a**S(3)*c**S(3) + S(90)*a**S(2)*b**S(2)*c**S(2) - S(30)*a*b**S(4)*c + S(3)*b**S(6))*atanh((b + S(2)*c*(d + e*x)**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*a**S(4)*e*f**S(3)*(-S(4)*a*c + b**S(2))**(S(5)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(3)*x + S(2))**S(6)*((S(3)*x + S(2))**S(14) + (S(3)*x + S(2))**S(7) + S(1)), x), x, (S(3)*x + S(2))**S(21)/S(63) + (S(3)*x + S(2))**S(14)/S(42) + (S(3)*x + S(2))**S(7)/S(21), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(3)*x + S(2))**S(6)*((S(3)*x + S(2))**S(14) + (S(3)*x + S(2))**S(7) + S(1))**S(2), x), x, (S(3)*x + S(2))**S(35)/S(105) + (S(3)*x + S(2))**S(28)/S(42) + (S(3)*x + S(2))**S(21)/S(21) + (S(3)*x + S(2))**S(14)/S(21) + (S(3)*x + S(2))**S(7)/S(21), expand=True, _diff=True, _numerical=True)
def test_2():
assert rubi_test(rubi_integrate((c + d*x**S(2))/(a + b*x**S(4)), x), x, -sqrt(S(2))*(-sqrt(a)*d + sqrt(b)*c)*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*x + sqrt(a) + sqrt(b)*x**S(2))/(S(8)*a**(S(3)/4)*b**(S(3)/4)) + sqrt(S(2))*(-sqrt(a)*d + sqrt(b)*c)*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*x + sqrt(a) + sqrt(b)*x**S(2))/(S(8)*a**(S(3)/4)*b**(S(3)/4)) - sqrt(S(2))*(sqrt(a)*d + sqrt(b)*c)*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*x/a**(S(1)/4))/(S(4)*a**(S(3)/4)*b**(S(3)/4)) + sqrt(S(2))*(sqrt(a)*d + sqrt(b)*c)*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*x/a**(S(1)/4))/(S(4)*a**(S(3)/4)*b**(S(3)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c - d*x**S(2))/(a + b*x**S(4)), x), x, -sqrt(S(2))*(-sqrt(a)*d + sqrt(b)*c)*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*x/a**(S(1)/4))/(S(4)*a**(S(3)/4)*b**(S(3)/4)) + sqrt(S(2))*(-sqrt(a)*d + sqrt(b)*c)*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*x/a**(S(1)/4))/(S(4)*a**(S(3)/4)*b**(S(3)/4)) - sqrt(S(2))*(sqrt(a)*d + sqrt(b)*c)*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*x + sqrt(a) + sqrt(b)*x**S(2))/(S(8)*a**(S(3)/4)*b**(S(3)/4)) + sqrt(S(2))*(sqrt(a)*d + sqrt(b)*c)*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*x + sqrt(a) + sqrt(b)*x**S(2))/(S(8)*a**(S(3)/4)*b**(S(3)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c + d*x**S(2))/(a - b*x**S(4)), x), x, (-sqrt(a)*d + sqrt(b)*c)*atan(b**(S(1)/4)*x/a**(S(1)/4))/(S(2)*a**(S(3)/4)*b**(S(3)/4)) + (sqrt(a)*d + sqrt(b)*c)*atanh(b**(S(1)/4)*x/a**(S(1)/4))/(S(2)*a**(S(3)/4)*b**(S(3)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c - d*x**S(2))/(a - b*x**S(4)), x), x, (-sqrt(a)*d + sqrt(b)*c)*atanh(b**(S(1)/4)*x/a**(S(1)/4))/(S(2)*a**(S(3)/4)*b**(S(3)/4)) + (sqrt(a)*d + sqrt(b)*c)*atan(b**(S(1)/4)*x/a**(S(1)/4))/(S(2)*a**(S(3)/4)*b**(S(3)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(3)*x**S(2) + S(2))/(S(9)*x**S(4) + S(4)), x), x, sqrt(S(3))*atan(sqrt(S(3))*x + S(-1))/S(6) + sqrt(S(3))*atan(sqrt(S(3))*x + S(1))/S(6), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-S(3)*x**S(2) + S(2))/(S(9)*x**S(4) + S(4)), x), x, -sqrt(S(3))*log(S(3)*x**S(2) - S(2)*sqrt(S(3))*x + S(2))/S(12) + sqrt(S(3))*log(S(3)*x**S(2) + S(2)*sqrt(S(3))*x + S(2))/S(12), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(3)*x**S(2) + S(2))/(-S(9)*x**S(4) + S(4)), x), x, sqrt(S(6))*atanh(sqrt(S(6))*x/S(2))/S(6), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-S(3)*x**S(2) + S(2))/(-S(9)*x**S(4) + S(4)), x), x, sqrt(S(6))*atan(sqrt(S(6))*x/S(2))/S(6), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((sqrt(a)*sqrt(b) + b*x**S(2))/(a + b*x**S(4)), x), x, -sqrt(S(2))*b**(S(1)/4)*atan(S(1) - sqrt(S(2))*b**(S(1)/4)*x/a**(S(1)/4))/(S(2)*a**(S(1)/4)) + sqrt(S(2))*b**(S(1)/4)*atan(S(1) + sqrt(S(2))*b**(S(1)/4)*x/a**(S(1)/4))/(S(2)*a**(S(1)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((sqrt(a)*sqrt(b) - b*x**S(2))/(a + b*x**S(4)), x), x, -sqrt(S(2))*b**(S(1)/4)*log(-sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*x + sqrt(a) + sqrt(b)*x**S(2))/(S(4)*a**(S(1)/4)) + sqrt(S(2))*b**(S(1)/4)*log(sqrt(S(2))*a**(S(1)/4)*b**(S(1)/4)*x + sqrt(a) + sqrt(b)*x**S(2))/(S(4)*a**(S(1)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))/(d**S(2) + e**S(2)*x**S(4)), x), x, -sqrt(S(2))*atan(S(1) - sqrt(S(2))*sqrt(e)*x/sqrt(d))/(S(2)*sqrt(d)*sqrt(e)) + sqrt(S(2))*atan(S(1) + sqrt(S(2))*sqrt(e)*x/sqrt(d))/(S(2)*sqrt(d)*sqrt(e)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d - e*x**S(2))/(d**S(2) + e**S(2)*x**S(4)), x), x, -sqrt(S(2))*log(-sqrt(S(2))*sqrt(d)*sqrt(e)*x + d + e*x**S(2))/(S(4)*sqrt(d)*sqrt(e)) + sqrt(S(2))*log(sqrt(S(2))*sqrt(d)*sqrt(e)*x + d + e*x**S(2))/(S(4)*sqrt(d)*sqrt(e)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(2)*x**S(2) + S(5))/(x**S(4) + S(-1)), x), x, -S(3)*atan(x)/S(2) - S(7)*atanh(x)/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))**S(3)/sqrt(a + c*x**S(4)), x), x, -S(3)*a**(S(1)/4)*e*sqrt((a + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(-a*e**S(2) + S(5)*c*d**S(2))*elliptic_e(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2)/(S(5)*c**(S(7)/4)*sqrt(a + c*x**S(4))) + a**(S(1)/4)*sqrt((a + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(-S(3)*a*e**S(3) + S(15)*c*d**S(2)*e + S(5)*sqrt(c)*d*(-a*e**S(2) + c*d**S(2))/sqrt(a))*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2)/(S(10)*c**(S(7)/4)*sqrt(a + c*x**S(4))) + d*e**S(2)*x*sqrt(a + c*x**S(4))/c + e**S(3)*x**S(3)*sqrt(a + c*x**S(4))/(S(5)*c) + S(3)*e*x*sqrt(a + c*x**S(4))*(-a*e**S(2) + S(5)*c*d**S(2))/(S(5)*c**(S(3)/2)*(sqrt(a) + sqrt(c)*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))**S(2)/sqrt(a + c*x**S(4)), x), x, -S(2)*a**(S(1)/4)*d*e*sqrt((a + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*elliptic_e(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2)/(c**(S(3)/4)*sqrt(a + c*x**S(4))) + e**S(2)*x*sqrt(a + c*x**S(4))/(S(3)*c) + S(2)*d*e*x*sqrt(a + c*x**S(4))/(sqrt(c)*(sqrt(a) + sqrt(c)*x**S(2))) + sqrt((a + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(S(6)*sqrt(a)*sqrt(c)*d*e - a*e**S(2) + S(3)*c*d**S(2))*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2)/(S(6)*a**(S(1)/4)*c**(S(5)/4)*sqrt(a + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))/sqrt(a + c*x**S(4)), x), x, -a**(S(1)/4)*e*sqrt((a + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*elliptic_e(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2)/(c**(S(3)/4)*sqrt(a + c*x**S(4))) + a**(S(1)/4)*sqrt((a + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(e + sqrt(c)*d/sqrt(a))*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2)/(S(2)*c**(S(3)/4)*sqrt(a + c*x**S(4))) + e*x*sqrt(a + c*x**S(4))/(sqrt(c)*(sqrt(a) + sqrt(c)*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(sqrt(a + c*x**S(4))*(d + e*x**S(2))), x), x, atan(x*sqrt(a*e/d + c*d/e)/sqrt(a + c*x**S(4)))/(S(2)*d*sqrt(a*e/d + c*d/e)) + c**(S(1)/4)*sqrt((a + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2)/(S(2)*a**(S(1)/4)*sqrt(a + c*x**S(4))*(-sqrt(a)*e + sqrt(c)*d)) - sqrt((a + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(e + sqrt(c)*d/sqrt(a))*elliptic_pi(-sqrt(a)*(-e + sqrt(c)*d/sqrt(a))**S(2)/(S(4)*sqrt(c)*d*e), S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2)/(S(4)*a**(S(1)/4)*c**(S(1)/4)*d*sqrt(a + c*x**S(4))*(-e + sqrt(c)*d/sqrt(a))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(sqrt(a + c*x**S(4))*(d + e*x**S(2))**S(2)), x), x, a**(S(1)/4)*c**(S(1)/4)*e*sqrt((a + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*elliptic_e(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2)/(S(2)*d*sqrt(a + c*x**S(4))*(a*e**S(2) + c*d**S(2))) - a**(S(1)/4)*c**(S(1)/4)*sqrt((a + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(e + sqrt(c)*d/sqrt(a))*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2)/(S(4)*d*sqrt(a + c*x**S(4))*(a*e**S(2) + c*d**S(2))) - a**(S(1)/4)*sqrt((a + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(e + sqrt(c)*d/sqrt(a))*(a*e**S(2) + S(3)*c*d**S(2))*elliptic_pi(-(-sqrt(a)*e + sqrt(c)*d)**S(2)/(S(4)*sqrt(a)*sqrt(c)*d*e), S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2)/(S(8)*c**(S(1)/4)*d**S(2)*sqrt(a + c*x**S(4))*(-sqrt(a)*e + sqrt(c)*d)*(a*e**S(2) + c*d**S(2))) - sqrt(c)*e*x*sqrt(a + c*x**S(4))/(S(2)*d*(sqrt(a) + sqrt(c)*x**S(2))*(a*e**S(2) + c*d**S(2))) + e**S(2)*x*sqrt(a + c*x**S(4))/(S(2)*d*(d + e*x**S(2))*(a*e**S(2) + c*d**S(2))) + (a*e**S(2) + S(3)*c*d**S(2))*atan(x*sqrt(a*e/d + c*d/e)/sqrt(a + c*x**S(4)))/(S(4)*d**S(3)*e*(a*e/d + c*d/e)**(S(3)/2)) + c**(S(1)/4)*sqrt((a + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(a*e**S(2) + S(3)*c*d**S(2))*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2)/(S(4)*a**(S(1)/4)*d*sqrt(a + c*x**S(4))*(-sqrt(a)*e + sqrt(c)*d)*(a*e**S(2) + c*d**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))**S(3)/sqrt(a - c*x**S(4)), x), x, S(3)*a**(S(3)/4)*e*sqrt(S(1) - c*x**S(4)/a)*(a*e**S(2) + S(5)*c*d**S(2))*elliptic_e(asin(c**(S(1)/4)*x/a**(S(1)/4)), S(-1))/(S(5)*c**(S(7)/4)*sqrt(a - c*x**S(4))) - a**(S(3)/4)*sqrt(S(1) - c*x**S(4)/a)*(S(3)*a*e**S(3) + S(15)*c*d**S(2)*e - S(5)*sqrt(c)*d*(a*e**S(2) + c*d**S(2))/sqrt(a))*elliptic_f(asin(c**(S(1)/4)*x/a**(S(1)/4)), S(-1))/(S(5)*c**(S(7)/4)*sqrt(a - c*x**S(4))) - d*e**S(2)*x*sqrt(a - c*x**S(4))/c - e**S(3)*x**S(3)*sqrt(a - c*x**S(4))/(S(5)*c), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))**S(2)/sqrt(a - c*x**S(4)), x), x, S(2)*a**(S(3)/4)*d*e*sqrt(S(1) - c*x**S(4)/a)*elliptic_e(asin(c**(S(1)/4)*x/a**(S(1)/4)), S(-1))/(c**(S(3)/4)*sqrt(a - c*x**S(4))) + a**(S(1)/4)*sqrt(S(1) - c*x**S(4)/a)*(-S(6)*sqrt(a)*sqrt(c)*d*e + a*e**S(2) + S(3)*c*d**S(2))*elliptic_f(asin(c**(S(1)/4)*x/a**(S(1)/4)), S(-1))/(S(3)*c**(S(5)/4)*sqrt(a - c*x**S(4))) - e**S(2)*x*sqrt(a - c*x**S(4))/(S(3)*c), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))/sqrt(a - c*x**S(4)), x), x, a**(S(3)/4)*e*sqrt(S(1) - c*x**S(4)/a)*elliptic_e(asin(c**(S(1)/4)*x/a**(S(1)/4)), S(-1))/(c**(S(3)/4)*sqrt(a - c*x**S(4))) + a**(S(3)/4)*sqrt(S(1) - c*x**S(4)/a)*(-e + sqrt(c)*d/sqrt(a))*elliptic_f(asin(c**(S(1)/4)*x/a**(S(1)/4)), S(-1))/(c**(S(3)/4)*sqrt(a - c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(sqrt(a - c*x**S(4))*(d + e*x**S(2))), x), x, a**(S(1)/4)*sqrt(S(1) - c*x**S(4)/a)*elliptic_pi(-sqrt(a)*e/(sqrt(c)*d), asin(c**(S(1)/4)*x/a**(S(1)/4)), S(-1))/(c**(S(1)/4)*d*sqrt(a - c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(sqrt(a - c*x**S(4))*(d + e*x**S(2))**S(2)), x), x, -a**(S(3)/4)*c**(S(1)/4)*e*sqrt(S(1) - c*x**S(4)/a)*elliptic_e(asin(c**(S(1)/4)*x/a**(S(1)/4)), S(-1))/(S(2)*d*sqrt(a - c*x**S(4))*(-a*e**S(2) + c*d**S(2))) - a**(S(1)/4)*c**(S(1)/4)*sqrt(S(1) - c*x**S(4)/a)*elliptic_f(asin(c**(S(1)/4)*x/a**(S(1)/4)), S(-1))/(S(2)*d*sqrt(a - c*x**S(4))*(sqrt(a)*e + sqrt(c)*d)) + a**(S(1)/4)*sqrt(S(1) - c*x**S(4)/a)*(-a*e**S(2) + S(3)*c*d**S(2))*elliptic_pi(-sqrt(a)*e/(sqrt(c)*d), asin(c**(S(1)/4)*x/a**(S(1)/4)), S(-1))/(S(2)*c**(S(1)/4)*d**S(2)*sqrt(a - c*x**S(4))*(-a*e**S(2) + c*d**S(2))) - e**S(2)*x*sqrt(a - c*x**S(4))/(S(2)*d*(d + e*x**S(2))*(-a*e**S(2) + c*d**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))/sqrt(-a + c*x**S(4)), x), x, a**(S(3)/4)*e*sqrt(S(1) - c*x**S(4)/a)*elliptic_e(asin(c**(S(1)/4)*x/a**(S(1)/4)), S(-1))/(c**(S(3)/4)*sqrt(-a + c*x**S(4))) + a**(S(3)/4)*sqrt(S(1) - c*x**S(4)/a)*(-e + sqrt(c)*d/sqrt(a))*elliptic_f(asin(c**(S(1)/4)*x/a**(S(1)/4)), S(-1))/(c**(S(3)/4)*sqrt(-a + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(sqrt(-a + c*x**S(4))*(d + e*x**S(2))), x), x, a**(S(1)/4)*sqrt(S(1) - c*x**S(4)/a)*elliptic_pi(-sqrt(a)*e/(sqrt(c)*d), asin(c**(S(1)/4)*x/a**(S(1)/4)), S(-1))/(c**(S(1)/4)*d*sqrt(-a + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((sqrt(a) + sqrt(c)*x**S(2))/sqrt(-a + c*x**S(4)), x), x, a**(S(3)/4)*sqrt(S(1) - c*x**S(4)/a)*elliptic_e(asin(c**(S(1)/4)*x/a**(S(1)/4)), S(-1))/(c**(S(1)/4)*sqrt(-a + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(2)*sqrt(c/a) + S(1))/sqrt(-a + c*x**S(4)), x), x, sqrt(S(1) - c*x**S(4)/a)*elliptic_e(asin(x*(c/a)**(S(1)/4)), S(-1))/((c/a)**(S(1)/4)*sqrt(-a + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))/sqrt(-a - c*x**S(4)), x), x, -a**(S(1)/4)*e*sqrt((a + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*elliptic_e(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2)/(c**(S(3)/4)*sqrt(-a - c*x**S(4))) + a**(S(1)/4)*sqrt((a + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(e + sqrt(c)*d/sqrt(a))*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2)/(S(2)*c**(S(3)/4)*sqrt(-a - c*x**S(4))) - e*x*sqrt(-a - c*x**S(4))/(sqrt(c)*(sqrt(a) + sqrt(c)*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(sqrt(-a - c*x**S(4))*(d + e*x**S(2))), x), x, atan(x*sqrt(-a*e/d - c*d/e)/sqrt(-a - c*x**S(4)))/(S(2)*d*sqrt(-a*e/d - c*d/e)) + c**(S(1)/4)*sqrt((a + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2)/(S(2)*a**(S(1)/4)*sqrt(-a - c*x**S(4))*(-sqrt(a)*e + sqrt(c)*d)) - sqrt((a + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(e + sqrt(c)*d/sqrt(a))*elliptic_pi(-sqrt(a)*(-e + sqrt(c)*d/sqrt(a))**S(2)/(S(4)*sqrt(c)*d*e), S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2)/(S(4)*a**(S(1)/4)*c**(S(1)/4)*d*sqrt(-a - c*x**S(4))*(-e + sqrt(c)*d/sqrt(a))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((a + b*x**S(2))*sqrt(-S(5)*x**S(4) + S(4))), x), x, sqrt(S(2))*S(5)**(S(3)/4)*elliptic_pi(-S(2)*sqrt(S(5))*b/(S(5)*a), asin(sqrt(S(2))*S(5)**(S(1)/4)*x/S(2)), S(-1))/(S(10)*a), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((a + b*x**S(2))*sqrt(S(5)*x**S(4) + S(4))), x), x, sqrt(S(2))*S(5)**(S(1)/4)*sqrt((S(5)*x**S(4) + S(4))/(sqrt(S(5))*x**S(2) + S(2))**S(2))*(sqrt(S(5))*x**S(2) + S(2))*elliptic_f(S(2)*atan(sqrt(S(2))*S(5)**(S(1)/4)*x/S(2)), S(1)/2)/(S(4)*sqrt(S(5)*x**S(4) + S(4))*(sqrt(S(5))*a - S(2)*b)) - sqrt(S(2))*S(5)**(S(3)/4)*sqrt((S(5)*x**S(4) + S(4))/(sqrt(S(5))*x**S(2) + S(2))**S(2))*(sqrt(S(5))*a + S(2)*b)*(sqrt(S(5))*x**S(2) + S(2))*elliptic_pi(-sqrt(S(5))*(sqrt(S(5))*a - S(2)*b)**S(2)/(S(40)*a*b), S(2)*atan(sqrt(S(2))*S(5)**(S(1)/4)*x/S(2)), S(1)/2)/(S(40)*a*sqrt(S(5)*x**S(4) + S(4))*(sqrt(S(5))*a - S(2)*b)) + atan(x*sqrt(S(5)*a/b + S(4)*b/a)/sqrt(S(5)*x**S(4) + S(4)))/(S(2)*a*sqrt(S(5)*a/b + S(4)*b/a)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((a + b*x**S(2))*sqrt(-d*x**S(4) + S(4))), x), x, sqrt(S(2))*elliptic_pi(-S(2)*b/(a*sqrt(d)), asin(sqrt(S(2))*d**(S(1)/4)*x/S(2)), S(-1))/(S(2)*a*d**(S(1)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((a + b*x**S(2))*sqrt(d*x**S(4) + S(4))), x), x, -sqrt(S(2))*d**(S(1)/4)*sqrt((d*x**S(4) + S(4))/(sqrt(d)*x**S(2) + S(2))**S(2))*(sqrt(d)*x**S(2) + S(2))*elliptic_f(S(2)*atan(sqrt(S(2))*d**(S(1)/4)*x/S(2)), S(1)/2)/(S(4)*(-a*sqrt(d) + S(2)*b)*sqrt(d*x**S(4) + S(4))) + atan(x*sqrt(a*d/b + S(4)*b/a)/sqrt(d*x**S(4) + S(4)))/(S(2)*a*sqrt(a*d/b + S(4)*b/a)) + sqrt(S(2))*sqrt((d*x**S(4) + S(4))/(sqrt(d)*x**S(2) + S(2))**S(2))*(a*sqrt(d) + S(2)*b)*(sqrt(d)*x**S(2) + S(2))*elliptic_pi(-(-a*sqrt(d) + S(2)*b)**S(2)/(S(8)*a*b*sqrt(d)), S(2)*atan(sqrt(S(2))*d**(S(1)/4)*x/S(2)), S(1)/2)/(S(8)*a*d**(S(1)/4)*(-a*sqrt(d) + S(2)*b)*sqrt(d*x**S(4) + S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(c**S(2)*x**S(2) + S(1))/sqrt(-c**S(2)*x**S(2) + S(1)), x), x, elliptic_e(asin(c*x), S(-1))/c, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c**S(2)*x**S(2) + S(1))/sqrt(-c**S(4)*x**S(4) + S(1)), x), x, elliptic_e(asin(c*x), S(-1))/c, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(-c**S(2)*x**S(2) + S(1))/sqrt(c**S(2)*x**S(2) + S(1)), x), x, -elliptic_e(asin(c*x), S(-1))/c + S(2)*elliptic_f(asin(c*x), S(-1))/c, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-c**S(2)*x**S(2) + S(1))/sqrt(-c**S(4)*x**S(4) + S(1)), x), x, -elliptic_e(asin(c*x), S(-1))/c + S(2)*elliptic_f(asin(c*x), S(-1))/c, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + S(1))/sqrt(-b**S(2)*x**S(4) + S(1)), x), x, elliptic_e(asin(sqrt(b)*x), S(-1))/sqrt(b), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-b*x**S(2) + S(1))/sqrt(-b**S(2)*x**S(4) + S(1)), x), x, -elliptic_e(asin(sqrt(b)*x), S(-1))/sqrt(b) + S(2)*elliptic_f(asin(sqrt(b)*x), S(-1))/sqrt(b), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + S(1))/sqrt(b**S(2)*x**S(4) + S(-1)), x), x, sqrt(-b**S(2)*x**S(4) + S(1))*elliptic_e(asin(sqrt(b)*x), S(-1))/(sqrt(b)*sqrt(b**S(2)*x**S(4) + S(-1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-b*x**S(2) + S(1))/sqrt(b**S(2)*x**S(4) + S(-1)), x), x, -sqrt(-b**S(2)*x**S(4) + S(1))*elliptic_e(asin(sqrt(b)*x), S(-1))/(sqrt(b)*sqrt(b**S(2)*x**S(4) + S(-1))) + S(2)*sqrt(-b**S(2)*x**S(4) + S(1))*elliptic_f(asin(sqrt(b)*x), S(-1))/(sqrt(b)*sqrt(b**S(2)*x**S(4) + S(-1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-b*x**S(2) + S(1))/sqrt(b**S(2)*x**S(4) + S(1)), x), x, -x*sqrt(b**S(2)*x**S(4) + S(1))/(b*x**S(2) + S(1)) + sqrt((b**S(2)*x**S(4) + S(1))/(b*x**S(2) + S(1))**S(2))*(b*x**S(2) + S(1))*elliptic_e(S(2)*atan(sqrt(b)*x), S(1)/2)/(sqrt(b)*sqrt(b**S(2)*x**S(4) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + S(1))/sqrt(b**S(2)*x**S(4) + S(1)), x), x, x*sqrt(b**S(2)*x**S(4) + S(1))/(b*x**S(2) + S(1)) - sqrt((b**S(2)*x**S(4) + S(1))/(b*x**S(2) + S(1))**S(2))*(b*x**S(2) + S(1))*elliptic_e(S(2)*atan(sqrt(b)*x), S(1)/2)/(sqrt(b)*sqrt(b**S(2)*x**S(4) + S(1))) + sqrt((b**S(2)*x**S(4) + S(1))/(b*x**S(2) + S(1))**S(2))*(b*x**S(2) + S(1))*elliptic_f(S(2)*atan(sqrt(b)*x), S(1)/2)/(sqrt(b)*sqrt(b**S(2)*x**S(4) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-b*x**S(2) + S(1))/sqrt(-b**S(2)*x**S(4) + S(-1)), x), x, x*sqrt(-b**S(2)*x**S(4) + S(-1))/(b*x**S(2) + S(1)) + sqrt((b**S(2)*x**S(4) + S(1))/(b*x**S(2) + S(1))**S(2))*(b*x**S(2) + S(1))*elliptic_e(S(2)*atan(sqrt(b)*x), S(1)/2)/(sqrt(b)*sqrt(-b**S(2)*x**S(4) + S(-1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b*x**S(2) + S(1))/sqrt(-b**S(2)*x**S(4) + S(-1)), x), x, -x*sqrt(-b**S(2)*x**S(4) + S(-1))/(b*x**S(2) + S(1)) - sqrt((b**S(2)*x**S(4) + S(1))/(b*x**S(2) + S(1))**S(2))*(b*x**S(2) + S(1))*elliptic_e(S(2)*atan(sqrt(b)*x), S(1)/2)/(sqrt(b)*sqrt(-b**S(2)*x**S(4) + S(-1))) + sqrt((b**S(2)*x**S(4) + S(1))/(b*x**S(2) + S(1))**S(2))*(b*x**S(2) + S(1))*elliptic_f(S(2)*atan(sqrt(b)*x), S(1)/2)/(sqrt(b)*sqrt(-b**S(2)*x**S(4) + S(-1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))**S(4)/(-d**S(2) + e**S(2)*x**S(4)), x), x, -S(8)*d**(S(5)/2)*atanh(sqrt(e)*x/sqrt(d))/sqrt(e) + S(7)*d**S(2)*x + S(4)*d*e*x**S(3)/S(3) + e**S(2)*x**S(5)/S(5), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))**S(3)/(-d**S(2) + e**S(2)*x**S(4)), x), x, -S(4)*d**(S(3)/2)*atanh(sqrt(e)*x/sqrt(d))/sqrt(e) + S(3)*d*x + e*x**S(3)/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))**S(2)/(-d**S(2) + e**S(2)*x**S(4)), x), x, -S(2)*sqrt(d)*atanh(sqrt(e)*x/sqrt(d))/sqrt(e) + x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))/(-d**S(2) + e**S(2)*x**S(4)), x), x, -atanh(sqrt(e)*x/sqrt(d))/(sqrt(d)*sqrt(e)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((d + e*x**S(2))*(-d**S(2) + e**S(2)*x**S(4))), x), x, -x/(S(4)*d**S(2)*(d + e*x**S(2))) - atan(sqrt(e)*x/sqrt(d))/(S(2)*d**(S(5)/2)*sqrt(e)) - atanh(sqrt(e)*x/sqrt(d))/(S(4)*d**(S(5)/2)*sqrt(e)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((d + e*x**S(2))**S(2)*(-d**S(2) + e**S(2)*x**S(4))), x), x, -x/(S(8)*d**S(2)*(d + e*x**S(2))**S(2)) - S(5)*x/(S(16)*d**S(3)*(d + e*x**S(2))) - S(7)*atan(sqrt(e)*x/sqrt(d))/(S(16)*d**(S(7)/2)*sqrt(e)) - atanh(sqrt(e)*x/sqrt(d))/(S(8)*d**(S(7)/2)*sqrt(e)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))**(S(3)/2)/(-d**S(2) + e**S(2)*x**S(4)), x), x, atanh(sqrt(e)*x/sqrt(d + e*x**S(2)))/sqrt(e) - sqrt(S(2))*atanh(sqrt(S(2))*sqrt(e)*x/sqrt(d + e*x**S(2)))/sqrt(e), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(d + e*x**S(2))/(-d**S(2) + e**S(2)*x**S(4)), x), x, -sqrt(S(2))*atanh(sqrt(S(2))*sqrt(e)*x/sqrt(d + e*x**S(2)))/(S(2)*d*sqrt(e)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(sqrt(d + e*x**S(2))*(-d**S(2) + e**S(2)*x**S(4))), x), x, -x/(S(2)*d**S(2)*sqrt(d + e*x**S(2))) - sqrt(S(2))*atanh(sqrt(S(2))*sqrt(e)*x/sqrt(d + e*x**S(2)))/(S(4)*d**S(2)*sqrt(e)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((d + e*x**S(2))**(S(3)/2)*(-d**S(2) + e**S(2)*x**S(4))), x), x, -x/(S(6)*d**S(2)*(d + e*x**S(2))**(S(3)/2)) - S(7)*x/(S(12)*d**S(3)*sqrt(d + e*x**S(2))) - sqrt(S(2))*atanh(sqrt(S(2))*sqrt(e)*x/sqrt(d + e*x**S(2)))/(S(8)*d**S(3)*sqrt(e)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))**S(4)/(b*d*e + b*e**S(2)*x**S(2) - c*d**S(2) + c*e**S(2)*x**S(4)), x), x, e**S(2)*x**S(5)/(S(5)*c) + e*x**S(3)*(-b*e + S(4)*c*d)/(S(3)*c**S(2)) + x*(b**S(2)*e**S(2) - S(5)*b*c*d*e + S(7)*c**S(2)*d**S(2))/c**S(3) - (-b*e + S(2)*c*d)**S(3)*atanh(sqrt(c)*sqrt(e)*x/sqrt(-b*e + c*d))/(c**(S(7)/2)*sqrt(e)*sqrt(-b*e + c*d)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))**S(3)/(b*d*e + b*e**S(2)*x**S(2) - c*d**S(2) + c*e**S(2)*x**S(4)), x), x, e*x**S(3)/(S(3)*c) + x*(-b*e + S(3)*c*d)/c**S(2) - (-b*e + S(2)*c*d)**S(2)*atanh(sqrt(c)*sqrt(e)*x/sqrt(-b*e + c*d))/(c**(S(5)/2)*sqrt(e)*sqrt(-b*e + c*d)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))**S(2)/(b*d*e + b*e**S(2)*x**S(2) - c*d**S(2) + c*e**S(2)*x**S(4)), x), x, x/c - (-b*e + S(2)*c*d)*atanh(sqrt(c)*sqrt(e)*x/sqrt(-b*e + c*d))/(c**(S(3)/2)*sqrt(e)*sqrt(-b*e + c*d)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))/(b*d*e + b*e**S(2)*x**S(2) - c*d**S(2) + c*e**S(2)*x**S(4)), x), x, -atanh(sqrt(c)*sqrt(e)*x/sqrt(-b*e + c*d))/(sqrt(c)*sqrt(e)*sqrt(-b*e + c*d)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((d + e*x**S(2))*(b*d*e + b*e**S(2)*x**S(2) - c*d**S(2) + c*e**S(2)*x**S(4))), x), x, -c**(S(3)/2)*atanh(sqrt(c)*sqrt(e)*x/sqrt(-b*e + c*d))/(sqrt(e)*sqrt(-b*e + c*d)*(-b*e + S(2)*c*d)**S(2)) - x/(S(2)*d*(d + e*x**S(2))*(-b*e + S(2)*c*d)) - (-b*e + S(4)*c*d)*atan(sqrt(e)*x/sqrt(d))/(S(2)*d**(S(3)/2)*sqrt(e)*(-b*e + S(2)*c*d)**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((d + e*x**S(2))**S(2)*(b*d*e + b*e**S(2)*x**S(2) - c*d**S(2) + c*e**S(2)*x**S(4))), x), x, -c**(S(5)/2)*atanh(sqrt(c)*sqrt(e)*x/sqrt(-b*e + c*d))/(sqrt(e)*sqrt(-b*e + c*d)*(-b*e + S(2)*c*d)**S(3)) - x/(S(4)*d*(d + e*x**S(2))**S(2)*(-b*e + S(2)*c*d)) - x*(-S(3)*b*e + S(10)*c*d)/(S(8)*d**S(2)*(d + e*x**S(2))*(-b*e + S(2)*c*d)**S(2)) - (S(3)*b**S(2)*e**S(2) - S(16)*b*c*d*e + S(28)*c**S(2)*d**S(2))*atan(sqrt(e)*x/sqrt(d))/(S(8)*d**(S(5)/2)*sqrt(e)*(-b*e + S(2)*c*d)**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))**(S(5)/2)/(b*d*e + b*e**S(2)*x**S(2) - c*d**S(2) + c*e**S(2)*x**S(4)), x), x, x*sqrt(d + e*x**S(2))/(S(2)*c) + (-S(2)*b*e + S(5)*c*d)*atanh(sqrt(e)*x/sqrt(d + e*x**S(2)))/(S(2)*c**S(2)*sqrt(e)) - (-b*e + S(2)*c*d)**(S(3)/2)*atanh(sqrt(e)*x*sqrt(-b*e + S(2)*c*d)/(sqrt(d + e*x**S(2))*sqrt(-b*e + c*d)))/(c**S(2)*sqrt(e)*sqrt(-b*e + c*d)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))**(S(3)/2)/(b*d*e + b*e**S(2)*x**S(2) - c*d**S(2) + c*e**S(2)*x**S(4)), x), x, atanh(sqrt(e)*x/sqrt(d + e*x**S(2)))/(c*sqrt(e)) - sqrt(-b*e + S(2)*c*d)*atanh(sqrt(e)*x*sqrt(-b*e + S(2)*c*d)/(sqrt(d + e*x**S(2))*sqrt(-b*e + c*d)))/(c*sqrt(e)*sqrt(-b*e + c*d)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(d + e*x**S(2))/(b*d*e + b*e**S(2)*x**S(2) - c*d**S(2) + c*e**S(2)*x**S(4)), x), x, -atanh(sqrt(e)*x*sqrt(-b*e + S(2)*c*d)/(sqrt(d + e*x**S(2))*sqrt(-b*e + c*d)))/(sqrt(e)*sqrt(-b*e + c*d)*sqrt(-b*e + S(2)*c*d)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(sqrt(d + e*x**S(2))*(b*d*e + b*e**S(2)*x**S(2) - c*d**S(2) + c*e**S(2)*x**S(4))), x), x, -c*atanh(sqrt(e)*x*sqrt(-b*e + S(2)*c*d)/(sqrt(d + e*x**S(2))*sqrt(-b*e + c*d)))/(sqrt(e)*sqrt(-b*e + c*d)*(-b*e + S(2)*c*d)**(S(3)/2)) - x/(d*sqrt(d + e*x**S(2))*(-b*e + S(2)*c*d)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((d + e*x**S(2))**(S(3)/2)*(b*d*e + b*e**S(2)*x**S(2) - c*d**S(2) + c*e**S(2)*x**S(4))), x), x, -c**S(2)*atanh(sqrt(e)*x*sqrt(-b*e + S(2)*c*d)/(sqrt(d + e*x**S(2))*sqrt(-b*e + c*d)))/(sqrt(e)*sqrt(-b*e + c*d)*(-b*e + S(2)*c*d)**(S(5)/2)) - x/(S(3)*d*(d + e*x**S(2))**(S(3)/2)*(-b*e + S(2)*c*d)) - x*(-S(2)*b*e + S(7)*c*d)/(S(3)*d**S(2)*sqrt(d + e*x**S(2))*(-b*e + S(2)*c*d)**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))/(b*x**S(2) + d**S(2) + e**S(2)*x**S(4)), x), x, -atan((-S(2)*e*x + sqrt(-b + S(2)*d*e))/sqrt(b + S(2)*d*e))/sqrt(b + S(2)*d*e) + atan((S(2)*e*x + sqrt(-b + S(2)*d*e))/sqrt(b + S(2)*d*e))/sqrt(b + S(2)*d*e), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))/(-b*x**S(2) + d**S(2) + e**S(2)*x**S(4)), x), x, atanh((-S(2)*e*x + sqrt(b + S(2)*d*e))/sqrt(b - S(2)*d*e))/sqrt(b - S(2)*d*e) - atanh((S(2)*e*x + sqrt(b + S(2)*d*e))/sqrt(b - S(2)*d*e))/sqrt(b - S(2)*d*e), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))/(d**S(2) + e**S(2)*x**S(4) + f*x**S(2)), x), x, -atan((-S(2)*e*x + sqrt(S(2)*d*e - f))/sqrt(S(2)*d*e + f))/sqrt(S(2)*d*e + f) + atan((S(2)*e*x + sqrt(S(2)*d*e - f))/sqrt(S(2)*d*e + f))/sqrt(S(2)*d*e + f), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))/(d**S(2) + e**S(2)*x**S(4) - f*x**S(2)), x), x, -atan((-S(2)*e*x + sqrt(S(2)*d*e + f))/sqrt(S(2)*d*e - f))/sqrt(S(2)*d*e - f) + atan((S(2)*e*x + sqrt(S(2)*d*e + f))/sqrt(S(2)*d*e - f))/sqrt(S(2)*d*e - f), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d - e*x**S(2))/(b*x**S(2) + d**S(2) + e**S(2)*x**S(4)), x), x, -log(d + e*x**S(2) - x*sqrt(-b + S(2)*d*e))/(S(2)*sqrt(-b + S(2)*d*e)) + log(d + e*x**S(2) + x*sqrt(-b + S(2)*d*e))/(S(2)*sqrt(-b + S(2)*d*e)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d - e*x**S(2))/(-b*x**S(2) + d**S(2) + e**S(2)*x**S(4)), x), x, -log(d + e*x**S(2) - x*sqrt(b + S(2)*d*e))/(S(2)*sqrt(b + S(2)*d*e)) + log(d + e*x**S(2) + x*sqrt(b + S(2)*d*e))/(S(2)*sqrt(b + S(2)*d*e)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d - e*x**S(2))/(d**S(2) + e**S(2)*x**S(4) + f*x**S(2)), x), x, -log(d + e*x**S(2) - x*sqrt(S(2)*d*e - f))/(S(2)*sqrt(S(2)*d*e - f)) + log(d + e*x**S(2) + x*sqrt(S(2)*d*e - f))/(S(2)*sqrt(S(2)*d*e - f)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d - e*x**S(2))/(d**S(2) + e**S(2)*x**S(4) - f*x**S(2)), x), x, -log(d + e*x**S(2) - x*sqrt(S(2)*d*e + f))/(S(2)*sqrt(S(2)*d*e + f)) + log(d + e*x**S(2) + x*sqrt(S(2)*d*e + f))/(S(2)*sqrt(S(2)*d*e + f)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d - e*x**S(2))/(b*x**S(2) + c*d**S(2)/e**S(2) + c*x**S(4)), x), x, -e**(S(3)/2)*log(sqrt(c)*d + sqrt(c)*e*x**S(2) - sqrt(e)*x*sqrt(-b*e + S(2)*c*d))/(S(2)*sqrt(c)*sqrt(-b*e + S(2)*c*d)) + e**(S(3)/2)*log(sqrt(c)*d + sqrt(c)*e*x**S(2) + sqrt(e)*x*sqrt(-b*e + S(2)*c*d))/(S(2)*sqrt(c)*sqrt(-b*e + S(2)*c*d)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))/(b*x**S(2) + c*d**S(2)/e**S(2) + c*x**S(4)), x), x, -e**(S(3)/2)*atan((-S(2)*sqrt(c)*sqrt(e)*x + sqrt(-b*e + S(2)*c*d))/sqrt(b*e + S(2)*c*d))/(sqrt(c)*sqrt(b*e + S(2)*c*d)) + e**(S(3)/2)*atan((S(2)*sqrt(c)*sqrt(e)*x + sqrt(-b*e + S(2)*c*d))/sqrt(b*e + S(2)*c*d))/(sqrt(c)*sqrt(b*e + S(2)*c*d)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))/(b*x**S(2) + c*(d**S(2)/e**S(2) + x**S(4))), x), x, -e**(S(3)/2)*atan((-S(2)*sqrt(c)*sqrt(e)*x + sqrt(-b*e + S(2)*c*d))/sqrt(b*e + S(2)*c*d))/(sqrt(c)*sqrt(b*e + S(2)*c*d)) + e**(S(3)/2)*atan((S(2)*sqrt(c)*sqrt(e)*x + sqrt(-b*e + S(2)*c*d))/sqrt(b*e + S(2)*c*d))/(sqrt(c)*sqrt(b*e + S(2)*c*d)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a - b*x**S(2))/(a**S(2) + b**S(2)*x**S(4) + x**S(2)*(S(2)*a*b + S(-1))), x), x, -log(a + b*x**S(2) - x)/S(2) + log(a + b*x**S(2) + x)/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2))/(a**S(2) + b**S(2)*x**S(4) + x**S(2)*(S(2)*a*b + S(-1))), x), x, atanh((-S(2)*b*x + S(1))/sqrt(-S(4)*a*b + S(1)))/sqrt(-S(4)*a*b + S(1)) - atanh((S(2)*b*x + S(1))/sqrt(-S(4)*a*b + S(1)))/sqrt(-S(4)*a*b + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(2)*x**S(2) + S(1))/(b*x**S(2) + S(4)*x**S(4) + S(1)), x), x, -atan((-S(4)*x + sqrt(-b + S(4)))/sqrt(b + S(4)))/sqrt(b + S(4)) + atan((S(4)*x + sqrt(-b + S(4)))/sqrt(b + S(4)))/sqrt(b + S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(2)*x**S(2) + S(1))/(-b*x**S(2) + S(4)*x**S(4) + S(1)), x), x, -atan((-S(4)*x + sqrt(b + S(4)))/sqrt(-b + S(4)))/sqrt(-b + S(4)) + atan((S(4)*x + sqrt(b + S(4)))/sqrt(-b + S(4)))/sqrt(-b + S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(2)*x**S(2) + S(1))/(S(4)*x**S(4) + S(6)*x**S(2) + S(1)), x), x, sqrt(S(10))*atan(S(2)*x/sqrt(-sqrt(S(5)) + S(3)))/S(10) + sqrt(S(10))*atan(S(2)*x/sqrt(sqrt(S(5)) + S(3)))/S(10), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(2)*x**S(2) + S(1))/(S(4)*x**S(4) + S(5)*x**S(2) + S(1)), x), x, atan(x)/S(3) + atan(S(2)*x)/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(2)*x**S(2) + S(1))/(S(4)*x**S(4) + S(4)*x**S(2) + S(1)), x), x, sqrt(S(2))*atan(sqrt(S(2))*x)/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(2)*x**S(2) + S(1))/(S(4)*x**S(4) + S(3)*x**S(2) + S(1)), x), x, -sqrt(S(7))*atan(sqrt(S(7))*(-S(4)*x + S(1))/S(7))/S(7) + sqrt(S(7))*atan(sqrt(S(7))*(S(4)*x + S(1))/S(7))/S(7), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(2)*x**S(2) + S(1))/(S(4)*x**S(4) + S(2)*x**S(2) + S(1)), x), x, -sqrt(S(6))*atan(sqrt(S(6))*(-S(4)*x + sqrt(S(2)))/S(6))/S(6) + sqrt(S(6))*atan(sqrt(S(6))*(S(4)*x + sqrt(S(2)))/S(6))/S(6), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(2)*x**S(2) + S(1))/(S(4)*x**S(4) + x**S(2) + S(1)), x), x, -sqrt(S(5))*atan(sqrt(S(5))*(-S(4)*x + sqrt(S(3)))/S(5))/S(5) + sqrt(S(5))*atan(sqrt(S(5))*(S(4)*x + sqrt(S(3)))/S(5))/S(5), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(2)*x**S(2) + S(1))/(S(4)*x**S(4) + S(1)), x), x, atan(S(2)*x + S(-1))/S(2) + atan(S(2)*x + S(1))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(2)*x**S(2) + S(1))/(S(4)*x**S(4) - x**S(2) + S(1)), x), x, -sqrt(S(3))*atan(sqrt(S(3))*(-S(4)*x + sqrt(S(5)))/S(3))/S(3) + sqrt(S(3))*atan(sqrt(S(3))*(S(4)*x + sqrt(S(5)))/S(3))/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(2)*x**S(2) + S(1))/(S(4)*x**S(4) - S(2)*x**S(2) + S(1)), x), x, -sqrt(S(2))*atan(sqrt(S(2))*(-S(4)*x + sqrt(S(6)))/S(2))/S(2) + sqrt(S(2))*atan(sqrt(S(2))*(S(4)*x + sqrt(S(6)))/S(2))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(2)*x**S(2) + S(1))/(S(4)*x**S(4) - S(3)*x**S(2) + S(1)), x), x, atan(S(4)*x - sqrt(S(7))) + atan(S(4)*x + sqrt(S(7))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(2)*x**S(2) + S(1))/(S(4)*x**S(4) - S(4)*x**S(2) + S(1)), x), x, x/(-S(2)*x**S(2) + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(2)*x**S(2) + S(1))/(S(4)*x**S(4) - S(5)*x**S(2) + S(1)), x), x, -log(-S(2)*x**S(2) - x + S(1))/S(2) + log(-S(2)*x**S(2) + x + S(1))/S(2), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate((S(2)*x**S(2) + S(1))/(S(4)*x**S(4) - S(5)*x**S(2) + S(1)), x), x, -log(-S(2)*x + S(1))/S(2) + log(-x + S(1))/S(2) - log(x + S(1))/S(2) + log(S(2)*x + S(1))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(2)*x**S(2) + S(1))/(S(4)*x**S(4) - S(6)*x**S(2) + S(1)), x), x, -sqrt(S(10))*log(S(2)*x**S(2) - sqrt(S(10))*x + S(1))/S(20) + sqrt(S(10))*log(S(2)*x**S(2) + sqrt(S(10))*x + S(1))/S(20), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate((S(2)*x**S(2) + S(1))/(S(4)*x**S(4) - S(6)*x**S(2) + S(1)), x), x, sqrt(S(2))*atanh(sqrt(S(2))*(-S(4)*x + sqrt(S(10)))/S(2))/S(2) - sqrt(S(2))*atanh(sqrt(S(2))*(S(4)*x + sqrt(S(10)))/S(2))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-S(2)*x**S(2) + S(1))/(b*x**S(2) + S(4)*x**S(4) + S(1)), x), x, -log(S(2)*x**S(2) - x*sqrt(-b + S(4)) + S(1))/(S(2)*sqrt(-b + S(4))) + log(S(2)*x**S(2) + x*sqrt(-b + S(4)) + S(1))/(S(2)*sqrt(-b + S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-S(2)*x**S(2) + S(1))/(S(4)*x**S(4) + S(6)*x**S(2) + S(1)), x), x, sqrt(S(2))*atan(S(2)*x/sqrt(-sqrt(S(5)) + S(3)))/S(2) - sqrt(S(2))*atan(S(2)*x/sqrt(sqrt(S(5)) + S(3)))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-S(2)*x**S(2) + S(1))/(S(4)*x**S(4) + S(5)*x**S(2) + S(1)), x), x, -atan(x) + atan(S(2)*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-S(2)*x**S(2) + S(1))/(S(4)*x**S(4) + S(4)*x**S(2) + S(1)), x), x, x/(S(2)*x**S(2) + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-S(2)*x**S(2) + S(1))/(S(4)*x**S(4) + S(3)*x**S(2) + S(1)), x), x, -log(S(2)*x**S(2) - x + S(1))/S(2) + log(S(2)*x**S(2) + x + S(1))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-S(2)*x**S(2) + S(1))/(S(4)*x**S(4) + S(2)*x**S(2) + S(1)), x), x, -sqrt(S(2))*log(S(2)*x**S(2) - sqrt(S(2))*x + S(1))/S(4) + sqrt(S(2))*log(S(2)*x**S(2) + sqrt(S(2))*x + S(1))/S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-S(2)*x**S(2) + S(1))/(S(4)*x**S(4) + x**S(2) + S(1)), x), x, -sqrt(S(3))*log(S(2)*x**S(2) - sqrt(S(3))*x + S(1))/S(6) + sqrt(S(3))*log(S(2)*x**S(2) + sqrt(S(3))*x + S(1))/S(6), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-S(2)*x**S(2) + S(1))/(S(4)*x**S(4) + S(1)), x), x, -log(S(2)*x**S(2) - S(2)*x + S(1))/S(4) + log(S(2)*x**S(2) + S(2)*x + S(1))/S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-S(2)*x**S(2) + S(1))/(S(4)*x**S(4) - x**S(2) + S(1)), x), x, -sqrt(S(5))*log(S(2)*x**S(2) - sqrt(S(5))*x + S(1))/S(10) + sqrt(S(5))*log(S(2)*x**S(2) + sqrt(S(5))*x + S(1))/S(10), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-S(2)*x**S(2) + S(1))/(S(4)*x**S(4) - S(2)*x**S(2) + S(1)), x), x, -sqrt(S(6))*log(S(2)*x**S(2) - sqrt(S(6))*x + S(1))/S(12) + sqrt(S(6))*log(S(2)*x**S(2) + sqrt(S(6))*x + S(1))/S(12), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-S(2)*x**S(2) + S(1))/(S(4)*x**S(4) - S(3)*x**S(2) + S(1)), x), x, -sqrt(S(7))*log(S(2)*x**S(2) - sqrt(S(7))*x + S(1))/S(14) + sqrt(S(7))*log(S(2)*x**S(2) + sqrt(S(7))*x + S(1))/S(14), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-S(2)*x**S(2) + S(1))/(S(4)*x**S(4) - S(4)*x**S(2) + S(1)), x), x, sqrt(S(2))*atanh(sqrt(S(2))*x)/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-S(2)*x**S(2) + S(1))/(S(4)*x**S(4) - S(5)*x**S(2) + S(1)), x), x, -log(S(2)*x**S(2) - S(3)*x + S(1))/S(6) + log(S(2)*x**S(2) + S(3)*x + S(1))/S(6), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate((-S(2)*x**S(2) + S(1))/(S(4)*x**S(4) - S(5)*x**S(2) + S(1)), x), x, atanh(x)/S(3) + atanh(S(2)*x)/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-S(2)*x**S(2) + S(1))/(S(4)*x**S(4) - S(6)*x**S(2) + S(1)), x), x, -sqrt(S(10))*log(S(2)*x**S(2) - sqrt(S(10))*x + S(1))/S(20) + sqrt(S(10))*log(S(2)*x**S(2) + sqrt(S(10))*x + S(1))/S(20), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate((-S(2)*x**S(2) + S(1))/(S(4)*x**S(4) - S(6)*x**S(2) + S(1)), x), x, sqrt(S(10))*atanh(S(2)*x/sqrt(-sqrt(S(5)) + S(3)))/S(10) + sqrt(S(10))*atanh(S(2)*x/sqrt(sqrt(S(5)) + S(3)))/S(10), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(2) + S(1))/(b*x**S(2) + x**S(4) + S(1)), x), x, -atan((-S(2)*x + sqrt(-b + S(2)))/sqrt(b + S(2)))/sqrt(b + S(2)) + atan((S(2)*x + sqrt(-b + S(2)))/sqrt(b + S(2)))/sqrt(b + S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(2) + S(1))/(x**S(4) + S(5)*x**S(2) + S(1)), x), x, sqrt(S(7))*atan(x*sqrt(sqrt(S(21))/S(2) + S(5)/2))/S(7) + sqrt(S(7))*atan(sqrt(S(2))*x/sqrt(sqrt(S(21)) + S(5)))/S(7), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(2) + S(1))/(x**S(4) + S(4)*x**S(2) + S(1)), x), x, sqrt(S(6))*atan(x/sqrt(-sqrt(S(3)) + S(2)))/S(6) + sqrt(S(6))*atan(x/sqrt(sqrt(S(3)) + S(2)))/S(6), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(2) + S(1))/(x**S(4) + S(3)*x**S(2) + S(1)), x), x, sqrt(S(5))*atan(x*sqrt(sqrt(S(5))/S(2) + S(3)/2))/S(5) + sqrt(S(5))*atan(sqrt(S(2))*x/sqrt(sqrt(S(5)) + S(3)))/S(5), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(2) + S(1))/(x**S(4) + S(2)*x**S(2) + S(1)), x), x, atan(x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(2) + S(1))/(x**S(4) + x**S(2) + S(1)), x), x, -sqrt(S(3))*atan(sqrt(S(3))*(-S(2)*x + S(1))/S(3))/S(3) + sqrt(S(3))*atan(sqrt(S(3))*(S(2)*x + S(1))/S(3))/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(2) + S(1))/(x**S(4) + S(1)), x), x, sqrt(S(2))*atan(sqrt(S(2))*x + S(-1))/S(2) + sqrt(S(2))*atan(sqrt(S(2))*x + S(1))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(2) + S(1))/(x**S(4) - x**S(2) + S(1)), x), x, atan(S(2)*x - sqrt(S(3))) + atan(S(2)*x + sqrt(S(3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(2) + S(1))/(x**S(4) - S(2)*x**S(2) + S(1)), x), x, x/(-x**S(2) + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(2) + S(1))/(x**S(4) - S(3)*x**S(2) + S(1)), x), x, atanh(-S(2)*x + sqrt(S(5))) - atanh(S(2)*x + sqrt(S(5))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(2) + S(1))/(x**S(4) - S(4)*x**S(2) + S(1)), x), x, sqrt(S(2))*atanh(-sqrt(S(2))*x + sqrt(S(3)))/S(2) - sqrt(S(2))*atanh(sqrt(S(2))*x + sqrt(S(3)))/S(2), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate((x**S(2) + S(1))/(x**S(4) - S(4)*x**S(2) + S(1)), x), x, sqrt(S(2))*atanh(sqrt(S(2))*(-S(2)*x + sqrt(S(6)))/S(2))/S(2) - sqrt(S(2))*atanh(sqrt(S(2))*(S(2)*x + sqrt(S(6)))/S(2))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(2) + S(1))/(x**S(4) - S(5)*x**S(2) + S(1)), x), x, sqrt(S(3))*atanh(sqrt(S(3))*(-S(2)*x + sqrt(S(7)))/S(3))/S(3) - sqrt(S(3))*atanh(sqrt(S(3))*(S(2)*x + sqrt(S(7)))/S(3))/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-x**S(2) + S(1))/(b*x**S(2) + x**S(4) + S(1)), x), x, -log(x**S(2) - x*sqrt(-b + S(2)) + S(1))/(S(2)*sqrt(-b + S(2))) + log(x**S(2) + x*sqrt(-b + S(2)) + S(1))/(S(2)*sqrt(-b + S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-x**S(2) + S(1))/(x**S(4) + S(5)*x**S(2) + S(1)), x), x, sqrt(S(3))*atan(x*sqrt(sqrt(S(21))/S(2) + S(5)/2))/S(3) - sqrt(S(3))*atan(sqrt(S(2))*x/sqrt(sqrt(S(21)) + S(5)))/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-x**S(2) + S(1))/(x**S(4) + S(4)*x**S(2) + S(1)), x), x, sqrt(S(2))*atan(x/sqrt(-sqrt(S(3)) + S(2)))/S(2) - sqrt(S(2))*atan(x/sqrt(sqrt(S(3)) + S(2)))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-x**S(2) + S(1))/(x**S(4) + S(3)*x**S(2) + S(1)), x), x, atan(x*sqrt(sqrt(S(5))/S(2) + S(3)/2)) - atan(sqrt(S(2))*x/sqrt(sqrt(S(5)) + S(3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-x**S(2) + S(1))/(x**S(4) + S(2)*x**S(2) + S(1)), x), x, x/(x**S(2) + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-x**S(2) + S(1))/(x**S(4) + x**S(2) + S(1)), x), x, -log(x**S(2) - x + S(1))/S(2) + log(x**S(2) + x + S(1))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-x**S(2) + S(1))/(x**S(4) + S(1)), x), x, -sqrt(S(2))*log(x**S(2) - sqrt(S(2))*x + S(1))/S(4) + sqrt(S(2))*log(x**S(2) + sqrt(S(2))*x + S(1))/S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-x**S(2) + S(1))/(x**S(4) - x**S(2) + S(1)), x), x, -sqrt(S(3))*log(x**S(2) - sqrt(S(3))*x + S(1))/S(6) + sqrt(S(3))*log(x**S(2) + sqrt(S(3))*x + S(1))/S(6), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-x**S(2) + S(1))/(x**S(4) - S(2)*x**S(2) + S(1)), x), x, atanh(x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-x**S(2) + S(1))/(x**S(4) - S(3)*x**S(2) + S(1)), x), x, -sqrt(S(5))*log(x**S(2) - sqrt(S(5))*x + S(1))/S(10) + sqrt(S(5))*log(x**S(2) + sqrt(S(5))*x + S(1))/S(10), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate((-x**S(2) + S(1))/(x**S(4) - S(3)*x**S(2) + S(1)), x), x, sqrt(S(5))*atanh(x*sqrt(sqrt(S(5))/S(2) + S(3)/2))/S(5) + sqrt(S(5))*atanh(sqrt(S(2))*x/sqrt(sqrt(S(5)) + S(3)))/S(5), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-x**S(2) + S(1))/(x**S(4) - S(4)*x**S(2) + S(1)), x), x, -sqrt(S(6))*log(x**S(2) - sqrt(S(6))*x + S(1))/S(12) + sqrt(S(6))*log(x**S(2) + sqrt(S(6))*x + S(1))/S(12), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate((-x**S(2) + S(1))/(x**S(4) - S(4)*x**S(2) + S(1)), x), x, sqrt(S(6))*atanh(x/sqrt(-sqrt(S(3)) + S(2)))/S(6) + sqrt(S(6))*atanh(x/sqrt(sqrt(S(3)) + S(2)))/S(6), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-x**S(2) + S(1))/(x**S(4) - S(5)*x**S(2) + S(1)), x), x, -sqrt(S(7))*log(x**S(2) - sqrt(S(7))*x + S(1))/S(14) + sqrt(S(7))*log(x**S(2) + sqrt(S(7))*x + S(1))/S(14), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate((-x**S(2) + S(1))/(x**S(4) - S(5)*x**S(2) + S(1)), x), x, sqrt(S(7))*atanh(x*sqrt(sqrt(S(21))/S(2) + S(5)/2))/S(7) + sqrt(S(7))*atanh(sqrt(S(2))*x/sqrt(sqrt(S(21)) + S(5)))/S(7), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))**S(4)*(a + b*x**S(2) + c*x**S(4)), x), x, a*d**S(4)*x + c*e**S(4)*x**S(13)/S(13) + d**S(3)*x**S(3)*(S(4)*a*e + b*d)/S(3) + d**S(2)*x**S(5)*(S(6)*a*e**S(2) + S(4)*b*d*e + c*d**S(2))/S(5) + S(2)*d*e*x**S(7)*(S(2)*c*d**S(2) + e*(S(2)*a*e + S(3)*b*d))/S(7) + e**S(3)*x**S(11)*(b*e + S(4)*c*d)/S(11) + e**S(2)*x**S(9)*(S(6)*c*d**S(2) + e*(a*e + S(4)*b*d))/S(9), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))**S(3)*(a + b*x**S(2) + c*x**S(4)), x), x, a*d**S(3)*x + c*e**S(3)*x**S(11)/S(11) + d**S(2)*x**S(3)*(S(3)*a*e + b*d)/S(3) + d*x**S(5)*(c*d**S(2) + S(3)*e*(a*e + b*d))/S(5) + e**S(2)*x**S(9)*(b*e + S(3)*c*d)/S(9) + e*x**S(7)*(S(3)*c*d**S(2) + e*(a*e + S(3)*b*d))/S(7), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))**S(2)*(a + b*x**S(2) + c*x**S(4)), x), x, a*d**S(2)*x + c*e**S(2)*x**S(9)/S(9) + d*x**S(3)*(S(2)*a*e + b*d)/S(3) + e*x**S(7)*(b*e + S(2)*c*d)/S(7) + x**S(5)*(c*d**S(2) + e*(a*e + S(2)*b*d))/S(5), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))*(a + b*x**S(2) + c*x**S(4)), x), x, a*d*x + c*e*x**S(7)/S(7) + x**S(5)*(b*e + c*d)/S(5) + x**S(3)*(a*e + b*d)/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))/(d + e*x**S(2)), x), x, c*x**S(3)/(S(3)*e) - x*(-b*e + c*d)/e**S(2) + (a*e**S(2) - b*d*e + c*d**S(2))*atan(sqrt(e)*x/sqrt(d))/(sqrt(d)*e**(S(5)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))/(d + e*x**S(2))**S(2), x), x, c*x/e**S(2) + x*(a*e**S(2) - b*d*e + c*d**S(2))/(S(2)*d*e**S(2)*(d + e*x**S(2))) - (S(3)*c*d**S(2) - e*(a*e + b*d))*atan(sqrt(e)*x/sqrt(d))/(S(2)*d**(S(3)/2)*e**(S(5)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))/(d + e*x**S(2))**S(3), x), x, x*(a*e**S(2) - b*d*e + c*d**S(2))/(S(4)*d*e**S(2)*(d + e*x**S(2))**S(2)) - x*(S(5)*c*d**S(2) - e*(S(3)*a*e + b*d))/(S(8)*d**S(2)*e**S(2)*(d + e*x**S(2))) + (S(3)*c*d**S(2) + e*(S(3)*a*e + b*d))*atan(sqrt(e)*x/sqrt(d))/(S(8)*d**(S(5)/2)*e**(S(5)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))/(d + e*x**S(2))**S(4), x), x, x*(a*e**S(2) - b*d*e + c*d**S(2))/(S(6)*d*e**S(2)*(d + e*x**S(2))**S(3)) - x*(S(7)*c*d**S(2) - e*(S(5)*a*e + b*d))/(S(24)*d**S(2)*e**S(2)*(d + e*x**S(2))**S(2)) + x*(c*d**S(2) + e*(S(5)*a*e + b*d))/(S(16)*d**S(3)*e**S(2)*(d + e*x**S(2))) + (c*d**S(2) + e*(S(5)*a*e + b*d))*atan(sqrt(e)*x/sqrt(d))/(S(16)*d**(S(7)/2)*e**(S(5)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))**S(3)*(a + b*x**S(2) + c*x**S(4))**S(2), x), x, a**S(2)*d**S(3)*x + a*d**S(2)*x**S(3)*(S(3)*a*e + S(2)*b*d)/S(3) + c**S(2)*e**S(3)*x**S(15)/S(15) + c*e**S(2)*x**S(13)*(S(2)*b*e + S(3)*c*d)/S(13) + d*x**S(5)*(S(6)*a*b*d*e + a*(S(3)*a*e**S(2) + S(2)*c*d**S(2)) + b**S(2)*d**S(2))/S(5) + e*x**S(11)*(b**S(2)*e**S(2) + S(3)*c**S(2)*d**S(2) + S(2)*c*e*(a*e + S(3)*b*d))/S(11) + x**S(9)*(b*e**S(2)*(S(2)*a*e + S(3)*b*d)/S(9) + c**S(2)*d**S(3)/S(9) + S(2)*c*d*e*(a*e + b*d)/S(3)) + x**S(7)*(a**S(2)*e**S(3)/S(7) + S(6)*a*b*d*e**S(2)/S(7) + S(6)*a*c*d**S(2)*e/S(7) + S(3)*b**S(2)*d**S(2)*e/S(7) + S(2)*b*c*d**S(3)/S(7)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))**S(2)*(a + b*x**S(2) + c*x**S(4))**S(2), x), x, a**S(2)*d**S(2)*x + S(2)*a*d*x**S(3)*(a*e + b*d)/S(3) + c**S(2)*e**S(2)*x**S(13)/S(13) + S(2)*c*e*x**S(11)*(b*e + c*d)/S(11) + x**S(9)*(b**S(2)*e**S(2)/S(9) + c**S(2)*d**S(2)/S(9) + S(2)*c*e*(a*e + S(2)*b*d)/S(9)) + x**S(7)*(S(2)*a*b*e**S(2)/S(7) + S(4)*a*c*d*e/S(7) + S(2)*b**S(2)*d*e/S(7) + S(2)*b*c*d**S(2)/S(7)) + x**S(5)*(S(4)*a*b*d*e/S(5) + a*(a*e**S(2) + S(2)*c*d**S(2))/S(5) + b**S(2)*d**S(2)/S(5)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))*(a + b*x**S(2) + c*x**S(4))**S(2), x), x, a**S(2)*d*x + a*x**S(3)*(a*e + S(2)*b*d)/S(3) + c**S(2)*e*x**S(11)/S(11) + c*x**S(9)*(S(2)*b*e + c*d)/S(9) + x**S(7)*(S(2)*a*c*e/S(7) + b**S(2)*e/S(7) + S(2)*b*c*d/S(7)) + x**S(5)*(S(2)*a*b*e/S(5) + S(2)*a*c*d/S(5) + b**S(2)*d/S(5)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))**S(2), x), x, a**S(2)*x + S(2)*a*b*x**S(3)/S(3) + S(2)*b*c*x**S(7)/S(7) + c**S(2)*x**S(9)/S(9) + x**S(5)*(S(2)*a*c/S(5) + b**S(2)/S(5)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))**S(2)/(d + e*x**S(2)), x), x, c**S(2)*x**S(7)/(S(7)*e) - c*x**S(5)*(-S(2)*b*e + c*d)/(S(5)*e**S(2)) + x**S(3)*(b**S(2)*e**S(2) + c**S(2)*d**S(2) - S(2)*c*e*(-a*e + b*d))/(S(3)*e**S(3)) - x*(-b*e + c*d)*(c*d**S(2) - e*(-S(2)*a*e + b*d))/e**S(4) + (a*e**S(2) - b*d*e + c*d**S(2))**S(2)*atan(sqrt(e)*x/sqrt(d))/(sqrt(d)*e**(S(9)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))**S(2)/(d + e*x**S(2))**S(2), x), x, c**S(2)*x**S(7)/(S(5)*e*(d + e*x**S(2))) - c*x**S(3)*(-S(10)*b*e + S(7)*c*d)/(S(15)*e**S(3)) + x*(S(5)*b**S(2)*e**S(2) + S(14)*c**S(2)*d**S(2) - S(10)*c*e*(-a*e + S(2)*b*d))/(S(5)*e**S(4)) + x*(S(7)*c**S(2)*d**S(4) - S(10)*c*d**S(2)*e*(-a*e + b*d) + S(5)*e**S(2)*(-a*e + b*d)**S(2))/(S(10)*d*e**S(4)*(d + e*x**S(2))) - (S(7)*c*d**S(2) - e*(a*e + S(3)*b*d))*(a*e**S(2) - b*d*e + c*d**S(2))*atan(sqrt(e)*x/sqrt(d))/(S(2)*d**(S(3)/2)*e**(S(9)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))**S(2)/(d + e*x**S(2))**S(3), x), x, c**S(2)*x**S(7)/(S(3)*e*(d + e*x**S(2))**S(2)) - c*x*(-S(6)*b*e + S(7)*c*d)/(S(3)*e**S(4)) + x*(S(7)*c**S(2)*d**S(4) - S(6)*c*d**S(2)*e*(-a*e + b*d) + S(3)*e**S(2)*(-a*e + b*d)**S(2))/(S(12)*d*e**S(4)*(d + e*x**S(2))**S(2)) - x*(S(21)*c**S(2)*d**S(4) - S(2)*c*d**S(2)*e*(-S(5)*a*e + S(9)*b*d) + e**S(2)*(-S(3)*a**S(2)*e**S(2) - S(2)*a*b*d*e + S(5)*b**S(2)*d**S(2)))/(S(8)*d**S(2)*e**S(4)*(d + e*x**S(2))) + (S(35)*c**S(2)*d**S(4) - S(6)*c*d**S(2)*e*(-a*e + S(5)*b*d) + e**S(2)*(S(3)*a**S(2)*e**S(2) + S(2)*a*b*d*e + S(3)*b**S(2)*d**S(2)))*atan(sqrt(e)*x/sqrt(d))/(S(8)*d**(S(5)/2)*e**(S(9)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))**S(2)/(d + e*x**S(2))**S(4), x), x, c**S(2)*x**S(7)/(e*(d + e*x**S(2))**S(3)) + x*(S(7)*c**S(2)*d**S(4) - S(2)*c*d**S(2)*e*(-a*e + b*d) + e**S(2)*(-a*e + b*d)**S(2))/(S(6)*d*e**S(4)*(d + e*x**S(2))**S(3)) - x*(S(91)*c**S(2)*d**S(4) - S(2)*c*d**S(2)*e*(-S(7)*a*e + S(13)*b*d) + e**S(2)*(-S(5)*a**S(2)*e**S(2) - S(2)*a*b*d*e + S(7)*b**S(2)*d**S(2)))/(S(24)*d**S(2)*e**S(4)*(d + e*x**S(2))**S(2)) + x*(S(77)*c**S(2)*d**S(4) - S(2)*c*d**S(2)*e*(-a*e + S(11)*b*d) + e**S(2)*(S(5)*a**S(2)*e**S(2) + S(2)*a*b*d*e + b**S(2)*d**S(2)))/(S(16)*d**S(3)*e**S(4)*(d + e*x**S(2))) - (S(35)*c**S(2)*d**S(4) - S(2)*c*d**S(2)*e*(a*e + S(5)*b*d) - e**S(2)*(S(5)*a**S(2)*e**S(2) + S(2)*a*b*d*e + b**S(2)*d**S(2)))*atan(sqrt(e)*x/sqrt(d))/(S(16)*d**(S(7)/2)*e**(S(9)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))**S(2)/(d + e*x**S(2))**S(5), x), x, -c**S(2)*x**S(7)/(e*(d + e*x**S(2))**S(4)) - x*(S(7)*c**S(2)*d**S(4) + S(2)*c*d**S(2)*e*(-a*e + b*d) - e**S(2)*(-a*e + b*d)**S(2))/(S(8)*d*e**S(4)*(d + e*x**S(2))**S(4)) + x*(S(119)*c**S(2)*d**S(4) + S(2)*c*d**S(2)*e*(-S(9)*a*e + S(17)*b*d) - e**S(2)*(-S(7)*a**S(2)*e**S(2) - S(2)*a*b*d*e + S(9)*b**S(2)*d**S(2)))/(S(48)*d**S(2)*e**S(4)*(d + e*x**S(2))**S(3)) - x*(S(413)*c**S(2)*d**S(4) + S(2)*c*d**S(2)*e*(-S(3)*a*e + S(59)*b*d) - e**S(2)*(S(35)*a**S(2)*e**S(2) + S(10)*a*b*d*e + S(3)*b**S(2)*d**S(2)))/(S(192)*d**S(3)*e**S(4)*(d + e*x**S(2))**S(2)) + x*(S(35)*c**S(2)*d**S(4) + S(2)*c*d**S(2)*e*(S(3)*a*e + S(5)*b*d) + e**S(2)*(S(35)*a**S(2)*e**S(2) + S(10)*a*b*d*e + S(3)*b**S(2)*d**S(2)))/(S(128)*d**S(4)*e**S(4)*(d + e*x**S(2))) + (S(35)*c**S(2)*d**S(4) + S(2)*c*d**S(2)*e*(S(3)*a*e + S(5)*b*d) + e**S(2)*(S(35)*a**S(2)*e**S(2) + S(10)*a*b*d*e + S(3)*b**S(2)*d**S(2)))*atan(sqrt(e)*x/sqrt(d))/(S(128)*d**(S(9)/2)*e**(S(9)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))/(d + e*x**S(2))**S(2), x), x, c*x/e**S(2) + x*(a*e**S(2) - b*d*e + c*d**S(2))/(S(2)*d*e**S(2)*(d + e*x**S(2))) - (S(3)*c*d**S(2) - e*(a*e + b*d))*atan(sqrt(e)*x/sqrt(d))/(S(2)*d**(S(3)/2)*e**(S(5)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + x**S(2)*(b + c*x**S(2)))/(d + e*x**S(2))**S(2), x), x, c*x/e**S(2) + x*(a*e**S(2) - b*d*e + c*d**S(2))/(S(2)*d*e**S(2)*(d + e*x**S(2))) - (S(3)*c*d**S(2) - e*(a*e + b*d))*atan(sqrt(e)*x/sqrt(d))/(S(2)*d**(S(3)/2)*e**(S(5)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))**S(4)/(a + b*x**S(2) + c*x**S(4)), x), x, e**S(4)*x**S(5)/(S(5)*c) + e**S(3)*x**S(3)*(-b*e + S(4)*c*d)/(S(3)*c**S(2)) + e**S(2)*x*(b**S(2)*e**S(2) + S(6)*c**S(2)*d**S(2) - c*e*(a*e + S(4)*b*d))/c**S(3) + sqrt(S(2))*(e*(-b*e + S(2)*c*d)*(b**S(2)*e**S(2) + S(2)*c**S(2)*d**S(2) - S(2)*c*e*(a*e + b*d)) - (b**S(4)*e**S(4) - S(4)*b**S(2)*c*e**S(3)*(a*e + b*d) + S(2)*c**S(4)*d**S(4) - S(4)*c**S(3)*d**S(2)*e*(S(3)*a*e + b*d) + S(2)*c**S(2)*e**S(2)*(a**S(2)*e**S(2) + S(6)*a*b*d*e + S(3)*b**S(2)*d**S(2)))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*c**(S(7)/2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))) + sqrt(S(2))*(e*(-b*e + S(2)*c*d)*(b**S(2)*e**S(2) + S(2)*c**S(2)*d**S(2) - S(2)*c*e*(a*e + b*d)) + (b**S(4)*e**S(4) - S(4)*b**S(2)*c*e**S(3)*(a*e + b*d) + S(2)*c**S(4)*d**S(4) - S(4)*c**S(3)*d**S(2)*e*(S(3)*a*e + b*d) + S(2)*c**S(2)*e**S(2)*(a**S(2)*e**S(2) + S(6)*a*b*d*e + S(3)*b**S(2)*d**S(2)))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*c**(S(7)/2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))**S(3)/(a + b*x**S(2) + c*x**S(4)), x), x, e**S(3)*x**S(3)/(S(3)*c) + e**S(2)*x*(-b*e + S(3)*c*d)/c**S(2) + sqrt(S(2))*(e*(b**S(2)*e**S(2) + S(3)*c**S(2)*d**S(2) - c*e*(a*e + S(3)*b*d)) - (-b*e + S(2)*c*d)*(b**S(2)*e**S(2) + c**S(2)*d**S(2) - c*e*(S(3)*a*e + b*d))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*c**(S(5)/2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))) + sqrt(S(2))*(e*(b**S(2)*e**S(2) + S(3)*c**S(2)*d**S(2) - c*e*(a*e + S(3)*b*d)) + (-b*e + S(2)*c*d)*(b**S(2)*e**S(2) + c**S(2)*d**S(2) - c*e*(S(3)*a*e + b*d))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*c**(S(5)/2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))**S(2)/(a + b*x**S(2) + c*x**S(4)), x), x, e**S(2)*x/c + sqrt(S(2))*(e*(-b*e + S(2)*c*d) - (b**S(2)*e**S(2) + S(2)*c**S(2)*d**S(2) - S(2)*c*e*(a*e + b*d))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*c**(S(3)/2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))) + sqrt(S(2))*(e*(-b*e + S(2)*c*d) + (b**S(2)*e**S(2) + S(2)*c**S(2)*d**S(2) - S(2)*c*e*(a*e + b*d))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*c**(S(3)/2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))/(a + b*x**S(2) + c*x**S(4)), x), x, sqrt(S(2))*(e - (-b*e + S(2)*c*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*sqrt(c)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))) + sqrt(S(2))*(e + (-b*e + S(2)*c*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*sqrt(c)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(a + b*x**S(2) + c*x**S(4)), x), x, -sqrt(S(2))*sqrt(c)*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*sqrt(-S(4)*a*c + b**S(2))) + sqrt(S(2))*sqrt(c)*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((d + e*x**S(2))*(a + b*x**S(2) + c*x**S(4))), x), x, -sqrt(S(2))*sqrt(c)*(e + (-b*e + S(2)*c*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(a*e**S(2) - b*d*e + c*d**S(2))) - sqrt(S(2))*sqrt(c)*(e - (-b*e + S(2)*c*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(a*e**S(2) - b*d*e + c*d**S(2))) + e**(S(3)/2)*atan(sqrt(e)*x/sqrt(d))/(sqrt(d)*(a*e**S(2) - b*d*e + c*d**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((d + e*x**S(2))**S(2)*(a + b*x**S(2) + c*x**S(4))), x), x, -sqrt(S(2))*sqrt(c)*(b*e**S(2)*(b - sqrt(-S(4)*a*c + b**S(2))) + S(2)*c**S(2)*d**S(2) - S(2)*c*e*(a*e + b*d - d*sqrt(-S(4)*a*c + b**S(2))))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*sqrt(-S(4)*a*c + b**S(2))*(a*e**S(2) - b*d*e + c*d**S(2))**S(2)) + sqrt(S(2))*sqrt(c)*(b*e**S(2)*(b + sqrt(-S(4)*a*c + b**S(2))) + S(2)*c**S(2)*d**S(2) - S(2)*c*e*(a*e + b*d + d*sqrt(-S(4)*a*c + b**S(2))))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*sqrt(-S(4)*a*c + b**S(2))*(a*e**S(2) - b*d*e + c*d**S(2))**S(2)) + e**S(2)*x/(S(2)*d*(d + e*x**S(2))*(a*e**S(2) - b*d*e + c*d**S(2))) + e**(S(3)/2)*(-b*e + S(2)*c*d)*atan(sqrt(e)*x/sqrt(d))/(sqrt(d)*(a*e**S(2) - b*d*e + c*d**S(2))**S(2)) + e**(S(3)/2)*atan(sqrt(e)*x/sqrt(d))/(S(2)*d**(S(3)/2)*(a*e**S(2) - b*d*e + c*d**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))**S(3)/(a + b*x**S(2) + c*x**S(4))**S(2), x), x, x*(-a*b*e*(a*e**S(2) + S(3)*c*d**S(2)) - S(2)*a*c*d*(-S(3)*a*e**S(2) + c*d**S(2)) + b**S(2)*c*d**S(3) - x**S(2)*(a*b**S(2)*e**S(3) + S(2)*a*c*e*(-a*e**S(2) + S(3)*c*d**S(2)) - b*c*d*(S(3)*a*e**S(2) + c*d**S(2))))/(S(2)*a*c*(-S(4)*a*c + b**S(2))*(a + b*x**S(2) + c*x**S(4))) + sqrt(S(2))*(a*b**S(3)*e**S(3) + S(6)*a*c*(a*e**S(2) + c*d**S(2))*(S(2)*c*d - e*sqrt(-S(4)*a*c + b**S(2))) - b**S(2)*(-S(3)*a*c*d*e**S(2) - a*e**S(3)*sqrt(-S(4)*a*c + b**S(2)) + c**S(2)*d**S(3)) + b*c*(a*e**S(2)*(-S(8)*a*e + S(3)*d*sqrt(-S(4)*a*c + b**S(2))) + c*d**S(2)*(-S(12)*a*e + d*sqrt(-S(4)*a*c + b**S(2)))))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(4)*a*c**(S(3)/2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)) - sqrt(S(2))*(a*b**S(3)*e**S(3) + S(6)*a*c*(a*e**S(2) + c*d**S(2))*(S(2)*c*d + e*sqrt(-S(4)*a*c + b**S(2))) - b**S(2)*(-S(3)*a*c*d*e**S(2) + a*e**S(3)*sqrt(-S(4)*a*c + b**S(2)) + c**S(2)*d**S(3)) - b*c*(a*e**S(2)*(S(8)*a*e + S(3)*d*sqrt(-S(4)*a*c + b**S(2))) + c*d**S(2)*(S(12)*a*e + d*sqrt(-S(4)*a*c + b**S(2)))))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(4)*a*c**(S(3)/2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))**S(2)/(a + b*x**S(2) + c*x**S(4))**S(2), x), x, x*(-S(2)*a*b*d*e - S(2)*a*(-a*e**S(2) + c*d**S(2)) + b**S(2)*d**S(2) + x**S(2)*(a*b*e**S(2) - S(4)*a*c*d*e + b*c*d**S(2)))/(S(2)*a*(-S(4)*a*c + b**S(2))*(a + b*x**S(2) + c*x**S(4))) - sqrt(S(2))*(-S(4)*a*c*(S(3)*c*d**S(2) - e*(-a*e + d*sqrt(-S(4)*a*c + b**S(2)))) + b**S(2)*(-a*e**S(2) + c*d**S(2)) - b*(a*e**S(2)*sqrt(-S(4)*a*c + b**S(2)) + c*d*(-S(8)*a*e + d*sqrt(-S(4)*a*c + b**S(2)))))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(4)*a*sqrt(c)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)) + sqrt(S(2))*(-S(4)*a*c*(S(3)*c*d**S(2) + e*(a*e + d*sqrt(-S(4)*a*c + b**S(2)))) + b**S(2)*(-a*e**S(2) + c*d**S(2)) + b*(a*e**S(2)*sqrt(-S(4)*a*c + b**S(2)) + c*d*(S(8)*a*e + d*sqrt(-S(4)*a*c + b**S(2)))))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(4)*a*sqrt(c)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))/(a + b*x**S(2) + c*x**S(4))**S(2), x), x, sqrt(S(2))*sqrt(c)*(-S(2)*a*e + b*d - (S(4)*a*b*e - S(12)*a*c*d + b**S(2)*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(4)*a*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))) + sqrt(S(2))*sqrt(c)*(-S(2)*a*e + b*d + (S(4)*a*b*e - S(12)*a*c*d + b**S(2)*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(4)*a*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))) + x*(-a*b*e - S(2)*a*c*d + b**S(2)*d + c*x**S(2)*(-S(2)*a*e + b*d))/(S(2)*a*(-S(4)*a*c + b**S(2))*(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))**(S(-2)), x), x, -sqrt(S(2))*sqrt(c)*(-S(12)*a*c + b**S(2) - b*sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(4)*a*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)) + sqrt(S(2))*sqrt(c)*(-S(12)*a*c + b**S(2) + b*sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(4)*a*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)) + x*(-S(2)*a*c + b**S(2) + b*c*x**S(2))/(S(2)*a*(-S(4)*a*c + b**S(2))*(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((d + e*x**S(2))*(a + b*x**S(2) + c*x**S(4))**S(2)), x), x, -sqrt(S(2))*sqrt(c)*e**S(2)*(e + (-b*e + S(2)*c*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(a*e**S(2) - b*d*e + c*d**S(2))**S(2)) - sqrt(S(2))*sqrt(c)*e**S(2)*(e - (-b*e + S(2)*c*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(a*e**S(2) - b*d*e + c*d**S(2))**S(2)) + e**(S(7)/2)*atan(sqrt(e)*x/sqrt(d))/(sqrt(d)*(a*e**S(2) - b*d*e + c*d**S(2))**S(2)) + sqrt(S(2))*sqrt(c)*(S(2)*a*c*e - b**S(2)*e + b*c*d - (S(8)*a*b*c*e - S(12)*a*c**S(2)*d - b**S(3)*e + b**S(2)*c*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(4)*a*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))*(a*e**S(2) - b*d*e + c*d**S(2))) + sqrt(S(2))*sqrt(c)*(S(2)*a*c*e - b**S(2)*e + b*c*d + (S(8)*a*b*c*e - S(12)*a*c**S(2)*d - b**S(3)*e + b**S(2)*c*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(4)*a*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))*(a*e**S(2) - b*d*e + c*d**S(2))) + x*(S(3)*a*b*c*e - S(2)*a*c**S(2)*d - b**S(3)*e + b**S(2)*c*d + c*x**S(2)*(S(2)*a*c*e - b**S(2)*e + b*c*d))/(S(2)*a*(-S(4)*a*c + b**S(2))*(a + b*x**S(2) + c*x**S(4))*(a*e**S(2) - b*d*e + c*d**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((d + e*x**S(2))**S(2)*(a + b*x**S(2) + c*x**S(4))**S(2)), x), x, -sqrt(S(2))*sqrt(c)*e**S(2)*(b*e**S(2)*(b - sqrt(-S(4)*a*c + b**S(2))) + S(3)*c**S(2)*d**S(2) - c*e*(a*e + S(3)*b*d - S(2)*d*sqrt(-S(4)*a*c + b**S(2))))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*sqrt(-S(4)*a*c + b**S(2))*(a*e**S(2) - b*d*e + c*d**S(2))**S(3)) + sqrt(S(2))*sqrt(c)*e**S(2)*(b*e**S(2)*(b + sqrt(-S(4)*a*c + b**S(2))) + S(3)*c**S(2)*d**S(2) - c*e*(a*e + S(3)*b*d + S(2)*d*sqrt(-S(4)*a*c + b**S(2))))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*sqrt(-S(4)*a*c + b**S(2))*(a*e**S(2) - b*d*e + c*d**S(2))**S(3)) + e**S(4)*x/(S(2)*d*(d + e*x**S(2))*(a*e**S(2) - b*d*e + c*d**S(2))**S(2)) + S(2)*e**(S(7)/2)*(-b*e + S(2)*c*d)*atan(sqrt(e)*x/sqrt(d))/(sqrt(d)*(a*e**S(2) - b*d*e + c*d**S(2))**S(3)) + e**(S(7)/2)*atan(sqrt(e)*x/sqrt(d))/(S(2)*d**(S(3)/2)*(a*e**S(2) - b*d*e + c*d**S(2))**S(2)) - sqrt(S(2))*sqrt(c)*(-S(4)*a*c**S(2)*(S(3)*c*d**S(2) + e*(-S(3)*a*e + d*sqrt(-S(4)*a*c + b**S(2)))) + b**S(4)*e**S(2) - b**S(3)*e*(S(2)*c*d + e*sqrt(-S(4)*a*c + b**S(2))) + b**S(2)*c*(c*d**S(2) + e*(-S(9)*a*e + S(2)*d*sqrt(-S(4)*a*c + b**S(2)))) + b*c*(S(3)*a*e**S(2)*sqrt(-S(4)*a*c + b**S(2)) - c*d*(-S(16)*a*e + d*sqrt(-S(4)*a*c + b**S(2)))))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(4)*a*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)*(a*e**S(2) - b*d*e + c*d**S(2))**S(2)) + sqrt(S(2))*sqrt(c)*(-S(4)*a*c**S(2)*(S(3)*c*d**S(2) - e*(S(3)*a*e + d*sqrt(-S(4)*a*c + b**S(2)))) + b**S(4)*e**S(2) - b**S(3)*e*(S(2)*c*d - e*sqrt(-S(4)*a*c + b**S(2))) + b**S(2)*c*(c*d**S(2) - e*(S(9)*a*e + S(2)*d*sqrt(-S(4)*a*c + b**S(2)))) - b*c*(S(3)*a*e**S(2)*sqrt(-S(4)*a*c + b**S(2)) - c*d*(S(16)*a*e + d*sqrt(-S(4)*a*c + b**S(2)))))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(4)*a*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)*(a*e**S(2) - b*d*e + c*d**S(2))**S(2)) - x*(-S(6)*a*b*c**S(2)*d*e + S(2)*a*c**S(2)*(-a*e**S(2) + c*d**S(2)) - b**S(4)*e**S(2) + S(2)*b**S(3)*c*d*e - b**S(2)*c*(-S(4)*a*e**S(2) + c*d**S(2)) + c*x**S(2)*(-S(4)*a*c**S(2)*d*e - b**S(3)*e**S(2) + S(2)*b**S(2)*c*d*e - b*c*(-S(3)*a*e**S(2) + c*d**S(2))))/(S(2)*a*(-S(4)*a*c + b**S(2))*(a + b*x**S(2) + c*x**S(4))*(a*e**S(2) - b*d*e + c*d**S(2))**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(2)*x**S(2) + S(3))/(x**S(4) - S(2)*x**S(2) + S(1)), x), x, S(5)*x/(-S(2)*x**S(2) + S(2)) + atanh(x)/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(3)*x**S(2) + S(2))/(S(3)*x**S(4) - S(8)*x**S(2) + S(5)), x), x, S(5)*atanh(x)/S(2) - S(7)*sqrt(S(15))*atanh(sqrt(S(15))*x/S(5))/S(10), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))/(S(3)*x**S(4) - S(8)*x**S(2) + S(5)), x), x, (d/S(2) + e/S(2))*atanh(x) - sqrt(S(15))*(S(3)*d + S(5)*e)*atanh(sqrt(S(15))*x/S(5))/S(30), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(2) + S(3))/(x**S(4) + S(3)*x**S(2) + S(1)), x), x, sqrt(S(10))*(sqrt(S(5)) + S(3))**(S(3)/2)*atan(x*sqrt(sqrt(S(5))/S(2) + S(3)/2))/S(20) - sqrt(-S(80)*sqrt(S(5)) + S(180))*atan(sqrt(S(2))*x/sqrt(sqrt(S(5)) + S(3)))/S(10), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2))/(x**S(4) + x**S(2) + S(1)), x), x, -(a/S(4) - b/S(4))*log(x**S(2) - x + S(1)) + (a/S(4) - b/S(4))*log(x**S(2) + x + S(1)) - sqrt(S(3))*(a + b)*atan(sqrt(S(3))*(-S(2)*x + S(1))/S(3))/S(6) + sqrt(S(3))*(a + b)*atan(sqrt(S(3))*(S(2)*x + S(1))/S(3))/S(6), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2))/(x**S(4) + x**S(2) + S(1))**S(2), x), x, x*(a + b - x**S(2)*(a - S(2)*b))/(S(6)*x**S(4) + S(6)*x**S(2) + S(6)) - (a/S(4) - b/S(8))*log(x**S(2) - x + S(1)) + (a/S(4) - b/S(8))*log(x**S(2) + x + S(1)) - sqrt(S(3))*(S(4)*a + b)*atan(sqrt(S(3))*(-S(2)*x + S(1))/S(3))/S(36) + sqrt(S(3))*(S(4)*a + b)*atan(sqrt(S(3))*(S(2)*x + S(1))/S(3))/S(36), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2))/(x**S(4) + x**S(2) + S(2)), x), x, -(a - sqrt(S(2))*b)*log(x**S(2) - x*sqrt(S(-1) + S(2)*sqrt(S(2))) + sqrt(S(2)))/(S(4)*sqrt(S(-2) + S(4)*sqrt(S(2)))) + (a - sqrt(S(2))*b)*log(x**S(2) + x*sqrt(S(-1) + S(2)*sqrt(S(2))) + sqrt(S(2)))/(S(4)*sqrt(S(-2) + S(4)*sqrt(S(2)))) - sqrt(S(-1)/14 + sqrt(S(2))/S(7))*(a + sqrt(S(2))*b)*atan((-S(2)*x + sqrt(S(-1) + S(2)*sqrt(S(2))))/sqrt(S(1) + S(2)*sqrt(S(2))))/S(2) + sqrt(S(-1)/14 + sqrt(S(2))/S(7))*(a + sqrt(S(2))*b)*atan((S(2)*x + sqrt(S(-1) + S(2)*sqrt(S(2))))/sqrt(S(1) + S(2)*sqrt(S(2))))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2))/(x**S(4) + x**S(2) + S(2))**S(2), x), x, x*(S(3)*a + S(2)*b - x**S(2)*(a - S(4)*b))/(S(28)*x**S(4) + S(28)*x**S(2) + S(56)) - sqrt(S(-1)/14 + sqrt(S(2))/S(7))*(a*(-sqrt(S(2)) + S(11)) - b*(-S(4)*sqrt(S(2)) + S(2)))*atan((-S(2)*x + sqrt(S(-1) + S(2)*sqrt(S(2))))/sqrt(S(1) + S(2)*sqrt(S(2))))/S(56) + sqrt(S(-1)/14 + sqrt(S(2))/S(7))*(a*(-sqrt(S(2)) + S(11)) - b*(-S(4)*sqrt(S(2)) + S(2)))*atan((S(2)*x + sqrt(S(-1) + S(2)*sqrt(S(2))))/sqrt(S(1) + S(2)*sqrt(S(2))))/S(56) - (S(11)*a - S(2)*b + sqrt(S(2))*(a - S(4)*b))*log(x**S(2) - x*sqrt(S(-1) + S(2)*sqrt(S(2))) + sqrt(S(2)))/(S(112)*sqrt(S(-2) + S(4)*sqrt(S(2)))) + (a*(sqrt(S(2)) + S(11)) - S(4)*sqrt(S(2))*b - S(2)*b)*log(x**S(2) + x*sqrt(S(-1) + S(2)*sqrt(S(2))) + sqrt(S(2)))/(S(112)*sqrt(S(-2) + S(4)*sqrt(S(2)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-x**S(2) + sqrt(S(2)))/(x**S(4) - sqrt(S(2))*x**S(2) + S(1)), x), x, -sqrt(sqrt(S(2))/S(2) + S(1))*log(x**S(2) - x*sqrt(sqrt(S(2)) + S(2)) + S(1))/S(4) + sqrt(sqrt(S(2))/S(2) + S(1))*log(x**S(2) + x*sqrt(sqrt(S(2)) + S(2)) + S(1))/S(4) - atan((-S(2)*x + sqrt(sqrt(S(2)) + S(2)))/sqrt(-sqrt(S(2)) + S(2)))/(S(2)*sqrt(sqrt(S(2)) + S(2))) + atan((S(2)*x + sqrt(sqrt(S(2)) + S(2)))/sqrt(-sqrt(S(2)) + S(2)))/(S(2)*sqrt(sqrt(S(2)) + S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(2) + sqrt(S(2)))/(x**S(4) + sqrt(S(2))*x**S(2) + S(1)), x), x, -sqrt(-sqrt(S(2))/S(2) + S(1))*log(x**S(2) - x*sqrt(-sqrt(S(2)) + S(2)) + S(1))/S(4) + sqrt(-sqrt(S(2))/S(2) + S(1))*log(x**S(2) + x*sqrt(-sqrt(S(2)) + S(2)) + S(1))/S(4) - atan((-S(2)*x + sqrt(-sqrt(S(2)) + S(2)))/sqrt(sqrt(S(2)) + S(2)))/(S(2)*sqrt(-sqrt(S(2)) + S(2))) + atan((S(2)*x + sqrt(-sqrt(S(2)) + S(2)))/sqrt(sqrt(S(2)) + S(2)))/(S(2)*sqrt(-sqrt(S(2)) + S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-x**S(2) + sqrt(S(2)))/(b*x**S(2) + x**S(4) + S(1)), x), x, (-sqrt(S(2)) + S(1))*atan((-S(2)*x + sqrt(-b + S(2)))/sqrt(b + S(2)))/(S(2)*sqrt(b + S(2))) - (-sqrt(S(2)) + S(1))*atan((S(2)*x + sqrt(-b + S(2)))/sqrt(b + S(2)))/(S(2)*sqrt(b + S(2))) - (S(1) + sqrt(S(2)))*log(x**S(2) - x*sqrt(-b + S(2)) + S(1))/(S(4)*sqrt(-b + S(2))) + (S(1) + sqrt(S(2)))*log(x**S(2) + x*sqrt(-b + S(2)) + S(1))/(S(4)*sqrt(-b + S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(2) + sqrt(S(2)))/(b*x**S(2) + x**S(4) + S(1)), x), x, -(S(1) + sqrt(S(2)))*atan((-S(2)*x + sqrt(-b + S(2)))/sqrt(b + S(2)))/(S(2)*sqrt(b + S(2))) + (S(1) + sqrt(S(2)))*atan((S(2)*x + sqrt(-b + S(2)))/sqrt(b + S(2)))/(S(2)*sqrt(b + S(2))) + (-sqrt(S(2)) + S(1))*log(x**S(2) - x*sqrt(-b + S(2)) + S(1))/(S(4)*sqrt(-b + S(2))) - (-sqrt(S(2)) + S(1))*log(x**S(2) + x*sqrt(-b + S(2)) + S(1))/(S(4)*sqrt(-b + S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(2)*a - x**S(2))/(a**S(2) - a*x**S(2) + x**S(4)), x), x, -sqrt(S(3))*log(-sqrt(S(3))*sqrt(a)*x + a + x**S(2))/(S(4)*sqrt(a)) + sqrt(S(3))*log(sqrt(S(3))*sqrt(a)*x + a + x**S(2))/(S(4)*sqrt(a)) - atan((sqrt(S(3))*sqrt(a) - S(2)*x)/sqrt(a))/(S(2)*sqrt(a)) + atan((sqrt(S(3))*sqrt(a) + S(2)*x)/sqrt(a))/(S(2)*sqrt(a)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(2)*sqrt(a) - x**S(2))/(-sqrt(a)*x**S(2) + a + x**S(4)), x), x, -sqrt(S(3))*log(-sqrt(S(3))*a**(S(1)/4)*x + sqrt(a) + x**S(2))/(S(4)*a**(S(1)/4)) + sqrt(S(3))*log(sqrt(S(3))*a**(S(1)/4)*x + sqrt(a) + x**S(2))/(S(4)*a**(S(1)/4)) - atan((sqrt(S(3))*a**(S(1)/4) - S(2)*x)/a**(S(1)/4))/(S(2)*a**(S(1)/4)) + atan((sqrt(S(3))*a**(S(1)/4) + S(2)*x)/a**(S(1)/4))/(S(2)*a**(S(1)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(2)*b**(S(2)/3) + x**S(2))/(b**(S(4)/3) + b**(S(2)/3)*x**S(2) + x**S(4)), x), x, -log(b**(S(2)/3) - b**(S(1)/3)*x + x**S(2))/(S(4)*b**(S(1)/3)) + log(b**(S(2)/3) + b**(S(1)/3)*x + x**S(2))/(S(4)*b**(S(1)/3)) - sqrt(S(3))*atan(sqrt(S(3))*(b**(S(1)/3) - S(2)*x)/(S(3)*b**(S(1)/3)))/(S(2)*b**(S(1)/3)) + sqrt(S(3))*atan(sqrt(S(3))*(b**(S(1)/3) + S(2)*x)/(S(3)*b**(S(1)/3)))/(S(2)*b**(S(1)/3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((A + B*x**S(2))/(a**S(2) - a*x**S(2) + x**S(4)), x), x, -sqrt(S(3))*(A - B*a)*log(-sqrt(S(3))*sqrt(a)*x + a + x**S(2))/(S(12)*a**(S(3)/2)) + sqrt(S(3))*(A - B*a)*log(sqrt(S(3))*sqrt(a)*x + a + x**S(2))/(S(12)*a**(S(3)/2)) - (A + B*a)*atan((sqrt(S(3))*sqrt(a) - S(2)*x)/sqrt(a))/(S(2)*a**(S(3)/2)) + (A + B*a)*atan((sqrt(S(3))*sqrt(a) + S(2)*x)/sqrt(a))/(S(2)*a**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((A + B*x**S(2))/(-sqrt(a)*x**S(2) + a + x**S(4)), x), x, -sqrt(S(3))*(A - B*sqrt(a))*log(-sqrt(S(3))*a**(S(1)/4)*x + sqrt(a) + x**S(2))/(S(12)*a**(S(3)/4)) + sqrt(S(3))*(A - B*sqrt(a))*log(sqrt(S(3))*a**(S(1)/4)*x + sqrt(a) + x**S(2))/(S(12)*a**(S(3)/4)) - (A + B*sqrt(a))*atan((sqrt(S(3))*a**(S(1)/4) - S(2)*x)/a**(S(1)/4))/(S(2)*a**(S(3)/4)) + (A + B*sqrt(a))*atan((sqrt(S(3))*a**(S(1)/4) + S(2)*x)/a**(S(1)/4))/(S(2)*a**(S(3)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((A + B*x**S(2))/(a + c*x**S(4) - x**S(2)*sqrt(a*c)), x), x, -(A - B*sqrt(a)/sqrt(c))*log(sqrt(a) + sqrt(c)*x**S(2) - x*sqrt(S(2)*sqrt(a)*sqrt(c) + sqrt(a*c)))/(S(4)*sqrt(a)*sqrt(S(2)*sqrt(a)*sqrt(c) + sqrt(a*c))) + (A - B*sqrt(a)/sqrt(c))*log(sqrt(a) + sqrt(c)*x**S(2) + x*sqrt(S(2)*sqrt(a)*sqrt(c) + sqrt(a*c)))/(S(4)*sqrt(a)*sqrt(S(2)*sqrt(a)*sqrt(c) + sqrt(a*c))) - (A*sqrt(c) + B*sqrt(a))*atan((-S(2)*sqrt(c)*x + sqrt(S(2)*sqrt(a)*sqrt(c) + sqrt(a*c)))/sqrt(S(2)*sqrt(a)*sqrt(c) - sqrt(a*c)))/(S(2)*sqrt(a)*sqrt(c)*sqrt(S(2)*sqrt(a)*sqrt(c) - sqrt(a*c))) + (A*sqrt(c) + B*sqrt(a))*atan((S(2)*sqrt(c)*x + sqrt(S(2)*sqrt(a)*sqrt(c) + sqrt(a*c)))/sqrt(S(2)*sqrt(a)*sqrt(c) - sqrt(a*c)))/(S(2)*sqrt(a)*sqrt(c)*sqrt(S(2)*sqrt(a)*sqrt(c) - sqrt(a*c))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((A + B*x**S(2))/(-sqrt(a)*sqrt(c)*x**S(2) + a + c*x**S(4)), x), x, -sqrt(S(3))*(A - B*sqrt(a)/sqrt(c))*log(-sqrt(S(3))*a**(S(1)/4)*c**(S(1)/4)*x + sqrt(a) + sqrt(c)*x**S(2))/(S(12)*a**(S(3)/4)*c**(S(1)/4)) + sqrt(S(3))*(A - B*sqrt(a)/sqrt(c))*log(sqrt(S(3))*a**(S(1)/4)*c**(S(1)/4)*x + sqrt(a) + sqrt(c)*x**S(2))/(S(12)*a**(S(3)/4)*c**(S(1)/4)) - (A*sqrt(c) + B*sqrt(a))*atan((sqrt(S(3))*a**(S(1)/4) - S(2)*c**(S(1)/4)*x)/a**(S(1)/4))/(S(2)*a**(S(3)/4)*c**(S(3)/4)) + (A*sqrt(c) + B*sqrt(a))*atan((sqrt(S(3))*a**(S(1)/4) + S(2)*c**(S(1)/4)*x)/a**(S(1)/4))/(S(2)*a**(S(3)/4)*c**(S(3)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(5)*x**S(2) + S(7))**S(3)*sqrt(x**S(4) + S(3)*x**S(2) + S(2)), x), x, S(125)*x**S(3)*(x**S(4) + S(3)*x**S(2) + S(2))**(S(3)/2)/S(9) + S(577)*x*(x**S(2) + S(2))/(S(3)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))) + x*(S(757)*x**S(2) + S(2608))*sqrt(x**S(4) + S(3)*x**S(2) + S(2))/S(21) + S(275)*x*(x**S(4) + S(3)*x**S(2) + S(2))**(S(3)/2)/S(7) - S(577)*sqrt(S(2))*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*(x**S(2) + S(1))*elliptic_e(atan(x), S(1)/2)/(S(3)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))) + S(2945)*sqrt(S(2))*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*(x**S(2) + S(1))*elliptic_f(atan(x), S(1)/2)/(S(21)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(5)*x**S(2) + S(7))**S(2)*sqrt(x**S(4) + S(3)*x**S(2) + S(2)), x), x, S(31)*x*(x**S(2) + S(2))/sqrt(x**S(4) + S(3)*x**S(2) + S(2)) + x*(S(114)*x**S(2) + S(407))*sqrt(x**S(4) + S(3)*x**S(2) + S(2))/S(21) + S(25)*x*(x**S(4) + S(3)*x**S(2) + S(2))**(S(3)/2)/S(7) - S(31)*sqrt(S(2))*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*(x**S(2) + S(1))*elliptic_e(atan(x), S(1)/2)/sqrt(x**S(4) + S(3)*x**S(2) + S(2)) + S(472)*sqrt(S(2))*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*(x**S(2) + S(1))*elliptic_f(atan(x), S(1)/2)/(S(21)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(5)*x**S(2) + S(7))*sqrt(x**S(4) + S(3)*x**S(2) + S(2)), x), x, S(5)*x*(x**S(2) + S(2))/sqrt(x**S(4) + S(3)*x**S(2) + S(2)) + x*(S(3)*x**S(2) + S(10))*sqrt(x**S(4) + S(3)*x**S(2) + S(2))/S(3) - S(5)*sqrt(S(2))*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*(x**S(2) + S(1))*elliptic_e(atan(x), S(1)/2)/sqrt(x**S(4) + S(3)*x**S(2) + S(2)) + S(11)*sqrt(S(2))*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*(x**S(2) + S(1))*elliptic_f(atan(x), S(1)/2)/(S(3)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(x**S(4) + S(3)*x**S(2) + S(2)), x), x, x*(x**S(2) + S(2))/sqrt(x**S(4) + S(3)*x**S(2) + S(2)) + x*sqrt(x**S(4) + S(3)*x**S(2) + S(2))/S(3) - sqrt(S(2))*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*(x**S(2) + S(1))*elliptic_e(atan(x), S(1)/2)/sqrt(x**S(4) + S(3)*x**S(2) + S(2)) + S(2)*sqrt(S(2))*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*(x**S(2) + S(1))*elliptic_f(atan(x), S(1)/2)/(S(3)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(x**S(4) + S(3)*x**S(2) + S(2))/(S(5)*x**S(2) + S(7)), x), x, x*(x**S(2) + S(2))/(S(5)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))) - sqrt(S(2))*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*(x**S(2) + S(1))*elliptic_e(atan(x), S(1)/2)/(S(5)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))) + sqrt(S(2))*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*(S(3)*x**S(2) + S(3))*elliptic_pi(S(2)/7, atan(x), S(1)/2)/(S(70)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))) + sqrt((x**S(2) + S(2))/(S(2)*x**S(2) + S(2)))*(x**S(2) + S(1))*elliptic_f(atan(x), S(1)/2)/(S(5)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate(sqrt(x**S(4) + S(3)*x**S(2) + S(2))/(S(5)*x**S(2) + S(7)), x), x, x*(x**S(2) + S(2))/(S(5)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))) - sqrt(S(2))*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*(x**S(2) + S(1))*elliptic_e(atan(x), S(1)/2)/(S(5)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))) + S(4)*sqrt(S(2))*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*(x**S(2) + S(1))*elliptic_f(atan(x), S(1)/2)/(S(25)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))) - sqrt(S(2))*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*(S(3)*x**S(2) + S(3))*elliptic_f(atan(x), S(1)/2)/(S(50)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))) + sqrt(S(2))*(S(3)*x**S(2) + S(6))*elliptic_pi(S(2)/7, atan(x), S(1)/2)/(S(70)*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*sqrt(x**S(4) + S(3)*x**S(2) + S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(x**S(4) + S(3)*x**S(2) + S(2))/(S(5)*x**S(2) + S(7))**S(2), x), x, x*sqrt(x**S(4) + S(3)*x**S(2) + S(2))/(S(70)*x**S(2) + S(98)) - x*sqrt(x**S(4) + S(3)*x**S(2) + S(2))/(S(70)*x**S(2) + S(70)) + sqrt(S(2))*sqrt(x**S(4) + S(3)*x**S(2) + S(2))*elliptic_e(atan(x), S(1)/2)/(S(70)*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*(x**S(2) + S(1))) + S(3)*sqrt(S(2))*sqrt(x**S(4) + S(3)*x**S(2) + S(2))*elliptic_f(atan(x), S(1)/2)/(S(280)*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*(x**S(2) + S(1))) - sqrt(S(2))*sqrt(x**S(4) + S(3)*x**S(2) + S(2))*elliptic_pi(S(2)/7, atan(x), S(1)/2)/(S(1960)*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*(x**S(2) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(5)*x**S(2) + S(7))**S(3)*(x**S(4) + S(3)*x**S(2) + S(2))**(S(3)/2), x), x, S(125)*x**S(3)*(x**S(4) + S(3)*x**S(2) + S(2))**(S(5)/2)/S(13) + S(20884)*x*(x**S(2) + S(2))/(S(65)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))) + x*(S(65345)*x**S(2) + S(208212))*(x**S(4) + S(3)*x**S(2) + S(2))**(S(3)/2)/S(3003) + x*(S(297911)*x**S(2) + S(1032541))*sqrt(x**S(4) + S(3)*x**S(2) + S(2))/S(5005) + S(3825)*x*(x**S(4) + S(3)*x**S(2) + S(2))**(S(5)/2)/S(143) - S(20884)*sqrt(S(2))*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*(x**S(2) + S(1))*elliptic_e(atan(x), S(1)/2)/(S(65)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))) + S(1171349)*sqrt(S(2))*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*(x**S(2) + S(1))*elliptic_f(atan(x), S(1)/2)/(S(5005)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(5)*x**S(2) + S(7))**S(2)*(x**S(4) + S(3)*x**S(2) + S(2))**(S(3)/2), x), x, S(742)*x*(x**S(2) + S(2))/(S(15)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))) + x*(S(2240)*x**S(2) + S(7281))*(x**S(4) + S(3)*x**S(2) + S(2))**(S(3)/2)/S(693) + x*(S(10643)*x**S(2) + S(36783))*sqrt(x**S(4) + S(3)*x**S(2) + S(2))/S(1155) + S(25)*x*(x**S(4) + S(3)*x**S(2) + S(2))**(S(5)/2)/S(11) - S(742)*sqrt(S(2))*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*(x**S(2) + S(1))*elliptic_e(atan(x), S(1)/2)/(S(15)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))) + S(13879)*sqrt(S(2))*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*(x**S(2) + S(1))*elliptic_f(atan(x), S(1)/2)/(S(385)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(5)*x**S(2) + S(7))*(x**S(4) + S(3)*x**S(2) + S(2))**(S(3)/2), x), x, S(116)*x*(x**S(2) + S(2))/(S(15)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))) + x*(S(35)*x**S(2) + S(108))*(x**S(4) + S(3)*x**S(2) + S(2))**(S(3)/2)/S(63) + x*(S(149)*x**S(2) + S(519))*sqrt(x**S(4) + S(3)*x**S(2) + S(2))/S(105) - S(116)*sqrt(S(2))*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*(x**S(2) + S(1))*elliptic_e(atan(x), S(1)/2)/(S(15)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))) + S(197)*sqrt(S(2))*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*(x**S(2) + S(1))*elliptic_f(atan(x), S(1)/2)/(S(35)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(4) + S(3)*x**S(2) + S(2))**(S(3)/2), x), x, S(6)*x*(x**S(2) + S(2))/(S(5)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))) + x*(S(9)*x**S(2) + S(29))*sqrt(x**S(4) + S(3)*x**S(2) + S(2))/S(35) + x*(x**S(4) + S(3)*x**S(2) + S(2))**(S(3)/2)/S(7) - S(6)*sqrt(S(2))*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*(x**S(2) + S(1))*elliptic_e(atan(x), S(1)/2)/(S(5)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))) + S(31)*sqrt(S(2))*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*(x**S(2) + S(1))*elliptic_f(atan(x), S(1)/2)/(S(35)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(4) + S(3)*x**S(2) + S(2))**(S(3)/2)/(S(5)*x**S(2) + S(7)), x), x, x**S(3)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))/S(25) + S(24)*x*(x**S(2) + S(2))/(S(125)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))) + S(11)*x*sqrt(x**S(4) + S(3)*x**S(2) + S(2))/S(75) - S(24)*sqrt(S(2))*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*(x**S(2) + S(1))*elliptic_e(atan(x), S(1)/2)/(S(125)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))) + S(47)*sqrt(S(2))*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*(x**S(2) + S(1))*elliptic_f(atan(x), S(1)/2)/(S(375)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))) + (S(24)*x**S(2) + S(24))*elliptic_pi(S(-3)/7, atan(sqrt(S(2))*x/S(2)), S(-1))/(S(875)*sqrt((x**S(2) + S(1))/(x**S(2) + S(2)))*sqrt(x**S(4) + S(3)*x**S(2) + S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(4) + S(3)*x**S(2) + S(2))**(S(3)/2)/(S(5)*x**S(2) + S(7))**S(2), x), x, x*sqrt(x**S(4) + S(3)*x**S(2) + S(2))/S(75) - S(3)*x*sqrt(x**S(4) + S(3)*x**S(2) + S(2))/(S(875)*x**S(2) + S(1225)) + S(9)*x*sqrt(x**S(4) + S(3)*x**S(2) + S(2))/(S(175)*x**S(2) + S(175)) + S(8)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))*elliptic_pi(S(-3)/7, atan(sqrt(S(2))*x/S(2)), S(-1))/(S(875)*sqrt((x**S(2) + S(1))/(x**S(2) + S(2)))*(x**S(2) + S(2))) - S(9)*sqrt(S(2))*sqrt(x**S(4) + S(3)*x**S(2) + S(2))*elliptic_e(atan(x), S(1)/2)/(sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*(S(175)*x**S(2) + S(175))) + S(211)*sqrt(S(2))*sqrt(x**S(4) + S(3)*x**S(2) + S(2))*elliptic_f(atan(x), S(1)/2)/(S(10500)*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*(x**S(2) + S(1))) + S(129)*sqrt(S(2))*sqrt(x**S(4) + S(3)*x**S(2) + S(2))*elliptic_pi(S(2)/7, atan(x), S(1)/2)/(S(24500)*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*(x**S(2) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))**S(3)/sqrt(a + b*x**S(2) + c*x**S(4)), x), x, a**(S(1)/4)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(-S(9)*a*e**S(3)/c + S(8)*b**S(2)*e**S(3)/c**S(2) - S(30)*b*d*e**S(2)/c + S(45)*d**S(2)*e + (S(4)*a*b*e**S(3) - S(15)*a*c*d*e**S(2) + S(15)*c**S(2)*d**S(3))/(sqrt(a)*c**(S(3)/2)))*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(30)*c**(S(3)/4)*sqrt(a + b*x**S(2) + c*x**S(4))) - a**(S(1)/4)*e*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(S(8)*b**S(2)*e**S(2) + S(45)*c**S(2)*d**S(2) - S(3)*c*e*(S(3)*a*e + S(10)*b*d))*elliptic_e(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(15)*c**(S(11)/4)*sqrt(a + b*x**S(2) + c*x**S(4))) + e**S(3)*x**S(3)*sqrt(a + b*x**S(2) + c*x**S(4))/(S(5)*c) + e**S(2)*x*(-S(4)*b*e + S(15)*c*d)*sqrt(a + b*x**S(2) + c*x**S(4))/(S(15)*c**S(2)) + e*x*sqrt(a + b*x**S(2) + c*x**S(4))*(S(8)*b**S(2)*e**S(2) + S(45)*c**S(2)*d**S(2) - S(3)*c*e*(S(3)*a*e + S(10)*b*d))/(S(15)*c**(S(5)/2)*(sqrt(a) + sqrt(c)*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))**S(2)/sqrt(a + b*x**S(2) + c*x**S(4)), x), x, a**(S(1)/4)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(-S(2)*b*e**S(2)/c + S(6)*d*e + (-a*e**S(2) + S(3)*c*d**S(2))/(sqrt(a)*sqrt(c)))*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(6)*c**(S(3)/4)*sqrt(a + b*x**S(2) + c*x**S(4))) - S(2)*a**(S(1)/4)*e*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(-b*e + S(3)*c*d)*elliptic_e(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(3)*c**(S(7)/4)*sqrt(a + b*x**S(2) + c*x**S(4))) + e**S(2)*x*sqrt(a + b*x**S(2) + c*x**S(4))/(S(3)*c) + S(2)*e*x*(-b*e + S(3)*c*d)*sqrt(a + b*x**S(2) + c*x**S(4))/(S(3)*c**(S(3)/2)*(sqrt(a) + sqrt(c)*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))/sqrt(a + b*x**S(2) + c*x**S(4)), x), x, -a**(S(1)/4)*e*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*elliptic_e(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(c**(S(3)/4)*sqrt(a + b*x**S(2) + c*x**S(4))) + a**(S(1)/4)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(e + sqrt(c)*d/sqrt(a))*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(2)*c**(S(3)/4)*sqrt(a + b*x**S(2) + c*x**S(4))) + e*x*sqrt(a + b*x**S(2) + c*x**S(4))/(sqrt(c)*(sqrt(a) + sqrt(c)*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((d + e*x**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))), x), x, atan(x*sqrt(a*e/d - b + c*d/e)/sqrt(a + b*x**S(2) + c*x**S(4)))/(S(2)*d*sqrt(a*e/d - b + c*d/e)) + c**(S(1)/4)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(2)*a**(S(1)/4)*(-sqrt(a)*e + sqrt(c)*d)*sqrt(a + b*x**S(2) + c*x**S(4))) - sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(e + sqrt(c)*d/sqrt(a))*elliptic_pi(-sqrt(a)*(-e + sqrt(c)*d/sqrt(a))**S(2)/(S(4)*sqrt(c)*d*e), S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(4)*a**(S(1)/4)*c**(S(1)/4)*d*(-e + sqrt(c)*d/sqrt(a))*sqrt(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((d + e*x**S(2))**S(2)*sqrt(a + b*x**S(2) + c*x**S(4))), x), x, a**(S(1)/4)*c**(S(1)/4)*e*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*elliptic_e(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(2)*d*sqrt(a + b*x**S(2) + c*x**S(4))*(a*e**S(2) - b*d*e + c*d**S(2))) - a**(S(1)/4)*c**(S(1)/4)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(e + sqrt(c)*d/sqrt(a))*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(4)*d*sqrt(a + b*x**S(2) + c*x**S(4))*(a*e**S(2) - b*d*e + c*d**S(2))) - a**(S(1)/4)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(e + sqrt(c)*d/sqrt(a))*(S(3)*c*d**S(2) - e*(-a*e + S(2)*b*d))*elliptic_pi(-(-sqrt(a)*e + sqrt(c)*d)**S(2)/(S(4)*sqrt(a)*sqrt(c)*d*e), S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(8)*c**(S(1)/4)*d**S(2)*(-sqrt(a)*e + sqrt(c)*d)*sqrt(a + b*x**S(2) + c*x**S(4))*(a*e**S(2) - b*d*e + c*d**S(2))) - sqrt(c)*e*x*sqrt(a + b*x**S(2) + c*x**S(4))/(S(2)*d*(sqrt(a) + sqrt(c)*x**S(2))*(a*e**S(2) - b*d*e + c*d**S(2))) + e**S(2)*x*sqrt(a + b*x**S(2) + c*x**S(4))/(S(2)*d*(d + e*x**S(2))*(a*e**S(2) - b*d*e + c*d**S(2))) + (S(3)*c*d**S(2) - e*(-a*e + S(2)*b*d))*atan(x*sqrt(a*e/d - b + c*d/e)/sqrt(a + b*x**S(2) + c*x**S(4)))/(S(4)*d**S(3)*e*(a*e/d - b + c*d/e)**(S(3)/2)) + c**(S(1)/4)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(S(3)*c*d**S(2) - e*(-a*e + S(2)*b*d))*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(4)*a**(S(1)/4)*d*(-sqrt(a)*e + sqrt(c)*d)*sqrt(a + b*x**S(2) + c*x**S(4))*(a*e**S(2) - b*d*e + c*d**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))**S(3)/sqrt(a + b*x**S(2) - c*x**S(4)), x), x, -e**S(3)*x**S(3)*sqrt(a + b*x**S(2) - c*x**S(4))/(S(5)*c) - e**S(2)*x*(S(4)*b*e + S(15)*c*d)*sqrt(a + b*x**S(2) - c*x**S(4))/(S(15)*c**S(2)) + sqrt(S(2))*(b - sqrt(S(4)*a*c + b**S(2)))*sqrt(b + sqrt(S(4)*a*c + b**S(2)))*sqrt(-S(2)*c*x**S(2)/(b - sqrt(S(4)*a*c + b**S(2))) + S(1))*sqrt(-S(2)*c*x**S(2)/(b + sqrt(S(4)*a*c + b**S(2))) + S(1))*(S(9)*a*e**S(3)/c + S(8)*b**S(2)*e**S(3)/c**S(2) + S(30)*b*d*e**S(2)/c + S(45)*d**S(2)*e + (S(8)*a*b*e**S(3) + S(30)*a*c*d*e**S(2) + S(30)*c**S(2)*d**S(3))/(b*c - c*sqrt(S(4)*a*c + b**S(2))))*elliptic_f(asin(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(S(4)*a*c + b**S(2)))), (b + sqrt(S(4)*a*c + b**S(2)))/(b - sqrt(S(4)*a*c + b**S(2))))/(S(60)*c**(S(3)/2)*sqrt(a + b*x**S(2) - c*x**S(4))) - sqrt(S(2))*e*(b - sqrt(S(4)*a*c + b**S(2)))*sqrt(b + sqrt(S(4)*a*c + b**S(2)))*sqrt(-S(2)*c*x**S(2)/(b - sqrt(S(4)*a*c + b**S(2))) + S(1))*sqrt(-S(2)*c*x**S(2)/(b + sqrt(S(4)*a*c + b**S(2))) + S(1))*(S(8)*b**S(2)*e**S(2) + S(45)*c**S(2)*d**S(2) + S(3)*c*e*(S(3)*a*e + S(10)*b*d))*elliptic_e(asin(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(S(4)*a*c + b**S(2)))), (b + sqrt(S(4)*a*c + b**S(2)))/(b - sqrt(S(4)*a*c + b**S(2))))/(S(60)*c**(S(7)/2)*sqrt(a + b*x**S(2) - c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))**S(2)/sqrt(a + b*x**S(2) - c*x**S(4)), x), x, -e**S(2)*x*sqrt(a + b*x**S(2) - c*x**S(4))/(S(3)*c) - sqrt(S(2))*e*(b - sqrt(S(4)*a*c + b**S(2)))*sqrt(b + sqrt(S(4)*a*c + b**S(2)))*(b*e + S(3)*c*d)*sqrt(-S(2)*c*x**S(2)/(b - sqrt(S(4)*a*c + b**S(2))) + S(1))*sqrt(-S(2)*c*x**S(2)/(b + sqrt(S(4)*a*c + b**S(2))) + S(1))*elliptic_e(asin(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(S(4)*a*c + b**S(2)))), (b + sqrt(S(4)*a*c + b**S(2)))/(b - sqrt(S(4)*a*c + b**S(2))))/(S(6)*c**(S(5)/2)*sqrt(a + b*x**S(2) - c*x**S(4))) + sqrt(S(2))*sqrt(b + sqrt(S(4)*a*c + b**S(2)))*sqrt(-S(2)*c*x**S(2)/(b - sqrt(S(4)*a*c + b**S(2))) + S(1))*sqrt(-S(2)*c*x**S(2)/(b + sqrt(S(4)*a*c + b**S(2))) + S(1))*(b*e**S(2)*(b - sqrt(S(4)*a*c + b**S(2))) + S(3)*c**S(2)*d**S(2) + c*e*(a*e + S(3)*b*d - S(3)*d*sqrt(S(4)*a*c + b**S(2))))*elliptic_f(asin(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(S(4)*a*c + b**S(2)))), (b + sqrt(S(4)*a*c + b**S(2)))/(b - sqrt(S(4)*a*c + b**S(2))))/(S(6)*c**(S(5)/2)*sqrt(a + b*x**S(2) - c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))/sqrt(a + b*x**S(2) - c*x**S(4)), x), x, -sqrt(S(2))*e*(b - sqrt(S(4)*a*c + b**S(2)))*sqrt(b + sqrt(S(4)*a*c + b**S(2)))*sqrt(-S(2)*c*x**S(2)/(b - sqrt(S(4)*a*c + b**S(2))) + S(1))*sqrt(-S(2)*c*x**S(2)/(b + sqrt(S(4)*a*c + b**S(2))) + S(1))*elliptic_e(asin(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(S(4)*a*c + b**S(2)))), (b + sqrt(S(4)*a*c + b**S(2)))/(b - sqrt(S(4)*a*c + b**S(2))))/(S(4)*c**(S(3)/2)*sqrt(a + b*x**S(2) - c*x**S(4))) + sqrt(S(2))*sqrt(b + sqrt(S(4)*a*c + b**S(2)))*(S(2)*c*d + e*(b - sqrt(S(4)*a*c + b**S(2))))*sqrt(-S(2)*c*x**S(2)/(b - sqrt(S(4)*a*c + b**S(2))) + S(1))*sqrt(-S(2)*c*x**S(2)/(b + sqrt(S(4)*a*c + b**S(2))) + S(1))*elliptic_f(asin(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(S(4)*a*c + b**S(2)))), (b + sqrt(S(4)*a*c + b**S(2)))/(b - sqrt(S(4)*a*c + b**S(2))))/(S(4)*c**(S(3)/2)*sqrt(a + b*x**S(2) - c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((d + e*x**S(2))*sqrt(a + b*x**S(2) - c*x**S(4))), x), x, sqrt(S(2))*sqrt(b + sqrt(S(4)*a*c + b**S(2)))*sqrt(-S(2)*c*x**S(2)/(b - sqrt(S(4)*a*c + b**S(2))) + S(1))*sqrt(-S(2)*c*x**S(2)/(b + sqrt(S(4)*a*c + b**S(2))) + S(1))*elliptic_pi(-e*(b + sqrt(S(4)*a*c + b**S(2)))/(S(2)*c*d), asin(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(S(4)*a*c + b**S(2)))), (b + sqrt(S(4)*a*c + b**S(2)))/(b - sqrt(S(4)*a*c + b**S(2))))/(S(2)*sqrt(c)*d*sqrt(a + b*x**S(2) - c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((d + e*x**S(2))**S(2)*sqrt(a + b*x**S(2) - c*x**S(4))), x), x, -e**S(2)*x*sqrt(a + b*x**S(2) - c*x**S(4))/(S(2)*d*(d + e*x**S(2))*(-a*e**S(2) + b*d*e + c*d**S(2))) + sqrt(S(2))*e*(b - sqrt(S(4)*a*c + b**S(2)))*sqrt(b + sqrt(S(4)*a*c + b**S(2)))*sqrt(-S(2)*c*x**S(2)/(b - sqrt(S(4)*a*c + b**S(2))) + S(1))*sqrt(-S(2)*c*x**S(2)/(b + sqrt(S(4)*a*c + b**S(2))) + S(1))*elliptic_e(asin(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(S(4)*a*c + b**S(2)))), (b + sqrt(S(4)*a*c + b**S(2)))/(b - sqrt(S(4)*a*c + b**S(2))))/(S(8)*sqrt(c)*d*(c*d**S(2) + e*(-a*e + b*d))*sqrt(a + b*x**S(2) - c*x**S(4))) - sqrt(S(2))*sqrt(b + sqrt(S(4)*a*c + b**S(2)))*(S(2)*c*d + e*(b - sqrt(S(4)*a*c + b**S(2))))*sqrt(-S(2)*c*x**S(2)/(b - sqrt(S(4)*a*c + b**S(2))) + S(1))*sqrt(-S(2)*c*x**S(2)/(b + sqrt(S(4)*a*c + b**S(2))) + S(1))*elliptic_f(asin(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(S(4)*a*c + b**S(2)))), (b + sqrt(S(4)*a*c + b**S(2)))/(b - sqrt(S(4)*a*c + b**S(2))))/(S(8)*sqrt(c)*d*(c*d**S(2) + e*(-a*e + b*d))*sqrt(a + b*x**S(2) - c*x**S(4))) + sqrt(S(2))*sqrt(b + sqrt(S(4)*a*c + b**S(2)))*(S(3)*c*d**S(2) + e*(-a*e + S(2)*b*d))*sqrt(-S(2)*c*x**S(2)/(b - sqrt(S(4)*a*c + b**S(2))) + S(1))*sqrt(-S(2)*c*x**S(2)/(b + sqrt(S(4)*a*c + b**S(2))) + S(1))*elliptic_pi(-e*(b + sqrt(S(4)*a*c + b**S(2)))/(S(2)*c*d), asin(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(S(4)*a*c + b**S(2)))), (b + sqrt(S(4)*a*c + b**S(2)))/(b - sqrt(S(4)*a*c + b**S(2))))/(S(4)*sqrt(c)*d**S(2)*(c*d**S(2) + e*(-a*e + b*d))*sqrt(a + b*x**S(2) - c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))/sqrt(-a + b*x**S(2) + c*x**S(4)), x), x, e*x*(b - sqrt(S(4)*a*c + b**S(2)))*(S(2)*c*x**S(2)/(b - sqrt(S(4)*a*c + b**S(2))) + S(1))/(S(2)*c*sqrt(-a + b*x**S(2) + c*x**S(4))) + sqrt(S(2))*d*sqrt(b + sqrt(S(4)*a*c + b**S(2)))*(S(2)*c*x**S(2)/(b - sqrt(S(4)*a*c + b**S(2))) + S(1))*elliptic_f(atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(S(4)*a*c + b**S(2)))), -S(2)*sqrt(S(4)*a*c + b**S(2))/(b - sqrt(S(4)*a*c + b**S(2))))/(S(2)*sqrt(c)*sqrt((S(2)*c*x**S(2)/(b - sqrt(S(4)*a*c + b**S(2))) + S(1))/(S(2)*c*x**S(2)/(b + sqrt(S(4)*a*c + b**S(2))) + S(1)))*sqrt(-a + b*x**S(2) + c*x**S(4))) - sqrt(S(2))*e*(b - sqrt(S(4)*a*c + b**S(2)))*sqrt(b + sqrt(S(4)*a*c + b**S(2)))*(S(2)*c*x**S(2)/(b - sqrt(S(4)*a*c + b**S(2))) + S(1))*elliptic_e(atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(S(4)*a*c + b**S(2)))), -S(2)*sqrt(S(4)*a*c + b**S(2))/(b - sqrt(S(4)*a*c + b**S(2))))/(S(4)*c**(S(3)/2)*sqrt((S(2)*c*x**S(2)/(b - sqrt(S(4)*a*c + b**S(2))) + S(1))/(S(2)*c*x**S(2)/(b + sqrt(S(4)*a*c + b**S(2))) + S(1)))*sqrt(-a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((d + e*x**S(2))*sqrt(-a + b*x**S(2) + c*x**S(4))), x), x, sqrt(S(2))*sqrt(-b + sqrt(S(4)*a*c + b**S(2)))*sqrt(S(2)*c*x**S(2)/(b - sqrt(S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(2)/(b + sqrt(S(4)*a*c + b**S(2))) + S(1))*elliptic_pi(e*(b - sqrt(S(4)*a*c + b**S(2)))/(S(2)*c*d), asin(sqrt(S(2))*sqrt(c)*x/sqrt(-b + sqrt(S(4)*a*c + b**S(2)))), (b - sqrt(S(4)*a*c + b**S(2)))/(b + sqrt(S(4)*a*c + b**S(2))))/(S(2)*sqrt(c)*d*sqrt(-a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate(S(1)/((d + e*x**S(2))*sqrt(-a + b*x**S(2) + c*x**S(4))), x), x, sqrt(S(2))*sqrt(c)*sqrt(b + sqrt(S(4)*a*c + b**S(2)))*(S(2)*c*x**S(2)/(b - sqrt(S(4)*a*c + b**S(2))) + S(1))*elliptic_f(atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(S(4)*a*c + b**S(2)))), -S(2)*sqrt(S(4)*a*c + b**S(2))/(b - sqrt(S(4)*a*c + b**S(2))))/(sqrt((S(2)*c*x**S(2)/(b - sqrt(S(4)*a*c + b**S(2))) + S(1))/(S(2)*c*x**S(2)/(b + sqrt(S(4)*a*c + b**S(2))) + S(1)))*(S(2)*c*d - e*(b + sqrt(S(4)*a*c + b**S(2))))*sqrt(-a + b*x**S(2) + c*x**S(4))) - sqrt(S(2))*e*(b + sqrt(S(4)*a*c + b**S(2)))**(S(3)/2)*(S(2)*c*x**S(2)/(b - sqrt(S(4)*a*c + b**S(2))) + S(1))*elliptic_pi(S(1) - e*(b + sqrt(S(4)*a*c + b**S(2)))/(S(2)*c*d), atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(S(4)*a*c + b**S(2)))), -S(2)*sqrt(S(4)*a*c + b**S(2))/(b - sqrt(S(4)*a*c + b**S(2))))/(S(2)*sqrt(c)*d*sqrt((S(2)*c*x**S(2)/(b - sqrt(S(4)*a*c + b**S(2))) + S(1))/(S(2)*c*x**S(2)/(b + sqrt(S(4)*a*c + b**S(2))) + S(1)))*(S(2)*c*d - e*(b + sqrt(S(4)*a*c + b**S(2))))*sqrt(-a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))/sqrt(-a + b*x**S(2) - c*x**S(4)), x), x, -a**(S(1)/4)*e*sqrt((a - b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*elliptic_e(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 + b/(S(4)*sqrt(a)*sqrt(c)))/(c**(S(3)/4)*sqrt(-a + b*x**S(2) - c*x**S(4))) + a**(S(1)/4)*sqrt((a - b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(e + sqrt(c)*d/sqrt(a))*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 + b/(S(4)*sqrt(a)*sqrt(c)))/(S(2)*c**(S(3)/4)*sqrt(-a + b*x**S(2) - c*x**S(4))) - e*x*sqrt(-a + b*x**S(2) - c*x**S(4))/(sqrt(c)*(sqrt(a) + sqrt(c)*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((d + e*x**S(2))*sqrt(-a + b*x**S(2) - c*x**S(4))), x), x, atan(x*sqrt(-a*e/d - b - c*d/e)/sqrt(-a + b*x**S(2) - c*x**S(4)))/(S(2)*d*sqrt(-a*e/d - b - c*d/e)) + c**(S(1)/4)*sqrt((a - b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 + b/(S(4)*sqrt(a)*sqrt(c)))/(S(2)*a**(S(1)/4)*(-sqrt(a)*e + sqrt(c)*d)*sqrt(-a + b*x**S(2) - c*x**S(4))) - sqrt((a - b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(e + sqrt(c)*d/sqrt(a))*elliptic_pi(-sqrt(a)*(-e + sqrt(c)*d/sqrt(a))**S(2)/(S(4)*sqrt(c)*d*e), S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 + b/(S(4)*sqrt(a)*sqrt(c)))/(S(4)*a**(S(1)/4)*c**(S(1)/4)*d*(-e + sqrt(c)*d/sqrt(a))*sqrt(-a + b*x**S(2) - c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))**S(3)/sqrt(x**S(4) + S(3)*x**S(2) + S(2)), x), x, e**S(3)*x**S(3)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))/S(5) + e**S(2)*x*(d - S(4)*e/S(5))*sqrt(x**S(4) + S(3)*x**S(2) + S(2)) + S(3)*e*x*(x**S(2) + S(2))*(S(5)*d**S(2) - S(10)*d*e + S(6)*e**S(2))/(S(5)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))) - S(3)*sqrt(S(2))*e*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*(x**S(2) + S(1))*(S(5)*d**S(2) - S(10)*d*e + S(6)*e**S(2))*elliptic_e(atan(x), S(1)/2)/(S(5)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))) + sqrt(S(2))*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*(x**S(2) + S(1))*(S(5)*d**S(3) - S(10)*d*e**S(2) + S(8)*e**S(3))*elliptic_f(atan(x), S(1)/2)/(S(10)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))**S(2)/sqrt(x**S(4) + S(3)*x**S(2) + S(2)), x), x, e**S(2)*x*sqrt(x**S(4) + S(3)*x**S(2) + S(2))/S(3) + e*x*(S(2)*d - S(2)*e)*(x**S(2) + S(2))/sqrt(x**S(4) + S(3)*x**S(2) + S(2)) - S(2)*sqrt(S(2))*e*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*(d - e)*(x**S(2) + S(1))*elliptic_e(atan(x), S(1)/2)/sqrt(x**S(4) + S(3)*x**S(2) + S(2)) + sqrt(S(2))*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*(S(3)*d**S(2) - S(2)*e**S(2))*(x**S(2) + S(1))*elliptic_f(atan(x), S(1)/2)/(S(6)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))/sqrt(x**S(4) + S(3)*x**S(2) + S(2)), x), x, sqrt(S(2))*d*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*(x**S(2) + S(1))*elliptic_f(atan(x), S(1)/2)/(S(2)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))) + e*x*(x**S(2) + S(2))/sqrt(x**S(4) + S(3)*x**S(2) + S(2)) - sqrt(S(2))*e*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*(x**S(2) + S(1))*elliptic_e(atan(x), S(1)/2)/sqrt(x**S(4) + S(3)*x**S(2) + S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((d + e*x**S(2))*sqrt(x**S(4) + S(3)*x**S(2) + S(2))), x), x, sqrt(S(2))*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*(x**S(2) + S(1))*elliptic_f(atan(x), S(1)/2)/(S(2)*(d - e)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))) - sqrt(S(2))*e*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*(x**S(2) + S(1))*elliptic_pi(S(1) - e/d, atan(x), S(1)/2)/(S(2)*d*(d - e)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate(S(1)/((d + e*x**S(2))*sqrt(x**S(4) + S(3)*x**S(2) + S(2))), x), x, sqrt(S(2))*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*(x**S(2) + S(1))*elliptic_f(atan(x), S(1)/2)/(S(2)*(d - e)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))) - sqrt(S(2))*e*(x**S(2) + S(2))*elliptic_pi(S(1) - e/d, atan(x), S(1)/2)/(S(2)*d*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*(d - e)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((d + e*x**S(2))**S(2)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))), x), x, e**S(2)*x*sqrt(x**S(4) + S(3)*x**S(2) + S(2))/(S(2)*d*(d + e*x**S(2))*(d**S(2) - S(3)*d*e + S(2)*e**S(2))) - e*x*(x**S(2) + S(2))/(S(2)*d*(d**S(2) - S(3)*d*e + S(2)*e**S(2))*sqrt(x**S(4) + S(3)*x**S(2) + S(2))) + sqrt(S(2))*e*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*(x**S(2) + S(1))*elliptic_e(atan(x), S(1)/2)/(S(2)*d*(d - S(2)*e)*(d - e)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))) + sqrt((x**S(2) + S(2))/(S(2)*x**S(2) + S(2)))*(S(2)*d - e)*(x**S(2) + S(1))*elliptic_f(atan(x), S(1)/2)/(S(2)*d*(d - e)**S(2)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))) - sqrt(S(2))*e*(x**S(2) + S(2))*(S(3)*d**S(2) - S(6)*d*e + S(2)*e**S(2))*elliptic_pi(S(1) - e/d, atan(x), S(1)/2)/(S(4)*d**S(2)*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*(d - S(2)*e)*(d - e)**S(2)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate(S(1)/((d + e*x**S(2))**S(2)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))), x), x, -sqrt(S(2))*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*(x**S(2) + S(1))*elliptic_f(atan(x), S(1)/2)/(S(4)*(d - S(2)*e)*(d - e)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))) + e**S(2)*x*sqrt(x**S(4) + S(3)*x**S(2) + S(2))/(S(2)*d*(d + e*x**S(2))*(d**S(2) - S(3)*d*e + S(2)*e**S(2))) - e*x*(x**S(2) + S(2))/(S(2)*d*(d**S(2) - S(3)*d*e + S(2)*e**S(2))*sqrt(x**S(4) + S(3)*x**S(2) + S(2))) + sqrt(S(2))*e*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*(x**S(2) + S(1))*elliptic_e(atan(x), S(1)/2)/(S(2)*d*(d - S(2)*e)*(d - e)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))) + sqrt(S(2))*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*(x**S(2) + S(1))*(S(3)*d**S(2) - S(6)*d*e + S(2)*e**S(2))*elliptic_f(atan(x), S(1)/2)/(S(4)*d*(d - S(2)*e)*(d - e)**S(2)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))) - sqrt(S(2))*e*(x**S(2) + S(2))*(S(3)*d**S(2) - S(6)*d*e + S(2)*e**S(2))*elliptic_pi(S(1) - e/d, atan(x), S(1)/2)/(S(4)*d**S(2)*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*(d - S(2)*e)*(d - e)**S(2)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(5)*x**S(2) + S(7))**S(3)/sqrt(x**S(4) + S(3)*x**S(2) + S(2)), x), x, S(25)*x**S(3)*sqrt(x**S(4) + S(3)*x**S(2) + S(2)) + S(135)*x*(x**S(2) + S(2))/sqrt(x**S(4) + S(3)*x**S(2) + S(2)) + S(75)*x*sqrt(x**S(4) + S(3)*x**S(2) + S(2)) - S(135)*sqrt(S(2))*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*(x**S(2) + S(1))*elliptic_e(atan(x), S(1)/2)/sqrt(x**S(4) + S(3)*x**S(2) + S(2)) + sqrt(S(2))*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*(S(193)*x**S(2) + S(193))*elliptic_f(atan(x), S(1)/2)/(S(2)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(5)*x**S(2) + S(7))**S(2)/sqrt(x**S(4) + S(3)*x**S(2) + S(2)), x), x, S(20)*x*(x**S(2) + S(2))/sqrt(x**S(4) + S(3)*x**S(2) + S(2)) + S(25)*x*sqrt(x**S(4) + S(3)*x**S(2) + S(2))/S(3) - S(20)*sqrt(S(2))*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*(x**S(2) + S(1))*elliptic_e(atan(x), S(1)/2)/sqrt(x**S(4) + S(3)*x**S(2) + S(2)) + sqrt(S(2))*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*(S(97)*x**S(2) + S(97))*elliptic_f(atan(x), S(1)/2)/(S(6)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(5)*x**S(2) + S(7))/sqrt(x**S(4) + S(3)*x**S(2) + S(2)), x), x, S(5)*x*(x**S(2) + S(2))/sqrt(x**S(4) + S(3)*x**S(2) + S(2)) - S(5)*sqrt(S(2))*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*(x**S(2) + S(1))*elliptic_e(atan(x), S(1)/2)/sqrt(x**S(4) + S(3)*x**S(2) + S(2)) + sqrt(S(2))*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*(S(7)*x**S(2) + S(7))*elliptic_f(atan(x), S(1)/2)/(S(2)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(x**S(4) + S(3)*x**S(2) + S(2)), x), x, sqrt(S(2))*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*(x**S(2) + S(1))*elliptic_f(atan(x), S(1)/2)/(S(2)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((S(5)*x**S(2) + S(7))*sqrt(x**S(4) + S(3)*x**S(2) + S(2))), x), x, sqrt(S(2))*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*(x**S(2) + S(1))*elliptic_f(atan(x), S(1)/2)/(S(4)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))) - sqrt(S(2))*(S(5)*x**S(2) + S(10))*elliptic_pi(S(2)/7, atan(x), S(1)/2)/(S(28)*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*sqrt(x**S(4) + S(3)*x**S(2) + S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((S(5)*x**S(2) + S(7))**S(2)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))), x), x, S(5)*x*(x**S(2) + S(2))/(S(84)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))) - S(25)*x*sqrt(x**S(4) + S(3)*x**S(2) + S(2))/(S(420)*x**S(2) + S(588)) - sqrt(S(2))*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*(S(5)*x**S(2) + S(5))*elliptic_e(atan(x), S(1)/2)/(S(84)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))) + sqrt(S(2))*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*(S(9)*x**S(2) + S(9))*elliptic_f(atan(x), S(1)/2)/(S(112)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))) - sqrt(S(2))*(S(65)*x**S(2) + S(130))*elliptic_pi(S(2)/7, atan(x), S(1)/2)/(S(2352)*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*sqrt(x**S(4) + S(3)*x**S(2) + S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(5)*x**S(2) + S(7))**S(3)/(x**S(4) + S(3)*x**S(2) + S(2))**(S(3)/2), x), x, x*(-S(11)*x**S(2) + S(5))/(S(2)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))) + S(261)*x*(x**S(2) + S(2))/(S(2)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))) + sqrt(S(2))*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*(S(169)*x**S(2) + S(169))*elliptic_f(atan(x), S(1)/2)/(S(2)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))) - sqrt(S(2))*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*(S(261)*x**S(2) + S(261))*elliptic_e(atan(x), S(1)/2)/(S(2)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(5)*x**S(2) + S(7))**S(2)/(x**S(4) + S(3)*x**S(2) + S(2))**(S(3)/2), x), x, -S(17)*x*(x**S(2) + S(2))/(S(2)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))) + x*(S(17)*x**S(2) + S(25))/(S(2)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))) + S(6)*sqrt(S(2))*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*(x**S(2) + S(1))*elliptic_f(atan(x), S(1)/2)/sqrt(x**S(4) + S(3)*x**S(2) + S(2)) + sqrt(S(2))*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*(S(17)*x**S(2) + S(17))*elliptic_e(atan(x), S(1)/2)/(S(2)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(5)*x**S(2) + S(7))/(x**S(4) + S(3)*x**S(2) + S(2))**(S(3)/2), x), x, -x*(x**S(2) + S(2))/(S(2)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))) + x*(x**S(2) + S(5))/(S(2)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))) + sqrt(S(2))*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*(x**S(2) + S(1))*elliptic_e(atan(x), S(1)/2)/(S(2)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))) + sqrt(S(2))*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*(x**S(2) + S(1))*elliptic_f(atan(x), S(1)/2)/(S(2)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(4) + S(3)*x**S(2) + S(2))**(S(-3)/2), x), x, -S(3)*x*(x**S(2) + S(2))/(S(2)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))) + x*(S(3)*x**S(2) + S(5))/(S(2)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))) - sqrt(S(2))*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*(x**S(2) + S(1))*elliptic_f(atan(x), S(1)/2)/sqrt(x**S(4) + S(3)*x**S(2) + S(2)) + sqrt(S(2))*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*(S(3)*x**S(2) + S(3))*elliptic_e(atan(x), S(1)/2)/(S(2)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((S(5)*x**S(2) + S(7))*(x**S(4) + S(3)*x**S(2) + S(2))**(S(3)/2)), x), x, x/(S(6)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))) + sqrt(S(2))*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*(x**S(2) + S(1))*elliptic_e(atan(x), S(1)/2)/(S(3)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))) + sqrt(S(2))*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*(S(125)*x**S(2) + S(125))*elliptic_pi(S(2)/7, atan(x), S(1)/2)/(S(168)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))) - sqrt((x**S(2) + S(2))/(S(2)*x**S(2) + S(2)))*(S(9)*x**S(2) + S(9))*elliptic_f(atan(x), S(1)/2)/(S(4)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate(S(1)/((S(5)*x**S(2) + S(7))*(x**S(4) + S(3)*x**S(2) + S(2))**(S(3)/2)), x), x, -x*(x**S(2) + S(2))/(S(3)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))) + x*(S(2)*x**S(2) + S(5))/(S(6)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))) + sqrt(S(2))*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*(x**S(2) + S(1))*elliptic_e(atan(x), S(1)/2)/(S(3)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))) - sqrt(S(2))*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*(S(9)*x**S(2) + S(9))*elliptic_f(atan(x), S(1)/2)/(S(8)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))) + sqrt(S(2))*(S(125)*x**S(2) + S(250))*elliptic_pi(S(2)/7, atan(x), S(1)/2)/(S(168)*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*sqrt(x**S(4) + S(3)*x**S(2) + S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((S(5)*x**S(2) + S(7))**S(2)*(x**S(4) + S(3)*x**S(2) + S(2))**(S(3)/2)), x), x, S(625)*x*(x**S(2) + S(1))*(x**S(2) + S(2))/((S(2520)*x**S(2) + S(3528))*sqrt(x**S(4) + S(3)*x**S(2) + S(2))) - S(125)*x*(x**S(2) + S(2))/(S(504)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))) - x/(S(18)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))) + sqrt(S(2))*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*(S(31)*x**S(2) + S(31))*elliptic_e(atan(x), S(1)/2)/(S(56)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))) + sqrt(S(2))*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*(S(375)*x**S(2) + S(375))*elliptic_pi(S(2)/7, atan(x), S(1)/2)/(S(1568)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))) - sqrt((x**S(2) + S(2))/(S(2)*x**S(2) + S(2)))*(S(463)*x**S(2) + S(463))*elliptic_f(atan(x), S(1)/2)/(S(336)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate(S(1)/((S(5)*x**S(2) + S(7))**S(2)*(x**S(4) + S(3)*x**S(2) + S(2))**(S(3)/2)), x), x, S(625)*x*(x**S(2) + S(1))*(x**S(2) + S(2))/((S(2520)*x**S(2) + S(3528))*sqrt(x**S(4) + S(3)*x**S(2) + S(2))) - S(125)*x*(x**S(2) + S(2))/(S(504)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))) - x/(S(18)*sqrt(x**S(4) + S(3)*x**S(2) + S(2))) + (S(125)*x**S(2) + S(125))*elliptic_pi(S(-3)/7, atan(sqrt(S(2))*x/S(2)), S(-1))/(S(189)*sqrt((x**S(2) + S(1))/(x**S(2) + S(2)))*sqrt(x**S(4) + S(3)*x**S(2) + S(2))) + sqrt(S(2))*(S(31)*x**S(2) + S(62))*elliptic_e(atan(x), S(1)/2)/(S(56)*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*sqrt(x**S(4) + S(3)*x**S(2) + S(2))) + sqrt(S(2))*(S(6875)*x**S(2) + S(13750))*elliptic_pi(S(2)/7, atan(x), S(1)/2)/(S(14112)*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*sqrt(x**S(4) + S(3)*x**S(2) + S(2))) - sqrt(S(2))*(S(7667)*x**S(2) + S(15334))*elliptic_f(atan(x), S(1)/2)/(S(6048)*sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*sqrt(x**S(4) + S(3)*x**S(2) + S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-x**S(2) + S(3))/sqrt(-x**S(4) + x**S(2) + S(3)), x), x, -sqrt(S(-1)/2 + sqrt(S(13))/S(2))*elliptic_e(asin(sqrt(S(2))*x/sqrt(S(1) + sqrt(S(13)))), S(-7)/6 - sqrt(S(13))/S(6)) + sqrt(S(7) + S(2)*sqrt(S(13)))*elliptic_f(asin(sqrt(S(2))*x/sqrt(S(1) + sqrt(S(13)))), S(-7)/6 - sqrt(S(13))/S(6)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-x**S(2) + S(3))/sqrt(-x**S(4) + S(2)*x**S(2) + S(3)), x), x, -elliptic_e(asin(sqrt(S(3))*x/S(3)), S(-3)) + S(4)*elliptic_f(asin(sqrt(S(3))*x/S(3)), S(-3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-x**S(2) + S(3))/sqrt(-x**S(4) + S(3)*x**S(2) + S(3)), x), x, -sqrt(S(-3)/2 + sqrt(S(21))/S(2))*elliptic_e(asin(sqrt(S(2))*x/sqrt(S(3) + sqrt(S(21)))), S(-5)/2 - sqrt(S(21))/S(2)) + sqrt(S(9) + S(2)*sqrt(S(21)))*elliptic_f(asin(sqrt(S(2))*x/sqrt(S(3) + sqrt(S(21)))), S(-5)/2 - sqrt(S(21))/S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-x**S(2) + S(3))/sqrt(-x**S(4) - x**S(2) + S(3)), x), x, -sqrt(S(1)/2 + sqrt(S(13))/S(2))*elliptic_e(asin(sqrt(S(2))*x/sqrt(S(-1) + sqrt(S(13)))), S(-7)/6 + sqrt(S(13))/S(6)) + sqrt(S(5) + S(2)*sqrt(S(13)))*elliptic_f(asin(sqrt(S(2))*x/sqrt(S(-1) + sqrt(S(13)))), S(-7)/6 + sqrt(S(13))/S(6)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-x**S(2) + S(3))/sqrt(-x**S(4) - S(2)*x**S(2) + S(3)), x), x, -sqrt(S(3))*elliptic_e(asin(x), S(-1)/3) + S(2)*sqrt(S(3))*elliptic_f(asin(x), S(-1)/3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-x**S(2) + S(3))/sqrt(-x**S(4) - S(3)*x**S(2) + S(3)), x), x, -sqrt(S(3)/2 + sqrt(S(21))/S(2))*elliptic_e(asin(sqrt(S(2))*x/sqrt(S(-3) + sqrt(S(21)))), S(-5)/2 + sqrt(S(21))/S(2)) + sqrt(S(3) + S(2)*sqrt(S(21)))*elliptic_f(asin(sqrt(S(2))*x/sqrt(S(-3) + sqrt(S(21)))), S(-5)/2 + sqrt(S(21))/S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b + S(2)*c*x**S(2) - sqrt(-S(4)*a*c + b**S(2)))/sqrt(a + b*x**S(2) + c*x**S(4)), x), x, -S(2)*a**(S(1)/4)*c**(S(1)/4)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*elliptic_e(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/sqrt(a + b*x**S(2) + c*x**S(4)) + S(2)*sqrt(c)*x*sqrt(a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2)) + sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(S(2)*sqrt(a)*sqrt(c) + b - sqrt(-S(4)*a*c + b**S(2)))*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(2)*a**(S(1)/4)*c**(S(1)/4)*sqrt(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(2) + S(2))/((x**S(2) + S(1))*sqrt(x**S(4) + S(3)*x**S(2) + S(2))), x), x, sqrt(S(2))*(x**S(2) + S(2))*elliptic_e(atan(x), S(1)/2)/(sqrt((x**S(2) + S(2))/(x**S(2) + S(1)))*sqrt(x**S(4) + S(3)*x**S(2) + S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))**(S(5)/2)*(a + b*x**S(2) + c*x**S(4)), x), x, c*x**S(3)*(d + e*x**S(2))**(S(7)/2)/(S(10)*e) + d**S(3)*(S(80)*a*e**S(2) - S(10)*b*d*e + S(3)*c*d**S(2))*atanh(sqrt(e)*x/sqrt(d + e*x**S(2)))/(S(256)*e**(S(5)/2)) + d**S(2)*x*sqrt(d + e*x**S(2))*(S(80)*a*e**S(2) - S(10)*b*d*e + S(3)*c*d**S(2))/(S(256)*e**S(2)) + d*x*(d + e*x**S(2))**(S(3)/2)*(S(80)*a*e**S(2) - S(10)*b*d*e + S(3)*c*d**S(2))/(S(384)*e**S(2)) - x*(d + e*x**S(2))**(S(7)/2)*(-S(10)*b*e + S(3)*c*d)/(S(80)*e**S(2)) + x*(d + e*x**S(2))**(S(5)/2)*(S(80)*a*e**S(2) - S(10)*b*d*e + S(3)*c*d**S(2))/(S(480)*e**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))**(S(3)/2)*(a + b*x**S(2) + c*x**S(4)), x), x, c*x**S(3)*(d + e*x**S(2))**(S(5)/2)/(S(8)*e) + d**S(2)*(S(48)*a*e**S(2) - S(8)*b*d*e + S(3)*c*d**S(2))*atanh(sqrt(e)*x/sqrt(d + e*x**S(2)))/(S(128)*e**(S(5)/2)) + d*x*sqrt(d + e*x**S(2))*(S(48)*a*e**S(2) - S(8)*b*d*e + S(3)*c*d**S(2))/(S(128)*e**S(2)) - x*(d + e*x**S(2))**(S(5)/2)*(-S(8)*b*e + S(3)*c*d)/(S(48)*e**S(2)) + x*(d + e*x**S(2))**(S(3)/2)*(S(48)*a*e**S(2) - S(8)*b*d*e + S(3)*c*d**S(2))/(S(192)*e**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(d + e*x**S(2))*(a + b*x**S(2) + c*x**S(4)), x), x, c*x**S(3)*(d + e*x**S(2))**(S(3)/2)/(S(6)*e) + d*(S(8)*a*e**S(2) - S(2)*b*d*e + c*d**S(2))*atanh(sqrt(e)*x/sqrt(d + e*x**S(2)))/(S(16)*e**(S(5)/2)) - x*(d + e*x**S(2))**(S(3)/2)*(-S(2)*b*e + c*d)/(S(8)*e**S(2)) + x*sqrt(d + e*x**S(2))*(S(8)*a*e**S(2) - S(2)*b*d*e + c*d**S(2))/(S(16)*e**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))/sqrt(d + e*x**S(2)), x), x, c*x**S(3)*sqrt(d + e*x**S(2))/(S(4)*e) - x*sqrt(d + e*x**S(2))*(-S(4)*b*e + S(3)*c*d)/(S(8)*e**S(2)) + (S(8)*a*e**S(2) - S(4)*b*d*e + S(3)*c*d**S(2))*atanh(sqrt(e)*x/sqrt(d + e*x**S(2)))/(S(8)*e**(S(5)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))/(d + e*x**S(2))**(S(3)/2), x), x, c*x*sqrt(d + e*x**S(2))/(S(2)*e**S(2)) - (-S(2)*b*e + S(3)*c*d)*atanh(sqrt(e)*x/sqrt(d + e*x**S(2)))/(S(2)*e**(S(5)/2)) + x*(a*e**S(2) - b*d*e + c*d**S(2))/(d*e**S(2)*sqrt(d + e*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))/(d + e*x**S(2))**(S(5)/2), x), x, c*atanh(sqrt(e)*x/sqrt(d + e*x**S(2)))/e**(S(5)/2) + x*(a*e**S(2) - b*d*e + c*d**S(2))/(S(3)*d*e**S(2)*(d + e*x**S(2))**(S(3)/2)) - x*(S(4)*c*d**S(2) - e*(S(2)*a*e + b*d))/(S(3)*d**S(2)*e**S(2)*sqrt(d + e*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))/(d + e*x**S(2))**(S(7)/2), x), x, x*(a*e**S(2) - b*d*e + c*d**S(2))/(S(5)*d*e**S(2)*(d + e*x**S(2))**(S(5)/2)) - x*(c*d**S(2) - S(5)*c*d*e*x**S(2) - e*(S(4)*a*e + b*d))/(S(15)*d**S(2)*e**S(2)*(d + e*x**S(2))**(S(3)/2)) - x*(S(2)*c*d**S(2) - S(2)*e*(S(4)*a*e + b*d))/(S(15)*d**S(3)*e**S(2)*sqrt(d + e*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))/(d + e*x**S(2))**(S(9)/2), x), x, x*(a*e**S(2) - b*d*e + c*d**S(2))/(S(7)*d*e**S(2)*(d + e*x**S(2))**(S(7)/2)) - x*(S(8)*c*d**S(2) - e*(S(6)*a*e + b*d))/(S(35)*d**S(2)*e**S(2)*(d + e*x**S(2))**(S(5)/2)) + x*(S(3)*c*d**S(2) + S(4)*e*(S(6)*a*e + b*d))/(S(105)*d**S(3)*e**S(2)*(d + e*x**S(2))**(S(3)/2)) + x*(S(6)*c*d**S(2) + S(8)*e*(S(6)*a*e + b*d))/(S(105)*d**S(4)*e**S(2)*sqrt(d + e*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))/(d + e*x**S(2))**(S(11)/2), x), x, x*(a*e**S(2) - b*d*e + c*d**S(2))/(S(9)*d*e**S(2)*(d + e*x**S(2))**(S(9)/2)) - x*(S(10)*c*d**S(2) - e*(S(8)*a*e + b*d))/(S(63)*d**S(2)*e**S(2)*(d + e*x**S(2))**(S(7)/2)) + x*(c*d**S(2) + S(2)*e*(S(8)*a*e + b*d))/(S(105)*d**S(3)*e**S(2)*(d + e*x**S(2))**(S(5)/2)) + x*(S(4)*c*d**S(2) + S(8)*e*(S(8)*a*e + b*d))/(S(315)*d**S(4)*e**S(2)*(d + e*x**S(2))**(S(3)/2)) + x*(S(8)*c*d**S(2) + S(16)*e*(S(8)*a*e + b*d))/(S(315)*d**S(5)*e**S(2)*sqrt(d + e*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**n)**S(3)/(a + c*x**(S(2)*n)), x), x, S(3)*d*e**S(2)*x/c + e**S(3)*x**(n + S(1))/(c*(n + S(1))) - x*(-a*e**S(3) + sqrt(c)*d*(-S(3)*a*e**S(2) + c*d**S(2))/sqrt(-a) + S(3)*c*d**S(2)*e)*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), sqrt(c)*x**n/sqrt(-a))/(S(2)*c**(S(3)/2)*sqrt(-a)) + x*(-S(3)*a*sqrt(c)*d*e**S(2) + a*e**S(3)*sqrt(-a) + c**(S(3)/2)*d**S(3) - S(3)*c*d**S(2)*e*sqrt(-a))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -sqrt(c)*x**n/sqrt(-a))/(S(2)*a*c**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**n)**S(2)/(a + c*x**(S(2)*n)), x), x, e**S(2)*x/c + x*(-a*e**S(2) - S(2)*sqrt(c)*d*e*sqrt(-a) + c*d**S(2))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -sqrt(c)*x**n/sqrt(-a))/(S(2)*a*c) + x*(-a*e**S(2) + S(2)*sqrt(c)*d*e*sqrt(-a) + c*d**S(2))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), sqrt(c)*x**n/sqrt(-a))/(S(2)*a*c), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**n)/(a + c*x**(S(2)*n)), x), x, x*(d - e*sqrt(-a)/sqrt(c))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -sqrt(c)*x**n/sqrt(-a))/(S(2)*a) + x*(d + e*sqrt(-a)/sqrt(c))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), sqrt(c)*x**n/sqrt(-a))/(S(2)*a), expand=True, _diff=True, _numerical=True)
# Apart assert rubi_test(rubi_integrate(S(1)/((a + c*x**(S(2)*n))*(d + e*x**n)), x), x, e**S(2)*x*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -e*x**n/d)/(d*(a*e**S(2) + c*d**S(2))) + c*x*(d - e*sqrt(-a)/sqrt(c))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), sqrt(c)*x**n/sqrt(-a))/(S(2)*a*(a*e**S(2) + c*d**S(2))) + c*x*(d + e*sqrt(-a)/sqrt(c))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -sqrt(c)*x**n/sqrt(-a))/(S(2)*a*(a*e**S(2) + c*d**S(2))), expand=True, _diff=True, _numerical=True)
# Apart assert rubi_test(rubi_integrate(S(1)/((a + c*x**(S(2)*n))*(d + e*x**n)**S(2)), x), x, S(2)*c*e**S(2)*x*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -e*x**n/d)/(a*e**S(2) + c*d**S(2))**S(2) + e**S(2)*x*hyper((S(2), S(1)/n), (S(1) + S(1)/n,), -e*x**n/d)/(d**S(2)*(a*e**S(2) + c*d**S(2))) + c*x*(-a*e**S(2) - S(2)*sqrt(c)*d*e*sqrt(-a) + c*d**S(2))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), sqrt(c)*x**n/sqrt(-a))/(S(2)*a*(a*e**S(2) + c*d**S(2))**S(2)) + c*x*(-a*e**S(2) + S(2)*sqrt(c)*d*e*sqrt(-a) + c*d**S(2))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -sqrt(c)*x**n/sqrt(-a))/(S(2)*a*(a*e**S(2) + c*d**S(2))**S(2)), expand=True, _diff=True, _numerical=True)
# Apart assert rubi_test(rubi_integrate(S(1)/((a + c*x**(S(2)*n))*(d + e*x**n)**S(3)), x), x, c**(S(3)/2)*x*(-a*e**S(3) - sqrt(c)*d*(-S(3)*a*e**S(2) + c*d**S(2))/sqrt(-a) + S(3)*c*d**S(2)*e)*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), sqrt(c)*x**n/sqrt(-a))/(S(2)*sqrt(-a)*(a*e**S(2) + c*d**S(2))**S(3)) + c*e**S(2)*x*(-a*e**S(2) + S(3)*c*d**S(2))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -e*x**n/d)/(d*(a*e**S(2) + c*d**S(2))**S(3)) + S(2)*c*e**S(2)*x*hyper((S(2), S(1)/n), (S(1) + S(1)/n,), -e*x**n/d)/(d*(a*e**S(2) + c*d**S(2))**S(2)) + e**S(2)*x*hyper((S(3), S(1)/n), (S(1) + S(1)/n,), -e*x**n/d)/(d**S(3)*(a*e**S(2) + c*d**S(2))) + c**(S(3)/2)*x*(-S(3)*a*sqrt(c)*d*e**S(2) + c**(S(3)/2)*d**S(3) + S(3)*c*d**S(2)*e*sqrt(-a) + e**S(3)*(-a)**(S(3)/2))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -sqrt(c)*x**n/sqrt(-a))/(S(2)*a*(a*e**S(2) + c*d**S(2))**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**n)/(a - c*x**(S(2)*n)), x), x, x*(-sqrt(a)*e/sqrt(c) + d)*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -sqrt(c)*x**n/sqrt(a))/(S(2)*a) + x*(sqrt(a)*e/sqrt(c) + d)*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), sqrt(c)*x**n/sqrt(a))/(S(2)*a), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**n)**S(3)/(a + c*x**(S(2)*n))**S(2), x), x, -x*(sqrt(c)*(-S(2)*n + S(1))*(-S(3)*a*d*e**S(2) + c*d**S(3))/sqrt(-a) - (-n + S(1))*(-a*e**S(3) + S(3)*c*d**S(2)*e))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -sqrt(c)*x**n/sqrt(-a))/(S(4)*c**(S(3)/2)*n*(-a)**(S(3)/2)) - x*(sqrt(c)*(-S(2)*n + S(1))*(-S(3)*a*d*e**S(2) + c*d**S(3))/sqrt(-a) + (-n + S(1))*(-a*e**S(3) + S(3)*c*d**S(2)*e))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), sqrt(c)*x**n/sqrt(-a))/(S(4)*c**(S(3)/2)*n*(-a)**(S(3)/2)) + e**S(2)*x*(S(3)*d - e*sqrt(-a)/sqrt(c))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -sqrt(c)*x**n/sqrt(-a))/(S(2)*a*c) + e**S(2)*x*(S(3)*d + e*sqrt(-a)/sqrt(c))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), sqrt(c)*x**n/sqrt(-a))/(S(2)*a*c) + x*(d*(-S(3)*a*e**S(2) + c*d**S(2)) + e*x**n*(-a*e**S(2) + S(3)*c*d**S(2)))/(S(2)*a*c*n*(a + c*x**(S(2)*n))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**n)**S(2)/(a + c*x**(S(2)*n))**S(2), x), x, e**S(2)*x*hyper((S(1), S(1)/(S(2)*n)), (S(1) + S(1)/(S(2)*n),), -c*x**(S(2)*n)/a)/(a*c) + x*(-a*e**S(2) + c*d**S(2) + S(2)*c*d*e*x**n)/(S(2)*a*c*n*(a + c*x**(S(2)*n))) - x*(-a*e**S(2)*(-S(2)*n + S(1)) - S(2)*sqrt(c)*d*e*sqrt(-a)*(-n + S(1)) + c*d**S(2)*(-S(2)*n + S(1)))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -sqrt(c)*x**n/sqrt(-a))/(S(4)*a**S(2)*c*n) - x*(-a*e**S(2)*(-S(2)*n + S(1)) + S(2)*sqrt(c)*d*e*sqrt(-a)*(-n + S(1)) + c*d**S(2)*(-S(2)*n + S(1)))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), sqrt(c)*x**n/sqrt(-a))/(S(4)*a**S(2)*c*n), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**n)/(a + c*x**(S(2)*n))**S(2), x), x, x*(d + e*x**n)/(S(2)*a*n*(a + c*x**(S(2)*n))) - x*(sqrt(c)*(-S(2)*d*n + d) + e*sqrt(-a)*(-n + S(1)))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), sqrt(c)*x**n/sqrt(-a))/(S(4)*a**S(2)*sqrt(c)*n) - x*(sqrt(c)*d*(-S(2)*n + S(1)) - e*sqrt(-a)*(-n + S(1)))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -sqrt(c)*x**n/sqrt(-a))/(S(4)*a**S(2)*sqrt(c)*n), expand=True, _diff=True, _numerical=True)
# Apart assert rubi_test(rubi_integrate(S(1)/((a + c*x**(S(2)*n))**S(2)*(d + e*x**n)), x), x, e**S(4)*x*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -e*x**n/d)/(d*(a*e**S(2) + c*d**S(2))**S(2)) + c*e**S(2)*x*(d - e*sqrt(-a)/sqrt(c))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), sqrt(c)*x**n/sqrt(-a))/(S(2)*a*(a*e**S(2) + c*d**S(2))**S(2)) + c*e**S(2)*x*(d + e*sqrt(-a)/sqrt(c))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -sqrt(c)*x**n/sqrt(-a))/(S(2)*a*(a*e**S(2) + c*d**S(2))**S(2)) + c*x*(d - e*x**n)/(S(2)*a*n*(a + c*x**(S(2)*n))*(a*e**S(2) + c*d**S(2))) - sqrt(c)*x*(sqrt(c)*(-S(2)*d*n + d) + e*sqrt(-a)*(-n + S(1)))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -sqrt(c)*x**n/sqrt(-a))/(S(4)*a**S(2)*n*(a*e**S(2) + c*d**S(2))) - sqrt(c)*x*(sqrt(c)*d*(-S(2)*n + S(1)) - e*sqrt(-a)*(-n + S(1)))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), sqrt(c)*x**n/sqrt(-a))/(S(4)*a**S(2)*n*(a*e**S(2) + c*d**S(2))), expand=True, _diff=True, _numerical=True)
# apart assert rubi_test(rubi_integrate(S(1)/((a + c*x**(S(2)*n))**S(2)*(d + e*x**n)**S(2)), x), x, S(4)*c*e**S(4)*x*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -e*x**n/d)/(a*e**S(2) + c*d**S(2))**S(3) + e**S(4)*x*hyper((S(2), S(1)/n), (S(1) + S(1)/n,), -e*x**n/d)/(d**S(2)*(a*e**S(2) + c*d**S(2))**S(2)) + c*e**S(2)*x*(-a*e**S(2) - S(4)*sqrt(c)*d*e*sqrt(-a) + S(3)*c*d**S(2))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), sqrt(c)*x**n/sqrt(-a))/(S(2)*a*(a*e**S(2) + c*d**S(2))**S(3)) + c*e**S(2)*x*(-a*e**S(2) + S(4)*sqrt(c)*d*e*sqrt(-a) + S(3)*c*d**S(2))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -sqrt(c)*x**n/sqrt(-a))/(S(2)*a*(a*e**S(2) + c*d**S(2))**S(3)) + c*x*(-a*e**S(2) + c*d**S(2) - S(2)*c*d*e*x**n)/(S(2)*a*n*(a + c*x**(S(2)*n))*(a*e**S(2) + c*d**S(2))**S(2)) - c*x*(-a*e**S(2)*(-S(2)*n + S(1)) - S(2)*sqrt(c)*d*e*sqrt(-a)*(-n + S(1)) + c*d**S(2)*(-S(2)*n + S(1)))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), sqrt(c)*x**n/sqrt(-a))/(S(4)*a**S(2)*n*(a*e**S(2) + c*d**S(2))**S(2)) - c*x*(-a*e**S(2)*(-S(2)*n + S(1)) + S(2)*sqrt(c)*d*e*sqrt(-a)*(-n + S(1)) + c*d**S(2)*(-S(2)*n + S(1)))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -sqrt(c)*x**n/sqrt(-a))/(S(4)*a**S(2)*n*(a*e**S(2) + c*d**S(2))**S(2)), expand=True, _diff=True, _numerical=True)
# apart assert rubi_test(rubi_integrate(S(1)/((a + c*x**(S(2)*n))**S(2)*(d + e*x**n)**S(3)), x), x, c**(S(3)/2)*e**S(2)*x*(-a*e**S(3) - S(3)*sqrt(c)*d*(-a*e**S(2) + c*d**S(2))/sqrt(-a) + S(5)*c*d**S(2)*e)*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), sqrt(c)*x**n/sqrt(-a))/(sqrt(-a)*(a*e**S(2) + c*d**S(2))**S(4)) - c**(S(3)/2)*x*(sqrt(c)*(-S(2)*n + S(1))*(-S(3)*a*d*e**S(2) + c*d**S(3))/sqrt(-a) - (-n + S(1))*(-a*e**S(3) + S(3)*c*d**S(2)*e))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), sqrt(c)*x**n/sqrt(-a))/(S(4)*n*(-a)**(S(3)/2)*(a*e**S(2) + c*d**S(2))**S(3)) - c**(S(3)/2)*x*(sqrt(c)*(-S(2)*n + S(1))*(-S(3)*a*d*e**S(2) + c*d**S(3))/sqrt(-a) + (-n + S(1))*(-a*e**S(3) + S(3)*c*d**S(2)*e))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -sqrt(c)*x**n/sqrt(-a))/(S(4)*n*(-a)**(S(3)/2)*(a*e**S(2) + c*d**S(2))**S(3)) + S(2)*c*e**S(4)*x*(-a*e**S(2) + S(5)*c*d**S(2))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -e*x**n/d)/(d*(a*e**S(2) + c*d**S(2))**S(4)) + S(4)*c*e**S(4)*x*hyper((S(2), S(1)/n), (S(1) + S(1)/n,), -e*x**n/d)/(d*(a*e**S(2) + c*d**S(2))**S(3)) + e**S(4)*x*hyper((S(3), S(1)/n), (S(1) + S(1)/n,), -e*x**n/d)/(d**S(3)*(a*e**S(2) + c*d**S(2))**S(2)) + c**(S(3)/2)*e**S(2)*x*(-S(3)*a*sqrt(c)*d*e**S(2) + S(3)*c**(S(3)/2)*d**S(3) + S(5)*c*d**S(2)*e*sqrt(-a) + e**S(3)*(-a)**(S(3)/2))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -sqrt(c)*x**n/sqrt(-a))/(a*(a*e**S(2) + c*d**S(2))**S(4)) + c**S(2)*x*(d*(-S(3)*a*e**S(2) + c*d**S(2)) - e*x**n*(-a*e**S(2) + S(3)*c*d**S(2)))/(S(2)*a*n*(a + c*x**(S(2)*n))*(a*e**S(2) + c*d**S(2))**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**n)**S(3)/(a + c*x**(S(2)*n))**S(3), x), x, -x*(sqrt(c)*(-S(4)*n + S(1))*(-S(2)*n + S(1))*(-S(3)*a*d*e**S(2) + c*d**S(3))/sqrt(-a) - (-S(3)*n + S(1))*(-n + S(1))*(-a*e**S(3) + S(3)*c*d**S(2)*e))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -sqrt(c)*x**n/sqrt(-a))/(S(16)*c**(S(3)/2)*n**S(2)*(-a)**(S(5)/2)) - x*(sqrt(c)*(-S(4)*n + S(1))*(-S(2)*n + S(1))*(-S(3)*a*d*e**S(2) + c*d**S(3))/sqrt(-a) + (-S(3)*n + S(1))*(-n + S(1))*(-a*e**S(3) + S(3)*c*d**S(2)*e))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), sqrt(c)*x**n/sqrt(-a))/(S(16)*c**(S(3)/2)*n**S(2)*(-a)**(S(5)/2)) + e**S(2)*x*(S(3)*d + e*x**n)/(S(2)*a*c*n*(a + c*x**(S(2)*n))) + x*(d*(-S(3)*a*e**S(2) + c*d**S(2)) + e*x**n*(-a*e**S(2) + S(3)*c*d**S(2)))/(S(4)*a*c*n*(a + c*x**(S(2)*n))**S(2)) - x*(d*(-S(4)*n + S(1))*(-S(3)*a*e**S(2) + c*d**S(2)) + e*x**n*(-S(3)*n + S(1))*(-a*e**S(2) + S(3)*c*d**S(2)))/(S(8)*a**S(2)*c*n**S(2)*(a + c*x**(S(2)*n))) - e**S(2)*x*(sqrt(c)*d*(-S(6)*n + S(3)) - e*sqrt(-a)*(-n + S(1)))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -sqrt(c)*x**n/sqrt(-a))/(S(4)*a**S(2)*c**(S(3)/2)*n) - e**S(2)*x*(sqrt(c)*d*(-S(6)*n + S(3)) + e*sqrt(-a)*(-n + S(1)))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), sqrt(c)*x**n/sqrt(-a))/(S(4)*a**S(2)*c**(S(3)/2)*n), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**n)**S(2)/(a + c*x**(S(2)*n))**S(3), x), x, x*(-a*e**S(2) + c*d**S(2) + S(2)*c*d*e*x**n)/(S(4)*a*c*n*(a + c*x**(S(2)*n))**S(2)) + e**S(2)*x*hyper((S(2), S(1)/(S(2)*n)), (S(1) + S(1)/(S(2)*n),), -c*x**(S(2)*n)/a)/(a**S(2)*c) - x*(S(2)*c*d*e*x**n*(-S(3)*n + S(1)) + (-S(4)*n + S(1))*(-a*e**S(2) + c*d**S(2)))/(S(8)*a**S(2)*c*n**S(2)*(a + c*x**(S(2)*n))) + x*(-a*e**S(2)*(S(8)*n**S(2) - S(6)*n + S(1)) + S(2)*sqrt(c)*d*e*sqrt(-a)*(S(3)*n**S(2) - S(4)*n + S(1)) + c*d**S(2)*(S(8)*n**S(2) - S(6)*n + S(1)))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), sqrt(c)*x**n/sqrt(-a))/(S(16)*a**S(3)*c*n**S(2)) - x*(a*e**S(2)*(S(8)*n**S(2) - S(6)*n + S(1)) + S(2)*sqrt(c)*d*e*sqrt(-a)*(S(3)*n**S(2) - S(4)*n + S(1)) - c*d**S(2)*(S(8)*n**S(2) - S(6)*n + S(1)))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -sqrt(c)*x**n/sqrt(-a))/(S(16)*a**S(3)*c*n**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**n)/(a + c*x**(S(2)*n))**S(3), x), x, x*(d + e*x**n)/(S(4)*a*n*(a + c*x**(S(2)*n))**S(2)) - x*(d*(-S(4)*n + S(1)) + e*x**n*(-S(3)*n + S(1)))/(S(8)*a**S(2)*n**S(2)*(a + c*x**(S(2)*n))) - x*(-sqrt(c)*d*(S(8)*n**S(2) - S(6)*n + S(1)) + e*sqrt(-a)*(S(3)*n**S(2) - S(4)*n + S(1)))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -sqrt(c)*x**n/sqrt(-a))/(S(16)*a**S(3)*sqrt(c)*n**S(2)) + x*(sqrt(c)*d*(S(8)*n**S(2) - S(6)*n + S(1)) + e*sqrt(-a)*(S(3)*n**S(2) - S(4)*n + S(1)))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), sqrt(c)*x**n/sqrt(-a))/(S(16)*a**S(3)*sqrt(c)*n**S(2)), expand=True, _diff=True, _numerical=True)
# Apart assert rubi_test(rubi_integrate(S(1)/((a + c*x**(S(2)*n))**S(3)*(d + e*x**n)), x), x, e**S(6)*x*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -e*x**n/d)/(d*(a*e**S(2) + c*d**S(2))**S(3)) + c*e**S(4)*x*(d - e*sqrt(-a)/sqrt(c))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), sqrt(c)*x**n/sqrt(-a))/(S(2)*a*(a*e**S(2) + c*d**S(2))**S(3)) + c*e**S(4)*x*(d + e*sqrt(-a)/sqrt(c))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -sqrt(c)*x**n/sqrt(-a))/(S(2)*a*(a*e**S(2) + c*d**S(2))**S(3)) + c*e**S(2)*x*(d - e*x**n)/(S(2)*a*n*(a + c*x**(S(2)*n))*(a*e**S(2) + c*d**S(2))**S(2)) + c*x*(d - e*x**n)/(S(4)*a*n*(a + c*x**(S(2)*n))**S(2)*(a*e**S(2) + c*d**S(2))) - sqrt(c)*e**S(2)*x*(sqrt(c)*(-S(2)*d*n + d) + e*sqrt(-a)*(-n + S(1)))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -sqrt(c)*x**n/sqrt(-a))/(S(4)*a**S(2)*n*(a*e**S(2) + c*d**S(2))**S(2)) - sqrt(c)*e**S(2)*x*(sqrt(c)*d*(-S(2)*n + S(1)) - e*sqrt(-a)*(-n + S(1)))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), sqrt(c)*x**n/sqrt(-a))/(S(4)*a**S(2)*n*(a*e**S(2) + c*d**S(2))**S(2)) - c*x*(d*(-S(4)*n + S(1)) - e*x**n*(-S(3)*n + S(1)))/(S(8)*a**S(2)*n**S(2)*(a + c*x**(S(2)*n))*(a*e**S(2) + c*d**S(2))) - sqrt(c)*x*(-sqrt(c)*d*(S(8)*n**S(2) - S(6)*n + S(1)) + e*sqrt(-a)*(S(3)*n**S(2) - S(4)*n + S(1)))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), sqrt(c)*x**n/sqrt(-a))/(S(16)*a**S(3)*n**S(2)*(a*e**S(2) + c*d**S(2))) + sqrt(c)*x*(sqrt(c)*d*(S(8)*n**S(2) - S(6)*n + S(1)) + e*sqrt(-a)*(S(3)*n**S(2) - S(4)*n + S(1)))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -sqrt(c)*x**n/sqrt(-a))/(S(16)*a**S(3)*n**S(2)*(a*e**S(2) + c*d**S(2))), expand=True, _diff=True, _numerical=True)
# Apart assert rubi_test(rubi_integrate(S(1)/((a + c*x**(S(2)*n))**S(3)*(d + e*x**n)**S(2)), x), x, S(6)*c*e**S(6)*x*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -e*x**n/d)/(a*e**S(2) + c*d**S(2))**S(4) + e**S(6)*x*hyper((S(2), S(1)/n), (S(1) + S(1)/n,), -e*x**n/d)/(d**S(2)*(a*e**S(2) + c*d**S(2))**S(3)) + c*e**S(4)*x*(-a*e**S(2) - S(6)*sqrt(c)*d*e*sqrt(-a) + S(5)*c*d**S(2))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), sqrt(c)*x**n/sqrt(-a))/(S(2)*a*(a*e**S(2) + c*d**S(2))**S(4)) + c*e**S(4)*x*(-a*e**S(2) + S(6)*sqrt(c)*d*e*sqrt(-a) + S(5)*c*d**S(2))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -sqrt(c)*x**n/sqrt(-a))/(S(2)*a*(a*e**S(2) + c*d**S(2))**S(4)) + c*e**S(2)*x*(-a*e**S(2) + S(3)*c*d**S(2) - S(4)*c*d*e*x**n)/(S(2)*a*n*(a + c*x**(S(2)*n))*(a*e**S(2) + c*d**S(2))**S(3)) + c*x*(-a*e**S(2) + c*d**S(2) - S(2)*c*d*e*x**n)/(S(4)*a*n*(a + c*x**(S(2)*n))**S(2)*(a*e**S(2) + c*d**S(2))**S(2)) - c*e**S(2)*x*(-a*e**S(2)*(-S(2)*n + S(1)) - S(4)*sqrt(c)*d*e*sqrt(-a)*(-n + S(1)) + S(3)*c*d**S(2)*(-S(2)*n + S(1)))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), sqrt(c)*x**n/sqrt(-a))/(S(4)*a**S(2)*n*(a*e**S(2) + c*d**S(2))**S(3)) - c*e**S(2)*x*(-a*e**S(2)*(-S(2)*n + S(1)) + S(4)*sqrt(c)*d*e*sqrt(-a)*(-n + S(1)) + S(3)*c*d**S(2)*(-S(2)*n + S(1)))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -sqrt(c)*x**n/sqrt(-a))/(S(4)*a**S(2)*n*(a*e**S(2) + c*d**S(2))**S(3)) - c*x*(-S(2)*c*d*e*x**n*(-S(3)*n + S(1)) + (-S(4)*n + S(1))*(-a*e**S(2) + c*d**S(2)))/(S(8)*a**S(2)*n**S(2)*(a + c*x**(S(2)*n))*(a*e**S(2) + c*d**S(2))**S(2)) + c*x*(-a*e**S(2)*(S(8)*n**S(2) - S(6)*n + S(1)) + S(2)*sqrt(c)*d*e*sqrt(-a)*(S(3)*n**S(2) - S(4)*n + S(1)) + c*d**S(2)*(S(8)*n**S(2) - S(6)*n + S(1)))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -sqrt(c)*x**n/sqrt(-a))/(S(16)*a**S(3)*n**S(2)*(a*e**S(2) + c*d**S(2))**S(2)) - c*x*(a*e**S(2)*(S(8)*n**S(2) - S(6)*n + S(1)) + S(2)*sqrt(c)*d*e*sqrt(-a)*(S(3)*n**S(2) - S(4)*n + S(1)) - c*d**S(2)*(S(8)*n**S(2) - S(6)*n + S(1)))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), sqrt(c)*x**n/sqrt(-a))/(S(16)*a**S(3)*n**S(2)*(a*e**S(2) + c*d**S(2))**S(2)), expand=True, _diff=True, _numerical=True)
# Apart assert rubi_test(rubi_integrate(S(1)/((a + c*x**(S(2)*n))**S(3)*(d + e*x**n)**S(3)), x), x, S(3)*c**(S(3)/2)*e**S(4)*x*(-a*e**S(3) - sqrt(c)*d*(-S(3)*a*e**S(2) + S(5)*c*d**S(2))/sqrt(-a) + S(7)*c*d**S(2)*e)*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), sqrt(c)*x**n/sqrt(-a))/(S(2)*sqrt(-a)*(a*e**S(2) + c*d**S(2))**S(5)) - c**(S(3)/2)*e**S(2)*x*(S(3)*sqrt(c)*(-S(2)*n + S(1))*(-a*d*e**S(2) + c*d**S(3))/sqrt(-a) - (-n + S(1))*(-a*e**S(3) + S(5)*c*d**S(2)*e))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), sqrt(c)*x**n/sqrt(-a))/(S(2)*n*(-a)**(S(3)/2)*(a*e**S(2) + c*d**S(2))**S(4)) - c**(S(3)/2)*e**S(2)*x*(S(3)*sqrt(c)*(-S(2)*n + S(1))*(-a*d*e**S(2) + c*d**S(3))/sqrt(-a) + (-n + S(1))*(-a*e**S(3) + S(5)*c*d**S(2)*e))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -sqrt(c)*x**n/sqrt(-a))/(S(2)*n*(-a)**(S(3)/2)*(a*e**S(2) + c*d**S(2))**S(4)) - c**(S(3)/2)*x*(sqrt(c)*(-S(4)*n + S(1))*(-S(2)*n + S(1))*(-S(3)*a*d*e**S(2) + c*d**S(3))/sqrt(-a) - (-S(3)*n + S(1))*(-n + S(1))*(-a*e**S(3) + S(3)*c*d**S(2)*e))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), sqrt(c)*x**n/sqrt(-a))/(S(16)*n**S(2)*(-a)**(S(5)/2)*(a*e**S(2) + c*d**S(2))**S(3)) - c**(S(3)/2)*x*(sqrt(c)*(-S(4)*n + S(1))*(-S(2)*n + S(1))*(-S(3)*a*d*e**S(2) + c*d**S(3))/sqrt(-a) + (-S(3)*n + S(1))*(-n + S(1))*(-a*e**S(3) + S(3)*c*d**S(2)*e))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -sqrt(c)*x**n/sqrt(-a))/(S(16)*n**S(2)*(-a)**(S(5)/2)*(a*e**S(2) + c*d**S(2))**S(3)) + S(3)*c*e**S(6)*x*(-a*e**S(2) + S(7)*c*d**S(2))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -e*x**n/d)/(d*(a*e**S(2) + c*d**S(2))**S(5)) + S(6)*c*e**S(6)*x*hyper((S(2), S(1)/n), (S(1) + S(1)/n,), -e*x**n/d)/(d*(a*e**S(2) + c*d**S(2))**S(4)) + e**S(6)*x*hyper((S(3), S(1)/n), (S(1) + S(1)/n,), -e*x**n/d)/(d**S(3)*(a*e**S(2) + c*d**S(2))**S(3)) + S(3)*c**(S(3)/2)*e**S(4)*x*(-S(3)*a*sqrt(c)*d*e**S(2) + S(5)*c**(S(3)/2)*d**S(3) + S(7)*c*d**S(2)*e*sqrt(-a) + e**S(3)*(-a)**(S(3)/2))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -sqrt(c)*x**n/sqrt(-a))/(S(2)*a*(a*e**S(2) + c*d**S(2))**S(5)) + c**S(2)*e**S(2)*x*(S(3)*d*(-a*e**S(2) + c*d**S(2)) - e*x**n*(-a*e**S(2) + S(5)*c*d**S(2)))/(a*n*(a + c*x**(S(2)*n))*(a*e**S(2) + c*d**S(2))**S(4)) + c**S(2)*x*(d*(-S(3)*a*e**S(2) + c*d**S(2)) - e*x**n*(-a*e**S(2) + S(3)*c*d**S(2)))/(S(4)*a*n*(a + c*x**(S(2)*n))**S(2)*(a*e**S(2) + c*d**S(2))**S(3)) - c**S(2)*x*(d*(-S(4)*n + S(1))*(-S(3)*a*e**S(2) + c*d**S(2)) - e*x**n*(-S(3)*n + S(1))*(-a*e**S(2) + S(3)*c*d**S(2)))/(S(8)*a**S(2)*n**S(2)*(a + c*x**(S(2)*n))*(a*e**S(2) + c*d**S(2))**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + c*x**(S(2)*n))**p*(d + e*x**n)**S(3), x), x, d**S(3)*x*(S(1) + c*x**(S(2)*n)/a)**(-p)*(a + c*x**(S(2)*n))**p*hyper((S(1)/(S(2)*n), -p), (S(1) + S(1)/(S(2)*n),), -c*x**(S(2)*n)/a) + S(3)*d**S(2)*e*x**(n + S(1))*(S(1) + c*x**(S(2)*n)/a)**(-p)*(a + c*x**(S(2)*n))**p*hyper(((n + S(1))/(S(2)*n), -p), (S(3)/2 + S(1)/(S(2)*n),), -c*x**(S(2)*n)/a)/(n + S(1)) + S(3)*d*e**S(2)*x**(S(2)*n + S(1))*(S(1) + c*x**(S(2)*n)/a)**(-p)*(a + c*x**(S(2)*n))**p*hyper((S(1) + S(1)/(S(2)*n), -p), (S(2) + S(1)/(S(2)*n),), -c*x**(S(2)*n)/a)/(S(2)*n + S(1)) + e**S(3)*x**(S(3)*n + S(1))*(S(1) + c*x**(S(2)*n)/a)**(-p)*(a + c*x**(S(2)*n))**p*hyper((S(3)/2 + S(1)/(S(2)*n), -p), (S(5)/2 + S(1)/(S(2)*n),), -c*x**(S(2)*n)/a)/(S(3)*n + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + c*x**(S(2)*n))**p*(d + e*x**n)**S(2), x), x, d**S(2)*x*(S(1) + c*x**(S(2)*n)/a)**(-p)*(a + c*x**(S(2)*n))**p*hyper((S(1)/(S(2)*n), -p), (S(1) + S(1)/(S(2)*n),), -c*x**(S(2)*n)/a) + S(2)*d*e*x**(n + S(1))*(S(1) + c*x**(S(2)*n)/a)**(-p)*(a + c*x**(S(2)*n))**p*hyper(((n + S(1))/(S(2)*n), -p), (S(3)/2 + S(1)/(S(2)*n),), -c*x**(S(2)*n)/a)/(n + S(1)) + e**S(2)*x**(S(2)*n + S(1))*(S(1) + c*x**(S(2)*n)/a)**(-p)*(a + c*x**(S(2)*n))**p*hyper((S(1) + S(1)/(S(2)*n), -p), (S(2) + S(1)/(S(2)*n),), -c*x**(S(2)*n)/a)/(S(2)*n + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + c*x**(S(2)*n))**p*(d + e*x**n), x), x, d*x*(S(1) + c*x**(S(2)*n)/a)**(-p)*(a + c*x**(S(2)*n))**p*hyper((S(1)/(S(2)*n), -p), (S(1) + S(1)/(S(2)*n),), -c*x**(S(2)*n)/a) + e*x**(n + S(1))*(S(1) + c*x**(S(2)*n)/a)**(-p)*(a + c*x**(S(2)*n))**p*hyper(((n + S(1))/(S(2)*n), -p), (S(3)/2 + S(1)/(S(2)*n),), -c*x**(S(2)*n)/a)/(n + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**n)*(a + b*x**n + c*x**(S(2)*n)), x), x, a*d*x + c*e*x**(S(3)*n + S(1))/(S(3)*n + S(1)) + x**(n + S(1))*(a*e + b*d)/(n + S(1)) + x**(S(2)*n + S(1))*(b*e + c*d)/(S(2)*n + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**n)*(a + b*x**n + c*x**(S(2)*n))**S(2), x), x, a**S(2)*d*x + a*x**(n + S(1))*(a*e + S(2)*b*d)/(n + S(1)) + c**S(2)*e*x**(S(5)*n + S(1))/(S(5)*n + S(1)) + c*x**(S(4)*n + S(1))*(S(2)*b*e + c*d)/(S(4)*n + S(1)) + x**(S(2)*n + S(1))*(S(2)*a*b*e + S(2)*a*c*d + b**S(2)*d)/(S(2)*n + S(1)) + x**(S(3)*n + S(1))*(S(2)*a*c*e + b**S(2)*e + S(2)*b*c*d)/(S(3)*n + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**n)*(a + b*x**n + c*x**(S(2)*n))**S(3), x), x, a**S(3)*d*x + a**S(2)*x**(n + S(1))*(a*e + S(3)*b*d)/(n + S(1)) + S(3)*a*x**(S(2)*n + S(1))*(a*b*e + a*c*d + b**S(2)*d)/(S(2)*n + S(1)) + c**S(3)*e*x**(S(7)*n + S(1))/(S(7)*n + S(1)) + c**S(2)*x**(S(6)*n + S(1))*(S(3)*b*e + c*d)/(S(6)*n + S(1)) + S(3)*c*x**(S(5)*n + S(1))*(a*c*e + b**S(2)*e + b*c*d)/(S(5)*n + S(1)) + x**(S(3)*n + S(1))*(S(3)*a**S(2)*c*e + S(3)*a*b**S(2)*e + S(6)*a*b*c*d + b**S(3)*d)/(S(3)*n + S(1)) + x**(S(4)*n + S(1))*(S(6)*a*b*c*e + S(3)*a*c**S(2)*d + b**S(3)*e + S(3)*b**S(2)*c*d)/(S(4)*n + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**n)**S(3)/(a + b*x**n + c*x**(S(2)*n)), x), x, e**S(3)*x**(n + S(1))/(c*(n + S(1))) + e**S(2)*x*(-b*e + S(3)*c*d)/c**S(2) + x*(-a*c*e**S(3) + b**S(2)*e**S(3) - S(3)*b*c*d*e**S(2) + S(3)*c**S(2)*d**S(2)*e - (-b*e + S(2)*c*d)*(b**S(2)*e**S(2) + c**S(2)*d**S(2) - c*e*(S(3)*a*e + b*d))/sqrt(-S(4)*a*c + b**S(2)))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(c**S(2)*(b + sqrt(-S(4)*a*c + b**S(2)))) + x*(-a*c*e**S(3) + b**S(2)*e**S(3) - S(3)*b*c*d*e**S(2) + S(3)*c**S(2)*d**S(2)*e + (-b*e + S(2)*c*d)*(b**S(2)*e**S(2) + c**S(2)*d**S(2) - c*e*(S(3)*a*e + b*d))/sqrt(-S(4)*a*c + b**S(2)))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))))/(c**S(2)*(b - sqrt(-S(4)*a*c + b**S(2)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**n)**S(2)/(a + b*x**n + c*x**(S(2)*n)), x), x, e**S(2)*x/c + x*(-b*e**S(2) + S(2)*c*d*e - (b**S(2)*e**S(2) + S(2)*c**S(2)*d**S(2) - S(2)*c*e*(a*e + b*d))/sqrt(-S(4)*a*c + b**S(2)))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(c*(b + sqrt(-S(4)*a*c + b**S(2)))) + x*(-b*e**S(2) + S(2)*c*d*e + (b**S(2)*e**S(2) + S(2)*c**S(2)*d**S(2) - S(2)*c*e*(a*e + b*d))/sqrt(-S(4)*a*c + b**S(2)))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))))/(c*(b - sqrt(-S(4)*a*c + b**S(2)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**n)/(a + b*x**n + c*x**(S(2)*n)), x), x, x*(e - (-b*e + S(2)*c*d)/sqrt(-S(4)*a*c + b**S(2)))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(b + sqrt(-S(4)*a*c + b**S(2))) + x*(e + (-b*e + S(2)*c*d)/sqrt(-S(4)*a*c + b**S(2)))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))))/(b - sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
# Apart assert rubi_test(rubi_integrate(S(1)/((d + e*x**n)*(a + b*x**n + c*x**(S(2)*n))), x), x, -c*x*(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))))/((-S(4)*a*c + b**S(2) - b*sqrt(-S(4)*a*c + b**S(2)))*(a*e**S(2) - b*d*e + c*d**S(2))) - c*x*(e + (-b*e + S(2)*c*d)/sqrt(-S(4)*a*c + b**S(2)))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/((b + sqrt(-S(4)*a*c + b**S(2)))*(a*e**S(2) - b*d*e + c*d**S(2))) + e**S(2)*x*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -e*x**n/d)/(d*(a*e**S(2) - b*d*e + c*d**S(2))), expand=True, _diff=True, _numerical=True)
# Apart assert rubi_test(rubi_integrate(S(1)/((d + e*x**n)**S(2)*(a + b*x**n + c*x**(S(2)*n))), x), x, -c*x*(b*e**S(2)*(b - sqrt(-S(4)*a*c + b**S(2))) + S(2)*c**S(2)*d**S(2) - S(2)*c*e*(a*e + b*d - d*sqrt(-S(4)*a*c + b**S(2))))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/((-S(4)*a*c + b**S(2) + b*sqrt(-S(4)*a*c + b**S(2)))*(a*e**S(2) - b*d*e + c*d**S(2))**S(2)) - c*x*(b*e**S(2)*(b + sqrt(-S(4)*a*c + b**S(2))) + S(2)*c**S(2)*d**S(2) - S(2)*c*e*(a*e + b*d + d*sqrt(-S(4)*a*c + b**S(2))))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))))/((-S(4)*a*c + b**S(2) - b*sqrt(-S(4)*a*c + b**S(2)))*(a*e**S(2) - b*d*e + c*d**S(2))**S(2)) + e**S(2)*x*(-b*e + S(2)*c*d)*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -e*x**n/d)/(d*(a*e**S(2) - b*d*e + c*d**S(2))**S(2)) + e**S(2)*x*hyper((S(2), S(1)/n), (S(1) + S(1)/n,), -e*x**n/d)/(d**S(2)*(a*e**S(2) - b*d*e + c*d**S(2))), expand=True, _diff=True, _numerical=True)
# Apart assert rubi_test(rubi_integrate(S(1)/((d + e*x**n)**S(3)*(a + b*x**n + c*x**(S(2)*n))), x), x, -c*x*(-b**S(2)*e**S(3)*(b - sqrt(-S(4)*a*c + b**S(2))) + S(2)*c**S(3)*d**S(3) - S(3)*c**S(2)*d*e*(S(2)*a*e + b*d - d*sqrt(-S(4)*a*c + b**S(2))) + c*e**S(2)*(S(3)*a*b*e - a*e*sqrt(-S(4)*a*c + b**S(2)) + S(3)*b**S(2)*d - S(3)*b*d*sqrt(-S(4)*a*c + b**S(2))))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/((-S(4)*a*c + b**S(2) + b*sqrt(-S(4)*a*c + b**S(2)))*(a*e**S(2) - b*d*e + c*d**S(2))**S(3)) - c*x*(-b**S(2)*e**S(3)*(b + sqrt(-S(4)*a*c + b**S(2))) + S(2)*c**S(3)*d**S(3) - S(3)*c**S(2)*d*e*(S(2)*a*e + b*d + d*sqrt(-S(4)*a*c + b**S(2))) + c*e**S(2)*(a*e*sqrt(-S(4)*a*c + b**S(2)) + S(3)*b**S(2)*d + S(3)*b*(a*e + d*sqrt(-S(4)*a*c + b**S(2)))))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))))/((-S(4)*a*c + b**S(2) - b*sqrt(-S(4)*a*c + b**S(2)))*(a*e**S(2) - b*d*e + c*d**S(2))**S(3)) + e**S(2)*x*(b**S(2)*e**S(2) + S(3)*c**S(2)*d**S(2) - c*e*(a*e + S(3)*b*d))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -e*x**n/d)/(d*(a*e**S(2) - b*d*e + c*d**S(2))**S(3)) + e**S(2)*x*(-b*e + S(2)*c*d)*hyper((S(2), S(1)/n), (S(1) + S(1)/n,), -e*x**n/d)/(d**S(2)*(a*e**S(2) - b*d*e + c*d**S(2))**S(2)) + e**S(2)*x*hyper((S(3), S(1)/n), (S(1) + S(1)/n,), -e*x**n/d)/(d**S(3)*(a*e**S(2) - b*d*e + c*d**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**n)**S(3)/(a + b*x**n + c*x**(S(2)*n))**S(2), x), x, e**S(2)*x*(e - (-S(3)*b*e + S(6)*c*d)/sqrt(-S(4)*a*c + b**S(2)))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(c*(b + sqrt(-S(4)*a*c + b**S(2)))) + e**S(2)*x*(e + (-S(3)*b*e + S(6)*c*d)/sqrt(-S(4)*a*c + b**S(2)))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))))/(c*(b - sqrt(-S(4)*a*c + b**S(2)))) + x*(-a*b*e*(a*e**S(2) + S(3)*c*d**S(2)) - S(2)*a*c*d*(-S(3)*a*e**S(2) + c*d**S(2)) + b**S(2)*c*d**S(3) - x**n*(a*b**S(2)*e**S(3) + S(2)*a*c*e*(-a*e**S(2) + S(3)*c*d**S(2)) - b*c*d*(S(3)*a*e**S(2) + c*d**S(2))))/(a*c*n*(-S(4)*a*c + b**S(2))*(a + b*x**n + c*x**(S(2)*n))) + x*((-n + S(1))*(a*b**S(2)*e**S(3) + S(2)*a*c*e*(-a*e**S(2) + S(3)*c*d**S(2)) - b*c*d*(S(3)*a*e**S(2) + c*d**S(2))) - (-a*b**S(3)*e**S(3)*(-S(3)*n + S(1)) + S(2)*a*b*c*e*(a*e**S(2)*(-S(5)*n + S(2)) + S(3)*c*d**S(2)*n) + S(4)*a*c**S(2)*d*(-S(2)*n + S(1))*(-S(3)*a*e**S(2) + c*d**S(2)) + b**S(2)*c*d*(S(3)*a*e**S(2)*(-S(3)*n + S(1)) - c*d**S(2)*(-n + S(1))))/sqrt(-S(4)*a*c + b**S(2)))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(a*c*n*(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))) + x*((-n + S(1))*(a*b**S(2)*e**S(3) + S(2)*a*c*e*(-a*e**S(2) + S(3)*c*d**S(2)) - b*c*d*(S(3)*a*e**S(2) + c*d**S(2))) + (-a*b**S(3)*e**S(3)*(-S(3)*n + S(1)) + S(2)*a*b*c*e*(a*e**S(2)*(-S(5)*n + S(2)) + S(3)*c*d**S(2)*n) + S(4)*a*c**S(2)*d*(-S(2)*n + S(1))*(-S(3)*a*e**S(2) + c*d**S(2)) + b**S(2)*c*d*(S(3)*a*e**S(2)*(-S(3)*n + S(1)) - c*d**S(2)*(-n + S(1))))/sqrt(-S(4)*a*c + b**S(2)))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))))/(a*c*n*(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**n)**S(2)/(a + b*x**n + c*x**(S(2)*n))**S(2), x), x, -S(2)*e**S(2)*x*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(-S(4)*a*c + b**S(2) + b*sqrt(-S(4)*a*c + b**S(2))) - S(2)*e**S(2)*x*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))))/(-S(4)*a*c + b**S(2) - b*sqrt(-S(4)*a*c + b**S(2))) + x*(-S(2)*a*b*d*e - S(2)*a*(-a*e**S(2) + c*d**S(2)) + b**S(2)*d**S(2) + x**n*(a*b*e**S(2) - S(4)*a*c*d*e + b*c*d**S(2)))/(a*n*(-S(4)*a*c + b**S(2))*(a + b*x**n + c*x**(S(2)*n))) - x*((-n + S(1))*(a*b*e**S(2) - S(4)*a*c*d*e + b*c*d**S(2)) + (S(4)*a*b*c*d*e*n + S(4)*a*c*(-S(2)*n + S(1))*(-a*e**S(2) + c*d**S(2)) + b**S(2)*(a*e**S(2)*(-S(3)*n + S(1)) - c*d**S(2)*(-n + S(1))))/sqrt(-S(4)*a*c + b**S(2)))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(a*n*(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))) - x*((-n + S(1))*(a*b*e**S(2) - S(4)*a*c*d*e + b*c*d**S(2)) - (S(4)*a*b*c*d*e*n + S(4)*a*c*(-S(2)*n + S(1))*(-a*e**S(2) + c*d**S(2)) + b**S(2)*(a*e**S(2)*(-S(3)*n + S(1)) - c*d**S(2)*(-n + S(1))))/sqrt(-S(4)*a*c + b**S(2)))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))))/(a*n*(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**n)/(a + b*x**n + c*x**(S(2)*n))**S(2), x), x, -c*x*(S(2)*a*(c*d*(-S(4)*n + S(2)) - e*(-n + S(1))*sqrt(-S(4)*a*c + b**S(2))) - b**S(2)*d*(-n + S(1)) + b*(S(2)*a*e*n + d*(-n + S(1))*sqrt(-S(4)*a*c + b**S(2))))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(a*n*(-S(4)*a*c + b**S(2))*(-S(4)*a*c + b**S(2) + b*sqrt(-S(4)*a*c + b**S(2)))) - c*x*(S(2)*a*(S(2)*c*d*(-S(2)*n + S(1)) + e*(-n + S(1))*sqrt(-S(4)*a*c + b**S(2))) - b**S(2)*(-d*n + d) - b*(-S(2)*a*e*n + d*(-n + S(1))*sqrt(-S(4)*a*c + b**S(2))))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))))/(a*n*(-S(4)*a*c + b**S(2))*(-S(4)*a*c + b**S(2) - b*sqrt(-S(4)*a*c + b**S(2)))) + x*(-a*b*e - S(2)*a*c*d + b**S(2)*d + c*x**n*(-S(2)*a*e + b*d))/(a*n*(-S(4)*a*c + b**S(2))*(a + b*x**n + c*x**(S(2)*n))), expand=True, _diff=True, _numerical=True)
#Apart assert rubi_test(rubi_integrate(S(1)/((d + e*x**n)*(a + b*x**n + c*x**(S(2)*n))**S(2)), x), x, -c*e**S(2)*x*(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/((-S(4)*a*c + b**S(2) + b*sqrt(-S(4)*a*c + b**S(2)))*(a*e**S(2) - b*d*e + c*d**S(2))**S(2)) - c*e**S(2)*x*(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))))/((-S(4)*a*c + b**S(2) - b*sqrt(-S(4)*a*c + b**S(2)))*(a*e**S(2) - b*d*e + c*d**S(2))**S(2)) + e**S(4)*x*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -e*x**n/d)/(d*(a*e**S(2) - b*d*e + c*d**S(2))**S(2)) + c*x*(-S(2)*a*c*(S(2)*c*d*(-S(2)*n + S(1)) + e*(-n + S(1))*sqrt(-S(4)*a*c + b**S(2))) - b**S(3)*e*(-n + S(1)) + b**S(2)*(-n + S(1))*(c*d + e*sqrt(-S(4)*a*c + b**S(2))) + b*c*(S(2)*a*e*(-S(3)*n + S(2)) - d*(-n + S(1))*sqrt(-S(4)*a*c + b**S(2))))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(a*n*(-S(4)*a*c + b**S(2))*(-S(4)*a*c + b**S(2) + b*sqrt(-S(4)*a*c + b**S(2)))*(a*e**S(2) - b*d*e + c*d**S(2))) - c*x*((-n + S(1))*(S(2)*a*c*e - b**S(2)*e + b*c*d) + (S(2)*a*b*c*e*(-S(3)*n + S(2)) - S(4)*a*c**S(2)*d*(-S(2)*n + S(1)) - b**S(3)*e*(-n + S(1)) + b**S(2)*c*d*(-n + S(1)))/sqrt(-S(4)*a*c + b**S(2)))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))))/(a*n*(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))*(a*e**S(2) - b*d*e + c*d**S(2))) + x*(S(3)*a*b*c*e - S(2)*a*c**S(2)*d - b**S(3)*e + b**S(2)*c*d + c*x**n*(S(2)*a*c*e - b**S(2)*e + b*c*d))/(a*n*(-S(4)*a*c + b**S(2))*(a + b*x**n + c*x**(S(2)*n))*(a*e**S(2) - b*d*e + c*d**S(2))), expand=True, _diff=True, _numerical=True)
#Apart assert rubi_test(rubi_integrate(S(1)/((d + e*x**n)**S(2)*(a + b*x**n + c*x**(S(2)*n))**S(2)), x), x, -S(2)*c*e**S(2)*x*(b*e**S(2)*(b - sqrt(-S(4)*a*c + b**S(2))) + S(3)*c**S(2)*d**S(2) - c*e*(a*e + S(3)*b*d - S(2)*d*sqrt(-S(4)*a*c + b**S(2))))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/((-S(4)*a*c + b**S(2) + b*sqrt(-S(4)*a*c + b**S(2)))*(a*e**S(2) - b*d*e + c*d**S(2))**S(3)) - S(2)*c*e**S(2)*x*(b*e**S(2)*(b + sqrt(-S(4)*a*c + b**S(2))) + S(3)*c**S(2)*d**S(2) - c*e*(a*e + S(3)*b*d + S(2)*d*sqrt(-S(4)*a*c + b**S(2))))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))))/((-S(4)*a*c + b**S(2) - b*sqrt(-S(4)*a*c + b**S(2)))*(a*e**S(2) - b*d*e + c*d**S(2))**S(3)) + S(2)*e**S(4)*x*(-b*e + S(2)*c*d)*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -e*x**n/d)/(d*(a*e**S(2) - b*d*e + c*d**S(2))**S(3)) + e**S(4)*x*hyper((S(2), S(1)/n), (S(1) + S(1)/n,), -e*x**n/d)/(d**S(2)*(a*e**S(2) - b*d*e + c*d**S(2))**S(2)) + c*x*(S(4)*a*c**S(2)*(-c*d**S(2)*(-S(2)*n + S(1)) + e*(a*e*(-S(2)*n + S(1)) - d*(-n + S(1))*sqrt(-S(4)*a*c + b**S(2)))) + b**S(4)*e**S(2)*(-n + S(1)) - b**S(3)*e*(-n + S(1))*(S(2)*c*d + e*sqrt(-S(4)*a*c + b**S(2))) - b**S(2)*c*(-c*d**S(2)*(-n + S(1)) + e*(a*e*(-S(7)*n + S(5)) - S(2)*d*(-n + S(1))*sqrt(-S(4)*a*c + b**S(2)))) + b*c*(S(3)*a*e**S(2)*(-n + S(1))*sqrt(-S(4)*a*c + b**S(2)) + c*d*(S(4)*a*e*(-S(3)*n + S(2)) - d*(-n + S(1))*sqrt(-S(4)*a*c + b**S(2)))))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(a*n*(-S(4)*a*c + b**S(2))*(-S(4)*a*c + b**S(2) + b*sqrt(-S(4)*a*c + b**S(2)))*(a*e**S(2) - b*d*e + c*d**S(2))**S(2)) + c*x*(S(4)*a*c**S(2)*(-c*d**S(2)*(-S(2)*n + S(1)) + e*(a*e*(-S(2)*n + S(1)) + d*(-n + S(1))*sqrt(-S(4)*a*c + b**S(2)))) + b**S(4)*e**S(2)*(-n + S(1)) - b**S(3)*e*(-n + S(1))*(S(2)*c*d - e*sqrt(-S(4)*a*c + b**S(2))) - b**S(2)*c*(-c*d**S(2)*(-n + S(1)) + e*(a*e*(-S(7)*n + S(5)) + S(2)*d*(-n + S(1))*sqrt(-S(4)*a*c + b**S(2)))) + b*c*(-S(3)*a*e**S(2)*(-n + S(1))*sqrt(-S(4)*a*c + b**S(2)) + c*d*(S(4)*a*e*(-S(3)*n + S(2)) + d*(-n + S(1))*sqrt(-S(4)*a*c + b**S(2)))))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))))/(a*n*(-S(4)*a*c + b**S(2))*(-S(4)*a*c + b**S(2) - b*sqrt(-S(4)*a*c + b**S(2)))*(a*e**S(2) - b*d*e + c*d**S(2))**S(2)) - x*(-S(6)*a*b*c**S(2)*d*e + S(2)*a*c**S(2)*(-a*e**S(2) + c*d**S(2)) - b**S(4)*e**S(2) + S(2)*b**S(3)*c*d*e - b**S(2)*c*(-S(4)*a*e**S(2) + c*d**S(2)) + c*x**n*(-S(4)*a*c**S(2)*d*e - b**S(3)*e**S(2) + S(2)*b**S(2)*c*d*e - b*c*(-S(3)*a*e**S(2) + c*d**S(2))))/(a*n*(-S(4)*a*c + b**S(2))*(a + b*x**n + c*x**(S(2)*n))*(a*e**S(2) - b*d*e + c*d**S(2))**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**n)**S(3)/(a + b*x**n + c*x**(S(2)*n))**S(3), x), x, e**S(2)*x*(-S(2)*a*c*(S(6)*c*d*(-S(2)*n + S(1)) - e*(-n + S(1))*sqrt(-S(4)*a*c + b**S(2))) - b**S(3)*e*(-n + S(1)) + b**S(2)*(-n + S(1))*(S(3)*c*d + e*sqrt(-S(4)*a*c + b**S(2))) + b*c*(S(2)*a*e*(-S(5)*n + S(2)) - S(3)*d*(-n + S(1))*sqrt(-S(4)*a*c + b**S(2))))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(a*c*n*(-S(4)*a*c + b**S(2))*(-S(4)*a*c + b**S(2) + b*sqrt(-S(4)*a*c + b**S(2)))) + e**S(2)*x*(-S(2)*a*c*(S(6)*c*d*(-S(2)*n + S(1)) + e*(-n + S(1))*sqrt(-S(4)*a*c + b**S(2))) - b**S(3)*e*(-n + S(1)) + b**S(2)*(-n + S(1))*(S(3)*c*d - e*sqrt(-S(4)*a*c + b**S(2))) + b*c*(S(2)*a*e*(-S(5)*n + S(2)) + S(3)*d*(-n + S(1))*sqrt(-S(4)*a*c + b**S(2))))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))))/(a*c*n*(-S(4)*a*c + b**S(2))*(-S(4)*a*c + b**S(2) - b*sqrt(-S(4)*a*c + b**S(2)))) + x*(-a*b*e*(a*e**S(2) + S(3)*c*d**S(2)) - S(2)*a*c*d*(-S(3)*a*e**S(2) + c*d**S(2)) + b**S(2)*c*d**S(3) - x**n*(a*b**S(2)*e**S(3) + S(2)*a*c*e*(-a*e**S(2) + S(3)*c*d**S(2)) - b*c*d*(S(3)*a*e**S(2) + c*d**S(2))))/(S(2)*a*c*n*(-S(4)*a*c + b**S(2))*(a + b*x**n + c*x**(S(2)*n))**S(2)) + e**S(2)*x*(a*b*c*e - S(6)*a*c**S(2)*d - b**S(3)*e + S(3)*b**S(2)*c*d + c*x**n*(-S(2)*a*c*e - b**S(2)*e + S(3)*b*c*d))/(a*c**S(2)*n*(-S(4)*a*c + b**S(2))*(a + b*x**n + c*x**(S(2)*n))) + x*((-n + S(1))*(S(4)*a**S(2)*c**S(2)*e*(-S(3)*n + S(1))*(-a*e**S(2) + S(3)*c*d**S(2)) - S(2)*a*b**S(4)*e**S(3)*n - a*b**S(2)*c*e*(-a*e**S(2)*(S(2)*n + S(1)) + S(3)*c*d**S(2)) - S(2)*a*b*c**S(2)*d*(S(3)*a*e**S(2)*n + c*d**S(2)*(-S(7)*n + S(2))) + b**S(3)*c*d*(S(6)*a*e**S(2)*n + c*d**S(2)*(-S(2)*n + S(1)))) + (-S(4)*a**S(2)*b*c**S(2)*e*(a*e**S(2)*(S(19)*n**S(2) - S(11)*n + S(1)) + S(3)*c*d**S(2)*(-S(3)*n**S(2) - n + S(1))) - S(8)*a**S(2)*c**S(3)*d*(-S(3)*a*e**S(2) + c*d**S(2))*(S(8)*n**S(2) - S(6)*n + S(1)) + S(2)*a*b**S(5)*e**S(3)*n*(-n + S(1)) + a*b**S(3)*c*e*(a*e**S(2)*(S(30)*n**S(2) - S(19)*n + S(1)) + S(3)*c*d**S(2)*(-n + S(1))) + S(6)*a*b**S(2)*c**S(2)*d*(-a*e**S(2)*(S(15)*n**S(2) - S(10)*n + S(1)) + c*d**S(2)*(S(3)*n**S(2) - S(4)*n + S(1))) - b**S(4)*c*d*(-n + S(1))*(S(6)*a*e**S(2)*n + c*d**S(2)*(-S(2)*n + S(1))))/sqrt(-S(4)*a*c + b**S(2)))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*a**S(2)*c*n**S(2)*(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**S(2)) + x*((-n + S(1))*(S(4)*a**S(2)*c**S(2)*e*(-S(3)*n + S(1))*(-a*e**S(2) + S(3)*c*d**S(2)) - S(2)*a*b**S(4)*e**S(3)*n - a*b**S(2)*c*e*(-a*e**S(2)*(S(2)*n + S(1)) + S(3)*c*d**S(2)) - S(2)*a*b*c**S(2)*d*(S(3)*a*e**S(2)*n + c*d**S(2)*(-S(7)*n + S(2))) + b**S(3)*c*d*(S(6)*a*e**S(2)*n + c*d**S(2)*(-S(2)*n + S(1)))) - (-S(4)*a**S(2)*b*c**S(2)*e*(a*e**S(2)*(S(19)*n**S(2) - S(11)*n + S(1)) + S(3)*c*d**S(2)*(-S(3)*n**S(2) - n + S(1))) - S(8)*a**S(2)*c**S(3)*d*(-S(3)*a*e**S(2) + c*d**S(2))*(S(8)*n**S(2) - S(6)*n + S(1)) + S(2)*a*b**S(5)*e**S(3)*n*(-n + S(1)) + a*b**S(3)*c*e*(a*e**S(2)*(S(30)*n**S(2) - S(19)*n + S(1)) + S(3)*c*d**S(2)*(-n + S(1))) + S(6)*a*b**S(2)*c**S(2)*d*(-a*e**S(2)*(S(15)*n**S(2) - S(10)*n + S(1)) + c*d**S(2)*(S(3)*n**S(2) - S(4)*n + S(1))) - b**S(4)*c*d*(-n + S(1))*(S(6)*a*e**S(2)*n + c*d**S(2)*(-S(2)*n + S(1))))/sqrt(-S(4)*a*c + b**S(2)))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*a**S(2)*c*n**S(2)*(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**S(2)) - x*(S(2)*a**S(2)*b*c**S(2)*e*(-S(5)*a*e**S(2)*n + S(3)*c*d**S(2)*(-S(3)*n + S(2))) + S(4)*a**S(2)*c**S(3)*d*(-S(4)*n + S(1))*(-S(3)*a*e**S(2) + c*d**S(2)) - S(2)*a*b**S(5)*e**S(3)*n - S(3)*a*b**S(3)*c*e*(-S(3)*a*e**S(2)*n + c*d**S(2)) + a*b**S(2)*c**S(2)*d*(S(3)*a*e**S(2)*(-S(9)*n + S(1)) - S(5)*c*d**S(2)*(-S(3)*n + S(1))) + b**S(4)*c*d*(S(6)*a*e**S(2)*n + c*d**S(2)*(-S(2)*n + S(1))) + c*x**n*(S(4)*a**S(2)*c**S(2)*e*(-S(3)*n + S(1))*(-a*e**S(2) + S(3)*c*d**S(2)) - S(2)*a*b**S(4)*e**S(3)*n - a*b**S(2)*c*e*(-a*e**S(2)*(S(2)*n + S(1)) + S(3)*c*d**S(2)) - S(2)*a*b*c**S(2)*d*(S(3)*a*e**S(2)*n + c*d**S(2)*(-S(7)*n + S(2))) + b**S(3)*c*d*(S(6)*a*e**S(2)*n + c*d**S(2)*(-S(2)*n + S(1)))))/(S(2)*a**S(2)*c**S(2)*n**S(2)*(-S(4)*a*c + b**S(2))**S(2)*(a + b*x**n + c*x**(S(2)*n))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**n)**S(2)/(a + b*x**n + c*x**(S(2)*n))**S(3), x), x, -e**S(2)*x*(S(4)*a*c*(-S(2)*n + S(1)) - b**S(2)*(-n + S(1)) + b*(-n + S(1))*sqrt(-S(4)*a*c + b**S(2)))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(a*n*(-S(4)*a*c + b**S(2))*(-S(4)*a*c + b**S(2) + b*sqrt(-S(4)*a*c + b**S(2)))) - e**S(2)*x*(S(4)*a*c*(-S(2)*n + S(1)) - b**S(2)*(-n + S(1)) - b*(-n + S(1))*sqrt(-S(4)*a*c + b**S(2)))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))))/(a*n*(-S(4)*a*c + b**S(2))*(-S(4)*a*c + b**S(2) - b*sqrt(-S(4)*a*c + b**S(2)))) + x*(-S(2)*a*b*d*e - S(2)*a*(-a*e**S(2) + c*d**S(2)) + b**S(2)*d**S(2) + x**n*(a*b*e**S(2) - S(4)*a*c*d*e + b*c*d**S(2)))/(S(2)*a*n*(-S(4)*a*c + b**S(2))*(a + b*x**n + c*x**(S(2)*n))**S(2)) + e**S(2)*x*(-S(2)*a*c + b**S(2) + b*c*x**n)/(a*c*n*(-S(4)*a*c + b**S(2))*(a + b*x**n + c*x**(S(2)*n))) - x*((-n + S(1))*(-S(8)*a**S(2)*c**S(2)*d*e*(-S(3)*n + S(1)) + S(2)*a*b**S(2)*c*d*e + S(2)*a*b*c*(a*e**S(2)*n + c*d**S(2)*(-S(7)*n + S(2))) - b**S(3)*(S(2)*a*e**S(2)*n + c*d**S(2)*(-S(2)*n + S(1)))) - (-S(8)*a**S(2)*b*c**S(2)*d*e*(-S(3)*n**S(2) - n + S(1)) - S(8)*a**S(2)*c**S(2)*(-a*e**S(2) + c*d**S(2))*(S(8)*n**S(2) - S(6)*n + S(1)) + S(2)*a*b**S(3)*c*d*e*(-n + S(1)) + S(2)*a*b**S(2)*c*(-a*e**S(2)*(S(15)*n**S(2) - S(10)*n + S(1)) + S(3)*c*d**S(2)*(S(3)*n**S(2) - S(4)*n + S(1))) - b**S(4)*(-n + S(1))*(S(2)*a*e**S(2)*n + c*d**S(2)*(-S(2)*n + S(1))))/sqrt(-S(4)*a*c + b**S(2)))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*a**S(2)*n**S(2)*(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**S(2)) - x*((-n + S(1))*(-S(8)*a**S(2)*c**S(2)*d*e*(-S(3)*n + S(1)) + S(2)*a*b**S(2)*c*d*e + S(2)*a*b*c*(a*e**S(2)*n + c*d**S(2)*(-S(7)*n + S(2))) - b**S(3)*(S(2)*a*e**S(2)*n + c*d**S(2)*(-S(2)*n + S(1)))) + (-S(8)*a**S(2)*b*c**S(2)*d*e*(-S(3)*n**S(2) - n + S(1)) - S(8)*a**S(2)*c**S(2)*(-a*e**S(2) + c*d**S(2))*(S(8)*n**S(2) - S(6)*n + S(1)) + S(2)*a*b**S(3)*c*d*e*(-n + S(1)) + S(2)*a*b**S(2)*c*(-a*e**S(2)*(S(15)*n**S(2) - S(10)*n + S(1)) + S(3)*c*d**S(2)*(S(3)*n**S(2) - S(4)*n + S(1))) - b**S(4)*(-n + S(1))*(S(2)*a*e**S(2)*n + c*d**S(2)*(-S(2)*n + S(1))))/sqrt(-S(4)*a*c + b**S(2)))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*a**S(2)*n**S(2)*(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**S(2)) + x*(-S(4)*a**S(2)*b*c**S(2)*d*e*(-S(3)*n + S(2)) - S(4)*a**S(2)*c**S(2)*(-S(4)*n + S(1))*(-a*e**S(2) + c*d**S(2)) + S(2)*a*b**S(3)*c*d*e - a*b**S(2)*c*(a*e**S(2)*(-S(9)*n + S(1)) - S(5)*c*d**S(2)*(-S(3)*n + S(1))) - b**S(4)*(S(2)*a*e**S(2)*n + c*d**S(2)*(-S(2)*n + S(1))) + c*x**n*(-S(8)*a**S(2)*c**S(2)*d*e*(-S(3)*n + S(1)) + S(2)*a*b**S(2)*c*d*e + S(2)*a*b*c*(a*e**S(2)*n + c*d**S(2)*(-S(7)*n + S(2))) - b**S(3)*(S(2)*a*e**S(2)*n + c*d**S(2)*(-S(2)*n + S(1)))))/(S(2)*a**S(2)*c*n**S(2)*(-S(4)*a*c + b**S(2))**S(2)*(a + b*x**n + c*x**(S(2)*n))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**n)/(a + b*x**n + c*x**(S(2)*n))**S(3), x), x, x*(-a*b*e - S(2)*a*c*d + b**S(2)*d + c*x**n*(-S(2)*a*e + b*d))/(S(2)*a*n*(-S(4)*a*c + b**S(2))*(a + b*x**n + c*x**(S(2)*n))**S(2)) - c*x*(-S(4)*a**S(2)*c*(-S(2)*c*d*(S(8)*n**S(2) - S(6)*n + S(1)) + e*sqrt(-S(4)*a*c + b**S(2))*(S(3)*n**S(2) - S(4)*n + S(1))) + a*b**S(2)*(-n + S(1))*(-S(6)*c*d*(-S(3)*n + S(1)) + e*sqrt(-S(4)*a*c + b**S(2))) + S(2)*a*b*c*(S(2)*a*e*(-S(3)*n**S(2) - n + S(1)) + d*sqrt(-S(4)*a*c + b**S(2))*(S(7)*n**S(2) - S(9)*n + S(2))) + b**S(4)*d*(S(2)*n**S(2) - S(3)*n + S(1)) - b**S(3)*(-n + S(1))*(a*e + d*(-S(2)*n + S(1))*sqrt(-S(4)*a*c + b**S(2))))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*a**S(2)*n**S(2)*(-S(4)*a*c + b**S(2))**S(2)*(-S(4)*a*c + b**S(2) + b*sqrt(-S(4)*a*c + b**S(2)))) + c*x*(-S(4)*a**S(2)*c*(S(2)*c*d*(S(8)*n**S(2) - S(6)*n + S(1)) + e*sqrt(-S(4)*a*c + b**S(2))*(S(3)*n**S(2) - S(4)*n + S(1))) + a*b**S(2)*(-n + S(1))*(S(6)*c*d*(-S(3)*n + S(1)) + e*sqrt(-S(4)*a*c + b**S(2))) - S(2)*a*b*c*(S(2)*a*e*(-S(3)*n**S(2) - n + S(1)) - d*sqrt(-S(4)*a*c + b**S(2))*(S(7)*n**S(2) - S(9)*n + S(2))) - b**S(4)*d*(S(2)*n**S(2) - S(3)*n + S(1)) + b**S(3)*(-n + S(1))*(a*e - d*(-S(2)*n + S(1))*sqrt(-S(4)*a*c + b**S(2))))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*a**S(2)*n**S(2)*(-S(4)*a*c + b**S(2))**S(2)*(-S(4)*a*c + b**S(2) - b*sqrt(-S(4)*a*c + b**S(2)))) + x*(-S(2)*a**S(2)*b*c*e*(-S(3)*n + S(2)) - S(4)*a**S(2)*c**S(2)*d*(-S(4)*n + S(1)) + a*b**S(3)*e + S(5)*a*b**S(2)*c*d*(-S(3)*n + S(1)) - b**S(4)*d*(-S(2)*n + S(1)) + c*x**n*(-S(4)*a**S(2)*c*e*(-S(3)*n + S(1)) + a*b**S(2)*e + S(2)*a*b*c*d*(-S(7)*n + S(2)) - b**S(3)*d*(-S(2)*n + S(1))))/(S(2)*a**S(2)*n**S(2)*(-S(4)*a*c + b**S(2))**S(2)*(a + b*x**n + c*x**(S(2)*n))), expand=True, _diff=True, _numerical=True)
#Apart# assert rubi_test(rubi_integrate(S(1)/((d + e*x**n)*(a + b*x**n + c*x**(S(2)*n))**S(3)), x), x, -c*e**S(4)*x*(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/((-S(4)*a*c + b**S(2) + b*sqrt(-S(4)*a*c + b**S(2)))*(a*e**S(2) - b*d*e + c*d**S(2))**S(3)) - c*e**S(4)*x*(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))))/((-S(4)*a*c + b**S(2) - b*sqrt(-S(4)*a*c + b**S(2)))*(a*e**S(2) - b*d*e + c*d**S(2))**S(3)) + e**S(6)*x*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -e*x**n/d)/(d*(a*e**S(2) - b*d*e + c*d**S(2))**S(3)) + c*e**S(2)*x*(-S(2)*a*c*(S(2)*c*d*(-S(2)*n + S(1)) + e*(-n + S(1))*sqrt(-S(4)*a*c + b**S(2))) - b**S(3)*e*(-n + S(1)) + b**S(2)*(-n + S(1))*(c*d + e*sqrt(-S(4)*a*c + b**S(2))) + b*c*(S(2)*a*e*(-S(3)*n + S(2)) - d*(-n + S(1))*sqrt(-S(4)*a*c + b**S(2))))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(a*n*(-S(4)*a*c + b**S(2))*(-S(4)*a*c + b**S(2) + b*sqrt(-S(4)*a*c + b**S(2)))*(a*e**S(2) - b*d*e + c*d**S(2))**S(2)) + c*e**S(2)*x*(-S(2)*a*c*(S(2)*c*d*(-S(2)*n + S(1)) - e*(-n + S(1))*sqrt(-S(4)*a*c + b**S(2))) - b**S(3)*e*(-n + S(1)) + b**S(2)*(-n + S(1))*(c*d - e*sqrt(-S(4)*a*c + b**S(2))) + b*c*(S(2)*a*e*(-S(3)*n + S(2)) + d*(-n + S(1))*sqrt(-S(4)*a*c + b**S(2))))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))))/(a*n*(-S(4)*a*c + b**S(2))*(-S(4)*a*c + b**S(2) - b*sqrt(-S(4)*a*c + b**S(2)))*(a*e**S(2) - b*d*e + c*d**S(2))**S(2)) + e**S(2)*x*(S(3)*a*b*c*e - S(2)*a*c**S(2)*d - b**S(3)*e + b**S(2)*c*d + c*x**n*(S(2)*a*c*e - b**S(2)*e + b*c*d))/(a*n*(-S(4)*a*c + b**S(2))*(a + b*x**n + c*x**(S(2)*n))*(a*e**S(2) - b*d*e + c*d**S(2))**S(2)) + x*(S(3)*a*b*c*e - S(2)*a*c**S(2)*d - b**S(3)*e + b**S(2)*c*d + c*x**n*(S(2)*a*c*e - b**S(2)*e + b*c*d))/(S(2)*a*n*(-S(4)*a*c + b**S(2))*(a + b*x**n + c*x**(S(2)*n))**S(2)*(a*e**S(2) - b*d*e + c*d**S(2))) - c*x*(-S(4)*a**S(2)*c**S(2)*(-S(2)*c*d*(S(8)*n**S(2) - S(6)*n + S(1)) + e*sqrt(-S(4)*a*c + b**S(2))*(S(3)*n**S(2) - S(4)*n + S(1))) + a*b**S(2)*c*(-n + S(1))*(-S(6)*c*d*(-S(3)*n + S(1)) + e*(-S(14)*n + S(5))*sqrt(-S(4)*a*c + b**S(2))) - S(2)*a*b*c**S(2)*(S(2)*a*e*(S(13)*n**S(2) - S(13)*n + S(3)) + d*sqrt(-S(4)*a*c + b**S(2))*(S(7)*n**S(2) - S(9)*n + S(2))) - b**S(5)*e*(S(2)*n**S(2) - S(3)*n + S(1)) + b**S(4)*(c*d - e*sqrt(-S(4)*a*c + b**S(2)))*(S(2)*n**S(2) - S(3)*n + S(1)) + b**S(3)*c*(-n + S(1))*(a*e*(-S(18)*n + S(7)) + d*(-S(2)*n + S(1))*sqrt(-S(4)*a*c + b**S(2))))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*a**S(2)*n**S(2)*(-S(4)*a*c + b**S(2))**S(2)*(-S(4)*a*c + b**S(2) - b*sqrt(-S(4)*a*c + b**S(2)))*(a*e**S(2) - b*d*e + c*d**S(2))) + c*x*(-S(4)*a**S(2)*c**S(2)*(S(2)*c*d*(S(8)*n**S(2) - S(6)*n + S(1)) + e*sqrt(-S(4)*a*c + b**S(2))*(S(3)*n**S(2) - S(4)*n + S(1))) + a*b**S(2)*c*(-n + S(1))*(S(6)*c*d*(-S(3)*n + S(1)) + e*(-S(14)*n + S(5))*sqrt(-S(4)*a*c + b**S(2))) - S(2)*a*b*c**S(2)*(-S(2)*a*e*(S(13)*n**S(2) - S(13)*n + S(3)) + d*sqrt(-S(4)*a*c + b**S(2))*(S(7)*n**S(2) - S(9)*n + S(2))) + b**S(5)*e*(S(2)*n**S(2) - S(3)*n + S(1)) - b**S(4)*(c*d + e*sqrt(-S(4)*a*c + b**S(2)))*(S(2)*n**S(2) - S(3)*n + S(1)) - b**S(3)*c*(-n + S(1))*(a*e*(-S(18)*n + S(7)) - d*(-S(2)*n + S(1))*sqrt(-S(4)*a*c + b**S(2))))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*a**S(2)*n**S(2)*(-S(4)*a*c + b**S(2))**S(2)*(c*d**S(2) - e*(-a*e + b*d))*(-S(4)*a*c + b**S(2) + b*sqrt(-S(4)*a*c + b**S(2)))) + x*(S(2)*a**S(2)*b*c**S(2)*e*(-S(11)*n + S(4)) - S(4)*a**S(2)*c**S(3)*d*(-S(4)*n + S(1)) - S(3)*a*b**S(3)*c*e*(-S(5)*n + S(2)) + S(5)*a*b**S(2)*c**S(2)*d*(-S(3)*n + S(1)) + b**S(5)*(-S(2)*e*n + e) - b**S(4)*c*d*(-S(2)*n + S(1)) - c*x**n*(-S(4)*a**S(2)*c**S(2)*e*(-S(3)*n + S(1)) + a*b**S(2)*c*e*(-S(14)*n + S(5)) - S(2)*a*b*c**S(2)*d*(-S(7)*n + S(2)) - b**S(4)*e*(-S(2)*n + S(1)) + b**S(3)*c*d*(-S(2)*n + S(1))))/(S(2)*a**S(2)*n**S(2)*(-S(4)*a*c + b**S(2))**S(2)*(a + b*x**n + c*x**(S(2)*n))*(a*e**S(2) - b*d*e + c*d**S(2))), expand=True, _diff=True, _numerical=True)
#Apart# assert rubi_test(rubi_integrate(S(1)/((d + e*x**n)**S(2)*(a + b*x**n + c*x**(S(2)*n))**S(3)), x), x, -c*e**S(4)*x*(S(3)*b*e**S(2)*(b - sqrt(-S(4)*a*c + b**S(2))) + S(10)*c**S(2)*d**S(2) - S(2)*c*e*(a*e + S(5)*b*d - S(3)*d*sqrt(-S(4)*a*c + b**S(2))))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/((-S(4)*a*c + b**S(2) + b*sqrt(-S(4)*a*c + b**S(2)))*(a*e**S(2) - b*d*e + c*d**S(2))**S(4)) - c*e**S(4)*x*(S(3)*b*e**S(2)*(b + sqrt(-S(4)*a*c + b**S(2))) + S(10)*c**S(2)*d**S(2) - S(2)*c*e*(a*e + S(5)*b*d + S(3)*d*sqrt(-S(4)*a*c + b**S(2))))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))))/((-S(4)*a*c + b**S(2) - b*sqrt(-S(4)*a*c + b**S(2)))*(a*e**S(2) - b*d*e + c*d**S(2))**S(4)) + S(3)*e**S(6)*x*(-b*e + S(2)*c*d)*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -e*x**n/d)/(d*(a*e**S(2) - b*d*e + c*d**S(2))**S(4)) + e**S(6)*x*hyper((S(2), S(1)/n), (S(1) + S(1)/n,), -e*x**n/d)/(d**S(2)*(a*e**S(2) - b*d*e + c*d**S(2))**S(3)) + c*e**S(2)*x*(S(4)*a*c**S(2)*(-S(3)*c*d**S(2)*(-S(2)*n + S(1)) + e*(a*e*(-S(2)*n + S(1)) - S(2)*d*(-n + S(1))*sqrt(-S(4)*a*c + b**S(2)))) + S(2)*b**S(4)*e**S(2)*(-n + S(1)) - b**S(3)*e*(-n + S(1))*(S(5)*c*d + S(2)*e*sqrt(-S(4)*a*c + b**S(2))) - b**S(2)*c*(-S(3)*c*d**S(2)*(-n + S(1)) + e*(a*e*(-S(13)*n + S(9)) - S(5)*d*(-n + S(1))*sqrt(-S(4)*a*c + b**S(2)))) + b*c*(S(5)*a*e**S(2)*(-n + S(1))*sqrt(-S(4)*a*c + b**S(2)) + c*d*(S(4)*a*e*(-S(8)*n + S(5)) - S(3)*d*(-n + S(1))*sqrt(-S(4)*a*c + b**S(2)))))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(a*n*(-S(4)*a*c + b**S(2))*(-S(4)*a*c + b**S(2) + b*sqrt(-S(4)*a*c + b**S(2)))*(a*e**S(2) - b*d*e + c*d**S(2))**S(3)) + c*e**S(2)*x*(S(4)*a*c**S(2)*(-S(3)*c*d**S(2)*(-S(2)*n + S(1)) + e*(a*e*(-S(2)*n + S(1)) + S(2)*d*(-n + S(1))*sqrt(-S(4)*a*c + b**S(2)))) + S(2)*b**S(4)*e**S(2)*(-n + S(1)) - b**S(3)*e*(-n + S(1))*(S(5)*c*d - S(2)*e*sqrt(-S(4)*a*c + b**S(2))) - b**S(2)*c*(-S(3)*c*d**S(2)*(-n + S(1)) + e*(a*e*(-S(13)*n + S(9)) + S(5)*d*(-n + S(1))*sqrt(-S(4)*a*c + b**S(2)))) + b*c*(-S(5)*a*e**S(2)*(-n + S(1))*sqrt(-S(4)*a*c + b**S(2)) + c*d*(S(4)*a*e*(-S(8)*n + S(5)) + S(3)*d*(-n + S(1))*sqrt(-S(4)*a*c + b**S(2)))))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))))/(a*n*(-S(4)*a*c + b**S(2))*(-S(4)*a*c + b**S(2) - b*sqrt(-S(4)*a*c + b**S(2)))*(a*e**S(2) - b*d*e + c*d**S(2))**S(3)) - e**S(2)*x*(-S(14)*a*b*c**S(2)*d*e + S(2)*a*c**S(2)*(-a*e**S(2) + S(3)*c*d**S(2)) - S(2)*b**S(4)*e**S(2) + S(5)*b**S(3)*c*d*e - b**S(2)*c*(-S(7)*a*e**S(2) + S(3)*c*d**S(2)) + c*x**n*(-S(8)*a*c**S(2)*d*e - S(2)*b**S(3)*e**S(2) + S(5)*b**S(2)*c*d*e - b*c*(-S(5)*a*e**S(2) + S(3)*c*d**S(2))))/(a*n*(-S(4)*a*c + b**S(2))*(a + b*x**n + c*x**(S(2)*n))*(a*e**S(2) - b*d*e + c*d**S(2))**S(3)) - x*(-S(6)*a*b*c**S(2)*d*e + S(2)*a*c**S(2)*(-a*e**S(2) + c*d**S(2)) - b**S(4)*e**S(2) + S(2)*b**S(3)*c*d*e - b**S(2)*c*(-S(4)*a*e**S(2) + c*d**S(2)) + c*x**n*(-S(4)*a*c**S(2)*d*e - b**S(3)*e**S(2) + S(2)*b**S(2)*c*d*e - b*c*(-S(3)*a*e**S(2) + c*d**S(2))))/(S(2)*a*n*(-S(4)*a*c + b**S(2))*(a + b*x**n + c*x**(S(2)*n))**S(2)*(a*e**S(2) - b*d*e + c*d**S(2))**S(2)) + c*x*((-n + S(1))*(-S(8)*a**S(2)*c**S(3)*d*e*(-S(3)*n + S(1)) + S(2)*a*b**S(2)*c**S(2)*d*e*(-S(14)*n + S(5)) + S(2)*a*b*c**S(2)*(a*e**S(2)*(-S(13)*n + S(4)) - c*d**S(2)*(-S(7)*n + S(2))) + b**S(5)*e**S(2)*(-S(2)*n + S(1)) - S(2)*b**S(4)*c*d*e*(-S(2)*n + S(1)) - b**S(3)*c*(S(2)*a*e**S(2)*(-S(8)*n + S(3)) - c*d**S(2)*(-S(2)*n + S(1)))) + (S(8)*a**S(2)*b*c**S(3)*d*e*(S(13)*n**S(2) - S(13)*n + S(3)) - S(8)*a**S(2)*c**S(3)*(-a*e**S(2) + c*d**S(2))*(S(8)*n**S(2) - S(6)*n + S(1)) - S(2)*a*b**S(3)*c**S(2)*d*e*(S(18)*n**S(2) - S(25)*n + S(7)) + S(2)*a*b**S(2)*c**S(2)*(-a*e**S(2)*(S(35)*n**S(2) - S(38)*n + S(9)) + S(3)*c*d**S(2)*(S(3)*n**S(2) - S(4)*n + S(1))) - b**S(6)*e**S(2)*(S(2)*n**S(2) - S(3)*n + S(1)) + S(2)*b**S(5)*c*d*e*(S(2)*n**S(2) - S(3)*n + S(1)) + b**S(4)*c*(-n + S(1))*(S(4)*a*e**S(2)*(-S(5)*n + S(2)) - c*d**S(2)*(-S(2)*n + S(1))))/sqrt(-S(4)*a*c + b**S(2)))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*a**S(2)*n**S(2)*(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**S(2)*(a*e**S(2) - b*d*e + c*d**S(2))**S(2)) + c*x*((-n + S(1))*(-S(8)*a**S(2)*c**S(3)*d*e*(-S(3)*n + S(1)) + S(2)*a*b**S(2)*c**S(2)*d*e*(-S(14)*n + S(5)) + S(2)*a*b*c**S(2)*(a*e**S(2)*(-S(13)*n + S(4)) - c*d**S(2)*(-S(7)*n + S(2))) + b**S(5)*e**S(2)*(-S(2)*n + S(1)) - S(2)*b**S(4)*c*d*e*(-S(2)*n + S(1)) - b**S(3)*c*(S(2)*a*e**S(2)*(-S(8)*n + S(3)) - c*d**S(2)*(-S(2)*n + S(1)))) - (S(8)*a**S(2)*b*c**S(3)*d*e*(S(13)*n**S(2) - S(13)*n + S(3)) - S(8)*a**S(2)*c**S(3)*(-a*e**S(2) + c*d**S(2))*(S(8)*n**S(2) - S(6)*n + S(1)) - S(2)*a*b**S(3)*c**S(2)*d*e*(S(18)*n**S(2) - S(25)*n + S(7)) + S(2)*a*b**S(2)*c**S(2)*(-a*e**S(2)*(S(35)*n**S(2) - S(38)*n + S(9)) + S(3)*c*d**S(2)*(S(3)*n**S(2) - S(4)*n + S(1))) - b**S(6)*e**S(2)*(S(2)*n**S(2) - S(3)*n + S(1)) + S(2)*b**S(5)*c*d*e*(S(2)*n**S(2) - S(3)*n + S(1)) + b**S(4)*c*(-n + S(1))*(S(4)*a*e**S(2)*(-S(5)*n + S(2)) - c*d**S(2)*(-S(2)*n + S(1))))/sqrt(-S(4)*a*c + b**S(2)))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*a**S(2)*n**S(2)*(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**S(2)*(a*e**S(2) - b*d*e + c*d**S(2))**S(2)) - x*(-S(4)*a**S(2)*b*c**S(3)*d*e*(-S(11)*n + S(4)) + S(4)*a**S(2)*c**S(3)*(-S(4)*n + S(1))*(-a*e**S(2) + c*d**S(2)) + S(6)*a*b**S(3)*c**S(2)*d*e*(-S(5)*n + S(2)) + a*b**S(2)*c**S(2)*(a*e**S(2)*(-S(37)*n + S(13)) - S(5)*c*d**S(2)*(-S(3)*n + S(1))) + b**S(6)*e**S(2)*(-S(2)*n + S(1)) - S(2)*b**S(5)*c*d*e*(-S(2)*n + S(1)) - b**S(4)*c*(a*e**S(2)*(-S(17)*n + S(7)) - c*d**S(2)*(-S(2)*n + S(1))) + c*x**n*(-S(8)*a**S(2)*c**S(3)*d*e*(-S(3)*n + S(1)) + S(2)*a*b**S(2)*c**S(2)*d*e*(-S(14)*n + S(5)) + S(2)*a*b*c**S(2)*(a*e**S(2)*(-S(13)*n + S(4)) - c*d**S(2)*(-S(7)*n + S(2))) + b**S(5)*e**S(2)*(-S(2)*n + S(1)) - S(2)*b**S(4)*c*d*e*(-S(2)*n + S(1)) - b**S(3)*c*(S(2)*a*e**S(2)*(-S(8)*n + S(3)) - c*d**S(2)*(-S(2)*n + S(1)))))/(S(2)*a**S(2)*n**S(2)*(-S(4)*a*c + b**S(2))**S(2)*(a + b*x**n + c*x**(S(2)*n))*(a*e**S(2) - b*d*e + c*d**S(2))**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + c*x**(S(2)*n))**p/(d + e*x**n), x), x, x*(S(1) + c*x**(S(2)*n)/a)**(-p)*(a + c*x**(S(2)*n))**p*AppellF1(S(1)/(S(2)*n), -p, S(1), S(1) + S(1)/(S(2)*n), -c*x**(S(2)*n)/a, e**S(2)*x**(S(2)*n)/d**S(2))/d - e*x**(n + S(1))*(S(1) + c*x**(S(2)*n)/a)**(-p)*(a + c*x**(S(2)*n))**p*AppellF1((n + S(1))/(S(2)*n), -p, S(1), S(3)/2 + S(1)/(S(2)*n), -c*x**(S(2)*n)/a, e**S(2)*x**(S(2)*n)/d**S(2))/(d**S(2)*(n + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + c*x**(S(2)*n))**p/(d + e*x**n)**S(2), x), x, x*(S(1) + c*x**(S(2)*n)/a)**(-p)*(a + c*x**(S(2)*n))**p*AppellF1(S(1)/(S(2)*n), -p, S(2), S(1) + S(1)/(S(2)*n), -c*x**(S(2)*n)/a, e**S(2)*x**(S(2)*n)/d**S(2))/d**S(2) - S(2)*e*x**(n + S(1))*(S(1) + c*x**(S(2)*n)/a)**(-p)*(a + c*x**(S(2)*n))**p*AppellF1((n + S(1))/(S(2)*n), -p, S(2), S(3)/2 + S(1)/(S(2)*n), -c*x**(S(2)*n)/a, e**S(2)*x**(S(2)*n)/d**S(2))/(d**S(3)*(n + S(1))) + e**S(2)*x**(S(2)*n + S(1))*(S(1) + c*x**(S(2)*n)/a)**(-p)*(a + c*x**(S(2)*n))**p*AppellF1(S(1) + S(1)/(S(2)*n), -p, S(2), S(2) + S(1)/(S(2)*n), -c*x**(S(2)*n)/a, e**S(2)*x**(S(2)*n)/d**S(2))/(d**S(4)*(S(2)*n + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + c*x**(S(2)*n))**p/(d + e*x**n)**S(3), x), x, x*(S(1) + c*x**(S(2)*n)/a)**(-p)*(a + c*x**(S(2)*n))**p*AppellF1(S(1)/(S(2)*n), -p, S(3), S(1) + S(1)/(S(2)*n), -c*x**(S(2)*n)/a, e**S(2)*x**(S(2)*n)/d**S(2))/d**S(3) - S(3)*e*x**(n + S(1))*(S(1) + c*x**(S(2)*n)/a)**(-p)*(a + c*x**(S(2)*n))**p*AppellF1((n + S(1))/(S(2)*n), -p, S(3), S(3)/2 + S(1)/(S(2)*n), -c*x**(S(2)*n)/a, e**S(2)*x**(S(2)*n)/d**S(2))/(d**S(4)*(n + S(1))) + S(3)*e**S(2)*x**(S(2)*n + S(1))*(S(1) + c*x**(S(2)*n)/a)**(-p)*(a + c*x**(S(2)*n))**p*AppellF1(S(1) + S(1)/(S(2)*n), -p, S(3), S(2) + S(1)/(S(2)*n), -c*x**(S(2)*n)/a, e**S(2)*x**(S(2)*n)/d**S(2))/(d**S(5)*(S(2)*n + S(1))) - e**S(3)*x**(S(3)*n + S(1))*(S(1) + c*x**(S(2)*n)/a)**(-p)*(a + c*x**(S(2)*n))**p*AppellF1(S(3)/2 + S(1)/(S(2)*n), -p, S(3), S(5)/2 + S(1)/(S(2)*n), -c*x**(S(2)*n)/a, e**S(2)*x**(S(2)*n)/d**S(2))/(d**S(6)*(S(3)*n + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(sqrt(a + c*x**(S(2)*n))*(d + e*x**n)), x), x, x*sqrt(S(1) + c*x**(S(2)*n)/a)*AppellF1(S(1)/(S(2)*n), S(1)/2, S(1), S(1) + S(1)/(S(2)*n), -c*x**(S(2)*n)/a, e**S(2)*x**(S(2)*n)/d**S(2))/(d*sqrt(a + c*x**(S(2)*n))) - e*x**(n + S(1))*sqrt(S(1) + c*x**(S(2)*n)/a)*AppellF1((n + S(1))/(S(2)*n), S(1)/2, S(1), S(3)/2 + S(1)/(S(2)*n), -c*x**(S(2)*n)/a, e**S(2)*x**(S(2)*n)/d**S(2))/(d**S(2)*sqrt(a + c*x**(S(2)*n))*(n + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**n)*sqrt(a + b*x**n + c*x**(S(2)*n)), x), x, d*x*sqrt(a + b*x**n + c*x**(S(2)*n))*AppellF1(S(1)/n, S(-1)/2, S(-1)/2, S(1) + S(1)/n, -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(sqrt(S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))) + e*x**(n + S(1))*sqrt(a + b*x**n + c*x**(S(2)*n))*AppellF1(S(1) + S(1)/n, S(-1)/2, S(-1)/2, S(2) + S(1)/n, -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/((n + S(1))*sqrt(S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**n)*(a + b*x**n + c*x**(S(2)*n))**(S(3)/2), x), x, a*d*x*sqrt(a + b*x**n + c*x**(S(2)*n))*AppellF1(S(1)/n, S(-3)/2, S(-3)/2, S(1) + S(1)/n, -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(sqrt(S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))) + a*e*x**(n + S(1))*sqrt(a + b*x**n + c*x**(S(2)*n))*AppellF1(S(1) + S(1)/n, S(-3)/2, S(-3)/2, S(2) + S(1)/n, -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/((n + S(1))*sqrt(S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**n)/sqrt(a + b*x**n + c*x**(S(2)*n)), x), x, d*x*sqrt(S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))*AppellF1(S(1)/n, S(1)/2, S(1)/2, S(1) + S(1)/n, -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/sqrt(a + b*x**n + c*x**(S(2)*n)) + e*x**(n + S(1))*sqrt(S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))*AppellF1(S(1) + S(1)/n, S(1)/2, S(1)/2, S(2) + S(1)/n, -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/((n + S(1))*sqrt(a + b*x**n + c*x**(S(2)*n))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**n)/(a + b*x**n + c*x**(S(2)*n))**(S(3)/2), x), x, d*x*sqrt(S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))*AppellF1(S(1)/n, S(3)/2, S(3)/2, S(1) + S(1)/n, -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(a*sqrt(a + b*x**n + c*x**(S(2)*n))) + e*x**(n + S(1))*sqrt(S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))*AppellF1(S(1) + S(1)/n, S(3)/2, S(3)/2, S(2) + S(1)/n, -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(a*(n + S(1))*sqrt(a + b*x**n + c*x**(S(2)*n))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**n)/(a + b*x**n + c*x**(S(2)*n))**(S(5)/2), x), x, d*x*sqrt(S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))*AppellF1(S(1)/n, S(5)/2, S(5)/2, S(1) + S(1)/n, -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(a**S(2)*sqrt(a + b*x**n + c*x**(S(2)*n))) + e*x**(n + S(1))*sqrt(S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))*AppellF1(S(1) + S(1)/n, S(5)/2, S(5)/2, S(2) + S(1)/n, -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(a**S(2)*(n + S(1))*sqrt(a + b*x**n + c*x**(S(2)*n))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**n)**S(3)*(a + b*x**n + c*x**(S(2)*n))**p, x), x, d**S(3)*x*(S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))**(-p)*(S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))**(-p)*(a + b*x**n + c*x**(S(2)*n))**p*AppellF1(S(1)/n, -p, -p, S(1) + S(1)/n, -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2)))) + S(3)*d**S(2)*e*x**(n + S(1))*(S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))**(-p)*(S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))**(-p)*(a + b*x**n + c*x**(S(2)*n))**p*AppellF1(S(1) + S(1)/n, -p, -p, S(2) + S(1)/n, -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(n + S(1)) + S(3)*d*e**S(2)*x**(S(2)*n + S(1))*(S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))**(-p)*(S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))**(-p)*(a + b*x**n + c*x**(S(2)*n))**p*AppellF1(S(2) + S(1)/n, -p, -p, S(3) + S(1)/n, -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*n + S(1)) + e**S(3)*x**(S(3)*n + S(1))*(S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))**(-p)*(S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))**(-p)*(a + b*x**n + c*x**(S(2)*n))**p*AppellF1(S(3) + S(1)/n, -p, -p, S(4) + S(1)/n, -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(3)*n + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**n)**S(2)*(a + b*x**n + c*x**(S(2)*n))**p, x), x, d**S(2)*x*(S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))**(-p)*(S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))**(-p)*(a + b*x**n + c*x**(S(2)*n))**p*AppellF1(S(1)/n, -p, -p, S(1) + S(1)/n, -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2)))) + S(2)*d*e*x**(n + S(1))*(S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))**(-p)*(S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))**(-p)*(a + b*x**n + c*x**(S(2)*n))**p*AppellF1(S(1) + S(1)/n, -p, -p, S(2) + S(1)/n, -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(n + S(1)) + e**S(2)*x**(S(2)*n + S(1))*(S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))**(-p)*(S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))**(-p)*(a + b*x**n + c*x**(S(2)*n))**p*AppellF1(S(2) + S(1)/n, -p, -p, S(3) + S(1)/n, -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*n + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**n)*(a + b*x**n + c*x**(S(2)*n))**p, x), x, d*x*(S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))**(-p)*(S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))**(-p)*(a + b*x**n + c*x**(S(2)*n))**p*AppellF1(S(1)/n, -p, -p, S(1) + S(1)/n, -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2)))) + e*x**(n + S(1))*(S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))**(-p)*(S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))**(-p)*(a + b*x**n + c*x**(S(2)*n))**p*AppellF1(S(1) + S(1)/n, -p, -p, S(2) + S(1)/n, -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(n + S(1)), expand=True, _diff=True, _numerical=True)
def test_3():
assert rubi_test(rubi_integrate(x**S(3)*(a + c*x**S(4))**S(5)*(d + e*x**S(2)), x), x, a**S(5)*d*x**S(4)/S(4) + a**S(5)*e*x**S(6)/S(6) + S(5)*a**S(4)*c*d*x**S(8)/S(8) + a**S(4)*c*e*x**S(10)/S(2) + S(5)*a**S(3)*c**S(2)*d*x**S(12)/S(6) + S(5)*a**S(3)*c**S(2)*e*x**S(14)/S(7) + S(5)*a**S(2)*c**S(3)*d*x**S(16)/S(8) + S(5)*a**S(2)*c**S(3)*e*x**S(18)/S(9) + a*c**S(4)*d*x**S(20)/S(4) + S(5)*a*c**S(4)*e*x**S(22)/S(22) + c**S(5)*d*x**S(24)/S(24) + c**S(5)*e*x**S(26)/S(26), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(a + c*x**S(4))**S(5)*(d + e*x**S(2)), x), x, a**S(5)*d*x**S(3)/S(3) + a**S(5)*e*x**S(5)/S(5) + S(5)*a**S(4)*c*d*x**S(7)/S(7) + S(5)*a**S(4)*c*e*x**S(9)/S(9) + S(10)*a**S(3)*c**S(2)*d*x**S(11)/S(11) + S(10)*a**S(3)*c**S(2)*e*x**S(13)/S(13) + S(2)*a**S(2)*c**S(3)*d*x**S(15)/S(3) + S(10)*a**S(2)*c**S(3)*e*x**S(17)/S(17) + S(5)*a*c**S(4)*d*x**S(19)/S(19) + S(5)*a*c**S(4)*e*x**S(21)/S(21) + c**S(5)*d*x**S(23)/S(23) + c**S(5)*e*x**S(25)/S(25), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(a + c*x**S(4))**S(5)*(d + e*x**S(2)), x), x, a**S(5)*d*x**S(2)/S(2) + S(5)*a**S(4)*c*d*x**S(6)/S(6) + a**S(3)*c**S(2)*d*x**S(10) + S(5)*a**S(2)*c**S(3)*d*x**S(14)/S(7) + S(5)*a*c**S(4)*d*x**S(18)/S(18) + c**S(5)*d*x**S(22)/S(22) + e*(a + c*x**S(4))**S(6)/(S(24)*c), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + c*x**S(4))**S(5)*(d + e*x**S(2)), x), x, a**S(5)*d*x + a**S(5)*e*x**S(3)/S(3) + a**S(4)*c*d*x**S(5) + S(5)*a**S(4)*c*e*x**S(7)/S(7) + S(10)*a**S(3)*c**S(2)*d*x**S(9)/S(9) + S(10)*a**S(3)*c**S(2)*e*x**S(11)/S(11) + S(10)*a**S(2)*c**S(3)*d*x**S(13)/S(13) + S(2)*a**S(2)*c**S(3)*e*x**S(15)/S(3) + S(5)*a*c**S(4)*d*x**S(17)/S(17) + S(5)*a*c**S(4)*e*x**S(19)/S(19) + c**S(5)*d*x**S(21)/S(21) + c**S(5)*e*x**S(23)/S(23), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + c*x**S(4))**S(5)*(d + e*x**S(2))/x, x), x, a**S(5)*d*log(x) + a**S(5)*e*x**S(2)/S(2) + S(5)*a**S(4)*c*d*x**S(4)/S(4) + S(5)*a**S(4)*c*e*x**S(6)/S(6) + S(5)*a**S(3)*c**S(2)*d*x**S(8)/S(4) + a**S(3)*c**S(2)*e*x**S(10) + S(5)*a**S(2)*c**S(3)*d*x**S(12)/S(6) + S(5)*a**S(2)*c**S(3)*e*x**S(14)/S(7) + S(5)*a*c**S(4)*d*x**S(16)/S(16) + S(5)*a*c**S(4)*e*x**S(18)/S(18) + c**S(5)*d*x**S(20)/S(20) + c**S(5)*e*x**S(22)/S(22), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + c*x**S(4))**S(5)*(d + e*x**S(2))/x**S(2), x), x, -a**S(5)*d/x + a**S(5)*e*x + S(5)*a**S(4)*c*d*x**S(3)/S(3) + a**S(4)*c*e*x**S(5) + S(10)*a**S(3)*c**S(2)*d*x**S(7)/S(7) + S(10)*a**S(3)*c**S(2)*e*x**S(9)/S(9) + S(10)*a**S(2)*c**S(3)*d*x**S(11)/S(11) + S(10)*a**S(2)*c**S(3)*e*x**S(13)/S(13) + a*c**S(4)*d*x**S(15)/S(3) + S(5)*a*c**S(4)*e*x**S(17)/S(17) + c**S(5)*d*x**S(19)/S(19) + c**S(5)*e*x**S(21)/S(21), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + c*x**S(4))**S(5)*(d + e*x**S(2))/x**S(3), x), x, -a**S(5)*d/(S(2)*x**S(2)) + a**S(5)*e*log(x) + S(5)*a**S(4)*c*d*x**S(2)/S(2) + S(5)*a**S(4)*c*e*x**S(4)/S(4) + S(5)*a**S(3)*c**S(2)*d*x**S(6)/S(3) + S(5)*a**S(3)*c**S(2)*e*x**S(8)/S(4) + a**S(2)*c**S(3)*d*x**S(10) + S(5)*a**S(2)*c**S(3)*e*x**S(12)/S(6) + S(5)*a*c**S(4)*d*x**S(14)/S(14) + S(5)*a*c**S(4)*e*x**S(16)/S(16) + c**S(5)*d*x**S(18)/S(18) + c**S(5)*e*x**S(20)/S(20), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((f*x)**m*(d + e*x**S(2))*(x**S(4) + S(2)*x**S(2) + S(1))**S(5), x), x, d*(f*x)**(m + S(1))/(f*(m + S(1))) + e*(f*x)**(m + S(23))/(f**S(23)*(m + S(23))) + (f*x)**(m + S(3))*(S(10)*d + e)/(f**S(3)*(m + S(3))) + (f*x)**(m + S(5))*(S(45)*d + S(10)*e)/(f**S(5)*(m + S(5))) + (f*x)**(m + S(7))*(S(120)*d + S(45)*e)/(f**S(7)*(m + S(7))) + (f*x)**(m + S(9))*(S(210)*d + S(120)*e)/(f**S(9)*(m + S(9))) + (f*x)**(m + S(11))*(S(252)*d + S(210)*e)/(f**S(11)*(m + S(11))) + (f*x)**(m + S(13))*(S(210)*d + S(252)*e)/(f**S(13)*(m + S(13))) + (f*x)**(m + S(15))*(S(120)*d + S(210)*e)/(f**S(15)*(m + S(15))) + (f*x)**(m + S(17))*(S(45)*d + S(120)*e)/(f**S(17)*(m + S(17))) + (f*x)**(m + S(19))*(S(10)*d + S(45)*e)/(f**S(19)*(m + S(19))) + (f*x)**(m + S(21))*(d + S(10)*e)/(f**S(21)*(m + S(21))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)*(d + e*x**S(2))*(x**S(4) + S(2)*x**S(2) + S(1))**S(5), x), x, e*(x**S(2) + S(1))**S(14)/S(28) + (d/S(26) - S(3)*e/S(26))*(x**S(2) + S(1))**S(13) + (d/S(22) - e/S(22))*(x**S(2) + S(1))**S(11) - (d/S(12) - e/S(8))*(x**S(2) + S(1))**S(12), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)*(d + e*x**S(2))*(x**S(4) + S(2)*x**S(2) + S(1))**S(5), x), x, d*x**S(5)/S(5) + e*x**S(27)/S(27) + x**S(25)*(d/S(25) + S(2)*e/S(5)) + x**S(23)*(S(10)*d/S(23) + S(45)*e/S(23)) + x**S(21)*(S(15)*d/S(7) + S(40)*e/S(7)) + x**S(19)*(S(120)*d/S(19) + S(210)*e/S(19)) + x**S(17)*(S(210)*d/S(17) + S(252)*e/S(17)) + x**S(15)*(S(84)*d/S(5) + S(14)*e) + x**S(13)*(S(210)*d/S(13) + S(120)*e/S(13)) + x**S(11)*(S(120)*d/S(11) + S(45)*e/S(11)) + x**S(9)*(S(5)*d + S(10)*e/S(9)) + x**S(7)*(S(10)*d/S(7) + e/S(7)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*(d + e*x**S(2))*(x**S(4) + S(2)*x**S(2) + S(1))**S(5), x), x, e*(x**S(2) + S(1))**S(13)/S(26) + (-d/S(22) + e/S(22))*(x**S(2) + S(1))**S(11) + (d/S(24) - e/S(12))*(x**S(2) + S(1))**S(12), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(d + e*x**S(2))*(x**S(4) + S(2)*x**S(2) + S(1))**S(5), x), x, d*x**S(3)/S(3) + e*x**S(25)/S(25) + x**S(23)*(d/S(23) + S(10)*e/S(23)) + x**S(21)*(S(10)*d/S(21) + S(15)*e/S(7)) + x**S(19)*(S(45)*d/S(19) + S(120)*e/S(19)) + x**S(17)*(S(120)*d/S(17) + S(210)*e/S(17)) + x**S(15)*(S(14)*d + S(84)*e/S(5)) + x**S(13)*(S(252)*d/S(13) + S(210)*e/S(13)) + x**S(11)*(S(210)*d/S(11) + S(120)*e/S(11)) + x**S(9)*(S(40)*d/S(3) + S(5)*e) + x**S(7)*(S(45)*d/S(7) + S(10)*e/S(7)) + x**S(5)*(S(2)*d + e/S(5)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(d + e*x**S(2))*(x**S(4) + S(2)*x**S(2) + S(1))**S(5), x), x, e*(x**S(2) + S(1))**S(12)/S(24) + (d/S(22) - e/S(22))*(x**S(2) + S(1))**S(11), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))*(x**S(4) + S(2)*x**S(2) + S(1))**S(5), x), x, d*x + e*x**S(23)/S(23) + x**S(21)*(d/S(21) + S(10)*e/S(21)) + x**S(19)*(S(10)*d/S(19) + S(45)*e/S(19)) + x**S(17)*(S(45)*d/S(17) + S(120)*e/S(17)) + x**S(15)*(S(8)*d + S(14)*e) + x**S(13)*(S(210)*d/S(13) + S(252)*e/S(13)) + x**S(11)*(S(252)*d/S(11) + S(210)*e/S(11)) + x**S(9)*(S(70)*d/S(3) + S(40)*e/S(3)) + x**S(7)*(S(120)*d/S(7) + S(45)*e/S(7)) + x**S(5)*(S(9)*d + S(2)*e) + x**S(3)*(S(10)*d/S(3) + e/S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))*(x**S(4) + S(2)*x**S(2) + S(1))**S(5)/x, x), x, d*x**S(20)/S(20) + S(5)*d*x**S(18)/S(9) + S(45)*d*x**S(16)/S(16) + S(60)*d*x**S(14)/S(7) + S(35)*d*x**S(12)/S(2) + S(126)*d*x**S(10)/S(5) + S(105)*d*x**S(8)/S(4) + S(20)*d*x**S(6) + S(45)*d*x**S(4)/S(4) + S(5)*d*x**S(2) + d*log(x) + e*(x**S(2) + S(1))**S(11)/S(22), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))*(x**S(4) + S(2)*x**S(2) + S(1))**S(5)/x**S(2), x), x, -d/x + e*x**S(21)/S(21) + x**S(19)*(d/S(19) + S(10)*e/S(19)) + x**S(17)*(S(10)*d/S(17) + S(45)*e/S(17)) + x**S(15)*(S(3)*d + S(8)*e) + x**S(13)*(S(120)*d/S(13) + S(210)*e/S(13)) + x**S(11)*(S(210)*d/S(11) + S(252)*e/S(11)) + x**S(9)*(S(28)*d + S(70)*e/S(3)) + x**S(7)*(S(30)*d + S(120)*e/S(7)) + x**S(5)*(S(24)*d + S(9)*e) + x**S(3)*(S(15)*d + S(10)*e/S(3)) + x*(S(10)*d + e), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))*(x**S(4) + S(2)*x**S(2) + S(1))**S(5)/x**S(3), x), x, -d/(S(2)*x**S(2)) + e*x**S(20)/S(20) + x**S(18)*(d/S(18) + S(5)*e/S(9)) + x**S(16)*(S(5)*d/S(8) + S(45)*e/S(16)) + x**S(14)*(S(45)*d/S(14) + S(60)*e/S(7)) + x**S(12)*(S(10)*d + S(35)*e/S(2)) + x**S(10)*(S(21)*d + S(126)*e/S(5)) + x**S(8)*(S(63)*d/S(2) + S(105)*e/S(4)) + x**S(6)*(S(35)*d + S(20)*e) + x**S(4)*(S(30)*d + S(45)*e/S(4)) + x**S(2)*(S(45)*d/S(2) + S(5)*e) + (S(10)*d + e)*log(x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((f*x)**m*(x**S(2) + S(1))*(x**S(4) + S(2)*x**S(2) + S(1))**S(5), x), x, (f*x)**(m + S(1))/(f*(m + S(1))) + S(11)*(f*x)**(m + S(3))/(f**S(3)*(m + S(3))) + S(55)*(f*x)**(m + S(5))/(f**S(5)*(m + S(5))) + S(165)*(f*x)**(m + S(7))/(f**S(7)*(m + S(7))) + S(330)*(f*x)**(m + S(9))/(f**S(9)*(m + S(9))) + S(462)*(f*x)**(m + S(11))/(f**S(11)*(m + S(11))) + S(462)*(f*x)**(m + S(13))/(f**S(13)*(m + S(13))) + S(330)*(f*x)**(m + S(15))/(f**S(15)*(m + S(15))) + S(165)*(f*x)**(m + S(17))/(f**S(17)*(m + S(17))) + S(55)*(f*x)**(m + S(19))/(f**S(19)*(m + S(19))) + S(11)*(f*x)**(m + S(21))/(f**S(21)*(m + S(21))) + (f*x)**(m + S(23))/(f**S(23)*(m + S(23))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)*(x**S(2) + S(1))*(x**S(4) + S(2)*x**S(2) + S(1))**S(5), x), x, (x**S(2) + S(1))**S(14)/S(28) - (x**S(2) + S(1))**S(13)/S(13) + (x**S(2) + S(1))**S(12)/S(24), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)*(x**S(2) + S(1))*(x**S(4) + S(2)*x**S(2) + S(1))**S(5), x), x, x**S(27)/S(27) + S(11)*x**S(25)/S(25) + S(55)*x**S(23)/S(23) + S(55)*x**S(21)/S(7) + S(330)*x**S(19)/S(19) + S(462)*x**S(17)/S(17) + S(154)*x**S(15)/S(5) + S(330)*x**S(13)/S(13) + S(15)*x**S(11) + S(55)*x**S(9)/S(9) + S(11)*x**S(7)/S(7) + x**S(5)/S(5), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*(x**S(2) + S(1))*(x**S(4) + S(2)*x**S(2) + S(1))**S(5), x), x, (x**S(2) + S(1))**S(13)/S(26) - (x**S(2) + S(1))**S(12)/S(24), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(x**S(2) + S(1))*(x**S(4) + S(2)*x**S(2) + S(1))**S(5), x), x, x**S(25)/S(25) + S(11)*x**S(23)/S(23) + S(55)*x**S(21)/S(21) + S(165)*x**S(19)/S(19) + S(330)*x**S(17)/S(17) + S(154)*x**S(15)/S(5) + S(462)*x**S(13)/S(13) + S(30)*x**S(11) + S(55)*x**S(9)/S(3) + S(55)*x**S(7)/S(7) + S(11)*x**S(5)/S(5) + x**S(3)/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(x**S(2) + S(1))*(x**S(4) + S(2)*x**S(2) + S(1))**S(5), x), x, (x**S(2) + S(1))**S(12)/S(24), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(2) + S(1))*(x**S(4) + S(2)*x**S(2) + S(1))**S(5), x), x, x**S(23)/S(23) + S(11)*x**S(21)/S(21) + S(55)*x**S(19)/S(19) + S(165)*x**S(17)/S(17) + S(22)*x**S(15) + S(462)*x**S(13)/S(13) + S(42)*x**S(11) + S(110)*x**S(9)/S(3) + S(165)*x**S(7)/S(7) + S(11)*x**S(5) + S(11)*x**S(3)/S(3) + x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(2) + S(1))*(x**S(4) + S(2)*x**S(2) + S(1))**S(5)/x, x), x, x**S(22)/S(22) + S(11)*x**S(20)/S(20) + S(55)*x**S(18)/S(18) + S(165)*x**S(16)/S(16) + S(165)*x**S(14)/S(7) + S(77)*x**S(12)/S(2) + S(231)*x**S(10)/S(5) + S(165)*x**S(8)/S(4) + S(55)*x**S(6)/S(2) + S(55)*x**S(4)/S(4) + S(11)*x**S(2)/S(2) + log(x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(2) + S(1))*(x**S(4) + S(2)*x**S(2) + S(1))**S(5)/x**S(2), x), x, x**S(21)/S(21) + S(11)*x**S(19)/S(19) + S(55)*x**S(17)/S(17) + S(11)*x**S(15) + S(330)*x**S(13)/S(13) + S(42)*x**S(11) + S(154)*x**S(9)/S(3) + S(330)*x**S(7)/S(7) + S(33)*x**S(5) + S(55)*x**S(3)/S(3) + S(11)*x - S(1)/x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(2) + S(1))*(x**S(4) + S(2)*x**S(2) + S(1))**S(5)/x**S(3), x), x, x**S(20)/S(20) + S(11)*x**S(18)/S(18) + S(55)*x**S(16)/S(16) + S(165)*x**S(14)/S(14) + S(55)*x**S(12)/S(2) + S(231)*x**S(10)/S(5) + S(231)*x**S(8)/S(4) + S(55)*x**S(6) + S(165)*x**S(4)/S(4) + S(55)*x**S(2)/S(2) + S(11)*log(x) - S(1)/(S(2)*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((f*x)**m*(d + e*x**S(2))/sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4)), x), x, e*(f*x)**(m + S(1))*(a + b*x**S(2))/(b*f*(m + S(1))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + (f*x)**(m + S(1))*(a + b*x**S(2))*(-a*e + b*d)*hyper((S(1), m/S(2) + S(1)/2), (m/S(2) + S(3)/2,), -b*x**S(2)/a)/(a*b*f*(m + S(1))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(d + e*x**S(2))/sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4)), x), x, -sqrt(a)*(a + b*x**S(2))*(-a*e + b*d)*atan(sqrt(b)*x/sqrt(a))/(b**(S(5)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + e*x**S(3)*(a + b*x**S(2))/(S(3)*b*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + x*(a + b*x**S(2))*(-a*e + b*d)/(b**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(d + e*x**S(2))/sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4)), x), x, e*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(2)*b**S(2)) + (a + b*x**S(2))*(-a*e + b*d)*log(a + b*x**S(2))/(S(2)*b**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))/sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4)), x), x, e*x*(a + b*x**S(2))/(b*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + (a + b*x**S(2))*(-a*e + b*d)*atan(sqrt(b)*x/sqrt(a))/(sqrt(a)*b**(S(3)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))/(x*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), x), x, d*(a + b*x**S(2))*log(x)/(a*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - (a + b*x**S(2))*(-a*e + b*d)*log(a + b*x**S(2))/(S(2)*a*b*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))/(x**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), x), x, -d*(a + b*x**S(2))/(a*x*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - (a + b*x**S(2))*(-a*e + b*d)*atan(sqrt(b)*x/sqrt(a))/(a**(S(3)/2)*sqrt(b)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))/(x**S(3)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), x), x, -d*(a + b*x**S(2))/(S(2)*a*x**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - (a + b*x**S(2))*(-a*e + b*d)*log(x)/(a**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + (a + b*x**S(2))*(-a*e + b*d)*log(a + b*x**S(2))/(S(2)*a**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((f*x)**m*(d + e*x**S(2))/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2), x), x, (f*x)**(m + S(1))*(-a*e + b*d)/(S(4)*a*b*f*(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + (f*x)**(m + S(1))*(a + b*x**S(2))*(a*e*(m + S(1)) + b*d*(-m + S(3)))*hyper((S(2), m/S(2) + S(1)/2), (m/S(2) + S(3)/2,), -b*x**S(2)/a)/(S(4)*a**S(3)*b*f*(m + S(1))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(d + e*x**S(2))/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2), x), x, -x*(-a*e + b*d)/(S(4)*b**S(2)*(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + x*(-S(5)*a*e + b*d)/(S(8)*a*b**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + (a + b*x**S(2))*(S(3)*a*e + b*d)*atan(sqrt(b)*x/sqrt(a))/(S(8)*a**(S(3)/2)*b**(S(5)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(d + e*x**S(2))/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2), x), x, -(a + b*x**S(2))*(d + e*x**S(2))**S(2)/((-S(4)*a*e + S(4)*b*d)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))/(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2), x), x, x*(-a*e + b*d)/(S(4)*a*b*(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + x*(a*e + S(3)*b*d)/(S(8)*a**S(2)*b*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + (a + b*x**S(2))*(a*e + S(3)*b*d)*atan(sqrt(b)*x/sqrt(a))/(S(8)*a**(S(5)/2)*b**(S(3)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))/(x*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)), x), x, (-a*e + b*d)/(S(4)*a*b*(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + d/(S(2)*a**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + d*(a + b*x**S(2))*log(x)/(a**S(3)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - d*(a + b*x**S(2))*log(a + b*x**S(2))/(S(2)*a**S(3)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))/(x**S(2)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)), x), x, -x*(-a*e + b*d)/(S(4)*a**S(2)*(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - d*(a + b*x**S(2))/(a**S(3)*x*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - x*(-S(3)*a*e + S(7)*b*d)/(S(8)*a**S(3)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - (a + b*x**S(2))*(-S(3)*a*e + S(15)*b*d)*atan(sqrt(b)*x/sqrt(a))/(S(8)*a**(S(7)/2)*sqrt(b)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))/(x**S(3)*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(S(3)/2)), x), x, -(-a*e + b*d)/(S(4)*a**S(2)*(a + b*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - d*(a + b*x**S(2))/(S(2)*a**S(3)*x**S(2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - (-a*e + S(2)*b*d)/(S(2)*a**S(3)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) - (a + b*x**S(2))*(-a*e + S(3)*b*d)*log(x)/(a**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))) + (a + b*x**S(2))*(-a*e + S(3)*b*d)*log(a + b*x**S(2))/(S(2)*a**S(4)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(a + b*x**S(2))*(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**p, x), x, (a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))**(p + S(1))/(S(4)*b*(p + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*sqrt(c + d*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4)), x), x, b*x**S(3)*(c + d*x**S(2))**(S(3)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(6)*d*(a + b*x**S(2))) + c**S(2)*(-S(2)*a*d + b*c)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))*atanh(sqrt(d)*x/sqrt(c + d*x**S(2)))/(S(16)*d**(S(5)/2)*(a + b*x**S(2))) - c*x*sqrt(c + d*x**S(2))*(-S(2)*a*d + b*c)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(16)*d**S(2)*(a + b*x**S(2))) - x**S(3)*sqrt(c + d*x**S(2))*(-S(2)*a*d + b*c)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(8)*d*(a + b*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*sqrt(c + d*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4)), x), x, (c + d*x**S(2))**(S(3)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(5)*d) - (c + d*x**S(2))**(S(3)/2)*(-S(2)*a*d + S(2)*b*c)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(15)*d**S(2)*(a + b*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(c + d*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4)), x), x, b*x*(c + d*x**S(2))**(S(3)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(4)*d*(a + b*x**S(2))) - c*(-S(4)*a*d + b*c)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))*atanh(sqrt(d)*x/sqrt(c + d*x**S(2)))/(S(8)*d**(S(3)/2)*(a + b*x**S(2))) - x*sqrt(c + d*x**S(2))*(-S(4)*a*d + b*c)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(8)*d*(a + b*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(c + d*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/x, x), x, -a*sqrt(c)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))*atanh(sqrt(c + d*x**S(2))/sqrt(c))/(a + b*x**S(2)) + a*sqrt(c + d*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(a + b*x**S(2)) + b*(c + d*x**S(2))**(S(3)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(3)*d*(a + b*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(c + d*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/x**S(2), x), x, -a*(c + d*x**S(2))**(S(3)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(c*x*(a + b*x**S(2))) + (S(2)*a*d + b*c)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))*atanh(sqrt(d)*x/sqrt(c + d*x**S(2)))/(S(2)*sqrt(d)*(a + b*x**S(2))) + x*sqrt(c + d*x**S(2))*(S(2)*a*d + b*c)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(2)*c*(a + b*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(c + d*x**S(2))*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/x**S(3), x), x, -a*(c + d*x**S(2))**(S(3)/2)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(2)*c*x**S(2)*(a + b*x**S(2))) + sqrt(c + d*x**S(2))*(a*d + S(2)*b*c)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))/(S(2)*c*(a + b*x**S(2))) - (a*d + S(2)*b*c)*sqrt(a**S(2) + S(2)*a*b*x**S(2) + b**S(2)*x**S(4))*atanh(sqrt(c + d*x**S(2))/sqrt(c))/(S(2)*sqrt(c)*(a + b*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*(A + B*x**S(2))*(a + b*x**S(2) + c*x**S(4))**S(3), x), x, A*a**S(3)*x**S(4)/S(4) + B*c**S(3)*x**S(18)/S(18) + a**S(2)*x**S(6)*(S(3)*A*b + B*a)/S(6) + S(3)*a*x**S(8)*(A*(a*c + b**S(2)) + B*a*b)/S(8) + c**S(2)*x**S(16)*(A*c + S(3)*B*b)/S(16) + S(3)*c*x**S(14)*(A*b*c + B*a*c + B*b**S(2))/S(14) + x**S(12)*(A*a*c**S(2)/S(4) + A*b**S(2)*c/S(4) + B*a*b*c/S(2) + B*b**S(3)/S(12)) + x**S(10)*(A*(S(6)*a*b*c + b**S(3))/S(10) + S(3)*B*a*(a*c + b**S(2))/S(10)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(A + B*x**S(2))*(a + b*x**S(2) + c*x**S(4))**S(3), x), x, A*a**S(3)*x**S(3)/S(3) + B*c**S(3)*x**S(17)/S(17) + a**S(2)*x**S(5)*(S(3)*A*b + B*a)/S(5) + S(3)*a*x**S(7)*(A*(a*c + b**S(2)) + B*a*b)/S(7) + c**S(2)*x**S(15)*(A*c + S(3)*B*b)/S(15) + S(3)*c*x**S(13)*(A*b*c + B*a*c + B*b**S(2))/S(13) + x**S(11)*(S(3)*A*a*c**S(2)/S(11) + S(3)*A*b**S(2)*c/S(11) + S(6)*B*a*b*c/S(11) + B*b**S(3)/S(11)) + x**S(9)*(A*(S(6)*a*b*c + b**S(3))/S(9) + B*a*(a*c + b**S(2))/S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(A + B*x**S(2))*(a + b*x**S(2) + c*x**S(4))**S(3), x), x, A*a**S(3)*x**S(2)/S(2) + B*c**S(3)*x**S(16)/S(16) + a**S(2)*x**S(4)*(S(3)*A*b + B*a)/S(4) + a*x**S(6)*(A*(a*c + b**S(2)) + B*a*b)/S(2) + c**S(2)*x**S(14)*(A*c + S(3)*B*b)/S(14) + c*x**S(12)*(A*b*c + B*a*c + B*b**S(2))/S(4) + x**S(10)*(S(3)*A*a*c**S(2)/S(10) + S(3)*A*b**S(2)*c/S(10) + S(3)*B*a*b*c/S(5) + B*b**S(3)/S(10)) + x**S(8)*(A*(S(6)*a*b*c + b**S(3))/S(8) + S(3)*B*a*(a*c + b**S(2))/S(8)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((A + B*x**S(2))*(a + b*x**S(2) + c*x**S(4))**S(3), x), x, A*a**S(3)*x + B*c**S(3)*x**S(15)/S(15) + a**S(2)*x**S(3)*(S(3)*A*b + B*a)/S(3) + S(3)*a*x**S(5)*(A*(a*c + b**S(2)) + B*a*b)/S(5) + c**S(2)*x**S(13)*(A*c + S(3)*B*b)/S(13) + S(3)*c*x**S(11)*(A*b*c + B*a*c + B*b**S(2))/S(11) + x**S(9)*(A*a*c**S(2)/S(3) + A*b**S(2)*c/S(3) + S(2)*B*a*b*c/S(3) + B*b**S(3)/S(9)) + x**S(7)*(A*(S(6)*a*b*c + b**S(3))/S(7) + S(3)*B*a*(a*c + b**S(2))/S(7)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((A + B*x**S(2))*(a + b*x**S(2) + c*x**S(4))**S(3)/x, x), x, A*a**S(3)*log(x) + B*c**S(3)*x**S(14)/S(14) + a**S(2)*x**S(2)*(S(3)*A*b + B*a)/S(2) + S(3)*a*x**S(4)*(A*(a*c + b**S(2)) + B*a*b)/S(4) + c**S(2)*x**S(12)*(A*c + S(3)*B*b)/S(12) + S(3)*c*x**S(10)*(A*b*c + B*a*c + B*b**S(2))/S(10) + x**S(8)*(S(3)*A*a*c**S(2)/S(8) + S(3)*A*b**S(2)*c/S(8) + S(3)*B*a*b*c/S(4) + B*b**S(3)/S(8)) + x**S(6)*(A*(S(6)*a*b*c + b**S(3))/S(6) + B*a*(a*c + b**S(2))/S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((A + B*x**S(2))*(a + b*x**S(2) + c*x**S(4))**S(3)/x**S(2), x), x, -A*a**S(3)/x + B*c**S(3)*x**S(13)/S(13) + a**S(2)*x*(S(3)*A*b + B*a) + a*x**S(3)*(A*(a*c + b**S(2)) + B*a*b) + c**S(2)*x**S(11)*(A*c + S(3)*B*b)/S(11) + c*x**S(9)*(A*b*c + B*a*c + B*b**S(2))/S(3) + x**S(7)*(S(3)*A*a*c**S(2)/S(7) + S(3)*A*b**S(2)*c/S(7) + S(6)*B*a*b*c/S(7) + B*b**S(3)/S(7)) + x**S(5)*(A*(S(6)*a*b*c + b**S(3))/S(5) + S(3)*B*a*(a*c + b**S(2))/S(5)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((A + B*x**S(2))*(a + b*x**S(2) + c*x**S(4))**S(3)/x**S(3), x), x, -A*a**S(3)/(S(2)*x**S(2)) + B*c**S(3)*x**S(12)/S(12) + a**S(2)*(S(3)*A*b + B*a)*log(x) + S(3)*a*x**S(2)*(A*(a*c + b**S(2)) + B*a*b)/S(2) + c**S(2)*x**S(10)*(A*c + S(3)*B*b)/S(10) + S(3)*c*x**S(8)*(A*b*c + B*a*c + B*b**S(2))/S(8) + x**S(6)*(A*a*c**S(2)/S(2) + A*b**S(2)*c/S(2) + B*a*b*c + B*b**S(3)/S(6)) + x**S(4)*(A*(S(6)*a*b*c + b**S(3))/S(4) + S(3)*B*a*(a*c + b**S(2))/S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)*(A + B*x**S(2))/(a + b*x**S(2) + c*x**S(4)), x), x, B*x**S(4)/(S(4)*c) - x**S(2)*(-A*c + B*b)/(S(2)*c**S(2)) + (-A*b*c - B*a*c + B*b**S(2))*log(a + b*x**S(2) + c*x**S(4))/(S(4)*c**S(3)) + (S(2)*A*a*c**S(2) - A*b**S(2)*c - S(3)*B*a*b*c + B*b**S(3))*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*c**S(3)*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*(A + B*x**S(2))/(a + b*x**S(2) + c*x**S(4)), x), x, B*x**S(2)/(S(2)*c) - (-A*c + B*b)*log(a + b*x**S(2) + c*x**S(4))/(S(4)*c**S(2)) - (-A*b*c - S(2)*B*a*c + B*b**S(2))*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*c**S(2)*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(A + B*x**S(2))/(a + b*x**S(2) + c*x**S(4)), x), x, B*log(a + b*x**S(2) + c*x**S(4))/(S(4)*c) + (-S(2)*A*c + B*b)*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*c*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((A + B*x**S(2))/(x*(a + b*x**S(2) + c*x**S(4))), x), x, A*log(x)/a - A*log(a + b*x**S(2) + c*x**S(4))/(S(4)*a) + (A*b - S(2)*B*a)*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*a*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((A + B*x**S(2))/(x**S(3)*(a + b*x**S(2) + c*x**S(4))), x), x, -A/(S(2)*a*x**S(2)) - (A*b - B*a)*log(x)/a**S(2) + (A*b - B*a)*log(a + b*x**S(2) + c*x**S(4))/(S(4)*a**S(2)) - (-S(2)*A*a*c + A*b**S(2) - B*a*b)*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*a**S(2)*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)*(A + B*x**S(2))/(a + b*x**S(2) + c*x**S(4)), x), x, B*x**S(3)/(S(3)*c) - x*(-A*c + B*b)/c**S(2) + sqrt(S(2))*(-A*b*c - B*a*c + B*b**S(2) + (S(2)*A*a*c**S(2) - A*b**S(2)*c - S(3)*B*a*b*c + B*b**S(3))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*c**(S(5)/2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))) + sqrt(S(2))*(-A*b*c - B*a*c + B*b**S(2) - (S(2)*A*a*c**S(2) - A*b**S(2)*c - S(3)*B*a*b*c + B*b**S(3))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*c**(S(5)/2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(A + B*x**S(2))/(a + b*x**S(2) + c*x**S(4)), x), x, B*x/c - sqrt(S(2))*(-A*c + B*b + (-A*b*c - S(2)*B*a*c + B*b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*c**(S(3)/2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))) - sqrt(S(2))*(-A*c + B*b - (-A*b*c - S(2)*B*a*c + B*b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*c**(S(3)/2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((A + B*x**S(2))/(a + b*x**S(2) + c*x**S(4)), x), x, sqrt(S(2))*(B - (-S(2)*A*c + B*b)/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*sqrt(c)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))) + sqrt(S(2))*(B + (-S(2)*A*c + B*b)/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*sqrt(c)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((A + B*x**S(2))/(x**S(2)*(a + b*x**S(2) + c*x**S(4))), x), x, -A/(a*x) - sqrt(S(2))*sqrt(c)*(A - (A*b - S(2)*B*a)/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*a*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))) - sqrt(S(2))*sqrt(c)*(A + (A*b - S(2)*B*a)/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*a*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((A + B*x**S(2))/(x**S(4)*(a + b*x**S(2) + c*x**S(4))), x), x, -A/(S(3)*a*x**S(3)) + sqrt(S(2))*sqrt(c)*(-A*(-S(2)*a*c + b**S(2) - b*sqrt(-S(4)*a*c + b**S(2))) + B*a*(b - sqrt(-S(4)*a*c + b**S(2))))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*a**S(2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*sqrt(-S(4)*a*c + b**S(2))) - sqrt(S(2))*sqrt(c)*(-A*(-S(2)*a*c + b**S(2) + b*sqrt(-S(4)*a*c + b**S(2))) + B*a*(b + sqrt(-S(4)*a*c + b**S(2))))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*a**S(2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*sqrt(-S(4)*a*c + b**S(2))) + (A*b - B*a)/(a**S(2)*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(7)*(A + B*x**S(2))/(a + b*x**S(2) + c*x**S(4))**S(2), x), x, -x**S(4)*(a*(-S(2)*A*c + B*b) + x**S(2)*(-A*b*c - S(2)*B*a*c + B*b**S(2)))/(S(2)*c*(-S(4)*a*c + b**S(2))*(a + b*x**S(2) + c*x**S(4))) + x**S(2)*(-A*b*c - S(6)*B*a*c + S(2)*B*b**S(2))/(S(2)*c**S(2)*(-S(4)*a*c + b**S(2))) - (-A*c + S(2)*B*b)*log(a + b*x**S(2) + c*x**S(4))/(S(4)*c**S(3)) - (S(6)*A*a*b*c**S(2) - A*b**S(3)*c + S(12)*B*a**S(2)*c**S(2) - S(12)*B*a*b**S(2)*c + S(2)*B*b**S(4))*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*c**S(3)*(-S(4)*a*c + b**S(2))**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)*(A + B*x**S(2))/(a + b*x**S(2) + c*x**S(4))**S(2), x), x, B*log(a + b*x**S(2) + c*x**S(4))/(S(4)*c**S(2)) - x**S(2)*(a*(-S(2)*A*c + B*b) + x**S(2)*(-A*b*c - S(2)*B*a*c + B*b**S(2)))/(S(2)*c*(-S(4)*a*c + b**S(2))*(a + b*x**S(2) + c*x**S(4))) + (S(4)*A*a*c**S(2) - S(6)*B*a*b*c + B*b**S(3))*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*c**S(2)*(-S(4)*a*c + b**S(2))**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*(A + B*x**S(2))/(a + b*x**S(2) + c*x**S(4))**S(2), x), x, (A + B*x**S(2))*(S(2)*a + b*x**S(2))/((-S(8)*a*c + S(2)*b**S(2))*(a + b*x**S(2) + c*x**S(4))) - (A*b - S(2)*B*a)*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(-S(4)*a*c + b**S(2))**(S(3)/2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(A + B*x**S(2))/(a + b*x**S(2) + c*x**S(4))**S(2), x), x, -(-S(2)*A*c + B*b)*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(-S(4)*a*c + b**S(2))**(S(3)/2) - (A*b - S(2)*B*a - x**S(2)*(-S(2)*A*c + B*b))/((-S(8)*a*c + S(2)*b**S(2))*(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((A + B*x**S(2))/(x*(a + b*x**S(2) + c*x**S(4))**S(2)), x), x, A*log(x)/a**S(2) - A*log(a + b*x**S(2) + c*x**S(4))/(S(4)*a**S(2)) - (-A*(-S(2)*a*c + b**S(2)) + B*a*b - c*x**S(2)*(A*b - S(2)*B*a))/(S(2)*a*(-S(4)*a*c + b**S(2))*(a + b*x**S(2) + c*x**S(4))) + (A*(-S(6)*a*b*c + b**S(3)) + S(4)*B*a**S(2)*c)*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*a**S(2)*(-S(4)*a*c + b**S(2))**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((A + B*x**S(2))/(x**S(3)*(a + b*x**S(2) + c*x**S(4))**S(2)), x), x, -(-A*(-S(2)*a*c + b**S(2)) + B*a*b - c*x**S(2)*(A*b - S(2)*B*a))/(S(2)*a*x**S(2)*(-S(4)*a*c + b**S(2))*(a + b*x**S(2) + c*x**S(4))) - (-S(6)*A*a*c + S(2)*A*b**S(2) - B*a*b)/(S(2)*a**S(2)*x**S(2)*(-S(4)*a*c + b**S(2))) - (S(2)*A*b - B*a)*log(x)/a**S(3) + (S(2)*A*b - B*a)*log(a + b*x**S(2) + c*x**S(4))/(S(4)*a**S(3)) + (-S(2)*A*(S(6)*a**S(2)*c**S(2) - S(6)*a*b**S(2)*c + b**S(4)) + B*a*b*(-S(6)*a*c + b**S(2)))*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*a**S(3)*(-S(4)*a*c + b**S(2))**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(6)*(A + B*x**S(2))/(a + b*x**S(2) + c*x**S(4))**S(2), x), x, -x**S(5)*(A*b - S(2)*B*a - x**S(2)*(-S(2)*A*c + B*b))/((-S(8)*a*c + S(2)*b**S(2))*(a + b*x**S(2) + c*x**S(4))) - x**S(3)*(-S(2)*A*c + B*b)/(S(2)*c*(-S(4)*a*c + b**S(2))) + x*(-A*b*c - S(10)*B*a*c + S(3)*B*b**S(2))/(S(2)*c**S(2)*(-S(4)*a*c + b**S(2))) - sqrt(S(2))*(S(6)*A*a*c**S(2) - A*b**S(2)*c - S(13)*B*a*b*c + S(3)*B*b**S(3) + (S(8)*A*a*b*c**S(2) - A*b**S(3)*c + S(20)*B*a**S(2)*c**S(2) - S(19)*B*a*b**S(2)*c + S(3)*B*b**S(4))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(4)*c**(S(5)/2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))) - sqrt(S(2))*(S(6)*A*a*c**S(2) - A*b**S(2)*c - S(13)*B*a*b*c + S(3)*B*b**S(3) - (S(8)*A*a*b*c**S(2) - A*b**S(3)*c + S(20)*B*a**S(2)*c**S(2) - S(19)*B*a*b**S(2)*c + S(3)*B*b**S(4))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(4)*c**(S(5)/2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)*(A + B*x**S(2))/(a + b*x**S(2) + c*x**S(4))**S(2), x), x, -x**S(3)*(A*b - S(2)*B*a - x**S(2)*(-S(2)*A*c + B*b))/((-S(8)*a*c + S(2)*b**S(2))*(a + b*x**S(2) + c*x**S(4))) - x*(-S(2)*A*c + B*b)/(S(2)*c*(-S(4)*a*c + b**S(2))) + sqrt(S(2))*(A*b*c - S(6)*B*a*c + B*b**S(2) + (S(4)*A*a*c**S(2) + A*b**S(2)*c - S(8)*B*a*b*c + B*b**S(3))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(4)*c**(S(3)/2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))) + sqrt(S(2))*(A*b*c - S(6)*B*a*c + B*b**S(2) - (S(4)*A*a*c**S(2) + A*b**S(2)*c - S(8)*B*a*b*c + B*b**S(3))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(4)*c**(S(3)/2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(A + B*x**S(2))/(a + b*x**S(2) + c*x**S(4))**S(2), x), x, -x*(A*b - S(2)*B*a - x**S(2)*(-S(2)*A*c + B*b))/((-S(8)*a*c + S(2)*b**S(2))*(a + b*x**S(2) + c*x**S(4))) + sqrt(S(2))*(-S(2)*A*c + B*b + (-S(4)*A*b*c + S(4)*B*a*c + B*b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(4)*sqrt(c)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))) + sqrt(S(2))*(-S(2)*A*c + B*b - (-S(4)*A*b*c + S(4)*B*a*c + B*b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(4)*sqrt(c)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((A + B*x**S(2))/(a + b*x**S(2) + c*x**S(4))**S(2), x), x, sqrt(S(2))*sqrt(c)*(A*b - S(2)*B*a - (-S(12)*A*a*c + A*b**S(2) + S(4)*B*a*b)/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(4)*a*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))) + sqrt(S(2))*sqrt(c)*(A*b - S(2)*B*a + (A*(-S(12)*a*c + b**S(2)) + S(4)*B*a*b)/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(4)*a*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))) - x*(-A*(-S(2)*a*c + b**S(2)) + B*a*b - c*x**S(2)*(A*b - S(2)*B*a))/(S(2)*a*(-S(4)*a*c + b**S(2))*(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((A + B*x**S(2))/(x**S(2)*(a + b*x**S(2) + c*x**S(4))**S(2)), x), x, -(-A*(-S(2)*a*c + b**S(2)) + B*a*b - c*x**S(2)*(A*b - S(2)*B*a))/(S(2)*a*x*(-S(4)*a*c + b**S(2))*(a + b*x**S(2) + c*x**S(4))) - sqrt(S(2))*sqrt(c)*(-S(10)*A*a*c + S(3)*A*b**S(2) - B*a*b + (-A*(-S(16)*a*b*c + S(3)*b**S(3)) + B*a*(-S(12)*a*c + b**S(2)))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(4)*a**S(2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))) + sqrt(S(2))*sqrt(c)*(-A*(-S(16)*a*b*c - S(10)*a*c*sqrt(-S(4)*a*c + b**S(2)) + S(3)*b**S(3) + S(3)*b**S(2)*sqrt(-S(4)*a*c + b**S(2))) + B*a*(-S(12)*a*c + b**S(2) + b*sqrt(-S(4)*a*c + b**S(2))))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(4)*a**S(2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)) - (-S(10)*A*a*c + S(3)*A*b**S(2) - B*a*b)/(S(2)*a**S(2)*x*(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((A + B*x**S(2))/(x**S(4)*(a + b*x**S(2) + c*x**S(4))**S(2)), x), x, -(-A*(-S(2)*a*c + b**S(2)) + B*a*b - c*x**S(2)*(A*b - S(2)*B*a))/(S(2)*a*x**S(3)*(-S(4)*a*c + b**S(2))*(a + b*x**S(2) + c*x**S(4))) - (-S(14)*A*a*c + S(5)*A*b**S(2) - S(3)*B*a*b)/(S(6)*a**S(2)*x**S(3)*(-S(4)*a*c + b**S(2))) + sqrt(S(2))*sqrt(c)*(-A*(S(28)*a**S(2)*c**S(2) - S(29)*a*b**S(2)*c + S(19)*a*b*c*sqrt(-S(4)*a*c + b**S(2)) + S(5)*b**S(4) - S(5)*b**S(3)*sqrt(-S(4)*a*c + b**S(2))) + B*a*(-S(16)*a*b*c + S(10)*a*c*sqrt(-S(4)*a*c + b**S(2)) + S(3)*b**S(3) - S(3)*b**S(2)*sqrt(-S(4)*a*c + b**S(2))))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(4)*a**S(3)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)) - sqrt(S(2))*sqrt(c)*(-A*(S(28)*a**S(2)*c**S(2) - S(29)*a*b**S(2)*c - S(19)*a*b*c*sqrt(-S(4)*a*c + b**S(2)) + S(5)*b**S(4) + S(5)*b**S(3)*sqrt(-S(4)*a*c + b**S(2))) + B*a*(-S(16)*a*b*c - S(10)*a*c*sqrt(-S(4)*a*c + b**S(2)) + S(3)*b**S(3) + S(3)*b**S(2)*sqrt(-S(4)*a*c + b**S(2))))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(4)*a**S(3)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)) - (-A*(-S(19)*a*b*c + S(5)*b**S(3)) + B*a*(-S(10)*a*c + S(3)*b**S(2)))/(S(2)*a**S(3)*x*(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(11)*(A + B*x**S(2))/(a + b*x**S(2) + c*x**S(4))**S(3), x), x, -x**S(8)*(a*(-S(2)*A*c + B*b) + x**S(2)*(-A*b*c - S(2)*B*a*c + B*b**S(2)))/(S(4)*c*(-S(4)*a*c + b**S(2))*(a + b*x**S(2) + c*x**S(4))**S(2)) - x**S(4)*(a*(S(16)*A*a*c**S(2) - A*b**S(2)*c - S(18)*B*a*b*c + S(3)*B*b**S(3)) + x**S(2)*(S(10)*A*a*b*c**S(2) - A*b**S(3)*c + S(20)*B*a**S(2)*c**S(2) - S(20)*B*a*b**S(2)*c + S(3)*B*b**S(4)))/(S(4)*c**S(2)*(-S(4)*a*c + b**S(2))**S(2)*(a + b*x**S(2) + c*x**S(4))) - x**S(2)*(A*(-S(7)*a*b*c + b**S(3)) + S(3)*B*(-S(10)*a**S(2)*c + S(7)*a*b**S(2) - b**S(4)/c))/(S(2)*c**S(2)*(-S(4)*a*c + b**S(2))**S(2)) - (-A*c + S(3)*B*b)*log(a + b*x**S(2) + c*x**S(4))/(S(4)*c**S(4)) - (-S(30)*A*a**S(2)*b*c**S(3) + S(10)*A*a*b**S(3)*c**S(2) - A*b**S(5)*c - S(60)*B*a**S(3)*c**S(3) + S(90)*B*a**S(2)*b**S(2)*c**S(2) - S(30)*B*a*b**S(4)*c + S(3)*B*b**S(6))*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*c**S(4)*(-S(4)*a*c + b**S(2))**(S(5)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(9)*(A + B*x**S(2))/(a + b*x**S(2) + c*x**S(4))**S(3), x), x, B*log(a + b*x**S(2) + c*x**S(4))/(S(4)*c**S(3)) - x**S(6)*(a*(-S(2)*A*c + B*b) + x**S(2)*(-A*b*c - S(2)*B*a*c + B*b**S(2)))/(S(4)*c*(-S(4)*a*c + b**S(2))*(a + b*x**S(2) + c*x**S(4))**S(2)) - x**S(2)*(S(2)*a*(S(6)*A*a*c**S(2) - S(7)*B*a*b*c + B*b**S(3)) + x**S(2)*(S(6)*A*a*b*c**S(2) + S(16)*B*a**S(2)*c**S(2) - S(15)*B*a*b**S(2)*c + S(2)*B*b**S(4)))/(S(4)*c**S(2)*(-S(4)*a*c + b**S(2))**S(2)*(a + b*x**S(2) + c*x**S(4))) + (-S(12)*A*a**S(2)*c**S(3) + S(30)*B*a**S(2)*b*c**S(2) - S(10)*B*a*b**S(3)*c + B*b**S(5))*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*c**S(3)*(-S(4)*a*c + b**S(2))**(S(5)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(7)*(A + B*x**S(2))/(a + b*x**S(2) + c*x**S(4))**S(3), x), x, S(3)*a*(A*b - S(2)*B*a)*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(-S(4)*a*c + b**S(2))**(S(5)/2) - x**S(6)*(A*b - S(2)*B*a - x**S(2)*(-S(2)*A*c + B*b))/((-S(16)*a*c + S(4)*b**S(2))*(a + b*x**S(2) + c*x**S(4))**S(2)) + x**S(2)*(S(2)*a + b*x**S(2))*(S(3)*A*b - S(6)*B*a)/(S(4)*(-S(4)*a*c + b**S(2))**S(2)*(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)*(A + B*x**S(2))/(a + b*x**S(2) + c*x**S(4))**S(3), x), x, -x**S(4)*(A*b - S(2)*B*a - x**S(2)*(-S(2)*A*c + B*b))/((-S(16)*a*c + S(4)*b**S(2))*(a + b*x**S(2) + c*x**S(4))**S(2)) + (S(2)*a + b*x**S(2))*(S(2)*A*b - S(4)*B*a + x**S(2)*(-S(2)*A*c + B*b))/(S(4)*(-S(4)*a*c + b**S(2))**S(2)*(a + b*x**S(2) + c*x**S(4))) + (-A*(S(2)*a*c + b**S(2)) + S(3)*B*a*b)*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(-S(4)*a*c + b**S(2))**(S(5)/2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*(A + B*x**S(2))/(a + b*x**S(2) + c*x**S(4))**S(3), x), x, -(-S(3)*A*b*c + S(2)*B*a*c + B*b**S(2))*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(-S(4)*a*c + b**S(2))**(S(5)/2) + (b + S(2)*c*x**S(2))*(-S(3)*A*b*c + S(2)*B*a*c + B*b**S(2))/(S(4)*c*(-S(4)*a*c + b**S(2))**S(2)*(a + b*x**S(2) + c*x**S(4))) - (a*(-S(2)*A*c + B*b) + x**S(2)*(-A*b*c - S(2)*B*a*c + B*b**S(2)))/(S(4)*c*(-S(4)*a*c + b**S(2))*(a + b*x**S(2) + c*x**S(4))**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(A + B*x**S(2))/(a + b*x**S(2) + c*x**S(4))**S(3), x), x, S(3)*c*(-S(2)*A*c + B*b)*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(-S(4)*a*c + b**S(2))**(S(5)/2) - (b + S(2)*c*x**S(2))*(-S(6)*A*c + S(3)*B*b)/(S(4)*(-S(4)*a*c + b**S(2))**S(2)*(a + b*x**S(2) + c*x**S(4))) - (A*b - S(2)*B*a - x**S(2)*(-S(2)*A*c + B*b))/((-S(16)*a*c + S(4)*b**S(2))*(a + b*x**S(2) + c*x**S(4))**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((A + B*x**S(2))/(x*(a + b*x**S(2) + c*x**S(4))**S(3)), x), x, A*log(x)/a**S(3) - A*log(a + b*x**S(2) + c*x**S(4))/(S(4)*a**S(3)) - (-A*(-S(2)*a*c + b**S(2)) + B*a*b - c*x**S(2)*(A*b - S(2)*B*a))/(S(4)*a*(-S(4)*a*c + b**S(2))*(a + b*x**S(2) + c*x**S(4))**S(2)) + (A*(S(16)*a**S(2)*c**S(2) - S(15)*a*b**S(2)*c + S(2)*b**S(4)) + S(6)*B*a**S(2)*b*c + S(2)*c*x**S(2)*(A*(-S(7)*a*b*c + b**S(3)) + S(6)*B*a**S(2)*c))/(S(4)*a**S(2)*(-S(4)*a*c + b**S(2))**S(2)*(a + b*x**S(2) + c*x**S(4))) - (-A*(S(30)*a**S(2)*b*c**S(2) - S(10)*a*b**S(3)*c + b**S(5)) + S(12)*B*a**S(3)*c**S(2))*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*a**S(3)*(-S(4)*a*c + b**S(2))**(S(5)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((A + B*x**S(2))/(x**S(3)*(a + b*x**S(2) + c*x**S(4))**S(3)), x), x, -(-A*(-S(2)*a*c + b**S(2)) + B*a*b - c*x**S(2)*(A*b - S(2)*B*a))/(S(4)*a*x**S(2)*(-S(4)*a*c + b**S(2))*(a + b*x**S(2) + c*x**S(4))**S(2)) - (-A*(S(20)*a**S(2)*c**S(2) - S(20)*a*b**S(2)*c + S(3)*b**S(4)) + B*a*b*(-S(10)*a*c + b**S(2)) + c*x**S(2)*(-S(3)*A*(-S(6)*a*b*c + b**S(3)) + B*a*(-S(16)*a*c + b**S(2))))/(S(4)*a**S(2)*x**S(2)*(-S(4)*a*c + b**S(2))**S(2)*(a + b*x**S(2) + c*x**S(4))) + (-S(3)*A*(S(10)*a**S(2)*c**S(2) - S(7)*a*b**S(2)*c + b**S(4)) + B*a*b*(-S(7)*a*c + b**S(2)))/(S(2)*a**S(3)*x**S(2)*(-S(4)*a*c + b**S(2))**S(2)) - (S(3)*A*b - B*a)*log(x)/a**S(4) + (S(3)*A*b - B*a)*log(a + b*x**S(2) + c*x**S(4))/(S(4)*a**S(4)) + (-S(3)*A*(-S(20)*a**S(3)*c**S(3) + S(30)*a**S(2)*b**S(2)*c**S(2) - S(10)*a*b**S(4)*c + b**S(6)) + B*a*b*(S(30)*a**S(2)*c**S(2) - S(10)*a*b**S(2)*c + b**S(4)))*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*a**S(4)*(-S(4)*a*c + b**S(2))**(S(5)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(8)*(A + B*x**S(2))/(a + b*x**S(2) + c*x**S(4))**S(3), x), x, -x**S(7)*(A*b - S(2)*B*a - x**S(2)*(-S(2)*A*c + B*b))/((-S(16)*a*c + S(4)*b**S(2))*(a + b*x**S(2) + c*x**S(4))**S(2)) - x**S(5)*(-S(4)*A*a*c + S(7)*A*b**S(2) - S(12)*B*a*b + x**S(2)*(S(12)*A*b*c - S(28)*B*a*c + B*b**S(2)))/(S(8)*(-S(4)*a*c + b**S(2))**S(2)*(a + b*x**S(2) + c*x**S(4))) + x**S(3)*(S(12)*A*b*c - S(28)*B*a*c + B*b**S(2))/(S(8)*c*(-S(4)*a*c + b**S(2))**S(2)) - x*(S(20)*A*a*c**S(2) + A*b**S(2)*c - S(24)*B*a*b*c + S(3)*B*b**S(3))/(S(8)*c**S(2)*(-S(4)*a*c + b**S(2))**S(2)) + sqrt(S(2))*(-S(16)*A*a*b*c**S(2) + A*b**S(3)*c + S(84)*B*a**S(2)*c**S(2) - S(27)*B*a*b**S(2)*c + S(3)*B*b**S(4) + (-S(40)*A*a**S(2)*c**S(3) - S(18)*A*a*b**S(2)*c**S(2) + A*b**S(4)*c + S(132)*B*a**S(2)*b*c**S(2) - S(33)*B*a*b**S(3)*c + S(3)*B*b**S(5))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(16)*c**(S(5)/2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**S(2)) + sqrt(S(2))*(-S(16)*A*a*b*c**S(2) + A*b**S(3)*c + S(84)*B*a**S(2)*c**S(2) - S(27)*B*a*b**S(2)*c + S(3)*B*b**S(4) - (-S(40)*A*a**S(2)*c**S(3) - S(18)*A*a*b**S(2)*c**S(2) + A*b**S(4)*c + S(132)*B*a**S(2)*b*c**S(2) - S(33)*B*a*b**S(3)*c + S(3)*B*b**S(5))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(16)*c**(S(5)/2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(6)*(A + B*x**S(2))/(a + b*x**S(2) + c*x**S(4))**S(3), x), x, -x**S(5)*(A*b - S(2)*B*a - x**S(2)*(-S(2)*A*c + B*b))/((-S(16)*a*c + S(4)*b**S(2))*(a + b*x**S(2) + c*x**S(4))**S(2)) - x**S(3)*(S(4)*A*a*c + S(5)*A*b**S(2) - S(12)*B*a*b - x**S(2)*(-S(12)*A*b*c + S(20)*B*a*c + B*b**S(2)))/(S(8)*(-S(4)*a*c + b**S(2))**S(2)*(a + b*x**S(2) + c*x**S(4))) - x*(-S(12)*A*b*c + S(20)*B*a*c + B*b**S(2))/(S(8)*c*(-S(4)*a*c + b**S(2))**S(2)) + sqrt(S(2))*(S(12)*A*a*c**S(2) + S(3)*A*b**S(2)*c - S(16)*B*a*b*c + B*b**S(3) + (S(36)*A*a*b*c**S(2) + S(3)*A*b**S(3)*c - S(40)*B*a**S(2)*c**S(2) - S(18)*B*a*b**S(2)*c + B*b**S(4))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(16)*c**(S(3)/2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**S(2)) + sqrt(S(2))*(S(12)*A*a*c**S(2) + S(3)*A*b**S(2)*c - S(16)*B*a*b*c + B*b**S(3) - (S(36)*A*a*b*c**S(2) + S(3)*A*b**S(3)*c - S(40)*B*a**S(2)*c**S(2) - S(18)*B*a*b**S(2)*c + B*b**S(4))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(16)*c**(S(3)/2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)*(A + B*x**S(2))/(a + b*x**S(2) + c*x**S(4))**S(3), x), x, -x**S(3)*(A*b - S(2)*B*a - x**S(2)*(-S(2)*A*c + B*b))/((-S(16)*a*c + S(4)*b**S(2))*(a + b*x**S(2) + c*x**S(4))**S(2)) + S(3)*x*(-A*(S(4)*a*c + b**S(2)) + S(4)*B*a*b + x**S(2)*(-S(4)*A*b*c + S(4)*B*a*c + B*b**S(2)))/(S(8)*(-S(4)*a*c + b**S(2))**S(2)*(a + b*x**S(2) + c*x**S(4))) + sqrt(S(2))*(-S(12)*A*b*c + S(12)*B*a*c + S(3)*B*b**S(2) + S(3)*(-S(8)*A*a*c**S(2) - S(6)*A*b**S(2)*c + S(12)*B*a*b*c + B*b**S(3))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(16)*sqrt(c)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**S(2)) + sqrt(S(2))*(-S(12)*A*b*c + S(12)*B*a*c + S(3)*B*b**S(2) - S(3)*(-S(8)*A*a*c**S(2) - S(6)*A*b**S(2)*c + S(12)*B*a*b*c + B*b**S(3))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(16)*sqrt(c)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(A + B*x**S(2))/(a + b*x**S(2) + c*x**S(4))**S(3), x), x, -x*(A*b - S(2)*B*a - x**S(2)*(-S(2)*A*c + B*b))/((-S(16)*a*c + S(4)*b**S(2))*(a + b*x**S(2) + c*x**S(4))**S(2)) - sqrt(S(2))*sqrt(c)*(-A*(S(20)*a*c + b**S(2)) + S(12)*B*a*b + (A*(-S(52)*a*b*c + b**S(3)) + S(6)*B*a*(S(4)*a*c + S(3)*b**S(2)))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(16)*a*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**S(2)) - sqrt(S(2))*sqrt(c)*(-A*(S(20)*a*c + b**S(2)) + S(12)*B*a*b - (A*(-S(52)*a*b*c + b**S(3)) + S(6)*B*a*(S(4)*a*c + S(3)*b**S(2)))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(16)*a*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**S(2)) - x*(-A*(S(8)*a*b*c + b**S(3)) + B*a*(-S(4)*a*c + S(7)*b**S(2)) + c*x**S(2)*(-A*(S(20)*a*c + b**S(2)) + S(12)*B*a*b))/(S(8)*a*(-S(4)*a*c + b**S(2))**S(2)*(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((A + B*x**S(2))/(a + b*x**S(2) + c*x**S(4))**S(3), x), x, -x*(-A*(-S(2)*a*c + b**S(2)) + B*a*b - c*x**S(2)*(A*b - S(2)*B*a))/(S(4)*a*(-S(4)*a*c + b**S(2))*(a + b*x**S(2) + c*x**S(4))**S(2)) + sqrt(S(2))*sqrt(c)*(S(3)*A*(-S(8)*a*b*c + b**S(3)) + B*a*(S(20)*a*c + b**S(2)) - (S(3)*A*(S(56)*a**S(2)*c**S(2) - S(10)*a*b**S(2)*c + b**S(4)) + B*a*b*(-S(52)*a*c + b**S(2)))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(16)*a**S(2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**S(2)) + sqrt(S(2))*sqrt(c)*(S(3)*A*(-S(8)*a*b*c + b**S(3)) + B*a*(S(20)*a*c + b**S(2)) + (S(3)*A*(S(56)*a**S(2)*c**S(2) - S(10)*a*b**S(2)*c + b**S(4)) + B*a*b*(-S(52)*a*c + b**S(2)))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(16)*a**S(2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**S(2)) + x*(A*(S(28)*a**S(2)*c**S(2) - S(25)*a*b**S(2)*c + S(3)*b**S(4)) + B*a*b*(S(8)*a*c + b**S(2)) + c*x**S(2)*(S(3)*A*(-S(8)*a*b*c + b**S(3)) + B*a*(S(20)*a*c + b**S(2))))/(S(8)*a**S(2)*(-S(4)*a*c + b**S(2))**S(2)*(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(S(4)*x**S(2) + S(-7))/(x**S(4) - S(5)*x**S(2) + S(4)), x), x, log(-x**S(2) + S(1))/S(2) + S(3)*log(-x**S(2) + S(4))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(4)*x**S(3) - S(7)*x)/(x**S(4) - S(5)*x**S(2) + S(4)), x), x, log(-x**S(2) + S(1))/S(2) + S(3)*log(-x**S(2) + S(4))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(x**S(2) + S(2))/(x**S(4) + x**S(2) + S(1)), x), x, log(x**S(4) + x**S(2) + S(1))/S(4) + sqrt(S(3))*atan(sqrt(S(3))*(S(2)*x**S(2) + S(1))/S(3))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(3) + S(2)*x)/(x**S(4) + x**S(2) + S(1)), x), x, log(x**S(4) + x**S(2) + S(1))/S(4) + sqrt(S(3))*atan(sqrt(S(3))*(S(2)*x**S(2) + S(1))/S(3))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(2)*x**S(3) + S(11)*x)/(x**S(4) + S(2)*x**S(2) + S(3))**S(2), x), x, (S(9)*x**S(2) + S(5))/(S(8)*x**S(4) + S(16)*x**S(2) + S(24)) + S(9)*sqrt(S(2))*atan(sqrt(S(2))*(x**S(2) + S(1))/S(2))/S(16), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*(A + B*x**S(2))*(a + b*x**S(2) + c*x**S(4))**(S(3)/2), x), x, -(a + b*x**S(2) + c*x**S(4))**(S(5)/2)*(-S(12)*A*c + S(7)*B*b - S(10)*B*c*x**S(2))/(S(120)*c**S(2)) + (b + S(2)*c*x**S(2))*(a + b*x**S(2) + c*x**S(4))**(S(3)/2)*(-S(12)*A*b*c - S(4)*B*a*c + S(7)*B*b**S(2))/(S(384)*c**S(3)) - (b + S(2)*c*x**S(2))*(-S(4)*a*c + b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))*(-S(12)*A*b*c - S(4)*B*a*c + S(7)*B*b**S(2))/(S(1024)*c**S(4)) + (-S(4)*a*c + b**S(2))**S(2)*(-S(12)*A*b*c - S(4)*B*a*c + S(7)*B*b**S(2))*atanh((b + S(2)*c*x**S(2))/(S(2)*sqrt(c)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(2048)*c**(S(9)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(A + B*x**S(2))*(a + b*x**S(2) + c*x**S(4))**(S(3)/2), x), x, B*(a + b*x**S(2) + c*x**S(4))**(S(5)/2)/(S(10)*c) - (b + S(2)*c*x**S(2))*(-S(2)*A*c + B*b)*(a + b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(32)*c**S(2)) + (b + S(2)*c*x**S(2))*(-S(2)*A*c + B*b)*(-S(12)*a*c + S(3)*b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))/(S(256)*c**S(3)) - S(3)*(-S(2)*A*c + B*b)*(-S(4)*a*c + b**S(2))**S(2)*atanh((b + S(2)*c*x**S(2))/(S(2)*sqrt(c)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(512)*c**(S(7)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((A + B*x**S(2))*(a + b*x**S(2) + c*x**S(4))**(S(3)/2)/x, x), x, -A*a**(S(3)/2)*atanh((S(2)*a + b*x**S(2))/(S(2)*sqrt(a)*sqrt(a + b*x**S(2) + c*x**S(4))))/S(2) + (a + b*x**S(2) + c*x**S(4))**(S(3)/2)*(S(8)*A*c + S(3)*B*b + S(6)*B*c*x**S(2))/(S(48)*c) - sqrt(a + b*x**S(2) + c*x**S(4))*(-S(64)*A*a*c**S(2) - S(8)*A*b**S(2)*c - S(12)*B*a*b*c + S(3)*B*b**S(3) + S(2)*c*x**S(2)*(-S(8)*A*b*c - S(12)*B*a*c + S(3)*B*b**S(2)))/(S(128)*c**S(2)) + (S(64)*A*a*b*c**S(2) + (-S(4)*a*c + b**S(2))*(-S(8)*A*b*c - S(12)*B*a*c + S(3)*B*b**S(2)))*atanh((b + S(2)*c*x**S(2))/(S(2)*sqrt(c)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(256)*c**(S(5)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((A + B*x**S(2))*(a + b*x**S(2) + c*x**S(4))**(S(3)/2)/x**S(3), x), x, -sqrt(a)*(S(3)*A*b + S(2)*B*a)*atanh((S(2)*a + b*x**S(2))/(S(2)*sqrt(a)*sqrt(a + b*x**S(2) + c*x**S(4))))/S(4) - (S(3)*A - B*x**S(2))*(a + b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(6)*x**S(2)) + sqrt(a + b*x**S(2) + c*x**S(4))*(S(18)*A*b*c + S(8)*B*a*c + B*b**S(2) + S(2)*c*x**S(2)*(S(6)*A*c + B*b))/(S(16)*c) - (-S(24)*A*a*c**S(2) - S(6)*A*b**S(2)*c - S(12)*B*a*b*c + B*b**S(3))*atanh((b + S(2)*c*x**S(2))/(S(2)*sqrt(c)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(32)*c**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((A + B*x**S(2))*(a + b*x**S(2) + c*x**S(4))**(S(3)/2)/x**S(5), x), x, -sqrt(a + b*x**S(2) + c*x**S(4))*(S(3)*A*b + S(6)*B*a - S(3)*x**S(2)*(S(2)*A*c + B*b))/(S(8)*x**S(2)) - (A - B*x**S(2))*(a + b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(4)*x**S(4)) + (S(12)*A*b*c + S(12)*B*a*c + S(3)*B*b**S(2))*atanh((b + S(2)*c*x**S(2))/(S(2)*sqrt(c)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(16)*sqrt(c)) - (S(3)*A*(S(4)*a*c + b**S(2)) + S(12)*B*a*b)*atanh((S(2)*a + b*x**S(2))/(S(2)*sqrt(a)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(16)*sqrt(a)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((A + B*x**S(2))*(a + b*x**S(2) + c*x**S(4))**(S(3)/2), x), x, -a**(S(1)/4)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(S(144)*A*a*b*c**S(2) - S(18)*A*b**S(3)*c + S(84)*B*a**S(2)*c**S(2) - S(57)*B*a*b**S(2)*c + S(8)*B*b**S(4))*elliptic_e(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(315)*c**(S(11)/4)*sqrt(a + b*x**S(2) + c*x**S(4))) + a**(S(1)/4)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(S(144)*A*a*b*c**S(2) - S(18)*A*b**S(3)*c + S(84)*B*a**S(2)*c**S(2) - S(57)*B*a*b**S(2)*c + S(8)*B*b**S(4) + sqrt(a)*sqrt(c)*(S(180)*A*a*c**S(2) - S(9)*A*b**S(2)*c - S(24)*B*a*b*c + S(4)*B*b**S(3)))*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(630)*c**(S(11)/4)*sqrt(a + b*x**S(2) + c*x**S(4))) + x*(a + b*x**S(2) + c*x**S(4))**(S(3)/2)*(S(9)*A*c + S(3)*B*b + S(7)*B*c*x**S(2))/(S(63)*c) - x*sqrt(a + b*x**S(2) + c*x**S(4))*(-S(90)*A*a*c**S(2) - S(9)*A*b**S(2)*c - S(9)*B*a*b*c + S(4)*B*b**S(3) + S(3)*c*x**S(2)*(-S(9)*A*b*c - S(14)*B*a*c + S(4)*B*b**S(2)))/(S(315)*c**S(2)) + x*sqrt(a + b*x**S(2) + c*x**S(4))*(S(144)*A*a*b*c**S(2) - S(18)*A*b**S(3)*c + S(84)*B*a**S(2)*c**S(2) - S(57)*B*a*b**S(2)*c + S(8)*B*b**S(4))/(S(315)*c**(S(5)/2)*(sqrt(a) + sqrt(c)*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((A + B*x**S(2))*(a + b*x**S(2) + c*x**S(4))**(S(3)/2)/x**S(2), x), x, a**(S(1)/4)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(-S(84)*A*a*c**S(2) - S(7)*A*b**S(2)*c - S(16)*B*a*b*c + S(2)*B*b**S(3))*elliptic_e(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(35)*c**(S(7)/4)*sqrt(a + b*x**S(2) + c*x**S(4))) - a**(S(1)/4)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(-S(84)*A*a*c**S(2) - S(7)*A*b**S(2)*c - S(16)*B*a*b*c + S(2)*B*b**S(3) + sqrt(a)*sqrt(c)*(-S(56)*A*b*c - S(20)*B*a*c + B*b**S(2)))*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(70)*c**(S(7)/4)*sqrt(a + b*x**S(2) + c*x**S(4))) - (S(7)*A - B*x**S(2))*(a + b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(7)*x) + x*sqrt(a + b*x**S(2) + c*x**S(4))*(S(49)*A*b*c + S(10)*B*a*c + B*b**S(2) + S(3)*c*x**S(2)*(S(14)*A*c + B*b))/(S(35)*c) - x*sqrt(a + b*x**S(2) + c*x**S(4))*(-S(84)*A*a*c**S(2) - S(7)*A*b**S(2)*c - S(16)*B*a*b*c + S(2)*B*b**S(3))/(S(35)*c**(S(3)/2)*(sqrt(a) + sqrt(c)*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((A + B*x**S(2))*(a + b*x**S(2) + c*x**S(4))**(S(3)/2)/x**S(4), x), x, -a**(S(1)/4)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(S(40)*A*b*c + S(36)*B*a*c + S(3)*B*b**S(2))*elliptic_e(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(15)*c**(S(3)/4)*sqrt(a + b*x**S(2) + c*x**S(4))) + a**(S(1)/4)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(S(40)*A*b*c + S(36)*B*a*c + S(3)*B*b**S(2) + sqrt(c)*(S(5)*A*(S(4)*a*c + S(3)*b**S(2)) + S(24)*B*a*b)/sqrt(a))*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(30)*c**(S(3)/4)*sqrt(a + b*x**S(2) + c*x**S(4))) - sqrt(a + b*x**S(2) + c*x**S(4))*(S(15)*A*b + S(18)*B*a - x**S(2)*(S(10)*A*c + S(3)*B*b))/(S(15)*x) - (S(5)*A - S(3)*B*x**S(2))*(a + b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(15)*x**S(3)) + x*sqrt(a + b*x**S(2) + c*x**S(4))*(S(40)*A*b*c + S(36)*B*a*c + S(3)*B*b**S(2))/(S(15)*sqrt(c)*(sqrt(a) + sqrt(c)*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((A + B*x**S(2))*(a + b*x**S(2) + c*x**S(4))**(S(3)/2)/x**S(6), x), x, -sqrt(a + b*x**S(2) + c*x**S(4))*(S(3)*A*b + S(10)*B*a - x**S(2)*(S(18)*A*c + S(15)*B*b))/(S(15)*x**S(3)) - (S(3)*A - S(5)*B*x**S(2))*(a + b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(15)*x**S(5)) + sqrt(c)*x*(S(3)*A*(S(12)*a*c + b**S(2)) + S(40)*B*a*b)*sqrt(a + b*x**S(2) + c*x**S(4))/(S(15)*a*(sqrt(a) + sqrt(c)*x**S(2))) - (S(3)*A*(S(12)*a*c + b**S(2)) + S(40)*B*a*b)*sqrt(a + b*x**S(2) + c*x**S(4))/(S(15)*a*x) - c**(S(1)/4)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(S(3)*A*(S(12)*a*c + b**S(2)) + S(40)*B*a*b)*elliptic_e(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(15)*a**(S(3)/4)*sqrt(a + b*x**S(2) + c*x**S(4))) + sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(S(2)*sqrt(a)*sqrt(c) + b)*(S(3)*A*b*sqrt(c) + S(10)*B*a*sqrt(c) + S(3)*sqrt(a)*(S(6)*A*c + S(5)*B*b))*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(30)*a**(S(3)/4)*c**(S(1)/4)*sqrt(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)*(A + B*x**S(2))/sqrt(a + b*x**S(2) + c*x**S(4)), x), x, B*x**S(4)*sqrt(a + b*x**S(2) + c*x**S(4))/(S(6)*c) + sqrt(a + b*x**S(2) + c*x**S(4))*(-S(18)*A*b*c - S(16)*B*a*c + S(15)*B*b**S(2) - S(2)*c*x**S(2)*(-S(6)*A*c + S(5)*B*b))/(S(48)*c**S(3)) - (S(8)*A*a*c**S(2) - S(6)*A*b**S(2)*c - S(12)*B*a*b*c + S(5)*B*b**S(3))*atanh((b + S(2)*c*x**S(2))/(S(2)*sqrt(c)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(32)*c**(S(7)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*(A + B*x**S(2))/sqrt(a + b*x**S(2) + c*x**S(4)), x), x, -sqrt(a + b*x**S(2) + c*x**S(4))*(-S(4)*A*c + S(3)*B*b - S(2)*B*c*x**S(2))/(S(8)*c**S(2)) + (-S(4)*A*b*c - S(4)*B*a*c + S(3)*B*b**S(2))*atanh((b + S(2)*c*x**S(2))/(S(2)*sqrt(c)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(16)*c**(S(5)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(A + B*x**S(2))/sqrt(a + b*x**S(2) + c*x**S(4)), x), x, B*sqrt(a + b*x**S(2) + c*x**S(4))/(S(2)*c) - (-S(2)*A*c + B*b)*atanh((b + S(2)*c*x**S(2))/(S(2)*sqrt(c)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(4)*c**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((A + B*x**S(2))/(x*sqrt(a + b*x**S(2) + c*x**S(4))), x), x, -A*atanh((S(2)*a + b*x**S(2))/(S(2)*sqrt(a)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(2)*sqrt(a)) + B*atanh((b + S(2)*c*x**S(2))/(S(2)*sqrt(c)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(2)*sqrt(c)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((A + B*x**S(2))/(x**S(3)*sqrt(a + b*x**S(2) + c*x**S(4))), x), x, -A*sqrt(a + b*x**S(2) + c*x**S(4))/(S(2)*a*x**S(2)) + (A*b - S(2)*B*a)*atanh((S(2)*a + b*x**S(2))/(S(2)*sqrt(a)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(4)*a**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((A + B*x**S(2))/(x**S(5)*sqrt(a + b*x**S(2) + c*x**S(4))), x), x, -A*sqrt(a + b*x**S(2) + c*x**S(4))/(S(4)*a*x**S(4)) + (S(3)*A*b - S(4)*B*a)*sqrt(a + b*x**S(2) + c*x**S(4))/(S(8)*a**S(2)*x**S(2)) - (-S(4)*A*a*c + S(3)*A*b**S(2) - S(4)*B*a*b)*atanh((S(2)*a + b*x**S(2))/(S(2)*sqrt(a)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(16)*a**(S(5)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((A + B*x**S(2))/(x**S(7)*sqrt(a + b*x**S(2) + c*x**S(4))), x), x, -A*sqrt(a + b*x**S(2) + c*x**S(4))/(S(6)*a*x**S(6)) + (S(5)*A*b - S(6)*B*a)*sqrt(a + b*x**S(2) + c*x**S(4))/(S(24)*a**S(2)*x**S(4)) - sqrt(a + b*x**S(2) + c*x**S(4))*(-S(16)*A*a*c + S(15)*A*b**S(2) - S(18)*B*a*b)/(S(48)*a**S(3)*x**S(2)) + (-S(12)*A*a*b*c + S(5)*A*b**S(3) + S(8)*B*a**S(2)*c - S(6)*B*a*b**S(2))*atanh((S(2)*a + b*x**S(2))/(S(2)*sqrt(a)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(32)*a**(S(7)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)*(A + B*x**S(2))/sqrt(a + b*x**S(2) + c*x**S(4)), x), x, B*x**S(3)*sqrt(a + b*x**S(2) + c*x**S(4))/(S(5)*c) - a**(S(1)/4)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(-S(10)*A*b*c - S(9)*B*a*c + S(8)*B*b**S(2))*elliptic_e(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(15)*c**(S(11)/4)*sqrt(a + b*x**S(2) + c*x**S(4))) + a**(S(1)/4)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(-S(10)*A*b*c - S(9)*B*a*c + S(8)*B*b**S(2) + sqrt(a)*sqrt(c)*(-S(5)*A*c + S(4)*B*b))*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(30)*c**(S(11)/4)*sqrt(a + b*x**S(2) + c*x**S(4))) - x*(-S(5)*A*c + S(4)*B*b)*sqrt(a + b*x**S(2) + c*x**S(4))/(S(15)*c**S(2)) + x*sqrt(a + b*x**S(2) + c*x**S(4))*(-S(10)*A*b*c - S(9)*B*a*c + S(8)*B*b**S(2))/(S(15)*c**(S(5)/2)*(sqrt(a) + sqrt(c)*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(A + B*x**S(2))/sqrt(a + b*x**S(2) + c*x**S(4)), x), x, B*x*sqrt(a + b*x**S(2) + c*x**S(4))/(S(3)*c) + a**(S(1)/4)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(-S(3)*A*c + S(2)*B*b)*elliptic_e(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(3)*c**(S(7)/4)*sqrt(a + b*x**S(2) + c*x**S(4))) - a**(S(1)/4)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(-S(3)*A*c + B*sqrt(a)*sqrt(c) + S(2)*B*b)*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(6)*c**(S(7)/4)*sqrt(a + b*x**S(2) + c*x**S(4))) - x*(-S(3)*A*c + S(2)*B*b)*sqrt(a + b*x**S(2) + c*x**S(4))/(S(3)*c**(S(3)/2)*(sqrt(a) + sqrt(c)*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((A + B*x**S(2))/sqrt(a + b*x**S(2) + c*x**S(4)), x), x, -B*a**(S(1)/4)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*elliptic_e(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(c**(S(3)/4)*sqrt(a + b*x**S(2) + c*x**S(4))) + B*x*sqrt(a + b*x**S(2) + c*x**S(4))/(sqrt(c)*(sqrt(a) + sqrt(c)*x**S(2))) + a**(S(1)/4)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(A*sqrt(c)/sqrt(a) + B)*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(2)*c**(S(3)/4)*sqrt(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((A + B*x**S(2))/(x**S(2)*sqrt(a + b*x**S(2) + c*x**S(4))), x), x, A*sqrt(c)*x*sqrt(a + b*x**S(2) + c*x**S(4))/(a*(sqrt(a) + sqrt(c)*x**S(2))) - A*sqrt(a + b*x**S(2) + c*x**S(4))/(a*x) - A*c**(S(1)/4)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*elliptic_e(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(a**(S(3)/4)*sqrt(a + b*x**S(2) + c*x**S(4))) + sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(A*sqrt(c) + B*sqrt(a))*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(2)*a**(S(3)/4)*c**(S(1)/4)*sqrt(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((A + B*x**S(2))/(x**S(4)*sqrt(a + b*x**S(2) + c*x**S(4))), x), x, -A*sqrt(a + b*x**S(2) + c*x**S(4))/(S(3)*a*x**S(3)) - sqrt(c)*x*(S(2)*A*b - S(3)*B*a)*sqrt(a + b*x**S(2) + c*x**S(4))/(S(3)*a**S(2)*(sqrt(a) + sqrt(c)*x**S(2))) + (S(2)*A*b - S(3)*B*a)*sqrt(a + b*x**S(2) + c*x**S(4))/(S(3)*a**S(2)*x) + c**(S(1)/4)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(S(2)*A*b - S(3)*B*a)*elliptic_e(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(3)*a**(S(7)/4)*sqrt(a + b*x**S(2) + c*x**S(4))) - c**(S(1)/4)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(A*sqrt(a)*sqrt(c) + S(2)*A*b - S(3)*B*a)*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(6)*a**(S(7)/4)*sqrt(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)*(A + B*x**S(2))/(a + b*x**S(2) + c*x**S(4))**(S(3)/2), x), x, -x**S(2)*(a*(-S(2)*A*c + B*b) + x**S(2)*(-A*b*c - S(2)*B*a*c + B*b**S(2)))/(c*(-S(4)*a*c + b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))) + sqrt(a + b*x**S(2) + c*x**S(4))*(-S(2)*A*b*c - S(8)*B*a*c + S(3)*B*b**S(2))/(S(2)*c**S(2)*(-S(4)*a*c + b**S(2))) - (-S(2)*A*c + S(3)*B*b)*atanh((b + S(2)*c*x**S(2))/(S(2)*sqrt(c)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(4)*c**(S(5)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*(A + B*x**S(2))/(a + b*x**S(2) + c*x**S(4))**(S(3)/2), x), x, B*atanh((b + S(2)*c*x**S(2))/(S(2)*sqrt(c)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(2)*c**(S(3)/2)) - (a*(-S(2)*A*c + B*b) + x**S(2)*(-A*b*c - S(2)*B*a*c + B*b**S(2)))/(c*(-S(4)*a*c + b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(A + B*x**S(2))/(a + b*x**S(2) + c*x**S(4))**(S(3)/2), x), x, -(A*b - S(2)*B*a - x**S(2)*(-S(2)*A*c + B*b))/((-S(4)*a*c + b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((A + B*x**S(2))/(x*(a + b*x**S(2) + c*x**S(4))**(S(3)/2)), x), x, -A*atanh((S(2)*a + b*x**S(2))/(S(2)*sqrt(a)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(2)*a**(S(3)/2)) - (-A*(-S(2)*a*c + b**S(2)) + B*a*b - c*x**S(2)*(A*b - S(2)*B*a))/(a*(-S(4)*a*c + b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((A + B*x**S(2))/(x**S(3)*(a + b*x**S(2) + c*x**S(4))**(S(3)/2)), x), x, -(-A*(-S(2)*a*c + b**S(2)) + B*a*b - c*x**S(2)*(A*b - S(2)*B*a))/(a*x**S(2)*(-S(4)*a*c + b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))) - sqrt(a + b*x**S(2) + c*x**S(4))*(-S(8)*A*a*c + S(3)*A*b**S(2) - S(2)*B*a*b)/(S(2)*a**S(2)*x**S(2)*(-S(4)*a*c + b**S(2))) + (S(3)*A*b - S(2)*B*a)*atanh((S(2)*a + b*x**S(2))/(S(2)*sqrt(a)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(4)*a**(S(5)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)*(A + B*x**S(2))/(a + b*x**S(2) + c*x**S(4))**(S(3)/2), x), x, -a**(S(1)/4)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(-A*b*c - S(6)*B*a*c + S(2)*B*b**S(2))*elliptic_e(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(c**(S(7)/4)*(-S(4)*a*c + b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))) + a**(S(1)/4)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(-A*c - S(3)*B*sqrt(a)*sqrt(c) + S(2)*B*b)*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(c**(S(7)/4)*(-S(4)*sqrt(a)*sqrt(c) + S(2)*b)*sqrt(a + b*x**S(2) + c*x**S(4))) - x**S(3)*(A*b - S(2)*B*a - x**S(2)*(-S(2)*A*c + B*b))/((-S(4)*a*c + b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))) - x*(-S(2)*A*c + B*b)*sqrt(a + b*x**S(2) + c*x**S(4))/(c*(-S(4)*a*c + b**S(2))) + x*sqrt(a + b*x**S(2) + c*x**S(4))*(-A*b*c - S(6)*B*a*c + S(2)*B*b**S(2))/(c**(S(3)/2)*(sqrt(a) + sqrt(c)*x**S(2))*(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(A + B*x**S(2))/(a + b*x**S(2) + c*x**S(4))**(S(3)/2), x), x, a**(S(1)/4)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(-S(2)*A*c + B*b)*elliptic_e(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(c**(S(3)/4)*(-S(4)*a*c + b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))) - x*(A*b - S(2)*B*a - x**S(2)*(-S(2)*A*c + B*b))/((-S(4)*a*c + b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))) - x*(-S(2)*A*c + B*b)*sqrt(a + b*x**S(2) + c*x**S(4))/(sqrt(c)*(sqrt(a) + sqrt(c)*x**S(2))*(-S(4)*a*c + b**S(2))) - sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(-A*sqrt(c) + B*sqrt(a))*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(2)*a**(S(1)/4)*c**(S(3)/4)*(-S(2)*sqrt(a)*sqrt(c) + b)*sqrt(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((A + B*x**S(2))/(a + b*x**S(2) + c*x**S(4))**(S(3)/2), x), x, -sqrt(c)*x*(A*b - S(2)*B*a)*sqrt(a + b*x**S(2) + c*x**S(4))/(a*(sqrt(a) + sqrt(c)*x**S(2))*(-S(4)*a*c + b**S(2))) - x*(-A*(-S(2)*a*c + b**S(2)) + B*a*b - c*x**S(2)*(A*b - S(2)*B*a))/(a*(-S(4)*a*c + b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))) + c**(S(1)/4)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(A*b - S(2)*B*a)*elliptic_e(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(a**(S(3)/4)*(-S(4)*a*c + b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))) + sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(-A*sqrt(c) + B*sqrt(a))*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(2)*a**(S(3)/4)*c**(S(1)/4)*(-S(2)*sqrt(a)*sqrt(c) + b)*sqrt(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((A + B*x**S(2))/(x**S(2)*(a + b*x**S(2) + c*x**S(4))**(S(3)/2)), x), x, -(-A*(-S(2)*a*c + b**S(2)) + B*a*b - c*x**S(2)*(A*b - S(2)*B*a))/(a*x*(-S(4)*a*c + b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))) + sqrt(c)*x*sqrt(a + b*x**S(2) + c*x**S(4))*(-S(6)*A*a*c + S(2)*A*b**S(2) - B*a*b)/(a**S(2)*(sqrt(a) + sqrt(c)*x**S(2))*(-S(4)*a*c + b**S(2))) - sqrt(a + b*x**S(2) + c*x**S(4))*(-S(6)*A*a*c + S(2)*A*b**S(2) - B*a*b)/(a**S(2)*x*(-S(4)*a*c + b**S(2))) - c**(S(1)/4)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(-S(6)*A*a*c + S(2)*A*b**S(2) - B*a*b)*elliptic_e(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(a**(S(7)/4)*(-S(4)*a*c + b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))) + c**(S(1)/4)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(-S(3)*A*sqrt(a)*sqrt(c) + S(2)*A*b - B*a)*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(2)*a**(S(7)/4)*(-S(2)*sqrt(a)*sqrt(c) + b)*sqrt(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((f*x)**(S(3)/2)*(d + e*x**S(2))*sqrt(a + b*x**S(2) + c*x**S(4)), x), x, S(2)*d*(f*x)**(S(5)/2)*sqrt(a + b*x**S(2) + c*x**S(4))*AppellF1(S(5)/4, S(-1)/2, S(-1)/2, S(9)/4, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(5)*f*sqrt(S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))) + S(2)*e*(f*x)**(S(9)/2)*sqrt(a + b*x**S(2) + c*x**S(4))*AppellF1(S(9)/4, S(-1)/2, S(-1)/2, S(13)/4, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(9)*f**S(3)*sqrt(S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(f*x)*(d + e*x**S(2))*sqrt(a + b*x**S(2) + c*x**S(4)), x), x, S(2)*d*(f*x)**(S(3)/2)*sqrt(a + b*x**S(2) + c*x**S(4))*AppellF1(S(3)/4, S(-1)/2, S(-1)/2, S(7)/4, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(3)*f*sqrt(S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))) + S(2)*e*(f*x)**(S(7)/2)*sqrt(a + b*x**S(2) + c*x**S(4))*AppellF1(S(7)/4, S(-1)/2, S(-1)/2, S(11)/4, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(7)*f**S(3)*sqrt(S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))/sqrt(f*x), x), x, S(2)*d*sqrt(f*x)*sqrt(a + b*x**S(2) + c*x**S(4))*AppellF1(S(1)/4, S(-1)/2, S(-1)/2, S(5)/4, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/(f*sqrt(S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))) + S(2)*e*(f*x)**(S(5)/2)*sqrt(a + b*x**S(2) + c*x**S(4))*AppellF1(S(5)/4, S(-1)/2, S(-1)/2, S(9)/4, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(5)*f**S(3)*sqrt(S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))/(f*x)**(S(3)/2), x), x, -S(2)*d*sqrt(a + b*x**S(2) + c*x**S(4))*AppellF1(S(-1)/4, S(-1)/2, S(-1)/2, S(3)/4, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/(f*sqrt(f*x)*sqrt(S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))) + S(2)*e*(f*x)**(S(3)/2)*sqrt(a + b*x**S(2) + c*x**S(4))*AppellF1(S(3)/4, S(-1)/2, S(-1)/2, S(7)/4, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(3)*f**S(3)*sqrt(S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((f*x)**(S(3)/2)*(d + e*x**S(2))*(a + b*x**S(2) + c*x**S(4))**(S(3)/2), x), x, S(2)*a*d*(f*x)**(S(5)/2)*sqrt(a + b*x**S(2) + c*x**S(4))*AppellF1(S(5)/4, S(-3)/2, S(-3)/2, S(9)/4, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(5)*f*sqrt(S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))) + S(2)*a*e*(f*x)**(S(9)/2)*sqrt(a + b*x**S(2) + c*x**S(4))*AppellF1(S(9)/4, S(-3)/2, S(-3)/2, S(13)/4, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(9)*f**S(3)*sqrt(S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(f*x)*(d + e*x**S(2))*(a + b*x**S(2) + c*x**S(4))**(S(3)/2), x), x, S(2)*a*d*(f*x)**(S(3)/2)*sqrt(a + b*x**S(2) + c*x**S(4))*AppellF1(S(3)/4, S(-3)/2, S(-3)/2, S(7)/4, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(3)*f*sqrt(S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))) + S(2)*a*e*(f*x)**(S(7)/2)*sqrt(a + b*x**S(2) + c*x**S(4))*AppellF1(S(7)/4, S(-3)/2, S(-3)/2, S(11)/4, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(7)*f**S(3)*sqrt(S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))*(a + b*x**S(2) + c*x**S(4))**(S(3)/2)/sqrt(f*x), x), x, S(2)*a*d*sqrt(f*x)*sqrt(a + b*x**S(2) + c*x**S(4))*AppellF1(S(1)/4, S(-3)/2, S(-3)/2, S(5)/4, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/(f*sqrt(S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))) + S(2)*a*e*(f*x)**(S(5)/2)*sqrt(a + b*x**S(2) + c*x**S(4))*AppellF1(S(5)/4, S(-3)/2, S(-3)/2, S(9)/4, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(5)*f**S(3)*sqrt(S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))*(a + b*x**S(2) + c*x**S(4))**(S(3)/2)/(f*x)**(S(3)/2), x), x, -S(2)*a*d*sqrt(a + b*x**S(2) + c*x**S(4))*AppellF1(S(-1)/4, S(-3)/2, S(-3)/2, S(3)/4, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/(f*sqrt(f*x)*sqrt(S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))) + S(2)*a*e*(f*x)**(S(3)/2)*sqrt(a + b*x**S(2) + c*x**S(4))*AppellF1(S(3)/4, S(-3)/2, S(-3)/2, S(7)/4, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(3)*f**S(3)*sqrt(S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((f*x)**(S(3)/2)*(d + e*x**S(2))/sqrt(a + b*x**S(2) + c*x**S(4)), x), x, S(2)*d*(f*x)**(S(5)/2)*sqrt(S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))*AppellF1(S(5)/4, S(1)/2, S(1)/2, S(9)/4, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(5)*f*sqrt(a + b*x**S(2) + c*x**S(4))) + S(2)*e*(f*x)**(S(9)/2)*sqrt(S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))*AppellF1(S(9)/4, S(1)/2, S(1)/2, S(13)/4, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(9)*f**S(3)*sqrt(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(f*x)*(d + e*x**S(2))/sqrt(a + b*x**S(2) + c*x**S(4)), x), x, S(2)*d*(f*x)**(S(3)/2)*sqrt(S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))*AppellF1(S(3)/4, S(1)/2, S(1)/2, S(7)/4, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(3)*f*sqrt(a + b*x**S(2) + c*x**S(4))) + S(2)*e*(f*x)**(S(7)/2)*sqrt(S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))*AppellF1(S(7)/4, S(1)/2, S(1)/2, S(11)/4, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(7)*f**S(3)*sqrt(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))/(sqrt(f*x)*sqrt(a + b*x**S(2) + c*x**S(4))), x), x, S(2)*d*sqrt(f*x)*sqrt(S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))*AppellF1(S(1)/4, S(1)/2, S(1)/2, S(5)/4, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/(f*sqrt(a + b*x**S(2) + c*x**S(4))) + S(2)*e*(f*x)**(S(5)/2)*sqrt(S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))*AppellF1(S(5)/4, S(1)/2, S(1)/2, S(9)/4, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(5)*f**S(3)*sqrt(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))/((f*x)**(S(3)/2)*sqrt(a + b*x**S(2) + c*x**S(4))), x), x, -S(2)*d*sqrt(S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))*AppellF1(S(-1)/4, S(1)/2, S(1)/2, S(3)/4, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/(f*sqrt(f*x)*sqrt(a + b*x**S(2) + c*x**S(4))) + S(2)*e*(f*x)**(S(3)/2)*sqrt(S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))*AppellF1(S(3)/4, S(1)/2, S(1)/2, S(7)/4, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(3)*f**S(3)*sqrt(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((f*x)**(S(3)/2)*(d + e*x**S(2))/(a + b*x**S(2) + c*x**S(4))**(S(3)/2), x), x, S(2)*d*(f*x)**(S(5)/2)*sqrt(S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))*AppellF1(S(5)/4, S(3)/2, S(3)/2, S(9)/4, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(5)*a*f*sqrt(a + b*x**S(2) + c*x**S(4))) + S(2)*e*(f*x)**(S(9)/2)*sqrt(S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))*AppellF1(S(9)/4, S(3)/2, S(3)/2, S(13)/4, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(9)*a*f**S(3)*sqrt(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(f*x)*(d + e*x**S(2))/(a + b*x**S(2) + c*x**S(4))**(S(3)/2), x), x, S(2)*d*(f*x)**(S(3)/2)*sqrt(S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))*AppellF1(S(3)/4, S(3)/2, S(3)/2, S(7)/4, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(3)*a*f*sqrt(a + b*x**S(2) + c*x**S(4))) + S(2)*e*(f*x)**(S(7)/2)*sqrt(S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))*AppellF1(S(7)/4, S(3)/2, S(3)/2, S(11)/4, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(7)*a*f**S(3)*sqrt(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))/(sqrt(f*x)*(a + b*x**S(2) + c*x**S(4))**(S(3)/2)), x), x, S(2)*d*sqrt(f*x)*sqrt(S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))*AppellF1(S(1)/4, S(3)/2, S(3)/2, S(5)/4, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/(a*f*sqrt(a + b*x**S(2) + c*x**S(4))) + S(2)*e*(f*x)**(S(5)/2)*sqrt(S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))*AppellF1(S(5)/4, S(3)/2, S(3)/2, S(9)/4, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(5)*a*f**S(3)*sqrt(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))/((f*x)**(S(3)/2)*(a + b*x**S(2) + c*x**S(4))**(S(3)/2)), x), x, -S(2)*d*sqrt(S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))*AppellF1(S(-1)/4, S(3)/2, S(3)/2, S(3)/4, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/(a*f*sqrt(f*x)*sqrt(a + b*x**S(2) + c*x**S(4))) + S(2)*e*(f*x)**(S(3)/2)*sqrt(S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))*AppellF1(S(3)/4, S(3)/2, S(3)/2, S(7)/4, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(3)*a*f**S(3)*sqrt(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((f*x)**m*(d + e*x**S(2))/(a + b*x**S(2) + c*x**S(4))**S(2), x), x, -c*(f*x)**(m + S(1))*(S(2)*a*(-S(2)*c*d*(-m + S(3)) + e*(-m + S(1))*sqrt(-S(4)*a*c + b**S(2))) + b**S(2)*d*(-m + S(1)) + b*(S(4)*a*e - d*(-m + S(1))*sqrt(-S(4)*a*c + b**S(2))))*hyper((S(1), m/S(2) + S(1)/2), (m/S(2) + S(3)/2,), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*a*f*(b + sqrt(-S(4)*a*c + b**S(2)))*(m + S(1))*(-S(4)*a*c + b**S(2))**(S(3)/2)) + c*(f*x)**(m + S(1))*(-S(2)*a*(S(2)*c*d*(-m + S(3)) + e*(-m + S(1))*sqrt(-S(4)*a*c + b**S(2))) + b**S(2)*(-d*m + d) + b*(S(4)*a*e + d*(-m + S(1))*sqrt(-S(4)*a*c + b**S(2))))*hyper((S(1), m/S(2) + S(1)/2), (m/S(2) + S(3)/2,), -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*a*f*(b - sqrt(-S(4)*a*c + b**S(2)))*(m + S(1))*(-S(4)*a*c + b**S(2))**(S(3)/2)) + (f*x)**(m + S(1))*(-a*b*e - S(2)*a*c*d + b**S(2)*d + c*x**S(2)*(-S(2)*a*e + b*d))/(S(2)*a*f*(-S(4)*a*c + b**S(2))*(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((f*x)**m*(d + e*x**S(2))*(a + b*x**S(2) + c*x**S(4))**(S(3)/2), x), x, a*d*(f*x)**(m + S(1))*sqrt(a + b*x**S(2) + c*x**S(4))*AppellF1(m/S(2) + S(1)/2, S(-3)/2, S(-3)/2, m/S(2) + S(3)/2, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/(f*(m + S(1))*sqrt(S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))) + a*e*(f*x)**(m + S(3))*sqrt(a + b*x**S(2) + c*x**S(4))*AppellF1(m/S(2) + S(3)/2, S(-3)/2, S(-3)/2, m/S(2) + S(5)/2, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/(f**S(3)*(m + S(3))*sqrt(S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((f*x)**m*(d + e*x**S(2))*sqrt(a + b*x**S(2) + c*x**S(4)), x), x, d*(f*x)**(m + S(1))*sqrt(a + b*x**S(2) + c*x**S(4))*AppellF1(m/S(2) + S(1)/2, S(-1)/2, S(-1)/2, m/S(2) + S(3)/2, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/(f*(m + S(1))*sqrt(S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))) + e*(f*x)**(m + S(3))*sqrt(a + b*x**S(2) + c*x**S(4))*AppellF1(m/S(2) + S(3)/2, S(-1)/2, S(-1)/2, m/S(2) + S(5)/2, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/(f**S(3)*(m + S(3))*sqrt(S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((f*x)**m*(d + e*x**S(2))/sqrt(a + b*x**S(2) + c*x**S(4)), x), x, d*(f*x)**(m + S(1))*sqrt(S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))*AppellF1(m/S(2) + S(1)/2, S(1)/2, S(1)/2, m/S(2) + S(3)/2, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/(f*(m + S(1))*sqrt(a + b*x**S(2) + c*x**S(4))) + e*(f*x)**(m + S(3))*sqrt(S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))*AppellF1(m/S(2) + S(3)/2, S(1)/2, S(1)/2, m/S(2) + S(5)/2, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/(f**S(3)*(m + S(3))*sqrt(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((f*x)**m*(d + e*x**S(2))/(a + b*x**S(2) + c*x**S(4))**(S(3)/2), x), x, d*(f*x)**(m + S(1))*sqrt(S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))*AppellF1(m/S(2) + S(1)/2, S(3)/2, S(3)/2, m/S(2) + S(3)/2, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/(a*f*(m + S(1))*sqrt(a + b*x**S(2) + c*x**S(4))) + e*(f*x)**(m + S(3))*sqrt(S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))*AppellF1(m/S(2) + S(3)/2, S(3)/2, S(3)/2, m/S(2) + S(5)/2, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/(a*f**S(3)*(m + S(3))*sqrt(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((f*x)**m*(d + e*x**S(2))*(a + b*x**S(2) + c*x**S(4))**S(3), x), x, a**S(3)*d*(f*x)**(m + S(1))/(f*(m + S(1))) + a**S(2)*(f*x)**(m + S(3))*(a*e + S(3)*b*d)/(f**S(3)*(m + S(3))) + S(3)*a*(f*x)**(m + S(5))*(a*b*e + a*c*d + b**S(2)*d)/(f**S(5)*(m + S(5))) + c**S(3)*e*(f*x)**(m + S(15))/(f**S(15)*(m + S(15))) + c**S(2)*(f*x)**(m + S(13))*(S(3)*b*e + c*d)/(f**S(13)*(m + S(13))) + S(3)*c*(f*x)**(m + S(11))*(a*c*e + b**S(2)*e + b*c*d)/(f**S(11)*(m + S(11))) + (f*x)**(m + S(7))*(S(3)*a**S(2)*c*e + S(3)*a*b**S(2)*e + S(6)*a*b*c*d + b**S(3)*d)/(f**S(7)*(m + S(7))) + (f*x)**(m + S(9))*(S(6)*a*b*c*e + S(3)*a*c**S(2)*d + b**S(3)*e + S(3)*b**S(2)*c*d)/(f**S(9)*(m + S(9))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((f*x)**m*(d + e*x**S(2))*(a + b*x**S(2) + c*x**S(4))**S(2), x), x, a**S(2)*d*(f*x)**(m + S(1))/(f*(m + S(1))) + a*(f*x)**(m + S(3))*(a*e + S(2)*b*d)/(f**S(3)*(m + S(3))) + c**S(2)*e*(f*x)**(m + S(11))/(f**S(11)*(m + S(11))) + c*(f*x)**(m + S(9))*(S(2)*b*e + c*d)/(f**S(9)*(m + S(9))) + (f*x)**(m + S(5))*(S(2)*a*b*e + S(2)*a*c*d + b**S(2)*d)/(f**S(5)*(m + S(5))) + (f*x)**(m + S(7))*(S(2)*a*c*e + b**S(2)*e + S(2)*b*c*d)/(f**S(7)*(m + S(7))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((f*x)**m*(d + e*x**S(2))*(a + b*x**S(2) + c*x**S(4)), x), x, a*d*(f*x)**(m + S(1))/(f*(m + S(1))) + c*e*(f*x)**(m + S(7))/(f**S(7)*(m + S(7))) + (f*x)**(m + S(3))*(a*e + b*d)/(f**S(3)*(m + S(3))) + (f*x)**(m + S(5))*(b*e + c*d)/(f**S(5)*(m + S(5))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((f*x)**m*(d + e*x**S(2))/(a + b*x**S(2) + c*x**S(4)), x), x, (f*x)**(m + S(1))*(e - (-b*e + S(2)*c*d)/sqrt(-S(4)*a*c + b**S(2)))*hyper((S(1), m/S(2) + S(1)/2), (m/S(2) + S(3)/2,), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/(f*(b + sqrt(-S(4)*a*c + b**S(2)))*(m + S(1))) + (f*x)**(m + S(1))*(e + (-b*e + S(2)*c*d)/sqrt(-S(4)*a*c + b**S(2)))*hyper((S(1), m/S(2) + S(1)/2), (m/S(2) + S(3)/2,), -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))))/(f*(b - sqrt(-S(4)*a*c + b**S(2)))*(m + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*(d + e*x**S(2))**S(2)*(a + b*x**S(2) + c*x**S(4)), x), x, a*d**S(2)*x**S(4)/S(4) + c*e**S(2)*x**S(12)/S(12) + d*x**S(6)*(S(2)*a*e + b*d)/S(6) + e*x**S(10)*(b*e + S(2)*c*d)/S(10) + x**S(8)*(c*d**S(2)/S(8) + e*(a*e + S(2)*b*d)/S(8)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(d + e*x**S(2))**S(2)*(a + b*x**S(2) + c*x**S(4)), x), x, a*d**S(2)*x**S(3)/S(3) + c*e**S(2)*x**S(11)/S(11) + d*x**S(5)*(S(2)*a*e + b*d)/S(5) + e*x**S(9)*(b*e + S(2)*c*d)/S(9) + x**S(7)*(c*d**S(2)/S(7) + e*(a*e + S(2)*b*d)/S(7)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(d + e*x**S(2))**S(2)*(a + b*x**S(2) + c*x**S(4)), x), x, a*d**S(2)*x**S(2)/S(2) + c*e**S(2)*x**S(10)/S(10) + d*x**S(4)*(S(2)*a*e + b*d)/S(4) + e*x**S(8)*(b*e + S(2)*c*d)/S(8) + x**S(6)*(c*d**S(2)/S(6) + e*(a*e + S(2)*b*d)/S(6)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))**S(2)*(a + b*x**S(2) + c*x**S(4)), x), x, a*d**S(2)*x + c*e**S(2)*x**S(9)/S(9) + d*x**S(3)*(S(2)*a*e + b*d)/S(3) + e*x**S(7)*(b*e + S(2)*c*d)/S(7) + x**S(5)*(c*d**S(2)/S(5) + e*(a*e + S(2)*b*d)/S(5)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))**S(2)*(a + b*x**S(2) + c*x**S(4))/x, x), x, a*d**S(2)*log(x) + c*e**S(2)*x**S(8)/S(8) + d*x**S(2)*(S(2)*a*e + b*d)/S(2) + e*x**S(6)*(b*e + S(2)*c*d)/S(6) + x**S(4)*(c*d**S(2)/S(4) + e*(a*e + S(2)*b*d)/S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))**S(2)*(a + b*x**S(2) + c*x**S(4))/x**S(2), x), x, -a*d**S(2)/x + c*e**S(2)*x**S(7)/S(7) + d*x*(S(2)*a*e + b*d) + e*x**S(5)*(b*e + S(2)*c*d)/S(5) + x**S(3)*(c*d**S(2)/S(3) + e*(a*e + S(2)*b*d)/S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))**S(2)*(a + b*x**S(2) + c*x**S(4))/x**S(3), x), x, -a*d**S(2)/(S(2)*x**S(2)) + c*e**S(2)*x**S(6)/S(6) + d*(S(2)*a*e + b*d)*log(x) + e*x**S(4)*(b*e + S(2)*c*d)/S(4) + x**S(2)*(c*d**S(2)/S(2) + e*(a*e + S(2)*b*d)/S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(6)*(a + b*x**S(2) + c*x**S(4))/(d + e*x**S(2))**S(2), x), x, c*x**S(7)/(S(7)*e**S(2)) + d**(S(3)/2)*(S(9)*c*d**S(2) - e*(-S(5)*a*e + S(7)*b*d))*atan(sqrt(e)*x/sqrt(d))/(S(2)*e**(S(11)/2)) - d**S(2)*x*(a*e**S(2) - b*d*e + c*d**S(2))/(S(2)*e**S(5)*(d + e*x**S(2))) - d*x*(S(4)*c*d**S(2) - e*(-S(2)*a*e + S(3)*b*d))/e**S(5) - x**S(5)*(-b*e + S(2)*c*d)/(S(5)*e**S(3)) + x**S(3)*(S(3)*c*d**S(2) - e*(-a*e + S(2)*b*d))/(S(3)*e**S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)*(a + b*x**S(2) + c*x**S(4))/(d + e*x**S(2))**S(2), x), x, c*x**S(5)/(S(5)*e**S(2)) - sqrt(d)*(S(7)*c*d**S(2) - e*(-S(3)*a*e + S(5)*b*d))*atan(sqrt(e)*x/sqrt(d))/(S(2)*e**(S(9)/2)) + d*x*(a*e**S(2) - b*d*e + c*d**S(2))/(S(2)*e**S(4)*(d + e*x**S(2))) - x**S(3)*(-b*e + S(2)*c*d)/(S(3)*e**S(3)) + x*(S(3)*c*d**S(2) - e*(-a*e + S(2)*b*d))/e**S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(a + b*x**S(2) + c*x**S(4))/(d + e*x**S(2))**S(2), x), x, c*x**S(3)/(S(3)*e**S(2)) - x*(-b*e + S(2)*c*d)/e**S(3) - x*(a*e**S(2) - b*d*e + c*d**S(2))/(S(2)*e**S(3)*(d + e*x**S(2))) + (S(5)*c*d**S(2) - e*(-a*e + S(3)*b*d))*atan(sqrt(e)*x/sqrt(d))/(S(2)*sqrt(d)*e**(S(7)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))/(d + e*x**S(2))**S(2), x), x, c*x/e**S(2) + x*(a*e**S(2) - b*d*e + c*d**S(2))/(S(2)*d*e**S(2)*(d + e*x**S(2))) - (S(3)*c*d**S(2) - e*(a*e + b*d))*atan(sqrt(e)*x/sqrt(d))/(S(2)*d**(S(3)/2)*e**(S(5)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))/(x**S(2)*(d + e*x**S(2))**S(2)), x), x, -a/(d**S(2)*x) - x*(a*e**S(2) - b*d*e + c*d**S(2))/(S(2)*d**S(2)*e*(d + e*x**S(2))) + (c*d**S(2) + e*(-S(3)*a*e + b*d))*atan(sqrt(e)*x/sqrt(d))/(S(2)*d**(S(5)/2)*e**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))/(x**S(4)*(d + e*x**S(2))**S(2)), x), x, -a/(S(3)*d**S(2)*x**S(3)) + x*(a*e**S(2) - b*d*e + c*d**S(2))/(S(2)*d**S(3)*(d + e*x**S(2))) - (-S(2)*a*e + b*d)/(d**S(3)*x) + (c*d**S(2) - e*(-S(5)*a*e + S(3)*b*d))*atan(sqrt(e)*x/sqrt(d))/(S(2)*d**(S(7)/2)*sqrt(e)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))/(x**S(6)*(d + e*x**S(2))**S(2)), x), x, -a/(S(5)*d**S(2)*x**S(5)) - (-S(2)*a*e + b*d)/(S(3)*d**S(3)*x**S(3)) - e*x*(a*e**S(2) - b*d*e + c*d**S(2))/(S(2)*d**S(4)*(d + e*x**S(2))) - (c*d**S(2) - e*(-S(3)*a*e + S(2)*b*d))/(d**S(4)*x) - sqrt(e)*(S(3)*c*d**S(2) - e*(-S(7)*a*e + S(5)*b*d))*atan(sqrt(e)*x/sqrt(d))/(S(2)*d**(S(9)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))/(x**S(8)*(d + e*x**S(2))**S(2)), x), x, -a/(S(7)*d**S(2)*x**S(7)) - (-S(2)*a*e + b*d)/(S(5)*d**S(3)*x**S(5)) - (c*d**S(2) - e*(-S(3)*a*e + S(2)*b*d))/(S(3)*d**S(4)*x**S(3)) + e**S(2)*x*(a*e**S(2) - b*d*e + c*d**S(2))/(S(2)*d**S(5)*(d + e*x**S(2))) + e*(S(2)*c*d**S(2) - e*(-S(4)*a*e + S(3)*b*d))/(d**S(5)*x) + e**(S(3)/2)*(S(5)*c*d**S(2) - e*(-S(9)*a*e + S(7)*b*d))*atan(sqrt(e)*x/sqrt(d))/(S(2)*d**(S(11)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(6)*(a + b*x**S(2) + c*x**S(4))/(d + e*x**S(2))**S(3), x), x, c*x**S(5)/(S(5)*e**S(3)) - sqrt(d)*(S(15)*a*e**S(2) - S(35)*b*d*e + S(63)*c*d**S(2))*atan(sqrt(e)*x/sqrt(d))/(S(8)*e**(S(11)/2)) - d**S(2)*x*(a*e**S(2) - b*d*e + c*d**S(2))/(S(4)*e**S(5)*(d + e*x**S(2))**S(2)) + d*x*(S(17)*c*d**S(2) - e*(-S(9)*a*e + S(13)*b*d))/(S(8)*e**S(5)*(d + e*x**S(2))) - x**S(3)*(-b*e + S(3)*c*d)/(S(3)*e**S(4)) + x*(S(6)*c*d**S(2) - e*(-a*e + S(3)*b*d))/e**S(5), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)*(a + b*x**S(2) + c*x**S(4))/(d + e*x**S(2))**S(3), x), x, c*x**S(3)/(S(3)*e**S(3)) + d*x*(a*e**S(2) - b*d*e + c*d**S(2))/(S(4)*e**S(4)*(d + e*x**S(2))**S(2)) - x*(-b*e + S(3)*c*d)/e**S(4) - x*(S(13)*c*d**S(2) - e*(-S(5)*a*e + S(9)*b*d))/(S(8)*e**S(4)*(d + e*x**S(2))) + (S(35)*c*d**S(2) - S(3)*e*(-a*e + S(5)*b*d))*atan(sqrt(e)*x/sqrt(d))/(S(8)*sqrt(d)*e**(S(9)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(a + b*x**S(2) + c*x**S(4))/(d + e*x**S(2))**S(3), x), x, c*x/e**S(3) - x*(a*e**S(2) - b*d*e + c*d**S(2))/(S(4)*e**S(3)*(d + e*x**S(2))**S(2)) + x*(S(9)*c*d**S(2) - e*(-a*e + S(5)*b*d))/(S(8)*d*e**S(3)*(d + e*x**S(2))) - (S(15)*c*d**S(2) - e*(a*e + S(3)*b*d))*atan(sqrt(e)*x/sqrt(d))/(S(8)*d**(S(3)/2)*e**(S(7)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))/(d + e*x**S(2))**S(3), x), x, x*(a*e**S(2) - b*d*e + c*d**S(2))/(S(4)*d*e**S(2)*(d + e*x**S(2))**S(2)) - x*(S(5)*c*d**S(2) - e*(S(3)*a*e + b*d))/(S(8)*d**S(2)*e**S(2)*(d + e*x**S(2))) + (S(3)*c*d**S(2) + e*(S(3)*a*e + b*d))*atan(sqrt(e)*x/sqrt(d))/(S(8)*d**(S(5)/2)*e**(S(5)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))/(x**S(2)*(d + e*x**S(2))**S(3)), x), x, -a/(d**S(3)*x) - x*(a*e**S(2) - b*d*e + c*d**S(2))/(S(4)*d**S(2)*e*(d + e*x**S(2))**S(2)) + x*(c*d**S(2) + e*(-S(7)*a*e + S(3)*b*d))/(S(8)*d**S(3)*e*(d + e*x**S(2))) + (c*d**S(2) + S(3)*e*(-S(5)*a*e + b*d))*atan(sqrt(e)*x/sqrt(d))/(S(8)*d**(S(7)/2)*e**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))/(x**S(4)*(d + e*x**S(2))**S(3)), x), x, -a/(S(3)*d**S(3)*x**S(3)) + x*(a*e**S(2) - b*d*e + c*d**S(2))/(S(4)*d**S(3)*(d + e*x**S(2))**S(2)) + x*(S(3)*c*d**S(2) - e*(-S(11)*a*e + S(7)*b*d))/(S(8)*d**S(4)*(d + e*x**S(2))) - (-S(3)*a*e + b*d)/(d**S(4)*x) + (S(35)*a*e**S(2) - S(15)*b*d*e + S(3)*c*d**S(2))*atan(sqrt(e)*x/sqrt(d))/(S(8)*d**(S(9)/2)*sqrt(e)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))/(x**S(6)*(d + e*x**S(2))**S(3)), x), x, -a/(S(5)*d**S(3)*x**S(5)) - e*x*(a*e**S(2) - b*d*e + c*d**S(2))/(S(4)*d**S(4)*(d + e*x**S(2))**S(2)) - (-S(3)*a*e + b*d)/(S(3)*d**S(4)*x**S(3)) - e*x*(S(7)*c*d**S(2) - e*(-S(15)*a*e + S(11)*b*d))/(S(8)*d**S(5)*(d + e*x**S(2))) - (S(6)*a*e**S(2) - S(3)*b*d*e + c*d**S(2))/(d**S(5)*x) - sqrt(e)*(S(63)*a*e**S(2) - S(35)*b*d*e + S(15)*c*d**S(2))*atan(sqrt(e)*x/sqrt(d))/(S(8)*d**(S(11)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(9)/((d + e*x**S(2))*(a + b*x**S(2) + c*x**S(4))), x), x, d**S(4)*log(d + e*x**S(2))/(S(2)*e**S(3)*(a*e**S(2) - b*d*e + c*d**S(2))) + x**S(4)/(S(4)*c*e) - x**S(2)*(b*e + c*d)/(S(2)*c**S(2)*e**S(2)) - (a**S(2)*c*e - a*b**S(2)*e - S(2)*a*b*c*d + b**S(3)*d)*log(a + b*x**S(2) + c*x**S(4))/(S(4)*c**S(3)*(a*e**S(2) - b*d*e + c*d**S(2))) - (S(3)*a**S(2)*b*c*e + S(2)*a**S(2)*c**S(2)*d - a*b**S(3)*e - S(4)*a*b**S(2)*c*d + b**S(4)*d)*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*c**S(3)*sqrt(-S(4)*a*c + b**S(2))*(a*e**S(2) - b*d*e + c*d**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(7)/((d + e*x**S(2))*(a + b*x**S(2) + c*x**S(4))), x), x, -d**S(3)*log(d + e*x**S(2))/(S(2)*e**S(2)*(a*e**S(2) - b*d*e + c*d**S(2))) + x**S(2)/(S(2)*c*e) + (-a*b*e - a*c*d + b**S(2)*d)*log(a + b*x**S(2) + c*x**S(4))/(S(4)*c**S(2)*(a*e**S(2) - b*d*e + c*d**S(2))) + (S(2)*a**S(2)*c*e - a*b**S(2)*e - S(3)*a*b*c*d + b**S(3)*d)*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*c**S(2)*sqrt(-S(4)*a*c + b**S(2))*(a*e**S(2) - b*d*e + c*d**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)/((d + e*x**S(2))*(a + b*x**S(2) + c*x**S(4))), x), x, d**S(2)*log(d + e*x**S(2))/(S(2)*e*(a*e**S(2) - b*d*e + c*d**S(2))) - (-a*e + b*d)*log(a + b*x**S(2) + c*x**S(4))/(S(4)*c*(a*e**S(2) - b*d*e + c*d**S(2))) - (-a*b*e - S(2)*a*c*d + b**S(2)*d)*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*c*sqrt(-S(4)*a*c + b**S(2))*(a*e**S(2) - b*d*e + c*d**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/((d + e*x**S(2))*(a + b*x**S(2) + c*x**S(4))), x), x, d*log(a + b*x**S(2) + c*x**S(4))/(S(4)*a*e**S(2) - S(4)*b*d*e + S(4)*c*d**S(2)) - d*log(d + e*x**S(2))/(S(2)*a*e**S(2) - S(2)*b*d*e + S(2)*c*d**S(2)) + (-S(2)*a*e + b*d)*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*sqrt(-S(4)*a*c + b**S(2))*(a*e**S(2) - b*d*e + c*d**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/((d + e*x**S(2))*(a + b*x**S(2) + c*x**S(4))), x), x, -e*log(a + b*x**S(2) + c*x**S(4))/(S(4)*a*e**S(2) - S(4)*b*d*e + S(4)*c*d**S(2)) + e*log(d + e*x**S(2))/(S(2)*a*e**S(2) - S(2)*b*d*e + S(2)*c*d**S(2)) - (-b*e + S(2)*c*d)*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*sqrt(-S(4)*a*c + b**S(2))*(a*e**S(2) - b*d*e + c*d**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*(d + e*x**S(2))*(a + b*x**S(2) + c*x**S(4))), x), x, -e**S(2)*log(d + e*x**S(2))/(S(2)*d*(a*e**S(2) - b*d*e + c*d**S(2))) - (-b*e + c*d)*log(a + b*x**S(2) + c*x**S(4))/(S(4)*a*(a*e**S(2) - b*d*e + c*d**S(2))) + (S(2)*a*c*e - b**S(2)*e + b*c*d)*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*a*sqrt(-S(4)*a*c + b**S(2))*(a*e**S(2) - b*d*e + c*d**S(2))) + log(x)/(a*d), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(3)*(d + e*x**S(2))*(a + b*x**S(2) + c*x**S(4))), x), x, e**S(3)*log(d + e*x**S(2))/(S(2)*d**S(2)*(a*e**S(2) - b*d*e + c*d**S(2))) - S(1)/(S(2)*a*d*x**S(2)) + (a*c*e - b**S(2)*e + b*c*d)*log(a + b*x**S(2) + c*x**S(4))/(S(4)*a**S(2)*(a*e**S(2) - b*d*e + c*d**S(2))) - (S(3)*a*b*c*e - S(2)*a*c**S(2)*d - b**S(3)*e + b**S(2)*c*d)*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*a**S(2)*sqrt(-S(4)*a*c + b**S(2))*(a*e**S(2) - b*d*e + c*d**S(2))) - (a*e + b*d)*log(x)/(a**S(2)*d**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(5)*(d + e*x**S(2))*(a + b*x**S(2) + c*x**S(4))), x), x, -e**S(4)*log(d + e*x**S(2))/(S(2)*d**S(3)*(a*e**S(2) - b*d*e + c*d**S(2))) - S(1)/(S(4)*a*d*x**S(4)) + (a*e + b*d)/(S(2)*a**S(2)*d**S(2)*x**S(2)) - (S(2)*a*b*c*e - a*c**S(2)*d - b**S(3)*e + b**S(2)*c*d)*log(a + b*x**S(2) + c*x**S(4))/(S(4)*a**S(3)*(a*e**S(2) - b*d*e + c*d**S(2))) + (-S(2)*a**S(2)*c**S(2)*e + S(4)*a*b**S(2)*c*e - S(3)*a*b*c**S(2)*d - b**S(4)*e + b**S(3)*c*d)*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*a**S(3)*sqrt(-S(4)*a*c + b**S(2))*(a*e**S(2) - b*d*e + c*d**S(2))) + (a*b*d*e - a*(-a*e**S(2) + c*d**S(2)) + b**S(2)*d**S(2))*log(x)/(a**S(3)*d**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(8)/((d + e*x**S(2))*(a + b*x**S(2) + c*x**S(4))), x), x, d**(S(7)/2)*atan(sqrt(e)*x/sqrt(d))/(e**(S(5)/2)*(a*e**S(2) - b*d*e + c*d**S(2))) + x**S(3)/(S(3)*c*e) - x*(b*e + c*d)/(c**S(2)*e**S(2)) - sqrt(S(2))*(a**S(2)*c*e - a*b**S(2)*e - S(2)*a*b*c*d + b**S(3)*d + (S(3)*a**S(2)*b*c*e + S(2)*a**S(2)*c**S(2)*d - a*b**S(3)*e - S(4)*a*b**S(2)*c*d + b**S(4)*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*c**(S(5)/2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(a*e**S(2) - b*d*e + c*d**S(2))) - sqrt(S(2))*(a**S(2)*c*e - a*b**S(2)*e - S(2)*a*b*c*d + b**S(3)*d - (S(3)*a**S(2)*b*c*e + S(2)*a**S(2)*c**S(2)*d - a*b**S(3)*e - S(4)*a*b**S(2)*c*d + b**S(4)*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*c**(S(5)/2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(a*e**S(2) - b*d*e + c*d**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(6)/((d + e*x**S(2))*(a + b*x**S(2) + c*x**S(4))), x), x, -d**(S(5)/2)*atan(sqrt(e)*x/sqrt(d))/(e**(S(3)/2)*(a*e**S(2) - b*d*e + c*d**S(2))) + x/(c*e) + sqrt(S(2))*(-a*b*e - a*c*d + b**S(2)*d + (S(2)*a**S(2)*c*e - a*b**S(2)*e - S(3)*a*b*c*d + b**S(3)*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*c**(S(3)/2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(a*e**S(2) - b*d*e + c*d**S(2))) + sqrt(S(2))*(-a*b*e - a*c*d + b**S(2)*d - (S(2)*a**S(2)*c*e - a*b**S(2)*e - S(3)*a*b*c*d + b**S(3)*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*c**(S(3)/2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(a*e**S(2) - b*d*e + c*d**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)/((d + e*x**S(2))*(a + b*x**S(2) + c*x**S(4))), x), x, d**(S(3)/2)*atan(sqrt(e)*x/sqrt(d))/(sqrt(e)*(a*e**S(2) - b*d*e + c*d**S(2))) - sqrt(S(2))*(-a*e + b*d + (-a*b*e - S(2)*a*c*d + b**S(2)*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*sqrt(c)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(a*e**S(2) - b*d*e + c*d**S(2))) - sqrt(S(2))*(-a*e + b*d - (-a*b*e - S(2)*a*c*d + b**S(2)*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*sqrt(c)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(a*e**S(2) - b*d*e + c*d**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/((d + e*x**S(2))*(a + b*x**S(2) + c*x**S(4))), x), x, sqrt(S(2))*sqrt(c)*(d + (-S(2)*a*e + b*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(a*e**S(2) - b*d*e + c*d**S(2))) + sqrt(S(2))*sqrt(c)*(d - (-S(2)*a*e + b*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(a*e**S(2) - b*d*e + c*d**S(2))) - sqrt(d)*sqrt(e)*atan(sqrt(e)*x/sqrt(d))/(a*e**S(2) - b*d*e + c*d**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((d + e*x**S(2))*(a + b*x**S(2) + c*x**S(4))), x), x, -sqrt(S(2))*sqrt(c)*(e + (-b*e + S(2)*c*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(a*e**S(2) - b*d*e + c*d**S(2))) - sqrt(S(2))*sqrt(c)*(e - (-b*e + S(2)*c*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(a*e**S(2) - b*d*e + c*d**S(2))) + e**(S(3)/2)*atan(sqrt(e)*x/sqrt(d))/(sqrt(d)*(a*e**S(2) - b*d*e + c*d**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*(d + e*x**S(2))*(a + b*x**S(2) + c*x**S(4))), x), x, -e**(S(5)/2)*atan(sqrt(e)*x/sqrt(d))/(d**(S(3)/2)*(a*e**S(2) - b*d*e + c*d**S(2))) + sqrt(S(2))*sqrt(c)*(S(2)*a*c*e - b**S(2)*e + b*c*d - sqrt(-S(4)*a*c + b**S(2))*(-b*e + c*d))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*a*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*sqrt(-S(4)*a*c + b**S(2))*(a*e**S(2) - b*d*e + c*d**S(2))) - sqrt(S(2))*sqrt(c)*(S(2)*a*c*e - b**S(2)*e + b*c*d + sqrt(-S(4)*a*c + b**S(2))*(-b*e + c*d))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*a*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*sqrt(-S(4)*a*c + b**S(2))*(a*e**S(2) - b*d*e + c*d**S(2))) - S(1)/(a*d*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(4)*(d + e*x**S(2))*(a + b*x**S(2) + c*x**S(4))), x), x, e**(S(7)/2)*atan(sqrt(e)*x/sqrt(d))/(d**(S(5)/2)*(a*e**S(2) - b*d*e + c*d**S(2))) - S(1)/(S(3)*a*d*x**S(3)) + sqrt(S(2))*sqrt(c)*(a*c*(S(2)*c*d + e*sqrt(-S(4)*a*c + b**S(2))) + b**S(3)*e - b**S(2)*(c*d + e*sqrt(-S(4)*a*c + b**S(2))) + b*c*(-S(3)*a*e + d*sqrt(-S(4)*a*c + b**S(2))))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*a**S(2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*sqrt(-S(4)*a*c + b**S(2))*(a*e**S(2) - b*d*e + c*d**S(2))) + sqrt(S(2))*sqrt(c)*(a*c*e - b**S(2)*e + b*c*d + (S(3)*a*b*c*e - S(2)*a*c**S(2)*d - b**S(3)*e + b**S(2)*c*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*a**S(2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(a*e**S(2) - b*d*e + c*d**S(2))) + (a*e + b*d)/(a**S(2)*d**S(2)*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(sqrt(f*x)*(d + e*x**S(2))*(a + b*x**S(2) + c*x**S(4))), x), x, -S(2)**(S(3)/4)*c**(S(3)/4)*(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))*atan(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(f*x)/(sqrt(f)*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)))/(S(2)*sqrt(f)*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)*sqrt(-S(4)*a*c + b**S(2))*(a*e**S(2) - b*d*e + c*d**S(2))) - S(2)**(S(3)/4)*c**(S(3)/4)*(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(f*x)/(sqrt(f)*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)))/(S(2)*sqrt(f)*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)*sqrt(-S(4)*a*c + b**S(2))*(a*e**S(2) - b*d*e + c*d**S(2))) + S(2)**(S(3)/4)*c**(S(3)/4)*(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))*atan(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(f*x)/(sqrt(f)*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)))/(S(2)*sqrt(f)*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)*sqrt(-S(4)*a*c + b**S(2))*(a*e**S(2) - b*d*e + c*d**S(2))) + S(2)**(S(3)/4)*c**(S(3)/4)*(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*sqrt(f*x)/(sqrt(f)*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)))/(S(2)*sqrt(f)*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)*sqrt(-S(4)*a*c + b**S(2))*(a*e**S(2) - b*d*e + c*d**S(2))) - sqrt(S(2))*e**(S(7)/4)*log(-sqrt(S(2))*d**(S(1)/4)*e**(S(1)/4)*sqrt(f*x) + sqrt(d)*sqrt(f) + sqrt(e)*sqrt(f)*x)/(S(4)*d**(S(3)/4)*sqrt(f)*(a*e**S(2) - b*d*e + c*d**S(2))) + sqrt(S(2))*e**(S(7)/4)*log(sqrt(S(2))*d**(S(1)/4)*e**(S(1)/4)*sqrt(f*x) + sqrt(d)*sqrt(f) + sqrt(e)*sqrt(f)*x)/(S(4)*d**(S(3)/4)*sqrt(f)*(a*e**S(2) - b*d*e + c*d**S(2))) - sqrt(S(2))*e**(S(7)/4)*atan(S(1) - sqrt(S(2))*e**(S(1)/4)*sqrt(f*x)/(d**(S(1)/4)*sqrt(f)))/(S(2)*d**(S(3)/4)*sqrt(f)*(a*e**S(2) - b*d*e + c*d**S(2))) + sqrt(S(2))*e**(S(7)/4)*atan(S(1) + sqrt(S(2))*e**(S(1)/4)*sqrt(f*x)/(d**(S(1)/4)*sqrt(f)))/(S(2)*d**(S(3)/4)*sqrt(f)*(a*e**S(2) - b*d*e + c*d**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)*sqrt(a + b*x**S(2) + c*x**S(4))/(d + e*x**S(2)), x), x, -b*(b + S(2)*c*x**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))/(S(16)*c**S(2)*e) + b*(-S(4)*a*c + b**S(2))*atanh((b + S(2)*c*x**S(2))/(S(2)*sqrt(c)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(32)*c**(S(5)/2)*e) + d**S(2)*sqrt(a + b*x**S(2) + c*x**S(4))/(S(2)*e**S(3)) + d**S(2)*sqrt(a*e**S(2) - b*d*e + c*d**S(2))*atanh((-S(2)*a*e + b*d + x**S(2)*(-b*e + S(2)*c*d))/(S(2)*sqrt(a + b*x**S(2) + c*x**S(4))*sqrt(a*e**S(2) - b*d*e + c*d**S(2))))/(S(2)*e**S(4)) - d*(b + S(2)*c*x**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))/(S(8)*c*e**S(2)) + (a + b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(6)*c*e) - d**S(2)*(-b*e + S(2)*c*d)*atanh((b + S(2)*c*x**S(2))/(S(2)*sqrt(c)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(4)*sqrt(c)*e**S(4)) + d*(-S(4)*a*c + b**S(2))*atanh((b + S(2)*c*x**S(2))/(S(2)*sqrt(c)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(16)*c**(S(3)/2)*e**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*sqrt(a + b*x**S(2) + c*x**S(4))/(d + e*x**S(2)), x), x, -d*sqrt(a*e**S(2) - b*d*e + c*d**S(2))*atanh((-S(2)*a*e + b*d + x**S(2)*(-b*e + S(2)*c*d))/(S(2)*sqrt(a + b*x**S(2) + c*x**S(4))*sqrt(a*e**S(2) - b*d*e + c*d**S(2))))/(S(2)*e**S(3)) - sqrt(a + b*x**S(2) + c*x**S(4))*(-b*e + S(4)*c*d - S(2)*c*e*x**S(2))/(S(8)*c*e**S(2)) + (-b**S(2)*e**S(2) + S(8)*c**S(2)*d**S(2) - S(4)*c*e*(-a*e + b*d))*atanh((b + S(2)*c*x**S(2))/(S(2)*sqrt(c)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(16)*c**(S(3)/2)*e**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*sqrt(a + b*x**S(2) + c*x**S(4))/(d + e*x**S(2)), x), x, sqrt(a + b*x**S(2) + c*x**S(4))/(S(2)*e) + sqrt(a*e**S(2) - b*d*e + c*d**S(2))*atanh((-S(2)*a*e + b*d + x**S(2)*(-b*e + S(2)*c*d))/(S(2)*sqrt(a + b*x**S(2) + c*x**S(4))*sqrt(a*e**S(2) - b*d*e + c*d**S(2))))/(S(2)*e**S(2)) - (-b*e + S(2)*c*d)*atanh((b + S(2)*c*x**S(2))/(S(2)*sqrt(c)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(4)*sqrt(c)*e**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a + b*x**S(2) + c*x**S(4))/(x*(d + e*x**S(2))), x), x, -sqrt(a)*atanh((S(2)*a + b*x**S(2))/(S(2)*sqrt(a)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(2)*d) + sqrt(c)*atanh((b + S(2)*c*x**S(2))/(S(2)*sqrt(c)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(2)*e) - sqrt(a*e**S(2) - b*d*e + c*d**S(2))*atanh((-S(2)*a*e + b*d + x**S(2)*(-b*e + S(2)*c*d))/(S(2)*sqrt(a + b*x**S(2) + c*x**S(4))*sqrt(a*e**S(2) - b*d*e + c*d**S(2))))/(S(2)*d*e), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a + b*x**S(2) + c*x**S(4))/(x**S(3)*(d + e*x**S(2))), x), x, sqrt(a)*e*atanh((S(2)*a + b*x**S(2))/(S(2)*sqrt(a)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(2)*d**S(2)) - b*e*atanh((b + S(2)*c*x**S(2))/(S(2)*sqrt(c)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(4)*sqrt(c)*d**S(2)) + sqrt(c)*atanh((b + S(2)*c*x**S(2))/(S(2)*sqrt(c)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(2)*d) - sqrt(a + b*x**S(2) + c*x**S(4))/(S(2)*d*x**S(2)) + sqrt(a*e**S(2) - b*d*e + c*d**S(2))*atanh((-S(2)*a*e + b*d + x**S(2)*(-b*e + S(2)*c*d))/(S(2)*sqrt(a + b*x**S(2) + c*x**S(4))*sqrt(a*e**S(2) - b*d*e + c*d**S(2))))/(S(2)*d**S(2)) - (-b*e + S(2)*c*d)*atanh((b + S(2)*c*x**S(2))/(S(2)*sqrt(c)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(4)*sqrt(c)*d**S(2)) - b*atanh((S(2)*a + b*x**S(2))/(S(2)*sqrt(a)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(4)*sqrt(a)*d), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(S(2)*x**S(2) + S(3)), x), x, x*(S(3)*x**S(2) + S(1))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/S(30) - x*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/S(4) + S(109)*sqrt(S(2))*x*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(S(120)*(sqrt(S(2))*x**S(2) + S(1))) + S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(S(-70) + S(263)*sqrt(S(2)))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(120)*(S(-2) + S(3)*sqrt(S(2)))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(S(15)*sqrt(S(2)) + S(45))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_pi(-S(11)*sqrt(S(2))/S(24) + S(1)/2, S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(32)*(-S(3)*sqrt(S(2)) + S(2))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) - S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(S(109)*sqrt(S(2))*x**S(2) + S(109))*elliptic_e(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(120)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + S(3)*sqrt(S(15))*atan(sqrt(S(15))*x/(S(3)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))))/S(16), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate(x**S(4)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(S(2)*x**S(2) + S(3)), x), x, x*(S(3)*x**S(2) + S(1))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/S(30) - x*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/S(4) + S(109)*sqrt(S(2))*x*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(S(120)*(sqrt(S(2))*x**S(2) + S(1))) - S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(S(1) + sqrt(S(2)))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(8)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) - S(2)**(S(3)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(-S(139)*sqrt(S(2)) + S(139))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(480)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(S(15)*sqrt(S(2)) + S(45))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_pi(-S(11)*sqrt(S(2))/S(24) + S(1)/2, S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(32)*(-S(3)*sqrt(S(2)) + S(2))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) - S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(S(45)*sqrt(S(2))*x**S(2) + S(45))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(16)*(-S(3)*sqrt(S(2)) + S(2))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) - S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(S(109)*sqrt(S(2))*x**S(2) + S(109))*elliptic_e(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(120)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + S(3)*sqrt(S(15))*atan(sqrt(S(15))*x/(S(3)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))))/S(16), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(S(2)*x**S(2) + S(3)), x), x, x*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/S(6) - S(7)*sqrt(S(2))*x*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(S(12)*(sqrt(S(2))*x**S(2) + S(1))) - S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(S(-4) + S(17)*sqrt(S(2)))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(12)*(S(-2) + S(3)*sqrt(S(2)))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) - S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(S(5)*sqrt(S(2)) + S(15))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_pi(-S(11)*sqrt(S(2))/S(24) + S(1)/2, S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(16)*(-S(3)*sqrt(S(2)) + S(2))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(S(7)*sqrt(S(2))*x**S(2) + S(7))*elliptic_e(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(12)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) - sqrt(S(15))*atan(sqrt(S(15))*x/(S(3)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))))/S(8), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate(x**S(2)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(S(2)*x**S(2) + S(3)), x), x, x*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/S(6) - S(7)*sqrt(S(2))*x*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(S(12)*(sqrt(S(2))*x**S(2) + S(1))) + S(2)**(S(3)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(-S(3)*sqrt(S(2)) + S(3))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(16)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(S(1) + sqrt(S(2)))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(12)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) - S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(S(5)*sqrt(S(2)) + S(15))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_pi(-S(11)*sqrt(S(2))/S(24) + S(1)/2, S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(16)*(-S(3)*sqrt(S(2)) + S(2))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(S(7)*sqrt(S(2))*x**S(2) + S(7))*elliptic_e(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(12)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(S(15)*sqrt(S(2))*x**S(2) + S(15))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(8)*(-S(3)*sqrt(S(2)) + S(2))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) - sqrt(S(15))*atan(sqrt(S(15))*x/(S(3)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))))/S(8), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(S(2)*x**S(2) + S(3)), x), x, sqrt(S(2))*x*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(S(2)*(sqrt(S(2))*x**S(2) + S(1))) - S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_e(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(2)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + S(2)**(S(3)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/((S(-2) + S(3)*sqrt(S(2)))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(S(5)*sqrt(S(2)) + S(15))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_pi(-S(11)*sqrt(S(2))/S(24) + S(1)/2, S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(24)*(-S(3)*sqrt(S(2)) + S(2))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + sqrt(S(15))*atan(sqrt(S(15))*x/(S(3)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))))/S(12), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate(sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(S(2)*x**S(2) + S(3)), x), x, sqrt(S(2))*x*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(S(2)*(sqrt(S(2))*x**S(2) + S(1))) - S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_e(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(2)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) - S(2)**(S(3)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(-sqrt(S(2)) + S(1))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(8)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(S(5)*sqrt(S(2)) + S(15))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_pi(-S(11)*sqrt(S(2))/S(24) + S(1)/2, S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(24)*(-S(3)*sqrt(S(2)) + S(2))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) - S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(S(5)*sqrt(S(2))*x**S(2) + S(5))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(4)*(-S(3)*sqrt(S(2)) + S(2))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + sqrt(S(15))*atan(sqrt(S(15))*x/(S(3)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))))/S(12), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(x**S(2)*(S(2)*x**S(2) + S(3))), x), x, sqrt(S(2))*x*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(S(3)*sqrt(S(2))*x**S(2) + S(3)) - S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_e(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(3)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/((S(-6) + S(9)*sqrt(S(2)))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) - S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(S(5)*sqrt(S(2)) + S(15))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_pi(-S(11)*sqrt(S(2))/S(24) + S(1)/2, S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(36)*(-S(3)*sqrt(S(2)) + S(2))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) - sqrt(S(15))*atan(sqrt(S(15))*x/(S(3)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))))/S(18) - sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(S(3)*x), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate(sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(x**S(2)*(S(2)*x**S(2) + S(3))), x), x, sqrt(S(2))*x*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(S(3)*sqrt(S(2))*x**S(2) + S(3)) - S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_e(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(3)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + S(2)**(S(3)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(sqrt(S(2)) + S(3))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(12)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) - S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(S(5)*sqrt(S(2)) + S(15))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_pi(-S(11)*sqrt(S(2))/S(24) + S(1)/2, S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(36)*(-S(3)*sqrt(S(2)) + S(2))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(S(5)*sqrt(S(2))*x**S(2) + S(5))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(6)*(-S(3)*sqrt(S(2)) + S(2))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) - sqrt(S(15))*atan(sqrt(S(15))*x/(S(3)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))))/S(18) - sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(S(3)*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(x**S(4)*(S(2)*x**S(2) + S(3))), x), x, -S(2)**(S(3)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(18)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) - S(5)*S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/((-S(27)*sqrt(S(2)) + S(18))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(S(5)*sqrt(S(2)) + S(15))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_pi(-S(11)*sqrt(S(2))/S(24) + S(1)/2, S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(54)*(-S(3)*sqrt(S(2)) + S(2))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + sqrt(S(15))*atan(sqrt(S(15))*x/(S(3)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))))/S(27) - sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(S(9)*x**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(x**S(6)*(S(2)*x**S(2) + S(3))), x), x, S(4)*sqrt(S(2))*x*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(S(45)*sqrt(S(2))*x**S(2) + S(45)) - S(4)*S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_e(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(45)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + S(10)*S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/((-S(81)*sqrt(S(2)) + S(54))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) - S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(-S(2)*sqrt(S(2)) + S(19))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(135)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + S(5)*S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(27)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) - S(5)*S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(sqrt(S(2)) + S(3))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_pi(-S(11)*sqrt(S(2))/S(24) + S(1)/2, S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/((-S(243)*sqrt(S(2)) + S(162))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) - S(2)*sqrt(S(15))*atan(sqrt(S(15))*x/(S(3)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))))/S(81) - S(4)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(S(45)*x) + S(4)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(S(135)*x**S(3)) - sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(S(15)*x**S(5)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)*(a + b*x**S(2) + c*x**S(4))**(S(3)/2)/(d + e*x**S(2)), x), x, -b*(b + S(2)*c*x**S(2))*(a + b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(32)*c**S(2)*e) + S(3)*b*(b + S(2)*c*x**S(2))*(-S(4)*a*c + b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))/(S(256)*c**S(3)*e) - S(3)*b*(-S(4)*a*c + b**S(2))**S(2)*atanh((b + S(2)*c*x**S(2))/(S(2)*sqrt(c)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(512)*c**(S(7)/2)*e) + d**S(2)*(a + b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(6)*e**S(3)) + d**S(2)*(a*e**S(2) - b*d*e + c*d**S(2))**(S(3)/2)*atanh((-S(2)*a*e + b*d + x**S(2)*(-b*e + S(2)*c*d))/(S(2)*sqrt(a + b*x**S(2) + c*x**S(4))*sqrt(a*e**S(2) - b*d*e + c*d**S(2))))/(S(2)*e**S(6)) + d**S(2)*sqrt(a + b*x**S(2) + c*x**S(4))*(b**S(2)*e**S(2) + S(8)*c**S(2)*d**S(2) - S(2)*c*e*x**S(2)*(-b*e + S(2)*c*d) - S(2)*c*e*(-S(4)*a*e + S(5)*b*d))/(S(16)*c*e**S(5)) - d*(b + S(2)*c*x**S(2))*(a + b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(16)*c*e**S(2)) + (a + b*x**S(2) + c*x**S(4))**(S(5)/2)/(S(10)*c*e) + d*(b + S(2)*c*x**S(2))*(-S(12)*a*c + S(3)*b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))/(S(128)*c**S(2)*e**S(2)) - d**S(2)*(-b*e + S(2)*c*d)*(-b**S(2)*e**S(2) + S(8)*c**S(2)*d**S(2) - S(4)*c*e*(-S(3)*a*e + S(2)*b*d))*atanh((b + S(2)*c*x**S(2))/(S(2)*sqrt(c)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(32)*c**(S(3)/2)*e**S(6)) - S(3)*d*(-S(4)*a*c + b**S(2))**S(2)*atanh((b + S(2)*c*x**S(2))/(S(2)*sqrt(c)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(256)*c**(S(5)/2)*e**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*(a + b*x**S(2) + c*x**S(4))**(S(3)/2)/(d + e*x**S(2)), x), x, -d*(a*e**S(2) - b*d*e + c*d**S(2))**(S(3)/2)*atanh((-S(2)*a*e + b*d + x**S(2)*(-b*e + S(2)*c*d))/(S(2)*sqrt(a + b*x**S(2) + c*x**S(4))*sqrt(a*e**S(2) - b*d*e + c*d**S(2))))/(S(2)*e**S(5)) - (a + b*x**S(2) + c*x**S(4))**(S(3)/2)*(-S(3)*b*e + S(8)*c*d - S(6)*c*e*x**S(2))/(S(48)*c*e**S(2)) - sqrt(a + b*x**S(2) + c*x**S(4))*(S(3)*b**S(3)*e**S(3) + S(4)*b*c*e**S(2)*(-S(3)*a*e + S(2)*b*d) + S(64)*c**S(3)*d**S(3) - S(16)*c**S(2)*d*e*(-S(4)*a*e + S(5)*b*d) - S(2)*c*e*x**S(2)*(-S(3)*b**S(2)*e**S(2) + S(16)*c**S(2)*d**S(2) - S(4)*c*e*(-S(3)*a*e + S(2)*b*d)))/(S(128)*c**S(2)*e**S(4)) + (S(3)*b**S(4)*e**S(4) + S(8)*b**S(2)*c*e**S(3)*(-S(3)*a*e + b*d) + S(128)*c**S(4)*d**S(4) - S(192)*c**S(3)*d**S(2)*e*(-a*e + b*d) + S(48)*c**S(2)*e**S(2)*(-a*e + b*d)**S(2))*atanh((b + S(2)*c*x**S(2))/(S(2)*sqrt(c)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(256)*c**(S(5)/2)*e**S(5)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(a + b*x**S(2) + c*x**S(4))**(S(3)/2)/(d + e*x**S(2)), x), x, (a + b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(6)*e) + (a*e**S(2) - b*d*e + c*d**S(2))**(S(3)/2)*atanh((-S(2)*a*e + b*d + x**S(2)*(-b*e + S(2)*c*d))/(S(2)*sqrt(a + b*x**S(2) + c*x**S(4))*sqrt(a*e**S(2) - b*d*e + c*d**S(2))))/(S(2)*e**S(4)) + sqrt(a + b*x**S(2) + c*x**S(4))*(b**S(2)*e**S(2) + S(8)*c**S(2)*d**S(2) - S(2)*c*e*x**S(2)*(-b*e + S(2)*c*d) - S(2)*c*e*(-S(4)*a*e + S(5)*b*d))/(S(16)*c*e**S(3)) - (-b*e + S(2)*c*d)*(-b**S(2)*e**S(2) + S(8)*c**S(2)*d**S(2) - S(4)*c*e*(-S(3)*a*e + S(2)*b*d))*atanh((b + S(2)*c*x**S(2))/(S(2)*sqrt(c)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(32)*c**(S(3)/2)*e**S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))**(S(3)/2)/(x*(d + e*x**S(2))), x), x, -a**(S(3)/2)*atanh((S(2)*a + b*x**S(2))/(S(2)*sqrt(a)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(2)*d) + a*b*atanh((b + S(2)*c*x**S(2))/(S(2)*sqrt(c)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(4)*sqrt(c)*d) + a*sqrt(a + b*x**S(2) + c*x**S(4))/(S(2)*d) - sqrt(a + b*x**S(2) + c*x**S(4))*(S(4)*c*d**S(2) - S(2)*c*d*e*x**S(2) - e*(-S(4)*a*e + S(5)*b*d))/(S(8)*d*e**S(2)) - (a*e**S(2) - b*d*e + c*d**S(2))**(S(3)/2)*atanh((-S(2)*a*e + b*d + x**S(2)*(-b*e + S(2)*c*d))/(S(2)*sqrt(a + b*x**S(2) + c*x**S(4))*sqrt(a*e**S(2) - b*d*e + c*d**S(2))))/(S(2)*d*e**S(3)) + (b*e**S(2)*(-S(4)*a*e + S(3)*b*d) + S(8)*c**S(2)*d**S(3) - S(12)*c*d*e*(-a*e + b*d))*atanh((b + S(2)*c*x**S(2))/(S(2)*sqrt(c)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(16)*sqrt(c)*d*e**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))**(S(3)/2)/(x**S(3)*(d + e*x**S(2))), x), x, a**(S(3)/2)*e*atanh((S(2)*a + b*x**S(2))/(S(2)*sqrt(a)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(2)*d**S(2)) - S(3)*sqrt(a)*b*atanh((S(2)*a + b*x**S(2))/(S(2)*sqrt(a)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(4)*d) + b*e*(-S(12)*a*c + b**S(2))*atanh((b + S(2)*c*x**S(2))/(S(2)*sqrt(c)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(32)*c**(S(3)/2)*d**S(2)) + (S(9)*b + S(6)*c*x**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))/(S(8)*d) - (a + b*x**S(2) + c*x**S(4))**(S(3)/2)/(S(2)*d*x**S(2)) + (a*e**S(2) - b*d*e + c*d**S(2))**(S(3)/2)*atanh((-S(2)*a*e + b*d + x**S(2)*(-b*e + S(2)*c*d))/(S(2)*sqrt(a + b*x**S(2) + c*x**S(4))*sqrt(a*e**S(2) - b*d*e + c*d**S(2))))/(S(2)*d**S(2)*e**S(2)) - e*sqrt(a + b*x**S(2) + c*x**S(4))*(S(8)*a*c + b**S(2) + S(2)*b*c*x**S(2))/(S(16)*c*d**S(2)) + sqrt(a + b*x**S(2) + c*x**S(4))*(b**S(2)*e**S(2) + S(8)*c**S(2)*d**S(2) - S(2)*c*e*x**S(2)*(-b*e + S(2)*c*d) - S(2)*c*e*(-S(4)*a*e + S(5)*b*d))/(S(16)*c*d**S(2)*e) + (S(12)*a*c + S(3)*b**S(2))*atanh((b + S(2)*c*x**S(2))/(S(2)*sqrt(c)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(16)*sqrt(c)*d) - (-b*e + S(2)*c*d)*(-b**S(2)*e**S(2) + S(8)*c**S(2)*d**S(2) - S(4)*c*e*(-S(3)*a*e + S(2)*b*d))*atanh((b + S(2)*c*x**S(2))/(S(2)*sqrt(c)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(32)*c**(S(3)/2)*d**S(2)*e**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(S(2)*x**S(4) + S(2)*x**S(2) + S(1))**(S(3)/2)/(-S(2)*x**S(2) + S(3)), x), x, -S(27)*x**S(3)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/S(70) - x*(S(2)*x**S(4) + S(2)*x**S(2) + S(1))**(S(3)/2)/S(14) - S(213)*x*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/S(140) - S(2211)*sqrt(S(2))*x*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(S(280)*(sqrt(S(2))*x**S(2) + S(1))) - S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(S(1542) + S(8151)*sqrt(S(2)))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(280)*(S(2) + S(3)*sqrt(S(2)))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) - S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(-S(289)*sqrt(S(2)) + S(867))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_pi(S(1)/2 + S(11)*sqrt(S(2))/S(24), S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(32)*(S(2) + S(3)*sqrt(S(2)))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(S(2211)*sqrt(S(2))*x**S(2) + S(2211))*elliptic_e(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(280)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + S(17)*sqrt(S(51))*atanh(sqrt(S(51))*x/(S(3)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))))/S(16), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate(x**S(2)*(S(2)*x**S(4) + S(2)*x**S(2) + S(1))**(S(3)/2)/(-S(2)*x**S(2) + S(3)), x), x, -S(3)*x*(x**S(2) + S(2))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/S(35) - x*(S(3)*x**S(2) + S(1))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/S(10) - x*(S(2)*x**S(4) + S(2)*x**S(2) + S(1))**(S(3)/2)/S(14) - S(5)*x*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/S(4) - S(6)*sqrt(S(2))*x*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(S(35)*sqrt(S(2))*x**S(2) + S(35)) - S(309)*sqrt(S(2))*x*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(S(40)*(sqrt(S(2))*x**S(2) + S(1))) + S(6)*S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_e(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(35)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) - S(2)**(S(3)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(S(51)*sqrt(S(2)) + S(255))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(32)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) - S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(S(5) + S(5)*sqrt(S(2)))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(8)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) - S(2)**(S(3)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(S(6)*sqrt(S(2)) + S(9))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(140)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + S(2)**(S(3)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(-sqrt(S(2)) + S(1))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(40)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) - S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(-S(289)*sqrt(S(2)) + S(867))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_pi(S(1)/2 + S(11)*sqrt(S(2))/S(24), S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(32)*(S(2) + S(3)*sqrt(S(2)))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(S(309)*sqrt(S(2))*x**S(2) + S(309))*elliptic_e(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(40)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(S(867)*sqrt(S(2))*x**S(2) + S(867))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(16)*(S(2) + S(3)*sqrt(S(2)))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + S(17)*sqrt(S(51))*atanh(sqrt(S(51))*x/(S(3)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))))/S(16), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(2)*x**S(4) + S(2)*x**S(2) + S(1))**(S(3)/2)/(-S(2)*x**S(2) + S(3)), x), x, -x**S(3)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/S(5) - S(9)*x*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/S(10) - S(103)*sqrt(S(2))*x*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(S(20)*(sqrt(S(2))*x**S(2) + S(1))) - S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(S(66) + S(383)*sqrt(S(2)))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(20)*(S(2) + S(3)*sqrt(S(2)))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) - S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(-S(289)*sqrt(S(2)) + S(867))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_pi(S(1)/2 + S(11)*sqrt(S(2))/S(24), S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(48)*(S(2) + S(3)*sqrt(S(2)))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(S(103)*sqrt(S(2))*x**S(2) + S(103))*elliptic_e(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(20)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + S(17)*sqrt(S(51))*atanh(sqrt(S(51))*x/(S(3)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))))/S(24), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate((S(2)*x**S(4) + S(2)*x**S(2) + S(1))**(S(3)/2)/(-S(2)*x**S(2) + S(3)), x), x, -x*(S(3)*x**S(2) + S(1))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/S(15) - S(5)*x*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/S(6) - S(103)*sqrt(S(2))*x*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(S(20)*(sqrt(S(2))*x**S(2) + S(1))) - S(2)**(S(3)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(S(17)*sqrt(S(2)) + S(85))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(16)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) - S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(S(5) + S(5)*sqrt(S(2)))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(12)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + S(2)**(S(3)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(-sqrt(S(2)) + S(1))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(60)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) - S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(-S(289)*sqrt(S(2)) + S(867))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_pi(S(1)/2 + S(11)*sqrt(S(2))/S(24), S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(48)*(S(2) + S(3)*sqrt(S(2)))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(S(103)*sqrt(S(2))*x**S(2) + S(103))*elliptic_e(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(20)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(S(289)*sqrt(S(2))*x**S(2) + S(289))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(8)*(S(2) + S(3)*sqrt(S(2)))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + S(17)*sqrt(S(51))*atanh(sqrt(S(51))*x/(S(3)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))))/S(24), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(2)*x**S(4) + S(2)*x**S(2) + S(1))**(S(3)/2)/(x**S(2)*(-S(2)*x**S(2) + S(3))), x), x, sqrt(S(2))*x*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(S(3)*sqrt(S(2))*x**S(2) + S(3)) - S(17)*sqrt(S(2))*x*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(S(6)*(sqrt(S(2))*x**S(2) + S(1))) - S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_e(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(3)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) - S(2)**(S(3)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(S(17)*sqrt(S(2)) + S(85))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(24)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(6)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) - S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(-S(289)*sqrt(S(2)) + S(867))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_pi(S(1)/2 + S(11)*sqrt(S(2))/S(24), S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(72)*(S(2) + S(3)*sqrt(S(2)))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(S(17)*sqrt(S(2))*x**S(2) + S(17))*elliptic_e(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(6)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(S(289)*sqrt(S(2))*x**S(2) + S(289))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(12)*(S(2) + S(3)*sqrt(S(2)))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + S(17)*sqrt(S(51))*atanh(sqrt(S(51))*x/(S(3)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))))/S(36) - (x**S(2) + S(1))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(S(3)*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(2)*x**S(4) + S(2)*x**S(2) + S(1))**(S(3)/2)/(x**S(4)*(-S(2)*x**S(2) + S(3))), x), x, sqrt(S(2))*x*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(S(9)*sqrt(S(2))*x**S(2) + S(9)) - S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_e(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(9)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) - S(2)**(S(3)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(S(17)*sqrt(S(2)) + S(85))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(36)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(S(5)*sqrt(S(2)) + S(9))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(9)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) - S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(-S(289)*sqrt(S(2)) + S(867))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_pi(S(1)/2 + S(11)*sqrt(S(2))/S(24), S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(108)*(S(2) + S(3)*sqrt(S(2)))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(S(289)*sqrt(S(2))*x**S(2) + S(289))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(18)*(S(2) + S(3)*sqrt(S(2)))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + S(17)*sqrt(S(51))*atanh(sqrt(S(51))*x/(S(3)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))))/S(54) - S(2)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/x - (-S(8)*x**S(2) + S(1))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(S(9)*x**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(2)*x**S(4) + S(2)*x**S(2) + S(1))**(S(3)/2)/(x**S(6)*(-S(2)*x**S(2) + S(3))), x), x, S(262)*sqrt(S(2))*x*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(S(135)*sqrt(S(2))*x**S(2) + S(135)) - S(262)*S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_e(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(135)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) - S(2)**(S(3)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(-S(17)*sqrt(S(2)) + S(51))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(54)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + S(2)**(S(3)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(S(23)*sqrt(S(2)) + S(37))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(135)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + S(289)*S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/((S(54) + S(81)*sqrt(S(2)))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) - S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(-S(289)*sqrt(S(2)) + S(867))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_pi(S(1)/2 + S(11)*sqrt(S(2))/S(24), S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(162)*(S(2) + S(3)*sqrt(S(2)))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + S(17)*sqrt(S(51))*atanh(sqrt(S(51))*x/(S(3)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))))/S(81) - S(262)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(S(135)*x) + S(74)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(S(135)*x**S(3)) - (S(40)*x**S(2) + S(3))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(S(45)*x**S(5)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)/((d + e*x**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))), x), x, -b*atanh((b + S(2)*c*x**S(2))/(S(2)*sqrt(c)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(4)*c**(S(3)/2)*e) + d**S(2)*atanh((-S(2)*a*e + b*d + x**S(2)*(-b*e + S(2)*c*d))/(S(2)*sqrt(a + b*x**S(2) + c*x**S(4))*sqrt(a*e**S(2) - b*d*e + c*d**S(2))))/(S(2)*e**S(2)*sqrt(a*e**S(2) - b*d*e + c*d**S(2))) + sqrt(a + b*x**S(2) + c*x**S(4))/(S(2)*c*e) - d*atanh((b + S(2)*c*x**S(2))/(S(2)*sqrt(c)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(2)*sqrt(c)*e**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/((d + e*x**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))), x), x, -d*atanh((-S(2)*a*e + b*d + x**S(2)*(-b*e + S(2)*c*d))/(S(2)*sqrt(a + b*x**S(2) + c*x**S(4))*sqrt(a*e**S(2) - b*d*e + c*d**S(2))))/(S(2)*e*sqrt(a*e**S(2) - b*d*e + c*d**S(2))) + atanh((b + S(2)*c*x**S(2))/(S(2)*sqrt(c)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(2)*sqrt(c)*e), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/((d + e*x**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))), x), x, atanh((-S(2)*a*e + b*d + x**S(2)*(-b*e + S(2)*c*d))/(S(2)*sqrt(a + b*x**S(2) + c*x**S(4))*sqrt(a*e**S(2) - b*d*e + c*d**S(2))))/(S(2)*sqrt(a*e**S(2) - b*d*e + c*d**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*(d + e*x**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))), x), x, -e*atanh((-S(2)*a*e + b*d + x**S(2)*(-b*e + S(2)*c*d))/(S(2)*sqrt(a + b*x**S(2) + c*x**S(4))*sqrt(a*e**S(2) - b*d*e + c*d**S(2))))/(S(2)*d*sqrt(a*e**S(2) - b*d*e + c*d**S(2))) - atanh((S(2)*a + b*x**S(2))/(S(2)*sqrt(a)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(2)*sqrt(a)*d), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(3)*(d + e*x**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))), x), x, e**S(2)*atanh((-S(2)*a*e + b*d + x**S(2)*(-b*e + S(2)*c*d))/(S(2)*sqrt(a + b*x**S(2) + c*x**S(4))*sqrt(a*e**S(2) - b*d*e + c*d**S(2))))/(S(2)*d**S(2)*sqrt(a*e**S(2) - b*d*e + c*d**S(2))) - sqrt(a + b*x**S(2) + c*x**S(4))/(S(2)*a*d*x**S(2)) + e*atanh((S(2)*a + b*x**S(2))/(S(2)*sqrt(a)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(2)*sqrt(a)*d**S(2)) + b*atanh((S(2)*a + b*x**S(2))/(S(2)*sqrt(a)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(4)*a**(S(3)/2)*d), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)/((S(2)*x**S(2) + S(3))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))), x), x, sqrt(S(2))*x*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(S(4)*(sqrt(S(2))*x**S(2) + S(1))) - S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_e(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(4)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(8)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(S(3)*sqrt(S(2)) + S(9))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_pi(-S(11)*sqrt(S(2))/S(24) + S(1)/2, S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(16)*(-S(3)*sqrt(S(2)) + S(2))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) - S(2)**(S(3)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(S(3)*sqrt(S(2))*x**S(2) + S(3))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(16)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) - S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(S(9)*sqrt(S(2))*x**S(2) + S(9))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(8)*(-S(3)*sqrt(S(2)) + S(2))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + S(3)*sqrt(S(15))*atan(sqrt(S(15))*x/(S(3)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))))/S(40), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/((S(2)*x**S(2) + S(3))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))), x), x, S(2)**(S(3)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(8)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) - S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(sqrt(S(2)) + S(3))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_pi(-S(11)*sqrt(S(2))/S(24) + S(1)/2, S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(8)*(-S(3)*sqrt(S(2)) + S(2))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(S(3)*sqrt(S(2))*x**S(2) + S(3))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(4)*(-S(3)*sqrt(S(2)) + S(2))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) - sqrt(S(15))*atan(sqrt(S(15))*x/(S(3)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))))/S(20), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((S(2)*x**S(2) + S(3))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))), x), x, -S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(2)*(-S(3)*sqrt(S(2)) + S(2))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(sqrt(S(2)) + S(3))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_pi(-S(11)*sqrt(S(2))/S(24) + S(1)/2, S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(12)*(-S(3)*sqrt(S(2)) + S(2))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + sqrt(S(15))*atan(sqrt(S(15))*x/(S(3)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))))/S(30), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*(S(2)*x**S(2) + S(3))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))), x), x, sqrt(S(2))*x*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(S(3)*sqrt(S(2))*x**S(2) + S(3)) - S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_e(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(3)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/((-S(9)*sqrt(S(2)) + S(6))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(6)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) - S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(sqrt(S(2)) + S(3))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_pi(-S(11)*sqrt(S(2))/S(24) + S(1)/2, S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(18)*(-S(3)*sqrt(S(2)) + S(2))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) - sqrt(S(15))*atan(sqrt(S(15))*x/(S(3)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))))/S(45) - sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(S(3)*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(4)*(S(2)*x**S(2) + S(3))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))), x), x, -S(2)*sqrt(S(2))*x*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(S(3)*sqrt(S(2))*x**S(2) + S(3)) + S(2)*S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_e(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(3)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) - S(2)**(S(3)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(S(1) + S(2)*sqrt(S(2)))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(18)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) - S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(9)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) - S(2)*S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/((-S(27)*sqrt(S(2)) + S(18))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(sqrt(S(2)) + S(3))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_pi(-S(11)*sqrt(S(2))/S(24) + S(1)/2, S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/((-S(81)*sqrt(S(2)) + S(54))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + S(2)*sqrt(S(15))*atan(sqrt(S(15))*x/(S(3)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))))/S(135) + S(2)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(S(3)*x) - sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(S(9)*x**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(7)/((d + e*x**S(2))*(a + b*x**S(2) + c*x**S(4))**(S(3)/2)), x), x, -b*sqrt(a + b*x**S(2) + c*x**S(4))/(c*e*(-S(4)*a*c + b**S(2))) - d**S(3)*atanh((-S(2)*a*e + b*d + x**S(2)*(-b*e + S(2)*c*d))/(S(2)*sqrt(a + b*x**S(2) + c*x**S(4))*sqrt(a*e**S(2) - b*d*e + c*d**S(2))))/(S(2)*e*(a*e**S(2) - b*d*e + c*d**S(2))**(S(3)/2)) + d**S(3)*(S(2)*a*c*e - b**S(2)*e + b*c*d + c*x**S(2)*(-b*e + S(2)*c*d))/(e**S(3)*(-S(4)*a*c + b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))*(a*e**S(2) - b*d*e + c*d**S(2))) - d**S(2)*(b + S(2)*c*x**S(2))/(e**S(3)*(-S(4)*a*c + b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))) - d*(S(2)*a + b*x**S(2))/(e**S(2)*(-S(4)*a*c + b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))) + x**S(2)*(S(2)*a + b*x**S(2))/(e*(-S(4)*a*c + b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))) + atanh((b + S(2)*c*x**S(2))/(S(2)*sqrt(c)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(2)*c**(S(3)/2)*e), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)/((d + e*x**S(2))*(a + b*x**S(2) + c*x**S(4))**(S(3)/2)), x), x, d**S(2)*atanh((-S(2)*a*e + b*d + x**S(2)*(-b*e + S(2)*c*d))/(S(2)*sqrt(a + b*x**S(2) + c*x**S(4))*sqrt(a*e**S(2) - b*d*e + c*d**S(2))))/(S(2)*(a*e**S(2) - b*d*e + c*d**S(2))**(S(3)/2)) - d**S(2)*(S(2)*a*c*e - b**S(2)*e + b*c*d + c*x**S(2)*(-b*e + S(2)*c*d))/(e**S(2)*(-S(4)*a*c + b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))*(a*e**S(2) - b*d*e + c*d**S(2))) + d*(b + S(2)*c*x**S(2))/(e**S(2)*(-S(4)*a*c + b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))) + (S(2)*a + b*x**S(2))/(e*(-S(4)*a*c + b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/((d + e*x**S(2))*(a + b*x**S(2) + c*x**S(4))**(S(3)/2)), x), x, -d*e*atanh((-S(2)*a*e + b*d + x**S(2)*(-b*e + S(2)*c*d))/(S(2)*sqrt(a + b*x**S(2) + c*x**S(4))*sqrt(a*e**S(2) - b*d*e + c*d**S(2))))/(S(2)*(a*e**S(2) - b*d*e + c*d**S(2))**(S(3)/2)) + (a*(-b*e + S(2)*c*d) + c*x**S(2)*(-S(2)*a*e + b*d))/((-S(4)*a*c + b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))*(a*e**S(2) - b*d*e + c*d**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/((d + e*x**S(2))*(a + b*x**S(2) + c*x**S(4))**(S(3)/2)), x), x, e**S(2)*atanh((-S(2)*a*e + b*d + x**S(2)*(-b*e + S(2)*c*d))/(S(2)*sqrt(a + b*x**S(2) + c*x**S(4))*sqrt(a*e**S(2) - b*d*e + c*d**S(2))))/(S(2)*(a*e**S(2) - b*d*e + c*d**S(2))**(S(3)/2)) - (S(2)*a*c*e - b**S(2)*e + b*c*d + c*x**S(2)*(-b*e + S(2)*c*d))/((-S(4)*a*c + b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))*(a*e**S(2) - b*d*e + c*d**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*(d + e*x**S(2))*(a + b*x**S(2) + c*x**S(4))**(S(3)/2)), x), x, -e**S(3)*atanh((-S(2)*a*e + b*d + x**S(2)*(-b*e + S(2)*c*d))/(S(2)*sqrt(a + b*x**S(2) + c*x**S(4))*sqrt(a*e**S(2) - b*d*e + c*d**S(2))))/(S(2)*d*(a*e**S(2) - b*d*e + c*d**S(2))**(S(3)/2)) + e*(S(2)*a*c*e - b**S(2)*e + b*c*d + c*x**S(2)*(-b*e + S(2)*c*d))/(d*(-S(4)*a*c + b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))*(a*e**S(2) - b*d*e + c*d**S(2))) + (-S(2)*a*c + b**S(2) + b*c*x**S(2))/(a*d*(-S(4)*a*c + b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))) - atanh((S(2)*a + b*x**S(2))/(S(2)*sqrt(a)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(2)*a**(S(3)/2)*d), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(3)*(d + e*x**S(2))*(a + b*x**S(2) + c*x**S(4))**(S(3)/2)), x), x, e**S(4)*atanh((-S(2)*a*e + b*d + x**S(2)*(-b*e + S(2)*c*d))/(S(2)*sqrt(a + b*x**S(2) + c*x**S(4))*sqrt(a*e**S(2) - b*d*e + c*d**S(2))))/(S(2)*d**S(2)*(a*e**S(2) - b*d*e + c*d**S(2))**(S(3)/2)) - e**S(2)*(S(2)*a*c*e - b**S(2)*e + b*c*d + c*x**S(2)*(-b*e + S(2)*c*d))/(d**S(2)*(-S(4)*a*c + b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))*(a*e**S(2) - b*d*e + c*d**S(2))) + (-S(2)*a*c + b**S(2) + b*c*x**S(2))/(a*d*x**S(2)*(-S(4)*a*c + b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))) - e*(-S(2)*a*c + b**S(2) + b*c*x**S(2))/(a*d**S(2)*(-S(4)*a*c + b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))) - (-S(8)*a*c + S(3)*b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))/(S(2)*a**S(2)*d*x**S(2)*(-S(4)*a*c + b**S(2))) + e*atanh((S(2)*a + b*x**S(2))/(S(2)*sqrt(a)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(2)*a**(S(3)/2)*d**S(2)) + S(3)*b*atanh((S(2)*a + b*x**S(2))/(S(2)*sqrt(a)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(4)*a**(S(5)/2)*d), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(8)/((S(2)*x**S(2) + S(3))*(S(2)*x**S(4) + S(2)*x**S(2) + S(1))**(S(3)/2)), x), x, x**S(3)*(-S(2)*x**S(2) + S(1))/(S(20)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + x*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/S(20) + sqrt(S(2))*x*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(S(20)*(sqrt(S(2))*x**S(2) + S(1))) - S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_e(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(20)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) - S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(sqrt(S(2)) + S(7))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(80)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(S(27)*sqrt(S(2)) + S(81))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_pi(-S(11)*sqrt(S(2))/S(24) + S(1)/2, S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(160)*(-S(3)*sqrt(S(2)) + S(2))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(S(9)*sqrt(S(2))*x**S(2) + S(9))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(80)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) - S(2)**(S(3)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(S(27)*sqrt(S(2))*x**S(2) + S(27))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(160)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) - S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(S(81)*sqrt(S(2))*x**S(2) + S(81))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(80)*(-S(3)*sqrt(S(2)) + S(2))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + S(27)*sqrt(S(15))*atan(sqrt(S(15))*x/(S(3)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))))/S(400), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(6)/((S(2)*x**S(2) + S(3))*(S(2)*x**S(4) + S(2)*x**S(2) + S(1))**(S(3)/2)), x), x, x*(-S(2)*x**S(2) + S(1))/(S(20)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + sqrt(S(2))*x*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(S(20)*(sqrt(S(2))*x**S(2) + S(1))) - S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_e(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(20)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) - S(2)**(S(3)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(-sqrt(S(2)) + S(1))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(80)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) - S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(S(9)*sqrt(S(2)) + S(27))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_pi(-S(11)*sqrt(S(2))/S(24) + S(1)/2, S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(80)*(-S(3)*sqrt(S(2)) + S(2))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + S(2)**(S(3)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(S(9)*sqrt(S(2))*x**S(2) + S(9))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(80)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(S(27)*sqrt(S(2))*x**S(2) + S(27))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(40)*(-S(3)*sqrt(S(2)) + S(2))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) - S(9)*sqrt(S(15))*atan(sqrt(S(15))*x/(S(3)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))))/S(200), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)/((S(2)*x**S(2) + S(3))*(S(2)*x**S(4) + S(2)*x**S(2) + S(1))**(S(3)/2)), x), x, -x*(x**S(2) + S(2))/(S(10)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + sqrt(S(2))*x*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(S(20)*(sqrt(S(2))*x**S(2) + S(1))) - S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_e(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(20)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(-sqrt(S(2)) + S(1))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(40)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(S(3)*sqrt(S(2)) + S(9))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_pi(-S(11)*sqrt(S(2))/S(24) + S(1)/2, S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(40)*(-S(3)*sqrt(S(2)) + S(2))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) - S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(S(9)*sqrt(S(2))*x**S(2) + S(9))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(20)*(-S(3)*sqrt(S(2)) + S(2))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + S(3)*sqrt(S(15))*atan(sqrt(S(15))*x/(S(3)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))))/S(100), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/((S(2)*x**S(2) + S(3))*(S(2)*x**S(4) + S(2)*x**S(2) + S(1))**(S(3)/2)), x), x, x*(S(4)*x**S(2) + S(3))/(S(10)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) - sqrt(S(2))*x*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(S(5)*sqrt(S(2))*x**S(2) + S(5)) + S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_e(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(5)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) - S(2)**(S(3)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(S(1) + S(2)*sqrt(S(2)))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(40)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) - S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(sqrt(S(2)) + S(3))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_pi(-S(11)*sqrt(S(2))/S(24) + S(1)/2, S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(20)*(-S(3)*sqrt(S(2)) + S(2))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(S(3)*sqrt(S(2))*x**S(2) + S(3))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(10)*(-S(3)*sqrt(S(2)) + S(2))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) - sqrt(S(15))*atan(sqrt(S(15))*x/(S(3)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))))/S(50), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((S(2)*x**S(2) + S(3))*(S(2)*x**S(4) + S(2)*x**S(2) + S(1))**(S(3)/2)), x), x, -x*(S(3)*x**S(2) + S(1))/(S(5)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + S(3)*sqrt(S(2))*x*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(S(10)*(sqrt(S(2))*x**S(2) + S(1))) + S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(sqrt(S(2)) + S(2))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(4)*(S(-2) + S(3)*sqrt(S(2)))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(sqrt(S(2)) + S(3))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_pi(-S(11)*sqrt(S(2))/S(24) + S(1)/2, S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(30)*(-S(3)*sqrt(S(2)) + S(2))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) - S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(S(3)*sqrt(S(2))*x**S(2) + S(3))*elliptic_e(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(10)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + sqrt(S(15))*atan(sqrt(S(15))*x/(S(3)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))))/S(75), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate(S(1)/((S(2)*x**S(2) + S(3))*(S(2)*x**S(4) + S(2)*x**S(2) + S(1))**(S(3)/2)), x), x, -x*(S(3)*x**S(2) + S(1))/(S(5)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + S(3)*sqrt(S(2))*x*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(S(10)*(sqrt(S(2))*x**S(2) + S(1))) - S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/((-S(15)*sqrt(S(2)) + S(10))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + S(2)**(S(3)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(10)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(sqrt(S(2)) + S(3))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_pi(-S(11)*sqrt(S(2))/S(24) + S(1)/2, S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(30)*(-S(3)*sqrt(S(2)) + S(2))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) - S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(S(3)*sqrt(S(2))*x**S(2) + S(3))*elliptic_e(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(10)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(S(3)*sqrt(S(2))*x**S(2) + S(3))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(20)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + sqrt(S(15))*atan(sqrt(S(15))*x/(S(3)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))))/S(75), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*(S(2)*x**S(2) + S(3))*(S(2)*x**S(4) + S(2)*x**S(2) + S(1))**(S(3)/2)), x), x, S(2)*x*(S(3)*x**S(2) + S(1))/(S(15)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) - x/(S(3)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + S(2)*sqrt(S(2))*x*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(S(15)*sqrt(S(2))*x**S(2) + S(15)) - S(2)*S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_e(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(15)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(S(-7) + S(3)*sqrt(S(2)))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(6)*(S(-2) + S(3)*sqrt(S(2)))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) - S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(sqrt(S(2)) + S(3))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_pi(-S(11)*sqrt(S(2))/S(24) + S(1)/2, S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/((-S(135)*sqrt(S(2)) + S(90))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) - S(2)*sqrt(S(15))*atan(sqrt(S(15))*x/(S(3)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))))/S(225) - sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(S(3)*x), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate(S(1)/(x**S(2)*(S(2)*x**S(2) + S(3))*(S(2)*x**S(4) + S(2)*x**S(2) + S(1))**(S(3)/2)), x), x, S(2)*x*(S(3)*x**S(2) + S(1))/(S(15)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) - x/(S(3)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + S(2)*sqrt(S(2))*x*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(S(15)*sqrt(S(2))*x**S(2) + S(15)) - S(2)*S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_e(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(15)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) - S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(10)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) - S(2)**(S(3)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(15)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) + S(2)*S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/((-S(45)*sqrt(S(2)) + S(30))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) - S(2)**(S(3)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(-sqrt(S(2)) + S(1))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_f(S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/(S(12)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) - S(2)**(S(1)/4)*sqrt((S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(sqrt(S(2))*x**S(2) + S(1))**S(2))*(sqrt(S(2)) + S(3))*(sqrt(S(2))*x**S(2) + S(1))*elliptic_pi(-S(11)*sqrt(S(2))/S(24) + S(1)/2, S(2)*atan(S(2)**(S(1)/4)*x), -sqrt(S(2))/S(4) + S(1)/2)/((-S(135)*sqrt(S(2)) + S(90))*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))) - S(2)*sqrt(S(15))*atan(sqrt(S(15))*x/(S(3)*sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))))/S(225) - sqrt(S(2)*x**S(4) + S(2)*x**S(2) + S(1))/(S(3)*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(7)*sqrt(d + e*x**S(2))/(a + b*x**S(2) + c*x**S(4)), x), x, (d + e*x**S(2))**(S(5)/2)/(S(5)*c*e**S(2)) - (d + e*x**S(2))**(S(3)/2)*(b*e + c*d)/(S(3)*c**S(2)*e**S(2)) + sqrt(d + e*x**S(2))*(-a*c + b**S(2))/c**S(3) - sqrt(S(2))*(S(2)*a*b*c*e - a*c**S(2)*d - b**S(3)*e + b**S(2)*c*d + (-S(2)*a**S(2)*c**S(2)*e + S(4)*a*b**S(2)*c*e - S(3)*a*b*c**S(2)*d - b**S(4)*e + b**S(3)*c*d)/sqrt(-S(4)*a*c + b**S(2)))*atanh(sqrt(S(2))*sqrt(c)*sqrt(d + e*x**S(2))/sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2)))))/(S(2)*c**(S(7)/2)*sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))) - sqrt(S(2))*(S(2)*a*b*c*e - a*c**S(2)*d - b**S(3)*e + b**S(2)*c*d - (-S(2)*a**S(2)*c**S(2)*e + S(4)*a*b**S(2)*c*e - S(3)*a*b*c**S(2)*d - b**S(4)*e + b**S(3)*c*d)/sqrt(-S(4)*a*c + b**S(2)))*atanh(sqrt(S(2))*sqrt(c)*sqrt(d + e*x**S(2))/sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2)))))/(S(2)*c**(S(7)/2)*sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)*sqrt(d + e*x**S(2))/(a + b*x**S(2) + c*x**S(4)), x), x, -b*sqrt(d + e*x**S(2))/c**S(2) + (d + e*x**S(2))**(S(3)/2)/(S(3)*c*e) + sqrt(S(2))*(a*c*e - b**S(2)*e + b*c*d + (S(3)*a*b*c*e - S(2)*a*c**S(2)*d - b**S(3)*e + b**S(2)*c*d)/sqrt(-S(4)*a*c + b**S(2)))*atanh(sqrt(S(2))*sqrt(c)*sqrt(d + e*x**S(2))/sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2)))))/(S(2)*c**(S(5)/2)*sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))) + sqrt(S(2))*(a*c*e - b**S(2)*e + b*c*d - (S(3)*a*b*c*e - S(2)*a*c**S(2)*d - b**S(3)*e + b**S(2)*c*d)/sqrt(-S(4)*a*c + b**S(2)))*atanh(sqrt(S(2))*sqrt(c)*sqrt(d + e*x**S(2))/sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2)))))/(S(2)*c**(S(5)/2)*sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*sqrt(d + e*x**S(2))/(a + b*x**S(2) + c*x**S(4)), x), x, sqrt(d + e*x**S(2))/c - sqrt(S(2))*(S(2)*a*c*e - b**S(2)*e + b*c*d + sqrt(-S(4)*a*c + b**S(2))*(-b*e + c*d))*atanh(sqrt(S(2))*sqrt(c)*sqrt(d + e*x**S(2))/sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2)))))/(S(2)*c**(S(3)/2)*sqrt(-S(4)*a*c + b**S(2))*sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))) + sqrt(S(2))*(S(2)*a*c*e - b**S(2)*e + b*c*d - sqrt(-S(4)*a*c + b**S(2))*(-b*e + c*d))*atanh(sqrt(S(2))*sqrt(c)*sqrt(d + e*x**S(2))/sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2)))))/(S(2)*c**(S(3)/2)*sqrt(-S(4)*a*c + b**S(2))*sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*sqrt(d + e*x**S(2))/(a + b*x**S(2) + c*x**S(4)), x), x, -sqrt(S(2))*sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))*atanh(sqrt(S(2))*sqrt(c)*sqrt(d + e*x**S(2))/sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2)))))/(S(2)*sqrt(c)*sqrt(-S(4)*a*c + b**S(2))) + sqrt(S(2))*sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))*atanh(sqrt(S(2))*sqrt(c)*sqrt(d + e*x**S(2))/sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2)))))/(S(2)*sqrt(c)*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(d + e*x**S(2))/(x*(a + b*x**S(2) + c*x**S(4))), x), x, -sqrt(S(2))*sqrt(c)*(-S(2)*a*e + b*d - d*sqrt(-S(4)*a*c + b**S(2)))*atanh(sqrt(S(2))*sqrt(c)*sqrt(d + e*x**S(2))/sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2)))))/(S(2)*a*sqrt(-S(4)*a*c + b**S(2))*sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))) + sqrt(S(2))*sqrt(c)*(-S(2)*a*e + b*d + d*sqrt(-S(4)*a*c + b**S(2)))*atanh(sqrt(S(2))*sqrt(c)*sqrt(d + e*x**S(2))/sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2)))))/(S(2)*a*sqrt(-S(4)*a*c + b**S(2))*sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))) - sqrt(d)*atanh(sqrt(d + e*x**S(2))/sqrt(d))/a, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(d + e*x**S(2))/(x**S(5)*(a + b*x**S(2) + c*x**S(4))), x), x, -sqrt(d + e*x**S(2))/(S(4)*a*x**S(4)) + S(3)*e*sqrt(d + e*x**S(2))/(S(8)*a*d*x**S(2)) - S(3)*e**S(2)*atanh(sqrt(d + e*x**S(2))/sqrt(d))/(S(8)*a*d**(S(3)/2)) + sqrt(d + e*x**S(2))*(-a*e + b*d)/(S(2)*a**S(2)*d*x**S(2)) - e*(-a*e + b*d)*atanh(sqrt(d + e*x**S(2))/sqrt(d))/(S(2)*a**S(2)*d**(S(3)/2)) - sqrt(S(2))*sqrt(c)*(-a*b*(S(3)*c*d - e*sqrt(-S(4)*a*c + b**S(2))) + a*c*(S(2)*a*e + d*sqrt(-S(4)*a*c + b**S(2))) + b**S(3)*d - b**S(2)*(a*e + d*sqrt(-S(4)*a*c + b**S(2))))*atanh(sqrt(S(2))*sqrt(c)*sqrt(d + e*x**S(2))/sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2)))))/(S(2)*a**S(3)*sqrt(-S(4)*a*c + b**S(2))*sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))) + sqrt(S(2))*sqrt(c)*(-a*b*(S(3)*c*d + e*sqrt(-S(4)*a*c + b**S(2))) - a*c*(-S(2)*a*e + d*sqrt(-S(4)*a*c + b**S(2))) + b**S(3)*d + b**S(2)*(-a*e + d*sqrt(-S(4)*a*c + b**S(2))))*atanh(sqrt(S(2))*sqrt(c)*sqrt(d + e*x**S(2))/sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2)))))/(S(2)*a**S(3)*sqrt(-S(4)*a*c + b**S(2))*sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))) - (-a*b*e - a*c*d + b**S(2)*d)*atanh(sqrt(d + e*x**S(2))/sqrt(d))/(a**S(3)*sqrt(d)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)*sqrt(d + e*x**S(2))/(a + b*x**S(2) + c*x**S(4)), x), x, x*sqrt(d + e*x**S(2))/(S(2)*c) - (a*c*e - b**S(2)*e + b*c*d + (S(3)*a*b*c*e - S(2)*a*c**S(2)*d - b**S(3)*e + b**S(2)*c*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(x*sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))/(sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*sqrt(d + e*x**S(2))))/(c**S(2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))) - (a*c*e - b**S(2)*e + b*c*d - (S(3)*a*b*c*e - S(2)*a*c**S(2)*d - b**S(3)*e + b**S(2)*c*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(x*sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))/(sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*sqrt(d + e*x**S(2))))/(c**S(2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))) + (-S(2)*b*e + c*d)*atanh(sqrt(e)*x/sqrt(d + e*x**S(2)))/(S(2)*c**S(2)*sqrt(e)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*sqrt(d + e*x**S(2))/(a + b*x**S(2) + c*x**S(4)), x), x, sqrt(e)*atanh(sqrt(e)*x/sqrt(d + e*x**S(2)))/c + (-b*e + c*d + (S(2)*a*c*e - b**S(2)*e + b*c*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(x*sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))/(sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*sqrt(d + e*x**S(2))))/(c*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))) + (-b*e + c*d - (S(2)*a*c*e - b**S(2)*e + b*c*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(x*sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))/(sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*sqrt(d + e*x**S(2))))/(c*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(d + e*x**S(2))/(a + b*x**S(2) + c*x**S(4)), x), x, -sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))*atan(x*sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))/(sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*sqrt(d + e*x**S(2))))/(sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*sqrt(-S(4)*a*c + b**S(2))) + sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))*atan(x*sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))/(sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*sqrt(d + e*x**S(2))))/(sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(d + e*x**S(2))/(x**S(2)*(a + b*x**S(2) + c*x**S(4))), x), x, -c*(d - (-S(2)*a*e + b*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(x*sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))/(sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*sqrt(d + e*x**S(2))))/(a*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))) - c*(d + (-S(2)*a*e + b*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(x*sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))/(sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*sqrt(d + e*x**S(2))))/(a*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))) - sqrt(d + e*x**S(2))/(a*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(d + e*x**S(2))/(x**S(4)*(a + b*x**S(2) + c*x**S(4))), x), x, -sqrt(d + e*x**S(2))/(S(3)*a*x**S(3)) + S(2)*e*sqrt(d + e*x**S(2))/(S(3)*a*d*x) + c*(-a*e + b*d - (-a*b*e - S(2)*a*c*d + b**S(2)*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(x*sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))/(sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*sqrt(d + e*x**S(2))))/(a**S(2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))) + c*(-a*e + b*d + (-a*b*e - S(2)*a*c*d + b**S(2)*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(x*sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))/(sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*sqrt(d + e*x**S(2))))/(a**S(2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))) + sqrt(d + e*x**S(2))*(-a*e + b*d)/(a**S(2)*d*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(d + e*x**S(2))/(x**S(6)*(a + b*x**S(2) + c*x**S(4))), x), x, -sqrt(d + e*x**S(2))/(S(5)*a*x**S(5)) + S(4)*e*sqrt(d + e*x**S(2))/(S(15)*a*d*x**S(3)) - S(8)*e**S(2)*sqrt(d + e*x**S(2))/(S(15)*a*d**S(2)*x) + sqrt(d + e*x**S(2))*(-a*e + b*d)/(S(3)*a**S(2)*d*x**S(3)) - S(2)*e*sqrt(d + e*x**S(2))*(-a*e + b*d)/(S(3)*a**S(2)*d**S(2)*x) - c*(-a*b*e - a*c*d + b**S(2)*d - (S(2)*a**S(2)*c*e - a*b**S(2)*e - S(3)*a*b*c*d + b**S(3)*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(x*sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))/(sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*sqrt(d + e*x**S(2))))/(a**S(3)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))) - c*(-a*b*e - a*c*d + b**S(2)*d + (S(2)*a**S(2)*c*e - a*b**S(2)*e - S(3)*a*b*c*d + b**S(3)*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(x*sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))/(sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*sqrt(d + e*x**S(2))))/(a**S(3)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))) - sqrt(d + e*x**S(2))*(-a*b*e - a*c*d + b**S(2)*d)/(a**S(3)*d*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*(d + e*x**S(2))**(S(3)/2)/(a + b*x**S(2) + c*x**S(4)), x), x, (d + e*x**S(2))**(S(3)/2)/(S(3)*c) + sqrt(d + e*x**S(2))*(-b*e + c*d)/c**S(2) - sqrt(S(2))*(b**S(3)*e**S(2) - b**S(2)*e*(S(2)*c*d - e*sqrt(-S(4)*a*c + b**S(2))) + b*c*(c*d**S(2) - e*(S(3)*a*e + S(2)*d*sqrt(-S(4)*a*c + b**S(2)))) - c*(a*e**S(2)*sqrt(-S(4)*a*c + b**S(2)) - c*d*(S(4)*a*e + d*sqrt(-S(4)*a*c + b**S(2)))))*atanh(sqrt(S(2))*sqrt(c)*sqrt(d + e*x**S(2))/sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2)))))/(S(2)*c**(S(5)/2)*sqrt(-S(4)*a*c + b**S(2))*sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))) + sqrt(S(2))*(b**S(3)*e**S(2) - b**S(2)*e*(S(2)*c*d + e*sqrt(-S(4)*a*c + b**S(2))) + b*c*(c*d**S(2) + e*(-S(3)*a*e + S(2)*d*sqrt(-S(4)*a*c + b**S(2)))) + c*(a*e**S(2)*sqrt(-S(4)*a*c + b**S(2)) - c*d*(-S(4)*a*e + d*sqrt(-S(4)*a*c + b**S(2)))))*atanh(sqrt(S(2))*sqrt(c)*sqrt(d + e*x**S(2))/sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2)))))/(S(2)*c**(S(5)/2)*sqrt(-S(4)*a*c + b**S(2))*sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(d + e*x**S(2))**(S(3)/2)/(a + b*x**S(2) + c*x**S(4)), x), x, e*sqrt(d + e*x**S(2))/c + sqrt(S(2))*(b*e**S(2)*(b + sqrt(-S(4)*a*c + b**S(2))) + S(2)*c**S(2)*d**S(2) - S(2)*c*e*(a*e + b*d + d*sqrt(-S(4)*a*c + b**S(2))))*atanh(sqrt(S(2))*sqrt(c)*sqrt(d + e*x**S(2))/sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2)))))/(S(2)*c**(S(3)/2)*sqrt(-S(4)*a*c + b**S(2))*sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))) - sqrt(S(2))*(b*e**S(2)*(b - sqrt(-S(4)*a*c + b**S(2))) + S(2)*c**S(2)*d**S(2) - S(2)*c*e*(a*e + b*d - d*sqrt(-S(4)*a*c + b**S(2))))*atanh(sqrt(S(2))*sqrt(c)*sqrt(d + e*x**S(2))/sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2)))))/(S(2)*c**(S(3)/2)*sqrt(-S(4)*a*c + b**S(2))*sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))**(S(3)/2)/(x*(a + b*x**S(2) + c*x**S(4))), x), x, -d**(S(3)/2)*atanh(sqrt(d + e*x**S(2))/sqrt(d))/a - sqrt(S(2))*(a*e**S(2)*sqrt(-S(4)*a*c + b**S(2)) + b*(a*e**S(2) + c*d**S(2)) - c*d*(S(4)*a*e + d*sqrt(-S(4)*a*c + b**S(2))))*atanh(sqrt(S(2))*sqrt(c)*sqrt(d + e*x**S(2))/sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2)))))/(S(2)*a*sqrt(c)*sqrt(-S(4)*a*c + b**S(2))*sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))) - sqrt(S(2))*(a*e**S(2)*sqrt(-S(4)*a*c + b**S(2)) - b*(a*e**S(2) + c*d**S(2)) - c*d*(-S(4)*a*e + d*sqrt(-S(4)*a*c + b**S(2))))*atanh(sqrt(S(2))*sqrt(c)*sqrt(d + e*x**S(2))/sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2)))))/(S(2)*a*sqrt(c)*sqrt(-S(4)*a*c + b**S(2))*sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))**(S(3)/2)/(x**S(3)*(a + b*x**S(2) + c*x**S(4))), x), x, sqrt(d)*e*atanh(sqrt(d + e*x**S(2))/sqrt(d))/(S(2)*a) - d*sqrt(d + e*x**S(2))/(S(2)*a*x**S(2)) + sqrt(S(2))*sqrt(c)*(-S(2)*a*(c*d**S(2) - e*(a*e + d*sqrt(-S(4)*a*c + b**S(2)))) + b**S(2)*d**S(2) - b*d*(S(2)*a*e + d*sqrt(-S(4)*a*c + b**S(2))))*atanh(sqrt(S(2))*sqrt(c)*sqrt(d + e*x**S(2))/sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2)))))/(S(2)*a**S(2)*sqrt(-S(4)*a*c + b**S(2))*sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))) - sqrt(S(2))*sqrt(c)*(-S(2)*a*(c*d**S(2) + e*(-a*e + d*sqrt(-S(4)*a*c + b**S(2)))) + b**S(2)*d**S(2) + b*d*(-S(2)*a*e + d*sqrt(-S(4)*a*c + b**S(2))))*atanh(sqrt(S(2))*sqrt(c)*sqrt(d + e*x**S(2))/sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2)))))/(S(2)*a**S(2)*sqrt(-S(4)*a*c + b**S(2))*sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))) + sqrt(d)*(-S(2)*a*e + b*d)*atanh(sqrt(d + e*x**S(2))/sqrt(d))/a**S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)*(d + e*x**S(2))**(S(3)/2)/(a + b*x**S(2) + c*x**S(4)), x), x, x*(d + e*x**S(2))**(S(3)/2)/(S(4)*c) + d*(-S(4)*b*e + S(3)*c*d)*atanh(sqrt(e)*x/sqrt(d + e*x**S(2)))/(S(8)*c**S(2)*sqrt(e)) + x*sqrt(d + e*x**S(2))*(-S(4)*b*e + S(3)*c*d)/(S(8)*c**S(2)) - sqrt(e)*(a*c*e - b**S(2)*e + b*c*d - (S(3)*a*b*c*e - S(2)*a*c**S(2)*d - b**S(3)*e + b**S(2)*c*d)/sqrt(-S(4)*a*c + b**S(2)))*atanh(sqrt(e)*x/sqrt(d + e*x**S(2)))/(S(2)*c**S(3)) - sqrt(e)*(a*c*e - b**S(2)*e + b*c*d + (S(3)*a*b*c*e - S(2)*a*c**S(2)*d - b**S(3)*e + b**S(2)*c*d)/sqrt(-S(4)*a*c + b**S(2)))*atanh(sqrt(e)*x/sqrt(d + e*x**S(2)))/(S(2)*c**S(3)) - sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))*(a*c*e - b**S(2)*e + b*c*d + (S(3)*a*b*c*e - S(2)*a*c**S(2)*d - b**S(3)*e + b**S(2)*c*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(x*sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))/(sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*sqrt(d + e*x**S(2))))/(S(2)*c**S(3)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))) - sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))*(a*c*e - b**S(2)*e + b*c*d - (S(3)*a*b*c*e - S(2)*a*c**S(2)*d - b**S(3)*e + b**S(2)*c*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(x*sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))/(sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*sqrt(d + e*x**S(2))))/(S(2)*c**S(3)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(d + e*x**S(2))**(S(3)/2)/(a + b*x**S(2) + c*x**S(4)), x), x, d*sqrt(e)*atanh(sqrt(e)*x/sqrt(d + e*x**S(2)))/(S(2)*c) + e*x*sqrt(d + e*x**S(2))/(S(2)*c) + sqrt(e)*(-b*e + c*d - (S(2)*a*c*e - b**S(2)*e + b*c*d)/sqrt(-S(4)*a*c + b**S(2)))*atanh(sqrt(e)*x/sqrt(d + e*x**S(2)))/(S(2)*c**S(2)) + sqrt(e)*(-b*e + c*d + (S(2)*a*c*e - b**S(2)*e + b*c*d)/sqrt(-S(4)*a*c + b**S(2)))*atanh(sqrt(e)*x/sqrt(d + e*x**S(2)))/(S(2)*c**S(2)) + sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))*(-b*e + c*d + (S(2)*a*c*e - b**S(2)*e + b*c*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(x*sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))/(sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*sqrt(d + e*x**S(2))))/(S(2)*c**S(2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))) + sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))*(-b*e + c*d - (S(2)*a*c*e - b**S(2)*e + b*c*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(x*sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))/(sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*sqrt(d + e*x**S(2))))/(S(2)*c**S(2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))**(S(3)/2)/(a + b*x**S(2) + c*x**S(4)), x), x, sqrt(e)*(S(3)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))*atanh(sqrt(e)*x/sqrt(d + e*x**S(2)))/(S(2)*c*sqrt(-S(4)*a*c + b**S(2))) - sqrt(e)*(S(3)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))*atanh(sqrt(e)*x/sqrt(d + e*x**S(2)))/(S(2)*c*sqrt(-S(4)*a*c + b**S(2))) - (b*e**S(2)*(b + sqrt(-S(4)*a*c + b**S(2))) + S(2)*c**S(2)*d**S(2) - S(2)*c*e*(a*e + b*d + d*sqrt(-S(4)*a*c + b**S(2))))*atan(x*sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))/(sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*sqrt(d + e*x**S(2))))/(c*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*sqrt(-S(4)*a*c + b**S(2))*sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))) + (b*e**S(2)*(b - sqrt(-S(4)*a*c + b**S(2))) + S(2)*c**S(2)*d**S(2) - S(2)*c*e*(a*e + b*d - d*sqrt(-S(4)*a*c + b**S(2))))*atan(x*sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))/(sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*sqrt(d + e*x**S(2))))/(c*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*sqrt(-S(4)*a*c + b**S(2))*sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))**(S(3)/2)/(x**S(2)*(a + b*x**S(2) + c*x**S(4))), x), x, (S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))**(S(3)/2)*atan(x*sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))/(sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*sqrt(d + e*x**S(2))))/((b + sqrt(-S(4)*a*c + b**S(2)))**(S(3)/2)*sqrt(-S(4)*a*c + b**S(2))) - (S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))**(S(3)/2)*atan(x*sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))/(sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*sqrt(d + e*x**S(2))))/((b - sqrt(-S(4)*a*c + b**S(2)))**(S(3)/2)*sqrt(-S(4)*a*c + b**S(2))) - d*sqrt(d + e*x**S(2))/(a*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(2))**(S(3)/2)/(x**S(4)*(a + b*x**S(2) + c*x**S(4))), x), x, -(d + e*x**S(2))**(S(3)/2)/(S(3)*a*x**S(3)) - sqrt(e)*(-a*e + b*d)*atanh(sqrt(e)*x/sqrt(d + e*x**S(2)))/a**S(2) + sqrt(e)*(-a*e + b*d - (-a*b*e - S(2)*a*c*d + b**S(2)*d)/sqrt(-S(4)*a*c + b**S(2)))*atanh(sqrt(e)*x/sqrt(d + e*x**S(2)))/(S(2)*a**S(2)) + sqrt(e)*(-a*e + b*d + (-a*b*e - S(2)*a*c*d + b**S(2)*d)/sqrt(-S(4)*a*c + b**S(2)))*atanh(sqrt(e)*x/sqrt(d + e*x**S(2)))/(S(2)*a**S(2)) + sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))*(-a*e + b*d - (-a*b*e - S(2)*a*c*d + b**S(2)*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(x*sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))/(sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*sqrt(d + e*x**S(2))))/(S(2)*a**S(2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))) + sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))*(-a*e + b*d + (-a*b*e - S(2)*a*c*d + b**S(2)*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(x*sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))/(sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*sqrt(d + e*x**S(2))))/(S(2)*a**S(2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))) + sqrt(d + e*x**S(2))*(-a*e + b*d)/(a**S(2)*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)*sqrt(-x**S(2) + S(1))/(a + b*x**S(2) + c*x**S(4)), x), x, -b*sqrt(-x**S(2) + S(1))/c**S(2) - (-x**S(2) + S(1))**(S(3)/2)/(S(3)*c) + sqrt(S(2))*(-a*c + b**S(2) + b*c + (-S(3)*a*b*c - S(2)*a*c**S(2) + b**S(3) + b**S(2)*c)/sqrt(-S(4)*a*c + b**S(2)))*atanh(sqrt(S(2))*sqrt(c)*sqrt(-x**S(2) + S(1))/sqrt(b + S(2)*c + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*c**(S(5)/2)*sqrt(b + S(2)*c + sqrt(-S(4)*a*c + b**S(2)))) + sqrt(S(2))*(-a*c + b**S(2) + b*c - (-S(3)*a*b*c - S(2)*a*c**S(2) + b**S(3) + b**S(2)*c)/sqrt(-S(4)*a*c + b**S(2)))*atanh(sqrt(S(2))*sqrt(c)*sqrt(-x**S(2) + S(1))/sqrt(b + S(2)*c - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*c**(S(5)/2)*sqrt(b + S(2)*c - sqrt(-S(4)*a*c + b**S(2)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*sqrt(-x**S(2) + S(1))/(a + b*x**S(2) + c*x**S(4)), x), x, sqrt(-x**S(2) + S(1))/c - sqrt(S(2))*(b + c - (-S(2)*a*c + b**S(2) + b*c)/sqrt(-S(4)*a*c + b**S(2)))*atanh(sqrt(S(2))*sqrt(c)*sqrt(-x**S(2) + S(1))/sqrt(b + S(2)*c - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*c**(S(3)/2)*sqrt(b + S(2)*c - sqrt(-S(4)*a*c + b**S(2)))) - sqrt(S(2))*(b + c + (-S(2)*a*c + b**S(2) + b*c)/sqrt(-S(4)*a*c + b**S(2)))*atanh(sqrt(S(2))*sqrt(c)*sqrt(-x**S(2) + S(1))/sqrt(b + S(2)*c + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*c**(S(3)/2)*sqrt(b + S(2)*c + sqrt(-S(4)*a*c + b**S(2)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*sqrt(-x**S(2) + S(1))/(a + b*x**S(2) + c*x**S(4)), x), x, -sqrt(S(2))*sqrt(b + S(2)*c - sqrt(-S(4)*a*c + b**S(2)))*atanh(sqrt(S(2))*sqrt(c)*sqrt(-x**S(2) + S(1))/sqrt(b + S(2)*c - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*sqrt(c)*sqrt(-S(4)*a*c + b**S(2))) + sqrt(S(2))*sqrt(b + S(2)*c + sqrt(-S(4)*a*c + b**S(2)))*atanh(sqrt(S(2))*sqrt(c)*sqrt(-x**S(2) + S(1))/sqrt(b + S(2)*c + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*sqrt(c)*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(-x**S(2) + S(1))/(x*(a + b*x**S(2) + c*x**S(4))), x), x, -sqrt(S(2))*sqrt(c)*(S(2)*a + b - sqrt(-S(4)*a*c + b**S(2)))*atanh(sqrt(S(2))*sqrt(c)*sqrt(-x**S(2) + S(1))/sqrt(b + S(2)*c + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*a*sqrt(-S(4)*a*c + b**S(2))*sqrt(b + S(2)*c + sqrt(-S(4)*a*c + b**S(2)))) + sqrt(S(2))*sqrt(c)*(S(2)*a + b + sqrt(-S(4)*a*c + b**S(2)))*atanh(sqrt(S(2))*sqrt(c)*sqrt(-x**S(2) + S(1))/sqrt(b + S(2)*c - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*a*sqrt(-S(4)*a*c + b**S(2))*sqrt(b + S(2)*c - sqrt(-S(4)*a*c + b**S(2)))) - atanh(sqrt(-x**S(2) + S(1)))/a, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(-x**S(2) + S(1))/(x**S(3)*(a + b*x**S(2) + c*x**S(4))), x), x, S(1)/(S(4)*a*(sqrt(-x**S(2) + S(1)) + S(1))) - S(1)/(S(4)*a*(-sqrt(-x**S(2) + S(1)) + S(1))) + sqrt(S(2))*sqrt(c)*(a*(b - S(2)*c - sqrt(-S(4)*a*c + b**S(2))) + b*(b - sqrt(-S(4)*a*c + b**S(2))))*atanh(sqrt(S(2))*sqrt(c)*sqrt(-x**S(2) + S(1))/sqrt(b + S(2)*c + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*a**S(2)*sqrt(-S(4)*a*c + b**S(2))*sqrt(b + S(2)*c + sqrt(-S(4)*a*c + b**S(2)))) - sqrt(S(2))*sqrt(c)*(a*(b - S(2)*c + sqrt(-S(4)*a*c + b**S(2))) + b*(b + sqrt(-S(4)*a*c + b**S(2))))*atanh(sqrt(S(2))*sqrt(c)*sqrt(-x**S(2) + S(1))/sqrt(b + S(2)*c - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*a**S(2)*sqrt(-S(4)*a*c + b**S(2))*sqrt(b + S(2)*c - sqrt(-S(4)*a*c + b**S(2)))) + (a + S(2)*b)*atanh(sqrt(-x**S(2) + S(1)))/(S(2)*a**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)*sqrt(-x**S(2) + S(1))/(a + b*x**S(2) + c*x**S(4)), x), x, x*sqrt(-x**S(2) + S(1))/(S(2)*c) + (S(2)*b + c)*asin(x)/(S(2)*c**S(2)) - (-a*c + b**S(2) + b*c + (-S(3)*a*b*c - S(2)*a*c**S(2) + b**S(3) + b**S(2)*c)/sqrt(-S(4)*a*c + b**S(2)))*atan(x*sqrt(b + S(2)*c + sqrt(-S(4)*a*c + b**S(2)))/(sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*sqrt(-x**S(2) + S(1))))/(c**S(2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*sqrt(b + S(2)*c + sqrt(-S(4)*a*c + b**S(2)))) - (-a*c + b**S(2) + b*c - (-S(3)*a*b*c - S(2)*a*c**S(2) + b**S(3) + b**S(2)*c)/sqrt(-S(4)*a*c + b**S(2)))*atan(x*sqrt(b + S(2)*c - sqrt(-S(4)*a*c + b**S(2)))/(sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*sqrt(-x**S(2) + S(1))))/(c**S(2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*sqrt(b + S(2)*c - sqrt(-S(4)*a*c + b**S(2)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*sqrt(-x**S(2) + S(1))/(a + b*x**S(2) + c*x**S(4)), x), x, -asin(x)/c + (b + c + (-S(2)*a*c + b**S(2) + b*c)/sqrt(-S(4)*a*c + b**S(2)))*atan(x*sqrt(b + S(2)*c + sqrt(-S(4)*a*c + b**S(2)))/(sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*sqrt(-x**S(2) + S(1))))/(c*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*sqrt(b + S(2)*c + sqrt(-S(4)*a*c + b**S(2)))) + (b + c - (-S(2)*a*c + b**S(2) + b*c)/sqrt(-S(4)*a*c + b**S(2)))*atan(x*sqrt(b + S(2)*c - sqrt(-S(4)*a*c + b**S(2)))/(sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*sqrt(-x**S(2) + S(1))))/(c*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*sqrt(b + S(2)*c - sqrt(-S(4)*a*c + b**S(2)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(-x**S(2) + S(1))/(a + b*x**S(2) + c*x**S(4)), x), x, -sqrt(b + S(2)*c + sqrt(-S(4)*a*c + b**S(2)))*atan(x*sqrt(b + S(2)*c + sqrt(-S(4)*a*c + b**S(2)))/(sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*sqrt(-x**S(2) + S(1))))/(sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*sqrt(-S(4)*a*c + b**S(2))) + sqrt(b + S(2)*c - sqrt(-S(4)*a*c + b**S(2)))*atan(x*sqrt(b + S(2)*c - sqrt(-S(4)*a*c + b**S(2)))/(sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*sqrt(-x**S(2) + S(1))))/(sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(-x**S(2) + S(1))/(x**S(2)*(a + b*x**S(2) + c*x**S(4))), x), x, -c*(-(S(2)*a + b)/sqrt(-S(4)*a*c + b**S(2)) + S(1))*atan(x*sqrt(b + S(2)*c + sqrt(-S(4)*a*c + b**S(2)))/(sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*sqrt(-x**S(2) + S(1))))/(a*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*sqrt(b + S(2)*c + sqrt(-S(4)*a*c + b**S(2)))) - c*((S(2)*a + b)/sqrt(-S(4)*a*c + b**S(2)) + S(1))*atan(x*sqrt(b + S(2)*c - sqrt(-S(4)*a*c + b**S(2)))/(sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*sqrt(-x**S(2) + S(1))))/(a*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*sqrt(b + S(2)*c - sqrt(-S(4)*a*c + b**S(2)))) - sqrt(-x**S(2) + S(1))/(a*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*sqrt(-x**S(2) + S(1))/(x**S(4) + x**S(2) + S(-1)), x), x, -asin(x) + sqrt(S(2)/5 + sqrt(S(5))/S(5))*atan(x*sqrt(S(1)/2 + sqrt(S(5))/S(2))/sqrt(-x**S(2) + S(1))) - sqrt(S(-2)/5 + sqrt(S(5))/S(5))*atanh(x*sqrt(S(-1)/2 + sqrt(S(5))/S(2))/sqrt(-x**S(2) + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(8)/(sqrt(d + e*x**S(2))*(a + b*x**S(2) + c*x**S(4))), x), x, b*d*atanh(sqrt(e)*x/sqrt(d + e*x**S(2)))/(S(2)*c**S(2)*e**(S(3)/2)) - b*x*sqrt(d + e*x**S(2))/(S(2)*c**S(2)*e) + S(3)*d**S(2)*atanh(sqrt(e)*x/sqrt(d + e*x**S(2)))/(S(8)*c*e**(S(5)/2)) - S(3)*d*x*sqrt(d + e*x**S(2))/(S(8)*c*e**S(2)) + x**S(3)*sqrt(d + e*x**S(2))/(S(4)*c*e) - (-S(2)*a*b*c + b**S(3) + (S(2)*a**S(2)*c**S(2) - S(4)*a*b**S(2)*c + b**S(4))/sqrt(-S(4)*a*c + b**S(2)))*atan(x*sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))/(sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*sqrt(d + e*x**S(2))))/(c**S(3)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))) - (-S(2)*a*b*c + b**S(3) - (S(2)*a**S(2)*c**S(2) - S(4)*a*b**S(2)*c + b**S(4))/sqrt(-S(4)*a*c + b**S(2)))*atan(x*sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))/(sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*sqrt(d + e*x**S(2))))/(c**S(3)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))) + (-a*c + b**S(2))*atanh(sqrt(e)*x/sqrt(d + e*x**S(2)))/(c**S(3)*sqrt(e)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(6)/(sqrt(d + e*x**S(2))*(a + b*x**S(2) + c*x**S(4))), x), x, -b*atanh(sqrt(e)*x/sqrt(d + e*x**S(2)))/(c**S(2)*sqrt(e)) - d*atanh(sqrt(e)*x/sqrt(d + e*x**S(2)))/(S(2)*c*e**(S(3)/2)) + x*sqrt(d + e*x**S(2))/(S(2)*c*e) + (-a*c + b**S(2) + b*(-S(3)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(x*sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))/(sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*sqrt(d + e*x**S(2))))/(c**S(2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))) + (-a*c + b**S(2) - b*(-S(3)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(x*sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))/(sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*sqrt(d + e*x**S(2))))/(c**S(2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)/(sqrt(d + e*x**S(2))*(a + b*x**S(2) + c*x**S(4))), x), x, -(b - (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(x*sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))/(sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*sqrt(d + e*x**S(2))))/(c*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))) - (b + (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(x*sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))/(sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*sqrt(d + e*x**S(2))))/(c*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))) + atanh(sqrt(e)*x/sqrt(d + e*x**S(2)))/(c*sqrt(e)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/(sqrt(d + e*x**S(2))*(a + b*x**S(2) + c*x**S(4))), x), x, -sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*atan(x*sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))/(sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*sqrt(d + e*x**S(2))))/(sqrt(-S(4)*a*c + b**S(2))*sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))) + sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*atan(x*sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))/(sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*sqrt(d + e*x**S(2))))/(sqrt(-S(4)*a*c + b**S(2))*sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(sqrt(d + e*x**S(2))*(a + b*x**S(2) + c*x**S(4))), x), x, -S(2)*c*atan(x*sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))/(sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*sqrt(d + e*x**S(2))))/(sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*sqrt(-S(4)*a*c + b**S(2))*sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))) + S(2)*c*atan(x*sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))/(sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*sqrt(d + e*x**S(2))))/(sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*sqrt(-S(4)*a*c + b**S(2))*sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*sqrt(d + e*x**S(2))*(a + b*x**S(2) + c*x**S(4))), x), x, -c*(-b/sqrt(-S(4)*a*c + b**S(2)) + S(1))*atan(x*sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))/(sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*sqrt(d + e*x**S(2))))/(a*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))) - c*(b/sqrt(-S(4)*a*c + b**S(2)) + S(1))*atan(x*sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))/(sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*sqrt(d + e*x**S(2))))/(a*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))) - sqrt(d + e*x**S(2))/(a*d*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(4)*sqrt(d + e*x**S(2))*(a + b*x**S(2) + c*x**S(4))), x), x, -sqrt(d + e*x**S(2))/(S(3)*a*d*x**S(3)) + S(2)*e*sqrt(d + e*x**S(2))/(S(3)*a*d**S(2)*x) + b*sqrt(d + e*x**S(2))/(a**S(2)*d*x) + c*(b - (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(x*sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))/(sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*sqrt(d + e*x**S(2))))/(a**S(2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))) + c*(b + (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(x*sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))/(sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*sqrt(d + e*x**S(2))))/(a**S(2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(6)*sqrt(d + e*x**S(2))*(a + b*x**S(2) + c*x**S(4))), x), x, -sqrt(d + e*x**S(2))/(S(5)*a*d*x**S(5)) + S(4)*e*sqrt(d + e*x**S(2))/(S(15)*a*d**S(2)*x**S(3)) - S(8)*e**S(2)*sqrt(d + e*x**S(2))/(S(15)*a*d**S(3)*x) + b*sqrt(d + e*x**S(2))/(S(3)*a**S(2)*d*x**S(3)) - S(2)*b*e*sqrt(d + e*x**S(2))/(S(3)*a**S(2)*d**S(2)*x) - c*(-a*c + b**S(2) - b*(-S(3)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(x*sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))/(sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*sqrt(d + e*x**S(2))))/(a**S(3)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))) - c*(-a*c + b**S(2) + b*(-S(3)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(x*sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))/(sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*sqrt(d + e*x**S(2))))/(a**S(3)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))) - sqrt(d + e*x**S(2))*(-a*c + b**S(2))/(a**S(3)*d*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(6)/((d + e*x**S(2))**(S(3)/2)*(a + b*x**S(2) + c*x**S(4))), x), x, -d**S(2)*x/(e*sqrt(d + e*x**S(2))*(a*e**S(2) - b*d*e + c*d**S(2))) + (-S(2)*a*c + S(2)*b**S(2) + S(2)*b*(-S(3)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(x*sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))/(sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*sqrt(d + e*x**S(2))))/(c*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))**(S(3)/2)) + (-S(2)*a*c + S(2)*b**S(2) - S(2)*b*(-S(3)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(x*sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))/(sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*sqrt(d + e*x**S(2))))/(c*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))**(S(3)/2)) + atanh(sqrt(e)*x/sqrt(d + e*x**S(2)))/(c*e**(S(3)/2)), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate(x**S(6)/((d + e*x**S(2))**(S(3)/2)*(a + b*x**S(2) + c*x**S(4))), x), x, -d**S(2)*x/(e*sqrt(d + e*x**S(2))*(a*e**S(2) - b*d*e + c*d**S(2))) + d**S(2)*atanh(sqrt(e)*x/sqrt(d + e*x**S(2)))/(e**(S(3)/2)*(a*e**S(2) - b*d*e + c*d**S(2))) + (-a*b*e - a*c*d + b**S(2)*d + (S(2)*a**S(2)*c*e - a*b**S(2)*e - S(3)*a*b*c*d + b**S(3)*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(x*sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))/(sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*sqrt(d + e*x**S(2))))/(c*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))*(a*e**S(2) - b*d*e + c*d**S(2))) + (-a*b*e - a*c*d + b**S(2)*d - (S(2)*a**S(2)*c*e - a*b**S(2)*e - S(3)*a*b*c*d + b**S(3)*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(x*sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))/(sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*sqrt(d + e*x**S(2))))/(c*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))*(a*e**S(2) - b*d*e + c*d**S(2))) - (-a*e + b*d)*atanh(sqrt(e)*x/sqrt(d + e*x**S(2)))/(c*sqrt(e)*(a*e**S(2) - b*d*e + c*d**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)/((d + e*x**S(2))**(S(3)/2)*(a + b*x**S(2) + c*x**S(4))), x), x, d*x/(sqrt(d + e*x**S(2))*(a*e**S(2) - b*d*e + c*d**S(2))) - (-a*e + b*d + (-a*b*e - S(2)*a*c*d + b**S(2)*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(x*sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))/(sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*sqrt(d + e*x**S(2))))/(sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))*(a*e**S(2) - b*d*e + c*d**S(2))) - (-a*e + b*d - (-a*b*e - S(2)*a*c*d + b**S(2)*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(x*sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))/(sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*sqrt(d + e*x**S(2))))/(sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))*(a*e**S(2) - b*d*e + c*d**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/((d + e*x**S(2))**(S(3)/2)*(a + b*x**S(2) + c*x**S(4))), x), x, c*(d + (-S(2)*a*e + b*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(x*sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))/(sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*sqrt(d + e*x**S(2))))/(sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))*(a*e**S(2) - b*d*e + c*d**S(2))) + c*(d - (-S(2)*a*e + b*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(x*sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))/(sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*sqrt(d + e*x**S(2))))/(sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))*(a*e**S(2) - b*d*e + c*d**S(2))) - e*x/(sqrt(d + e*x**S(2))*(a*e**S(2) - b*d*e + c*d**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/((d + e*x**S(2))**(S(3)/2)*(a + b*x**S(2) + c*x**S(4))), x), x, -c*(e + (-b*e + S(2)*c*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(x*sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))/(sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*sqrt(d + e*x**S(2))))/(sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))*(a*e**S(2) - b*d*e + c*d**S(2))) - c*(e - (-b*e + S(2)*c*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(x*sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))/(sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*sqrt(d + e*x**S(2))))/(sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))*(a*e**S(2) - b*d*e + c*d**S(2))) + e**S(2)*x/(d*sqrt(d + e*x**S(2))*(a*e**S(2) - b*d*e + c*d**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*(d + e*x**S(2))**(S(3)/2)*(a + b*x**S(2) + c*x**S(4))), x), x, -S(2)*c**S(2)*(-b/sqrt(-S(4)*a*c + b**S(2)) + S(1))*atan(x*sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))/(sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*sqrt(d + e*x**S(2))))/(a*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))**(S(3)/2)) - S(2)*c**S(2)*(b/sqrt(-S(4)*a*c + b**S(2)) + S(1))*atan(x*sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))/(sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*sqrt(d + e*x**S(2))))/(a*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))**(S(3)/2)) + e*x*(-b*e + c*d)/(a*d*sqrt(d + e*x**S(2))*(c*d**S(2) + e*(a*e - b*d))) + (-d - S(2)*e*x**S(2))/(a*d**S(2)*x*sqrt(d + e*x**S(2))), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate(S(1)/(x**S(2)*(d + e*x**S(2))**(S(3)/2)*(a + b*x**S(2) + c*x**S(4))), x), x, -e**S(2)/(d*x*sqrt(d + e*x**S(2))*(a*e**S(2) - b*d*e + c*d**S(2))) - S(2)*e**S(3)*x/(d**S(2)*sqrt(d + e*x**S(2))*(a*e**S(2) - b*d*e + c*d**S(2))) - c*(-b*e + c*d - (S(2)*a*c*e - b**S(2)*e + b*c*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(x*sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))/(sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*sqrt(d + e*x**S(2))))/(a*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))*(a*e**S(2) - b*d*e + c*d**S(2))) - c*(-b*e + c*d + (S(2)*a*c*e - b**S(2)*e + b*c*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(x*sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))/(sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*sqrt(d + e*x**S(2))))/(a*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))*(a*e**S(2) - b*d*e + c*d**S(2))) - sqrt(d + e*x**S(2))*(-b*e + c*d)/(a*d*x*(a*e**S(2) - b*d*e + c*d**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(4)*(d + e*x**S(2))**(S(3)/2)*(a + b*x**S(2) + c*x**S(4))), x), x, -S(1)/(S(3)*a*d*x**S(3)*sqrt(d + e*x**S(2))) + S(2)*c**S(2)*(b - (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(x*sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))/(sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*sqrt(d + e*x**S(2))))/(a**S(2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))**(S(3)/2)) + S(2)*c**S(2)*(b + (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(x*sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))/(sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*sqrt(d + e*x**S(2))))/(a**S(2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))**(S(3)/2)) - e*x*(a*c*e - b**S(2)*e + b*c*d)/(a**S(2)*d*sqrt(d + e*x**S(2))*(c*d**S(2) + e*(a*e - b*d))) + (S(4)*a*e + S(3)*b*d)/(S(3)*a**S(2)*d**S(2)*x*sqrt(d + e*x**S(2))) + S(2)*e*x*(S(4)*a*e + S(3)*b*d)/(S(3)*a**S(2)*d**S(3)*sqrt(d + e*x**S(2))), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate(S(1)/(x**S(4)*(d + e*x**S(2))**(S(3)/2)*(a + b*x**S(2) + c*x**S(4))), x), x, -e**S(2)/(S(3)*d*x**S(3)*sqrt(d + e*x**S(2))*(a*e**S(2) - b*d*e + c*d**S(2))) + S(4)*e**S(3)/(S(3)*d**S(2)*x*sqrt(d + e*x**S(2))*(a*e**S(2) - b*d*e + c*d**S(2))) + S(8)*e**S(4)*x/(S(3)*d**S(3)*sqrt(d + e*x**S(2))*(a*e**S(2) - b*d*e + c*d**S(2))) - sqrt(d + e*x**S(2))*(-b*e + c*d)/(S(3)*a*d*x**S(3)*(a*e**S(2) - b*d*e + c*d**S(2))) + S(2)*e*sqrt(d + e*x**S(2))*(-b*e + c*d)/(S(3)*a*d**S(2)*x*(a*e**S(2) - b*d*e + c*d**S(2))) + c*(a*c*e - b**S(2)*e + b*c*d - (S(3)*a*b*c*e - S(2)*a*c**S(2)*d - b**S(3)*e + b**S(2)*c*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(x*sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))/(sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*sqrt(d + e*x**S(2))))/(a**S(2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*sqrt(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))*(a*e**S(2) - b*d*e + c*d**S(2))) + c*(a*c*e - b**S(2)*e + b*c*d + (S(3)*a*b*c*e - S(2)*a*c**S(2)*d - b**S(3)*e + b**S(2)*c*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(x*sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))/(sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*sqrt(d + e*x**S(2))))/(a**S(2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*sqrt(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))*(a*e**S(2) - b*d*e + c*d**S(2))) + sqrt(d + e*x**S(2))*(a*c*e - b**S(2)*e + b*c*d)/(a**S(2)*d*x*(a*e**S(2) - b*d*e + c*d**S(2))), expand=True, _diff=True, _numerical=True)
# '''Apart
# assert rubi_test(rubi_integrate((f*x)**m*(d + e*x**S(2))**q/(a + b*x**S(2) + c*x**S(4)), x), x, -S(2)*c*(f*x)**(m + S(1))*(S(1) + e*x**S(2)/d)**(-q)*(d + e*x**S(2))**q*AppellF1(m/S(2) + S(1)/2, S(1), -q, m/S(2) + S(3)/2, -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))), -e*x**S(2)/d)/(f*(b + sqrt(-S(4)*a*c + b**S(2)))*(m + S(1))*sqrt(-S(4)*a*c + b**S(2))) + S(2)*c*(f*x)**(m + S(1))*(S(1) + e*x**S(2)/d)**(-q)*(d + e*x**S(2))**q*AppellF1(m/S(2) + S(1)/2, S(1), -q, m/S(2) + S(3)/2, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -e*x**S(2)/d)/(f*(b - sqrt(-S(4)*a*c + b**S(2)))*(m + S(1))*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
# assert rubi_test(rubi_integrate(x**S(7)*(d + e*x**S(2))**q/(a + b*x**S(2) + c*x**S(4)), x), x, (d + e*x**S(2))**(q + S(1))*(a - b**S(2)/c - b*(-S(3)*a*c + b**S(2))/(c*sqrt(-S(4)*a*c + b**S(2))))*hyper((S(1), q + S(1)), (q + S(2),), S(2)*c*(d + e*x**S(2))/(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2)))))/(S(2)*c*(q + S(1))*(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))) + (d + e*x**S(2))**(q + S(1))*(a - b**S(2)/c + b*(-S(3)*a*c + b**S(2))/(c*sqrt(-S(4)*a*c + b**S(2))))*hyper((S(1), q + S(1)), (q + S(2),), S(2)*c*(d + e*x**S(2))/(-b*e + S(2)*c*d + e*sqrt(-S(4)*a*c + b**S(2))))/(S(2)*c*(q + S(1))*(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))) + (d + e*x**S(2))**(q + S(2))/(S(2)*c*e**S(2)*(q + S(2))) - (d + e*x**S(2))**(q + S(1))*(b*e + c*d)/(S(2)*c**S(2)*e**S(2)*(q + S(1))), expand=True, _diff=True, _numerical=True)
# assert rubi_test(rubi_integrate(x**S(5)*(d + e*x**S(2))**q/(a + b*x**S(2) + c*x**S(4)), x), x, (b - (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*(d + e*x**S(2))**(q + S(1))*hyper((S(1), q + S(1)), (q + S(2),), S(2)*c*(d + e*x**S(2))/(-b*e + S(2)*c*d + e*sqrt(-S(4)*a*c + b**S(2))))/(S(2)*c*(q + S(1))*(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))) + (b + (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*(d + e*x**S(2))**(q + S(1))*hyper((S(1), q + S(1)), (q + S(2),), S(2)*c*(d + e*x**S(2))/(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2)))))/(S(2)*c*(q + S(1))*(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))) + (d + e*x**S(2))**(q + S(1))/(S(2)*c*e*(q + S(1))), expand=True, _diff=True, _numerical=True)
# assert rubi_test(rubi_integrate(x**S(3)*(d + e*x**S(2))**q/(a + b*x**S(2) + c*x**S(4)), x), x, -(d + e*x**S(2))**(q + S(1))*(-b/sqrt(-S(4)*a*c + b**S(2)) + S(1))*hyper((S(1), q + S(1)), (q + S(2),), S(2)*c*(d + e*x**S(2))/(-b*e + S(2)*c*d + e*sqrt(-S(4)*a*c + b**S(2))))/((q + S(1))*(S(4)*c*d - S(2)*e*(b - sqrt(-S(4)*a*c + b**S(2))))) - (d + e*x**S(2))**(q + S(1))*(b/sqrt(-S(4)*a*c + b**S(2)) + S(1))*hyper((S(1), q + S(1)), (q + S(2),), S(2)*c*(d + e*x**S(2))/(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2)))))/((q + S(1))*(S(4)*c*d - S(2)*e*(b + sqrt(-S(4)*a*c + b**S(2))))), expand=True, _diff=True, _numerical=True)
# NC assert rubi_test(rubi_integrate(x*(d + e*x**S(2))**q/(a + b*x**S(2) + c*x**S(4)), x), x, c*(d + e*x**S(2))**(q + S(1))*hyper((S(1), q + S(1)), (q + S(2),), S(2)*c*(d + e*x**S(2))/(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2)))))/((q + S(1))*sqrt(-S(4)*a*c + b**S(2))*(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))) - c*(d + e*x**S(2))**(q + S(1))*hyper((S(1), q + S(1)), (q + S(2),), S(2)*c*(d + e*x**S(2))/(-b*e + S(2)*c*d + e*sqrt(-S(4)*a*c + b**S(2))))/((q + S(1))*sqrt(-S(4)*a*c + b**S(2))*(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))), expand=True, _diff=True, _numerical=True)
# NC assert rubi_test(rubi_integrate((d + e*x**S(2))**q/(x*(a + b*x**S(2) + c*x**S(4))), x), x, c*(d + e*x**S(2))**(q + S(1))*(-b/sqrt(-S(4)*a*c + b**S(2)) + S(1))*hyper((S(1), q + S(1)), (q + S(2),), S(2)*c*(d + e*x**S(2))/(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2)))))/(S(2)*a*(q + S(1))*(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))) + c*(d + e*x**S(2))**(q + S(1))*(b/sqrt(-S(4)*a*c + b**S(2)) + S(1))*hyper((S(1), q + S(1)), (q + S(2),), S(2)*c*(d + e*x**S(2))/(-b*e + S(2)*c*d + e*sqrt(-S(4)*a*c + b**S(2))))/(S(2)*a*(q + S(1))*(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))) - (d + e*x**S(2))**(q + S(1))*hyper((S(1), q + S(1)), (q + S(2),), S(1) + e*x**S(2)/d)/(S(2)*a*d*(q + S(1))), expand=True, _diff=True, _numerical=True)
# NC assert rubi_test(rubi_integrate((d + e*x**S(2))**q/(x**S(3)*(a + b*x**S(2) + c*x**S(4))), x), x, e*(d + e*x**S(2))**(q + S(1))*hyper((S(2), q + S(1)), (q + S(2),), S(1) + e*x**S(2)/d)/(S(2)*a*d**S(2)*(q + S(1))) + b*(d + e*x**S(2))**(q + S(1))*hyper((S(1), q + S(1)), (q + S(2),), S(1) + e*x**S(2)/d)/(S(2)*a**S(2)*d*(q + S(1))) - c*(b - (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*(d + e*x**S(2))**(q + S(1))*hyper((S(1), q + S(1)), (q + S(2),), S(2)*c*(d + e*x**S(2))/(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2)))))/(S(2)*a**S(2)*(q + S(1))*(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))) - c*(b + (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*(d + e*x**S(2))**(q + S(1))*hyper((S(1), q + S(1)), (q + S(2),), S(2)*c*(d + e*x**S(2))/(-b*e + S(2)*c*d + e*sqrt(-S(4)*a*c + b**S(2))))/(S(2)*a**S(2)*(q + S(1))*(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))), expand=True, _diff=True, _numerical=True)
# NC assert rubi_test(rubi_integrate(x**S(6)*(d + e*x**S(2))**q/(a + b*x**S(2) + c*x**S(4)), x), x, -b*x*(S(1) + e*x**S(2)/d)**(-q)*(d + e*x**S(2))**q*hyper((S(1)/2, -q), (S(3)/2,), -e*x**S(2)/d)/c**S(2) + x**S(3)*(S(1) + e*x**S(2)/d)**(-q)*(d + e*x**S(2))**q*hyper((S(3)/2, -q), (S(5)/2,), -e*x**S(2)/d)/(S(3)*c) + x*(S(1) + e*x**S(2)/d)**(-q)*(d + e*x**S(2))**q*(-a*c + b**S(2) + b*(-S(3)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*AppellF1(S(1)/2, S(1), -q, S(3)/2, -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))), -e*x**S(2)/d)/(c**S(2)*(b + sqrt(-S(4)*a*c + b**S(2)))) + x*(S(1) + e*x**S(2)/d)**(-q)*(d + e*x**S(2))**q*(-a*c + b**S(2) - b*(-S(3)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*AppellF1(S(1)/2, S(1), -q, S(3)/2, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -e*x**S(2)/d)/(c**S(2)*(b - sqrt(-S(4)*a*c + b**S(2)))), expand=True, _diff=True, _numerical=True)
# NC assert rubi_test(rubi_integrate(x**S(4)*(d + e*x**S(2))**q/(a + b*x**S(2) + c*x**S(4)), x), x, -x*(S(1) + e*x**S(2)/d)**(-q)*(b - (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*(d + e*x**S(2))**q*AppellF1(S(1)/2, S(1), -q, S(3)/2, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -e*x**S(2)/d)/(c*(b - sqrt(-S(4)*a*c + b**S(2)))) - x*(S(1) + e*x**S(2)/d)**(-q)*(b + (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*(d + e*x**S(2))**q*AppellF1(S(1)/2, S(1), -q, S(3)/2, -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))), -e*x**S(2)/d)/(c*(b + sqrt(-S(4)*a*c + b**S(2)))) + x*(S(1) + e*x**S(2)/d)**(-q)*(d + e*x**S(2))**q*hyper((S(1)/2, -q), (S(3)/2,), -e*x**S(2)/d)/c, expand=True, _diff=True, _numerical=True)
# NC assert rubi_test(rubi_integrate(x**S(2)*(d + e*x**S(2))**q/(a + b*x**S(2) + c*x**S(4)), x), x, -x*(S(1) + e*x**S(2)/d)**(-q)*(d + e*x**S(2))**q*AppellF1(S(1)/2, S(1), -q, S(3)/2, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -e*x**S(2)/d)/sqrt(-S(4)*a*c + b**S(2)) + x*(S(1) + e*x**S(2)/d)**(-q)*(d + e*x**S(2))**q*AppellF1(S(1)/2, S(1), -q, S(3)/2, -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))), -e*x**S(2)/d)/sqrt(-S(4)*a*c + b**S(2)), expand=True, _diff=True, _numerical=True)
# NC assert rubi_test(rubi_integrate((d + e*x**S(2))**q/(a + b*x**S(2) + c*x**S(4)), x), x, -S(2)*c*x*(S(1) + e*x**S(2)/d)**(-q)*(d + e*x**S(2))**q*AppellF1(S(1)/2, S(1), -q, S(3)/2, -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))), -e*x**S(2)/d)/(-S(4)*a*c + b**S(2) + b*sqrt(-S(4)*a*c + b**S(2))) - S(2)*c*x*(S(1) + e*x**S(2)/d)**(-q)*(d + e*x**S(2))**q*AppellF1(S(1)/2, S(1), -q, S(3)/2, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -e*x**S(2)/d)/(-S(4)*a*c + b**S(2) - b*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
# NC assert rubi_test(rubi_integrate((d + e*x**S(2))**q/(x**S(2)*(a + b*x**S(2) + c*x**S(4))), x), x, -c*x*(S(1) + e*x**S(2)/d)**(-q)*(d + e*x**S(2))**q*(-b/sqrt(-S(4)*a*c + b**S(2)) + S(1))*AppellF1(S(1)/2, S(1), -q, S(3)/2, -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))), -e*x**S(2)/d)/(a*(b + sqrt(-S(4)*a*c + b**S(2)))) - c*x*(S(1) + e*x**S(2)/d)**(-q)*(d + e*x**S(2))**q*(b/sqrt(-S(4)*a*c + b**S(2)) + S(1))*AppellF1(S(1)/2, S(1), -q, S(3)/2, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -e*x**S(2)/d)/(a*(b - sqrt(-S(4)*a*c + b**S(2)))) - (S(1) + e*x**S(2)/d)**(-q)*(d + e*x**S(2))**q*hyper((S(-1)/2, -q), (S(1)/2,), -e*x**S(2)/d)/(a*x), expand=True, _diff=True, _numerical=True)
# NC assert rubi_test(rubi_integrate((d + e*x**S(2))**q/(x**S(4)*(a + b*x**S(2) + c*x**S(4))), x), x, -(S(1) + e*x**S(2)/d)**(-q)*(d + e*x**S(2))**q*hyper((S(-3)/2, -q), (S(-1)/2,), -e*x**S(2)/d)/(S(3)*a*x**S(3)) + b*(S(1) + e*x**S(2)/d)**(-q)*(d + e*x**S(2))**q*hyper((S(-1)/2, -q), (S(1)/2,), -e*x**S(2)/d)/(a**S(2)*x) + c*x*(S(1) + e*x**S(2)/d)**(-q)*(b - (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*(d + e*x**S(2))**q*AppellF1(S(1)/2, S(1), -q, S(3)/2, -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))), -e*x**S(2)/d)/(a**S(2)*(b + sqrt(-S(4)*a*c + b**S(2)))) + c*x*(S(1) + e*x**S(2)/d)**(-q)*(b + (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*(d + e*x**S(2))**q*AppellF1(S(1)/2, S(1), -q, S(3)/2, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -e*x**S(2)/d)/(a**S(2)*(b - sqrt(-S(4)*a*c + b**S(2)))), expand=True, _diff=True, _numerical=True)
# NC assert rubi_test(rubi_integrate((d + e*x**S(3))/(a + c*x**S(6)), x), x, -(sqrt(c)*d - e*sqrt(-a))*log(c**(S(1)/6)*x + (-a)**(S(1)/6))/(S(6)*c**(S(2)/3)*(-a)**(S(5)/6)) + (sqrt(c)*d - e*sqrt(-a))*log(-c**(S(1)/6)*x*(-a)**(S(1)/6) + c**(S(1)/3)*x**S(2) + (-a)**(S(1)/3))/(S(12)*c**(S(2)/3)*(-a)**(S(5)/6)) + sqrt(S(3))*(sqrt(c)*d - e*sqrt(-a))*atan(sqrt(S(3))*(-S(2)*c**(S(1)/6)*x/(-a)**(S(1)/6) + S(1))/S(3))/(S(6)*c**(S(2)/3)*(-a)**(S(5)/6)) + (sqrt(c)*d + e*sqrt(-a))*log(-c**(S(1)/6)*x + (-a)**(S(1)/6))/(S(6)*c**(S(2)/3)*(-a)**(S(5)/6)) - (sqrt(c)*d + e*sqrt(-a))*log(c**(S(1)/6)*x*(-a)**(S(1)/6) + c**(S(1)/3)*x**S(2) + (-a)**(S(1)/3))/(S(12)*c**(S(2)/3)*(-a)**(S(5)/6)) - sqrt(S(3))*(sqrt(c)*d + e*sqrt(-a))*atan(sqrt(S(3))*(S(2)*c**(S(1)/6)*x/(-a)**(S(1)/6) + S(1))/S(3))/(S(6)*c**(S(2)/3)*(-a)**(S(5)/6)), expand=True, _diff=True, _numerical=True)
# NC assert rubi_test(rubi_integrate((d + e*x**S(3))/(a - c*x**S(6)), x), x, (-sqrt(a)*e + sqrt(c)*d)*log(a**(S(1)/6) + c**(S(1)/6)*x)/(S(6)*a**(S(5)/6)*c**(S(2)/3)) - (-sqrt(a)*e + sqrt(c)*d)*log(-a**(S(1)/6)*c**(S(1)/6)*x + a**(S(1)/3) + c**(S(1)/3)*x**S(2))/(S(12)*a**(S(5)/6)*c**(S(2)/3)) - sqrt(S(3))*(-sqrt(a)*e + sqrt(c)*d)*atan(sqrt(S(3))*(a**(S(1)/6) - S(2)*c**(S(1)/6)*x)/(S(3)*a**(S(1)/6)))/(S(6)*a**(S(5)/6)*c**(S(2)/3)) - (sqrt(a)*e + sqrt(c)*d)*log(a**(S(1)/6) - c**(S(1)/6)*x)/(S(6)*a**(S(5)/6)*c**(S(2)/3)) + (sqrt(a)*e + sqrt(c)*d)*log(a**(S(1)/6)*c**(S(1)/6)*x + a**(S(1)/3) + c**(S(1)/3)*x**S(2))/(S(12)*a**(S(5)/6)*c**(S(2)/3)) + sqrt(S(3))*(sqrt(a)*e + sqrt(c)*d)*atan(sqrt(S(3))*(a**(S(1)/6) + S(2)*c**(S(1)/6)*x)/(S(3)*a**(S(1)/6)))/(S(6)*a**(S(5)/6)*c**(S(2)/3)), expand=True, _diff=True, _numerical=True)
# nc assert rubi_test(rubi_integrate((d + e*x**S(3))**S(5)*(a + b*x**S(3) + c*x**S(6)), x), x, a*d**S(5)*x + c*e**S(5)*x**S(22)/S(22) + d**S(4)*x**S(4)*(S(5)*a*e + b*d)/S(4) + d**S(3)*x**S(7)*(c*d**S(2) + S(5)*e*(S(2)*a*e + b*d))/S(7) + d**S(2)*e*x**S(10)*(c*d**S(2) + S(2)*e*(a*e + b*d))/S(2) + S(5)*d*e**S(2)*x**S(13)*(S(2)*c*d**S(2) + e*(a*e + S(2)*b*d))/S(13) + e**S(4)*x**S(19)*(b*e + S(5)*c*d)/S(19) + e**S(3)*x**S(16)*(S(10)*c*d**S(2) + e*(a*e + S(5)*b*d))/S(16), expand=True, _diff=True, _numerical=True)
# nc assert rubi_test(rubi_integrate((d + e*x**S(3))**S(4)*(a + b*x**S(3) + c*x**S(6)), x), x, a*d**S(4)*x + c*e**S(4)*x**S(19)/S(19) + d**S(3)*x**S(4)*(S(4)*a*e + b*d)/S(4) + d**S(2)*x**S(7)*(S(6)*a*e**S(2) + S(4)*b*d*e + c*d**S(2))/S(7) + d*e*x**S(10)*(S(2)*c*d**S(2) + e*(S(2)*a*e + S(3)*b*d))/S(5) + e**S(3)*x**S(16)*(b*e + S(4)*c*d)/S(16) + e**S(2)*x**S(13)*(S(6)*c*d**S(2) + e*(a*e + S(4)*b*d))/S(13), expand=True, _diff=True, _numerical=True)
# nc assert rubi_test(rubi_integrate((d + e*x**S(3))**S(3)*(a + b*x**S(3) + c*x**S(6)), x), x, a*d**S(3)*x + c*e**S(3)*x**S(16)/S(16) + d**S(2)*x**S(4)*(S(3)*a*e + b*d)/S(4) + d*x**S(7)*(c*d**S(2) + S(3)*e*(a*e + b*d))/S(7) + e**S(2)*x**S(13)*(b*e + S(3)*c*d)/S(13) + e*x**S(10)*(S(3)*c*d**S(2) + e*(a*e + S(3)*b*d))/S(10), expand=True, _diff=True, _numerical=True)
# ncassert rubi_test(rubi_integrate((d + e*x**S(3))**S(2)*(a + b*x**S(3) + c*x**S(6)), x), x, a*d**S(2)*x + c*e**S(2)*x**S(13)/S(13) + d*x**S(4)*(S(2)*a*e + b*d)/S(4) + e*x**S(10)*(b*e + S(2)*c*d)/S(10) + x**S(7)*(c*d**S(2) + e*(a*e + S(2)*b*d))/S(7), expand=True, _diff=True, _numerical=True)
# nc assert rubi_test(rubi_integrate((d + e*x**S(3))*(a + b*x**S(3) + c*x**S(6)), x), x, a*d*x + c*e*x**S(10)/S(10) + x**S(7)*(b*e + c*d)/S(7) + x**S(4)*(a*e + b*d)/S(4), expand=True, _diff=True, _numerical=True)
# nc assert rubi_test(rubi_integrate((a + b*x**S(3) + c*x**S(6))/(d + e*x**S(3)), x), x, c*x**S(4)/(S(4)*e) - x*(-b*e + c*d)/e**S(2) + (a*e**S(2) - b*d*e + c*d**S(2))*log(d**(S(1)/3) + e**(S(1)/3)*x)/(S(3)*d**(S(2)/3)*e**(S(7)/3)) - (a*e**S(2) - b*d*e + c*d**S(2))*log(d**(S(2)/3) - d**(S(1)/3)*e**(S(1)/3)*x + e**(S(2)/3)*x**S(2))/(S(6)*d**(S(2)/3)*e**(S(7)/3)) - sqrt(S(3))*(a*e**S(2) - b*d*e + c*d**S(2))*atan(sqrt(S(3))*(d**(S(1)/3) - S(2)*e**(S(1)/3)*x)/(S(3)*d**(S(1)/3)))/(S(3)*d**(S(2)/3)*e**(S(7)/3)), expand=True, _diff=True, _numerical=True)
# nc assert rubi_test(rubi_integrate((a + b*x**S(3) + c*x**S(6))/(d + e*x**S(3))**S(2), x), x, c*x/e**S(2) + x*(a*e**S(2) - b*d*e + c*d**S(2))/(S(3)*d*e**S(2)*(d + e*x**S(3))) - (S(4)*c*d**S(2) - e*(S(2)*a*e + b*d))*log(d**(S(1)/3) + e**(S(1)/3)*x)/(S(9)*d**(S(5)/3)*e**(S(7)/3)) + (S(4)*c*d**S(2) - e*(S(2)*a*e + b*d))*log(d**(S(2)/3) - d**(S(1)/3)*e**(S(1)/3)*x + e**(S(2)/3)*x**S(2))/(S(18)*d**(S(5)/3)*e**(S(7)/3)) + sqrt(S(3))*(S(4)*c*d**S(2) - e*(S(2)*a*e + b*d))*atan(sqrt(S(3))*(d**(S(1)/3) - S(2)*e**(S(1)/3)*x)/(S(3)*d**(S(1)/3)))/(S(9)*d**(S(5)/3)*e**(S(7)/3)), expand=True, _diff=True, _numerical=True)
# nc assert rubi_test(rubi_integrate((a + b*x**S(3) + c*x**S(6))/(d + e*x**S(3))**S(3), x), x, x*(a*e**S(2) - b*d*e + c*d**S(2))/(S(6)*d*e**S(2)*(d + e*x**S(3))**S(2)) - x*(S(7)*c*d**S(2) - e*(S(5)*a*e + b*d))/(S(18)*d**S(2)*e**S(2)*(d + e*x**S(3))) + (S(2)*c*d**S(2) + e*(S(5)*a*e + b*d))*log(d**(S(1)/3) + e**(S(1)/3)*x)/(S(27)*d**(S(8)/3)*e**(S(7)/3)) - (S(2)*c*d**S(2) + e*(S(5)*a*e + b*d))*log(d**(S(2)/3) - d**(S(1)/3)*e**(S(1)/3)*x + e**(S(2)/3)*x**S(2))/(S(54)*d**(S(8)/3)*e**(S(7)/3)) - sqrt(S(3))*(S(2)*c*d**S(2) + e*(S(5)*a*e + b*d))*atan(sqrt(S(3))*(d**(S(1)/3) - S(2)*e**(S(1)/3)*x)/(S(3)*d**(S(1)/3)))/(S(27)*d**(S(8)/3)*e**(S(7)/3)), expand=True, _diff=True, _numerical=True)
# '''
assert rubi_test(rubi_integrate(x**S(8)*(d + e*x**S(3))/(a + b*x**S(3) + c*x**S(6)), x), x, e*x**S(6)/(S(6)*c) + x**S(3)*(-b*e + c*d)/(S(3)*c**S(2)) - (a*c*e - b**S(2)*e + b*c*d)*log(a + b*x**S(3) + c*x**S(6))/(S(6)*c**S(3)) - (S(3)*a*b*c*e - S(2)*a*c**S(2)*d - b**S(3)*e + b**S(2)*c*d)*atanh((b + S(2)*c*x**S(3))/sqrt(-S(4)*a*c + b**S(2)))/(S(3)*c**S(3)*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)*(d + e*x**S(3))/(a + b*x**S(3) + c*x**S(6)), x), x, e*x**S(3)/(S(3)*c) + (-b*e + c*d)*log(a + b*x**S(3) + c*x**S(6))/(S(6)*c**S(2)) + (S(2)*a*c*e - b**S(2)*e + b*c*d)*atanh((b + S(2)*c*x**S(3))/sqrt(-S(4)*a*c + b**S(2)))/(S(3)*c**S(2)*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(d + e*x**S(3))/(a + b*x**S(3) + c*x**S(6)), x), x, e*log(a + b*x**S(3) + c*x**S(6))/(S(6)*c) - (-b*e + S(2)*c*d)*atanh((b + S(2)*c*x**S(3))/sqrt(-S(4)*a*c + b**S(2)))/(S(3)*c*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(3))/(x*(a + b*x**S(3) + c*x**S(6))), x), x, d*log(x)/a - d*log(a + b*x**S(3) + c*x**S(6))/(S(6)*a) + (-S(2)*a*e + b*d)*atanh((b + S(2)*c*x**S(3))/sqrt(-S(4)*a*c + b**S(2)))/(S(3)*a*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(3))/(x**S(4)*(a + b*x**S(3) + c*x**S(6))), x), x, -d/(S(3)*a*x**S(3)) - (-a*e + b*d)*log(x)/a**S(2) + (-a*e + b*d)*log(a + b*x**S(3) + c*x**S(6))/(S(6)*a**S(2)) - (-a*b*e - S(2)*a*c*d + b**S(2)*d)*atanh((b + S(2)*c*x**S(3))/sqrt(-S(4)*a*c + b**S(2)))/(S(3)*a**S(2)*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)*(d + e*x**S(3))/(a + b*x**S(3) + c*x**S(6)), x), x, e*x**S(2)/(S(2)*c) - S(2)**(S(1)/3)*(-b*e + c*d + (S(2)*a*c*e - b**S(2)*e + b*c*d)/sqrt(-S(4)*a*c + b**S(2)))*log(S(2)**(S(1)/3)*c**(S(1)/3)*x + (b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3))/(S(6)*c**(S(5)/3)*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3)) + S(2)**(S(1)/3)*(-b*e + c*d + (S(2)*a*c*e - b**S(2)*e + b*c*d)/sqrt(-S(4)*a*c + b**S(2)))*log(S(2)**(S(2)/3)*c**(S(2)/3)*x**S(2) - S(2)**(S(1)/3)*c**(S(1)/3)*x*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + (b + sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3))/(S(12)*c**(S(5)/3)*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3)) - S(2)**(S(1)/3)*sqrt(S(3))*(-b*e + c*d + (S(2)*a*c*e - b**S(2)*e + b*c*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(3))*(-S(2)*S(2)**(S(1)/3)*c**(S(1)/3)*x/(b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + S(1))/S(3))/(S(6)*c**(S(5)/3)*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3)) - S(2)**(S(1)/3)*(-b*e + c*d - (S(2)*a*c*e - b**S(2)*e + b*c*d)/sqrt(-S(4)*a*c + b**S(2)))*log(S(2)**(S(1)/3)*c**(S(1)/3)*x + (b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3))/(S(6)*c**(S(5)/3)*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3)) + S(2)**(S(1)/3)*(-b*e + c*d - (S(2)*a*c*e - b**S(2)*e + b*c*d)/sqrt(-S(4)*a*c + b**S(2)))*log(S(2)**(S(2)/3)*c**(S(2)/3)*x**S(2) - S(2)**(S(1)/3)*c**(S(1)/3)*x*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + (b - sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3))/(S(12)*c**(S(5)/3)*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3)) - S(2)**(S(1)/3)*sqrt(S(3))*(-b*e + c*d - (S(2)*a*c*e - b**S(2)*e + b*c*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(3))*(-S(2)*S(2)**(S(1)/3)*c**(S(1)/3)*x/(b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + S(1))/S(3))/(S(6)*c**(S(5)/3)*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*(d + e*x**S(3))/(a + b*x**S(3) + c*x**S(6)), x), x, e*x/c + S(2)**(S(2)/3)*(-b*e + c*d + (S(2)*a*c*e - b**S(2)*e + b*c*d)/sqrt(-S(4)*a*c + b**S(2)))*log(S(2)**(S(1)/3)*c**(S(1)/3)*x + (b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3))/(S(6)*c**(S(4)/3)*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)) - S(2)**(S(2)/3)*(-b*e + c*d + (S(2)*a*c*e - b**S(2)*e + b*c*d)/sqrt(-S(4)*a*c + b**S(2)))*log(S(2)**(S(2)/3)*c**(S(2)/3)*x**S(2) - S(2)**(S(1)/3)*c**(S(1)/3)*x*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + (b + sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3))/(S(12)*c**(S(4)/3)*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)) - S(2)**(S(2)/3)*sqrt(S(3))*(-b*e + c*d + (S(2)*a*c*e - b**S(2)*e + b*c*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(3))*(-S(2)*S(2)**(S(1)/3)*c**(S(1)/3)*x/(b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + S(1))/S(3))/(S(6)*c**(S(4)/3)*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)) + S(2)**(S(2)/3)*(-b*e + c*d - (S(2)*a*c*e - b**S(2)*e + b*c*d)/sqrt(-S(4)*a*c + b**S(2)))*log(S(2)**(S(1)/3)*c**(S(1)/3)*x + (b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3))/(S(6)*c**(S(4)/3)*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)) - S(2)**(S(2)/3)*(-b*e + c*d - (S(2)*a*c*e - b**S(2)*e + b*c*d)/sqrt(-S(4)*a*c + b**S(2)))*log(S(2)**(S(2)/3)*c**(S(2)/3)*x**S(2) - S(2)**(S(1)/3)*c**(S(1)/3)*x*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + (b - sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3))/(S(12)*c**(S(4)/3)*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)) - S(2)**(S(2)/3)*sqrt(S(3))*(-b*e + c*d - (S(2)*a*c*e - b**S(2)*e + b*c*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(3))*(-S(2)*S(2)**(S(1)/3)*c**(S(1)/3)*x/(b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + S(1))/S(3))/(S(6)*c**(S(4)/3)*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(d + e*x**S(3))/(a + b*x**S(3) + c*x**S(6)), x), x, -S(2)**(S(1)/3)*(e - (-b*e + S(2)*c*d)/sqrt(-S(4)*a*c + b**S(2)))*log(S(2)**(S(1)/3)*c**(S(1)/3)*x + (b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3))/(S(6)*c**(S(2)/3)*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3)) + S(2)**(S(1)/3)*(e - (-b*e + S(2)*c*d)/sqrt(-S(4)*a*c + b**S(2)))*log(S(2)**(S(2)/3)*c**(S(2)/3)*x**S(2) - S(2)**(S(1)/3)*c**(S(1)/3)*x*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + (b + sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3))/(S(12)*c**(S(2)/3)*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3)) - S(2)**(S(1)/3)*sqrt(S(3))*(e - (-b*e + S(2)*c*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(3))*(-S(2)*S(2)**(S(1)/3)*c**(S(1)/3)*x/(b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + S(1))/S(3))/(S(6)*c**(S(2)/3)*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3)) - S(2)**(S(1)/3)*(e + (-b*e + S(2)*c*d)/sqrt(-S(4)*a*c + b**S(2)))*log(S(2)**(S(1)/3)*c**(S(1)/3)*x + (b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3))/(S(6)*c**(S(2)/3)*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3)) + S(2)**(S(1)/3)*(e + (-b*e + S(2)*c*d)/sqrt(-S(4)*a*c + b**S(2)))*log(S(2)**(S(2)/3)*c**(S(2)/3)*x**S(2) - S(2)**(S(1)/3)*c**(S(1)/3)*x*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + (b - sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3))/(S(12)*c**(S(2)/3)*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3)) - S(2)**(S(1)/3)*sqrt(S(3))*(e + (-b*e + S(2)*c*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(3))*(-S(2)*S(2)**(S(1)/3)*c**(S(1)/3)*x/(b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + S(1))/S(3))/(S(6)*c**(S(2)/3)*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(3))/(a + b*x**S(3) + c*x**S(6)), x), x, S(2)**(S(2)/3)*(e - (-b*e + S(2)*c*d)/sqrt(-S(4)*a*c + b**S(2)))*log(S(2)**(S(1)/3)*c**(S(1)/3)*x + (b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3))/(S(6)*c**(S(1)/3)*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)) - S(2)**(S(2)/3)*(e - (-b*e + S(2)*c*d)/sqrt(-S(4)*a*c + b**S(2)))*log(S(2)**(S(2)/3)*c**(S(2)/3)*x**S(2) - S(2)**(S(1)/3)*c**(S(1)/3)*x*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + (b + sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3))/(S(12)*c**(S(1)/3)*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)) - S(2)**(S(2)/3)*sqrt(S(3))*(e - (-b*e + S(2)*c*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(3))*(-S(2)*S(2)**(S(1)/3)*c**(S(1)/3)*x/(b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + S(1))/S(3))/(S(6)*c**(S(1)/3)*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)) + S(2)**(S(2)/3)*(e + (-b*e + S(2)*c*d)/sqrt(-S(4)*a*c + b**S(2)))*log(S(2)**(S(1)/3)*c**(S(1)/3)*x + (b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3))/(S(6)*c**(S(1)/3)*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)) - S(2)**(S(2)/3)*(e + (-b*e + S(2)*c*d)/sqrt(-S(4)*a*c + b**S(2)))*log(S(2)**(S(2)/3)*c**(S(2)/3)*x**S(2) - S(2)**(S(1)/3)*c**(S(1)/3)*x*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + (b - sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3))/(S(12)*c**(S(1)/3)*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)) - S(2)**(S(2)/3)*sqrt(S(3))*(e + (-b*e + S(2)*c*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(3))*(-S(2)*S(2)**(S(1)/3)*c**(S(1)/3)*x/(b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + S(1))/S(3))/(S(6)*c**(S(1)/3)*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(3))/(x**S(2)*(a + b*x**S(3) + c*x**S(6))), x), x, S(2)**(S(1)/3)*c**(S(1)/3)*(d - (-S(2)*a*e + b*d)/sqrt(-S(4)*a*c + b**S(2)))*log(S(2)**(S(1)/3)*c**(S(1)/3)*x + (b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3))/(S(6)*a*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3)) - S(2)**(S(1)/3)*c**(S(1)/3)*(d - (-S(2)*a*e + b*d)/sqrt(-S(4)*a*c + b**S(2)))*log(S(2)**(S(2)/3)*c**(S(2)/3)*x**S(2) - S(2)**(S(1)/3)*c**(S(1)/3)*x*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + (b + sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3))/(S(12)*a*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3)) + S(2)**(S(1)/3)*sqrt(S(3))*c**(S(1)/3)*(d - (-S(2)*a*e + b*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(3))*(-S(2)*S(2)**(S(1)/3)*c**(S(1)/3)*x/(b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + S(1))/S(3))/(S(6)*a*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3)) + S(2)**(S(1)/3)*c**(S(1)/3)*(d + (-S(2)*a*e + b*d)/sqrt(-S(4)*a*c + b**S(2)))*log(S(2)**(S(1)/3)*c**(S(1)/3)*x + (b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3))/(S(6)*a*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3)) - S(2)**(S(1)/3)*c**(S(1)/3)*(d + (-S(2)*a*e + b*d)/sqrt(-S(4)*a*c + b**S(2)))*log(S(2)**(S(2)/3)*c**(S(2)/3)*x**S(2) - S(2)**(S(1)/3)*c**(S(1)/3)*x*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + (b - sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3))/(S(12)*a*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3)) + S(2)**(S(1)/3)*sqrt(S(3))*c**(S(1)/3)*(d + (-S(2)*a*e + b*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(3))*(-S(2)*S(2)**(S(1)/3)*c**(S(1)/3)*x/(b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + S(1))/S(3))/(S(6)*a*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3)) - d/(a*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(3))/(x**S(3)*(a + b*x**S(3) + c*x**S(6))), x), x, -S(2)**(S(2)/3)*c**(S(2)/3)*(d - (-S(2)*a*e + b*d)/sqrt(-S(4)*a*c + b**S(2)))*log(S(2)**(S(1)/3)*c**(S(1)/3)*x + (b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3))/(S(6)*a*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)) + S(2)**(S(2)/3)*c**(S(2)/3)*(d - (-S(2)*a*e + b*d)/sqrt(-S(4)*a*c + b**S(2)))*log(S(2)**(S(2)/3)*c**(S(2)/3)*x**S(2) - S(2)**(S(1)/3)*c**(S(1)/3)*x*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + (b + sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3))/(S(12)*a*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)) + S(2)**(S(2)/3)*sqrt(S(3))*c**(S(2)/3)*(d - (-S(2)*a*e + b*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(3))*(-S(2)*S(2)**(S(1)/3)*c**(S(1)/3)*x/(b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + S(1))/S(3))/(S(6)*a*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)) - S(2)**(S(2)/3)*c**(S(2)/3)*(d + (-S(2)*a*e + b*d)/sqrt(-S(4)*a*c + b**S(2)))*log(S(2)**(S(1)/3)*c**(S(1)/3)*x + (b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3))/(S(6)*a*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)) + S(2)**(S(2)/3)*c**(S(2)/3)*(d + (-S(2)*a*e + b*d)/sqrt(-S(4)*a*c + b**S(2)))*log(S(2)**(S(2)/3)*c**(S(2)/3)*x**S(2) - S(2)**(S(1)/3)*c**(S(1)/3)*x*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + (b - sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3))/(S(12)*a*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)) + S(2)**(S(2)/3)*sqrt(S(3))*c**(S(2)/3)*(d + (-S(2)*a*e + b*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(3))*(-S(2)*S(2)**(S(1)/3)*c**(S(1)/3)*x/(b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + S(1))/S(3))/(S(6)*a*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)) - d/(S(2)*a*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(8)*(-x**S(3) + S(1))/(x**S(6) - x**S(3) + S(1)), x), x, -x**S(6)/S(6) + log(x**S(6) - x**S(3) + S(1))/S(6) - sqrt(S(3))*atan(sqrt(S(3))*(-S(2)*x**S(3) + S(1))/S(3))/S(9), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)*(-x**S(3) + S(1))/(x**S(6) - x**S(3) + S(1)), x), x, -x**S(3)/S(3) - S(2)*sqrt(S(3))*atan(sqrt(S(3))*(-S(2)*x**S(3) + S(1))/S(3))/S(9), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(-x**S(3) + S(1))/(x**S(6) - x**S(3) + S(1)), x), x, -log(x**S(6) - x**S(3) + S(1))/S(6) - sqrt(S(3))*atan(sqrt(S(3))*(-S(2)*x**S(3) + S(1))/S(3))/S(9), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-x**S(3) + S(1))/(x*(x**S(6) - x**S(3) + S(1))), x), x, log(x) - log(x**S(6) - x**S(3) + S(1))/S(6) + sqrt(S(3))*atan(sqrt(S(3))*(-S(2)*x**S(3) + S(1))/S(3))/S(9), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-x**S(3) + S(1))/(x**S(4)*(x**S(6) - x**S(3) + S(1))), x), x, S(2)*sqrt(S(3))*atan(sqrt(S(3))*(-S(2)*x**S(3) + S(1))/S(3))/S(9) - S(1)/(S(3)*x**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(6)*(-x**S(3) + S(1))/(x**S(6) - x**S(3) + S(1)), x), x, -x**S(4)/S(4) + S(2)**(S(2)/3)*(S(3) + sqrt(S(3))*I)*log(-S(2)**(S(1)/3)*x + (S(1) - sqrt(S(3))*I)**(S(1)/3))/(S(18)*(S(1) - sqrt(S(3))*I)**(S(2)/3)) + S(2)**(S(2)/3)*(S(3) - sqrt(S(3))*I)*log(-S(2)**(S(1)/3)*x + (S(1) + sqrt(S(3))*I)**(S(1)/3))/(S(18)*(S(1) + sqrt(S(3))*I)**(S(2)/3)) - S(2)**(S(2)/3)*(S(3) + sqrt(S(3))*I)*log(S(2)**(S(2)/3)*x**S(2) + x*(S(2) - S(2)*sqrt(S(3))*I)**(S(1)/3) + (S(1) - sqrt(S(3))*I)**(S(2)/3))/(S(36)*(S(1) - sqrt(S(3))*I)**(S(2)/3)) - S(2)**(S(2)/3)*(S(3) - sqrt(S(3))*I)*log(S(2)**(S(2)/3)*x**S(2) + x*(S(2) + S(2)*sqrt(S(3))*I)**(S(1)/3) + (S(1) + sqrt(S(3))*I)**(S(2)/3))/(S(36)*(S(1) + sqrt(S(3))*I)**(S(2)/3)) - S(2)**(S(2)/3)*(sqrt(S(3)) + I)*atan(sqrt(S(3))*(S(2)*x/(S(1)/2 - sqrt(S(3))*I/S(2))**(S(1)/3) + S(1))/S(3))/(S(6)*(S(1) - sqrt(S(3))*I)**(S(2)/3)) + S(2)**(S(2)/3)*(-sqrt(S(3)) + I)*atan(sqrt(S(3))*(S(2)*x/(S(1)/2 + sqrt(S(3))*I/S(2))**(S(1)/3) + S(1))/S(3))/(S(6)*(S(1) + sqrt(S(3))*I)**(S(2)/3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)*(-x**S(3) + S(1))/(x**S(6) - x**S(3) + S(1)), x), x, -x**S(2)/S(2) + sqrt(S(3))*I*log(-S(2)**(S(1)/3)*x + (S(1) - sqrt(S(3))*I)**(S(1)/3))/(S(9)*(S(1)/2 - sqrt(S(3))*I/S(2))**(S(1)/3)) - sqrt(S(3))*I*log(-S(2)**(S(1)/3)*x + (S(1) + sqrt(S(3))*I)**(S(1)/3))/(S(9)*(S(1)/2 + sqrt(S(3))*I/S(2))**(S(1)/3)) - S(2)**(S(1)/3)*sqrt(S(3))*I*log(S(2)**(S(2)/3)*x**S(2) + x*(S(2) - S(2)*sqrt(S(3))*I)**(S(1)/3) + (S(1) - sqrt(S(3))*I)**(S(2)/3))/(S(18)*(S(1) - sqrt(S(3))*I)**(S(1)/3)) + S(2)**(S(1)/3)*sqrt(S(3))*I*log(S(2)**(S(2)/3)*x**S(2) + x*(S(2) + S(2)*sqrt(S(3))*I)**(S(1)/3) + (S(1) + sqrt(S(3))*I)**(S(2)/3))/(S(18)*(S(1) + sqrt(S(3))*I)**(S(1)/3)) + I*atan(sqrt(S(3))*(S(2)*x/(S(1)/2 - sqrt(S(3))*I/S(2))**(S(1)/3) + S(1))/S(3))/(S(3)*(S(1)/2 - sqrt(S(3))*I/S(2))**(S(1)/3)) - I*atan(sqrt(S(3))*(S(2)*x/(S(1)/2 + sqrt(S(3))*I/S(2))**(S(1)/3) + S(1))/S(3))/(S(3)*(S(1)/2 + sqrt(S(3))*I/S(2))**(S(1)/3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*(-x**S(3) + S(1))/(x**S(6) - x**S(3) + S(1)), x), x, -x + sqrt(S(3))*I*log(-S(2)**(S(1)/3)*x + (S(1) - sqrt(S(3))*I)**(S(1)/3))/(S(9)*(S(1)/2 - sqrt(S(3))*I/S(2))**(S(2)/3)) - sqrt(S(3))*I*log(-S(2)**(S(1)/3)*x + (S(1) + sqrt(S(3))*I)**(S(1)/3))/(S(9)*(S(1)/2 + sqrt(S(3))*I/S(2))**(S(2)/3)) - S(2)**(S(2)/3)*sqrt(S(3))*I*log(S(2)**(S(2)/3)*x**S(2) + x*(S(2) - S(2)*sqrt(S(3))*I)**(S(1)/3) + (S(1) - sqrt(S(3))*I)**(S(2)/3))/(S(18)*(S(1) - sqrt(S(3))*I)**(S(2)/3)) + S(2)**(S(2)/3)*sqrt(S(3))*I*log(S(2)**(S(2)/3)*x**S(2) + x*(S(2) + S(2)*sqrt(S(3))*I)**(S(1)/3) + (S(1) + sqrt(S(3))*I)**(S(2)/3))/(S(18)*(S(1) + sqrt(S(3))*I)**(S(2)/3)) - I*atan(sqrt(S(3))*(S(2)*x/(S(1)/2 - sqrt(S(3))*I/S(2))**(S(1)/3) + S(1))/S(3))/(S(3)*(S(1)/2 - sqrt(S(3))*I/S(2))**(S(2)/3)) + I*atan(sqrt(S(3))*(S(2)*x/(S(1)/2 + sqrt(S(3))*I/S(2))**(S(1)/3) + S(1))/S(3))/(S(3)*(S(1)/2 + sqrt(S(3))*I/S(2))**(S(2)/3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(-x**S(3) + S(1))/(x**S(6) - x**S(3) + S(1)), x), x, -S(2)**(S(1)/3)*(S(3) - sqrt(S(3))*I)*log(-S(2)**(S(1)/3)*x + (S(1) - sqrt(S(3))*I)**(S(1)/3))/(S(18)*(S(1) - sqrt(S(3))*I)**(S(1)/3)) - S(2)**(S(1)/3)*(S(3) + sqrt(S(3))*I)*log(-S(2)**(S(1)/3)*x + (S(1) + sqrt(S(3))*I)**(S(1)/3))/(S(18)*(S(1) + sqrt(S(3))*I)**(S(1)/3)) + S(2)**(S(1)/3)*(S(3) - sqrt(S(3))*I)*log(S(2)**(S(2)/3)*x**S(2) + x*(S(2) - S(2)*sqrt(S(3))*I)**(S(1)/3) + (S(1) - sqrt(S(3))*I)**(S(2)/3))/(S(36)*(S(1) - sqrt(S(3))*I)**(S(1)/3)) + S(2)**(S(1)/3)*(S(3) + sqrt(S(3))*I)*log(S(2)**(S(2)/3)*x**S(2) + x*(S(2) + S(2)*sqrt(S(3))*I)**(S(1)/3) + (S(1) + sqrt(S(3))*I)**(S(2)/3))/(S(36)*(S(1) + sqrt(S(3))*I)**(S(1)/3)) + S(2)**(S(1)/3)*(-sqrt(S(3)) + I)*atan(sqrt(S(3))*(S(2)*x/(S(1)/2 - sqrt(S(3))*I/S(2))**(S(1)/3) + S(1))/S(3))/(S(6)*(S(1) - sqrt(S(3))*I)**(S(1)/3)) - S(2)**(S(1)/3)*(sqrt(S(3)) + I)*atan(sqrt(S(3))*(S(2)*x/(S(1)/2 + sqrt(S(3))*I/S(2))**(S(1)/3) + S(1))/S(3))/(S(6)*(S(1) + sqrt(S(3))*I)**(S(1)/3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-x**S(3) + S(1))/(x**S(6) - x**S(3) + S(1)), x), x, -S(2)**(S(2)/3)*(S(3) - sqrt(S(3))*I)*log(-S(2)**(S(1)/3)*x + (S(1) - sqrt(S(3))*I)**(S(1)/3))/(S(18)*(S(1) - sqrt(S(3))*I)**(S(2)/3)) - S(2)**(S(2)/3)*(S(3) + sqrt(S(3))*I)*log(-S(2)**(S(1)/3)*x + (S(1) + sqrt(S(3))*I)**(S(1)/3))/(S(18)*(S(1) + sqrt(S(3))*I)**(S(2)/3)) + S(2)**(S(2)/3)*(S(3) - sqrt(S(3))*I)*log(S(2)**(S(2)/3)*x**S(2) + x*(S(2) - S(2)*sqrt(S(3))*I)**(S(1)/3) + (S(1) - sqrt(S(3))*I)**(S(2)/3))/(S(36)*(S(1) - sqrt(S(3))*I)**(S(2)/3)) + S(2)**(S(2)/3)*(S(3) + sqrt(S(3))*I)*log(S(2)**(S(2)/3)*x**S(2) + x*(S(2) + S(2)*sqrt(S(3))*I)**(S(1)/3) + (S(1) + sqrt(S(3))*I)**(S(2)/3))/(S(36)*(S(1) + sqrt(S(3))*I)**(S(2)/3)) - S(2)**(S(2)/3)*(-sqrt(S(3)) + I)*atan(sqrt(S(3))*(S(2)*x/(S(1)/2 - sqrt(S(3))*I/S(2))**(S(1)/3) + S(1))/S(3))/(S(6)*(S(1) - sqrt(S(3))*I)**(S(2)/3)) + S(2)**(S(2)/3)*(sqrt(S(3)) + I)*atan(sqrt(S(3))*(S(2)*x/(S(1)/2 + sqrt(S(3))*I/S(2))**(S(1)/3) + S(1))/S(3))/(S(6)*(S(1) + sqrt(S(3))*I)**(S(2)/3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-x**S(3) + S(1))/(x**S(2)*(x**S(6) - x**S(3) + S(1))), x), x, -S(2)**(S(1)/3)*(S(3) + sqrt(S(3))*I)*log(-S(2)**(S(1)/3)*x + (S(1) - sqrt(S(3))*I)**(S(1)/3))/(S(18)*(S(1) - sqrt(S(3))*I)**(S(1)/3)) - S(2)**(S(1)/3)*(S(3) - sqrt(S(3))*I)*log(-S(2)**(S(1)/3)*x + (S(1) + sqrt(S(3))*I)**(S(1)/3))/(S(18)*(S(1) + sqrt(S(3))*I)**(S(1)/3)) + S(2)**(S(1)/3)*(S(3) + sqrt(S(3))*I)*log(S(2)**(S(2)/3)*x**S(2) + x*(S(2) - S(2)*sqrt(S(3))*I)**(S(1)/3) + (S(1) - sqrt(S(3))*I)**(S(2)/3))/(S(36)*(S(1) - sqrt(S(3))*I)**(S(1)/3)) + S(2)**(S(1)/3)*(S(3) - sqrt(S(3))*I)*log(S(2)**(S(2)/3)*x**S(2) + x*(S(2) + S(2)*sqrt(S(3))*I)**(S(1)/3) + (S(1) + sqrt(S(3))*I)**(S(2)/3))/(S(36)*(S(1) + sqrt(S(3))*I)**(S(1)/3)) - S(2)**(S(1)/3)*(sqrt(S(3)) + I)*atan(sqrt(S(3))*(S(2)*x/(S(1)/2 - sqrt(S(3))*I/S(2))**(S(1)/3) + S(1))/S(3))/(S(6)*(S(1) - sqrt(S(3))*I)**(S(1)/3)) + S(2)**(S(1)/3)*(-sqrt(S(3)) + I)*atan(sqrt(S(3))*(S(2)*x/(S(1)/2 + sqrt(S(3))*I/S(2))**(S(1)/3) + S(1))/S(3))/(S(6)*(S(1) + sqrt(S(3))*I)**(S(1)/3)) - S(1)/x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-x**S(3) + S(1))/(x**S(3)*(x**S(6) - x**S(3) + S(1))), x), x, -S(2)**(S(2)/3)*(S(3) + sqrt(S(3))*I)*log(-S(2)**(S(1)/3)*x + (S(1) - sqrt(S(3))*I)**(S(1)/3))/(S(18)*(S(1) - sqrt(S(3))*I)**(S(2)/3)) - S(2)**(S(2)/3)*(S(3) - sqrt(S(3))*I)*log(-S(2)**(S(1)/3)*x + (S(1) + sqrt(S(3))*I)**(S(1)/3))/(S(18)*(S(1) + sqrt(S(3))*I)**(S(2)/3)) + S(2)**(S(2)/3)*(S(3) + sqrt(S(3))*I)*log(S(2)**(S(2)/3)*x**S(2) + x*(S(2) - S(2)*sqrt(S(3))*I)**(S(1)/3) + (S(1) - sqrt(S(3))*I)**(S(2)/3))/(S(36)*(S(1) - sqrt(S(3))*I)**(S(2)/3)) + S(2)**(S(2)/3)*(S(3) - sqrt(S(3))*I)*log(S(2)**(S(2)/3)*x**S(2) + x*(S(2) + S(2)*sqrt(S(3))*I)**(S(1)/3) + (S(1) + sqrt(S(3))*I)**(S(2)/3))/(S(36)*(S(1) + sqrt(S(3))*I)**(S(2)/3)) + S(2)**(S(2)/3)*(sqrt(S(3)) + I)*atan(sqrt(S(3))*(S(2)*x/(S(1)/2 - sqrt(S(3))*I/S(2))**(S(1)/3) + S(1))/S(3))/(S(6)*(S(1) - sqrt(S(3))*I)**(S(2)/3)) - S(2)**(S(2)/3)*(-sqrt(S(3)) + I)*atan(sqrt(S(3))*(S(2)*x/(S(1)/2 + sqrt(S(3))*I/S(2))**(S(1)/3) + S(1))/S(3))/(S(6)*(S(1) + sqrt(S(3))*I)**(S(2)/3)) - S(1)/(S(2)*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(x**S(3) + S(-2))/(x**S(6) - x**S(3) + S(1)), x), x, log(x**S(6) - x**S(3) + S(1))/S(6) + sqrt(S(3))*atan(sqrt(S(3))*(-S(2)*x**S(3) + S(1))/S(3))/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(3) + S(1))/(x*(x**S(6) - x**S(3) + S(1))), x), x, log(x) - log(x**S(6) - x**S(3) + S(1))/S(6) - sqrt(S(3))*atan(sqrt(S(3))*(-S(2)*x**S(3) + S(1))/S(3))/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(3) + S(1))/(x**S(7) - x**S(4) + x), x), x, log(x) - log(x**S(6) - x**S(3) + S(1))/S(6) - sqrt(S(3))*atan(sqrt(S(3))*(-S(2)*x**S(3) + S(1))/S(3))/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(3))**(S(5)/2)*(a + b*x**S(3) + c*x**S(6)), x), x, S(2)*c*x**S(4)*(d + e*x**S(3))**(S(7)/2)/(S(29)*e) + S(54)*S(3)**(S(3)/4)*d**S(3)*sqrt((d**(S(2)/3) - d**(S(1)/3)*e**(S(1)/3)*x + e**(S(2)/3)*x**S(2))/(d**(S(1)/3)*(S(1) + sqrt(S(3))) + e**(S(1)/3)*x)**S(2))*sqrt(sqrt(S(3)) + S(2))*(d**(S(1)/3) + e**(S(1)/3)*x)*(S(667)*a*e**S(2) - S(58)*b*d*e + S(16)*c*d**S(2))*elliptic_f(asin((d**(S(1)/3)*(-sqrt(S(3)) + S(1)) + e**(S(1)/3)*x)/(d**(S(1)/3)*(S(1) + sqrt(S(3))) + e**(S(1)/3)*x)), S(-7) - S(4)*sqrt(S(3)))/(S(124729)*e**(S(7)/3)*sqrt(d**(S(1)/3)*(d**(S(1)/3) + e**(S(1)/3)*x)/(d**(S(1)/3)*(S(1) + sqrt(S(3))) + e**(S(1)/3)*x)**S(2))*sqrt(d + e*x**S(3))) + S(54)*d**S(2)*x*sqrt(d + e*x**S(3))*(S(667)*a*e**S(2) - S(58)*b*d*e + S(16)*c*d**S(2))/(S(124729)*e**S(2)) + S(30)*d*x*(d + e*x**S(3))**(S(3)/2)*(S(667)*a*e**S(2) - S(58)*b*d*e + S(16)*c*d**S(2))/(S(124729)*e**S(2)) - x*(d + e*x**S(3))**(S(7)/2)*(-S(58)*b*e + S(16)*c*d)/(S(667)*e**S(2)) + x*(d + e*x**S(3))**(S(5)/2)*(S(1334)*a*e**S(2) - S(116)*b*d*e + S(32)*c*d**S(2))/(S(11339)*e**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(3))**(S(3)/2)*(a + b*x**S(3) + c*x**S(6)), x), x, S(2)*c*x**S(4)*(d + e*x**S(3))**(S(5)/2)/(S(23)*e) + S(18)*S(3)**(S(3)/4)*d**S(2)*sqrt((d**(S(2)/3) - d**(S(1)/3)*e**(S(1)/3)*x + e**(S(2)/3)*x**S(2))/(d**(S(1)/3)*(S(1) + sqrt(S(3))) + e**(S(1)/3)*x)**S(2))*sqrt(sqrt(S(3)) + S(2))*(d**(S(1)/3) + e**(S(1)/3)*x)*(S(391)*a*e**S(2) - S(46)*b*d*e + S(16)*c*d**S(2))*elliptic_f(asin((d**(S(1)/3)*(-sqrt(S(3)) + S(1)) + e**(S(1)/3)*x)/(d**(S(1)/3)*(S(1) + sqrt(S(3))) + e**(S(1)/3)*x)), S(-7) - S(4)*sqrt(S(3)))/(S(21505)*e**(S(7)/3)*sqrt(d**(S(1)/3)*(d**(S(1)/3) + e**(S(1)/3)*x)/(d**(S(1)/3)*(S(1) + sqrt(S(3))) + e**(S(1)/3)*x)**S(2))*sqrt(d + e*x**S(3))) + S(18)*d*x*sqrt(d + e*x**S(3))*(S(391)*a*e**S(2) - S(46)*b*d*e + S(16)*c*d**S(2))/(S(21505)*e**S(2)) - x*(d + e*x**S(3))**(S(5)/2)*(-S(46)*b*e + S(16)*c*d)/(S(391)*e**S(2)) + x*(d + e*x**S(3))**(S(3)/2)*(S(782)*a*e**S(2) - S(92)*b*d*e + S(32)*c*d**S(2))/(S(4301)*e**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(d + e*x**S(3))*(a + b*x**S(3) + c*x**S(6)), x), x, S(2)*c*x**S(4)*(d + e*x**S(3))**(S(3)/2)/(S(17)*e) + S(2)*S(3)**(S(3)/4)*d*sqrt((d**(S(2)/3) - d**(S(1)/3)*e**(S(1)/3)*x + e**(S(2)/3)*x**S(2))/(d**(S(1)/3)*(S(1) + sqrt(S(3))) + e**(S(1)/3)*x)**S(2))*sqrt(sqrt(S(3)) + S(2))*(d**(S(1)/3) + e**(S(1)/3)*x)*(S(187)*a*e**S(2) - S(34)*b*d*e + S(16)*c*d**S(2))*elliptic_f(asin((d**(S(1)/3)*(-sqrt(S(3)) + S(1)) + e**(S(1)/3)*x)/(d**(S(1)/3)*(S(1) + sqrt(S(3))) + e**(S(1)/3)*x)), S(-7) - S(4)*sqrt(S(3)))/(S(935)*e**(S(7)/3)*sqrt(d**(S(1)/3)*(d**(S(1)/3) + e**(S(1)/3)*x)/(d**(S(1)/3)*(S(1) + sqrt(S(3))) + e**(S(1)/3)*x)**S(2))*sqrt(d + e*x**S(3))) - x*(d + e*x**S(3))**(S(3)/2)*(-S(34)*b*e + S(16)*c*d)/(S(187)*e**S(2)) + x*sqrt(d + e*x**S(3))*(S(374)*a*e**S(2) - S(68)*b*d*e + S(32)*c*d**S(2))/(S(935)*e**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(3) + c*x**S(6))/sqrt(d + e*x**S(3)), x), x, S(2)*c*x**S(4)*sqrt(d + e*x**S(3))/(S(11)*e) - x*sqrt(d + e*x**S(3))*(-S(22)*b*e + S(16)*c*d)/(S(55)*e**S(2)) + S(2)*S(3)**(S(3)/4)*sqrt((d**(S(2)/3) - d**(S(1)/3)*e**(S(1)/3)*x + e**(S(2)/3)*x**S(2))/(d**(S(1)/3)*(S(1) + sqrt(S(3))) + e**(S(1)/3)*x)**S(2))*sqrt(sqrt(S(3)) + S(2))*(d**(S(1)/3) + e**(S(1)/3)*x)*(S(55)*a*e**S(2) - S(22)*b*d*e + S(16)*c*d**S(2))*elliptic_f(asin((d**(S(1)/3)*(-sqrt(S(3)) + S(1)) + e**(S(1)/3)*x)/(d**(S(1)/3)*(S(1) + sqrt(S(3))) + e**(S(1)/3)*x)), S(-7) - S(4)*sqrt(S(3)))/(S(165)*e**(S(7)/3)*sqrt(d**(S(1)/3)*(d**(S(1)/3) + e**(S(1)/3)*x)/(d**(S(1)/3)*(S(1) + sqrt(S(3))) + e**(S(1)/3)*x)**S(2))*sqrt(d + e*x**S(3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(3) + c*x**S(6))/(d + e*x**S(3))**(S(3)/2), x), x, S(2)*c*x*sqrt(d + e*x**S(3))/(S(5)*e**S(2)) + x*(S(2)*a*e**S(2) - S(2)*b*d*e + S(2)*c*d**S(2))/(S(3)*d*e**S(2)*sqrt(d + e*x**S(3))) - S(2)*S(3)**(S(3)/4)*sqrt((d**(S(2)/3) - d**(S(1)/3)*e**(S(1)/3)*x + e**(S(2)/3)*x**S(2))/(d**(S(1)/3)*(S(1) + sqrt(S(3))) + e**(S(1)/3)*x)**S(2))*sqrt(sqrt(S(3)) + S(2))*(d**(S(1)/3) + e**(S(1)/3)*x)*(S(16)*c*d**S(2) - S(5)*e*(a*e + S(2)*b*d))*elliptic_f(asin((d**(S(1)/3)*(-sqrt(S(3)) + S(1)) + e**(S(1)/3)*x)/(d**(S(1)/3)*(S(1) + sqrt(S(3))) + e**(S(1)/3)*x)), S(-7) - S(4)*sqrt(S(3)))/(S(45)*d*e**(S(7)/3)*sqrt(d**(S(1)/3)*(d**(S(1)/3) + e**(S(1)/3)*x)/(d**(S(1)/3)*(S(1) + sqrt(S(3))) + e**(S(1)/3)*x)**S(2))*sqrt(d + e*x**S(3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(3) + c*x**S(6))/(d + e*x**S(3))**(S(5)/2), x), x, x*(S(2)*a*e**S(2) - S(2)*b*d*e + S(2)*c*d**S(2))/(S(9)*d*e**S(2)*(d + e*x**S(3))**(S(3)/2)) - x*(-S(14)*a*e**S(2) - S(4)*b*d*e + S(22)*c*d**S(2))/(S(27)*d**S(2)*e**S(2)*sqrt(d + e*x**S(3))) + S(2)*S(3)**(S(3)/4)*sqrt((d**(S(2)/3) - d**(S(1)/3)*e**(S(1)/3)*x + e**(S(2)/3)*x**S(2))/(d**(S(1)/3)*(S(1) + sqrt(S(3))) + e**(S(1)/3)*x)**S(2))*sqrt(sqrt(S(3)) + S(2))*(d**(S(1)/3) + e**(S(1)/3)*x)*(S(16)*c*d**S(2) + e*(S(7)*a*e + S(2)*b*d))*elliptic_f(asin((d**(S(1)/3)*(-sqrt(S(3)) + S(1)) + e**(S(1)/3)*x)/(d**(S(1)/3)*(S(1) + sqrt(S(3))) + e**(S(1)/3)*x)), S(-7) - S(4)*sqrt(S(3)))/(S(81)*d**S(2)*e**(S(7)/3)*sqrt(d**(S(1)/3)*(d**(S(1)/3) + e**(S(1)/3)*x)/(d**(S(1)/3)*(S(1) + sqrt(S(3))) + e**(S(1)/3)*x)**S(2))*sqrt(d + e*x**S(3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(3) + c*x**S(6))/(d + e*x**S(3))**(S(7)/2), x), x, x*(S(2)*a*e**S(2) - S(2)*b*d*e + S(2)*c*d**S(2))/(S(15)*d*e**S(2)*(d + e*x**S(3))**(S(5)/2)) - x*(-S(26)*a*e**S(2) - S(4)*b*d*e + S(34)*c*d**S(2))/(S(135)*d**S(2)*e**S(2)*(d + e*x**S(3))**(S(3)/2)) + x*(S(182)*a*e**S(2) + S(28)*b*d*e + S(32)*c*d**S(2))/(S(405)*d**S(3)*e**S(2)*sqrt(d + e*x**S(3))) + S(2)*S(3)**(S(3)/4)*sqrt((d**(S(2)/3) - d**(S(1)/3)*e**(S(1)/3)*x + e**(S(2)/3)*x**S(2))/(d**(S(1)/3)*(S(1) + sqrt(S(3))) + e**(S(1)/3)*x)**S(2))*sqrt(sqrt(S(3)) + S(2))*(d**(S(1)/3) + e**(S(1)/3)*x)*(S(91)*a*e**S(2) + S(14)*b*d*e + S(16)*c*d**S(2))*elliptic_f(asin((d**(S(1)/3)*(-sqrt(S(3)) + S(1)) + e**(S(1)/3)*x)/(d**(S(1)/3)*(S(1) + sqrt(S(3))) + e**(S(1)/3)*x)), S(-7) - S(4)*sqrt(S(3)))/(S(1215)*d**S(3)*e**(S(7)/3)*sqrt(d**(S(1)/3)*(d**(S(1)/3) + e**(S(1)/3)*x)/(d**(S(1)/3)*(S(1) + sqrt(S(3))) + e**(S(1)/3)*x)**S(2))*sqrt(d + e*x**S(3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(3) + c*x**S(6))/(d + e*x**S(3))**(S(9)/2), x), x, x*(S(2)*a*e**S(2) - S(2)*b*d*e + S(2)*c*d**S(2))/(S(21)*d*e**S(2)*(d + e*x**S(3))**(S(7)/2)) - x*(-S(38)*a*e**S(2) - S(4)*b*d*e + S(46)*c*d**S(2))/(S(315)*d**S(2)*e**S(2)*(d + e*x**S(3))**(S(5)/2)) + x*(S(494)*a*e**S(2) + S(52)*b*d*e + S(32)*c*d**S(2))/(S(2835)*d**S(3)*e**S(2)*(d + e*x**S(3))**(S(3)/2)) + x*(S(494)*a*e**S(2) + S(52)*b*d*e + S(32)*c*d**S(2))/(S(1215)*d**S(4)*e**S(2)*sqrt(d + e*x**S(3))) + S(2)*S(3)**(S(3)/4)*sqrt((d**(S(2)/3) - d**(S(1)/3)*e**(S(1)/3)*x + e**(S(2)/3)*x**S(2))/(d**(S(1)/3)*(S(1) + sqrt(S(3))) + e**(S(1)/3)*x)**S(2))*sqrt(sqrt(S(3)) + S(2))*(d**(S(1)/3) + e**(S(1)/3)*x)*(S(247)*a*e**S(2) + S(26)*b*d*e + S(16)*c*d**S(2))*elliptic_f(asin((d**(S(1)/3)*(-sqrt(S(3)) + S(1)) + e**(S(1)/3)*x)/(d**(S(1)/3)*(S(1) + sqrt(S(3))) + e**(S(1)/3)*x)), S(-7) - S(4)*sqrt(S(3)))/(S(3645)*d**S(4)*e**(S(7)/3)*sqrt(d**(S(1)/3)*(d**(S(1)/3) + e**(S(1)/3)*x)/(d**(S(1)/3)*(S(1) + sqrt(S(3))) + e**(S(1)/3)*x)**S(2))*sqrt(d + e*x**S(3))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(4))/(a + c*x**S(8)), x), x, sqrt(S(2))*(sqrt(c)*d - e*sqrt(-a))*log(-sqrt(S(2))*c**(S(1)/8)*x*(-a)**(S(1)/8) + c**(S(1)/4)*x**S(2) + (-a)**(S(1)/4))/(S(16)*c**(S(5)/8)*(-a)**(S(7)/8)) - sqrt(S(2))*(sqrt(c)*d - e*sqrt(-a))*log(sqrt(S(2))*c**(S(1)/8)*x*(-a)**(S(1)/8) + c**(S(1)/4)*x**S(2) + (-a)**(S(1)/4))/(S(16)*c**(S(5)/8)*(-a)**(S(7)/8)) - sqrt(S(2))*(sqrt(c)*d - e*sqrt(-a))*atan(sqrt(S(2))*c**(S(1)/8)*x/(-a)**(S(1)/8) + S(-1))/(S(8)*c**(S(5)/8)*(-a)**(S(7)/8)) - sqrt(S(2))*(sqrt(c)*d - e*sqrt(-a))*atan(sqrt(S(2))*c**(S(1)/8)*x/(-a)**(S(1)/8) + S(1))/(S(8)*c**(S(5)/8)*(-a)**(S(7)/8)) - (sqrt(c)*d + e*sqrt(-a))*atan(c**(S(1)/8)*x/(-a)**(S(1)/8))/(S(4)*c**(S(5)/8)*(-a)**(S(7)/8)) - (sqrt(c)*d + e*sqrt(-a))*atanh(c**(S(1)/8)*x/(-a)**(S(1)/8))/(S(4)*c**(S(5)/8)*(-a)**(S(7)/8)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(4))/(a - c*x**S(8)), x), x, -sqrt(S(2))*(-sqrt(a)*e + sqrt(c)*d)*log(-sqrt(S(2))*a**(S(1)/8)*c**(S(1)/8)*x + a**(S(1)/4) + c**(S(1)/4)*x**S(2))/(S(16)*a**(S(7)/8)*c**(S(5)/8)) + sqrt(S(2))*(-sqrt(a)*e + sqrt(c)*d)*log(sqrt(S(2))*a**(S(1)/8)*c**(S(1)/8)*x + a**(S(1)/4) + c**(S(1)/4)*x**S(2))/(S(16)*a**(S(7)/8)*c**(S(5)/8)) - sqrt(S(2))*(-sqrt(a)*e + sqrt(c)*d)*atan(S(1) - sqrt(S(2))*c**(S(1)/8)*x/a**(S(1)/8))/(S(8)*a**(S(7)/8)*c**(S(5)/8)) + sqrt(S(2))*(-sqrt(a)*e + sqrt(c)*d)*atan(S(1) + sqrt(S(2))*c**(S(1)/8)*x/a**(S(1)/8))/(S(8)*a**(S(7)/8)*c**(S(5)/8)) + (sqrt(a)*e + sqrt(c)*d)*atan(c**(S(1)/8)*x/a**(S(1)/8))/(S(4)*a**(S(7)/8)*c**(S(5)/8)) + (sqrt(a)*e + sqrt(c)*d)*atanh(c**(S(1)/8)*x/a**(S(1)/8))/(S(4)*a**(S(7)/8)*c**(S(5)/8)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)*(d + e*x**S(4))/(a + b*x**S(4) + c*x**S(8)), x), x, e*x/c - S(2)**(S(3)/4)*(-b*e + c*d - (S(2)*a*c*e - b**S(2)*e + b*c*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(S(2)**(S(1)/4)*c**(S(1)/4)*x/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(4)*c**(S(5)/4)*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)) - S(2)**(S(3)/4)*(-b*e + c*d - (S(2)*a*c*e - b**S(2)*e + b*c*d)/sqrt(-S(4)*a*c + b**S(2)))*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*x/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(4)*c**(S(5)/4)*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)) - S(2)**(S(3)/4)*(-b*e + c*d + (S(2)*a*c*e - b**S(2)*e + b*c*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(S(2)**(S(1)/4)*c**(S(1)/4)*x/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(4)*c**(S(5)/4)*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)) - S(2)**(S(3)/4)*(-b*e + c*d + (S(2)*a*c*e - b**S(2)*e + b*c*d)/sqrt(-S(4)*a*c + b**S(2)))*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*x/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(4)*c**(S(5)/4)*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*(d + e*x**S(4))/(a + b*x**S(4) + c*x**S(8)), x), x, e*log(a + b*x**S(4) + c*x**S(8))/(S(8)*c) - (-b*e + S(2)*c*d)*atanh((b + S(2)*c*x**S(4))/sqrt(-S(4)*a*c + b**S(2)))/(S(4)*c*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(d + e*x**S(4))/(a + b*x**S(4) + c*x**S(8)), x), x, S(2)**(S(1)/4)*(e + (-b*e + S(2)*c*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(S(2)**(S(1)/4)*c**(S(1)/4)*x/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(4)*c**(S(3)/4)*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)) - S(2)**(S(1)/4)*(e + (-b*e + S(2)*c*d)/sqrt(-S(4)*a*c + b**S(2)))*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*x/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(4)*c**(S(3)/4)*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)) + S(2)**(S(1)/4)*(e - (-b*e + S(2)*c*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(S(2)**(S(1)/4)*c**(S(1)/4)*x/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(4)*c**(S(3)/4)*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)) - S(2)**(S(1)/4)*(e - (-b*e + S(2)*c*d)/sqrt(-S(4)*a*c + b**S(2)))*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*x/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(4)*c**(S(3)/4)*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(d + e*x**S(4))/(a + b*x**S(4) + c*x**S(8)), x), x, sqrt(S(2))*(e - (-b*e + S(2)*c*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x**S(2)/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(4)*sqrt(c)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))) + sqrt(S(2))*(e + (-b*e + S(2)*c*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x**S(2)/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(4)*sqrt(c)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(4))/(a + b*x**S(4) + c*x**S(8)), x), x, -S(2)**(S(3)/4)*(e + (-b*e + S(2)*c*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(S(2)**(S(1)/4)*c**(S(1)/4)*x/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(4)*c**(S(1)/4)*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)) - S(2)**(S(3)/4)*(e + (-b*e + S(2)*c*d)/sqrt(-S(4)*a*c + b**S(2)))*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*x/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(4)*c**(S(1)/4)*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)) - S(2)**(S(3)/4)*(e - (-b*e + S(2)*c*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(S(2)**(S(1)/4)*c**(S(1)/4)*x/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(4)*c**(S(1)/4)*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)) - S(2)**(S(3)/4)*(e - (-b*e + S(2)*c*d)/sqrt(-S(4)*a*c + b**S(2)))*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*x/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(4)*c**(S(1)/4)*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(4))/(x*(a + b*x**S(4) + c*x**S(8))), x), x, d*log(x)/a - d*log(a + b*x**S(4) + c*x**S(8))/(S(8)*a) + (-S(2)*a*e + b*d)*atanh((b + S(2)*c*x**S(4))/sqrt(-S(4)*a*c + b**S(2)))/(S(4)*a*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(4))/(x**S(2)*(a + b*x**S(4) + c*x**S(8))), x), x, -S(2)**(S(1)/4)*c**(S(1)/4)*(d + (-S(2)*a*e + b*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(S(2)**(S(1)/4)*c**(S(1)/4)*x/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(4)*a*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)) + S(2)**(S(1)/4)*c**(S(1)/4)*(d + (-S(2)*a*e + b*d)/sqrt(-S(4)*a*c + b**S(2)))*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*x/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(4)*a*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)) - S(2)**(S(1)/4)*c**(S(1)/4)*(d - (-S(2)*a*e + b*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(S(2)**(S(1)/4)*c**(S(1)/4)*x/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(4)*a*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)) + S(2)**(S(1)/4)*c**(S(1)/4)*(d - (-S(2)*a*e + b*d)/sqrt(-S(4)*a*c + b**S(2)))*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*x/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(4)*a*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4)) - d/(a*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(4))/(x**S(3)*(a + b*x**S(4) + c*x**S(8))), x), x, -sqrt(S(2))*sqrt(c)*(d - (-S(2)*a*e + b*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x**S(2)/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(4)*a*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))) - sqrt(S(2))*sqrt(c)*(d + (-S(2)*a*e + b*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x**S(2)/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(4)*a*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))) - d/(S(2)*a*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**S(4))/(x**S(4)*(a + b*x**S(4) + c*x**S(8))), x), x, S(2)**(S(3)/4)*c**(S(3)/4)*(d + (-S(2)*a*e + b*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(S(2)**(S(1)/4)*c**(S(1)/4)*x/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(4)*a*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)) + S(2)**(S(3)/4)*c**(S(3)/4)*(d + (-S(2)*a*e + b*d)/sqrt(-S(4)*a*c + b**S(2)))*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*x/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(4)*a*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)) + S(2)**(S(3)/4)*c**(S(3)/4)*(d - (-S(2)*a*e + b*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(S(2)**(S(1)/4)*c**(S(1)/4)*x/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(4)*a*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)) + S(2)**(S(3)/4)*c**(S(3)/4)*(d - (-S(2)*a*e + b*d)/sqrt(-S(4)*a*c + b**S(2)))*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*x/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(4)*a*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)) - d/(S(3)*a*x**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)*(-x**S(4) + S(1))/(x**S(8) - x**S(4) + S(1)), x), x, -x - sqrt(S(6))*log(x**S(2) - x*sqrt(-sqrt(S(3)) + S(2)) + S(1))/S(24) + sqrt(S(6))*log(x**S(2) + x*sqrt(-sqrt(S(3)) + S(2)) + S(1))/S(24) - sqrt(S(6))*log(x**S(2) - x*sqrt(sqrt(S(3)) + S(2)) + S(1))/S(24) + sqrt(S(6))*log(x**S(2) + x*sqrt(sqrt(S(3)) + S(2)) + S(1))/S(24) - sqrt(S(6))*atan((-S(2)*x + sqrt(sqrt(S(3)) + S(2)))/sqrt(-sqrt(S(3)) + S(2)))/S(12) + sqrt(S(6))*atan((S(2)*x + sqrt(sqrt(S(3)) + S(2)))/sqrt(-sqrt(S(3)) + S(2)))/S(12) - sqrt(S(6))*atan((-S(2)*x + sqrt(-sqrt(S(3)) + S(2)))/sqrt(sqrt(S(3)) + S(2)))/S(12) + sqrt(S(6))*atan((S(2)*x + sqrt(-sqrt(S(3)) + S(2)))/sqrt(sqrt(S(3)) + S(2)))/S(12), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*(-x**S(4) + S(1))/(x**S(8) - x**S(4) + S(1)), x), x, -log(x**S(8) - x**S(4) + S(1))/S(8) - sqrt(S(3))*atan(sqrt(S(3))*(-S(2)*x**S(4) + S(1))/S(3))/S(12), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(-x**S(4) + S(1))/(x**S(8) - x**S(4) + S(1)), x), x, sqrt(-sqrt(S(3))/S(3) + S(2)/3)*log(x**S(2) - x*sqrt(-sqrt(S(3)) + S(2)) + S(1))/S(8) - sqrt(-sqrt(S(3))/S(3) + S(2)/3)*log(x**S(2) + x*sqrt(-sqrt(S(3)) + S(2)) + S(1))/S(8) - sqrt(sqrt(S(3))/S(3) + S(2)/3)*log(x**S(2) - x*sqrt(sqrt(S(3)) + S(2)) + S(1))/S(8) + sqrt(sqrt(S(3))/S(3) + S(2)/3)*log(x**S(2) + x*sqrt(sqrt(S(3)) + S(2)) + S(1))/S(8) - atan((-S(2)*x + sqrt(sqrt(S(3)) + S(2)))/sqrt(-sqrt(S(3)) + S(2)))/(S(4)*sqrt(S(3)*sqrt(S(3)) + S(6))) + atan((S(2)*x + sqrt(sqrt(S(3)) + S(2)))/sqrt(-sqrt(S(3)) + S(2)))/(S(4)*sqrt(S(3)*sqrt(S(3)) + S(6))) + atan((-S(2)*x + sqrt(-sqrt(S(3)) + S(2)))/sqrt(sqrt(S(3)) + S(2)))/(S(4)*sqrt(-S(3)*sqrt(S(3)) + S(6))) - atan((S(2)*x + sqrt(-sqrt(S(3)) + S(2)))/sqrt(sqrt(S(3)) + S(2)))/(S(4)*sqrt(-S(3)*sqrt(S(3)) + S(6))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(-x**S(4) + S(1))/(x**S(8) - x**S(4) + S(1)), x), x, -sqrt(S(3))*log(x**S(4) - sqrt(S(3))*x**S(2) + S(1))/S(12) + sqrt(S(3))*log(x**S(4) + sqrt(S(3))*x**S(2) + S(1))/S(12), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-x**S(4) + S(1))/(x**S(8) - x**S(4) + S(1)), x), x, sqrt(-sqrt(S(3))/S(3) + S(2)/3)*log(x**S(2) - x*sqrt(-sqrt(S(3)) + S(2)) + S(1))/S(8) - sqrt(-sqrt(S(3))/S(3) + S(2)/3)*log(x**S(2) + x*sqrt(-sqrt(S(3)) + S(2)) + S(1))/S(8) - sqrt(sqrt(S(3))/S(3) + S(2)/3)*log(x**S(2) - x*sqrt(sqrt(S(3)) + S(2)) + S(1))/S(8) + sqrt(sqrt(S(3))/S(3) + S(2)/3)*log(x**S(2) + x*sqrt(sqrt(S(3)) + S(2)) + S(1))/S(8) + atan((-S(2)*x + sqrt(sqrt(S(3)) + S(2)))/sqrt(-sqrt(S(3)) + S(2)))/(S(4)*sqrt(S(3)*sqrt(S(3)) + S(6))) - atan((S(2)*x + sqrt(sqrt(S(3)) + S(2)))/sqrt(-sqrt(S(3)) + S(2)))/(S(4)*sqrt(S(3)*sqrt(S(3)) + S(6))) - atan((-S(2)*x + sqrt(-sqrt(S(3)) + S(2)))/sqrt(sqrt(S(3)) + S(2)))/(S(4)*sqrt(-S(3)*sqrt(S(3)) + S(6))) + atan((S(2)*x + sqrt(-sqrt(S(3)) + S(2)))/sqrt(sqrt(S(3)) + S(2)))/(S(4)*sqrt(-S(3)*sqrt(S(3)) + S(6))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-x**S(4) + S(1))/(x*(x**S(8) - x**S(4) + S(1))), x), x, log(x) - log(x**S(8) - x**S(4) + S(1))/S(8) + sqrt(S(3))*atan(sqrt(S(3))*(-S(2)*x**S(4) + S(1))/S(3))/S(12), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-x**S(4) + S(1))/(x**S(2)*(x**S(8) - x**S(4) + S(1))), x), x, -sqrt(S(6))*log(x**S(2) - x*sqrt(-sqrt(S(3)) + S(2)) + S(1))/S(24) + sqrt(S(6))*log(x**S(2) + x*sqrt(-sqrt(S(3)) + S(2)) + S(1))/S(24) - sqrt(S(6))*log(x**S(2) - x*sqrt(sqrt(S(3)) + S(2)) + S(1))/S(24) + sqrt(S(6))*log(x**S(2) + x*sqrt(sqrt(S(3)) + S(2)) + S(1))/S(24) + sqrt(S(6))*atan((-S(2)*x + sqrt(sqrt(S(3)) + S(2)))/sqrt(-sqrt(S(3)) + S(2)))/S(12) - sqrt(S(6))*atan((S(2)*x + sqrt(sqrt(S(3)) + S(2)))/sqrt(-sqrt(S(3)) + S(2)))/S(12) + sqrt(S(6))*atan((-S(2)*x + sqrt(-sqrt(S(3)) + S(2)))/sqrt(sqrt(S(3)) + S(2)))/S(12) - sqrt(S(6))*atan((S(2)*x + sqrt(-sqrt(S(3)) + S(2)))/sqrt(sqrt(S(3)) + S(2)))/S(12) - S(1)/x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-x**S(4) + S(1))/(x**S(3)*(x**S(8) - x**S(4) + S(1))), x), x, -sqrt(S(3))*log(x**S(4) - sqrt(S(3))*x**S(2) + S(1))/S(24) + sqrt(S(3))*log(x**S(4) + sqrt(S(3))*x**S(2) + S(1))/S(24) - atan(S(2)*x**S(2) - sqrt(S(3)))/S(4) - atan(S(2)*x**S(2) + sqrt(S(3)))/S(4) - S(1)/(S(2)*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-x**S(4) + S(1))/(x**S(4)*(x**S(8) - x**S(4) + S(1))), x), x, sqrt(sqrt(S(3))/S(3) + S(2)/3)*log(x**S(2) - x*sqrt(-sqrt(S(3)) + S(2)) + S(1))/S(8) - sqrt(sqrt(S(3))/S(3) + S(2)/3)*log(x**S(2) + x*sqrt(-sqrt(S(3)) + S(2)) + S(1))/S(8) - sqrt(-sqrt(S(3))/S(3) + S(2)/3)*log(x**S(2) - x*sqrt(sqrt(S(3)) + S(2)) + S(1))/S(8) + sqrt(-sqrt(S(3))/S(3) + S(2)/3)*log(x**S(2) + x*sqrt(sqrt(S(3)) + S(2)) + S(1))/S(8) + sqrt(sqrt(S(3))/S(3) + S(2)/3)*atan((-S(2)*x + sqrt(sqrt(S(3)) + S(2)))/sqrt(-sqrt(S(3)) + S(2)))/S(4) - sqrt(sqrt(S(3))/S(3) + S(2)/3)*atan((S(2)*x + sqrt(sqrt(S(3)) + S(2)))/sqrt(-sqrt(S(3)) + S(2)))/S(4) - sqrt(-sqrt(S(3))/S(3) + S(2)/3)*atan((-S(2)*x + sqrt(-sqrt(S(3)) + S(2)))/sqrt(sqrt(S(3)) + S(2)))/S(4) + sqrt(-sqrt(S(3))/S(3) + S(2)/3)*atan((S(2)*x + sqrt(-sqrt(S(3)) + S(2)))/sqrt(sqrt(S(3)) + S(2)))/S(4) - S(1)/(S(3)*x**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(4) + S(1))/(x**S(8) + x**S(4) + S(1)), x), x, -log(x**S(2) - x + S(1))/S(8) + log(x**S(2) + x + S(1))/S(8) - sqrt(S(3))*log(x**S(2) - sqrt(S(3))*x + S(1))/S(24) + sqrt(S(3))*log(x**S(2) + sqrt(S(3))*x + S(1))/S(24) - sqrt(S(3))*atan(sqrt(S(3))*(-S(2)*x + S(1))/S(3))/S(12) + sqrt(S(3))*atan(sqrt(S(3))*(S(2)*x + S(1))/S(3))/S(12) + atan(S(2)*x - sqrt(S(3)))/S(4) + atan(S(2)*x + sqrt(S(3)))/S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-x**S(4) + S(1))/(x**S(8) + x**S(4) + S(1)), x), x, log(x**S(2) - x + S(1))/S(8) - log(x**S(2) + x + S(1))/S(8) - sqrt(S(3))*log(x**S(2) - sqrt(S(3))*x + S(1))/S(8) + sqrt(S(3))*log(x**S(2) + sqrt(S(3))*x + S(1))/S(8) - sqrt(S(3))*atan(sqrt(S(3))*(-S(2)*x + S(1))/S(3))/S(4) + sqrt(S(3))*atan(sqrt(S(3))*(S(2)*x + S(1))/S(3))/S(4) - atan(S(2)*x - sqrt(S(3)))/S(4) - atan(S(2)*x + sqrt(S(3)))/S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(4) + S(1))/(x**S(8) - x**S(4) + S(1)), x), x, -log(x**S(2) - x*sqrt(-sqrt(S(3)) + S(2)) + S(1))/(S(8)*sqrt(-sqrt(S(3)) + S(2))) + log(x**S(2) + x*sqrt(-sqrt(S(3)) + S(2)) + S(1))/(S(8)*sqrt(-sqrt(S(3)) + S(2))) - log(x**S(2) - x*sqrt(sqrt(S(3)) + S(2)) + S(1))/(S(8)*sqrt(sqrt(S(3)) + S(2))) + log(x**S(2) + x*sqrt(sqrt(S(3)) + S(2)) + S(1))/(S(8)*sqrt(sqrt(S(3)) + S(2))) - sqrt(sqrt(S(3)) + S(2))*atan((-S(2)*x + sqrt(sqrt(S(3)) + S(2)))/sqrt(-sqrt(S(3)) + S(2)))/S(4) + sqrt(sqrt(S(3)) + S(2))*atan((S(2)*x + sqrt(sqrt(S(3)) + S(2)))/sqrt(-sqrt(S(3)) + S(2)))/S(4) - sqrt(-sqrt(S(3)) + S(2))*atan((-S(2)*x + sqrt(-sqrt(S(3)) + S(2)))/sqrt(sqrt(S(3)) + S(2)))/S(4) + sqrt(-sqrt(S(3)) + S(2))*atan((S(2)*x + sqrt(-sqrt(S(3)) + S(2)))/sqrt(sqrt(S(3)) + S(2)))/S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-x**S(4) + S(1))/(x**S(8) - S(3)*x**S(4) + S(1)), x), x, sqrt(S(5))*(sqrt(S(5))/S(2) + S(3)/2)**(S(1)/4)*atan(x*(sqrt(S(5))/S(2) + S(3)/2)**(S(1)/4))/S(10) + sqrt(S(5))*(-sqrt(S(5))/S(2) + S(3)/2)**(S(1)/4)*atan(S(2)**(S(1)/4)*x/(sqrt(S(5)) + S(3))**(S(1)/4))/S(10) + sqrt(S(5))*(sqrt(S(5))/S(2) + S(3)/2)**(S(1)/4)*atanh(x*(sqrt(S(5))/S(2) + S(3)/2)**(S(1)/4))/S(10) + sqrt(S(5))*(-sqrt(S(5))/S(2) + S(3)/2)**(S(1)/4)*atanh(S(2)**(S(1)/4)*x/(sqrt(S(5)) + S(3))**(S(1)/4))/S(10), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((S(2)*x**S(4) + S(-1) + sqrt(S(3)))/(x**S(8) - x**S(4) + S(1)), x), x, -sqrt(S(2))*log(x**S(2) - x*sqrt(-sqrt(S(3)) + S(2)) + S(1))/S(4) + sqrt(S(2))*log(x**S(2) + x*sqrt(-sqrt(S(3)) + S(2)) + S(1))/S(4) - sqrt(S(2))*atan((-S(2)*x + sqrt(sqrt(S(3)) + S(2)))/sqrt(-sqrt(S(3)) + S(2)))/S(2) + sqrt(S(2))*atan((S(2)*x + sqrt(sqrt(S(3)) + S(2)))/sqrt(-sqrt(S(3)) + S(2)))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(4)*(S(1) + sqrt(S(3))) + S(1))/(x**S(8) - x**S(4) + S(1)), x), x, -sqrt(sqrt(S(3)) + S(2))*log(x**S(2) - x*sqrt(-sqrt(S(3)) + S(2)) + S(1))/S(4) + sqrt(sqrt(S(3)) + S(2))*log(x**S(2) + x*sqrt(-sqrt(S(3)) + S(2)) + S(1))/S(4) - sqrt(sqrt(S(3)) + S(2))*atan((-S(2)*x + sqrt(sqrt(S(3)) + S(2)))/sqrt(-sqrt(S(3)) + S(2)))/S(2) + sqrt(sqrt(S(3)) + S(2))*atan((S(2)*x + sqrt(sqrt(S(3)) + S(2)))/sqrt(-sqrt(S(3)) + S(2)))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(4)*(S(-3) + sqrt(S(3))) - S(2)*sqrt(S(3)) + S(3))/(x**S(8) - x**S(4) + S(1)), x), x, sqrt(-S(3)*sqrt(S(3)) + S(6))*log(x**S(2) - x*sqrt(-sqrt(S(3)) + S(2)) + S(1))/S(4) - sqrt(-S(3)*sqrt(S(3)) + S(6))*log(x**S(2) + x*sqrt(-sqrt(S(3)) + S(2)) + S(1))/S(4) + sqrt(-S(3)*sqrt(S(3)) + S(6))*atan((-S(2)*x + sqrt(sqrt(S(3)) + S(2)))/sqrt(-sqrt(S(3)) + S(2)))/S(2) - sqrt(-S(3)*sqrt(S(3)) + S(6))*atan((S(2)*x + sqrt(sqrt(S(3)) + S(2)))/sqrt(-sqrt(S(3)) + S(2)))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e/x)/(a/x**S(2) + c), x), x, -sqrt(a)*d*atan(sqrt(c)*x/sqrt(a))/c**(S(3)/2) + d*x/c + e*log(a + c*x**S(2))/(S(2)*c), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e/x)/(a/x**S(2) + b/x + c), x), x, d*x/c - (b*d - c*e)*log(a + b*x + c*x**S(2))/(S(2)*c**S(2)) - (-S(2)*a*c*d + b**S(2)*d - b*c*e)*atanh((b + S(2)*c*x)/sqrt(-S(4)*a*c + b**S(2)))/(c**S(2)*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e/x**S(2))/(a/x**S(4) + c), x), x, d*x/c + sqrt(S(2))*(sqrt(a)*d - sqrt(c)*e)*atan(S(1) - sqrt(S(2))*c**(S(1)/4)*x/a**(S(1)/4))/(S(4)*a**(S(1)/4)*c**(S(5)/4)) - sqrt(S(2))*(sqrt(a)*d - sqrt(c)*e)*atan(S(1) + sqrt(S(2))*c**(S(1)/4)*x/a**(S(1)/4))/(S(4)*a**(S(1)/4)*c**(S(5)/4)) + sqrt(S(2))*(sqrt(a)*d + sqrt(c)*e)*log(-sqrt(S(2))*a**(S(1)/4)*c**(S(1)/4)*x + sqrt(a) + sqrt(c)*x**S(2))/(S(8)*a**(S(1)/4)*c**(S(5)/4)) - sqrt(S(2))*(sqrt(a)*d + sqrt(c)*e)*log(sqrt(S(2))*a**(S(1)/4)*c**(S(1)/4)*x + sqrt(a) + sqrt(c)*x**S(2))/(S(8)*a**(S(1)/4)*c**(S(5)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e/x**S(2))/(a/x**S(4) + b/x**S(2) + c), x), x, d*x/c - sqrt(S(2))*(b*d - c*e + (-S(2)*a*c*d + b**S(2)*d - b*c*e)/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*c**(S(3)/2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))) - sqrt(S(2))*(b*d - c*e - (-S(2)*a*c*d + b**S(2)*d - b*c*e)/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*c**(S(3)/2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e/x**S(3))/(a/x**S(6) + c), x), x, d*x/c - (-sqrt(c)*e + d*sqrt(-a))*log(c**(S(1)/6)*x + (-a)**(S(1)/6))/(S(6)*c**(S(7)/6)*(-a)**(S(1)/3)) + (-sqrt(c)*e + d*sqrt(-a))*log(-c**(S(1)/6)*x*(-a)**(S(1)/6) + c**(S(1)/3)*x**S(2) + (-a)**(S(1)/3))/(S(12)*c**(S(7)/6)*(-a)**(S(1)/3)) + sqrt(S(3))*(-sqrt(c)*e + d*sqrt(-a))*atan(sqrt(S(3))*(-S(2)*c**(S(1)/6)*x/(-a)**(S(1)/6) + S(1))/S(3))/(S(6)*c**(S(7)/6)*(-a)**(S(1)/3)) + (sqrt(c)*e + d*sqrt(-a))*log(-c**(S(1)/6)*x + (-a)**(S(1)/6))/(S(6)*c**(S(7)/6)*(-a)**(S(1)/3)) - (sqrt(c)*e + d*sqrt(-a))*log(c**(S(1)/6)*x*(-a)**(S(1)/6) + c**(S(1)/3)*x**S(2) + (-a)**(S(1)/3))/(S(12)*c**(S(7)/6)*(-a)**(S(1)/3)) - sqrt(S(3))*(sqrt(c)*e + d*sqrt(-a))*atan(sqrt(S(3))*(S(2)*c**(S(1)/6)*x/(-a)**(S(1)/6) + S(1))/S(3))/(S(6)*c**(S(7)/6)*(-a)**(S(1)/3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e/x**S(3))/(a/x**S(6) + b/x**S(3) + c), x), x, d*x/c - S(2)**(S(2)/3)*(b*d - c*e + (-S(2)*a*c*d + b**S(2)*d - b*c*e)/sqrt(-S(4)*a*c + b**S(2)))*log(S(2)**(S(1)/3)*c**(S(1)/3)*x + (b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3))/(S(6)*c**(S(4)/3)*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)) + S(2)**(S(2)/3)*(b*d - c*e + (-S(2)*a*c*d + b**S(2)*d - b*c*e)/sqrt(-S(4)*a*c + b**S(2)))*log(S(2)**(S(2)/3)*c**(S(2)/3)*x**S(2) - S(2)**(S(1)/3)*c**(S(1)/3)*x*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + (b + sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3))/(S(12)*c**(S(4)/3)*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)) + S(2)**(S(2)/3)*sqrt(S(3))*(b*d - c*e + (-S(2)*a*c*d + b**S(2)*d - b*c*e)/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(3))*(-S(2)*S(2)**(S(1)/3)*c**(S(1)/3)*x/(b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + S(1))/S(3))/(S(6)*c**(S(4)/3)*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)) - S(2)**(S(2)/3)*(b*d - c*e - (-S(2)*a*c*d + b**S(2)*d - b*c*e)/sqrt(-S(4)*a*c + b**S(2)))*log(S(2)**(S(1)/3)*c**(S(1)/3)*x + (b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3))/(S(6)*c**(S(4)/3)*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)) + S(2)**(S(2)/3)*(b*d - c*e - (-S(2)*a*c*d + b**S(2)*d - b*c*e)/sqrt(-S(4)*a*c + b**S(2)))*log(S(2)**(S(2)/3)*c**(S(2)/3)*x**S(2) - S(2)**(S(1)/3)*c**(S(1)/3)*x*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + (b - sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3))/(S(12)*c**(S(4)/3)*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)) + S(2)**(S(2)/3)*sqrt(S(3))*(b*d - c*e - (-S(2)*a*c*d + b**S(2)*d - b*c*e)/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(3))*(-S(2)*S(2)**(S(1)/3)*c**(S(1)/3)*x/(b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + S(1))/S(3))/(S(6)*c**(S(4)/3)*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e/x**S(4))/(a/x**S(8) + c), x), x, d*x/c + sqrt(S(2))*(-sqrt(c)*e + d*sqrt(-a))*log(-sqrt(S(2))*c**(S(1)/8)*x*(-a)**(S(1)/8) + c**(S(1)/4)*x**S(2) + (-a)**(S(1)/4))/(S(16)*c**(S(9)/8)*(-a)**(S(3)/8)) - sqrt(S(2))*(-sqrt(c)*e + d*sqrt(-a))*log(sqrt(S(2))*c**(S(1)/8)*x*(-a)**(S(1)/8) + c**(S(1)/4)*x**S(2) + (-a)**(S(1)/4))/(S(16)*c**(S(9)/8)*(-a)**(S(3)/8)) - sqrt(S(2))*(-sqrt(c)*e + d*sqrt(-a))*atan(sqrt(S(2))*c**(S(1)/8)*x/(-a)**(S(1)/8) + S(-1))/(S(8)*c**(S(9)/8)*(-a)**(S(3)/8)) - sqrt(S(2))*(-sqrt(c)*e + d*sqrt(-a))*atan(sqrt(S(2))*c**(S(1)/8)*x/(-a)**(S(1)/8) + S(1))/(S(8)*c**(S(9)/8)*(-a)**(S(3)/8)) - (sqrt(c)*e + d*sqrt(-a))*atan(c**(S(1)/8)*x/(-a)**(S(1)/8))/(S(4)*c**(S(9)/8)*(-a)**(S(3)/8)) - (sqrt(c)*e + d*sqrt(-a))*atanh(c**(S(1)/8)*x/(-a)**(S(1)/8))/(S(4)*c**(S(9)/8)*(-a)**(S(3)/8)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e/x**S(4))/(a/x**S(8) + b/x**S(4) + c), x), x, d*x/c + S(2)**(S(3)/4)*(b*d - c*e - (-S(2)*a*c*d + b**S(2)*d - b*c*e)/sqrt(-S(4)*a*c + b**S(2)))*atan(S(2)**(S(1)/4)*c**(S(1)/4)*x/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(4)*c**(S(5)/4)*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)) + S(2)**(S(3)/4)*(b*d - c*e - (-S(2)*a*c*d + b**S(2)*d - b*c*e)/sqrt(-S(4)*a*c + b**S(2)))*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*x/(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(4)*c**(S(5)/4)*(-b + sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)) + S(2)**(S(3)/4)*(b*d - c*e + (-S(2)*a*c*d + b**S(2)*d - b*c*e)/sqrt(-S(4)*a*c + b**S(2)))*atan(S(2)**(S(1)/4)*c**(S(1)/4)*x/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(4)*c**(S(5)/4)*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)) + S(2)**(S(3)/4)*(b*d - c*e + (-S(2)*a*c*d + b**S(2)*d - b*c*e)/sqrt(-S(4)*a*c + b**S(2)))*atanh(S(2)**(S(1)/4)*c**(S(1)/4)*x/(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/4))/(S(4)*c**(S(5)/4)*(-b - sqrt(-S(4)*a*c + b**S(2)))**(S(3)/4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((f*x)**m*(a + c*x**(S(2)*n))**p*(d + e*x**n)**S(3), x), x, d**S(3)*(f*x)**(m + S(1))*(S(1) + c*x**(S(2)*n)/a)**(-p)*(a + c*x**(S(2)*n))**p*hyper(((m + S(1))/(S(2)*n), -p), (S(1) + (m + S(1))/(S(2)*n),), -c*x**(S(2)*n)/a)/(f*(m + S(1))) + S(3)*d**S(2)*e*x**(n + S(1))*(f*x)**m*(S(1) + c*x**(S(2)*n)/a)**(-p)*(a + c*x**(S(2)*n))**p*hyper(((m + n + S(1))/(S(2)*n), -p), ((m + S(3)*n + S(1))/(S(2)*n),), -c*x**(S(2)*n)/a)/(m + n + S(1)) + S(3)*d*e**S(2)*x**(S(2)*n + S(1))*(f*x)**m*(S(1) + c*x**(S(2)*n)/a)**(-p)*(a + c*x**(S(2)*n))**p*hyper(((m + S(2)*n + S(1))/(S(2)*n), -p), ((m + S(4)*n + S(1))/(S(2)*n),), -c*x**(S(2)*n)/a)/(m + S(2)*n + S(1)) + e**S(3)*x**(S(3)*n + S(1))*(f*x)**m*(S(1) + c*x**(S(2)*n)/a)**(-p)*(a + c*x**(S(2)*n))**p*hyper(((m + S(3)*n + S(1))/(S(2)*n), -p), ((m + S(5)*n + S(1))/(S(2)*n),), -c*x**(S(2)*n)/a)/(m + S(3)*n + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((f*x)**m*(a + c*x**(S(2)*n))**p*(d + e*x**n)**S(2), x), x, d**S(2)*(f*x)**(m + S(1))*(S(1) + c*x**(S(2)*n)/a)**(-p)*(a + c*x**(S(2)*n))**p*hyper(((m + S(1))/(S(2)*n), -p), (S(1) + (m + S(1))/(S(2)*n),), -c*x**(S(2)*n)/a)/(f*(m + S(1))) + S(2)*d*e*x**(n + S(1))*(f*x)**m*(S(1) + c*x**(S(2)*n)/a)**(-p)*(a + c*x**(S(2)*n))**p*hyper(((m + n + S(1))/(S(2)*n), -p), ((m + S(3)*n + S(1))/(S(2)*n),), -c*x**(S(2)*n)/a)/(m + n + S(1)) + e**S(2)*x**(S(2)*n + S(1))*(f*x)**m*(S(1) + c*x**(S(2)*n)/a)**(-p)*(a + c*x**(S(2)*n))**p*hyper(((m + S(2)*n + S(1))/(S(2)*n), -p), ((m + S(4)*n + S(1))/(S(2)*n),), -c*x**(S(2)*n)/a)/(m + S(2)*n + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((f*x)**m*(a + c*x**(S(2)*n))**p*(d + e*x**n), x), x, d*(f*x)**(m + S(1))*(S(1) + c*x**(S(2)*n)/a)**(-p)*(a + c*x**(S(2)*n))**p*hyper(((m + S(1))/(S(2)*n), -p), (S(1) + (m + S(1))/(S(2)*n),), -c*x**(S(2)*n)/a)/(f*(m + S(1))) + e*x**(n + S(1))*(f*x)**m*(S(1) + c*x**(S(2)*n)/a)**(-p)*(a + c*x**(S(2)*n))**p*hyper(((m + n + S(1))/(S(2)*n), -p), ((m + S(3)*n + S(1))/(S(2)*n),), -c*x**(S(2)*n)/a)/(m + n + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b + S(2)*c*x)*(a + b*x + c*x**S(2))**S(13), x), x, (a + b*x + c*x**S(2))**S(14)/S(14), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(b + S(2)*c*x**S(2))*(a + b*x**S(2) + c*x**S(4))**S(13), x), x, (a + b*x**S(2) + c*x**S(4))**S(14)/S(28), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(b + S(2)*c*x**S(3))*(a + b*x**S(3) + c*x**S(6))**S(13), x), x, (a + b*x**S(3) + c*x**S(6))**S(14)/S(42), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(n + S(-1))*(b + S(2)*c*x**n)*(a + b*x**n + c*x**(S(2)*n))**S(13), x), x, (a + b*x**n + c*x**(S(2)*n))**S(14)/(S(14)*n), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b + S(2)*c*x)*(-a + b*x + c*x**S(2))**S(13), x), x, (-a + b*x + c*x**S(2))**S(14)/S(14), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(b + S(2)*c*x**S(2))*(-a + b*x**S(2) + c*x**S(4))**S(13), x), x, (a - b*x**S(2) - c*x**S(4))**S(14)/S(28), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(b + S(2)*c*x**S(3))*(-a + b*x**S(3) + c*x**S(6))**S(13), x), x, (a - b*x**S(3) - c*x**S(6))**S(14)/S(42), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(n + S(-1))*(b + S(2)*c*x**n)*(-a + b*x**n + c*x**(S(2)*n))**S(13), x), x, (a - b*x**n - c*x**(S(2)*n))**S(14)/(S(14)*n), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b + S(2)*c*x)*(b*x + c*x**S(2))**S(13), x), x, (b*x + c*x**S(2))**S(14)/S(14), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(b + S(2)*c*x**S(2))*(b*x**S(2) + c*x**S(4))**S(13), x), x, x**S(28)*(b + c*x**S(2))**S(14)/S(28), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(b + S(2)*c*x**S(3))*(b*x**S(3) + c*x**S(6))**S(13), x), x, x**S(42)*(b + c*x**S(3))**S(14)/S(42), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(n + S(-1))*(b + S(2)*c*x**n)*(b*x**n + c*x**(S(2)*n))**S(13), x), x, x**(S(14)*n)*(b + c*x**n)**S(14)/(S(14)*n), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b + S(2)*c*x)/(a + b*x + c*x**S(2)), x), x, log(a + b*x + c*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(b + S(2)*c*x**S(2))/(a + b*x**S(2) + c*x**S(4)), x), x, log(a + b*x**S(2) + c*x**S(4))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(b + S(2)*c*x**S(3))/(a + b*x**S(3) + c*x**S(6)), x), x, log(a + b*x**S(3) + c*x**S(6))/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(n + S(-1))*(b + S(2)*c*x**n)/(a + b*x**n + c*x**(S(2)*n)), x), x, log(a + b*x**n + c*x**(S(2)*n))/n, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b + S(2)*c*x)/(a + b*x + c*x**S(2))**S(8), x), x, -S(1)/(S(7)*(a + b*x + c*x**S(2))**S(7)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(b + S(2)*c*x**S(2))/(a + b*x**S(2) + c*x**S(4))**S(8), x), x, -S(1)/(S(14)*(a + b*x**S(2) + c*x**S(4))**S(7)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(b + S(2)*c*x**S(3))/(a + b*x**S(3) + c*x**S(6))**S(8), x), x, -S(1)/(S(21)*(a + b*x**S(3) + c*x**S(6))**S(7)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(n + S(-1))*(b + S(2)*c*x**n)/(a + b*x**n + c*x**(S(2)*n))**S(8), x), x, -S(1)/(S(7)*n*(a + b*x**n + c*x**(S(2)*n))**S(7)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b + S(2)*c*x)/(-a + b*x + c*x**S(2)), x), x, log(a - b*x - c*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(b + S(2)*c*x**S(2))/(-a + b*x**S(2) + c*x**S(4)), x), x, log(a - b*x**S(2) - c*x**S(4))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(b + S(2)*c*x**S(3))/(-a + b*x**S(3) + c*x**S(6)), x), x, log(a - b*x**S(3) - c*x**S(6))/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(n + S(-1))*(b + S(2)*c*x**n)/(-a + b*x**n + c*x**(S(2)*n)), x), x, log(a - b*x**n - c*x**(S(2)*n))/n, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b + S(2)*c*x)/(-a + b*x + c*x**S(2))**S(8), x), x, -S(1)/(S(7)*(-a + b*x + c*x**S(2))**S(7)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(b + S(2)*c*x**S(2))/(-a + b*x**S(2) + c*x**S(4))**S(8), x), x, S(1)/(S(14)*(a - b*x**S(2) - c*x**S(4))**S(7)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(b + S(2)*c*x**S(3))/(-a + b*x**S(3) + c*x**S(6))**S(8), x), x, S(1)/(S(21)*(a - b*x**S(3) - c*x**S(6))**S(7)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(n + S(-1))*(b + S(2)*c*x**n)/(-a + b*x**n + c*x**(S(2)*n))**S(8), x), x, S(1)/(S(7)*n*(a - b*x**n - c*x**(S(2)*n))**S(7)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b + S(2)*c*x)/(b*x + c*x**S(2)), x), x, log(b*x + c*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(b + S(2)*c*x**S(2))/(b*x**S(2) + c*x**S(4)), x), x, log(x) + log(b + c*x**S(2))/S(2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(b + S(2)*c*x**S(3))/(b*x**S(3) + c*x**S(6)), x), x, log(x) + log(b + c*x**S(3))/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(n + S(-1))*(b + S(2)*c*x**n)/(b*x**n + c*x**(S(2)*n)), x), x, log(x) + log(b + c*x**n)/n, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b + S(2)*c*x)/(b*x + c*x**S(2))**S(8), x), x, -S(1)/(S(7)*(b*x + c*x**S(2))**S(7)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(b + S(2)*c*x**S(2))/(b*x**S(2) + c*x**S(4))**S(8), x), x, -S(1)/(S(14)*x**S(14)*(b + c*x**S(2))**S(7)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(b + S(2)*c*x**S(3))/(b*x**S(3) + c*x**S(6))**S(8), x), x, -S(1)/(S(21)*x**S(21)*(b + c*x**S(3))**S(7)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(n + S(-1))*(b + S(2)*c*x**n)/(b*x**n + c*x**(S(2)*n))**S(8), x), x, -x**(-S(7)*n)/(S(7)*n*(b + c*x**n)**S(7)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b + S(2)*c*x)*(a + b*x + c*x**S(2))**p, x), x, (a + b*x + c*x**S(2))**(p + S(1))/(p + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(b + S(2)*c*x**S(2))*(a + b*x**S(2) + c*x**S(4))**p, x), x, (a + b*x**S(2) + c*x**S(4))**(p + S(1))/(S(2)*p + S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(b + S(2)*c*x**S(3))*(a + b*x**S(3) + c*x**S(6))**p, x), x, (a + b*x**S(3) + c*x**S(6))**(p + S(1))/(S(3)*p + S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(n + S(-1))*(b + S(2)*c*x**n)*(a + b*x**n + c*x**(S(2)*n))**p, x), x, (a + b*x**n + c*x**(S(2)*n))**(p + S(1))/(n*(p + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b + S(2)*c*x)*(-a + b*x + c*x**S(2))**p, x), x, (-a + b*x + c*x**S(2))**(p + S(1))/(p + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(b + S(2)*c*x**S(2))*(-a + b*x**S(2) + c*x**S(4))**p, x), x, (-a + b*x**S(2) + c*x**S(4))**(p + S(1))/(S(2)*p + S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(b + S(2)*c*x**S(3))*(-a + b*x**S(3) + c*x**S(6))**p, x), x, (-a + b*x**S(3) + c*x**S(6))**(p + S(1))/(S(3)*p + S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(n + S(-1))*(b + S(2)*c*x**n)*(-a + b*x**n + c*x**(S(2)*n))**p, x), x, (-a + b*x**n + c*x**(S(2)*n))**(p + S(1))/(n*(p + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((b + S(2)*c*x)*(b*x + c*x**S(2))**p, x), x, (b*x + c*x**S(2))**(p + S(1))/(p + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(b + S(2)*c*x**S(2))*(b*x**S(2) + c*x**S(4))**p, x), x, (b*x**S(2) + c*x**S(4))**(p + S(1))/(S(2)*p + S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(b + S(2)*c*x**S(3))*(b*x**S(3) + c*x**S(6))**p, x), x, (b*x**S(3) + c*x**S(6))**(p + S(1))/(S(3)*p + S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(n + S(-1))*(b + S(2)*c*x**n)*(b*x**n + c*x**(S(2)*n))**p, x), x, (b*x**n + c*x**(S(2)*n))**(p + S(1))/(n*(p + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((f*x)**m*(d + e*x**n)/(a + b*x**n + c*x**(S(2)*n)), x), x, (f*x)**(m + S(1))*(e - (-b*e + S(2)*c*d)/sqrt(-S(4)*a*c + b**S(2)))*hyper((S(1), (m + S(1))/n), ((m + n + S(1))/n,), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(f*(b + sqrt(-S(4)*a*c + b**S(2)))*(m + S(1))) + (f*x)**(m + S(1))*(e + (-b*e + S(2)*c*d)/sqrt(-S(4)*a*c + b**S(2)))*hyper((S(1), (m + S(1))/n), ((m + n + S(1))/n,), -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))))/(f*(b - sqrt(-S(4)*a*c + b**S(2)))*(m + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((f*x)**m*(d + e*x**n)/(a + b*x**n + c*x**(S(2)*n))**S(2), x), x, -c*(f*x)**(m + S(1))*((-S(2)*a*e + b*d)*(m - n + S(1)) + (S(2)*a*b*e*n + S(4)*a*c*d*(m - S(2)*n + S(1)) - b**S(2)*d*(m - n + S(1)))/sqrt(-S(4)*a*c + b**S(2)))*hyper((S(1), (m + S(1))/n), ((m + n + S(1))/n,), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(a*f*n*(b + sqrt(-S(4)*a*c + b**S(2)))*(m + S(1))*(-S(4)*a*c + b**S(2))) - c*(f*x)**(m + S(1))*((-S(2)*a*e + b*d)*(m - n + S(1)) - (S(2)*a*b*e*n + S(4)*a*c*d*(m - S(2)*n + S(1)) - b**S(2)*d*(m - n + S(1)))/sqrt(-S(4)*a*c + b**S(2)))*hyper((S(1), (m + S(1))/n), ((m + n + S(1))/n,), -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))))/(a*f*n*(b - sqrt(-S(4)*a*c + b**S(2)))*(m + S(1))*(-S(4)*a*c + b**S(2))) + (f*x)**(m + S(1))*(-a*b*e - S(2)*a*c*d + b**S(2)*d + c*x**n*(-S(2)*a*e + b*d))/(a*f*n*(-S(4)*a*c + b**S(2))*(a + b*x**n + c*x**(S(2)*n))), expand=True, _diff=True, _numerical=True)
# large time assert rubi_test(rubi_integrate((d + e*x**n)**q/(x*(a + b*x**n + c*x**(S(2)*n))), x), x, c*(d + e*x**n)**(q + S(1))*(-b/sqrt(-S(4)*a*c + b**S(2)) + S(1))*hyper((S(1), q + S(1)), (q + S(2),), S(2)*c*(d + e*x**n)/(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2)))))/(a*n*(q + S(1))*(S(2)*c*d - e*(b + sqrt(-S(4)*a*c + b**S(2))))) + c*(d + e*x**n)**(q + S(1))*(b/sqrt(-S(4)*a*c + b**S(2)) + S(1))*hyper((S(1), q + S(1)), (q + S(2),), S(2)*c*(d + e*x**n)/(-b*e + S(2)*c*d + e*sqrt(-S(4)*a*c + b**S(2))))/(a*n*(q + S(1))*(S(2)*c*d - e*(b - sqrt(-S(4)*a*c + b**S(2))))) - (d + e*x**n)**(q + S(1))*hyper((S(1), q + S(1)), (q + S(2),), S(1) + e*x**n/d)/(a*d*n*(q + S(1))), expand=True, _diff=True, _numerical=True)
# Apart assert rubi_test(rubi_integrate((f*x)**m*(d + e*x**n)/(a + b*x**n + c*x**(S(2)*n))**S(3), x), x, (f*x)**(m + S(1))*(-a*b*e - S(2)*a*c*d + b**S(2)*d + c*x**n*(-S(2)*a*e + b*d))/(S(2)*a*f*n*(-S(4)*a*c + b**S(2))*(a + b*x**n + c*x**(S(2)*n))**S(2)) - c*(f*x)**(m + S(1))*((m - n + S(1))*(-S(4)*a**S(2)*c*e*(m - S(3)*n + S(1)) + a*b**S(2)*e*(m + S(1)) + S(2)*a*b*c*d*(S(2)*m - S(7)*n + S(2)) - b**S(3)*d*(m - S(2)*n + S(1))) - (-S(4)*a**S(2)*b*c*e*(m**S(2) + m*(-n + S(2)) - S(3)*n**S(2) - n + S(1)) - S(8)*a**S(2)*c**S(2)*d*(m**S(2) + m*(-S(6)*n + S(2)) + S(8)*n**S(2) - S(6)*n + S(1)) + a*b**S(3)*e*(m + S(1))*(m - n + S(1)) + S(6)*a*b**S(2)*c*d*(m**S(2) + m*(-S(4)*n + S(2)) + S(3)*n**S(2) - S(4)*n + S(1)) - b**S(4)*d*(m**S(2) + m*(-S(3)*n + S(2)) + S(2)*n**S(2) - S(3)*n + S(1)))/sqrt(-S(4)*a*c + b**S(2)))*hyper((S(1), (m + S(1))/n), ((m + n + S(1))/n,), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*a**S(2)*f*n**S(2)*(b + sqrt(-S(4)*a*c + b**S(2)))*(m + S(1))*(-S(4)*a*c + b**S(2))**S(2)) - c*(f*x)**(m + S(1))*((m - n + S(1))*(-S(4)*a**S(2)*c*e*(m - S(3)*n + S(1)) + a*b**S(2)*e*(m + S(1)) + S(2)*a*b*c*d*(S(2)*m - S(7)*n + S(2)) - b**S(3)*d*(m - S(2)*n + S(1))) + (-S(4)*a**S(2)*b*c*e*(m**S(2) + m*(-n + S(2)) - S(3)*n**S(2) - n + S(1)) - S(8)*a**S(2)*c**S(2)*d*(m**S(2) + m*(-S(6)*n + S(2)) + S(8)*n**S(2) - S(6)*n + S(1)) + a*b**S(3)*e*(m + S(1))*(m - n + S(1)) + S(6)*a*b**S(2)*c*d*(m**S(2) + m*(-S(4)*n + S(2)) + S(3)*n**S(2) - S(4)*n + S(1)) - b**S(4)*d*(m**S(2) + m*(-S(3)*n + S(2)) + S(2)*n**S(2) - S(3)*n + S(1)))/sqrt(-S(4)*a*c + b**S(2)))*hyper((S(1), (m + S(1))/n), ((m + n + S(1))/n,), -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*a**S(2)*f*n**S(2)*(b - sqrt(-S(4)*a*c + b**S(2)))*(m + S(1))*(-S(4)*a*c + b**S(2))**S(2)) + (f*x)**(m + S(1))*(a*b*c*(-S(2)*a*e + b*d)*(m - S(3)*n + S(1)) + c*x**n*(-S(4)*a**S(2)*c*e*(m - S(3)*n + S(1)) + a*b**S(2)*e*(m + S(1)) + S(2)*a*b*c*d*(S(2)*m - S(7)*n + S(2)) - b**S(3)*d*(m - S(2)*n + S(1))) + (-S(2)*a*c + b**S(2))*(a*b*e*(m + S(1)) + S(2)*a*c*d*(m - S(4)*n + S(1)) - b**S(2)*d*(m - S(2)*n + S(1))))/(S(2)*a**S(2)*f*n**S(2)*(-S(4)*a*c + b**S(2))**S(2)*(a + b*x**n + c*x**(S(2)*n))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((c**(S(1)/3) - S(2)*d**(S(1)/3)*x**(S(1)/3))/(-c**(S(2)/3)*d**(S(2)/3)*x + c**(S(1)/3)*d*x**(S(4)/3) + c*d**(S(1)/3)*x**(S(2)/3)), x), x, -S(3)*log(c**(S(2)/3) - c**(S(1)/3)*d**(S(1)/3)*x**(S(1)/3) + d**(S(2)/3)*x**(S(2)/3))/(c**(S(1)/3)*d**(S(2)/3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)*(a + b*x**S(2) + c*x**S(4))/(sqrt(d - e*x)*sqrt(d + e*x)), x), x, -c*(d - e*x)**(S(9)/2)*(d + e*x)**(S(9)/2)/(S(9)*e**S(10)) - d**S(4)*sqrt(d - e*x)*sqrt(d + e*x)*(a*e**S(4) + b*d**S(2)*e**S(2) + c*d**S(4))/e**S(10) + d**S(2)*(d - e*x)**(S(3)/2)*(d + e*x)**(S(3)/2)*(S(2)*a*e**S(4) + S(3)*b*d**S(2)*e**S(2) + S(4)*c*d**S(4))/(S(3)*e**S(10)) + (d - e*x)**(S(7)/2)*(d + e*x)**(S(7)/2)*(b*e**S(2) + S(4)*c*d**S(2))/(S(7)*e**S(10)) - (d - e*x)**(S(5)/2)*(d + e*x)**(S(5)/2)*(a*e**S(4) + S(3)*b*d**S(2)*e**S(2) + S(6)*c*d**S(4))/(S(5)*e**S(10)), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate(x**S(5)*(a + b*x**S(2) + c*x**S(4))/(sqrt(d - e*x)*sqrt(d + e*x)), x), x, -c*(d**S(2) - e**S(2)*x**S(2))**S(5)/(S(9)*e**S(10)*sqrt(d - e*x)*sqrt(d + e*x)) - d**S(4)*(d**S(2) - e**S(2)*x**S(2))*(a*e**S(4) + b*d**S(2)*e**S(2) + c*d**S(4))/(e**S(10)*sqrt(d - e*x)*sqrt(d + e*x)) + d**S(2)*(d**S(2) - e**S(2)*x**S(2))**S(2)*(S(2)*a*e**S(4) + S(3)*b*d**S(2)*e**S(2) + S(4)*c*d**S(4))/(S(3)*e**S(10)*sqrt(d - e*x)*sqrt(d + e*x)) + (d**S(2) - e**S(2)*x**S(2))**S(4)*(b*e**S(2) + S(4)*c*d**S(2))/(S(7)*e**S(10)*sqrt(d - e*x)*sqrt(d + e*x)) - (d**S(2) - e**S(2)*x**S(2))**S(3)*(a*e**S(4) + S(3)*b*d**S(2)*e**S(2) + S(6)*c*d**S(4))/(S(5)*e**S(10)*sqrt(d - e*x)*sqrt(d + e*x)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*(a + b*x**S(2) + c*x**S(4))/(sqrt(d - e*x)*sqrt(d + e*x)), x), x, c*(d - e*x)**(S(7)/2)*(d + e*x)**(S(7)/2)/(S(7)*e**S(8)) - d**S(2)*sqrt(d - e*x)*sqrt(d + e*x)*(a*e**S(4) + b*d**S(2)*e**S(2) + c*d**S(4))/e**S(8) - (d - e*x)**(S(5)/2)*(d + e*x)**(S(5)/2)*(b*e**S(2) + S(3)*c*d**S(2))/(S(5)*e**S(8)) + (d - e*x)**(S(3)/2)*(d + e*x)**(S(3)/2)*(a*e**S(4) + S(2)*b*d**S(2)*e**S(2) + S(3)*c*d**S(4))/(S(3)*e**S(8)), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate(x**S(3)*(a + b*x**S(2) + c*x**S(4))/(sqrt(d - e*x)*sqrt(d + e*x)), x), x, c*(d**S(2) - e**S(2)*x**S(2))**S(4)/(S(7)*e**S(8)*sqrt(d - e*x)*sqrt(d + e*x)) - d**S(2)*(d**S(2) - e**S(2)*x**S(2))*(a*e**S(4) + b*d**S(2)*e**S(2) + c*d**S(4))/(e**S(8)*sqrt(d - e*x)*sqrt(d + e*x)) - (d**S(2) - e**S(2)*x**S(2))**S(3)*(b*e**S(2) + S(3)*c*d**S(2))/(S(5)*e**S(8)*sqrt(d - e*x)*sqrt(d + e*x)) + (d**S(2) - e**S(2)*x**S(2))**S(2)*(a*e**S(4) + S(2)*b*d**S(2)*e**S(2) + S(3)*c*d**S(4))/(S(3)*e**S(8)*sqrt(d - e*x)*sqrt(d + e*x)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(a + b*x**S(2) + c*x**S(4))/(sqrt(d - e*x)*sqrt(d + e*x)), x), x, -c*(d - e*x)**(S(5)/2)*(d + e*x)**(S(5)/2)/(S(5)*e**S(6)) + (d - e*x)**(S(3)/2)*(d + e*x)**(S(3)/2)*(b*e**S(2) + S(2)*c*d**S(2))/(S(3)*e**S(6)) - sqrt(d - e*x)*sqrt(d + e*x)*(a*e**S(4) + b*d**S(2)*e**S(2) + c*d**S(4))/e**S(6), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate(x*(a + b*x**S(2) + c*x**S(4))/(sqrt(d - e*x)*sqrt(d + e*x)), x), x, -c*(d**S(2) - e**S(2)*x**S(2))**S(3)/(S(5)*e**S(6)*sqrt(d - e*x)*sqrt(d + e*x)) + (d**S(2) - e**S(2)*x**S(2))**S(2)*(b*e**S(2) + S(2)*c*d**S(2))/(S(3)*e**S(6)*sqrt(d - e*x)*sqrt(d + e*x)) - (d**S(2) - e**S(2)*x**S(2))*(a*e**S(4) + b*d**S(2)*e**S(2) + c*d**S(4))/(e**S(6)*sqrt(d - e*x)*sqrt(d + e*x)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))/(x*sqrt(d - e*x)*sqrt(d + e*x)), x), x, -a*atanh(sqrt(d - e*x)*sqrt(d + e*x)/d)/d + c*(d - e*x)**(S(3)/2)*(d + e*x)**(S(3)/2)/(S(3)*e**S(4)) - sqrt(d - e*x)*sqrt(d + e*x)*(b*e**S(2) + c*d**S(2))/e**S(4), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))/(x*sqrt(d - e*x)*sqrt(d + e*x)), x), x, -a*sqrt(d**S(2) - e**S(2)*x**S(2))*atanh(sqrt(d**S(2) - e**S(2)*x**S(2))/d)/(d*sqrt(d - e*x)*sqrt(d + e*x)) + c*(d**S(2) - e**S(2)*x**S(2))**S(2)/(S(3)*e**S(4)*sqrt(d - e*x)*sqrt(d + e*x)) - (d**S(2) - e**S(2)*x**S(2))*(b*e**S(2) + c*d**S(2))/(e**S(4)*sqrt(d - e*x)*sqrt(d + e*x)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))/(x**S(3)*sqrt(d - e*x)*sqrt(d + e*x)), x), x, -a*sqrt(d - e*x)*sqrt(d + e*x)/(S(2)*d**S(2)*x**S(2)) - c*sqrt(d - e*x)*sqrt(d + e*x)/e**S(2) - (a*e**S(2) + S(2)*b*d**S(2))*atanh(sqrt(d - e*x)*sqrt(d + e*x)/d)/(S(2)*d**S(3)), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))/(x**S(3)*sqrt(d - e*x)*sqrt(d + e*x)), x), x, -a*(d**S(2) - e**S(2)*x**S(2))/(S(2)*d**S(2)*x**S(2)*sqrt(d - e*x)*sqrt(d + e*x)) - c*(d**S(2) - e**S(2)*x**S(2))/(e**S(2)*sqrt(d - e*x)*sqrt(d + e*x)) - sqrt(d**S(2) - e**S(2)*x**S(2))*(a*e**S(2) + S(2)*b*d**S(2))*atanh(sqrt(d**S(2) - e**S(2)*x**S(2))/d)/(S(2)*d**S(3)*sqrt(d - e*x)*sqrt(d + e*x)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))/(x**S(5)*sqrt(d - e*x)*sqrt(d + e*x)), x), x, -a*sqrt(d - e*x)*sqrt(d + e*x)/(S(4)*d**S(2)*x**S(4)) - sqrt(d - e*x)*sqrt(d + e*x)*(S(3)*a*e**S(2) + S(4)*b*d**S(2))/(S(8)*d**S(4)*x**S(2)) - (S(3)*a*e**S(4) + S(4)*b*d**S(2)*e**S(2) + S(8)*c*d**S(4))*atanh(sqrt(d - e*x)*sqrt(d + e*x)/d)/(S(8)*d**S(5)), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))/(x**S(5)*sqrt(d - e*x)*sqrt(d + e*x)), x), x, -a*(d**S(2) - e**S(2)*x**S(2))/(S(4)*d**S(2)*x**S(4)*sqrt(d - e*x)*sqrt(d + e*x)) - (d**S(2) - e**S(2)*x**S(2))*(S(3)*a*e**S(2) + S(4)*b*d**S(2))/(S(8)*d**S(4)*x**S(2)*sqrt(d - e*x)*sqrt(d + e*x)) - sqrt(d**S(2) - e**S(2)*x**S(2))*(S(3)*a*e**S(4) + S(4)*b*d**S(2)*e**S(2) + S(8)*c*d**S(4))*atanh(sqrt(d**S(2) - e**S(2)*x**S(2))/d)/(S(8)*d**S(5)*sqrt(d - e*x)*sqrt(d + e*x)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))/(x**S(7)*sqrt(d - e*x)*sqrt(d + e*x)), x), x, -a*sqrt(d - e*x)*sqrt(d + e*x)/(S(6)*d**S(2)*x**S(6)) - sqrt(d - e*x)*sqrt(d + e*x)*(S(5)*a*e**S(2) + S(6)*b*d**S(2))/(S(24)*d**S(4)*x**S(4)) - sqrt(d - e*x)*sqrt(d + e*x)*(S(5)*a*e**S(4) + S(6)*b*d**S(2)*e**S(2) + S(8)*c*d**S(4))/(S(16)*d**S(6)*x**S(2)) - e**S(2)*sqrt(d**S(2) - e**S(2)*x**S(2))*(S(5)*a*e**S(4) + S(6)*b*d**S(2)*e**S(2) + S(8)*c*d**S(4))*atanh(sqrt(d**S(2) - e**S(2)*x**S(2))/d)/(S(16)*d**S(7)*sqrt(d - e*x)*sqrt(d + e*x)), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))/(x**S(7)*sqrt(d - e*x)*sqrt(d + e*x)), x), x, -a*(d**S(2) - e**S(2)*x**S(2))/(S(6)*d**S(2)*x**S(6)*sqrt(d - e*x)*sqrt(d + e*x)) - (d**S(2) - e**S(2)*x**S(2))*(S(5)*a*e**S(2) + S(6)*b*d**S(2))/(S(24)*d**S(4)*x**S(4)*sqrt(d - e*x)*sqrt(d + e*x)) - (d**S(2) - e**S(2)*x**S(2))*(S(5)*a*e**S(4) + S(6)*b*d**S(2)*e**S(2) + S(8)*c*d**S(4))/(S(16)*d**S(6)*x**S(2)*sqrt(d - e*x)*sqrt(d + e*x)) - e**S(2)*sqrt(d**S(2) - e**S(2)*x**S(2))*(S(5)*a*e**S(4) + S(6)*b*d**S(2)*e**S(2) + S(8)*c*d**S(4))*atanh(sqrt(d**S(2) - e**S(2)*x**S(2))/d)/(S(16)*d**S(7)*sqrt(d - e*x)*sqrt(d + e*x)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)*(a + b*x**S(2) + c*x**S(4))/(sqrt(d - e*x)*sqrt(d + e*x)), x), x, c*x**S(7)*(-d + e*x)*sqrt(d + e*x)/(S(8)*e**S(2)*sqrt(d - e*x)) + d**S(4)*sqrt(d**S(2) - e**S(2)*x**S(2))*(S(48)*a*e**S(4) + S(40)*b*d**S(2)*e**S(2) + S(35)*c*d**S(4))*atan(e*x/sqrt(d**S(2) - e**S(2)*x**S(2)))/(S(128)*e**S(9)*sqrt(d - e*x)*sqrt(d + e*x)) - d**S(2)*x*sqrt(d - e*x)*sqrt(d + e*x)*(S(48)*a*e**S(4) + S(40)*b*d**S(2)*e**S(2) + S(35)*c*d**S(4))/(S(128)*e**S(8)) - x**S(5)*sqrt(d - e*x)*sqrt(d + e*x)*(S(8)*b*e**S(2) + S(7)*c*d**S(2))/(S(48)*e**S(4)) - x**S(3)*sqrt(d - e*x)*sqrt(d + e*x)*(S(48)*a*e**S(4) + S(40)*b*d**S(2)*e**S(2) + S(35)*c*d**S(4))/(S(192)*e**S(6)), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate(x**S(4)*(a + b*x**S(2) + c*x**S(4))/(sqrt(d - e*x)*sqrt(d + e*x)), x), x, -c*x**S(7)*(d**S(2) - e**S(2)*x**S(2))/(S(8)*e**S(2)*sqrt(d - e*x)*sqrt(d + e*x)) + d**S(4)*sqrt(d**S(2) - e**S(2)*x**S(2))*(S(48)*a*e**S(4) + S(40)*b*d**S(2)*e**S(2) + S(35)*c*d**S(4))*atan(e*x/sqrt(d**S(2) - e**S(2)*x**S(2)))/(S(128)*e**S(9)*sqrt(d - e*x)*sqrt(d + e*x)) - d**S(2)*x*(d**S(2) - e**S(2)*x**S(2))*(S(48)*a*e**S(4) + S(40)*b*d**S(2)*e**S(2) + S(35)*c*d**S(4))/(S(128)*e**S(8)*sqrt(d - e*x)*sqrt(d + e*x)) - x**S(5)*(d**S(2) - e**S(2)*x**S(2))*(S(8)*b*e**S(2) + S(7)*c*d**S(2))/(S(48)*e**S(4)*sqrt(d - e*x)*sqrt(d + e*x)) - x**S(3)*(d**S(2) - e**S(2)*x**S(2))*(S(48)*a*e**S(4) + S(40)*b*d**S(2)*e**S(2) + S(35)*c*d**S(4))/(S(192)*e**S(6)*sqrt(d - e*x)*sqrt(d + e*x)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(a + b*x**S(2) + c*x**S(4))/(sqrt(d - e*x)*sqrt(d + e*x)), x), x, c*x**S(5)*(-d + e*x)*sqrt(d + e*x)/(S(6)*e**S(2)*sqrt(d - e*x)) + d**S(2)*sqrt(d**S(2) - e**S(2)*x**S(2))*(S(8)*a*e**S(4) + S(6)*b*d**S(2)*e**S(2) + S(5)*c*d**S(4))*atan(e*x/sqrt(d**S(2) - e**S(2)*x**S(2)))/(S(16)*e**S(7)*sqrt(d - e*x)*sqrt(d + e*x)) - x**S(3)*sqrt(d - e*x)*sqrt(d + e*x)*(S(6)*b*e**S(2) + S(5)*c*d**S(2))/(S(24)*e**S(4)) - x*sqrt(d - e*x)*sqrt(d + e*x)*(S(8)*a*e**S(4) + S(6)*b*d**S(2)*e**S(2) + S(5)*c*d**S(4))/(S(16)*e**S(6)), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate(x**S(2)*(a + b*x**S(2) + c*x**S(4))/(sqrt(d - e*x)*sqrt(d + e*x)), x), x, -c*x**S(5)*(d**S(2) - e**S(2)*x**S(2))/(S(6)*e**S(2)*sqrt(d - e*x)*sqrt(d + e*x)) + d**S(2)*sqrt(d**S(2) - e**S(2)*x**S(2))*(S(8)*a*e**S(4) + S(6)*b*d**S(2)*e**S(2) + S(5)*c*d**S(4))*atan(e*x/sqrt(d**S(2) - e**S(2)*x**S(2)))/(S(16)*e**S(7)*sqrt(d - e*x)*sqrt(d + e*x)) - x**S(3)*(d**S(2) - e**S(2)*x**S(2))*(S(6)*b*e**S(2) + S(5)*c*d**S(2))/(S(24)*e**S(4)*sqrt(d - e*x)*sqrt(d + e*x)) - x*(d**S(2) - e**S(2)*x**S(2))*(S(8)*a*e**S(4) + S(6)*b*d**S(2)*e**S(2) + S(5)*c*d**S(4))/(S(16)*e**S(6)*sqrt(d - e*x)*sqrt(d + e*x)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))/(sqrt(d - e*x)*sqrt(d + e*x)), x), x, c*x**S(3)*(-d + e*x)*sqrt(d + e*x)/(S(4)*e**S(2)*sqrt(d - e*x)) - x*sqrt(d - e*x)*sqrt(d + e*x)*(S(4)*b*e**S(2) + S(3)*c*d**S(2))/(S(8)*e**S(4)) - (S(8)*a*e**S(4) + S(4)*b*d**S(2)*e**S(2) + S(3)*c*d**S(4))*atan(sqrt(d - e*x)/sqrt(d + e*x))/(S(4)*e**S(5)), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))/(sqrt(d - e*x)*sqrt(d + e*x)), x), x, -c*x**S(3)*(d**S(2) - e**S(2)*x**S(2))/(S(4)*e**S(2)*sqrt(d - e*x)*sqrt(d + e*x)) - x*(d**S(2) - e**S(2)*x**S(2))*(S(4)*b*e**S(2) + S(3)*c*d**S(2))/(S(8)*e**S(4)*sqrt(d - e*x)*sqrt(d + e*x)) + sqrt(d**S(2) - e**S(2)*x**S(2))*(S(8)*a*e**S(4) + S(4)*b*d**S(2)*e**S(2) + S(3)*c*d**S(4))*atan(e*x/sqrt(d**S(2) - e**S(2)*x**S(2)))/(S(8)*e**S(5)*sqrt(d - e*x)*sqrt(d + e*x)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))/(x**S(2)*sqrt(d - e*x)*sqrt(d + e*x)), x), x, -a*sqrt(d - e*x)*sqrt(d + e*x)/(d**S(2)*x) + c*x*(-d + e*x)*sqrt(d + e*x)/(S(2)*e**S(2)*sqrt(d - e*x)) - (S(2)*b*e**S(2) + c*d**S(2))*atan(sqrt(d - e*x)/sqrt(d + e*x))/e**S(3), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))/(x**S(2)*sqrt(d - e*x)*sqrt(d + e*x)), x), x, -a*(d**S(2) - e**S(2)*x**S(2))/(d**S(2)*x*sqrt(d - e*x)*sqrt(d + e*x)) - c*x*(d**S(2) - e**S(2)*x**S(2))/(S(2)*e**S(2)*sqrt(d - e*x)*sqrt(d + e*x)) + sqrt(d**S(2) - e**S(2)*x**S(2))*(S(2)*b*e**S(2) + c*d**S(2))*atan(e*x/sqrt(d**S(2) - e**S(2)*x**S(2)))/(S(2)*e**S(3)*sqrt(d - e*x)*sqrt(d + e*x)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))/(x**S(4)*sqrt(d - e*x)*sqrt(d + e*x)), x), x, -a*sqrt(d - e*x)*sqrt(d + e*x)/(S(3)*d**S(2)*x**S(3)) - S(2)*a*e**S(2)*sqrt(d - e*x)*sqrt(d + e*x)/(S(3)*d**S(4)*x) - b*sqrt(d - e*x)*sqrt(d + e*x)/(d**S(2)*x) + c*sqrt(d**S(2) - e**S(2)*x**S(2))*atan(e*x/sqrt(d**S(2) - e**S(2)*x**S(2)))/(e*sqrt(d - e*x)*sqrt(d + e*x)), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))/(x**S(4)*sqrt(d - e*x)*sqrt(d + e*x)), x), x, -a*(d**S(2) - e**S(2)*x**S(2))/(S(3)*d**S(2)*x**S(3)*sqrt(d - e*x)*sqrt(d + e*x)) - S(2)*a*e**S(2)*(d**S(2) - e**S(2)*x**S(2))/(S(3)*d**S(4)*x*sqrt(d - e*x)*sqrt(d + e*x)) - b*(d**S(2) - e**S(2)*x**S(2))/(d**S(2)*x*sqrt(d - e*x)*sqrt(d + e*x)) + c*sqrt(d**S(2) - e**S(2)*x**S(2))*atan(e*x/sqrt(d**S(2) - e**S(2)*x**S(2)))/(e*sqrt(d - e*x)*sqrt(d + e*x)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))/(x**S(6)*sqrt(d - e*x)*sqrt(d + e*x)), x), x, -a*sqrt(d - e*x)*sqrt(d + e*x)/(S(5)*d**S(2)*x**S(5)) - c*(-d + e*x)*sqrt(d + e*x)/(S(2)*e**S(2)*x**S(3)*sqrt(d - e*x)) - sqrt(d - e*x)*sqrt(d + e*x)*(S(8)*a*e**S(4) + S(10)*b*d**S(2)*e**S(2) + S(15)*c*d**S(4))/(S(30)*d**S(4)*e**S(2)*x**S(3)) - sqrt(d - e*x)*sqrt(d + e*x)*(S(8)*a*e**S(4) + S(10)*b*d**S(2)*e**S(2) + S(15)*c*d**S(4))/(S(15)*d**S(6)*x), expand=True, _diff=True, _numerical=True) or rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))/(x**S(6)*sqrt(d - e*x)*sqrt(d + e*x)), x), x, -a*(d**S(2) - e**S(2)*x**S(2))/(S(5)*d**S(2)*x**S(5)*sqrt(d - e*x)*sqrt(d + e*x)) + c*(d**S(2) - e**S(2)*x**S(2))/(S(2)*e**S(2)*x**S(3)*sqrt(d - e*x)*sqrt(d + e*x)) - (d**S(2) - e**S(2)*x**S(2))*(S(8)*a*e**S(4) + S(10)*b*d**S(2)*e**S(2) + S(15)*c*d**S(4))/(S(30)*d**S(4)*e**S(2)*x**S(3)*sqrt(d - e*x)*sqrt(d + e*x)) - (d**S(2) - e**S(2)*x**S(2))*(S(8)*a*e**S(4) + S(10)*b*d**S(2)*e**S(2) + S(15)*c*d**S(4))/(S(15)*d**S(6)*x*sqrt(d - e*x)*sqrt(d + e*x)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((f*x)**m*(a + c*x**(S(2)*n))**p/(d + e*x**n), x), x, x*(f*x)**m*(S(1) + c*x**(S(2)*n)/a)**(-p)*(a + c*x**(S(2)*n))**p*AppellF1((m + S(1))/(S(2)*n), -p, S(1), S(1) + (m + S(1))/(S(2)*n), -c*x**(S(2)*n)/a, e**S(2)*x**(S(2)*n)/d**S(2))/(d*(m + S(1))) - e*x**(n + S(1))*(f*x)**m*(S(1) + c*x**(S(2)*n)/a)**(-p)*(a + c*x**(S(2)*n))**p*AppellF1((m + n + S(1))/(S(2)*n), -p, S(1), (m + S(3)*n + S(1))/(S(2)*n), -c*x**(S(2)*n)/a, e**S(2)*x**(S(2)*n)/d**S(2))/(d**S(2)*(m + n + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((f*x)**m*(a + c*x**(S(2)*n))**p/(d + e*x**n)**S(2), x), x, x*(f*x)**m*(S(1) + c*x**(S(2)*n)/a)**(-p)*(a + c*x**(S(2)*n))**p*AppellF1((m + S(1))/(S(2)*n), -p, S(2), S(1) + (m + S(1))/(S(2)*n), -c*x**(S(2)*n)/a, e**S(2)*x**(S(2)*n)/d**S(2))/(d**S(2)*(m + S(1))) - S(2)*e*x**(n + S(1))*(f*x)**m*(S(1) + c*x**(S(2)*n)/a)**(-p)*(a + c*x**(S(2)*n))**p*AppellF1((m + n + S(1))/(S(2)*n), -p, S(2), (m + S(3)*n + S(1))/(S(2)*n), -c*x**(S(2)*n)/a, e**S(2)*x**(S(2)*n)/d**S(2))/(d**S(3)*(m + n + S(1))) + e**S(2)*x**(S(2)*n + S(1))*(f*x)**m*(S(1) + c*x**(S(2)*n)/a)**(-p)*(a + c*x**(S(2)*n))**p*AppellF1((m + S(2)*n + S(1))/(S(2)*n), -p, S(2), (m + S(4)*n + S(1))/(S(2)*n), -c*x**(S(2)*n)/a, e**S(2)*x**(S(2)*n)/d**S(2))/(d**S(4)*(m + S(2)*n + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((f*x)**m*(a + c*x**(S(2)*n))**p/(d + e*x**n)**S(3), x), x, x*(f*x)**m*(S(1) + c*x**(S(2)*n)/a)**(-p)*(a + c*x**(S(2)*n))**p*AppellF1((m + S(1))/(S(2)*n), -p, S(3), S(1) + (m + S(1))/(S(2)*n), -c*x**(S(2)*n)/a, e**S(2)*x**(S(2)*n)/d**S(2))/(d**S(3)*(m + S(1))) - S(3)*e*x**(n + S(1))*(f*x)**m*(S(1) + c*x**(S(2)*n)/a)**(-p)*(a + c*x**(S(2)*n))**p*AppellF1((m + n + S(1))/(S(2)*n), -p, S(3), (m + S(3)*n + S(1))/(S(2)*n), -c*x**(S(2)*n)/a, e**S(2)*x**(S(2)*n)/d**S(2))/(d**S(4)*(m + n + S(1))) + S(3)*e**S(2)*x**(S(2)*n + S(1))*(f*x)**m*(S(1) + c*x**(S(2)*n)/a)**(-p)*(a + c*x**(S(2)*n))**p*AppellF1((m + S(2)*n + S(1))/(S(2)*n), -p, S(3), (m + S(4)*n + S(1))/(S(2)*n), -c*x**(S(2)*n)/a, e**S(2)*x**(S(2)*n)/d**S(2))/(d**S(5)*(m + S(2)*n + S(1))) - e**S(3)*x**(S(3)*n + S(1))*(f*x)**m*(S(1) + c*x**(S(2)*n)/a)**(-p)*(a + c*x**(S(2)*n))**p*AppellF1((m + S(3)*n + S(1))/(S(2)*n), -p, S(3), (m + S(5)*n + S(1))/(S(2)*n), -c*x**(S(2)*n)/a, e**S(2)*x**(S(2)*n)/d**S(2))/(d**S(6)*(m + S(3)*n + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((f*x)**m*(d + e*x**n)**S(2)*(a + b*x**n + c*x**(S(2)*n))**p, x), x, d**S(2)*(f*x)**(m + S(1))*(S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))**(-p)*(S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))**(-p)*(a + b*x**n + c*x**(S(2)*n))**p*AppellF1((m + S(1))/n, -p, -p, (m + n + S(1))/n, -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(f*(m + S(1))) + S(2)*d*e*x**(n + S(1))*(f*x)**m*(S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))**(-p)*(S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))**(-p)*(a + b*x**n + c*x**(S(2)*n))**p*AppellF1((m + n + S(1))/n, -p, -p, (m + S(2)*n + S(1))/n, -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(m + n + S(1)) + e**S(2)*x**(S(2)*n + S(1))*(f*x)**m*(S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))**(-p)*(S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))**(-p)*(a + b*x**n + c*x**(S(2)*n))**p*AppellF1((m + S(2)*n + S(1))/n, -p, -p, (m + S(3)*n + S(1))/n, -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(m + S(2)*n + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((f*x)**m*(d + e*x**n)*(a + b*x**n + c*x**(S(2)*n))**p, x), x, d*(f*x)**(m + S(1))*(S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))**(-p)*(S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))**(-p)*(a + b*x**n + c*x**(S(2)*n))**p*AppellF1((m + S(1))/n, -p, -p, (m + n + S(1))/n, -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(f*(m + S(1))) + e*x**(n + S(1))*(f*x)**m*(S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))**(-p)*(S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))**(-p)*(a + b*x**n + c*x**(S(2)*n))**p*AppellF1((m + n + S(1))/n, -p, -p, (m + S(2)*n + S(1))/n, -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(m + n + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((f*x)**m*(a + b*x**n + c*x**(S(2)*n))**p, x), x, (f*x)**(m + S(1))*(S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))**(-p)*(S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))**(-p)*(a + b*x**n + c*x**(S(2)*n))**p*AppellF1((m + S(1))/n, -p, -p, (m + n + S(1))/n, -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(f*(m + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((f*x)**m*(d + e*x**n)**q/(a + b*x**n + c*x**(S(2)*n)), x), x, -S(2)*c*(f*x)**(m + S(1))*(S(1) + e*x**n/d)**(-q)*(d + e*x**n)**q*AppellF1((m + S(1))/n, S(1), -q, (m + n + S(1))/n, -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))), -e*x**n/d)/(f*(b + sqrt(-S(4)*a*c + b**S(2)))*(m + S(1))*sqrt(-S(4)*a*c + b**S(2))) + S(2)*c*(f*x)**(m + S(1))*(S(1) + e*x**n/d)**(-q)*(d + e*x**n)**q*AppellF1((m + S(1))/n, S(1), -q, (m + n + S(1))/n, -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))), -e*x**n/d)/(f*(b - sqrt(-S(4)*a*c + b**S(2)))*(m + S(1))*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(d + e*x**n)**q/(a + b*x**n + c*x**(S(2)*n)), x), x, -S(2)*c*x**S(3)*(S(1) + e*x**n/d)**(-q)*(d + e*x**n)**q*AppellF1(S(3)/n, S(1), -q, (n + S(3))/n, -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))), -e*x**n/d)/(-S(12)*a*c + S(3)*b**S(2) + S(3)*b*sqrt(-S(4)*a*c + b**S(2))) - S(2)*c*x**S(3)*(S(1) + e*x**n/d)**(-q)*(d + e*x**n)**q*AppellF1(S(3)/n, S(1), -q, (n + S(3))/n, -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))), -e*x**n/d)/(-S(12)*a*c + S(3)*b**S(2) - S(3)*b*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(d + e*x**n)**q/(a + b*x**n + c*x**(S(2)*n)), x), x, -c*x**S(2)*(S(1) + e*x**n/d)**(-q)*(d + e*x**n)**q*AppellF1(S(2)/n, S(1), -q, (n + S(2))/n, -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))), -e*x**n/d)/(-S(4)*a*c + b**S(2) + b*sqrt(-S(4)*a*c + b**S(2))) - c*x**S(2)*(S(1) + e*x**n/d)**(-q)*(d + e*x**n)**q*AppellF1(S(2)/n, S(1), -q, (n + S(2))/n, -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))), -e*x**n/d)/(-S(4)*a*c + b**S(2) - b*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**n)**q/(a + b*x**n + c*x**(S(2)*n)), x), x, -S(2)*c*x*(S(1) + e*x**n/d)**(-q)*(d + e*x**n)**q*AppellF1(S(1)/n, S(1), -q, S(1) + S(1)/n, -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))), -e*x**n/d)/(-S(4)*a*c + b**S(2) + b*sqrt(-S(4)*a*c + b**S(2))) - S(2)*c*x*(S(1) + e*x**n/d)**(-q)*(d + e*x**n)**q*AppellF1(S(1)/n, S(1), -q, S(1) + S(1)/n, -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))), -e*x**n/d)/(-S(4)*a*c + b**S(2) - b*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**n)**q/(x**S(2)*(a + b*x**n + c*x**(S(2)*n))), x), x, S(2)*c*(S(1) + e*x**n/d)**(-q)*(d + e*x**n)**q*AppellF1(-S(1)/n, S(1), -q, -(-n + S(1))/n, -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))), -e*x**n/d)/(x*(-S(4)*a*c + b**S(2) + b*sqrt(-S(4)*a*c + b**S(2)))) + S(2)*c*(S(1) + e*x**n/d)**(-q)*(d + e*x**n)**q*AppellF1(-S(1)/n, S(1), -q, -(-n + S(1))/n, -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))), -e*x**n/d)/(x*(-S(4)*a*c + b**S(2) - b*sqrt(-S(4)*a*c + b**S(2)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x**n)**q/(x**S(3)*(a + b*x**n + c*x**(S(2)*n))), x), x, c*(S(1) + e*x**n/d)**(-q)*(d + e*x**n)**q*AppellF1(-S(2)/n, S(1), -q, -(-n + S(2))/n, -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))), -e*x**n/d)/(x**S(2)*(-S(4)*a*c + b**S(2) + b*sqrt(-S(4)*a*c + b**S(2)))) + c*(S(1) + e*x**n/d)**(-q)*(d + e*x**n)**q*AppellF1(-S(2)/n, S(1), -q, -(-n + S(2))/n, -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))), -e*x**n/d)/(x**S(2)*(-S(4)*a*c + b**S(2) - b*sqrt(-S(4)*a*c + b**S(2)))), expand=True, _diff=True, _numerical=True)
def test_4():
assert rubi_test(rubi_integrate((x**S(3) + x**S(2))/(x**S(2) + x + S(-2)), x), x, x**S(2)/S(2) + S(2)*log(-x + S(1))/S(3) + S(4)*log(x + S(2))/S(3), expand=True, _diff=True, _numerical=True)
# Large time assert rubi_test(rubi_integrate((d + e*x + f*x**S(2) + g*x**S(3) + h*x**S(4) + j*x**S(5) + k*x**S(6) + l*x**S(7) + m*x**S(8))/(a + b*x + c*x**S(2)), x), x, m*x**S(7)/(S(7)*c) + x**S(6)*(-b*m + c*l)/(S(6)*c**S(2)) + x**S(5)*(b**S(2)*m + c**S(2)*k - c*(a*m + b*l))/(S(5)*c**S(3)) + x**S(4)*(-b**S(3)*m + b*c*(S(2)*a*m + b*l) + c**S(3)*j - c**S(2)*(a*l + b*k))/(S(4)*c**S(4)) + x**S(3)*(b**S(4)*m - b**S(2)*c*(S(3)*a*m + b*l) + c**S(4)*h - c**S(3)*(a*k + b*j) + c**S(2)*(a**S(2)*m + S(2)*a*b*l + b**S(2)*k))/(S(3)*c**S(5)) + x**S(2)*(-b**S(5)*m + b**S(3)*c*(S(4)*a*m + b*l) - b*c**S(2)*(S(3)*a**S(2)*m + S(3)*a*b*l + b**S(2)*k) + c**S(5)*g - c**S(4)*(a*j + b*h) + c**S(3)*(a**S(2)*l + S(2)*a*b*k + b**S(2)*j))/(S(2)*c**S(6)) + x*(b**S(6)*m - b**S(4)*c*(S(5)*a*m + b*l) + b**S(2)*c**S(2)*(S(6)*a**S(2)*m + S(4)*a*b*l + b**S(2)*k) + c**S(6)*f - c**S(5)*(a*h + b*g) + c**S(4)*(a**S(2)*k + S(2)*a*b*j + b**S(2)*h) - c**S(3)*(a**S(3)*m + S(3)*a**S(2)*b*l + S(3)*a*b**S(2)*k + b**S(3)*j))/c**S(7) + (-b**S(7)*m + b**S(5)*c*(S(6)*a*m + b*l) - b**S(3)*c**S(2)*(S(10)*a**S(2)*m + S(5)*a*b*l + b**S(2)*k) + b*c**S(3)*(S(4)*a**S(3)*m + S(6)*a**S(2)*b*l + S(4)*a*b**S(2)*k + b**S(3)*j) + c**S(7)*e - c**S(6)*(a*g + b*f) + c**S(5)*(a**S(2)*j + S(2)*a*b*h + b**S(2)*g) - c**S(4)*(a**S(3)*l + S(3)*a**S(2)*b*k + S(3)*a*b**S(2)*j + b**S(3)*h))*log(a + b*x + c*x**S(2))/(S(2)*c**S(8)) - (b**S(8)*m - b**S(6)*c*(S(8)*a*m + b*l) + b**S(4)*c**S(2)*(S(20)*a**S(2)*m + S(7)*a*b*l + b**S(2)*k) - b**S(2)*c**S(3)*(S(16)*a**S(3)*m + S(14)*a**S(2)*b*l + S(6)*a*b**S(2)*k + b**S(3)*j) + S(2)*c**S(8)*d - c**S(7)*(S(2)*a*f + b*e) + c**S(6)*(S(2)*a**S(2)*h + S(3)*a*b*g + b**S(2)*f) - c**S(5)*(S(2)*a**S(3)*k + S(5)*a**S(2)*b*j + S(4)*a*b**S(2)*h + b**S(3)*g) + c**S(4)*(S(2)*a**S(4)*m + S(7)*a**S(3)*b*l + S(9)*a**S(2)*b**S(2)*k + S(5)*a*b**S(3)*j + b**S(4)*h))*atanh((b + S(2)*c*x)/sqrt(-S(4)*a*c + b**S(2)))/(c**S(8)*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*x**S(2) + g*x**S(3))/(a + b*x + c*x**S(2))**S(2), x), x, g*log(a + b*x + c*x**S(2))/(S(2)*c**S(2)) - (-a*b**S(2)*g - S(2)*a*c*(-a*g + c*e) + b*c*(a*f + c*d) + x*(-b**S(3)*g + b*c*(S(3)*a*g + b*f) + S(2)*c**S(3)*d - c**S(2)*(S(2)*a*f + b*e)))/(c**S(2)*(-S(4)*a*c + b**S(2))*(a + b*x + c*x**S(2))) + (-S(6)*a*b*c*g + b**S(3)*g + S(4)*c**S(3)*d - c**S(2)*(-S(4)*a*f + S(2)*b*e))*atanh((b + S(2)*c*x)/sqrt(-S(4)*a*c + b**S(2)))/(c**S(2)*(-S(4)*a*c + b**S(2))**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*x**S(2) + g*x**S(3) + h*x**S(4) + i*x**S(5))/(a + b*x + c*x**S(2))**S(3), x), x, -x**S(3)*(-S(5)*b*i + S(2)*c*h)/(S(2)*c**S(2)*(a + b*x + c*x**S(2))**S(2)) + i*log(a + b*x + c*x**S(2))/(S(2)*c**S(3)) - x**S(2)*(-S(4)*a*c*i - S(9)*b**S(2)*i + S(2)*b*c*h + S(2)*c**S(2)*g)/(S(4)*c**S(3)*(a + b*x + c*x**S(2))**S(2)) - (-S(30)*a**S(2)*b*c**S(2)*i + S(10)*a*b**S(3)*c*i - b**S(5)*i + S(12)*c**S(5)*d - c**S(4)*(-S(4)*a*f + S(6)*b*e) + S(2)*c**S(3)*(S(6)*a**S(2)*h - S(3)*a*b*g + b**S(2)*f))*atanh((b + S(2)*c*x)/sqrt(-S(4)*a*c + b**S(2)))/(c**S(3)*(-S(4)*a*c + b**S(2))**(S(5)/2)) + (b + S(2)*c*x)*(-S(30)*a**S(2)*b*c**S(2)*i + S(10)*a*b**S(3)*c*i - b**S(5)*i + S(12)*c**S(5)*d - c**S(4)*(-S(4)*a*f + S(6)*b*e) + S(2)*c**S(3)*(S(6)*a**S(2)*h - S(3)*a*b*g + b**S(2)*f))/(S(4)*c**S(4)*(-S(4)*a*c + b**S(2))**S(2)*(a + b*x + c*x**S(2))) - (c**S(3)*(-a*b**S(4)*i/c**S(3) - S(4)*a*(-S(3)*a**S(2)*i/c + a*g + c*e) + S(2)*b*(a**S(2)*h/c + a*f + c*d)) + x*(-S(8)*a*b**S(3)*c*i + S(2)*a*b*c**S(2)*(S(23)*a*i + S(2)*b*h) - b**S(5)*i + S(4)*c**S(5)*d - S(2)*c**S(4)*(S(2)*a*f + b*e) + S(2)*c**S(3)*(-S(6)*a**S(2)*h - a*b*g + b**S(2)*f)))/(S(4)*c**S(4)*(-S(4)*a*c + b**S(2))*(a + b*x + c*x**S(2))**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*x**S(2) + g*x**S(3) + h*x**S(4))/(a + b*x + c*x**S(2))**(S(5)/2), x), x, -x**S(2)*(-S(2)*b*h + c*g)/(c**S(2)*(a + b*x + c*x**S(2))**(S(3)/2)) + (b + S(2)*c*x)*(-S(4)*b**S(4)*h + b**S(2)*c*(S(28)*a*h + b*g) + S(16)*c**S(4)*d - c**S(3)*(-S(8)*a*f + S(8)*b*e) + S(2)*c**S(2)*(-S(16)*a**S(2)*h - S(6)*a*b*g + b**S(2)*f))/(S(3)*c**S(3)*(-S(4)*a*c + b**S(2))**S(2)*sqrt(a + b*x + c*x**S(2))) - (c**S(2)*(-S(4)*a*b**S(3)*h/c**S(2) + a*b**S(2)*g/c - S(4)*a*(S(2)*a*g + c*e) + S(2)*b*(S(9)*a**S(2)*h/c + a*f + c*d)) + x*(-S(4)*b**S(4)*h + b**S(2)*c*(S(16)*a*h + b*g) + S(4)*c**S(4)*d - S(2)*c**S(3)*(S(2)*a*f + b*e) + S(2)*c**S(2)*(S(2)*a**S(2)*h - S(3)*a*b*g + b**S(2)*f)))/(S(3)*c**S(3)*(-S(4)*a*c + b**S(2))*(a + b*x + c*x**S(2))**(S(3)/2)) + h*atanh((b + S(2)*c*x)/(S(2)*sqrt(c)*sqrt(a + b*x + c*x**S(2))))/c**(S(5)/2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*x**S(2) + g*x**S(3) + h*x**S(4))/(a + b*x - c*x**S(2))**(S(5)/2), x), x, x**S(2)*(S(2)*b*h + c*g)/(c**S(2)*(a + b*x - c*x**S(2))**(S(3)/2)) - (b - S(2)*c*x)*(-S(4)*b**S(4)*h - b**S(2)*c*(S(28)*a*h + b*g) + S(16)*c**S(4)*d + S(8)*c**S(3)*(-a*f + b*e) + S(2)*c**S(2)*(-S(16)*a**S(2)*h - S(6)*a*b*g + b**S(2)*f))/(S(3)*c**S(3)*(S(4)*a*c + b**S(2))**S(2)*sqrt(a + b*x - c*x**S(2))) - (c**S(2)*(S(4)*a*b**S(3)*h/c**S(2) + a*b**S(2)*g/c - S(4)*a*(-S(2)*a*g + c*e) + S(2)*b*(S(9)*a**S(2)*h/c - a*f + c*d)) - x*(-S(4)*b**S(4)*h - b**S(2)*c*(S(16)*a*h + b*g) + S(4)*c**S(4)*d + S(2)*c**S(3)*(S(2)*a*f + b*e) + S(2)*c**S(2)*(S(2)*a**S(2)*h - S(3)*a*b*g + b**S(2)*f)))/(S(3)*c**S(3)*(S(4)*a*c + b**S(2))*(a + b*x - c*x**S(2))**(S(3)/2)) - h*atan((b - S(2)*c*x)/(S(2)*sqrt(c)*sqrt(a + b*x - c*x**S(2))))/c**(S(5)/2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x)*(a + b*x**S(2) + c*x**S(4)), x), x, a*d*x + a*e*x**S(2)/S(2) + b*d*x**S(3)/S(3) + b*e*x**S(4)/S(4) + c*d*x**S(5)/S(5) + c*e*x**S(6)/S(6), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))*(d + e*x + f*x**S(2)), x), x, a*d*x + a*e*x**S(2)/S(2) + b*e*x**S(4)/S(4) + c*e*x**S(6)/S(6) + c*f*x**S(7)/S(7) + x**S(5)*(b*f/S(5) + c*d/S(5)) + x**S(3)*(a*f/S(3) + b*d/S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))*(d + e*x + f*x**S(2) + g*x**S(3)), x), x, a*d*x + a*e*x**S(2)/S(2) + c*f*x**S(7)/S(7) + c*g*x**S(8)/S(8) + x**S(6)*(b*g/S(6) + c*e/S(6)) + x**S(5)*(b*f/S(5) + c*d/S(5)) + x**S(4)*(a*g/S(4) + b*e/S(4)) + x**S(3)*(a*f/S(3) + b*d/S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))*(d + e*x + f*x**S(2) + g*x**S(3) + h*x**S(4)), x), x, a*d*x + a*e*x**S(2)/S(2) + c*g*x**S(8)/S(8) + c*h*x**S(9)/S(9) + x**S(7)*(b*h/S(7) + c*f/S(7)) + x**S(6)*(b*g/S(6) + c*e/S(6)) + x**S(5)*(a*h/S(5) + b*f/S(5) + c*d/S(5)) + x**S(4)*(a*g/S(4) + b*e/S(4)) + x**S(3)*(a*f/S(3) + b*d/S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))*(d + e*x + f*x**S(2) + g*x**S(3) + h*x**S(4) + i*x**S(5)), x), x, a*d*x + a*e*x**S(2)/S(2) + c*h*x**S(9)/S(9) + c*i*x**S(10)/S(10) + x**S(8)*(b*i/S(8) + c*g/S(8)) + x**S(7)*(b*h/S(7) + c*f/S(7)) + x**S(6)*(a*i/S(6) + b*g/S(6) + c*e/S(6)) + x**S(5)*(a*h/S(5) + b*f/S(5) + c*d/S(5)) + x**S(4)*(a*g/S(4) + b*e/S(4)) + x**S(3)*(a*f/S(3) + b*d/S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x)*(a + b*x**S(2) + c*x**S(4))**S(2), x), x, a**S(2)*d*x + a**S(2)*e*x**S(2)/S(2) + S(2)*a*b*d*x**S(3)/S(3) + a*b*e*x**S(4)/S(2) + S(2)*b*c*d*x**S(7)/S(7) + b*c*e*x**S(8)/S(4) + c**S(2)*d*x**S(9)/S(9) + c**S(2)*e*x**S(10)/S(10) + d*x**S(5)*(S(2)*a*c/S(5) + b**S(2)/S(5)) + e*x**S(6)*(a*c/S(3) + b**S(2)/S(6)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))**S(2)*(d + e*x + f*x**S(2)), x), x, a**S(2)*d*x + a**S(2)*e*x**S(2)/S(2) + a*b*e*x**S(4)/S(2) + a*x**S(3)*(a*f + S(2)*b*d)/S(3) + b*c*e*x**S(8)/S(4) + c**S(2)*e*x**S(10)/S(10) + c**S(2)*f*x**S(11)/S(11) + c*x**S(9)*(S(2)*b*f + c*d)/S(9) + e*x**S(6)*(a*c/S(3) + b**S(2)/S(6)) + x**S(7)*(S(2)*a*c*f/S(7) + b**S(2)*f/S(7) + S(2)*b*c*d/S(7)) + x**S(5)*(S(2)*a*b*f/S(5) + S(2)*a*c*d/S(5) + b**S(2)*d/S(5)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))**S(2)*(d + e*x + f*x**S(2) + g*x**S(3)), x), x, a**S(2)*d*x + a**S(2)*e*x**S(2)/S(2) + a*x**S(4)*(a*g + S(2)*b*e)/S(4) + a*x**S(3)*(a*f + S(2)*b*d)/S(3) + c**S(2)*f*x**S(11)/S(11) + c**S(2)*g*x**S(12)/S(12) + c*x**S(10)*(S(2)*b*g + c*e)/S(10) + c*x**S(9)*(S(2)*b*f + c*d)/S(9) + x**S(8)*(a*c*g/S(4) + b**S(2)*g/S(8) + b*c*e/S(4)) + x**S(7)*(S(2)*a*c*f/S(7) + b**S(2)*f/S(7) + S(2)*b*c*d/S(7)) + x**S(6)*(a*b*g/S(3) + a*c*e/S(3) + b**S(2)*e/S(6)) + x**S(5)*(S(2)*a*b*f/S(5) + S(2)*a*c*d/S(5) + b**S(2)*d/S(5)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))**S(2)*(d + e*x + f*x**S(2) + g*x**S(3) + h*x**S(4)), x), x, a**S(2)*d*x + a**S(2)*e*x**S(2)/S(2) + a*x**S(4)*(a*g + S(2)*b*e)/S(4) + a*x**S(3)*(a*f + S(2)*b*d)/S(3) + c**S(2)*g*x**S(12)/S(12) + c**S(2)*h*x**S(13)/S(13) + c*x**S(11)*(S(2)*b*h + c*f)/S(11) + c*x**S(10)*(S(2)*b*g + c*e)/S(10) + x**S(9)*(b**S(2)*h/S(9) + c**S(2)*d/S(9) + S(2)*c*(a*h + b*f)/S(9)) + x**S(8)*(a*c*g/S(4) + b**S(2)*g/S(8) + b*c*e/S(4)) + x**S(7)*(S(2)*a*c*f/S(7) + b**S(2)*f/S(7) + S(2)*b*(a*h + c*d)/S(7)) + x**S(6)*(a*b*g/S(3) + a*c*e/S(3) + b**S(2)*e/S(6)) + x**S(5)*(S(2)*a*b*f/S(5) + a*(a*h + S(2)*c*d)/S(5) + b**S(2)*d/S(5)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x)/(x**S(4) - S(5)*x**S(2) + S(4)), x), x, -d*atanh(x/S(2))/S(6) + d*atanh(x)/S(3) - e*log(-x**S(2) + S(1))/S(6) + e*log(-x**S(2) + S(4))/S(6), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*x**S(2))/(x**S(4) - S(5)*x**S(2) + S(4)), x), x, -e*log(-x**S(2) + S(1))/S(6) + e*log(-x**S(2) + S(4))/S(6) + (-d/S(6) - S(2)*f/S(3))*atanh(x/S(2)) + (d/S(3) + f/S(3))*atanh(x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*x**S(2) + g*x**S(3))/(x**S(4) - S(5)*x**S(2) + S(4)), x), x, (-d/S(6) - S(2)*f/S(3))*atanh(x/S(2)) + (d/S(3) + f/S(3))*atanh(x) - (e/S(6) + g/S(6))*log(-x**S(2) + S(1)) + (e/S(6) + S(2)*g/S(3))*log(-x**S(2) + S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*x**S(2) + g*x**S(3) + h*x**S(4))/(x**S(4) - S(5)*x**S(2) + S(4)), x), x, h*x - (e/S(6) + g/S(6))*log(-x**S(2) + S(1)) + (e/S(6) + S(2)*g/S(3))*log(-x**S(2) + S(4)) - (d/S(6) + S(2)*f/S(3) + S(8)*h/S(3))*atanh(x/S(2)) + (d/S(3) + f/S(3) + h/S(3))*atanh(x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*x**S(2) + g*x**S(3) + h*x**S(4) + i*x**S(5))/(x**S(4) - S(5)*x**S(2) + S(4)), x), x, h*x + i*x**S(2)/S(2) - (d/S(6) + S(2)*f/S(3) + S(8)*h/S(3))*atanh(x/S(2)) + (d/S(3) + f/S(3) + h/S(3))*atanh(x) - (e/S(6) + g/S(6) + i/S(6))*log(-x**S(2) + S(1)) + (e/S(6) + S(2)*g/S(3) + S(8)*i/S(3))*log(-x**S(2) + S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x)/(x**S(4) + x**S(2) + S(1)), x), x, -d*log(x**S(2) - x + S(1))/S(4) + d*log(x**S(2) + x + S(1))/S(4) - sqrt(S(3))*d*atan(sqrt(S(3))*(-S(2)*x + S(1))/S(3))/S(6) + sqrt(S(3))*d*atan(sqrt(S(3))*(S(2)*x + S(1))/S(3))/S(6) + sqrt(S(3))*e*atan(sqrt(S(3))*(S(2)*x**S(2) + S(1))/S(3))/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*x**S(2))/(x**S(4) + x**S(2) + S(1)), x), x, sqrt(S(3))*e*atan(sqrt(S(3))*(S(2)*x**S(2) + S(1))/S(3))/S(3) - (d/S(4) - f/S(4))*log(x**S(2) - x + S(1)) + (d/S(4) - f/S(4))*log(x**S(2) + x + S(1)) - sqrt(S(3))*(d + f)*atan(sqrt(S(3))*(-S(2)*x + S(1))/S(3))/S(6) + sqrt(S(3))*(d + f)*atan(sqrt(S(3))*(S(2)*x + S(1))/S(3))/S(6), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*x**S(2) + g*x**S(3))/(x**S(4) + x**S(2) + S(1)), x), x, g*log(x**S(4) + x**S(2) + S(1))/S(4) - (d/S(4) - f/S(4))*log(x**S(2) - x + S(1)) + (d/S(4) - f/S(4))*log(x**S(2) + x + S(1)) - sqrt(S(3))*(d + f)*atan(sqrt(S(3))*(-S(2)*x + S(1))/S(3))/S(6) + sqrt(S(3))*(d + f)*atan(sqrt(S(3))*(S(2)*x + S(1))/S(3))/S(6) + sqrt(S(3))*(S(2)*e - g)*atan(sqrt(S(3))*(S(2)*x**S(2) + S(1))/S(3))/S(6), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*x**S(2) + g*x**S(3) + h*x**S(4))/(x**S(4) + x**S(2) + S(1)), x), x, g*log(x**S(4) + x**S(2) + S(1))/S(4) + h*x - (d/S(4) - f/S(4))*log(x**S(2) - x + S(1)) + (d/S(4) - f/S(4))*log(x**S(2) + x + S(1)) + sqrt(S(3))*(S(2)*e - g)*atan(sqrt(S(3))*(S(2)*x**S(2) + S(1))/S(3))/S(6) - sqrt(S(3))*(d + f - S(2)*h)*atan(sqrt(S(3))*(-S(2)*x + S(1))/S(3))/S(6) + sqrt(S(3))*(d + f - S(2)*h)*atan(sqrt(S(3))*(S(2)*x + S(1))/S(3))/S(6), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*x**S(2) + g*x**S(3) + h*x**S(4) + i*x**S(5))/(x**S(4) + x**S(2) + S(1)), x), x, h*x + i*x**S(2)/S(2) - (d/S(4) - f/S(4))*log(x**S(2) - x + S(1)) + (d/S(4) - f/S(4))*log(x**S(2) + x + S(1)) + (g/S(4) - i/S(4))*log(x**S(4) + x**S(2) + S(1)) - sqrt(S(3))*(d + f - S(2)*h)*atan(sqrt(S(3))*(-S(2)*x + S(1))/S(3))/S(6) + sqrt(S(3))*(d + f - S(2)*h)*atan(sqrt(S(3))*(S(2)*x + S(1))/S(3))/S(6) + sqrt(S(3))*(S(2)*e - g - i)*atan(sqrt(S(3))*(S(2)*x**S(2) + S(1))/S(3))/S(6), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x)/(a + b*x**S(2) + c*x**S(4)), x), x, -sqrt(S(2))*sqrt(c)*d*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*sqrt(-S(4)*a*c + b**S(2))) + sqrt(S(2))*sqrt(c)*d*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*sqrt(-S(4)*a*c + b**S(2))) - e*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/sqrt(-S(4)*a*c + b**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*x**S(2))/(a + b*x**S(2) + c*x**S(4)), x), x, -e*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/sqrt(-S(4)*a*c + b**S(2)) + sqrt(S(2))*(f - (-b*f + S(2)*c*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*sqrt(c)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))) + sqrt(S(2))*(f + (-b*f + S(2)*c*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*sqrt(c)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*x**S(2) + g*x**S(3))/(a + b*x**S(2) + c*x**S(4)), x), x, g*log(a + b*x**S(2) + c*x**S(4))/(S(4)*c) - (-b*g + S(2)*c*e)*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*c*sqrt(-S(4)*a*c + b**S(2))) + sqrt(S(2))*(f - (-b*f + S(2)*c*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*sqrt(c)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))) + sqrt(S(2))*(f + (-b*f + S(2)*c*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*sqrt(c)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*x**S(2) + g*x**S(3) + h*x**S(4))/(a + b*x**S(2) + c*x**S(4)), x), x, g*log(a + b*x**S(2) + c*x**S(4))/(S(4)*c) + h*x/c - (-b*g + S(2)*c*e)*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*c*sqrt(-S(4)*a*c + b**S(2))) + sqrt(S(2))*(-b*h/c + f - (-S(2)*a*c*h + b**S(2)*h - b*c*f + S(2)*c**S(2)*d)/(c*sqrt(-S(4)*a*c + b**S(2))))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*sqrt(c)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))) + sqrt(S(2))*(-b*h/c + f + (b**S(2)*h + S(2)*c**S(2)*d - c*(S(2)*a*h + b*f))/(c*sqrt(-S(4)*a*c + b**S(2))))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*sqrt(c)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*x**S(2) + g*x**S(3) + h*x**S(4) + i*x**S(5))/(a + b*x**S(2) + c*x**S(4)), x), x, h*x/c + i*x**S(2)/(S(2)*c) + (-b*i + c*g)*log(a + b*x**S(2) + c*x**S(4))/(S(4)*c**S(2)) - (-S(2)*a*c*i + b**S(2)*i - b*c*g + S(2)*c**S(2)*e)*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*c**S(2)*sqrt(-S(4)*a*c + b**S(2))) + sqrt(S(2))*(-b*h/c + f - (-S(2)*a*c*h + b**S(2)*h - b*c*f + S(2)*c**S(2)*d)/(c*sqrt(-S(4)*a*c + b**S(2))))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*sqrt(c)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))) + sqrt(S(2))*(-b*h/c + f + (b**S(2)*h + S(2)*c**S(2)*d - c*(S(2)*a*h + b*f))/(c*sqrt(-S(4)*a*c + b**S(2))))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*sqrt(c)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))), expand=True, _diff=True, _numerical=True)
# failing assert rubi_test(rubi_integrate((d + e*x + f*x**S(2) + g*x**S(3) + h*x**S(4) + j*x**S(5) + k*x**S(6) + l*x**S(7) + m*x**S(8))/(a + b*x**S(2) + c*x**S(4)), x), x, l*x**S(4)/(S(4)*c) + m*x**S(5)/(S(5)*c) + x**S(3)*(-b*m + c*k)/(S(3)*c**S(2)) + x**S(2)*(-b*l + c*j)/(S(2)*c**S(2)) + x*(b**S(2)*m + c**S(2)*h - c*(a*m + b*k))/c**S(3) + (b**S(2)*l + c**S(2)*g - c*(a*l + b*j))*log(a + b*x**S(2) + c*x**S(4))/(S(4)*c**S(3)) - (-b**S(3)*l + b*c*(S(3)*a*l + b*j) + S(2)*c**S(3)*e - c**S(2)*(S(2)*a*j + b*g))*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*c**S(3)*sqrt(-S(4)*a*c + b**S(2))) + sqrt(S(2))*(S(2)*a*b*m/c**S(2) - a*k/c - b**S(3)*m/c**S(3) + b**S(2)*k/c**S(2) - b*h/c + f - (b**S(4)*m - b**S(2)*c*(S(4)*a*m + b*k) + S(2)*c**S(4)*d - c**S(3)*(S(2)*a*h + b*f) + c**S(2)*(S(2)*a**S(2)*m + S(3)*a*b*k + b**S(2)*h))/(c**S(3)*sqrt(-S(4)*a*c + b**S(2))))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*sqrt(c)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))) + sqrt(S(2))*(S(2)*a*b*m/c**S(2) - a*k/c - b**S(3)*m/c**S(3) + b**S(2)*k/c**S(2) - b*h/c + f + (b**S(4)*m - b**S(2)*c*(S(4)*a*m + b*k) + S(2)*c**S(4)*d - c**S(3)*(S(2)*a*h + b*f) + c**S(2)*(S(2)*a**S(2)*m + S(3)*a*b*k + b**S(2)*h))/(c**S(3)*sqrt(-S(4)*a*c + b**S(2))))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*sqrt(c)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x)/(x**S(4) - S(5)*x**S(2) + S(4))**S(2), x), x, S(19)*d*atanh(x/S(2))/S(432) - d*atanh(x)/S(54) + e*log(-x**S(2) + S(1))/S(27) - e*log(-x**S(2) + S(4))/S(27) + x*(-S(5)*d*x**S(2) + S(17)*d - S(5)*e*x**S(3) + S(17)*e*x)/(S(72)*x**S(4) - S(360)*x**S(2) + S(288)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*x**S(2))/(x**S(4) - S(5)*x**S(2) + S(4))**S(2), x), x, e*log(-x**S(2) + S(1))/S(27) - e*log(-x**S(2) + S(4))/S(27) + x*(S(17)*d - S(5)*e*x**S(3) + S(17)*e*x + S(20)*f - x**S(2)*(S(5)*d + S(8)*f))/(S(72)*x**S(4) - S(360)*x**S(2) + S(288)) - (d/S(54) + S(7)*f/S(54))*atanh(x) + (S(19)*d/S(432) + S(13)*f/S(108))*atanh(x/S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*x**S(2) + g*x**S(3))/(x**S(4) - S(5)*x**S(2) + S(4))**S(2), x), x, x*(S(17)*d + S(20)*f - x**S(3)*(S(5)*e + S(8)*g) - x**S(2)*(S(5)*d + S(8)*f) + x*(S(17)*e + S(20)*g))/(S(72)*x**S(4) - S(360)*x**S(2) + S(288)) - (d/S(54) + S(7)*f/S(54))*atanh(x) + (S(19)*d/S(432) + S(13)*f/S(108))*atanh(x/S(2)) + (e/S(27) + S(5)*g/S(54))*log(-x**S(2) + S(1)) - (e/S(27) + S(5)*g/S(54))*log(-x**S(2) + S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*x**S(2) + g*x**S(3) + h*x**S(4))/(x**S(4) - S(5)*x**S(2) + S(4))**S(2), x), x, x*(S(17)*d + S(20)*f + S(32)*h - x**S(3)*(S(5)*e + S(8)*g) - x**S(2)*(S(5)*d + S(8)*f + S(20)*h) + x*(S(17)*e + S(20)*g))/(S(72)*x**S(4) - S(360)*x**S(2) + S(288)) + (e/S(27) + S(5)*g/S(54))*log(-x**S(2) + S(1)) - (e/S(27) + S(5)*g/S(54))*log(-x**S(2) + S(4)) - (d/S(54) + S(7)*f/S(54) + S(13)*h/S(54))*atanh(x) + (S(19)*d/S(432) + S(13)*f/S(108) + S(7)*h/S(27))*atanh(x/S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*x**S(2) + g*x**S(3) + h*x**S(4) + i*x**S(5))/(x**S(4) - S(5)*x**S(2) + S(4))**S(2), x), x, x*(S(17)*d + S(20)*f + S(32)*h - x**S(3)*(S(5)*e + S(8)*g + S(20)*i) - x**S(2)*(S(5)*d + S(8)*f + S(20)*h) + x*(S(17)*e + S(20)*g + S(32)*i))/(S(72)*x**S(4) - S(360)*x**S(2) + S(288)) - (d/S(54) + S(7)*f/S(54) + S(13)*h/S(54))*atanh(x) + (S(19)*d/S(432) + S(13)*f/S(108) + S(7)*h/S(27))*atanh(x/S(2)) + (e/S(27) + S(5)*g/S(54) + S(4)*i/S(27))*log(-x**S(2) + S(1)) - (e/S(27) + S(5)*g/S(54) + S(4)*i/S(27))*log(-x**S(2) + S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x)/(x**S(4) + x**S(2) + S(1))**S(2), x), x, -d*log(x**S(2) - x + S(1))/S(4) + d*log(x**S(2) + x + S(1))/S(4) - sqrt(S(3))*d*atan(sqrt(S(3))*(-S(2)*x + S(1))/S(3))/S(9) + sqrt(S(3))*d*atan(sqrt(S(3))*(S(2)*x + S(1))/S(3))/S(9) + S(2)*sqrt(S(3))*e*atan(sqrt(S(3))*(S(2)*x**S(2) + S(1))/S(3))/S(9) + x*(-d*x**S(2) + d - e*x**S(3) + e*x)/(S(6)*x**S(4) + S(6)*x**S(2) + S(6)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*x**S(2))/(x**S(4) + x**S(2) + S(1))**S(2), x), x, S(2)*sqrt(S(3))*e*atan(sqrt(S(3))*(S(2)*x**S(2) + S(1))/S(3))/S(9) + x*(d - e*x**S(3) + e*x + f - x**S(2)*(d - S(2)*f))/(S(6)*x**S(4) + S(6)*x**S(2) + S(6)) - (d/S(4) - f/S(8))*log(x**S(2) - x + S(1)) + (d/S(4) - f/S(8))*log(x**S(2) + x + S(1)) - sqrt(S(3))*(S(4)*d + f)*atan(sqrt(S(3))*(-S(2)*x + S(1))/S(3))/S(36) + sqrt(S(3))*(S(4)*d + f)*atan(sqrt(S(3))*(S(2)*x + S(1))/S(3))/S(36), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*x**S(2) + g*x**S(3))/(x**S(4) + x**S(2) + S(1))**S(2), x), x, x*(d + f - x**S(3)*(e - S(2)*g) - x**S(2)*(d - S(2)*f) + x*(e + g))/(S(6)*x**S(4) + S(6)*x**S(2) + S(6)) - (d/S(4) - f/S(8))*log(x**S(2) - x + S(1)) + (d/S(4) - f/S(8))*log(x**S(2) + x + S(1)) - sqrt(S(3))*(S(4)*d + f)*atan(sqrt(S(3))*(-S(2)*x + S(1))/S(3))/S(36) + sqrt(S(3))*(S(4)*d + f)*atan(sqrt(S(3))*(S(2)*x + S(1))/S(3))/S(36) + sqrt(S(3))*(S(2)*e - g)*atan(sqrt(S(3))*(S(2)*x**S(2) + S(1))/S(3))/S(9), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*x**S(2) + g*x**S(3) + h*x**S(4))/(x**S(4) + x**S(2) + S(1))**S(2), x), x, x*(d + f - S(2)*h - x**S(3)*(e - S(2)*g) - x**S(2)*(d - S(2)*f + h) + x*(e + g))/(S(6)*x**S(4) + S(6)*x**S(2) + S(6)) + sqrt(S(3))*(S(2)*e - g)*atan(sqrt(S(3))*(S(2)*x**S(2) + S(1))/S(3))/S(9) - (d/S(4) - f/S(8) + h/S(8))*log(x**S(2) - x + S(1)) + (d/S(4) - f/S(8) + h/S(8))*log(x**S(2) + x + S(1)) - sqrt(S(3))*(S(4)*d + f + h)*atan(sqrt(S(3))*(-S(2)*x + S(1))/S(3))/S(36) + sqrt(S(3))*(S(4)*d + f + h)*atan(sqrt(S(3))*(S(2)*x + S(1))/S(3))/S(36), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*x**S(2) + g*x**S(3) + h*x**S(4) + i*x**S(5))/(x**S(4) + x**S(2) + S(1))**S(2), x), x, x*(d + f - S(2)*h - x**S(3)*(e - S(2)*g + i) - x**S(2)*(d - S(2)*f + h) + x*(e + g - S(2)*i))/(S(6)*x**S(4) + S(6)*x**S(2) + S(6)) - (d/S(4) - f/S(8) + h/S(8))*log(x**S(2) - x + S(1)) + (d/S(4) - f/S(8) + h/S(8))*log(x**S(2) + x + S(1)) - sqrt(S(3))*(S(4)*d + f + h)*atan(sqrt(S(3))*(-S(2)*x + S(1))/S(3))/S(36) + sqrt(S(3))*(S(4)*d + f + h)*atan(sqrt(S(3))*(S(2)*x + S(1))/S(3))/S(36) + sqrt(S(3))*(S(2)*e - g + S(2)*i)*atan(sqrt(S(3))*(S(2)*x**S(2) + S(1))/S(3))/S(9), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x)/(a + b*x**S(2) + c*x**S(4))**S(2), x), x, S(2)*c*e*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(-S(4)*a*c + b**S(2))**(S(3)/2) + sqrt(S(2))*sqrt(c)*d*(b - (-S(12)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(4)*a*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))) + sqrt(S(2))*sqrt(c)*d*(b + (-S(12)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(4)*a*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))) + x*(b*c*d*x**S(2) + b*c*e*x**S(3) + d*(-S(2)*a*c + b**S(2)) + e*x*(-S(2)*a*c + b**S(2)))/(S(2)*a*(-S(4)*a*c + b**S(2))*(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*x**S(2))/(a + b*x**S(2) + c*x**S(4))**S(2), x), x, S(2)*c*e*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(-S(4)*a*c + b**S(2))**(S(3)/2) + sqrt(S(2))*sqrt(c)*(-S(2)*a*f + b*d - (S(4)*a*b*f - S(12)*a*c*d + b**S(2)*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(4)*a*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))) + sqrt(S(2))*sqrt(c)*(-S(2)*a*f + b*d + (S(4)*a*b*f - S(12)*a*c*d + b**S(2)*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(4)*a*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))) + x*(-a*b*f - S(2)*a*c*d + b**S(2)*d + b*c*e*x**S(3) + c*x**S(2)*(-S(2)*a*f + b*d) + e*x*(-S(2)*a*c + b**S(2)))/(S(2)*a*(-S(4)*a*c + b**S(2))*(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*x**S(2) + g*x**S(3))/(a + b*x**S(2) + c*x**S(4))**S(2), x), x, (-b*g + S(2)*c*e)*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(-S(4)*a*c + b**S(2))**(S(3)/2) + sqrt(S(2))*sqrt(c)*(-S(2)*a*f + b*d - (S(4)*a*b*f - S(12)*a*c*d + b**S(2)*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(4)*a*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))) + sqrt(S(2))*sqrt(c)*(-S(2)*a*f + b*d + (S(4)*a*b*f - S(12)*a*c*d + b**S(2)*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(4)*a*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))) + x*(-a*b*f - S(2)*a*c*d + b**S(2)*d + c*x**S(3)*(-S(2)*a*g + b*e) + c*x**S(2)*(-S(2)*a*f + b*d) + x*(-a*b*g - S(2)*a*c*e + b**S(2)*e))/(S(2)*a*(-S(4)*a*c + b**S(2))*(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*x**S(2) + g*x**S(3) + h*x**S(4))/(a + b*x**S(2) + c*x**S(4))**S(2), x), x, (-b*g + S(2)*c*e)*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(-S(4)*a*c + b**S(2))**(S(3)/2) + x*(-a*b*f - S(2)*a*(-a*h + c*d) + b**S(2)*d + c*x**S(3)*(-S(2)*a*g + b*e) + x**S(2)*(a*b*h - S(2)*a*c*f + b*c*d) + x*(-a*b*g - S(2)*a*c*e + b**S(2)*e))/(S(2)*a*(-S(4)*a*c + b**S(2))*(a + b*x**S(2) + c*x**S(4))) - sqrt(S(2))*(-S(2)*a*c*(S(2)*a*h + S(6)*c*d - f*sqrt(-S(4)*a*c + b**S(2))) + b**S(2)*(-a*h + c*d) - b*(-S(4)*a*c*f + a*h*sqrt(-S(4)*a*c + b**S(2)) + c*d*sqrt(-S(4)*a*c + b**S(2))))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(4)*a*sqrt(c)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)) + sqrt(S(2))*(-S(2)*a*c*(S(2)*a*h + S(6)*c*d + f*sqrt(-S(4)*a*c + b**S(2))) + b**S(2)*(-a*h + c*d) + b*(S(4)*a*c*f + a*h*sqrt(-S(4)*a*c + b**S(2)) + c*d*sqrt(-S(4)*a*c + b**S(2))))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(4)*a*sqrt(c)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*x**S(2) + g*x**S(3) + h*x**S(4) + i*x**S(5))/(a + b*x**S(2) + c*x**S(4))**S(2), x), x, (S(2)*a*i - b*g + S(2)*c*e)*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(-S(4)*a*c + b**S(2))**(S(3)/2) + x*(-a*b*f - S(2)*a*(-a*h + c*d) + b**S(2)*d + x**S(3)*(a*b*i - S(2)*a*c*g + b*c*e) + x**S(2)*(a*b*h - S(2)*a*c*f + b*c*d) + x*(-a*b*g - S(2)*a*(-a*i + c*e) + b**S(2)*e))/(S(2)*a*(-S(4)*a*c + b**S(2))*(a + b*x**S(2) + c*x**S(4))) - sqrt(S(2))*(-S(2)*a*c*(S(2)*a*h + S(6)*c*d - f*sqrt(-S(4)*a*c + b**S(2))) + b**S(2)*(-a*h + c*d) - b*(-S(4)*a*c*f + a*h*sqrt(-S(4)*a*c + b**S(2)) + c*d*sqrt(-S(4)*a*c + b**S(2))))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(4)*a*sqrt(c)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)) + sqrt(S(2))*(-S(2)*a*c*(S(2)*a*h + S(6)*c*d + f*sqrt(-S(4)*a*c + b**S(2))) + b**S(2)*(-a*h + c*d) + b*(S(4)*a*c*f + a*h*sqrt(-S(4)*a*c + b**S(2)) + c*d*sqrt(-S(4)*a*c + b**S(2))))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(4)*a*sqrt(c)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*x**S(2) + g*x**S(3) + h*x**S(4) + j*x**S(5) + k*x**S(6) + l*x**S(7) + m*x**S(8))/(a + b*x**S(2) + c*x**S(4))**S(2), x), x, l*log(a + b*x**S(2) + c*x**S(4))/(S(4)*c**S(2)) + m*x/c**S(2) + (-S(6)*a*b*c*l + b**S(3)*l + S(4)*c**S(3)*e - c**S(2)*(-S(4)*a*j + S(2)*b*g))*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*c**S(2)*(-S(4)*a*c + b**S(2))**(S(3)/2)) - x*(a*b*c*(a*k + c*f) + S(2)*a*c*(a**S(2)*m - a*c*h + c**S(2)*d) - b**S(2)*(a**S(2)*m + c**S(2)*d) - c*x**S(3)*(-a*b**S(2)*l - S(2)*a*c*(-a*l + c*g) + b*c*(a*j + c*e)) - c*x*(-a*b*(a*l + c*g) - S(2)*a*c*(-a*j + c*e) + b**S(2)*c*e) + x**S(2)*(-a*b**S(3)*m + a*b**S(2)*c*k + S(2)*a*c**S(2)*(-a*k + c*f) - b*c*(-S(3)*a**S(2)*m + a*c*h + c**S(2)*d)))/(S(2)*a*c**S(2)*(-S(4)*a*c + b**S(2))*(a + b*x**S(2) + c*x**S(4))) - sqrt(S(2))*(S(3)*a*b**S(4)*m - a*b**S(3)*(c*k - S(3)*m*sqrt(-S(4)*a*c + b**S(2))) - S(2)*a*c**S(2)*(-S(10)*a**S(2)*m + S(2)*a*c*h - S(3)*a*k*sqrt(-S(4)*a*c + b**S(2)) + S(6)*c**S(2)*d - c*f*sqrt(-S(4)*a*c + b**S(2))) + b**S(2)*c*(-a*c*h - a*(S(19)*a*m + k*sqrt(-S(4)*a*c + b**S(2))) + c**S(2)*d) - b*c*(S(13)*a**S(2)*m*sqrt(-S(4)*a*c + b**S(2)) + a*c*(-S(8)*a*k + h*sqrt(-S(4)*a*c + b**S(2))) + c**S(2)*(-S(4)*a*f + d*sqrt(-S(4)*a*c + b**S(2)))))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(4)*a*c**(S(5)/2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)) + sqrt(S(2))*(S(3)*a*b**S(4)*m - a*b**S(3)*(c*k + S(3)*m*sqrt(-S(4)*a*c + b**S(2))) - S(2)*a*c**S(2)*(-S(10)*a**S(2)*m + S(2)*a*c*h + S(3)*a*k*sqrt(-S(4)*a*c + b**S(2)) + S(6)*c**S(2)*d + c*f*sqrt(-S(4)*a*c + b**S(2))) + b**S(2)*c*(-a*c*h + a*(-S(19)*a*m + k*sqrt(-S(4)*a*c + b**S(2))) + c**S(2)*d) + b*c*(S(13)*a**S(2)*m*sqrt(-S(4)*a*c + b**S(2)) + a*c*(S(8)*a*k + h*sqrt(-S(4)*a*c + b**S(2))) + c**S(2)*(S(4)*a*f + d*sqrt(-S(4)*a*c + b**S(2)))))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(4)*a*c**(S(5)/2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x)/(x**S(4) - S(5)*x**S(2) + S(4))**S(3), x), x, -S(313)*d*atanh(x/S(2))/S(20736) + S(13)*d*atanh(x)/S(648) - e*log(-x**S(2) + S(1))/S(81) + e*log(-x**S(2) + S(4))/S(81) - x*(-S(35)*d*x**S(2) + S(59)*d - S(50)*e*x**S(3) + S(122)*e*x)/(S(3456)*x**S(4) - S(17280)*x**S(2) + S(13824)) + x*(-S(5)*d*x**S(2) + S(17)*d - S(5)*e*x**S(3) + S(17)*e*x)/(S(144)*(x**S(4) - S(5)*x**S(2) + S(4))**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*x**S(2))/(x**S(4) - S(5)*x**S(2) + S(4))**S(3), x), x, -e*log(-x**S(2) + S(1))/S(81) + e*log(-x**S(2) + S(4))/S(81) - x*(S(59)*d - S(50)*e*x**S(3) + S(122)*e*x + S(380)*f - x**S(2)*(S(35)*d + S(140)*f))/(S(3456)*x**S(4) - S(17280)*x**S(2) + S(13824)) + x*(S(17)*d - S(5)*e*x**S(3) + S(17)*e*x + S(20)*f - x**S(2)*(S(5)*d + S(8)*f))/(S(144)*(x**S(4) - S(5)*x**S(2) + S(4))**S(2)) + (S(13)*d/S(648) + S(25)*f/S(648))*atanh(x) - (S(313)*d + S(820)*f)*atanh(x/S(2))/S(20736), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*x**S(2) + g*x**S(3))/(x**S(4) - S(5)*x**S(2) + S(4))**S(3), x), x, -x*(S(59)*d + S(380)*f - x**S(3)*(S(50)*e + S(152)*g) - x**S(2)*(S(35)*d + S(140)*f) + x*(S(122)*e + S(440)*g))/(S(3456)*x**S(4) - S(17280)*x**S(2) + S(13824)) + x*(S(17)*d + S(20)*f - x**S(3)*(S(5)*e + S(8)*g) - x**S(2)*(S(5)*d + S(8)*f) + x*(S(17)*e + S(20)*g))/(S(144)*(x**S(4) - S(5)*x**S(2) + S(4))**S(2)) + (S(13)*d/S(648) + S(25)*f/S(648))*atanh(x) - (S(313)*d + S(820)*f)*atanh(x/S(2))/S(20736) - (e/S(81) + S(5)*g/S(162))*log(-x**S(2) + S(1)) + (e/S(81) + S(5)*g/S(162))*log(-x**S(2) + S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*x**S(2) + g*x**S(3) + h*x**S(4))/(x**S(4) - S(5)*x**S(2) + S(4))**S(3), x), x, -x*(S(59)*d + S(380)*f + S(848)*h - x**S(3)*(S(50)*e + S(152)*g) - x**S(2)*(S(35)*d + S(140)*f + S(320)*h) + x*(S(122)*e + S(440)*g))/(S(3456)*x**S(4) - S(17280)*x**S(2) + S(13824)) + x*(S(17)*d + S(20)*f + S(32)*h - x**S(3)*(S(5)*e + S(8)*g) - x**S(2)*(S(5)*d + S(8)*f + S(20)*h) + x*(S(17)*e + S(20)*g))/(S(144)*(x**S(4) - S(5)*x**S(2) + S(4))**S(2)) - (e/S(81) + S(5)*g/S(162))*log(-x**S(2) + S(1)) + (e/S(81) + S(5)*g/S(162))*log(-x**S(2) + S(4)) + (S(13)*d/S(648) + S(25)*f/S(648) + S(61)*h/S(648))*atanh(x) - (S(313)*d + S(820)*f + S(1936)*h)*atanh(x/S(2))/S(20736), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*x**S(2) + g*x**S(3) + h*x**S(4) + i*x**S(5))/(x**S(4) - S(5)*x**S(2) + S(4))**S(3), x), x, -x*(S(59)*d + S(380)*f + S(848)*h - x**S(3)*(S(50)*e + S(152)*g + S(320)*i) - x**S(2)*(S(35)*d + S(140)*f + S(320)*h) + x*(S(122)*e + S(440)*g + S(896)*i))/(S(3456)*x**S(4) - S(17280)*x**S(2) + S(13824)) + x*(S(17)*d + S(20)*f + S(32)*h - x**S(3)*(S(5)*e + S(8)*g + S(20)*i) - x**S(2)*(S(5)*d + S(8)*f + S(20)*h) + x*(S(17)*e + S(20)*g + S(32)*i))/(S(144)*(x**S(4) - S(5)*x**S(2) + S(4))**S(2)) + (S(13)*d/S(648) + S(25)*f/S(648) + S(61)*h/S(648))*atanh(x) - (S(313)*d + S(820)*f + S(1936)*h)*atanh(x/S(2))/S(20736) - (e/S(81) + S(5)*g/S(162) + S(11)*i/S(162))*log(-x**S(2) + S(1)) + (e/S(81) + S(5)*g/S(162) + S(11)*i/S(162))*log(-x**S(2) + S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x)/(x**S(4) + x**S(2) + S(1))**S(3), x), x, -S(9)*d*log(x**S(2) - x + S(1))/S(32) + S(9)*d*log(x**S(2) + x + S(1))/S(32) - S(13)*sqrt(S(3))*d*atan(sqrt(S(3))*(-S(2)*x + S(1))/S(3))/S(144) + S(13)*sqrt(S(3))*d*atan(sqrt(S(3))*(S(2)*x + S(1))/S(3))/S(144) + S(2)*sqrt(S(3))*e*atan(sqrt(S(3))*(S(2)*x**S(2) + S(1))/S(3))/S(9) + x*(-S(7)*d*x**S(2) + S(2)*d - S(6)*e*x**S(3) + S(2)*e*x)/(S(24)*x**S(4) + S(24)*x**S(2) + S(24)) + x*(-d*x**S(2) + d - e*x**S(3) + e*x)/(S(12)*(x**S(4) + x**S(2) + S(1))**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*x**S(2))/(x**S(4) + x**S(2) + S(1))**S(3), x), x, S(2)*sqrt(S(3))*e*atan(sqrt(S(3))*(S(2)*x**S(2) + S(1))/S(3))/S(9) + x*(S(2)*d - S(6)*e*x**S(3) + S(2)*e*x + S(3)*f - x**S(2)*(S(7)*d - S(7)*f))/(S(24)*x**S(4) + S(24)*x**S(2) + S(24)) + x*(d - e*x**S(3) + e*x + f - x**S(2)*(d - S(2)*f))/(S(12)*(x**S(4) + x**S(2) + S(1))**S(2)) - (S(9)*d/S(32) - f/S(8))*log(x**S(2) - x + S(1)) + (S(9)*d/S(32) - f/S(8))*log(x**S(2) + x + S(1)) - sqrt(S(3))*(S(13)*d + S(2)*f)*atan(sqrt(S(3))*(-S(2)*x + S(1))/S(3))/S(144) + sqrt(S(3))*(S(13)*d + S(2)*f)*atan(sqrt(S(3))*(S(2)*x + S(1))/S(3))/S(144), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*x**S(2) + g*x**S(3))/(x**S(4) + x**S(2) + S(1))**S(3), x), x, x*(S(2)*d + S(3)*f - x**S(3)*(S(6)*e - S(6)*g) - x**S(2)*(S(7)*d - S(7)*f) + x*(S(2)*e + S(2)*g))/(S(24)*x**S(4) + S(24)*x**S(2) + S(24)) + x*(d + f - x**S(3)*(e - S(2)*g) - x**S(2)*(d - S(2)*f) + x*(e + g))/(S(12)*(x**S(4) + x**S(2) + S(1))**S(2)) - (S(9)*d/S(32) - f/S(8))*log(x**S(2) - x + S(1)) + (S(9)*d/S(32) - f/S(8))*log(x**S(2) + x + S(1)) - sqrt(S(3))*(S(13)*d + S(2)*f)*atan(sqrt(S(3))*(-S(2)*x + S(1))/S(3))/S(144) + sqrt(S(3))*(S(13)*d + S(2)*f)*atan(sqrt(S(3))*(S(2)*x + S(1))/S(3))/S(144) + sqrt(S(3))*(S(2)*e - g)*atan(sqrt(S(3))*(S(2)*x**S(2) + S(1))/S(3))/S(9), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*x**S(2) + g*x**S(3) + h*x**S(4))/(x**S(4) + x**S(2) + S(1))**S(3), x), x, x*(S(2)*d + S(3)*f - h - x**S(3)*(S(6)*e - S(6)*g) - x**S(2)*(S(7)*d - S(7)*f + S(4)*h) + x*(S(2)*e + S(2)*g))/(S(24)*x**S(4) + S(24)*x**S(2) + S(24)) + x*(d + f - S(2)*h - x**S(3)*(e - S(2)*g) - x**S(2)*(d - S(2)*f + h) + x*(e + g))/(S(12)*(x**S(4) + x**S(2) + S(1))**S(2)) + sqrt(S(3))*(S(2)*e - g)*atan(sqrt(S(3))*(S(2)*x**S(2) + S(1))/S(3))/S(9) - (S(9)*d/S(32) - f/S(8) + S(3)*h/S(32))*log(x**S(2) - x + S(1)) + (S(9)*d/S(32) - f/S(8) + S(3)*h/S(32))*log(x**S(2) + x + S(1)) - sqrt(S(3))*(S(13)*d + S(2)*f + h)*atan(sqrt(S(3))*(-S(2)*x + S(1))/S(3))/S(144) + sqrt(S(3))*(S(13)*d + S(2)*f + h)*atan(sqrt(S(3))*(S(2)*x + S(1))/S(3))/S(144), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*x**S(2) + g*x**S(3) + h*x**S(4) + i*x**S(5))/(x**S(4) + x**S(2) + S(1))**S(3), x), x, x*(S(2)*d + S(3)*f - h - x**S(3)*(S(6)*e - S(6)*g + S(4)*i) - x**S(2)*(S(7)*d - S(7)*f + S(4)*h) + x*(S(2)*e + S(2)*g))/(S(24)*x**S(4) + S(24)*x**S(2) + S(24)) + x*(d + f - S(2)*h - x**S(3)*(e - S(2)*g + i) - x**S(2)*(d - S(2)*f + h) + x*(e + g - S(2)*i))/(S(12)*(x**S(4) + x**S(2) + S(1))**S(2)) - (S(9)*d/S(32) - f/S(8) + S(3)*h/S(32))*log(x**S(2) - x + S(1)) + (S(9)*d/S(32) - f/S(8) + S(3)*h/S(32))*log(x**S(2) + x + S(1)) - sqrt(S(3))*(S(13)*d + S(2)*f + h)*atan(sqrt(S(3))*(-S(2)*x + S(1))/S(3))/S(144) + sqrt(S(3))*(S(13)*d + S(2)*f + h)*atan(sqrt(S(3))*(S(2)*x + S(1))/S(3))/S(144) + sqrt(S(3))*(S(2)*e - g + i)*atan(sqrt(S(3))*(S(2)*x**S(2) + S(1))/S(3))/S(9), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x)/(a + b*x**S(2) + c*x**S(4))**S(3), x), x, -S(6)*c**S(2)*e*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(-S(4)*a*c + b**S(2))**(S(5)/2) + x*(b*c*d*x**S(2) + b*c*e*x**S(3) + d*(-S(2)*a*c + b**S(2)) + e*x*(-S(2)*a*c + b**S(2)))/(S(4)*a*(-S(4)*a*c + b**S(2))*(a + b*x**S(2) + c*x**S(4))**S(2)) - S(3)*sqrt(S(2))*sqrt(c)*d*(S(56)*a**S(2)*c**S(2) - S(10)*a*b**S(2)*c + b**S(4) - b*(-S(8)*a*c + b**S(2))*sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(16)*a**S(2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(5)/2)) + S(3)*sqrt(S(2))*sqrt(c)*d*(S(56)*a**S(2)*c**S(2) - S(10)*a*b**S(2)*c + b**S(4) + b*(-S(8)*a*c + b**S(2))*sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(16)*a**S(2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(5)/2)) + x*(S(3)*b*c*d*x**S(2)*(-S(8)*a*c + b**S(2)) + S(2)*b*c*e*x**S(3)*(-S(10)*a*c + b**S(2)) + d*(-S(7)*a*c + b**S(2))*(-S(4)*a*c + S(3)*b**S(2)) + e*x*(S(24)*a**S(2)*c**S(2) - S(20)*a*b**S(2)*c + S(2)*b**S(4)))/(S(8)*a**S(2)*(-S(4)*a*c + b**S(2))**S(2)*(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*x**S(2))/(a + b*x**S(2) + c*x**S(4))**S(3), x), x, -S(6)*c**S(2)*e*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(-S(4)*a*c + b**S(2))**(S(5)/2) + x*(-a*b*f - S(2)*a*c*d + b**S(2)*d + b*c*e*x**S(3) + c*x**S(2)*(-S(2)*a*f + b*d) + e*x*(-S(2)*a*c + b**S(2)))/(S(4)*a*(-S(4)*a*c + b**S(2))*(a + b*x**S(2) + c*x**S(4))**S(2)) - sqrt(S(2))*sqrt(c)*(S(4)*a**S(2)*c*(S(42)*c*d - S(5)*f*sqrt(-S(4)*a*c + b**S(2))) - a*b**S(2)*(S(30)*c*d + f*sqrt(-S(4)*a*c + b**S(2))) + S(4)*a*b*c*(-S(13)*a*f + S(6)*d*sqrt(-S(4)*a*c + b**S(2))) + S(3)*b**S(4)*d - b**S(3)*(-a*f + S(3)*d*sqrt(-S(4)*a*c + b**S(2))))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(16)*a**S(2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(5)/2)) + sqrt(S(2))*sqrt(c)*(S(4)*a**S(2)*c*(S(42)*c*d + S(5)*f*sqrt(-S(4)*a*c + b**S(2))) - a*b**S(2)*(S(30)*c*d - f*sqrt(-S(4)*a*c + b**S(2))) - S(4)*a*b*c*(S(13)*a*f + S(6)*d*sqrt(-S(4)*a*c + b**S(2))) + S(3)*b**S(4)*d + b**S(3)*(a*f + S(3)*d*sqrt(-S(4)*a*c + b**S(2))))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(16)*a**S(2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(5)/2)) + x*(S(8)*a**S(2)*b*c*f + S(28)*a**S(2)*c**S(2)*d + a*b**S(3)*f - S(25)*a*b**S(2)*c*d + S(3)*b**S(4)*d + S(2)*b*c*e*x**S(3)*(-S(10)*a*c + b**S(2)) + c*x**S(2)*(S(20)*a**S(2)*c*f + a*b**S(2)*f - S(24)*a*b*c*d + S(3)*b**S(3)*d) + e*x*(S(24)*a**S(2)*c**S(2) - S(20)*a*b**S(2)*c + S(2)*b**S(4)))/(S(8)*a**S(2)*(-S(4)*a*c + b**S(2))**S(2)*(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*x**S(2) + g*x**S(3))/(a + b*x**S(2) + c*x**S(4))**S(3), x), x, -S(3)*c*(-b*g + S(2)*c*e)*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(-S(4)*a*c + b**S(2))**(S(5)/2) + x*(-a*b*f - S(2)*a*c*d + b**S(2)*d + c*x**S(3)*(-S(2)*a*g + b*e) + c*x**S(2)*(-S(2)*a*f + b*d) + x*(-a*b*g - S(2)*a*c*e + b**S(2)*e))/(S(4)*a*(-S(4)*a*c + b**S(2))*(a + b*x**S(2) + c*x**S(4))**S(2)) - sqrt(S(2))*sqrt(c)*(S(4)*a**S(2)*c*(S(42)*c*d - S(5)*f*sqrt(-S(4)*a*c + b**S(2))) - a*b**S(2)*(S(30)*c*d + f*sqrt(-S(4)*a*c + b**S(2))) + S(4)*a*b*c*(-S(13)*a*f + S(6)*d*sqrt(-S(4)*a*c + b**S(2))) + S(3)*b**S(4)*d - b**S(3)*(-a*f + S(3)*d*sqrt(-S(4)*a*c + b**S(2))))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(16)*a**S(2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(5)/2)) + sqrt(S(2))*sqrt(c)*(S(4)*a**S(2)*c*(S(42)*c*d + S(5)*f*sqrt(-S(4)*a*c + b**S(2))) - a*b**S(2)*(S(30)*c*d - f*sqrt(-S(4)*a*c + b**S(2))) - S(4)*a*b*c*(S(13)*a*f + S(6)*d*sqrt(-S(4)*a*c + b**S(2))) + S(3)*b**S(4)*d + b**S(3)*(a*f + S(3)*d*sqrt(-S(4)*a*c + b**S(2))))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(16)*a**S(2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(5)/2)) + x*(S(8)*a**S(2)*b*c*f + S(28)*a**S(2)*c**S(2)*d + a*b**S(3)*f - S(25)*a*b**S(2)*c*d + S(3)*b**S(4)*d + S(2)*c*x**S(3)*(S(8)*a**S(2)*c*g + a*b**S(2)*g - S(10)*a*b*c*e + b**S(3)*e) + c*x**S(2)*(S(20)*a**S(2)*c*f + a*b**S(2)*f - S(24)*a*b*c*d + S(3)*b**S(3)*d) + x*(S(4)*a**S(2)*b*c*g + S(24)*a**S(2)*c**S(2)*e + S(2)*a*b**S(3)*g - S(20)*a*b**S(2)*c*e + S(2)*b**S(4)*e))/(S(8)*a**S(2)*(-S(4)*a*c + b**S(2))**S(2)*(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*x**S(2) + g*x**S(3) + h*x**S(4))/(a + b*x**S(2) + c*x**S(4))**S(3), x), x, -S(3)*c*(-b*g + S(2)*c*e)*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(-S(4)*a*c + b**S(2))**(S(5)/2) + x*(-a*b*f - S(2)*a*(-a*h + c*d) + b**S(2)*d + c*x**S(3)*(-S(2)*a*g + b*e) + x**S(2)*(a*b*h - S(2)*a*c*f + b*c*d) + x*(-a*b*g - S(2)*a*c*e + b**S(2)*e))/(S(4)*a*(-S(4)*a*c + b**S(2))*(a + b*x**S(2) + c*x**S(4))**S(2)) - sqrt(S(2))*sqrt(c)*(S(4)*a**S(2)*c*(S(6)*a*h + S(42)*c*d - S(5)*f*sqrt(-S(4)*a*c + b**S(2))) - a*b**S(2)*(-S(18)*a*h + S(30)*c*d + f*sqrt(-S(4)*a*c + b**S(2))) + S(4)*a*b*(-S(13)*a*c*f + S(3)*a*h*sqrt(-S(4)*a*c + b**S(2)) + S(6)*c*d*sqrt(-S(4)*a*c + b**S(2))) + S(3)*b**S(4)*d - b**S(3)*(-a*f + S(3)*d*sqrt(-S(4)*a*c + b**S(2))))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(16)*a**S(2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(5)/2)) + sqrt(S(2))*sqrt(c)*(S(4)*a**S(2)*c*(S(6)*a*h + S(42)*c*d + S(5)*f*sqrt(-S(4)*a*c + b**S(2))) - a*b**S(2)*(-S(18)*a*h + S(30)*c*d - f*sqrt(-S(4)*a*c + b**S(2))) - S(4)*a*b*(S(13)*a*c*f + S(3)*a*h*sqrt(-S(4)*a*c + b**S(2)) + S(6)*c*d*sqrt(-S(4)*a*c + b**S(2))) + S(3)*b**S(4)*d + b**S(3)*(a*f + S(3)*d*sqrt(-S(4)*a*c + b**S(2))))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(16)*a**S(2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(5)/2)) + x*(S(8)*a**S(2)*b*c*f + S(4)*a**S(2)*c*(a*h + S(7)*c*d) + a*b**S(3)*f - a*b**S(2)*(S(7)*a*h + S(25)*c*d) + S(3)*b**S(4)*d + S(2)*c*x**S(3)*(S(8)*a**S(2)*c*g + a*b**S(2)*g - S(10)*a*b*c*e + b**S(3)*e) + c*x**S(2)*(S(20)*a**S(2)*c*f + a*b**S(2)*f - S(12)*a*b*(a*h + S(2)*c*d) + S(3)*b**S(3)*d) + x*(S(4)*a**S(2)*b*c*g + S(24)*a**S(2)*c**S(2)*e + S(2)*a*b**S(3)*g - S(20)*a*b**S(2)*c*e + S(2)*b**S(4)*e))/(S(8)*a**S(2)*(-S(4)*a*c + b**S(2))**S(2)*(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*x**S(2) + g*x**S(3) + h*x**S(4) + i*x**S(5))/(a + b*x**S(2) + c*x**S(4))**S(3), x), x, -(S(2)*a*c*i + b**S(2)*i - S(3)*b*c*g + S(6)*c**S(2)*e)*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(-S(4)*a*c + b**S(2))**(S(5)/2) + x*(-a*b*f - S(2)*a*(-a*h + c*d) + b**S(2)*d + x**S(3)*(a*b*i - S(2)*a*c*g + b*c*e) + x**S(2)*(a*b*h - S(2)*a*c*f + b*c*d) + x*(-a*b*g - S(2)*a*(-a*i + c*e) + b**S(2)*e))/(S(4)*a*(-S(4)*a*c + b**S(2))*(a + b*x**S(2) + c*x**S(4))**S(2)) - sqrt(S(2))*sqrt(c)*(S(4)*a**S(2)*c*(S(6)*a*h + S(42)*c*d - S(5)*f*sqrt(-S(4)*a*c + b**S(2))) - a*b**S(2)*(-S(18)*a*h + S(30)*c*d + f*sqrt(-S(4)*a*c + b**S(2))) + S(4)*a*b*(-S(13)*a*c*f + S(3)*a*h*sqrt(-S(4)*a*c + b**S(2)) + S(6)*c*d*sqrt(-S(4)*a*c + b**S(2))) + S(3)*b**S(4)*d - b**S(3)*(-a*f + S(3)*d*sqrt(-S(4)*a*c + b**S(2))))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(16)*a**S(2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(5)/2)) + sqrt(S(2))*sqrt(c)*(S(4)*a**S(2)*c*(S(6)*a*h + S(42)*c*d + S(5)*f*sqrt(-S(4)*a*c + b**S(2))) - a*b**S(2)*(-S(18)*a*h + S(30)*c*d - f*sqrt(-S(4)*a*c + b**S(2))) - S(4)*a*b*(S(13)*a*c*f + S(3)*a*h*sqrt(-S(4)*a*c + b**S(2)) + S(6)*c*d*sqrt(-S(4)*a*c + b**S(2))) + S(3)*b**S(4)*d + b**S(3)*(a*f + S(3)*d*sqrt(-S(4)*a*c + b**S(2))))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(16)*a**S(2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(5)/2)) + x*(S(8)*a**S(2)*b*c*f + S(4)*a**S(2)*c*(a*h + S(7)*c*d) + a*b**S(3)*f - a*b**S(2)*(S(7)*a*h + S(25)*c*d) + S(3)*b**S(4)*d + S(2)*c*x**S(3)*(S(8)*a**S(2)*c*g + a*b**S(2)*g - S(2)*a*b*(S(3)*a*i + S(5)*c*e) + b**S(3)*e) + c*x**S(2)*(S(20)*a**S(2)*c*f + a*b**S(2)*f - S(12)*a*b*(a*h + S(2)*c*d) + S(3)*b**S(3)*d) + x*(S(4)*a**S(2)*b*c*g + S(8)*a**S(2)*c*(a*i + S(3)*c*e) + S(2)*a*b**S(3)*g - S(4)*a*b**S(2)*(S(2)*a*i + S(5)*c*e) + S(2)*b**S(4)*e))/(S(8)*a**S(2)*(-S(4)*a*c + b**S(2))**S(2)*(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*x**S(2) + g*x**S(3) + h*x**S(4) + j*x**S(5) + k*x**S(6) + l*x**S(7) + m*x**S(8))/(a + b*x**S(2) + c*x**S(4))**S(3), x), x, -(-S(3)*a*b*l + S(2)*a*c*j + b**S(2)*j - S(3)*b*c*g + S(6)*c**S(2)*e)*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(-S(4)*a*c + b**S(2))**(S(5)/2) - x*(a*b*c*(a*k + c*f) + S(2)*a*c*(a**S(2)*m - a*c*h + c**S(2)*d) - b**S(2)*(a**S(2)*m + c**S(2)*d) - c*x**S(3)*(-a*b**S(2)*l - S(2)*a*c*(-a*l + c*g) + b*c*(a*j + c*e)) - c*x*(-a*b*(a*l + c*g) - S(2)*a*c*(-a*j + c*e) + b**S(2)*c*e) + x**S(2)*(-a*b**S(3)*m + a*b**S(2)*c*k + S(2)*a*c**S(2)*(-a*k + c*f) - b*c*(-S(3)*a**S(2)*m + a*c*h + c**S(2)*d)))/(S(4)*a*c**S(2)*(-S(4)*a*c + b**S(2))*(a + b*x**S(2) + c*x**S(4))**S(2)) + x*(S(4)*a**S(2)*b*c**S(2)*(a*k + S(2)*c*f) + S(4)*a**S(2)*c**S(2)*(-S(9)*a**S(2)*m + a*c*h + S(7)*c**S(2)*d) + a*b**S(3)*c*(S(2)*a*k + c*f) - a*b**S(2)*c*(-S(11)*a**S(2)*m + S(7)*a*c*h + S(25)*c**S(2)*d) + b**S(4)*(-S(2)*a**S(2)*m + S(3)*c**S(2)*d) + S(2)*c**S(2)*x**S(3)*(S(8)*a**S(2)*c*(a*l + c*g) + a*b**S(2)*(a*l + c*g) - S(2)*a*b*c*(S(3)*a*j + S(5)*c*e) + b**S(3)*c*e) + c*x**S(2)*(S(4)*a**S(2)*c**S(2)*(S(3)*a*k + S(5)*c*f) + a*b**S(2)*c*(S(3)*a*k + c*f) - S(4)*a*b*c*(S(4)*a**S(2)*m + S(3)*a*c*h + S(6)*c**S(2)*d) + b**S(3)*(a**S(2)*m + S(3)*c**S(2)*d)) + S(2)*c*x*(S(2)*a**S(2)*b*c*(a*l + c*g) + S(4)*a**S(2)*c**S(2)*(a*j + S(3)*c*e) + a*b**S(3)*(a*l + c*g) - S(2)*a*b**S(2)*c*(S(2)*a*j + S(5)*c*e) + b**S(4)*c*e))/(S(8)*a**S(2)*c**S(2)*(-S(4)*a*c + b**S(2))**S(2)*(a + b*x**S(2) + c*x**S(4))) - sqrt(S(2))*(S(4)*a**S(2)*c**S(2)*(S(10)*a**S(2)*m + S(6)*a*c*h - S(3)*a*k*sqrt(-S(4)*a*c + b**S(2)) + S(42)*c**S(2)*d - S(5)*c*f*sqrt(-S(4)*a*c + b**S(2))) - a*b**S(2)*c*(S(3)*a*(-S(6)*a*m + k*sqrt(-S(4)*a*c + b**S(2))) + S(30)*c**S(2)*d + c*(-S(18)*a*h + f*sqrt(-S(4)*a*c + b**S(2)))) + S(4)*a*b*c*(S(4)*a**S(2)*m*sqrt(-S(4)*a*c + b**S(2)) + S(3)*a*c*(-S(3)*a*k + h*sqrt(-S(4)*a*c + b**S(2))) + c**S(2)*(-S(13)*a*f + S(6)*d*sqrt(-S(4)*a*c + b**S(2)))) + b**S(4)*(-a**S(2)*m + S(3)*c**S(2)*d) - b**S(3)*(S(3)*a**S(2)*c*k + a**S(2)*m*sqrt(-S(4)*a*c + b**S(2)) + c**S(2)*(-a*f + S(3)*d*sqrt(-S(4)*a*c + b**S(2)))))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(16)*a**S(2)*c**(S(3)/2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(5)/2)) + sqrt(S(2))*(S(4)*a**S(2)*c**S(2)*(S(10)*a**S(2)*m + S(6)*a*c*h + S(3)*a*k*sqrt(-S(4)*a*c + b**S(2)) + S(42)*c**S(2)*d + S(5)*c*f*sqrt(-S(4)*a*c + b**S(2))) - a*b**S(2)*c*(-S(3)*a*(S(6)*a*m + k*sqrt(-S(4)*a*c + b**S(2))) + S(30)*c**S(2)*d - c*(S(18)*a*h + f*sqrt(-S(4)*a*c + b**S(2)))) - S(4)*a*b*c*(S(4)*a**S(2)*m*sqrt(-S(4)*a*c + b**S(2)) + S(3)*a*c*(S(3)*a*k + h*sqrt(-S(4)*a*c + b**S(2))) + c**S(2)*(S(13)*a*f + S(6)*d*sqrt(-S(4)*a*c + b**S(2)))) + b**S(4)*(-a**S(2)*m + S(3)*c**S(2)*d) + b**S(3)*(-S(3)*a**S(2)*c*k + a**S(2)*m*sqrt(-S(4)*a*c + b**S(2)) + c**S(2)*(a*f + S(3)*d*sqrt(-S(4)*a*c + b**S(2)))))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(16)*a**S(2)*c**(S(3)/2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(5)/2)), expand=True, _diff=True, _numerical=True)
# long time assert rubi_test(rubi_integrate((d + e*x + f*x**S(2) + g*x**S(3) + h*x**S(4) + i*x**S(5) + j*x**S(6) + k*x**S(7))/(a + b*x**S(2) + c*x**S(4))**S(2), x), x, k*log(a + b*x**S(2) + c*x**S(4))/(S(4)*c**S(2)) + (-S(6)*a*b*c*k + b**S(3)*k + S(4)*c**S(3)*e - c**S(2)*(-S(4)*a*i + S(2)*b*g))*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*c**S(2)*(-S(4)*a*c + b**S(2))**(S(3)/2)) + x*(-a*b*(a*j + c*f) - S(2)*a*c*(-a*h + c*d) + b**S(2)*c*d + x**S(3)*(-a*b**S(2)*k - S(2)*a*c*(-a*k + c*g) + b*c*(a*i + c*e)) + x**S(2)*(-a*b**S(2)*j - S(2)*a*c*(-a*j + c*f) + b*c*(a*h + c*d)) + x*(-a*b*(a*k + c*g) - S(2)*a*c*(-a*i + c*e) + b**S(2)*c*e))/(S(2)*a*c*(-S(4)*a*c + b**S(2))*(a + b*x**S(2) + c*x**S(4))) + sqrt(S(2))*(a*b**S(3)*j + S(2)*a*c*(S(2)*a*c*h - S(3)*a*j*sqrt(-S(4)*a*c + b**S(2)) + S(6)*c**S(2)*d - c*f*sqrt(-S(4)*a*c + b**S(2))) - b**S(2)*(-a*c*h - a*j*sqrt(-S(4)*a*c + b**S(2)) + c**S(2)*d) + b*c*(-S(8)*a**S(2)*j - S(4)*a*c*f + a*h*sqrt(-S(4)*a*c + b**S(2)) + c*d*sqrt(-S(4)*a*c + b**S(2))))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(4)*a*c**(S(3)/2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)) - sqrt(S(2))*(a*b**S(3)*j + S(2)*a*c*(S(2)*a*c*h + S(3)*a*j*sqrt(-S(4)*a*c + b**S(2)) + S(6)*c**S(2)*d + c*f*sqrt(-S(4)*a*c + b**S(2))) - b**S(2)*(-a*c*h + a*j*sqrt(-S(4)*a*c + b**S(2)) + c**S(2)*d) - b*c*(S(8)*a**S(2)*j + S(4)*a*c*f + a*h*sqrt(-S(4)*a*c + b**S(2)) + c*d*sqrt(-S(4)*a*c + b**S(2))))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(4)*a*c**(S(3)/2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)), expand=True, _diff=True, _numerical=True)
# long time assert rubi_test(rubi_integrate((d + e*x + f*x**S(2) + g*x**S(3) + h*x**S(4) + i*x**S(5) + j*x**S(8) + k*x**S(11))/(a + b*x**S(2) + c*x**S(4))**S(3), x), x, k*log(a + b*x**S(2) + c*x**S(4))/(S(4)*c**S(3)) - (-S(30)*a**S(2)*b*c**S(2)*k + S(10)*a*b**S(3)*c*k - b**S(5)*k + S(2)*b**S(2)*c**S(3)*i + S(12)*c**S(5)*e - c**S(4)*(-S(4)*a*i + S(6)*b*g))*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*c**S(3)*(-S(4)*a*c + b**S(2))**(S(5)/2)) - x*(c*x**S(2)*(-a*b**S(3)*j + S(2)*a*c**S(3)*f - b*c*(-S(3)*a**S(2)*j + a*c*h + c**S(2)*d)) + c*(a*b*c**S(2)*f + S(2)*a*c*(a**S(2)*j - a*c*h + c**S(2)*d) - b**S(2)*(a**S(2)*j + c**S(2)*d)) - x**S(3)*(-S(2)*a**S(3)*c**S(2)*k + S(4)*a**S(2)*b**S(2)*c*k - a*b**S(4)*k - S(2)*a*c**S(4)*g + b*c**S(3)*(a*i + c*e)) - x*(-a**S(2)*b**S(3)*k - S(2)*a*c**S(3)*(-a*i + c*e) + b**S(2)*c**S(3)*e - b*(-S(3)*a**S(3)*c*k + a*c**S(3)*g)))/(S(4)*a*c**S(3)*(-S(4)*a*c + b**S(2))*(a + b*x**S(2) + c*x**S(4))**S(2)) + x*(c**S(2)*x**S(2)*(S(20)*a**S(2)*c**S(3)*f + a*b**S(2)*c**S(2)*f - S(4)*a*b*c*(S(4)*a**S(2)*j + S(3)*a*c*h + S(6)*c**S(2)*d) + b**S(3)*(a**S(2)*j + S(3)*c**S(2)*d)) + S(2)*c*x**S(3)*(-S(24)*a**S(4)*c**S(2)*k - S(3)*a**S(2)*b**S(4)*k + S(8)*a**S(2)*c**S(4)*g - S(2)*a*b*c**S(3)*(S(3)*a*i + S(5)*c*e) + b**S(3)*c**S(3)*e + b**S(2)*(S(21)*a**S(3)*c*k + a*c**S(3)*g)) + c*(S(8)*a**S(2)*b*c**S(3)*f + S(4)*a**S(2)*c**S(2)*(-S(9)*a**S(2)*j + a*c*h + S(7)*c**S(2)*d) + a*b**S(3)*c**S(2)*f - a*b**S(2)*c*(-S(11)*a**S(2)*j + S(7)*a*c*h + S(25)*c**S(2)*d) + b**S(4)*(-S(2)*a**S(2)*j + S(3)*c**S(2)*d)) + x*(S(2)*a**S(2)*b**S(5)*k + S(8)*a**S(2)*c**S(4)*(a*i + S(3)*c*e) - S(4)*a*b**S(2)*c**S(3)*(S(2)*a*i + S(5)*c*e) + S(2)*b**S(4)*c**S(3)*e + S(2)*b**S(3)*(-S(9)*a**S(3)*c*k + a*c**S(3)*g) + S(4)*b*(S(13)*a**S(4)*c**S(2)*k + a**S(2)*c**S(4)*g)))/(S(8)*a**S(2)*c**S(3)*(-S(4)*a*c + b**S(2))**S(2)*(a + b*x**S(2) + c*x**S(4))) + sqrt(S(2))*(-S(4)*a**S(2)*c**S(2)*(S(10)*a**S(2)*j + S(6)*a*c*h + S(42)*c**S(2)*d - S(5)*c*f*sqrt(-S(4)*a*c + b**S(2))) + a*b**S(2)*c*(-S(18)*a**S(2)*j - S(18)*a*c*h + S(30)*c**S(2)*d + c*f*sqrt(-S(4)*a*c + b**S(2))) - S(4)*a*b*c*(S(4)*a**S(2)*j*sqrt(-S(4)*a*c + b**S(2)) + S(3)*a*c*h*sqrt(-S(4)*a*c + b**S(2)) + c**S(2)*(-S(13)*a*f + S(6)*d*sqrt(-S(4)*a*c + b**S(2)))) - b**S(4)*(-a**S(2)*j + S(3)*c**S(2)*d) + b**S(3)*(a**S(2)*j*sqrt(-S(4)*a*c + b**S(2)) + c**S(2)*(-a*f + S(3)*d*sqrt(-S(4)*a*c + b**S(2)))))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(16)*a**S(2)*c**(S(3)/2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(5)/2)) - sqrt(S(2))*(-S(4)*a**S(2)*c**S(2)*(S(10)*a**S(2)*j + S(6)*a*c*h + S(42)*c**S(2)*d + S(5)*c*f*sqrt(-S(4)*a*c + b**S(2))) + a*b**S(2)*c*(-S(18)*a**S(2)*j - S(18)*a*c*h + S(30)*c**S(2)*d - c*f*sqrt(-S(4)*a*c + b**S(2))) + S(4)*a*b*c*(S(4)*a**S(2)*j*sqrt(-S(4)*a*c + b**S(2)) + S(3)*a*c*h*sqrt(-S(4)*a*c + b**S(2)) + c**S(2)*(S(13)*a*f + S(6)*d*sqrt(-S(4)*a*c + b**S(2)))) - b**S(4)*(-a**S(2)*j + S(3)*c**S(2)*d) - b**S(3)*(a**S(2)*j*sqrt(-S(4)*a*c + b**S(2)) + c**S(2)*(a*f + S(3)*d*sqrt(-S(4)*a*c + b**S(2)))))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(16)*a**S(2)*c**(S(3)/2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(5)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))**S(3)*(a*d + a*e*x + b*e*x**S(3) + c*e*x**S(5) + c*f*x**S(6) + x**S(4)*(b*f + c*d) + x**S(2)*(a*f + b*d)), x), x, a**S(4)*d*x + a**S(4)*e*x**S(2)/S(2) + a**S(3)*b*e*x**S(4) + a**S(3)*x**S(3)*(a*f + S(4)*b*d)/S(3) + a**S(2)*e*x**S(6)*(S(2)*a*c + S(3)*b**S(2))/S(3) + S(2)*a**S(2)*x**S(5)*(S(2)*a*b*f + S(2)*a*c*d + S(3)*b**S(2)*d)/S(5) + a*b*e*x**S(8)*(S(3)*a*c + b**S(2))/S(2) + S(2)*a*x**S(7)*(S(2)*a**S(2)*c*f + S(3)*a*b**S(2)*f + S(6)*a*b*c*d + S(2)*b**S(3)*d)/S(7) + b*c**S(3)*e*x**S(16)/S(4) + b*c*e*x**S(12)*(S(3)*a*c + b**S(2))/S(3) + c**S(4)*e*x**S(18)/S(18) + c**S(4)*f*x**S(19)/S(19) + c**S(3)*x**S(17)*(S(4)*b*f + c*d)/S(17) + c**S(2)*e*x**S(14)*(S(2)*a*c + S(3)*b**S(2))/S(7) + S(2)*c**S(2)*x**S(15)*(S(2)*a*c*f + S(3)*b**S(2)*f + S(2)*b*c*d)/S(15) + S(2)*c*x**S(13)*(S(6)*a*b*c*f + S(2)*a*c**S(2)*d + S(2)*b**S(3)*f + S(3)*b**S(2)*c*d)/S(13) + e*x**S(10)*(S(3)*a**S(2)*c**S(2)/S(5) + S(6)*a*b**S(2)*c/S(5) + b**S(4)/S(10)) + x**S(11)*(S(6)*a**S(2)*c**S(2)*f/S(11) + S(12)*a*b**S(2)*c*f/S(11) + S(12)*a*b*c**S(2)*d/S(11) + b**S(4)*f/S(11) + S(4)*b**S(3)*c*d/S(11)) + x**S(9)*(S(4)*a**S(2)*b*c*f/S(3) + S(2)*a**S(2)*c**S(2)*d/S(3) + S(4)*a*b**S(3)*f/S(9) + S(4)*a*b**S(2)*c*d/S(3) + b**S(4)*d/S(9)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))**S(2)*(a*d + a*e*x + b*e*x**S(3) + c*e*x**S(5) + c*f*x**S(6) + x**S(4)*(b*f + c*d) + x**S(2)*(a*f + b*d)), x), x, a**S(3)*d*x + a**S(3)*e*x**S(2)/S(2) + S(3)*a**S(2)*b*e*x**S(4)/S(4) + a**S(2)*x**S(3)*(a*f + S(3)*b*d)/S(3) + a*e*x**S(6)*(a*c + b**S(2))/S(2) + S(3)*a*x**S(5)*(a*b*f + a*c*d + b**S(2)*d)/S(5) + b*c**S(2)*e*x**S(12)/S(4) + b*e*x**S(8)*(S(6)*a*c + b**S(2))/S(8) + c**S(3)*e*x**S(14)/S(14) + c**S(3)*f*x**S(15)/S(15) + c**S(2)*x**S(13)*(S(3)*b*f + c*d)/S(13) + S(3)*c*e*x**S(10)*(a*c + b**S(2))/S(10) + S(3)*c*x**S(11)*(a*c*f + b**S(2)*f + b*c*d)/S(11) + x**S(9)*(S(2)*a*b*c*f/S(3) + a*c**S(2)*d/S(3) + b**S(3)*f/S(9) + b**S(2)*c*d/S(3)) + x**S(7)*(S(3)*a**S(2)*c*f/S(7) + S(3)*a*b**S(2)*f/S(7) + S(6)*a*b*c*d/S(7) + b**S(3)*d/S(7)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**S(2) + c*x**S(4))*(a*d + a*e*x + b*e*x**S(3) + c*e*x**S(5) + c*f*x**S(6) + x**S(4)*(b*f + c*d) + x**S(2)*(a*f + b*d)), x), x, a**S(2)*d*x + a**S(2)*e*x**S(2)/S(2) + a*b*e*x**S(4)/S(2) + a*x**S(3)*(a*f + S(2)*b*d)/S(3) + b*c*e*x**S(8)/S(4) + c**S(2)*e*x**S(10)/S(10) + c**S(2)*f*x**S(11)/S(11) + c*x**S(9)*(S(2)*b*f + c*d)/S(9) + e*x**S(6)*(a*c/S(3) + b**S(2)/S(6)) + x**S(7)*(S(2)*a*c*f/S(7) + b**S(2)*f/S(7) + S(2)*b*c*d/S(7)) + x**S(5)*(S(2)*a*b*f/S(5) + S(2)*a*c*d/S(5) + b**S(2)*d/S(5)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a*d + a*e*x + b*e*x**S(3) + c*e*x**S(5) + c*f*x**S(6) + x**S(4)*(b*f + c*d) + x**S(2)*(a*f + b*d))/(a + b*x**S(2) + c*x**S(4)), x), x, d*x + e*x**S(2)/S(2) + f*x**S(3)/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a*d + a*e*x + b*e*x**S(3) + c*e*x**S(5) + c*f*x**S(6) + x**S(4)*(b*f + c*d) + x**S(2)*(a*f + b*d))/(a + b*x**S(2) + c*x**S(4))**S(2), x), x, -e*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/sqrt(-S(4)*a*c + b**S(2)) + sqrt(S(2))*(f - (-b*f + S(2)*c*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*sqrt(c)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))) + sqrt(S(2))*(f + (-b*f + S(2)*c*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*sqrt(c)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a*d + a*e*x + b*e*x**S(3) + c*e*x**S(5) + c*f*x**S(6) + x**S(4)*(b*f + c*d) + x**S(2)*(a*f + b*d))/(a + b*x**S(2) + c*x**S(4))**S(3), x), x, S(2)*c*e*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(-S(4)*a*c + b**S(2))**(S(3)/2) + sqrt(S(2))*sqrt(c)*(-S(2)*a*f + b*d - (S(4)*a*b*f - S(12)*a*c*d + b**S(2)*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(4)*a*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))) + sqrt(S(2))*sqrt(c)*(-S(2)*a*f + b*d + (S(4)*a*b*f - S(12)*a*c*d + b**S(2)*d)/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(4)*a*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))) + x*(-a*b*f - S(2)*a*c*d + b**S(2)*d + b*c*e*x**S(3) + c*x**S(2)*(-S(2)*a*f + b*d) + e*x*(-S(2)*a*c + b**S(2)))/(S(2)*a*(-S(4)*a*c + b**S(2))*(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a*d + a*e*x + b*e*x**S(3) + c*e*x**S(5) + c*f*x**S(6) + x**S(4)*(b*f + c*d) + x**S(2)*(a*f + b*d))/(a + b*x**S(2) + c*x**S(4))**S(4), x), x, -S(6)*c**S(2)*e*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(-S(4)*a*c + b**S(2))**(S(5)/2) + x*(-a*b*f - S(2)*a*c*d + b**S(2)*d + b*c*e*x**S(3) + c*x**S(2)*(-S(2)*a*f + b*d) + e*x*(-S(2)*a*c + b**S(2)))/(S(4)*a*(-S(4)*a*c + b**S(2))*(a + b*x**S(2) + c*x**S(4))**S(2)) - sqrt(S(2))*sqrt(c)*(S(4)*a**S(2)*c*(S(42)*c*d - S(5)*f*sqrt(-S(4)*a*c + b**S(2))) - a*b**S(2)*(S(30)*c*d + f*sqrt(-S(4)*a*c + b**S(2))) + S(4)*a*b*c*(-S(13)*a*f + S(6)*d*sqrt(-S(4)*a*c + b**S(2))) + S(3)*b**S(4)*d - b**S(3)*(-a*f + S(3)*d*sqrt(-S(4)*a*c + b**S(2))))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(16)*a**S(2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(5)/2)) + sqrt(S(2))*sqrt(c)*(S(4)*a**S(2)*c*(S(42)*c*d + S(5)*f*sqrt(-S(4)*a*c + b**S(2))) - a*b**S(2)*(S(30)*c*d - f*sqrt(-S(4)*a*c + b**S(2))) - S(4)*a*b*c*(S(13)*a*f + S(6)*d*sqrt(-S(4)*a*c + b**S(2))) + S(3)*b**S(4)*d + b**S(3)*(a*f + S(3)*d*sqrt(-S(4)*a*c + b**S(2))))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(16)*a**S(2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(5)/2)) + x*(S(8)*a**S(2)*b*c*f + S(28)*a**S(2)*c**S(2)*d + a*b**S(3)*f - S(25)*a*b**S(2)*c*d + S(3)*b**S(4)*d + S(2)*b*c*e*x**S(3)*(-S(10)*a*c + b**S(2)) + c*x**S(2)*(S(20)*a**S(2)*c*f + a*b**S(2)*f - S(24)*a*b*c*d + S(3)*b**S(3)*d) + e*x*(S(24)*a**S(2)*c**S(2) - S(20)*a*b**S(2)*c + S(2)*b**S(4)))/(S(8)*a**S(2)*(-S(4)*a*c + b**S(2))**S(2)*(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(3) - S(2)*x**S(2) - x + S(2))/(x**S(4) - S(5)*x**S(2) + S(4)), x), x, log(x + S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x)*(x**S(3) - S(2)*x**S(2) - x + S(2))/(x**S(4) - S(5)*x**S(2) + S(4)), x), x, e*x + (d - S(2)*e)*log(x + S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*x**S(2))*(x**S(3) - S(2)*x**S(2) - x + S(2))/(x**S(4) - S(5)*x**S(2) + S(4)), x), x, f*(x + S(2))**S(2)/S(2) + x*(e - S(4)*f) + (d - S(2)*e + S(4)*f)*log(x + S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*x**S(2) + g*x**S(3))*(x**S(3) - S(2)*x**S(2) - x + S(2))/(x**S(4) - S(5)*x**S(2) + S(4)), x), x, g*(x + S(2))**S(3)/S(3) + x*(e - S(4)*f + S(12)*g) + (f/S(2) - S(3)*g)*(x + S(2))**S(2) + (d - S(2)*e + S(4)*f - S(8)*g)*log(x + S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(3) - S(2)*x**S(2) - x + S(2))*(d + e*x + f*x**S(2) + g*x**S(3) + h*x**S(4))/(x**S(4) - S(5)*x**S(2) + S(4)), x), x, h*x**S(4)/S(4) + x**S(3)*(g/S(3) - S(2)*h/S(3)) + x**S(2)*(f/S(2) - g + S(2)*h) + x*(e - S(2)*f + S(4)*g - S(8)*h) + (d - S(2)*e + S(4)*f - S(8)*g + S(16)*h)*log(x + S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(3) - S(2)*x**S(2) - x + S(2))*(d + e*x + f*x**S(2) + g*x**S(3) + h*x**S(4) + i*x**S(5))/(x**S(4) - S(5)*x**S(2) + S(4)), x), x, i*x**S(5)/S(5) + x**S(4)*(h/S(4) - i/S(2)) + x**S(3)*(g/S(3) - S(2)*h/S(3) + S(4)*i/S(3)) + x**S(2)*(f/S(2) - g + S(2)*h - S(4)*i) + x*(e - S(2)*f + S(4)*g - S(8)*h + S(16)*i) + (d - S(2)*e + S(4)*f - S(8)*g + S(16)*h - S(32)*i)*log(x + S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(2) - S(3)*x + S(2))/(x**S(4) - S(5)*x**S(2) + S(4)), x), x, -S(2)*atanh(S(2)*x + S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x)*(x**S(2) - S(3)*x + S(2))/(x**S(4) - S(5)*x**S(2) + S(4)), x), x, -(d - S(2)*e)*log(x + S(2)) + (d - e)*log(x + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*x**S(2))*(x**S(2) - S(3)*x + S(2))/(x**S(4) - S(5)*x**S(2) + S(4)), x), x, f*x - (d - S(2)*e + S(4)*f)*log(x + S(2)) + (d - e + f)*log(x + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(2) - S(3)*x + S(2))*(d + e*x + f*x**S(2) + g*x**S(3))/(x**S(4) - S(5)*x**S(2) + S(4)), x), x, g*x**S(2)/S(2) + x*(f - S(3)*g) - (d - S(2)*e + S(4)*f - S(8)*g)*log(x + S(2)) + (d - e + f - g)*log(x + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(2) - S(3)*x + S(2))*(d + e*x + f*x**S(2) + g*x**S(3) + h*x**S(4))/(x**S(4) - S(5)*x**S(2) + S(4)), x), x, h*x**S(3)/S(3) + x**S(2)*(g/S(2) - S(3)*h/S(2)) + x*(f - S(3)*g + S(7)*h) - (d - S(2)*e + S(4)*f - S(8)*g + S(16)*h)*log(x + S(2)) + (d - e + f - g + h)*log(x + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(2) - S(3)*x + S(2))*(d + e*x + f*x**S(2) + g*x**S(3) + h*x**S(4) + i*x**S(5))/(x**S(4) - S(5)*x**S(2) + S(4)), x), x, i*x**S(4)/S(4) + x**S(3)*(h/S(3) - i) + x**S(2)*(g/S(2) - S(3)*h/S(2) + S(7)*i/S(2)) + x*(f - S(3)*g + S(7)*h - S(15)*i) - (d - S(2)*e + S(4)*f - S(8)*g + S(16)*h - S(32)*i)*log(x + S(2)) + (d - e + f - g + h - i)*log(x + S(1)), expand=True, _diff=True, _numerical=True)
# wromg result (rule) assert rubi_test(rubi_integrate((x + S(2))/(x**S(4) - S(5)*x**S(2) + S(4)), x), x, -log(-x + S(1))/S(2) + log(-x + S(2))/S(3) + log(x + S(1))/S(6), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x)*(x + S(2))/(x**S(4) - S(5)*x**S(2) + S(4)), x), x, (-d/S(2) - e/S(2))*log(-x + S(1)) + (d/S(6) - e/S(6))*log(x + S(1)) + (d/S(3) + S(2)*e/S(3))*log(-x + S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x + S(2))*(d + e*x + f*x**S(2))/(x**S(4) - S(5)*x**S(2) + S(4)), x), x, (-d/S(2) - e/S(2) - f/S(2))*log(-x + S(1)) + (d/S(6) - e/S(6) + f/S(6))*log(x + S(1)) + (d/S(3) + S(2)*e/S(3) + S(4)*f/S(3))*log(-x + S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x + S(2))*(d + e*x + f*x**S(2) + g*x**S(3))/(x**S(4) - S(5)*x**S(2) + S(4)), x), x, g*x + (d/S(6) - e/S(6) + f/S(6) - g/S(6))*log(x + S(1)) + (d/S(3) + S(2)*e/S(3) + S(4)*f/S(3) + S(8)*g/S(3))*log(-x + S(2)) - (d/S(2) + e/S(2) + f/S(2) + g/S(2))*log(-x + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x + S(2))*(d + e*x + f*x**S(2) + g*x**S(3) + h*x**S(4))/(x**S(4) - S(5)*x**S(2) + S(4)), x), x, h*x**S(2)/S(2) + x*(g + S(2)*h) + (d/S(6) - e/S(6) + f/S(6) - g/S(6) + h/S(6))*log(x + S(1)) + (d/S(3) + S(2)*e/S(3) + S(4)*f/S(3) + S(8)*g/S(3) + S(16)*h/S(3))*log(-x + S(2)) - (d/S(2) + e/S(2) + f/S(2) + g/S(2) + h/S(2))*log(-x + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x + S(2))*(d + e*x + f*x**S(2) + g*x**S(3) + h*x**S(4) + i*x**S(5))/(x**S(4) - S(5)*x**S(2) + S(4)), x), x, i*x**S(3)/S(3) + x**S(2)*(h/S(2) + i) + x*(g + S(2)*h + S(5)*i) + (d/S(6) - e/S(6) + f/S(6) - g/S(6) + h/S(6) - i/S(6))*log(x + S(1)) + (d/S(3) + S(2)*e/S(3) + S(4)*f/S(3) + S(8)*g/S(3) + S(16)*h/S(3) + S(32)*i/S(3))*log(-x + S(2)) - (d/S(2) + e/S(2) + f/S(2) + g/S(2) + h/S(2) + i/S(2))*log(-x + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(3) - S(2)*x**S(2) - x + S(2))/(x**S(4) - S(5)*x**S(2) + S(4))**S(2), x), x, -log(-x + S(1))/S(18) + log(-x + S(2))/S(48) + log(x + S(1))/S(6) - S(19)*log(x + S(2))/S(144) + S(1)/(S(12)*x + S(24)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x)*(x**S(3) - S(2)*x**S(2) - x + S(2))/(x**S(4) - S(5)*x**S(2) + S(4))**S(2), x), x, (d/S(48) + e/S(24))*log(-x + S(2)) - (d/S(18) + e/S(18))*log(-x + S(1)) - (S(19)*d/S(144) - S(13)*e/S(72))*log(x + S(2)) + (d/S(6) - e/S(6))*log(x + S(1)) + (d - S(2)*e)/(S(12)*x + S(24)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*x**S(2))*(x**S(3) - S(2)*x**S(2) - x + S(2))/(x**S(4) - S(5)*x**S(2) + S(4))**S(2), x), x, (d/S(48) + e/S(24) + f/S(12))*log(-x + S(2)) - (d/S(18) + e/S(18) + f/S(18))*log(-x + S(1)) - (S(19)*d/S(144) - S(13)*e/S(72) + S(7)*f/S(36))*log(x + S(2)) + (d/S(6) - e/S(6) + f/S(6))*log(x + S(1)) + (d - S(2)*e + S(4)*f)/(S(12)*x + S(24)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*x**S(2) + g*x**S(3))*(x**S(3) - S(2)*x**S(2) - x + S(2))/(x**S(4) - S(5)*x**S(2) + S(4))**S(2), x), x, (d/S(48) + e/S(24) + f/S(12) + g/S(6))*log(-x + S(2)) - (d/S(18) + e/S(18) + f/S(18) + g/S(18))*log(-x + S(1)) - (S(19)*d/S(144) - S(13)*e/S(72) + S(7)*f/S(36) - g/S(18))*log(x + S(2)) + (d/S(6) - e/S(6) + f/S(6) - g/S(6))*log(x + S(1)) + (d - S(2)*e + S(4)*f - S(8)*g)/(S(12)*x + S(24)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(3) - S(2)*x**S(2) - x + S(2))*(d + e*x + f*x**S(2) + g*x**S(3) + h*x**S(4))/(x**S(4) - S(5)*x**S(2) + S(4))**S(2), x), x, (d/S(48) + e/S(24) + f/S(12) + g/S(6) + h/S(3))*log(-x + S(2)) - (d/S(18) + e/S(18) + f/S(18) + g/S(18) + h/S(18))*log(-x + S(1)) - (S(19)*d/S(144) - S(13)*e/S(72) + S(7)*f/S(36) - g/S(18) - S(5)*h/S(9))*log(x + S(2)) + (d/S(6) - e/S(6) + f/S(6) - g/S(6) + h/S(6))*log(x + S(1)) + (d - S(2)*e + S(4)*f - S(8)*g + S(16)*h)/(S(12)*x + S(24)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(3) - S(2)*x**S(2) - x + S(2))*(d + e*x + f*x**S(2) + g*x**S(3) + h*x**S(4) + i*x**S(5))/(x**S(4) - S(5)*x**S(2) + S(4))**S(2), x), x, i*x + (d/S(48) + e/S(24) + f/S(12) + g/S(6) + h/S(3) + S(2)*i/S(3))*log(-x + S(2)) - (d/S(18) + e/S(18) + f/S(18) + g/S(18) + h/S(18) + i/S(18))*log(-x + S(1)) - (S(19)*d/S(144) - S(13)*e/S(72) + S(7)*f/S(36) - g/S(18) - S(5)*h/S(9) + S(22)*i/S(9))*log(x + S(2)) + (d/S(6) - e/S(6) + f/S(6) - g/S(6) + h/S(6) - i/S(6))*log(x + S(1)) + (d - S(2)*e + S(4)*f - S(8)*g + S(16)*h - S(32)*i)/(S(12)*x + S(24)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(2) - S(3)*x + S(2))/(x**S(4) - S(5)*x**S(2) + S(4))**S(2), x), x, -(S(3)*x + S(5))/(S(12)*x**S(2) + S(36)*x + S(24)) - log(-x + S(1))/S(36) + log(-x + S(2))/S(144) - S(7)*log(x + S(1))/S(36) + S(31)*log(x + S(2))/S(144), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x)*(x**S(2) - S(3)*x + S(2))/(x**S(4) - S(5)*x**S(2) + S(4))**S(2), x), x, (d/S(144) + e/S(72))*log(-x + S(2)) - (d/S(36) + e/S(36))*log(-x + S(1)) - (S(7)*d/S(36) - S(13)*e/S(36))*log(x + S(1)) + (S(31)*d/S(144) - S(25)*e/S(72))*log(x + S(2)) - (S(5)*d - S(6)*e + x*(S(3)*d - S(4)*e))/(S(12)*x**S(2) + S(36)*x + S(24)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*x**S(2))*(x**S(2) - S(3)*x + S(2))/(x**S(4) - S(5)*x**S(2) + S(4))**S(2), x), x, (d/S(144) + e/S(72) + f/S(36))*log(-x + S(2)) - (d/S(36) + e/S(36) + f/S(36))*log(-x + S(1)) - (S(7)*d/S(36) - S(13)*e/S(36) + S(19)*f/S(36))*log(x + S(1)) + (S(31)*d/S(144) - S(25)*e/S(72) + S(19)*f/S(36))*log(x + S(2)) - (S(5)*d - S(6)*e + S(8)*f + x*(S(3)*d - S(4)*e + S(6)*f))/(S(12)*x**S(2) + S(36)*x + S(24)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(2) - S(3)*x + S(2))*(d + e*x + f*x**S(2) + g*x**S(3))/(x**S(4) - S(5)*x**S(2) + S(4))**S(2), x), x, (d/S(144) + e/S(72) + f/S(36) + g/S(18))*log(-x + S(2)) - (d/S(36) + e/S(36) + f/S(36) + g/S(36))*log(-x + S(1)) - (S(7)*d/S(36) - S(13)*e/S(36) + S(19)*f/S(36) - S(25)*g/S(36))*log(x + S(1)) + (S(31)*d/S(144) - S(25)*e/S(72) + S(19)*f/S(36) - S(13)*g/S(18))*log(x + S(2)) - (d - S(2)*e + S(4)*f - S(8)*g)/(S(12)*x + S(24)) - (d - e + f - g)/(S(6)*x + S(6)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(2) - S(3)*x + S(2))*(d + e*x + f*x**S(2) + g*x**S(3) + h*x**S(4))/(x**S(4) - S(5)*x**S(2) + S(4))**S(2), x), x, (d/S(144) + e/S(72) + f/S(36) + g/S(18) + h/S(9))*log(-x + S(2)) - (d/S(36) + e/S(36) + f/S(36) + g/S(36) + h/S(36))*log(-x + S(1)) - (S(7)*d/S(36) - S(13)*e/S(36) + S(19)*f/S(36) - S(25)*g/S(36) + S(31)*h/S(36))*log(x + S(1)) + (S(31)*d/S(144) - S(25)*e/S(72) + S(19)*f/S(36) - S(13)*g/S(18) + S(7)*h/S(9))*log(x + S(2)) - (d - S(2)*e + S(4)*f - S(8)*g + S(16)*h)/(S(12)*x + S(24)) - (d - e + f - g + h)/(S(6)*x + S(6)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x**S(2) - S(3)*x + S(2))*(d + e*x + f*x**S(2) + g*x**S(3) + h*x**S(4) + i*x**S(5))/(x**S(4) - S(5)*x**S(2) + S(4))**S(2), x), x, (d/S(144) + e/S(72) + f/S(36) + g/S(18) + h/S(9) + S(2)*i/S(9))*log(-x + S(2)) - (d/S(36) + e/S(36) + f/S(36) + g/S(36) + h/S(36) + i/S(36))*log(-x + S(1)) - (S(7)*d/S(36) - S(13)*e/S(36) + S(19)*f/S(36) - S(25)*g/S(36) + S(31)*h/S(36) - S(37)*i/S(36))*log(x + S(1)) + (S(31)*d/S(144) - S(25)*e/S(72) + S(19)*f/S(36) - S(13)*g/S(18) + S(7)*h/S(9) - S(2)*i/S(9))*log(x + S(2)) - (d - S(2)*e + S(4)*f - S(8)*g + S(16)*h - S(32)*i)/(S(12)*x + S(24)) - (d - e + f - g + h - i)/(S(6)*x + S(6)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x + S(2))/(x**S(4) - S(5)*x**S(2) + S(4))**S(2), x), x, log(-x + S(1))/S(18) - S(35)*log(-x + S(2))/S(432) + log(x + S(1))/S(54) + log(x + S(2))/S(144) - S(1)/(S(36)*x + S(36)) + S(1)/(-S(12)*x + S(12)) + S(1)/(-S(36)*x + S(72)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x)*(x + S(2))/(x**S(4) - S(5)*x**S(2) + S(4))**S(2), x), x, (d/S(144) - e/S(72))*log(x + S(2)) + (d/S(54) + e/S(108))*log(x + S(1)) + (d/S(18) + S(5)*e/S(36))*log(-x + S(1)) - (S(35)*d/S(432) + S(29)*e/S(216))*log(-x + S(2)) - (d - e)/(S(36)*x + S(36)) + (d + e)/(-S(12)*x + S(12)) + (d + S(2)*e)/(-S(36)*x + S(72)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x + S(2))*(d + e*x + f*x**S(2))/(x**S(4) - S(5)*x**S(2) + S(4))**S(2), x), x, (d/S(144) - e/S(72) + f/S(36))*log(x + S(2)) + (d/S(54) + e/S(108) - f/S(27))*log(x + S(1)) + (d/S(18) + S(5)*e/S(36) + S(2)*f/S(9))*log(-x + S(1)) - (S(35)*d/S(432) + S(29)*e/S(216) + S(23)*f/S(108))*log(-x + S(2)) - (d - e + f)/(S(36)*x + S(36)) + (d + e + f)/(-S(12)*x + S(12)) + (d + S(2)*e + S(4)*f)/(-S(36)*x + S(72)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x + S(2))*(d + e*x + f*x**S(2) + g*x**S(3))/(x**S(4) - S(5)*x**S(2) + S(4))**S(2), x), x, (d/S(144) - e/S(72) + f/S(36) - g/S(18))*log(x + S(2)) + (d/S(54) + e/S(108) - f/S(27) + S(7)*g/S(108))*log(x + S(1)) + (d/S(18) + S(5)*e/S(36) + S(2)*f/S(9) + S(11)*g/S(36))*log(-x + S(1)) - (S(35)*d/S(432) + S(29)*e/S(216) + S(23)*f/S(108) + S(17)*g/S(54))*log(-x + S(2)) - (d - e + f - g)/(S(36)*x + S(36)) + (d + e + f + g)/(-S(12)*x + S(12)) + (d + S(2)*e + S(4)*f + S(8)*g)/(-S(36)*x + S(72)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x + S(2))*(d + e*x + f*x**S(2) + g*x**S(3) + h*x**S(4))/(x**S(4) - S(5)*x**S(2) + S(4))**S(2), x), x, (d/S(144) - e/S(72) + f/S(36) - g/S(18) + h/S(9))*log(x + S(2)) + (d/S(54) + e/S(108) - f/S(27) + S(7)*g/S(108) - S(5)*h/S(54))*log(x + S(1)) + (d/S(18) + S(5)*e/S(36) + S(2)*f/S(9) + S(11)*g/S(36) + S(7)*h/S(18))*log(-x + S(1)) - (S(35)*d/S(432) + S(29)*e/S(216) + S(23)*f/S(108) + S(17)*g/S(54) + S(11)*h/S(27))*log(-x + S(2)) - (d - e + f - g + h)/(S(36)*x + S(36)) + (d + e + f + g + h)/(-S(12)*x + S(12)) + (d + S(2)*e + S(4)*f + S(8)*g + S(16)*h)/(-S(36)*x + S(72)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((x + S(2))*(d + e*x + f*x**S(2) + g*x**S(3) + h*x**S(4) + i*x**S(5))/(x**S(4) - S(5)*x**S(2) + S(4))**S(2), x), x, (d/S(144) - e/S(72) + f/S(36) - g/S(18) + h/S(9) - S(2)*i/S(9))*log(x + S(2)) + (d/S(54) + e/S(108) - f/S(27) + S(7)*g/S(108) - S(5)*h/S(54) + S(13)*i/S(108))*log(x + S(1)) + (d/S(18) + S(5)*e/S(36) + S(2)*f/S(9) + S(11)*g/S(36) + S(7)*h/S(18) + S(17)*i/S(36))*log(-x + S(1)) - (S(35)*d/S(432) + S(29)*e/S(216) + S(23)*f/S(108) + S(17)*g/S(54) + S(11)*h/S(27) + S(10)*i/S(27))*log(-x + S(2)) - (d - e + f - g + h - i)/(S(36)*x + S(36)) + (d + e + f + g + h + i)/(-S(12)*x + S(12)) + (d + S(2)*e + S(4)*f + S(8)*g + S(16)*h + S(32)*i)/(-S(36)*x + S(72)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a*g - c*g*x**S(4))/(a + b*x**S(2) + c*x**S(4))**(S(3)/2), x), x, g*x/sqrt(a + b*x**S(2) + c*x**S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a*g - c*g*x**S(4) + e*x)/(a + b*x**S(2) + c*x**S(4))**(S(3)/2), x), x, -(b*e + S(2)*c*e*x**S(2) - g*x*(-S(4)*a*c + b**S(2)))/((-S(4)*a*c + b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a*g - c*g*x**S(4) + f*x**S(3))/(a + b*x**S(2) + c*x**S(4))**(S(3)/2), x), x, (S(2)*a*f + b*f*x**S(2) + g*x*(-S(4)*a*c + b**S(2)))/((-S(4)*a*c + b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a*g - c*g*x**S(4) + e*x + f*x**S(3))/(a + b*x**S(2) + c*x**S(4))**(S(3)/2), x), x, -(-S(2)*a*f + b*e - g*x*(-S(4)*a*c + b**S(2)) + x**S(2)*(-b*f + S(2)*c*e))/((-S(4)*a*c + b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
# large time assert rubi_test(rubi_integrate((d + e*x + f*x**S(2) + g*x**S(3) + h*x**S(4) + j*x**S(5) + k*x**S(6) + l*x**S(7) + m*x**S(8))/(a + b*x**S(3) + c*x**S(6)), x), x, k*x/c + l*x**S(2)/(S(2)*c) + m*x**S(3)/(S(3)*c) + (-b*m + c*j)*log(a + b*x**S(3) + c*x**S(6))/(S(6)*c**S(2)) - (-S(2)*a*c*m + b**S(2)*m - b*c*j + S(2)*c**S(2)*f)*atanh((b + S(2)*c*x**S(3))/sqrt(-S(4)*a*c + b**S(2)))/(S(3)*c**S(2)*sqrt(-S(4)*a*c + b**S(2))) + S(2)**(S(2)/3)*(-b*k/c + g - (-S(2)*a*c*k + b**S(2)*k - b*c*g + S(2)*c**S(2)*d)/(c*sqrt(-S(4)*a*c + b**S(2))))*log(S(2)**(S(1)/3)*c**(S(1)/3)*x + (b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3))/(S(6)*c**(S(1)/3)*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)) - S(2)**(S(2)/3)*(-b*k/c + g - (-S(2)*a*c*k + b**S(2)*k - b*c*g + S(2)*c**S(2)*d)/(c*sqrt(-S(4)*a*c + b**S(2))))*log(S(2)**(S(2)/3)*c**(S(2)/3)*x**S(2) - S(2)**(S(1)/3)*c**(S(1)/3)*x*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + (b + sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3))/(S(12)*c**(S(1)/3)*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)) - S(2)**(S(2)/3)*sqrt(S(3))*(-b*k/c + g - (-S(2)*a*c*k + b**S(2)*k - b*c*g + S(2)*c**S(2)*d)/(c*sqrt(-S(4)*a*c + b**S(2))))*atan(sqrt(S(3))*(-S(2)*S(2)**(S(1)/3)*c**(S(1)/3)*x/(b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + S(1))/S(3))/(S(6)*c**(S(1)/3)*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)) + S(2)**(S(2)/3)*(-b*k/c + g + (b**S(2)*k + S(2)*c**S(2)*d - c*(S(2)*a*k + b*g))/(c*sqrt(-S(4)*a*c + b**S(2))))*log(S(2)**(S(1)/3)*c**(S(1)/3)*x + (b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3))/(S(6)*c**(S(1)/3)*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)) - S(2)**(S(2)/3)*(-b*k/c + g + (b**S(2)*k + S(2)*c**S(2)*d - c*(S(2)*a*k + b*g))/(c*sqrt(-S(4)*a*c + b**S(2))))*log(S(2)**(S(2)/3)*c**(S(2)/3)*x**S(2) - S(2)**(S(1)/3)*c**(S(1)/3)*x*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + (b - sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3))/(S(12)*c**(S(1)/3)*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)) - S(2)**(S(2)/3)*sqrt(S(3))*(-b*k/c + g + (b**S(2)*k + S(2)*c**S(2)*d - c*(S(2)*a*k + b*g))/(c*sqrt(-S(4)*a*c + b**S(2))))*atan(sqrt(S(3))*(-S(2)*S(2)**(S(1)/3)*c**(S(1)/3)*x/(b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + S(1))/S(3))/(S(6)*c**(S(1)/3)*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3)) - S(2)**(S(1)/3)*(-b*l/c + h - (-S(2)*a*c*l + b**S(2)*l - b*c*h + S(2)*c**S(2)*e)/(c*sqrt(-S(4)*a*c + b**S(2))))*log(S(2)**(S(1)/3)*c**(S(1)/3)*x + (b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3))/(S(6)*c**(S(2)/3)*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3)) + S(2)**(S(1)/3)*(-b*l/c + h - (-S(2)*a*c*l + b**S(2)*l - b*c*h + S(2)*c**S(2)*e)/(c*sqrt(-S(4)*a*c + b**S(2))))*log(S(2)**(S(2)/3)*c**(S(2)/3)*x**S(2) - S(2)**(S(1)/3)*c**(S(1)/3)*x*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + (b + sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3))/(S(12)*c**(S(2)/3)*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3)) - S(2)**(S(1)/3)*sqrt(S(3))*(-b*l/c + h - (-S(2)*a*c*l + b**S(2)*l - b*c*h + S(2)*c**S(2)*e)/(c*sqrt(-S(4)*a*c + b**S(2))))*atan(sqrt(S(3))*(-S(2)*S(2)**(S(1)/3)*c**(S(1)/3)*x/(b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + S(1))/S(3))/(S(6)*c**(S(2)/3)*(b + sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3)) - S(2)**(S(1)/3)*(-b*l/c + h + (b**S(2)*l + S(2)*c**S(2)*e - c*(S(2)*a*l + b*h))/(c*sqrt(-S(4)*a*c + b**S(2))))*log(S(2)**(S(1)/3)*c**(S(1)/3)*x + (b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3))/(S(6)*c**(S(2)/3)*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3)) + S(2)**(S(1)/3)*(-b*l/c + h + (b**S(2)*l + S(2)*c**S(2)*e - c*(S(2)*a*l + b*h))/(c*sqrt(-S(4)*a*c + b**S(2))))*log(S(2)**(S(2)/3)*c**(S(2)/3)*x**S(2) - S(2)**(S(1)/3)*c**(S(1)/3)*x*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + (b - sqrt(-S(4)*a*c + b**S(2)))**(S(2)/3))/(S(12)*c**(S(2)/3)*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3)) - S(2)**(S(1)/3)*sqrt(S(3))*(-b*l/c + h + (b**S(2)*l + S(2)*c**S(2)*e - c*(S(2)*a*l + b*h))/(c*sqrt(-S(4)*a*c + b**S(2))))*atan(sqrt(S(3))*(-S(2)*S(2)**(S(1)/3)*c**(S(1)/3)*x/(b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3) + S(1))/S(3))/(S(6)*c**(S(2)/3)*(b - sqrt(-S(4)*a*c + b**S(2)))**(S(1)/3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(a + b*x**n + c*x**(S(2)*n)), x), x, -S(2)*c*x*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(-S(4)*a*c + b**S(2) + b*sqrt(-S(4)*a*c + b**S(2))) - S(2)*c*x*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))))/(-S(4)*a*c + b**S(2) - b*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x)/(a + b*x**n + c*x**(S(2)*n)), x), x, -S(2)*c*d*x*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(-S(4)*a*c + b**S(2) + b*sqrt(-S(4)*a*c + b**S(2))) - S(2)*c*d*x*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))))/(-S(4)*a*c + b**S(2) - b*sqrt(-S(4)*a*c + b**S(2))) - c*e*x**S(2)*hyper((S(1), S(2)/n), ((n + S(2))/n,), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(-S(4)*a*c + b**S(2) + b*sqrt(-S(4)*a*c + b**S(2))) - c*e*x**S(2)*hyper((S(1), S(2)/n), ((n + S(2))/n,), -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))))/(-S(4)*a*c + b**S(2) - b*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*x**S(2))/(a + b*x**n + c*x**(S(2)*n)), x), x, -S(2)*c*d*x*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(-S(4)*a*c + b**S(2) + b*sqrt(-S(4)*a*c + b**S(2))) - S(2)*c*d*x*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))))/(-S(4)*a*c + b**S(2) - b*sqrt(-S(4)*a*c + b**S(2))) - c*e*x**S(2)*hyper((S(1), S(2)/n), ((n + S(2))/n,), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(-S(4)*a*c + b**S(2) + b*sqrt(-S(4)*a*c + b**S(2))) - c*e*x**S(2)*hyper((S(1), S(2)/n), ((n + S(2))/n,), -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))))/(-S(4)*a*c + b**S(2) - b*sqrt(-S(4)*a*c + b**S(2))) - S(2)*c*f*x**S(3)*hyper((S(1), S(3)/n), ((n + S(3))/n,), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(-S(12)*a*c + S(3)*b**S(2) + S(3)*b*sqrt(-S(4)*a*c + b**S(2))) - S(2)*c*f*x**S(3)*hyper((S(1), S(3)/n), ((n + S(3))/n,), -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))))/(-S(12)*a*c + S(3)*b**S(2) - S(3)*b*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*x**S(2) + g*x**S(3))/(a + b*x**n + c*x**(S(2)*n)), x), x, -S(2)*c*d*x*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(-S(4)*a*c + b**S(2) + b*sqrt(-S(4)*a*c + b**S(2))) - S(2)*c*d*x*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))))/(-S(4)*a*c + b**S(2) - b*sqrt(-S(4)*a*c + b**S(2))) - c*e*x**S(2)*hyper((S(1), S(2)/n), ((n + S(2))/n,), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(-S(4)*a*c + b**S(2) + b*sqrt(-S(4)*a*c + b**S(2))) - c*e*x**S(2)*hyper((S(1), S(2)/n), ((n + S(2))/n,), -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))))/(-S(4)*a*c + b**S(2) - b*sqrt(-S(4)*a*c + b**S(2))) - S(2)*c*f*x**S(3)*hyper((S(1), S(3)/n), ((n + S(3))/n,), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(-S(12)*a*c + S(3)*b**S(2) + S(3)*b*sqrt(-S(4)*a*c + b**S(2))) - S(2)*c*f*x**S(3)*hyper((S(1), S(3)/n), ((n + S(3))/n,), -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))))/(-S(12)*a*c + S(3)*b**S(2) - S(3)*b*sqrt(-S(4)*a*c + b**S(2))) - c*g*x**S(4)*hyper((S(1), S(4)/n), ((n + S(4))/n,), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(-S(8)*a*c + S(2)*b**S(2) + S(2)*b*sqrt(-S(4)*a*c + b**S(2))) - c*g*x**S(4)*hyper((S(1), S(4)/n), ((n + S(4))/n,), -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))))/(-S(8)*a*c + S(2)*b**S(2) - S(2)*b*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**n + c*x**(S(2)*n))**(S(-2)), x), x, -c*x*(S(4)*a*c*(-S(2)*n + S(1)) - b**S(2)*(-n + S(1)) + b*(-n + S(1))*sqrt(-S(4)*a*c + b**S(2)))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(a*n*(-S(4)*a*c + b**S(2))*(-S(4)*a*c + b**S(2) + b*sqrt(-S(4)*a*c + b**S(2)))) - c*x*(S(4)*a*c*(-S(2)*n + S(1)) - b**S(2)*(-n + S(1)) - b*(-n + S(1))*sqrt(-S(4)*a*c + b**S(2)))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))))/(a*n*(-S(4)*a*c + b**S(2))*(-S(4)*a*c + b**S(2) - b*sqrt(-S(4)*a*c + b**S(2)))) + x*(-S(2)*a*c + b**S(2) + b*c*x**n)/(a*n*(-S(4)*a*c + b**S(2))*(a + b*x**n + c*x**(S(2)*n))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x)/(a + b*x**n + c*x**(S(2)*n))**S(2), x), x, S(2)*b*c**S(2)*e*x**(n + S(2))*(-n + S(2))*hyper((S(1), (n + S(2))/n), (S(2) + S(2)/n,), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(a*n*(b + sqrt(-S(4)*a*c + b**S(2)))*(n + S(2))*(-S(4)*a*c + b**S(2))**(S(3)/2)) - S(2)*b*c**S(2)*e*x**(n + S(2))*(-n + S(2))*hyper((S(1), (n + S(2))/n), (S(2) + S(2)/n,), -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))))/(a*n*(b - sqrt(-S(4)*a*c + b**S(2)))*(n + S(2))*(-S(4)*a*c + b**S(2))**(S(3)/2)) - c*d*x*(S(4)*a*c*(-S(2)*n + S(1)) - b**S(2)*(-n + S(1)) + b*(-n + S(1))*sqrt(-S(4)*a*c + b**S(2)))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(a*n*(-S(4)*a*c + b**S(2))*(-S(4)*a*c + b**S(2) + b*sqrt(-S(4)*a*c + b**S(2)))) - c*d*x*(S(4)*a*c*(-S(2)*n + S(1)) - b**S(2)*(-n + S(1)) - b*(-n + S(1))*sqrt(-S(4)*a*c + b**S(2)))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))))/(a*n*(-S(4)*a*c + b**S(2))*(-S(4)*a*c + b**S(2) - b*sqrt(-S(4)*a*c + b**S(2)))) - c*e*x**S(2)*(S(4)*a*c*(-n + S(1)) - b**S(2)*(-n + S(2)))*hyper((S(1), S(2)/n), ((n + S(2))/n,), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(a*n*(-S(4)*a*c + b**S(2))*(-S(4)*a*c + b**S(2) + b*sqrt(-S(4)*a*c + b**S(2)))) - c*e*x**S(2)*(S(4)*a*c*(-n + S(1)) - b**S(2)*(-n + S(2)))*hyper((S(1), S(2)/n), ((n + S(2))/n,), -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))))/(a*n*(-S(4)*a*c + b**S(2))*(-S(4)*a*c + b**S(2) - b*sqrt(-S(4)*a*c + b**S(2)))) + d*x*(-S(2)*a*c + b**S(2) + b*c*x**n)/(a*n*(-S(4)*a*c + b**S(2))*(a + b*x**n + c*x**(S(2)*n))) + e*x**S(2)*(-S(2)*a*c + b**S(2) + b*c*x**n)/(a*n*(-S(4)*a*c + b**S(2))*(a + b*x**n + c*x**(S(2)*n))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*x**S(2))/(a + b*x**n + c*x**(S(2)*n))**S(2), x), x, S(2)*b*c**S(2)*e*x**(n + S(2))*(-n + S(2))*hyper((S(1), (n + S(2))/n), (S(2) + S(2)/n,), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(a*n*(b + sqrt(-S(4)*a*c + b**S(2)))*(n + S(2))*(-S(4)*a*c + b**S(2))**(S(3)/2)) - S(2)*b*c**S(2)*e*x**(n + S(2))*(-n + S(2))*hyper((S(1), (n + S(2))/n), (S(2) + S(2)/n,), -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))))/(a*n*(b - sqrt(-S(4)*a*c + b**S(2)))*(n + S(2))*(-S(4)*a*c + b**S(2))**(S(3)/2)) + S(2)*b*c**S(2)*f*x**(n + S(3))*(-n + S(3))*hyper((S(1), (n + S(3))/n), (S(2) + S(3)/n,), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(a*n*(b + sqrt(-S(4)*a*c + b**S(2)))*(n + S(3))*(-S(4)*a*c + b**S(2))**(S(3)/2)) - S(2)*b*c**S(2)*f*x**(n + S(3))*(-n + S(3))*hyper((S(1), (n + S(3))/n), (S(2) + S(3)/n,), -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))))/(a*n*(b - sqrt(-S(4)*a*c + b**S(2)))*(n + S(3))*(-S(4)*a*c + b**S(2))**(S(3)/2)) - c*d*x*(S(4)*a*c*(-S(2)*n + S(1)) - b**S(2)*(-n + S(1)) + b*(-n + S(1))*sqrt(-S(4)*a*c + b**S(2)))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(a*n*(-S(4)*a*c + b**S(2))*(-S(4)*a*c + b**S(2) + b*sqrt(-S(4)*a*c + b**S(2)))) - c*d*x*(S(4)*a*c*(-S(2)*n + S(1)) - b**S(2)*(-n + S(1)) - b*(-n + S(1))*sqrt(-S(4)*a*c + b**S(2)))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))))/(a*n*(-S(4)*a*c + b**S(2))*(-S(4)*a*c + b**S(2) - b*sqrt(-S(4)*a*c + b**S(2)))) - c*e*x**S(2)*(S(4)*a*c*(-n + S(1)) - b**S(2)*(-n + S(2)))*hyper((S(1), S(2)/n), ((n + S(2))/n,), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(a*n*(-S(4)*a*c + b**S(2))*(-S(4)*a*c + b**S(2) + b*sqrt(-S(4)*a*c + b**S(2)))) - c*e*x**S(2)*(S(4)*a*c*(-n + S(1)) - b**S(2)*(-n + S(2)))*hyper((S(1), S(2)/n), ((n + S(2))/n,), -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))))/(a*n*(-S(4)*a*c + b**S(2))*(-S(4)*a*c + b**S(2) - b*sqrt(-S(4)*a*c + b**S(2)))) - S(2)*c*f*x**S(3)*(S(2)*a*c*(-S(2)*n + S(3)) - b**S(2)*(-n + S(3)))*hyper((S(1), S(3)/n), ((n + S(3))/n,), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(3)*a*n*(-S(4)*a*c + b**S(2))*(-S(4)*a*c + b**S(2) + b*sqrt(-S(4)*a*c + b**S(2)))) - S(2)*c*f*x**S(3)*(S(2)*a*c*(-S(2)*n + S(3)) - b**S(2)*(-n + S(3)))*hyper((S(1), S(3)/n), ((n + S(3))/n,), -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))))/(S(3)*a*n*(-S(4)*a*c + b**S(2))*(-S(4)*a*c + b**S(2) - b*sqrt(-S(4)*a*c + b**S(2)))) + d*x*(-S(2)*a*c + b**S(2) + b*c*x**n)/(a*n*(-S(4)*a*c + b**S(2))*(a + b*x**n + c*x**(S(2)*n))) + e*x**S(2)*(-S(2)*a*c + b**S(2) + b*c*x**n)/(a*n*(-S(4)*a*c + b**S(2))*(a + b*x**n + c*x**(S(2)*n))) + f*x**S(3)*(-S(2)*a*c + b**S(2) + b*c*x**n)/(a*n*(-S(4)*a*c + b**S(2))*(a + b*x**n + c*x**(S(2)*n))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d + e*x + f*x**S(2) + g*x**S(3))/(a + b*x**n + c*x**(S(2)*n))**S(2), x), x, S(2)*b*c**S(2)*e*x**(n + S(2))*(-n + S(2))*hyper((S(1), (n + S(2))/n), (S(2) + S(2)/n,), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(a*n*(b + sqrt(-S(4)*a*c + b**S(2)))*(n + S(2))*(-S(4)*a*c + b**S(2))**(S(3)/2)) - S(2)*b*c**S(2)*e*x**(n + S(2))*(-n + S(2))*hyper((S(1), (n + S(2))/n), (S(2) + S(2)/n,), -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))))/(a*n*(b - sqrt(-S(4)*a*c + b**S(2)))*(n + S(2))*(-S(4)*a*c + b**S(2))**(S(3)/2)) + S(2)*b*c**S(2)*f*x**(n + S(3))*(-n + S(3))*hyper((S(1), (n + S(3))/n), (S(2) + S(3)/n,), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(a*n*(b + sqrt(-S(4)*a*c + b**S(2)))*(n + S(3))*(-S(4)*a*c + b**S(2))**(S(3)/2)) - S(2)*b*c**S(2)*f*x**(n + S(3))*(-n + S(3))*hyper((S(1), (n + S(3))/n), (S(2) + S(3)/n,), -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))))/(a*n*(b - sqrt(-S(4)*a*c + b**S(2)))*(n + S(3))*(-S(4)*a*c + b**S(2))**(S(3)/2)) + S(2)*b*c**S(2)*g*x**(n + S(4))*(-n + S(4))*hyper((S(1), (n + S(4))/n), (S(2) + S(4)/n,), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(a*n*(b + sqrt(-S(4)*a*c + b**S(2)))*(n + S(4))*(-S(4)*a*c + b**S(2))**(S(3)/2)) - S(2)*b*c**S(2)*g*x**(n + S(4))*(-n + S(4))*hyper((S(1), (n + S(4))/n), (S(2) + S(4)/n,), -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))))/(a*n*(b - sqrt(-S(4)*a*c + b**S(2)))*(n + S(4))*(-S(4)*a*c + b**S(2))**(S(3)/2)) - c*d*x*(S(4)*a*c*(-S(2)*n + S(1)) - b**S(2)*(-n + S(1)) + b*(-n + S(1))*sqrt(-S(4)*a*c + b**S(2)))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(a*n*(-S(4)*a*c + b**S(2))*(-S(4)*a*c + b**S(2) + b*sqrt(-S(4)*a*c + b**S(2)))) - c*d*x*(S(4)*a*c*(-S(2)*n + S(1)) - b**S(2)*(-n + S(1)) - b*(-n + S(1))*sqrt(-S(4)*a*c + b**S(2)))*hyper((S(1), S(1)/n), (S(1) + S(1)/n,), -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))))/(a*n*(-S(4)*a*c + b**S(2))*(-S(4)*a*c + b**S(2) - b*sqrt(-S(4)*a*c + b**S(2)))) - c*e*x**S(2)*(S(4)*a*c*(-n + S(1)) - b**S(2)*(-n + S(2)))*hyper((S(1), S(2)/n), ((n + S(2))/n,), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(a*n*(-S(4)*a*c + b**S(2))*(-S(4)*a*c + b**S(2) + b*sqrt(-S(4)*a*c + b**S(2)))) - c*e*x**S(2)*(S(4)*a*c*(-n + S(1)) - b**S(2)*(-n + S(2)))*hyper((S(1), S(2)/n), ((n + S(2))/n,), -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))))/(a*n*(-S(4)*a*c + b**S(2))*(-S(4)*a*c + b**S(2) - b*sqrt(-S(4)*a*c + b**S(2)))) - S(2)*c*f*x**S(3)*(S(2)*a*c*(-S(2)*n + S(3)) - b**S(2)*(-n + S(3)))*hyper((S(1), S(3)/n), ((n + S(3))/n,), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(3)*a*n*(-S(4)*a*c + b**S(2))*(-S(4)*a*c + b**S(2) + b*sqrt(-S(4)*a*c + b**S(2)))) - S(2)*c*f*x**S(3)*(S(2)*a*c*(-S(2)*n + S(3)) - b**S(2)*(-n + S(3)))*hyper((S(1), S(3)/n), ((n + S(3))/n,), -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))))/(S(3)*a*n*(-S(4)*a*c + b**S(2))*(-S(4)*a*c + b**S(2) - b*sqrt(-S(4)*a*c + b**S(2)))) - c*g*x**S(4)*(S(4)*a*c*(-n + S(2)) - b**S(2)*(-n + S(4)))*hyper((S(1), S(4)/n), ((n + S(4))/n,), -S(2)*c*x**n/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*a*n*(-S(4)*a*c + b**S(2))*(-S(4)*a*c + b**S(2) + b*sqrt(-S(4)*a*c + b**S(2)))) - c*g*x**S(4)*(S(4)*a*c*(-n + S(2)) - b**S(2)*(-n + S(4)))*hyper((S(1), S(4)/n), ((n + S(4))/n,), -S(2)*c*x**n/(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*a*n*(-S(4)*a*c + b**S(2))*(-S(4)*a*c + b**S(2) - b*sqrt(-S(4)*a*c + b**S(2)))) + d*x*(-S(2)*a*c + b**S(2) + b*c*x**n)/(a*n*(-S(4)*a*c + b**S(2))*(a + b*x**n + c*x**(S(2)*n))) + e*x**S(2)*(-S(2)*a*c + b**S(2) + b*c*x**n)/(a*n*(-S(4)*a*c + b**S(2))*(a + b*x**n + c*x**(S(2)*n))) + f*x**S(3)*(-S(2)*a*c + b**S(2) + b*c*x**n)/(a*n*(-S(4)*a*c + b**S(2))*(a + b*x**n + c*x**(S(2)*n))) + g*x**S(4)*(-S(2)*a*c + b**S(2) + b*c*x**n)/(a*n*(-S(4)*a*c + b**S(2))*(a + b*x**n + c*x**(S(2)*n))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((-a*h*x**(n/S(2) + S(-1)) + c*f*x**(n + S(-1)) + c*g*x**(S(2)*n + S(-1)) + c*h*x**(S(5)*n/S(2) + S(-1)))/(a + b*x**n + c*x**(S(2)*n))**(S(3)/2), x), x, -(S(2)*c*x**n*(-b*g + S(2)*c*f) + S(2)*c*(-S(2)*a*g + b*f) + S(2)*h*x**(n/S(2))*(-S(4)*a*c + b**S(2)))/(n*(-S(4)*a*c + b**S(2))*sqrt(a + b*x**n + c*x**(S(2)*n))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a + b*x**n + c*x**(S(2)*n))**p*(a + b*x**n*(n*p + n + S(1)) + c*x**(S(2)*n)*(S(2)*n*(p + S(1)) + S(1))), x), x, x*(a + b*x**n + c*x**(S(2)*n))**(p + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**m*(A + B*x + C*x**S(2))*(a + b*x**S(2) + c*x**S(4)), x), x, A*a*x**(m + S(1))/(m + S(1)) + B*a*x**(m + S(2))/(m + S(2)) + B*b*x**(m + S(4))/(m + S(4)) + B*c*x**(m + S(6))/(m + S(6)) + C*c*x**(m + S(7))/(m + S(7)) + x**(m + S(3))*(A*b + C*a)/(m + S(3)) + x**(m + S(5))*(A*c + C*b)/(m + S(5)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*(A + B*x + C*x**S(2))*(a + b*x**S(2) + c*x**S(4)), x), x, A*a*x**S(4)/S(4) + B*a*x**S(5)/S(5) + B*b*x**S(7)/S(7) + B*c*x**S(9)/S(9) + C*c*x**S(10)/S(10) + x**S(8)*(A*c/S(8) + C*b/S(8)) + x**S(6)*(A*b/S(6) + C*a/S(6)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(A + B*x + C*x**S(2))*(a + b*x**S(2) + c*x**S(4)), x), x, A*a*x**S(3)/S(3) + B*a*x**S(4)/S(4) + B*b*x**S(6)/S(6) + B*c*x**S(8)/S(8) + C*c*x**S(9)/S(9) + x**S(7)*(A*c/S(7) + C*b/S(7)) + x**S(5)*(A*b/S(5) + C*a/S(5)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(A + B*x + C*x**S(2))*(a + b*x**S(2) + c*x**S(4)), x), x, A*a*x**S(2)/S(2) + B*a*x**S(3)/S(3) + B*b*x**S(5)/S(5) + B*c*x**S(7)/S(7) + C*c*x**S(8)/S(8) + x**S(6)*(A*c/S(6) + C*b/S(6)) + x**S(4)*(A*b/S(4) + C*a/S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((A + B*x + C*x**S(2))*(a + b*x**S(2) + c*x**S(4)), x), x, A*a*x + B*a*x**S(2)/S(2) + B*b*x**S(4)/S(4) + B*c*x**S(6)/S(6) + C*c*x**S(7)/S(7) + x**S(5)*(A*c/S(5) + C*b/S(5)) + x**S(3)*(A*b/S(3) + C*a/S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((A + B*x + C*x**S(2))*(a + b*x**S(2) + c*x**S(4))/x, x), x, A*a*log(x) + B*a*x + B*b*x**S(3)/S(3) + B*c*x**S(5)/S(5) + C*c*x**S(6)/S(6) + x**S(4)*(A*c/S(4) + C*b/S(4)) + x**S(2)*(A*b/S(2) + C*a/S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((A + B*x + C*x**S(2))*(a + b*x**S(2) + c*x**S(4))/x**S(2), x), x, -A*a/x + B*a*log(x) + B*b*x**S(2)/S(2) + B*c*x**S(4)/S(4) + C*c*x**S(5)/S(5) + x**S(3)*(A*c/S(3) + C*b/S(3)) + x*(A*b + C*a), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((A + B*x + C*x**S(2))*(a + b*x**S(2) + c*x**S(4))/x**S(3), x), x, -A*a/(S(2)*x**S(2)) - B*a/x + B*b*x + B*c*x**S(3)/S(3) + C*c*x**S(4)/S(4) + x**S(2)*(A*c/S(2) + C*b/S(2)) + (A*b + C*a)*log(x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((A + B*x + C*x**S(2))*(a + b*x**S(2) + c*x**S(4))/x**S(4), x), x, -A*a/(S(3)*x**S(3)) - B*a/(S(2)*x**S(2)) + B*b*log(x) + B*c*x**S(2)/S(2) + C*c*x**S(3)/S(3) + x*(A*c + C*b) - (A*b + C*a)/x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((A + B*x + C*x**S(2))*(a + b*x**S(2) + c*x**S(4))/x**S(5), x), x, -A*a/(S(4)*x**S(4)) - B*a/(S(3)*x**S(3)) - B*b/x + B*c*x + C*c*x**S(2)/S(2) + (A*c + C*b)*log(x) - (A*b + C*a)/(S(2)*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((A + B*x + C*x**S(2))*(a + b*x**S(2) + c*x**S(4))/x**S(6), x), x, -A*a/(S(5)*x**S(5)) - B*a/(S(4)*x**S(4)) - B*b/(S(2)*x**S(2)) + B*c*log(x) + C*c*x - (A*c + C*b)/x - (A*b + C*a)/(S(3)*x**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((A + B*x + C*x**S(2))*(a + b*x**S(2) + c*x**S(4))/x**S(7), x), x, -A*a/(S(6)*x**S(6)) - B*a/(S(5)*x**S(5)) - B*b/(S(3)*x**S(3)) - B*c/x + C*c*log(x) - (A*c + C*b)/(S(2)*x**S(2)) - (A*b + C*a)/(S(4)*x**S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**m*(A + B*x + C*x**S(2))*(a + b*x**S(2) + c*x**S(4))**S(2), x), x, A*a**S(2)*x**(m + S(1))/(m + S(1)) + B*a**S(2)*x**(m + S(2))/(m + S(2)) + S(2)*B*a*b*x**(m + S(4))/(m + S(4)) + S(2)*B*b*c*x**(m + S(8))/(m + S(8)) + B*c**S(2)*x**(m + S(10))/(m + S(10)) + B*x**(m + S(6))*(S(2)*a*c + b**S(2))/(m + S(6)) + C*c**S(2)*x**(m + S(11))/(m + S(11)) + a*x**(m + S(3))*(S(2)*A*b + C*a)/(m + S(3)) + c*x**(m + S(9))*(A*c + S(2)*C*b)/(m + S(9)) + x**(m + S(5))*(A*(S(2)*a*c + b**S(2)) + S(2)*C*a*b)/(m + S(5)) + x**(m + S(7))*(S(2)*A*b*c + C*(S(2)*a*c + b**S(2)))/(m + S(7)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*(A + B*x + C*x**S(2))*(a + b*x**S(2) + c*x**S(4))**S(2), x), x, A*a**S(2)*x**S(4)/S(4) + B*a**S(2)*x**S(5)/S(5) + S(2)*B*a*b*x**S(7)/S(7) + S(2)*B*b*c*x**S(11)/S(11) + B*c**S(2)*x**S(13)/S(13) + B*x**S(9)*(S(2)*a*c + b**S(2))/S(9) + C*c**S(2)*x**S(14)/S(14) + a*x**S(6)*(S(2)*A*b + C*a)/S(6) + c*x**S(12)*(A*c + S(2)*C*b)/S(12) + x**S(10)*(A*b*c/S(5) + C*(S(2)*a*c + b**S(2))/S(10)) + x**S(8)*(A*(S(2)*a*c + b**S(2))/S(8) + C*a*b/S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(A + B*x + C*x**S(2))*(a + b*x**S(2) + c*x**S(4))**S(2), x), x, A*a**S(2)*x**S(3)/S(3) + B*a**S(2)*x**S(4)/S(4) + B*a*b*x**S(6)/S(3) + B*b*c*x**S(10)/S(5) + B*c**S(2)*x**S(12)/S(12) + B*x**S(8)*(S(2)*a*c + b**S(2))/S(8) + C*c**S(2)*x**S(13)/S(13) + a*x**S(5)*(S(2)*A*b + C*a)/S(5) + c*x**S(11)*(A*c + S(2)*C*b)/S(11) + x**S(9)*(S(2)*A*b*c/S(9) + C*(S(2)*a*c + b**S(2))/S(9)) + x**S(7)*(A*(S(2)*a*c + b**S(2))/S(7) + S(2)*C*a*b/S(7)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(A + B*x + C*x**S(2))*(a + b*x**S(2) + c*x**S(4))**S(2), x), x, A*a**S(2)*x**S(2)/S(2) + B*a**S(2)*x**S(3)/S(3) + S(2)*B*a*b*x**S(5)/S(5) + S(2)*B*b*c*x**S(9)/S(9) + B*c**S(2)*x**S(11)/S(11) + B*x**S(7)*(S(2)*a*c + b**S(2))/S(7) + C*c**S(2)*x**S(12)/S(12) + a*x**S(4)*(S(2)*A*b + C*a)/S(4) + c*x**S(10)*(A*c + S(2)*C*b)/S(10) + x**S(8)*(A*b*c/S(4) + C*(S(2)*a*c + b**S(2))/S(8)) + x**S(6)*(A*(S(2)*a*c + b**S(2))/S(6) + C*a*b/S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((A + B*x + C*x**S(2))*(a + b*x**S(2) + c*x**S(4))**S(2), x), x, A*a**S(2)*x + B*a**S(2)*x**S(2)/S(2) + B*a*b*x**S(4)/S(2) + B*b*c*x**S(8)/S(4) + B*c**S(2)*x**S(10)/S(10) + B*x**S(6)*(S(2)*a*c + b**S(2))/S(6) + C*c**S(2)*x**S(11)/S(11) + a*x**S(3)*(S(2)*A*b + C*a)/S(3) + c*x**S(9)*(A*c + S(2)*C*b)/S(9) + x**S(7)*(S(2)*A*b*c/S(7) + C*(S(2)*a*c + b**S(2))/S(7)) + x**S(5)*(A*(S(2)*a*c + b**S(2))/S(5) + S(2)*C*a*b/S(5)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((A + B*x + C*x**S(2))*(a + b*x**S(2) + c*x**S(4))**S(2)/x, x), x, A*a**S(2)*log(x) + B*a**S(2)*x + S(2)*B*a*b*x**S(3)/S(3) + S(2)*B*b*c*x**S(7)/S(7) + B*c**S(2)*x**S(9)/S(9) + B*x**S(5)*(S(2)*a*c + b**S(2))/S(5) + C*c**S(2)*x**S(10)/S(10) + a*x**S(2)*(S(2)*A*b + C*a)/S(2) + c*x**S(8)*(A*c + S(2)*C*b)/S(8) + x**S(6)*(A*b*c/S(3) + C*(S(2)*a*c + b**S(2))/S(6)) + x**S(4)*(A*(S(2)*a*c + b**S(2))/S(4) + C*a*b/S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((A + B*x + C*x**S(2))*(a + b*x**S(2) + c*x**S(4))**S(2)/x**S(2), x), x, -A*a**S(2)/x + B*a**S(2)*log(x) + B*a*b*x**S(2) + B*b*c*x**S(6)/S(3) + B*c**S(2)*x**S(8)/S(8) + B*x**S(4)*(S(2)*a*c + b**S(2))/S(4) + C*c**S(2)*x**S(9)/S(9) + a*x*(S(2)*A*b + C*a) + c*x**S(7)*(A*c + S(2)*C*b)/S(7) + x**S(5)*(S(2)*A*b*c/S(5) + C*(S(2)*a*c + b**S(2))/S(5)) + x**S(3)*(A*(S(2)*a*c + b**S(2))/S(3) + S(2)*C*a*b/S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((A + B*x + C*x**S(2))*(a + b*x**S(2) + c*x**S(4))**S(2)/x**S(3), x), x, -A*a**S(2)/(S(2)*x**S(2)) - B*a**S(2)/x + S(2)*B*a*b*x + S(2)*B*b*c*x**S(5)/S(5) + B*c**S(2)*x**S(7)/S(7) + B*x**S(3)*(S(2)*a*c + b**S(2))/S(3) + C*c**S(2)*x**S(8)/S(8) + a*(S(2)*A*b + C*a)*log(x) + c*x**S(6)*(A*c + S(2)*C*b)/S(6) + x**S(4)*(A*b*c/S(2) + C*(S(2)*a*c + b**S(2))/S(4)) + x**S(2)*(A*(S(2)*a*c + b**S(2))/S(2) + C*a*b), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((A + B*x + C*x**S(2))*(a + b*x**S(2) + c*x**S(4))**S(2)/x**S(4), x), x, -A*a**S(2)/(S(3)*x**S(3)) - B*a**S(2)/(S(2)*x**S(2)) + S(2)*B*a*b*log(x) + B*b*c*x**S(4)/S(2) + B*c**S(2)*x**S(6)/S(6) + B*x**S(2)*(S(2)*a*c + b**S(2))/S(2) + C*c**S(2)*x**S(7)/S(7) - a*(S(2)*A*b + C*a)/x + c*x**S(5)*(A*c + S(2)*C*b)/S(5) + x**S(3)*(S(2)*A*b*c/S(3) + C*(S(2)*a*c + b**S(2))/S(3)) + x*(A*(S(2)*a*c + b**S(2)) + S(2)*C*a*b), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((A + B*x + C*x**S(2))*(a + b*x**S(2) + c*x**S(4))**S(2)/x**S(5), x), x, -A*a**S(2)/(S(4)*x**S(4)) - B*a**S(2)/(S(3)*x**S(3)) - S(2)*B*a*b/x + S(2)*B*b*c*x**S(3)/S(3) + B*c**S(2)*x**S(5)/S(5) + B*x*(S(2)*a*c + b**S(2)) + C*c**S(2)*x**S(6)/S(6) - a*(S(2)*A*b + C*a)/(S(2)*x**S(2)) + c*x**S(4)*(A*c + S(2)*C*b)/S(4) + x**S(2)*(A*b*c + C*(S(2)*a*c + b**S(2))/S(2)) + (A*(S(2)*a*c + b**S(2)) + S(2)*C*a*b)*log(x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((A + B*x + C*x**S(2))*(a + b*x**S(2) + c*x**S(4))**S(2)/x**S(6), x), x, -A*a**S(2)/(S(5)*x**S(5)) - B*a**S(2)/(S(4)*x**S(4)) - B*a*b/x**S(2) + B*b*c*x**S(2) + B*c**S(2)*x**S(4)/S(4) + B*(S(2)*a*c + b**S(2))*log(x) + C*c**S(2)*x**S(5)/S(5) - a*(S(2)*A*b + C*a)/(S(3)*x**S(3)) + c*x**S(3)*(A*c + S(2)*C*b)/S(3) + x*(S(2)*A*b*c + C*(S(2)*a*c + b**S(2))) - (A*(S(2)*a*c + b**S(2)) + S(2)*C*a*b)/x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((A + B*x + C*x**S(2))*(a + b*x**S(2) + c*x**S(4))**S(2)/x**S(7), x), x, -A*a**S(2)/(S(6)*x**S(6)) - B*a**S(2)/(S(5)*x**S(5)) - S(2)*B*a*b/(S(3)*x**S(3)) + S(2)*B*b*c*x + B*c**S(2)*x**S(3)/S(3) - B*(S(2)*a*c + b**S(2))/x + C*c**S(2)*x**S(4)/S(4) - a*(S(2)*A*b + C*a)/(S(4)*x**S(4)) + c*x**S(2)*(A*c + S(2)*C*b)/S(2) + (S(2)*A*b*c + C*(S(2)*a*c + b**S(2)))*log(x) - (A*(S(2)*a*c + b**S(2)) + S(2)*C*a*b)/(S(2)*x**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**m*(A + B*x + C*x**S(2))/(a + b*x**S(2) + c*x**S(4)), x), x, -S(2)*B*c*x**(m + S(2))*hyper((S(1), m/S(2) + S(1)), (m/S(2) + S(2),), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/((b + sqrt(-S(4)*a*c + b**S(2)))*(m + S(2))*sqrt(-S(4)*a*c + b**S(2))) + S(2)*B*c*x**(m + S(2))*hyper((S(1), m/S(2) + S(1)), (m/S(2) + S(2),), -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))))/((b - sqrt(-S(4)*a*c + b**S(2)))*(m + S(2))*sqrt(-S(4)*a*c + b**S(2))) + x**(m + S(1))*(C - (S(2)*A*c - C*b)/sqrt(-S(4)*a*c + b**S(2)))*hyper((S(1), m/S(2) + S(1)/2), (m/S(2) + S(3)/2,), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/((b + sqrt(-S(4)*a*c + b**S(2)))*(m + S(1))) + x**(m + S(1))*(C + (S(2)*A*c - C*b)/sqrt(-S(4)*a*c + b**S(2)))*hyper((S(1), m/S(2) + S(1)/2), (m/S(2) + S(3)/2,), -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))))/((b - sqrt(-S(4)*a*c + b**S(2)))*(m + S(1))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)*(A + B*x + C*x**S(2))/(a + b*x**S(2) + c*x**S(4)), x), x, -B*b*log(a + b*x**S(2) + c*x**S(4))/(S(4)*c**S(2)) + B*x**S(2)/(S(2)*c) - B*(-S(2)*a*c + b**S(2))*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*c**S(2)*sqrt(-S(4)*a*c + b**S(2))) + C*x**S(3)/(S(3)*c) + x*(A*c - C*b)/c**S(2) - sqrt(S(2))*(A*b*c + C*a*c - C*b**S(2) + (A*c*(-S(2)*a*c + b**S(2)) - C*b*(-S(3)*a*c + b**S(2)))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*c**(S(5)/2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))) - sqrt(S(2))*(A*b*c + C*a*c - C*b**S(2) - (A*c*(-S(2)*a*c + b**S(2)) - C*b*(-S(3)*a*c + b**S(2)))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*c**(S(5)/2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*(A + B*x + C*x**S(2))/(a + b*x**S(2) + c*x**S(4)), x), x, B*x/c - sqrt(S(2))*B*(b - (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*c**(S(3)/2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))) - sqrt(S(2))*B*(b + (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*c**(S(3)/2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))) + C*x**S(2)/(S(2)*c) + (A*c - C*b)*log(a + b*x**S(2) + c*x**S(4))/(S(4)*c**S(2)) + (A*b*c + S(2)*C*a*c - C*b**S(2))*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*c**S(2)*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(A + B*x + C*x**S(2))/(a + b*x**S(2) + c*x**S(4)), x), x, B*b*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*c*sqrt(-S(4)*a*c + b**S(2))) + B*log(a + b*x**S(2) + c*x**S(4))/(S(4)*c) + C*x/c + sqrt(S(2))*(A*c - C*b + (A*b*c + S(2)*C*a*c - C*b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*c**(S(3)/2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))) + sqrt(S(2))*(A*c - C*b - (A*b*c - C*(-S(2)*a*c + b**S(2)))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*c**(S(3)/2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(A + B*x + C*x**S(2))/(a + b*x**S(2) + c*x**S(4)), x), x, -sqrt(S(2))*B*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*sqrt(c)*sqrt(-S(4)*a*c + b**S(2))) + sqrt(S(2))*B*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*sqrt(c)*sqrt(-S(4)*a*c + b**S(2))) + C*log(a + b*x**S(2) + c*x**S(4))/(S(4)*c) - (S(2)*A*c - C*b)*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*c*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((A + B*x + C*x**S(2))/(a + b*x**S(2) + c*x**S(4)), x), x, -B*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/sqrt(-S(4)*a*c + b**S(2)) + sqrt(S(2))*(C - (S(2)*A*c - C*b)/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*sqrt(c)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))) + sqrt(S(2))*(C + (S(2)*A*c - C*b)/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*sqrt(c)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((A + B*x + C*x**S(2))/(x*(a + b*x**S(2) + c*x**S(4))), x), x, A*log(x)/a - A*log(a + b*x**S(2) + c*x**S(4))/(S(4)*a) - sqrt(S(2))*B*sqrt(c)*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*sqrt(-S(4)*a*c + b**S(2))) + sqrt(S(2))*B*sqrt(c)*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*sqrt(-S(4)*a*c + b**S(2))) + (A*b - S(2)*C*a)*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*a*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((A + B*x + C*x**S(2))/(x**S(2)*(a + b*x**S(2) + c*x**S(4))), x), x, -A/(a*x) + B*b*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*a*sqrt(-S(4)*a*c + b**S(2))) + B*log(x)/a - B*log(a + b*x**S(2) + c*x**S(4))/(S(4)*a) - sqrt(S(2))*sqrt(c)*(A - (A*b - S(2)*C*a)/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*a*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))) - sqrt(S(2))*sqrt(c)*(A + (A*b - S(2)*C*a)/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*a*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((A + B*x + C*x**S(2))/(x**S(3)*(a + b*x**S(2) + c*x**S(4))), x), x, -A/(S(2)*a*x**S(2)) - sqrt(S(2))*B*sqrt(c)*(-b/sqrt(-S(4)*a*c + b**S(2)) + S(1))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*a*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))) - sqrt(S(2))*B*sqrt(c)*(b/sqrt(-S(4)*a*c + b**S(2)) + S(1))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*a*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))) - B/(a*x) - (A*b - C*a)*log(x)/a**S(2) + (A*b - C*a)*log(a + b*x**S(2) + c*x**S(4))/(S(4)*a**S(2)) - (A*(-S(2)*a*c + b**S(2)) - C*a*b)*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*a**S(2)*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**m*(A + B*x + C*x**S(2))/(a + b*x**S(2) + c*x**S(4))**S(2), x), x, B*c*x**(m + S(2))*(S(4)*a*c*(-m + S(2)) + b*m*(b - sqrt(-S(4)*a*c + b**S(2))))*hyper((S(1), m/S(2) + S(1)), (m/S(2) + S(2),), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*a*(b + sqrt(-S(4)*a*c + b**S(2)))*(m + S(2))*(-S(4)*a*c + b**S(2))**(S(3)/2)) - B*c*x**(m + S(2))*(S(4)*a*c*(-m + S(2)) + b*m*(b + sqrt(-S(4)*a*c + b**S(2))))*hyper((S(1), m/S(2) + S(1)), (m/S(2) + S(2),), -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*a*(b - sqrt(-S(4)*a*c + b**S(2)))*(m + S(2))*(-S(4)*a*c + b**S(2))**(S(3)/2)) + B*x**(m + S(2))*(-S(2)*a*c + b**S(2) + b*c*x**S(2))/(S(2)*a*(-S(4)*a*c + b**S(2))*(a + b*x**S(2) + c*x**S(4))) - c*x**(m + S(1))*(A*(-S(4)*a*c*(-m + S(3)) + b**S(2)*(-m + S(1)) - b*(-m + S(1))*sqrt(-S(4)*a*c + b**S(2))) + S(2)*C*a*(S(2)*b + (-m + S(1))*sqrt(-S(4)*a*c + b**S(2))))*hyper((S(1), m/S(2) + S(1)/2), (m/S(2) + S(3)/2,), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*a*(b + sqrt(-S(4)*a*c + b**S(2)))*(m + S(1))*(-S(4)*a*c + b**S(2))**(S(3)/2)) + c*x**(m + S(1))*(A*(-S(4)*a*c*(-m + S(3)) + b**S(2)*(-m + S(1)) + b*(-m + S(1))*sqrt(-S(4)*a*c + b**S(2))) + S(2)*C*a*(S(2)*b - (-m + S(1))*sqrt(-S(4)*a*c + b**S(2))))*hyper((S(1), m/S(2) + S(1)/2), (m/S(2) + S(3)/2,), -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*a*(b - sqrt(-S(4)*a*c + b**S(2)))*(m + S(1))*(-S(4)*a*c + b**S(2))**(S(3)/2)) + x**(m + S(1))*(A*(-S(2)*a*c + b**S(2)) - C*a*b + c*x**S(2)*(A*b - S(2)*C*a))/(S(2)*a*(-S(4)*a*c + b**S(2))*(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)*(A + B*x + C*x**S(2))/(a + b*x**S(2) + c*x**S(4))**S(2), x), x, S(2)*B*a*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(-S(4)*a*c + b**S(2))**(S(3)/2) + x*(S(2)*B*a*c*x + B*b*c*x**S(3) + a*(S(2)*A*c - C*b) + x**S(2)*(A*b*c + S(2)*C*a*c - C*b**S(2)))/(S(2)*c*(-S(4)*a*c + b**S(2))*(a + b*x**S(2) + c*x**S(4))) + sqrt(S(2))*(A*c*(S(4)*a*c + b**S(2) + b*sqrt(-S(4)*a*c + b**S(2))) + C*(-S(8)*a*b*c - S(6)*a*c*sqrt(-S(4)*a*c + b**S(2)) + b**S(3) + b**S(2)*sqrt(-S(4)*a*c + b**S(2))))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(4)*c**(S(3)/2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)) - sqrt(S(2))*(A*c*(S(4)*a*c + b**S(2) - b*sqrt(-S(4)*a*c + b**S(2))) + C*(-S(8)*a*b*c + S(6)*a*c*sqrt(-S(4)*a*c + b**S(2)) + b**S(3) - b**S(2)*sqrt(-S(4)*a*c + b**S(2))))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(4)*c**(S(3)/2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)*(A + B*x + C*x**S(2))/(a + b*x**S(2) + c*x**S(4))**S(2), x), x, sqrt(S(2))*B*(S(4)*a*c + b**S(2) + b*sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(4)*sqrt(c)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)) - sqrt(S(2))*B*(S(4)*a*c + b**S(2) - b*sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(4)*sqrt(c)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)) + x*(S(2)*B*a + B*b*x**S(2) - x**S(3)*(S(2)*A*c - C*b) - x*(A*b - S(2)*C*a))/((-S(8)*a*c + S(2)*b**S(2))*(a + b*x**S(2) + c*x**S(4))) - (A*b - S(2)*C*a)*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(-S(4)*a*c + b**S(2))**(S(3)/2), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(A + B*x + C*x**S(2))/(a + b*x**S(2) + c*x**S(4))**S(2), x), x, -B*b*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(-S(4)*a*c + b**S(2))**(S(3)/2) - x*(A*b + B*b*x + S(2)*B*c*x**S(3) - S(2)*C*a + x**S(2)*(S(2)*A*c - C*b))/((-S(8)*a*c + S(2)*b**S(2))*(a + b*x**S(2) + c*x**S(4))) - sqrt(S(2))*(S(2)*A*c*(S(2)*b + sqrt(-S(4)*a*c + b**S(2))) - C*(S(4)*a*c + b**S(2) + b*sqrt(-S(4)*a*c + b**S(2))))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(4)*sqrt(c)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)) + sqrt(S(2))*(S(2)*A*c*(S(2)*b - sqrt(-S(4)*a*c + b**S(2))) - C*(S(4)*a*c + b**S(2) - b*sqrt(-S(4)*a*c + b**S(2))))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(4)*sqrt(c)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(A + B*x + C*x**S(2))/(a + b*x**S(2) + c*x**S(4))**S(2), x), x, -sqrt(S(2))*B*sqrt(c)*(S(2)*b + sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)) + sqrt(S(2))*B*sqrt(c)*(S(2)*b - sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)) + (S(2)*A*c - C*b)*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(-S(4)*a*c + b**S(2))**(S(3)/2) - x*(B*a*b + S(2)*B*a*c*x**S(2) - c*x**S(3)*(A*b - S(2)*C*a) - x*(A*(-S(2)*a*c + b**S(2)) - C*a*b))/(S(2)*a*(-S(4)*a*c + b**S(2))*(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((A + B*x + C*x**S(2))/(a + b*x**S(2) + c*x**S(4))**S(2), x), x, S(2)*B*c*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(-S(4)*a*c + b**S(2))**(S(3)/2) + sqrt(S(2))*sqrt(c)*(A*b - S(2)*C*a - (-S(12)*A*a*c + A*b**S(2) + S(4)*C*a*b)/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(4)*a*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))) + sqrt(S(2))*sqrt(c)*(A*b - S(2)*C*a + (A*(-S(12)*a*c + b**S(2)) + S(4)*C*a*b)/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(4)*a*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))) + x*(A*(-S(2)*a*c + b**S(2)) + B*b*c*x**S(3) + B*x*(-S(2)*a*c + b**S(2)) - C*a*b + c*x**S(2)*(A*b - S(2)*C*a))/(S(2)*a*(-S(4)*a*c + b**S(2))*(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((A + B*x + C*x**S(2))/(x*(a + b*x**S(2) + c*x**S(4))**S(2)), x), x, A*log(x)/a**S(2) - A*log(a + b*x**S(2) + c*x**S(4))/(S(4)*a**S(2)) - sqrt(S(2))*B*sqrt(c)*(-S(12)*a*c + b**S(2) - b*sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(4)*a*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)) + sqrt(S(2))*B*sqrt(c)*(-S(12)*a*c + b**S(2) + b*sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(4)*a*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)) + B*x*(-S(2)*a*c + b**S(2) + b*c*x**S(2))/(S(2)*a*(-S(4)*a*c + b**S(2))*(a + b*x**S(2) + c*x**S(4))) + (A*(-S(2)*a*c + b**S(2)) - C*a*b + c*x**S(2)*(A*b - S(2)*C*a))/(S(2)*a*(-S(4)*a*c + b**S(2))*(a + b*x**S(2) + c*x**S(4))) + (A*(-S(6)*a*b*c + b**S(3)) + S(4)*C*a**S(2)*c)*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*a**S(2)*(-S(4)*a*c + b**S(2))**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((A + B*x + C*x**S(2))/(x**S(2)*(a + b*x**S(2) + c*x**S(4))**S(2)), x), x, B*(-S(2)*a*c + b**S(2) + b*c*x**S(2))/(S(2)*a*(-S(4)*a*c + b**S(2))*(a + b*x**S(2) + c*x**S(4))) + B*b*(-S(6)*a*c + b**S(2))*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*a**S(2)*(-S(4)*a*c + b**S(2))**(S(3)/2)) + B*log(x)/a**S(2) - B*log(a + b*x**S(2) + c*x**S(4))/(S(4)*a**S(2)) + (A*(-S(2)*a*c + b**S(2)) - C*a*b + c*x**S(2)*(A*b - S(2)*C*a))/(S(2)*a*x*(-S(4)*a*c + b**S(2))*(a + b*x**S(2) + c*x**S(4))) - sqrt(S(2))*sqrt(c)*(-S(10)*A*a*c + S(3)*A*b**S(2) - C*a*b - (A*(-S(16)*a*b*c + S(3)*b**S(3)) - C*a*(-S(12)*a*c + b**S(2)))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(4)*a**S(2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))) - sqrt(S(2))*sqrt(c)*(A*(-S(16)*a*b*c - S(10)*a*c*sqrt(-S(4)*a*c + b**S(2)) + S(3)*b**S(3) + S(3)*b**S(2)*sqrt(-S(4)*a*c + b**S(2))) - C*a*(-S(12)*a*c + b**S(2) + b*sqrt(-S(4)*a*c + b**S(2))))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(4)*a**S(2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)) - (-S(10)*A*a*c + S(3)*A*b**S(2) - C*a*b)/(S(2)*a**S(2)*x*(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((A + B*x + C*x**S(2))/(x**S(3)*(a + b*x**S(2) + c*x**S(4))**S(2)), x), x, B*(-S(2)*a*c + b**S(2) + b*c*x**S(2))/(S(2)*a*x*(-S(4)*a*c + b**S(2))*(a + b*x**S(2) + c*x**S(4))) + sqrt(S(2))*B*sqrt(c)*(-S(16)*a*b*c + S(3)*b**S(3) - (-S(10)*a*c + S(3)*b**S(2))*sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(4)*a**S(2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)) - sqrt(S(2))*B*sqrt(c)*(-S(16)*a*b*c + S(3)*b**S(3) + (-S(10)*a*c + S(3)*b**S(2))*sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(4)*a**S(2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)) - B*(-S(10)*a*c + S(3)*b**S(2))/(S(2)*a**S(2)*x*(-S(4)*a*c + b**S(2))) + (A*(-S(2)*a*c + b**S(2)) - C*a*b + c*x**S(2)*(A*b - S(2)*C*a))/(S(2)*a*x**S(2)*(-S(4)*a*c + b**S(2))*(a + b*x**S(2) + c*x**S(4))) - (-S(6)*A*a*c + S(2)*A*b**S(2) - C*a*b)/(S(2)*a**S(2)*x**S(2)*(-S(4)*a*c + b**S(2))) - (S(2)*A*b - C*a)*log(x)/a**S(3) + (S(2)*A*b - C*a)*log(a + b*x**S(2) + c*x**S(4))/(S(4)*a**S(3)) - (S(2)*A*(S(6)*a**S(2)*c**S(2) - S(6)*a*b**S(2)*c + b**S(4)) - C*a*b*(-S(6)*a*c + b**S(2)))*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*a**S(3)*(-S(4)*a*c + b**S(2))**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(A + B*x + C*x**S(2))/(a + b*x**S(2) + c*x**S(4))**S(2), x), x, -B*b*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(-S(4)*a*c + b**S(2))**(S(3)/2) - x*(A*b + B*b*x + S(2)*B*c*x**S(3) - S(2)*C*a + x**S(2)*(S(2)*A*c - C*b))/((-S(8)*a*c + S(2)*b**S(2))*(a + b*x**S(2) + c*x**S(4))) - sqrt(S(2))*(S(2)*A*c*(S(2)*b + sqrt(-S(4)*a*c + b**S(2))) - C*(S(4)*a*c + b**S(2) + b*sqrt(-S(4)*a*c + b**S(2))))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(4)*sqrt(c)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)) + sqrt(S(2))*(S(2)*A*c*(S(2)*b - sqrt(-S(4)*a*c + b**S(2))) - C*(S(4)*a*c + b**S(2) - b*sqrt(-S(4)*a*c + b**S(2))))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(4)*sqrt(c)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(A*x + B*x**S(2) + C*x**S(3))/(a + b*x**S(2) + c*x**S(4))**S(2), x), x, -B*b*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(-S(4)*a*c + b**S(2))**(S(3)/2) - x*(A*b + B*b*x + S(2)*B*c*x**S(3) - S(2)*C*a + x**S(2)*(S(2)*A*c - C*b))/((-S(8)*a*c + S(2)*b**S(2))*(a + b*x**S(2) + c*x**S(4))) - sqrt(S(2))*(S(2)*A*c*(S(2)*b + sqrt(-S(4)*a*c + b**S(2))) - C*(S(4)*a*c + b**S(2) + b*sqrt(-S(4)*a*c + b**S(2))))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(4)*sqrt(c)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)) + sqrt(S(2))*(S(2)*A*c*(S(2)*b - sqrt(-S(4)*a*c + b**S(2))) - C*(S(4)*a*c + b**S(2) - b*sqrt(-S(4)*a*c + b**S(2))))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(4)*sqrt(c)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((A*x**S(2) + B*x**S(3) + C*x**S(4))/(a + b*x**S(2) + c*x**S(4))**S(2), x), x, -B*b*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(-S(4)*a*c + b**S(2))**(S(3)/2) - x*(A*b + B*b*x + S(2)*B*c*x**S(3) - S(2)*C*a + x**S(2)*(S(2)*A*c - C*b))/((-S(8)*a*c + S(2)*b**S(2))*(a + b*x**S(2) + c*x**S(4))) - sqrt(S(2))*(S(2)*A*c*(S(2)*b + sqrt(-S(4)*a*c + b**S(2))) - C*(S(4)*a*c + b**S(2) + b*sqrt(-S(4)*a*c + b**S(2))))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(4)*sqrt(c)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)) + sqrt(S(2))*(S(2)*A*c*(S(2)*b - sqrt(-S(4)*a*c + b**S(2))) - C*(S(4)*a*c + b**S(2) - b*sqrt(-S(4)*a*c + b**S(2))))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(4)*sqrt(c)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((A*x**S(3) + B*x**S(4) + C*x**S(5))/(x*(a + b*x**S(2) + c*x**S(4))**S(2)), x), x, -B*b*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(-S(4)*a*c + b**S(2))**(S(3)/2) - x*(A*b + B*b*x + S(2)*B*c*x**S(3) - S(2)*C*a + x**S(2)*(S(2)*A*c - C*b))/((-S(8)*a*c + S(2)*b**S(2))*(a + b*x**S(2) + c*x**S(4))) - sqrt(S(2))*(S(2)*A*c*(S(2)*b + sqrt(-S(4)*a*c + b**S(2))) - C*(S(4)*a*c + b**S(2) + b*sqrt(-S(4)*a*c + b**S(2))))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(4)*sqrt(c)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)) + sqrt(S(2))*(S(2)*A*c*(S(2)*b - sqrt(-S(4)*a*c + b**S(2))) - C*(S(4)*a*c + b**S(2) - b*sqrt(-S(4)*a*c + b**S(2))))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(4)*sqrt(c)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((A*x**S(4) + B*x**S(5) + C*x**S(6))/(x**S(2)*(a + b*x**S(2) + c*x**S(4))**S(2)), x), x, -B*b*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(-S(4)*a*c + b**S(2))**(S(3)/2) - x*(A*b + B*b*x + S(2)*B*c*x**S(3) - S(2)*C*a + x**S(2)*(S(2)*A*c - C*b))/((-S(8)*a*c + S(2)*b**S(2))*(a + b*x**S(2) + c*x**S(4))) - sqrt(S(2))*(S(2)*A*c*(S(2)*b + sqrt(-S(4)*a*c + b**S(2))) - C*(S(4)*a*c + b**S(2) + b*sqrt(-S(4)*a*c + b**S(2))))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(4)*sqrt(c)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)) + sqrt(S(2))*(S(2)*A*c*(S(2)*b - sqrt(-S(4)*a*c + b**S(2))) - C*(S(4)*a*c + b**S(2) - b*sqrt(-S(4)*a*c + b**S(2))))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(4)*sqrt(c)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(d + e*x**S(2) + f*x**S(4) + g*x**S(6))/(a + b*x**S(2) + c*x**S(4)), x), x, g*x**S(4)/(S(4)*c) + x**S(2)*(-b*g + c*f)/(S(2)*c**S(2)) + (b**S(2)*g + c**S(2)*e - c*(a*g + b*f))*log(a + b*x**S(2) + c*x**S(4))/(S(4)*c**S(3)) - (-b**S(3)*g + b*c*(S(3)*a*g + b*f) + S(2)*c**S(3)*d - c**S(2)*(S(2)*a*f + b*e))*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*c**S(3)*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(a + b*x**S(2) + c*x**S(4))**p*(S(3)*a + b*x**S(2)*(S(2)*p + S(5)) + c*x**S(4)*(S(4)*p + S(7))), x), x, x**S(3)*(a + b*x**S(2) + c*x**S(4))**(p + S(1)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(n/S(4) + S(-1))*(-a*h + c*f*x**(n/S(4)) + c*g*x**(S(3)*n/S(4)) + c*h*x**n)/(a + c*x**n)**(S(3)/2), x), x, -(S(2)*a*g + S(4)*a*h*x**(n/S(4)) - S(2)*c*f*x**(n/S(2)))/(a*n*sqrt(a + c*x**n)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**(n/S(4) + S(-1))*(-a*h + c*f*x**(n/S(4)) + c*g*x**(S(3)*n/S(4)) + c*h*x**n)/(a + c*x**n)**(S(3)/2), x), x, -S(2)*x**(-n/S(4) + S(1))*(d*x)**(n/S(4) + S(-1))*(a*g + S(2)*a*h*x**(n/S(4)) - c*f*x**(n/S(2)))/(a*n*sqrt(a + c*x**n)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(n/S(2) + S(-1))*(-a*h + c*f*x**(n/S(2)) + c*g*x**(S(3)*n/S(2)) + c*h*x**(S(2)*n))/(a + b*x**n + c*x**(S(2)*n))**(S(3)/2), x), x, -(S(2)*c*x**n*(-b*g + S(2)*c*f) + S(2)*c*(-S(2)*a*g + b*f) + S(2)*h*x**(n/S(2))*(-S(4)*a*c + b**S(2)))/(n*(-S(4)*a*c + b**S(2))*sqrt(a + b*x**n + c*x**(S(2)*n))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((d*x)**(n/S(2) + S(-1))*(-a*h + c*f*x**(n/S(2)) + c*g*x**(S(3)*n/S(2)) + c*h*x**(S(2)*n))/(a + b*x**n + c*x**(S(2)*n))**(S(3)/2), x), x, -S(2)*x**(-n/S(2) + S(1))*(d*x)**(n/S(2) + S(-1))*(c*x**n*(-b*g + S(2)*c*f) + c*(-S(2)*a*g + b*f) + h*x**(n/S(2))*(-S(4)*a*c + b**S(2)))/(n*(-S(4)*a*c + b**S(2))*sqrt(a + b*x**n + c*x**(S(2)*n))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((g*x)**m*(a + b*x**n + c*x**(S(2)*n))**p*(a*(m + S(1)) + b*x**n*(m + n*p + n + S(1)) + c*x**(S(2)*n)*(m + S(2)*n*(p + S(1)) + S(1))), x), x, (g*x)**(m + S(1))*(a + b*x**n + c*x**(S(2)*n))**(p + S(1))/g, expand=True, _diff=True, _numerical=True)
def test_5():
assert rubi_test(rubi_integrate(x**S(2)*(a*x**S(2) + b*x**S(3) + c*x**S(4)), x), x, a*x**S(5)/S(5) + b*x**S(6)/S(6) + c*x**S(7)/S(7), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(a*x**S(2) + b*x**S(3) + c*x**S(4)), x), x, a*x**S(4)/S(4) + b*x**S(5)/S(5) + c*x**S(6)/S(6), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(a*x**S(2) + b*x**S(3) + c*x**S(4), x), x, a*x**S(3)/S(3) + b*x**S(4)/S(4) + c*x**S(5)/S(5), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a*x**S(2) + b*x**S(3) + c*x**S(4))/x, x), x, a*x**S(2)/S(2) + b*x**S(3)/S(3) + c*x**S(4)/S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a*x**S(2) + b*x**S(3) + c*x**S(4))/x**S(2), x), x, a*x + b*x**S(2)/S(2) + c*x**S(3)/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(a*x**S(2) + b*x**S(3) + c*x**S(4))**S(2), x), x, a**S(2)*x**S(7)/S(7) + a*b*x**S(8)/S(4) + b*c*x**S(10)/S(5) + c**S(2)*x**S(11)/S(11) + x**S(9)*(S(2)*a*c + b**S(2))/S(9), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(a*x**S(2) + b*x**S(3) + c*x**S(4))**S(2), x), x, a**S(2)*x**S(6)/S(6) + S(2)*a*b*x**S(7)/S(7) + S(2)*b*c*x**S(9)/S(9) + c**S(2)*x**S(10)/S(10) + x**S(8)*(S(2)*a*c + b**S(2))/S(8), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a*x**S(2) + b*x**S(3) + c*x**S(4))**S(2), x), x, a**S(2)*x**S(5)/S(5) + a*b*x**S(6)/S(3) + b*c*x**S(8)/S(4) + c**S(2)*x**S(9)/S(9) + x**S(7)*(S(2)*a*c + b**S(2))/S(7), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a*x**S(2) + b*x**S(3) + c*x**S(4))**S(2)/x, x), x, a**S(2)*x**S(4)/S(4) + S(2)*a*b*x**S(5)/S(5) + S(2)*b*c*x**S(7)/S(7) + c**S(2)*x**S(8)/S(8) + x**S(6)*(S(2)*a*c + b**S(2))/S(6), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a*x**S(2) + b*x**S(3) + c*x**S(4))**S(2)/x**S(2), x), x, a**S(2)*x**S(3)/S(3) + a*b*x**S(4)/S(2) + b*c*x**S(6)/S(3) + c**S(2)*x**S(7)/S(7) + x**S(5)*(S(2)*a*c + b**S(2))/S(5), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)/(a*x**S(2) + b*x**S(3) + c*x**S(4)), x), x, -b*x/c**S(2) + b*(-S(3)*a*c + b**S(2))*atanh((b + S(2)*c*x)/sqrt(-S(4)*a*c + b**S(2)))/(c**S(3)*sqrt(-S(4)*a*c + b**S(2))) + x**S(2)/(S(2)*c) + (-a*c + b**S(2))*log(a + b*x + c*x**S(2))/(S(2)*c**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)/(a*x**S(2) + b*x**S(3) + c*x**S(4)), x), x, -b*log(a + b*x + c*x**S(2))/(S(2)*c**S(2)) + x/c - (-S(2)*a*c + b**S(2))*atanh((b + S(2)*c*x)/sqrt(-S(4)*a*c + b**S(2)))/(c**S(2)*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/(a*x**S(2) + b*x**S(3) + c*x**S(4)), x), x, b*atanh((b + S(2)*c*x)/sqrt(-S(4)*a*c + b**S(2)))/(c*sqrt(-S(4)*a*c + b**S(2))) + log(a + b*x + c*x**S(2))/(S(2)*c), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/(a*x**S(2) + b*x**S(3) + c*x**S(4)), x), x, -S(2)*atanh((b + S(2)*c*x)/sqrt(-S(4)*a*c + b**S(2)))/sqrt(-S(4)*a*c + b**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(a*x**S(2) + b*x**S(3) + c*x**S(4)), x), x, b*atanh((b + S(2)*c*x)/sqrt(-S(4)*a*c + b**S(2)))/(a*sqrt(-S(4)*a*c + b**S(2))) + log(x)/a - log(a + b*x + c*x**S(2))/(S(2)*a), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(a*x**S(2) + b*x**S(3) + c*x**S(4)), x), x, -S(1)/(a*x) - b*log(x)/a**S(2) + b*log(a + b*x + c*x**S(2))/(S(2)*a**S(2)) - (-S(2)*a*c + b**S(2))*atanh((b + S(2)*c*x)/sqrt(-S(4)*a*c + b**S(2)))/(a**S(2)*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*(a*x**S(2) + b*x**S(3) + c*x**S(4))), x), x, -S(1)/(S(2)*a*x**S(2)) + b/(a**S(2)*x) + b*(-S(3)*a*c + b**S(2))*atanh((b + S(2)*c*x)/sqrt(-S(4)*a*c + b**S(2)))/(a**S(3)*sqrt(-S(4)*a*c + b**S(2))) + (-a*c + b**S(2))*log(x)/a**S(3) - (-a*c + b**S(2))*log(a + b*x + c*x**S(2))/(S(2)*a**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*(a*x**S(2) + b*x**S(3) + c*x**S(4))), x), x, -S(1)/(S(3)*a*x**S(3)) + b/(S(2)*a**S(2)*x**S(2)) - (-a*c + b**S(2))/(a**S(3)*x) - b*(-S(2)*a*c + b**S(2))*log(x)/a**S(4) + b*(-S(2)*a*c + b**S(2))*log(a + b*x + c*x**S(2))/(S(2)*a**S(4)) - (S(2)*a**S(2)*c**S(2) - S(4)*a*b**S(2)*c + b**S(4))*atanh((b + S(2)*c*x)/sqrt(-S(4)*a*c + b**S(2)))/(a**S(4)*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(8)/(a*x**S(2) + b*x**S(3) + c*x**S(4))**S(2), x), x, -b*x**S(2)/(c*(-S(4)*a*c + b**S(2))) - b*log(a + b*x + c*x**S(2))/c**S(3) + x**S(3)*(S(2)*a + b*x)/((-S(4)*a*c + b**S(2))*(a + b*x + c*x**S(2))) + x*(-S(6)*a*c + S(2)*b**S(2))/(c**S(2)*(-S(4)*a*c + b**S(2))) - (S(12)*a**S(2)*c**S(2) - S(12)*a*b**S(2)*c + S(2)*b**S(4))*atanh((b + S(2)*c*x)/sqrt(-S(4)*a*c + b**S(2)))/(c**S(3)*(-S(4)*a*c + b**S(2))**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(7)/(a*x**S(2) + b*x**S(3) + c*x**S(4))**S(2), x), x, -b*x/(c*(-S(4)*a*c + b**S(2))) + b*(-S(6)*a*c + b**S(2))*atanh((b + S(2)*c*x)/sqrt(-S(4)*a*c + b**S(2)))/(c**S(2)*(-S(4)*a*c + b**S(2))**(S(3)/2)) + x**S(2)*(S(2)*a + b*x)/((-S(4)*a*c + b**S(2))*(a + b*x + c*x**S(2))) + log(a + b*x + c*x**S(2))/(S(2)*c**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(6)/(a*x**S(2) + b*x**S(3) + c*x**S(4))**S(2), x), x, S(4)*a*atanh((b + S(2)*c*x)/sqrt(-S(4)*a*c + b**S(2)))/(-S(4)*a*c + b**S(2))**(S(3)/2) + x*(S(2)*a + b*x)/((-S(4)*a*c + b**S(2))*(a + b*x + c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)/(a*x**S(2) + b*x**S(3) + c*x**S(4))**S(2), x), x, -S(2)*b*atanh((b + S(2)*c*x)/sqrt(-S(4)*a*c + b**S(2)))/(-S(4)*a*c + b**S(2))**(S(3)/2) + (S(2)*a + b*x)/((-S(4)*a*c + b**S(2))*(a + b*x + c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)/(a*x**S(2) + b*x**S(3) + c*x**S(4))**S(2), x), x, S(4)*c*atanh((b + S(2)*c*x)/sqrt(-S(4)*a*c + b**S(2)))/(-S(4)*a*c + b**S(2))**(S(3)/2) - (b + S(2)*c*x)/((-S(4)*a*c + b**S(2))*(a + b*x + c*x**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/(a*x**S(2) + b*x**S(3) + c*x**S(4))**S(2), x), x, (-S(2)*a*c + b**S(2) + b*c*x)/(a*(-S(4)*a*c + b**S(2))*(a + b*x + c*x**S(2))) + b*(-S(6)*a*c + b**S(2))*atanh((b + S(2)*c*x)/sqrt(-S(4)*a*c + b**S(2)))/(a**S(2)*(-S(4)*a*c + b**S(2))**(S(3)/2)) + log(x)/a**S(2) - log(a + b*x + c*x**S(2))/(S(2)*a**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/(a*x**S(2) + b*x**S(3) + c*x**S(4))**S(2), x), x, (-S(2)*a*c + b**S(2) + b*c*x)/(a*x*(-S(4)*a*c + b**S(2))*(a + b*x + c*x**S(2))) + (S(6)*a*c - S(2)*b**S(2))/(a**S(2)*x*(-S(4)*a*c + b**S(2))) - S(2)*b*log(x)/a**S(3) + b*log(a + b*x + c*x**S(2))/a**S(3) - (S(12)*a**S(2)*c**S(2) - S(12)*a*b**S(2)*c + S(2)*b**S(4))*atanh((b + S(2)*c*x)/sqrt(-S(4)*a*c + b**S(2)))/(a**S(3)*(-S(4)*a*c + b**S(2))**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(a*x**S(2) + b*x**S(3) + c*x**S(4))**S(2), x), x, (-S(2)*a*c + b**S(2) + b*c*x)/(a*x**S(2)*(-S(4)*a*c + b**S(2))*(a + b*x + c*x**S(2))) - (-S(8)*a*c + S(3)*b**S(2))/(S(2)*a**S(2)*x**S(2)*(-S(4)*a*c + b**S(2))) + b*(-S(11)*a*c + S(3)*b**S(2))/(a**S(3)*x*(-S(4)*a*c + b**S(2))) + b*(S(30)*a**S(2)*c**S(2) - S(20)*a*b**S(2)*c + S(3)*b**S(4))*atanh((b + S(2)*c*x)/sqrt(-S(4)*a*c + b**S(2)))/(a**S(4)*(-S(4)*a*c + b**S(2))**(S(3)/2)) + (-S(2)*a*c + S(3)*b**S(2))*log(x)/a**S(4) - (-S(2)*a*c + S(3)*b**S(2))*log(a + b*x + c*x**S(2))/(S(2)*a**S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a*x**S(2) + b*x**S(3) + c*x**S(4))**(S(-2)), x), x, (-S(2)*a*c + b**S(2) + b*c*x)/(a*x**S(3)*(-S(4)*a*c + b**S(2))*(a + b*x + c*x**S(2))) - (-S(10)*a*c + S(4)*b**S(2))/(S(3)*a**S(2)*x**S(3)*(-S(4)*a*c + b**S(2))) + b*(-S(7)*a*c + S(2)*b**S(2))/(a**S(3)*x**S(2)*(-S(4)*a*c + b**S(2))) - (S(10)*a**S(2)*c**S(2) - S(18)*a*b**S(2)*c + S(4)*b**S(4))/(a**S(4)*x*(-S(4)*a*c + b**S(2))) - S(2)*b*(-S(3)*a*c + S(2)*b**S(2))*log(x)/a**S(5) + b*(-S(3)*a*c + S(2)*b**S(2))*log(a + b*x + c*x**S(2))/a**S(5) - (-S(20)*a**S(3)*c**S(3) + S(60)*a**S(2)*b**S(2)*c**S(2) - S(30)*a*b**S(4)*c + S(4)*b**S(6))*atanh((b + S(2)*c*x)/sqrt(-S(4)*a*c + b**S(2)))/(a**S(5)*(-S(4)*a*c + b**S(2))**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*(a*x**S(2) + b*x**S(3) + c*x**S(4))**S(2)), x), x, (-S(2)*a*c + b**S(2) + b*c*x)/(a*x**S(4)*(-S(4)*a*c + b**S(2))*(a + b*x + c*x**S(2))) - (-S(12)*a*c + S(5)*b**S(2))/(S(4)*a**S(2)*x**S(4)*(-S(4)*a*c + b**S(2))) + b*(-S(17)*a*c + S(5)*b**S(2))/(S(3)*a**S(3)*x**S(3)*(-S(4)*a*c + b**S(2))) - (S(12)*a**S(2)*c**S(2) - S(22)*a*b**S(2)*c + S(5)*b**S(4))/(S(2)*a**S(4)*x**S(2)*(-S(4)*a*c + b**S(2))) + b*(S(29)*a**S(2)*c**S(2) - S(27)*a*b**S(2)*c + S(5)*b**S(4))/(a**S(5)*x*(-S(4)*a*c + b**S(2))) + b*(-S(70)*a**S(3)*c**S(3) + S(105)*a**S(2)*b**S(2)*c**S(2) - S(42)*a*b**S(4)*c + S(5)*b**S(6))*atanh((b + S(2)*c*x)/sqrt(-S(4)*a*c + b**S(2)))/(a**S(6)*(-S(4)*a*c + b**S(2))**(S(3)/2)) + (S(3)*a**S(2)*c**S(2) - S(12)*a*b**S(2)*c + S(5)*b**S(4))*log(x)/a**S(6) - (S(3)*a**S(2)*c**S(2) - S(12)*a*b**S(2)*c + S(5)*b**S(4))*log(a + b*x + c*x**S(2))/(S(2)*a**S(6)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4)), x), x, b*(-S(116)*a*c + S(35)*b**S(2))*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))/(S(960)*c**S(3)) + b*x*(-S(12)*a*c + S(7)*b**S(2))*(-S(4)*a*c + b**S(2))*sqrt(a + b*x + c*x**S(2))*atanh((b + S(2)*c*x)/(S(2)*sqrt(c)*sqrt(a + b*x + c*x**S(2))))/(S(256)*c**(S(9)/2)*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))) + x**S(2)*(b + S(8)*c*x)*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))/(S(40)*c) - x*(-S(16)*a*c + S(7)*b**S(2))*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))/(S(240)*c**S(2)) - sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))*(S(256)*a**S(2)*c**S(2) - S(460)*a*b**S(2)*c + S(105)*b**S(4))/(S(1920)*c**S(4)*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4)), x), x, b*(-S(52)*a*c + S(15)*b**S(2))*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))/(S(192)*c**S(3)*x) + x*(b + S(6)*c*x)*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))/(S(24)*c) - (-S(12)*a*c + S(5)*b**S(2))*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))/(S(96)*c**S(2)) - x*(-S(4)*a*c + b**S(2))*(-S(4)*a*c + S(5)*b**S(2))*sqrt(a + b*x + c*x**S(2))*atanh((b + S(2)*c*x)/(S(2)*sqrt(c)*sqrt(a + b*x + c*x**S(2))))/(S(128)*c**(S(7)/2)*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4)), x), x, -b*(b + S(2)*c*x)*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))/(S(8)*c**S(2)*x) + b*(-S(4)*a*c + b**S(2))*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))*atanh((b + S(2)*c*x)/(S(2)*sqrt(c)*sqrt(a + b*x + c*x**S(2))))/(S(16)*c**(S(5)/2)*x*sqrt(a + b*x + c*x**S(2))) + (a + b*x + c*x**S(2))*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))/(S(3)*c*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))/x, x), x, (b + S(2)*c*x)*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))/(S(4)*c*x) - x*(-S(4)*a*c + b**S(2))*sqrt(a + b*x + c*x**S(2))*atanh((b + S(2)*c*x)/(S(2)*sqrt(c)*sqrt(a + b*x + c*x**S(2))))/(S(8)*c**(S(3)/2)*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))/x**S(2), x), x, -sqrt(a)*x*sqrt(a + b*x + c*x**S(2))*atanh((S(2)*a + b*x)/(S(2)*sqrt(a)*sqrt(a + b*x + c*x**S(2))))/sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4)) + b*x*sqrt(a + b*x + c*x**S(2))*atanh((b + S(2)*c*x)/(S(2)*sqrt(c)*sqrt(a + b*x + c*x**S(2))))/(S(2)*sqrt(c)*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))) + sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))/x, expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))/x**S(3), x), x, sqrt(c)*x*sqrt(a + b*x + c*x**S(2))*atanh((b + S(2)*c*x)/(S(2)*sqrt(c)*sqrt(a + b*x + c*x**S(2))))/sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4)) - sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))/x**S(2) - b*x*sqrt(a + b*x + c*x**S(2))*atanh((S(2)*a + b*x)/(S(2)*sqrt(a)*sqrt(a + b*x + c*x**S(2))))/(S(2)*sqrt(a)*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))/x**S(4), x), x, -sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))/(S(2)*x**S(3)) - b*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))/(S(4)*a*x**S(2)) + x*(-S(4)*a*c + b**S(2))*sqrt(a + b*x + c*x**S(2))*atanh((S(2)*a + b*x)/(S(2)*sqrt(a)*sqrt(a + b*x + c*x**S(2))))/(S(8)*a**(S(3)/2)*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))/x**S(5), x), x, -sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))/(S(3)*x**S(4)) - b*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))/(S(12)*a*x**S(3)) + (-S(8)*a*c + S(3)*b**S(2))*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))/(S(24)*a**S(2)*x**S(2)) - b*x*(-S(4)*a*c + b**S(2))*sqrt(a + b*x + c*x**S(2))*atanh((S(2)*a + b*x)/(S(2)*sqrt(a)*sqrt(a + b*x + c*x**S(2))))/(S(16)*a**(S(5)/2)*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))/x**S(6), x), x, -sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))/(S(4)*x**S(5)) - b*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))/(S(24)*a*x**S(4)) + (-S(12)*a*c + S(5)*b**S(2))*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))/(S(96)*a**S(2)*x**S(3)) - b*(-S(52)*a*c + S(15)*b**S(2))*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))/(S(192)*a**S(3)*x**S(2)) + x*(-S(4)*a*c + b**S(2))*(-S(4)*a*c + S(5)*b**S(2))*sqrt(a + b*x + c*x**S(2))*atanh((S(2)*a + b*x)/(S(2)*sqrt(a)*sqrt(a + b*x + c*x**S(2))))/(S(128)*a**(S(7)/2)*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(a*x**S(2) + b*x**S(3) + c*x**S(4))**(S(3)/2), x), x, -b*x*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))*(S(2416)*a**S(2)*c**S(2) - S(1560)*a*b**S(2)*c + S(231)*b**S(4))/(S(71680)*c**S(4)) - b*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))*(-S(58816)*a**S(3)*c**S(3) + S(81648)*a**S(2)*b**S(2)*c**S(2) - S(30660)*a*b**S(4)*c + S(3465)*b**S(6))/(S(573440)*c**S(6)*x) + x*(S(3)*b + S(14)*c*x)*(a*x**S(2) + b*x**S(3) + c*x**S(4))**(S(3)/2)/(S(112)*c) - x**S(3)*(b*(S(68)*a*c + S(11)*b**S(2)) + S(10)*c*x*(-S(28)*a*c + S(11)*b**S(2)))*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))/(S(4480)*c**S(2)) + x**S(2)*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))*(S(560)*a**S(2)*c**S(2) - S(568)*a*b**S(2)*c + S(99)*b**S(4))/(S(35840)*c**S(3)) + sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))*(-S(6720)*a**S(3)*c**S(3) + S(18896)*a**S(2)*b**S(2)*c**S(2) - S(8988)*a*b**S(4)*c + S(1155)*b**S(6))/(S(286720)*c**S(5)) + S(3)*x*(-S(4)*a*c + b**S(2))**S(2)*sqrt(a + b*x + c*x**S(2))*(S(16)*a**S(2)*c**S(2) - S(72)*a*b**S(2)*c + S(33)*b**S(4))*atanh((b + S(2)*c*x)/(S(2)*sqrt(c)*sqrt(a + b*x + c*x**S(2))))/(S(32768)*c**(S(13)/2)*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a*x**S(2) + b*x**S(3) + c*x**S(4))**(S(3)/2), x), x, -b*x**S(2)*(-S(44)*a*c + S(9)*b**S(2))*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))/(S(2240)*c**S(2)) - b*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))*(S(1168)*a**S(2)*c**S(2) - S(728)*a*b**S(2)*c + S(105)*b**S(4))/(S(17920)*c**S(4)) - S(3)*b*x*(-S(4)*a*c + b**S(2))**S(2)*(-S(4)*a*c + S(3)*b**S(2))*sqrt(a + b*x + c*x**S(2))*atanh((b + S(2)*c*x)/(S(2)*sqrt(c)*sqrt(a + b*x + c*x**S(2))))/(S(2048)*c**(S(11)/2)*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))) + x*(a*x**S(2) + b*x**S(3) + c*x**S(4))**(S(3)/2)/S(7) + x**S(3)*(S(24)*a*c + b**S(2) + S(10)*b*c*x)*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))/(S(280)*c) + x*(-S(32)*a*c + S(7)*b**S(2))*(-S(4)*a*c + S(3)*b**S(2))*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))/(S(4480)*c**S(3)) + sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))*(-S(2048)*a**S(3)*c**S(3) + S(5488)*a**S(2)*b**S(2)*c**S(2) - S(2520)*a*b**S(4)*c + S(315)*b**S(6))/(S(35840)*c**S(5)*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a*x**S(2) + b*x**S(3) + c*x**S(4))**(S(3)/2)/x, x), x, -b*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))*(S(1296)*a**S(2)*c**S(2) - S(760)*a*b**S(2)*c + S(105)*b**S(4))/(S(7680)*c**S(4)*x) + (S(3)*b + S(10)*c*x)*(a*x**S(2) + b*x**S(3) + c*x**S(4))**(S(3)/2)/(S(60)*c*x) - x*(b*(S(12)*a*c + S(7)*b**S(2)) + S(6)*c*x*(-S(20)*a*c + S(7)*b**S(2)))*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))/(S(960)*c**S(2)) + sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))*(S(240)*a**S(2)*c**S(2) - S(216)*a*b**S(2)*c + S(35)*b**S(4))/(S(3840)*c**S(3)) + x*(-S(4)*a*c + b**S(2))**S(2)*(-S(4)*a*c + S(7)*b**S(2))*sqrt(a + b*x + c*x**S(2))*atanh((b + S(2)*c*x)/(S(2)*sqrt(c)*sqrt(a + b*x + c*x**S(2))))/(S(1024)*c**(S(9)/2)*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a*x**S(2) + b*x**S(3) + c*x**S(4))**(S(3)/2)/x**S(2), x), x, -b*(b + S(2)*c*x)*(a*x**S(2) + b*x**S(3) + c*x**S(4))**(S(3)/2)/(S(16)*c**S(2)*x**S(3)) + S(3)*b*(b + S(2)*c*x)*(-S(4)*a*c + b**S(2))*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))/(S(128)*c**S(3)*x) - S(3)*b*x*(-S(4)*a*c + b**S(2))**S(2)*sqrt(a + b*x + c*x**S(2))*atanh((b + S(2)*c*x)/(S(2)*sqrt(c)*sqrt(a + b*x + c*x**S(2))))/(S(256)*c**(S(7)/2)*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))) + (a*x**S(2) + b*x**S(3) + c*x**S(4))**(S(5)/2)/(S(5)*c*x**S(5)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a*x**S(2) + b*x**S(3) + c*x**S(4))**(S(3)/2)/x**S(3), x), x, (b + S(2)*c*x)*(a*x**S(2) + b*x**S(3) + c*x**S(4))**(S(3)/2)/(S(8)*c*x**S(3)) - (b + S(2)*c*x)*(-S(12)*a*c + S(3)*b**S(2))*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))/(S(64)*c**S(2)*x) + S(3)*x*(-S(4)*a*c + b**S(2))**S(2)*sqrt(a + b*x + c*x**S(2))*atanh((b + S(2)*c*x)/(S(2)*sqrt(c)*sqrt(a + b*x + c*x**S(2))))/(S(128)*c**(S(5)/2)*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a*x**S(2) + b*x**S(3) + c*x**S(4))**(S(3)/2)/x**S(4), x), x, -a**(S(3)/2)*x*sqrt(a + b*x + c*x**S(2))*atanh((S(2)*a + b*x)/(S(2)*sqrt(a)*sqrt(a + b*x + c*x**S(2))))/sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4)) - b*x*(-S(12)*a*c + b**S(2))*sqrt(a + b*x + c*x**S(2))*atanh((b + S(2)*c*x)/(S(2)*sqrt(c)*sqrt(a + b*x + c*x**S(2))))/(S(16)*c**(S(3)/2)*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))) + (a*x**S(2) + b*x**S(3) + c*x**S(4))**(S(3)/2)/(S(3)*x**S(3)) + (S(8)*a*c + b**S(2) + S(2)*b*c*x)*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))/(S(8)*c*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a*x**S(2) + b*x**S(3) + c*x**S(4))**(S(3)/2)/x**S(5), x), x, -S(3)*sqrt(a)*b*x*sqrt(a + b*x + c*x**S(2))*atanh((S(2)*a + b*x)/(S(2)*sqrt(a)*sqrt(a + b*x + c*x**S(2))))/(S(2)*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))) + (S(9)*b + S(6)*c*x)*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))/(S(4)*x) - (a*x**S(2) + b*x**S(3) + c*x**S(4))**(S(3)/2)/x**S(4) + x*(S(12)*a*c + S(3)*b**S(2))*sqrt(a + b*x + c*x**S(2))*atanh((b + S(2)*c*x)/(S(2)*sqrt(c)*sqrt(a + b*x + c*x**S(2))))/(S(8)*sqrt(c)*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a*x**S(2) + b*x**S(3) + c*x**S(4))**(S(3)/2)/x**S(6), x), x, S(3)*b*sqrt(c)*x*sqrt(a + b*x + c*x**S(2))*atanh((b + S(2)*c*x)/(S(2)*sqrt(c)*sqrt(a + b*x + c*x**S(2))))/(S(2)*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))) - (S(3)*b - S(6)*c*x)*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))/(S(4)*x**S(2)) - (a*x**S(2) + b*x**S(3) + c*x**S(4))**(S(3)/2)/(S(2)*x**S(5)) - x*(S(12)*a*c + S(3)*b**S(2))*sqrt(a + b*x + c*x**S(2))*atanh((S(2)*a + b*x)/(S(2)*sqrt(a)*sqrt(a + b*x + c*x**S(2))))/(S(8)*sqrt(a)*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a*x**S(2) + b*x**S(3) + c*x**S(4))**(S(3)/2)/x**S(7), x), x, c**(S(3)/2)*x*sqrt(a + b*x + c*x**S(2))*atanh((b + S(2)*c*x)/(S(2)*sqrt(c)*sqrt(a + b*x + c*x**S(2))))/sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4)) - (a*x**S(2) + b*x**S(3) + c*x**S(4))**(S(3)/2)/(S(3)*x**S(6)) - b*(a*x**S(2) + b*x**S(3) + c*x**S(4))**(S(3)/2)/(S(4)*a*x**S(5)) + (-S(8)*a*c + b**S(2) + S(2)*b*c*x)*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))/(S(8)*a*x**S(2)) + b*x*(-S(12)*a*c + b**S(2))*sqrt(a + b*x + c*x**S(2))*atanh((S(2)*a + b*x)/(S(2)*sqrt(a)*sqrt(a + b*x + c*x**S(2))))/(S(16)*a**(S(3)/2)*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a*x**S(2) + b*x**S(3) + c*x**S(4))**(S(3)/2)/x**S(8), x), x, -(b + S(6)*c*x)*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))/(S(8)*x**S(4)) - (a*x**S(2) + b*x**S(3) + c*x**S(4))**(S(3)/2)/(S(4)*x**S(7)) - (-S(12)*a*c + b**S(2))*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))/(S(32)*a*x**S(3)) + b*(-S(20)*a*c + S(3)*b**S(2))*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))/(S(64)*a**S(2)*x**S(2)) - S(3)*x*(-S(4)*a*c + b**S(2))**S(2)*sqrt(a + b*x + c*x**S(2))*atanh((S(2)*a + b*x)/(S(2)*sqrt(a)*sqrt(a + b*x + c*x**S(2))))/(S(128)*a**(S(5)/2)*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a*x**S(2) + b*x**S(3) + c*x**S(4))**(S(3)/2)/x**S(9), x), x, -(S(3)*b + S(12)*c*x)*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))/(S(40)*x**S(5)) - (a*x**S(2) + b*x**S(3) + c*x**S(4))**(S(3)/2)/(S(5)*x**S(8)) - (-S(8)*a*c + b**S(2))*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))/(S(80)*a*x**S(4)) + b*(-S(28)*a*c + S(5)*b**S(2))*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))/(S(320)*a**S(2)*x**S(3)) - sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))*(S(128)*a**S(2)*c**S(2) - S(100)*a*b**S(2)*c + S(15)*b**S(4))/(S(640)*a**S(3)*x**S(2)) + S(3)*b*x*(-S(4)*a*c + b**S(2))**S(2)*sqrt(a + b*x + c*x**S(2))*atanh((S(2)*a + b*x)/(S(2)*sqrt(a)*sqrt(a + b*x + c*x**S(2))))/(S(256)*a**(S(7)/2)*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4)), x), x, -S(3)*b*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))/(S(4)*c**S(2)*x) + sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))/(S(2)*c) + x*(-S(4)*a*c + S(3)*b**S(2))*sqrt(a + b*x + c*x**S(2))*atanh((b + S(2)*c*x)/(S(2)*sqrt(c)*sqrt(a + b*x + c*x**S(2))))/(S(8)*c**(S(5)/2)*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4)), x), x, -b*x*sqrt(a + b*x + c*x**S(2))*atanh((b + S(2)*c*x)/(S(2)*sqrt(c)*sqrt(a + b*x + c*x**S(2))))/(S(2)*c**(S(3)/2)*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))) + sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))/(c*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4)), x), x, x*sqrt(a + b*x + c*x**S(2))*atanh((b + S(2)*c*x)/(S(2)*sqrt(c)*sqrt(a + b*x + c*x**S(2))))/(sqrt(c)*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4)), x), x, -x*sqrt(a + b*x + c*x**S(2))*atanh((S(2)*a + b*x)/(S(2)*sqrt(a)*sqrt(a + b*x + c*x**S(2))))/(sqrt(a)*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))), x), x, -sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))/(a*x**S(2)) + b*x*sqrt(a + b*x + c*x**S(2))*atanh((S(2)*a + b*x)/(S(2)*sqrt(a)*sqrt(a + b*x + c*x**S(2))))/(S(2)*a**(S(3)/2)*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))), x), x, -sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))/(S(2)*a*x**S(3)) + S(3)*b*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))/(S(4)*a**S(2)*x**S(2)) - x*(-S(4)*a*c + S(3)*b**S(2))*sqrt(a + b*x + c*x**S(2))*atanh((S(2)*a + b*x)/(S(2)*sqrt(a)*sqrt(a + b*x + c*x**S(2))))/(S(8)*a**(S(5)/2)*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(7)/(a*x**S(2) + b*x**S(3) + c*x**S(4))**(S(3)/2), x), x, -S(2)*b*x*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))/(c*(-S(4)*a*c + b**S(2))) - b*(-S(52)*a*c + S(15)*b**S(2))*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))/(S(4)*c**S(3)*x*(-S(4)*a*c + b**S(2))) + S(2)*x**S(4)*(S(2)*a + b*x)/((-S(4)*a*c + b**S(2))*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))) + (-S(12)*a*c + S(5)*b**S(2))*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))/(S(2)*c**S(2)*(-S(4)*a*c + b**S(2))) + x*(-S(12)*a*c + S(15)*b**S(2))*sqrt(a + b*x + c*x**S(2))*atanh((b + S(2)*c*x)/(S(2)*sqrt(c)*sqrt(a + b*x + c*x**S(2))))/(S(8)*c**(S(7)/2)*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(6)/(a*x**S(2) + b*x**S(3) + c*x**S(4))**(S(3)/2), x), x, -S(2)*b*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))/(c*(-S(4)*a*c + b**S(2))) - S(3)*b*x*sqrt(a + b*x + c*x**S(2))*atanh((b + S(2)*c*x)/(S(2)*sqrt(c)*sqrt(a + b*x + c*x**S(2))))/(S(2)*c**(S(5)/2)*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))) + S(2)*x**S(3)*(S(2)*a + b*x)/((-S(4)*a*c + b**S(2))*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))) + (-S(8)*a*c + S(3)*b**S(2))*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))/(c**S(2)*x*(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)/(a*x**S(2) + b*x**S(3) + c*x**S(4))**(S(3)/2), x), x, -S(2)*b*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))/(c*x*(-S(4)*a*c + b**S(2))) + S(2)*x**S(2)*(S(2)*a + b*x)/((-S(4)*a*c + b**S(2))*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))) + x*sqrt(a + b*x + c*x**S(2))*atanh((b + S(2)*c*x)/(S(2)*sqrt(c)*sqrt(a + b*x + c*x**S(2))))/(c**(S(3)/2)*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)/(a*x**S(2) + b*x**S(3) + c*x**S(4))**(S(3)/2), x), x, S(2)*x*(S(2)*a + b*x)/((-S(4)*a*c + b**S(2))*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/(a*x**S(2) + b*x**S(3) + c*x**S(4))**(S(3)/2), x), x, -S(2)*x*(b + S(2)*c*x)/((-S(4)*a*c + b**S(2))*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/(a*x**S(2) + b*x**S(3) + c*x**S(4))**(S(3)/2), x), x, S(2)*x*(-S(2)*a*c + b**S(2) + b*c*x)/(a*(-S(4)*a*c + b**S(2))*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))) - x*sqrt(a + b*x + c*x**S(2))*atanh((S(2)*a + b*x)/(S(2)*sqrt(a)*sqrt(a + b*x + c*x**S(2))))/(a**(S(3)/2)*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(a*x**S(2) + b*x**S(3) + c*x**S(4))**(S(3)/2), x), x, (-S(4)*a*c + S(2)*b**S(2) + S(2)*b*c*x)/(a*(-S(4)*a*c + b**S(2))*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))) - (-S(8)*a*c + S(3)*b**S(2))*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))/(a**S(2)*x**S(2)*(-S(4)*a*c + b**S(2))) + S(3)*b*x*sqrt(a + b*x + c*x**S(2))*atanh((S(2)*a + b*x)/(S(2)*sqrt(a)*sqrt(a + b*x + c*x**S(2))))/(S(2)*a**(S(5)/2)*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a*x**S(2) + b*x**S(3) + c*x**S(4))**(S(-3)/2), x), x, (-S(4)*a*c + S(2)*b**S(2) + S(2)*b*c*x)/(a*x*(-S(4)*a*c + b**S(2))*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))) - (-S(12)*a*c + S(5)*b**S(2))*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))/(S(2)*a**S(2)*x**S(3)*(-S(4)*a*c + b**S(2))) + b*(-S(52)*a*c + S(15)*b**S(2))*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))/(S(4)*a**S(3)*x**S(2)*(-S(4)*a*c + b**S(2))) - x*(-S(12)*a*c + S(15)*b**S(2))*sqrt(a + b*x + c*x**S(2))*atanh((S(2)*a + b*x)/(S(2)*sqrt(a)*sqrt(a + b*x + c*x**S(2))))/(S(8)*a**(S(7)/2)*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*(a*x**S(2) + b*x**S(3) + c*x**S(4))**(S(3)/2)), x), x, (-S(4)*a*c + S(2)*b**S(2) + S(2)*b*c*x)/(a*x**S(2)*(-S(4)*a*c + b**S(2))*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))) - (-S(16)*a*c + S(7)*b**S(2))*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))/(S(3)*a**S(2)*x**S(4)*(-S(4)*a*c + b**S(2))) + b*(-S(116)*a*c + S(35)*b**S(2))*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))/(S(12)*a**S(3)*x**S(3)*(-S(4)*a*c + b**S(2))) - sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))*(S(256)*a**S(2)*c**S(2) - S(460)*a*b**S(2)*c + S(105)*b**S(4))/(S(24)*a**S(4)*x**S(2)*(-S(4)*a*c + b**S(2))) + S(5)*b*x*(-S(12)*a*c + S(7)*b**S(2))*sqrt(a + b*x + c*x**S(2))*atanh((S(2)*a + b*x)/(S(2)*sqrt(a)*sqrt(a + b*x + c*x**S(2))))/(S(16)*a**(S(9)/2)*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*(a*x**S(2) + b*x**S(3) + c*x**S(4))**(S(3)/2)), x), x, (-S(4)*a*c + S(2)*b**S(2) + S(2)*b*c*x)/(a*x**S(3)*(-S(4)*a*c + b**S(2))*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))) - (-S(20)*a*c + S(9)*b**S(2))*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))/(S(4)*a**S(2)*x**S(5)*(-S(4)*a*c + b**S(2))) + b*(-S(68)*a*c + S(21)*b**S(2))*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))/(S(8)*a**S(3)*x**S(4)*(-S(4)*a*c + b**S(2))) - sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))*(S(240)*a**S(2)*c**S(2) - S(448)*a*b**S(2)*c + S(105)*b**S(4))/(S(32)*a**S(4)*x**S(3)*(-S(4)*a*c + b**S(2))) + b*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))*(S(1808)*a**S(2)*c**S(2) - S(1680)*a*b**S(2)*c + S(315)*b**S(4))/(S(64)*a**S(5)*x**S(2)*(-S(4)*a*c + b**S(2))) - x*sqrt(a + b*x + c*x**S(2))*(S(240)*a**S(2)*c**S(2) - S(840)*a*b**S(2)*c + S(315)*b**S(4))*atanh((S(2)*a + b*x)/(S(2)*sqrt(a)*sqrt(a + b*x + c*x**S(2))))/(S(128)*a**(S(11)/2)*sqrt(a*x**S(2) + b*x**S(3) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**m*(a*x + b*x**S(3) + c*x**S(5)), x), x, a*x**(m + S(2))/(m + S(2)) + b*x**(m + S(4))/(m + S(4)) + c*x**(m + S(6))/(m + S(6)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(a*x + b*x**S(3) + c*x**S(5)), x), x, a*x**S(4)/S(4) + b*x**S(6)/S(6) + c*x**S(8)/S(8), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(a*x + b*x**S(3) + c*x**S(5)), x), x, a*x**S(3)/S(3) + b*x**S(5)/S(5) + c*x**S(7)/S(7), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(a*x + b*x**S(3) + c*x**S(5), x), x, a*x**S(2)/S(2) + b*x**S(4)/S(4) + c*x**S(6)/S(6), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a*x + b*x**S(3) + c*x**S(5))/x, x), x, a*x + b*x**S(3)/S(3) + c*x**S(5)/S(5), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a*x + b*x**S(3) + c*x**S(5))/x**S(2), x), x, a*log(x) + b*x**S(2)/S(2) + c*x**S(4)/S(4), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a*x + b*x**S(3) + c*x**S(5))/x**S(3), x), x, -a/x + b*x + c*x**S(3)/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**m*(a*x + b*x**S(3) + c*x**S(5))**S(2), x), x, a**S(2)*x**(m + S(3))/(m + S(3)) + S(2)*a*b*x**(m + S(5))/(m + S(5)) + S(2)*b*c*x**(m + S(9))/(m + S(9)) + c**S(2)*x**(m + S(11))/(m + S(11)) + x**(m + S(7))*(S(2)*a*c + b**S(2))/(m + S(7)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)*(a*x + b*x**S(3) + c*x**S(5))**S(2), x), x, a**S(2)*x**S(5)/S(5) + S(2)*a*b*x**S(7)/S(7) + S(2)*b*c*x**S(11)/S(11) + c**S(2)*x**S(13)/S(13) + x**S(9)*(S(2)*a*c + b**S(2))/S(9), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(a*x + b*x**S(3) + c*x**S(5))**S(2), x), x, a**S(2)*x**S(4)/S(4) + a*b*x**S(6)/S(3) + b*c*x**S(10)/S(5) + c**S(2)*x**S(12)/S(12) + x**S(8)*(S(2)*a*c + b**S(2))/S(8), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a*x + b*x**S(3) + c*x**S(5))**S(2), x), x, a**S(2)*x**S(3)/S(3) + S(2)*a*b*x**S(5)/S(5) + S(2)*b*c*x**S(9)/S(9) + c**S(2)*x**S(11)/S(11) + x**S(7)*(S(2)*a*c + b**S(2))/S(7), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a*x + b*x**S(3) + c*x**S(5))**S(2)/x, x), x, a**S(2)*x**S(2)/S(2) + a*b*x**S(4)/S(2) + b*c*x**S(8)/S(4) + c**S(2)*x**S(10)/S(10) + x**S(6)*(S(2)*a*c + b**S(2))/S(6), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a*x + b*x**S(3) + c*x**S(5))**S(2)/x**S(2), x), x, a**S(2)*x + S(2)*a*b*x**S(3)/S(3) + S(2)*b*c*x**S(7)/S(7) + c**S(2)*x**S(9)/S(9) + x**S(5)*(S(2)*a*c + b**S(2))/S(5), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(8)/(a*x + b*x**S(3) + c*x**S(5)), x), x, -b*x**S(2)/(S(2)*c**S(2)) + b*(-S(3)*a*c + b**S(2))*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*c**S(3)*sqrt(-S(4)*a*c + b**S(2))) + x**S(4)/(S(4)*c) + (-a*c + b**S(2))*log(a + b*x**S(2) + c*x**S(4))/(S(4)*c**S(3)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(7)/(a*x + b*x**S(3) + c*x**S(5)), x), x, -b*x/c**S(2) + x**S(3)/(S(3)*c) + sqrt(S(2))*(-a*c + b**S(2) + b*(-S(3)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*c**(S(5)/2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))) + sqrt(S(2))*(-a*c + b**S(2) - b*(-S(3)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*c**(S(5)/2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(6)/(a*x + b*x**S(3) + c*x**S(5)), x), x, -b*log(a + b*x**S(2) + c*x**S(4))/(S(4)*c**S(2)) + x**S(2)/(S(2)*c) - (-S(2)*a*c + b**S(2))*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*c**S(2)*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)/(a*x + b*x**S(3) + c*x**S(5)), x), x, x/c - sqrt(S(2))*(b - (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*c**(S(3)/2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))) - sqrt(S(2))*(b + (-S(2)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*c**(S(3)/2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)/(a*x + b*x**S(3) + c*x**S(5)), x), x, b*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*c*sqrt(-S(4)*a*c + b**S(2))) + log(a + b*x**S(2) + c*x**S(4))/(S(4)*c), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/(a*x + b*x**S(3) + c*x**S(5)), x), x, -sqrt(S(2))*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*sqrt(c)*sqrt(-S(4)*a*c + b**S(2))) + sqrt(S(2))*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*sqrt(c)*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/(a*x + b*x**S(3) + c*x**S(5)), x), x, -atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/sqrt(-S(4)*a*c + b**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(a*x + b*x**S(3) + c*x**S(5)), x), x, -sqrt(S(2))*sqrt(c)*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*sqrt(-S(4)*a*c + b**S(2))) + sqrt(S(2))*sqrt(c)*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(a*x + b*x**S(3) + c*x**S(5)), x), x, b*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*a*sqrt(-S(4)*a*c + b**S(2))) + log(x)/a - log(a + b*x**S(2) + c*x**S(4))/(S(4)*a), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*(a*x + b*x**S(3) + c*x**S(5))), x), x, -sqrt(S(2))*sqrt(c)*(-b/sqrt(-S(4)*a*c + b**S(2)) + S(1))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*a*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))) - sqrt(S(2))*sqrt(c)*(b/sqrt(-S(4)*a*c + b**S(2)) + S(1))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*a*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))) - S(1)/(a*x), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*(a*x + b*x**S(3) + c*x**S(5))), x), x, -S(1)/(S(2)*a*x**S(2)) - b*log(x)/a**S(2) + b*log(a + b*x**S(2) + c*x**S(4))/(S(4)*a**S(2)) - (-S(2)*a*c + b**S(2))*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*a**S(2)*sqrt(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(11)/(a*x + b*x**S(3) + c*x**S(5))**S(2), x), x, -b*x**S(4)/(S(2)*c*(-S(4)*a*c + b**S(2))) - b*log(a + b*x**S(2) + c*x**S(4))/(S(2)*c**S(3)) + x**S(6)*(S(2)*a + b*x**S(2))/((-S(8)*a*c + S(2)*b**S(2))*(a + b*x**S(2) + c*x**S(4))) + x**S(2)*(-S(3)*a*c + b**S(2))/(c**S(2)*(-S(4)*a*c + b**S(2))) - (S(6)*a**S(2)*c**S(2) - S(6)*a*b**S(2)*c + b**S(4))*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(c**S(3)*(-S(4)*a*c + b**S(2))**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(10)/(a*x + b*x**S(3) + c*x**S(5))**S(2), x), x, -b*x**S(3)/(S(2)*c*(-S(4)*a*c + b**S(2))) + x**S(5)*(S(2)*a + b*x**S(2))/((-S(8)*a*c + S(2)*b**S(2))*(a + b*x**S(2) + c*x**S(4))) + x*(-S(10)*a*c + S(3)*b**S(2))/(S(2)*c**S(2)*(-S(4)*a*c + b**S(2))) - sqrt(S(2))*(-S(13)*a*b*c + S(3)*b**S(3) + (S(20)*a**S(2)*c**S(2) - S(19)*a*b**S(2)*c + S(3)*b**S(4))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(4)*c**(S(5)/2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))) - sqrt(S(2))*(-S(13)*a*b*c + S(3)*b**S(3) - (S(20)*a**S(2)*c**S(2) - S(19)*a*b**S(2)*c + S(3)*b**S(4))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(4)*c**(S(5)/2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(9)/(a*x + b*x**S(3) + c*x**S(5))**S(2), x), x, -b*x**S(2)/(S(2)*c*(-S(4)*a*c + b**S(2))) + b*(-S(6)*a*c + b**S(2))*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*c**S(2)*(-S(4)*a*c + b**S(2))**(S(3)/2)) + x**S(4)*(S(2)*a + b*x**S(2))/((-S(8)*a*c + S(2)*b**S(2))*(a + b*x**S(2) + c*x**S(4))) + log(a + b*x**S(2) + c*x**S(4))/(S(4)*c**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(8)/(a*x + b*x**S(3) + c*x**S(5))**S(2), x), x, -b*x/(S(2)*c*(-S(4)*a*c + b**S(2))) + x**S(3)*(S(2)*a + b*x**S(2))/((-S(8)*a*c + S(2)*b**S(2))*(a + b*x**S(2) + c*x**S(4))) + sqrt(S(2))*(-S(6)*a*c + b**S(2) + b*(-S(8)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(4)*c**(S(3)/2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))) + sqrt(S(2))*(-S(6)*a*c + b**S(2) - b*(-S(8)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(4)*c**(S(3)/2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(7)/(a*x + b*x**S(3) + c*x**S(5))**S(2), x), x, S(2)*a*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(-S(4)*a*c + b**S(2))**(S(3)/2) + x**S(2)*(S(2)*a + b*x**S(2))/((-S(8)*a*c + S(2)*b**S(2))*(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(6)/(a*x + b*x**S(3) + c*x**S(5))**S(2), x), x, x*(S(2)*a + b*x**S(2))/((-S(8)*a*c + S(2)*b**S(2))*(a + b*x**S(2) + c*x**S(4))) + sqrt(S(2))*(b - (S(4)*a*c + b**S(2))/sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(4)*sqrt(c)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))) + sqrt(S(2))*(S(4)*a*c + b**S(2) + b*sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(4)*sqrt(c)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(5)/(a*x + b*x**S(3) + c*x**S(5))**S(2), x), x, -b*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(-S(4)*a*c + b**S(2))**(S(3)/2) + (S(2)*a + b*x**S(2))/((-S(8)*a*c + S(2)*b**S(2))*(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(4)/(a*x + b*x**S(3) + c*x**S(5))**S(2), x), x, -sqrt(S(2))*sqrt(c)*(S(2)*b + sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)) + sqrt(S(2))*sqrt(c)*(S(2)*b - sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)) - x*(b + S(2)*c*x**S(2))/((-S(8)*a*c + S(2)*b**S(2))*(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(3)/(a*x + b*x**S(3) + c*x**S(5))**S(2), x), x, S(2)*c*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(-S(4)*a*c + b**S(2))**(S(3)/2) - (b + S(2)*c*x**S(2))/((-S(8)*a*c + S(2)*b**S(2))*(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**S(2)/(a*x + b*x**S(3) + c*x**S(5))**S(2), x), x, -sqrt(S(2))*sqrt(c)*(-S(12)*a*c + b**S(2) - b*sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(4)*a*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)) + sqrt(S(2))*sqrt(c)*(-S(12)*a*c + b**S(2) + b*sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(4)*a*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)) + x*(-S(2)*a*c + b**S(2) + b*c*x**S(2))/(S(2)*a*(-S(4)*a*c + b**S(2))*(a + b*x**S(2) + c*x**S(4))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/(a*x + b*x**S(3) + c*x**S(5))**S(2), x), x, (-S(2)*a*c + b**S(2) + b*c*x**S(2))/(S(2)*a*(-S(4)*a*c + b**S(2))*(a + b*x**S(2) + c*x**S(4))) + b*(-S(6)*a*c + b**S(2))*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*a**S(2)*(-S(4)*a*c + b**S(2))**(S(3)/2)) + log(x)/a**S(2) - log(a + b*x**S(2) + c*x**S(4))/(S(4)*a**S(2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a*x + b*x**S(3) + c*x**S(5))**(S(-2)), x), x, (-S(2)*a*c + b**S(2) + b*c*x**S(2))/(S(2)*a*x*(-S(4)*a*c + b**S(2))*(a + b*x**S(2) + c*x**S(4))) + sqrt(S(2))*sqrt(c)*(-S(16)*a*b*c + S(3)*b**S(3) - (-S(10)*a*c + S(3)*b**S(2))*sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(4)*a**S(2)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)) - sqrt(S(2))*sqrt(c)*(-S(16)*a*b*c + S(3)*b**S(3) + (-S(10)*a*c + S(3)*b**S(2))*sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(4)*a**S(2)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)) - (-S(10)*a*c + S(3)*b**S(2))/(S(2)*a**S(2)*x*(-S(4)*a*c + b**S(2))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x*(a*x + b*x**S(3) + c*x**S(5))**S(2)), x), x, (-S(2)*a*c + b**S(2) + b*c*x**S(2))/(S(2)*a*x**S(2)*(-S(4)*a*c + b**S(2))*(a + b*x**S(2) + c*x**S(4))) - (-S(3)*a*c + b**S(2))/(a**S(2)*x**S(2)*(-S(4)*a*c + b**S(2))) - S(2)*b*log(x)/a**S(3) + b*log(a + b*x**S(2) + c*x**S(4))/(S(2)*a**S(3)) - (S(6)*a**S(2)*c**S(2) - S(6)*a*b**S(2)*c + b**S(4))*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(a**S(3)*(-S(4)*a*c + b**S(2))**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(2)*(a*x + b*x**S(3) + c*x**S(5))**S(2)), x), x, (-S(2)*a*c + b**S(2) + b*c*x**S(2))/(S(2)*a*x**S(3)*(-S(4)*a*c + b**S(2))*(a + b*x**S(2) + c*x**S(4))) - (-S(14)*a*c + S(5)*b**S(2))/(S(6)*a**S(2)*x**S(3)*(-S(4)*a*c + b**S(2))) + b*(-S(19)*a*c + S(5)*b**S(2))/(S(2)*a**S(3)*x*(-S(4)*a*c + b**S(2))) - sqrt(S(2))*sqrt(c)*(S(28)*a**S(2)*c**S(2) - S(29)*a*b**S(2)*c + S(5)*b**S(4) - b*(-S(19)*a*c + S(5)*b**S(2))*sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b + sqrt(-S(4)*a*c + b**S(2))))/(S(4)*a**S(3)*sqrt(b + sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)) + sqrt(S(2))*sqrt(c)*(S(28)*a**S(2)*c**S(2) - S(29)*a*b**S(2)*c + S(5)*b**S(4) + b*(-S(19)*a*c + S(5)*b**S(2))*sqrt(-S(4)*a*c + b**S(2)))*atan(sqrt(S(2))*sqrt(c)*x/sqrt(b - sqrt(-S(4)*a*c + b**S(2))))/(S(4)*a**S(3)*sqrt(b - sqrt(-S(4)*a*c + b**S(2)))*(-S(4)*a*c + b**S(2))**(S(3)/2)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**S(3)*(a*x + b*x**S(3) + c*x**S(5))**S(2)), x), x, (-S(2)*a*c + b**S(2) + b*c*x**S(2))/(S(2)*a*x**S(4)*(-S(4)*a*c + b**S(2))*(a + b*x**S(2) + c*x**S(4))) - (-S(8)*a*c + S(3)*b**S(2))/(S(4)*a**S(2)*x**S(4)*(-S(4)*a*c + b**S(2))) + b*(-S(11)*a*c + S(3)*b**S(2))/(S(2)*a**S(3)*x**S(2)*(-S(4)*a*c + b**S(2))) + b*(S(30)*a**S(2)*c**S(2) - S(20)*a*b**S(2)*c + S(3)*b**S(4))*atanh((b + S(2)*c*x**S(2))/sqrt(-S(4)*a*c + b**S(2)))/(S(2)*a**S(4)*(-S(4)*a*c + b**S(2))**(S(3)/2)) + (-S(2)*a*c + S(3)*b**S(2))*log(x)/a**S(4) - (-S(2)*a*c + S(3)*b**S(2))*log(a + b*x**S(2) + c*x**S(4))/(S(4)*a**S(4)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(3)/2)*sqrt(a*x + b*x**S(3) + c*x**S(5)), x), x, S(2)*a**(S(1)/4)*sqrt(x)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(-S(3)*a*c + b**S(2))*elliptic_e(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(15)*c**(S(7)/4)*sqrt(a*x + b*x**S(3) + c*x**S(5))) - a**(S(1)/4)*sqrt(x)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(sqrt(a)*b*sqrt(c) - S(6)*a*c + S(2)*b**S(2))*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(30)*c**(S(7)/4)*sqrt(a*x + b*x**S(3) + c*x**S(5))) + sqrt(x)*(b + S(3)*c*x**S(2))*sqrt(a*x + b*x**S(3) + c*x**S(5))/(S(15)*c) - x**(S(3)/2)*(-S(6)*a*c + S(2)*b**S(2))*(a + b*x**S(2) + c*x**S(4))/(S(15)*c**(S(3)/2)*(sqrt(a) + sqrt(c)*x**S(2))*sqrt(a*x + b*x**S(3) + c*x**S(5))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(x)*sqrt(a*x + b*x**S(3) + c*x**S(5)), x), x, (b + S(2)*c*x**S(2))*sqrt(a*x + b*x**S(3) + c*x**S(5))/(S(8)*c*sqrt(x)) - sqrt(x)*(-S(4)*a*c + b**S(2))*sqrt(a + b*x**S(2) + c*x**S(4))*atanh((b + S(2)*c*x**S(2))/(S(2)*sqrt(c)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(16)*c**(S(3)/2)*sqrt(a*x + b*x**S(3) + c*x**S(5))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a*x + b*x**S(3) + c*x**S(5))/sqrt(x), x), x, -a**(S(1)/4)*b*sqrt(x)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*elliptic_e(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(3)*c**(S(3)/4)*sqrt(a*x + b*x**S(3) + c*x**S(5))) + a**(S(1)/4)*sqrt(x)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(S(2)*sqrt(a)*sqrt(c) + b)*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(6)*c**(S(3)/4)*sqrt(a*x + b*x**S(3) + c*x**S(5))) + b*x**(S(3)/2)*(a + b*x**S(2) + c*x**S(4))/(S(3)*sqrt(c)*(sqrt(a) + sqrt(c)*x**S(2))*sqrt(a*x + b*x**S(3) + c*x**S(5))) + sqrt(x)*sqrt(a*x + b*x**S(3) + c*x**S(5))/S(3), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(a*x + b*x**S(3) + c*x**S(5))/x**(S(3)/2), x), x, -sqrt(a)*sqrt(x)*sqrt(a + b*x**S(2) + c*x**S(4))*atanh((S(2)*a + b*x**S(2))/(S(2)*sqrt(a)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(2)*sqrt(a*x + b*x**S(3) + c*x**S(5))) + b*sqrt(x)*sqrt(a + b*x**S(2) + c*x**S(4))*atanh((b + S(2)*c*x**S(2))/(S(2)*sqrt(c)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(4)*sqrt(c)*sqrt(a*x + b*x**S(3) + c*x**S(5))) + sqrt(a*x + b*x**S(3) + c*x**S(5))/(S(2)*sqrt(x)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(3)/2)*(a*x + b*x**S(3) + c*x**S(5))**(S(3)/2), x), x, -S(3)*b*sqrt(x)*(-S(4)*a*c + b**S(2))**S(2)*sqrt(a + b*x**S(2) + c*x**S(4))*atanh((b + S(2)*c*x**S(2))/(S(2)*sqrt(c)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(512)*c**(S(7)/2)*sqrt(a*x + b*x**S(3) + c*x**S(5))) + sqrt(x)*(S(3)*b + S(8)*c*x**S(2))*(a*x + b*x**S(3) + c*x**S(5))**(S(3)/2)/(S(80)*c) - x**(S(3)/2)*(b*(-S(4)*a*c + S(5)*b**S(2)) + S(4)*c*x**S(2)*(-S(16)*a*c + S(5)*b**S(2)))*sqrt(a*x + b*x**S(3) + c*x**S(5))/(S(640)*c**S(2)) + sqrt(a*x + b*x**S(3) + c*x**S(5))*(S(128)*a**S(2)*c**S(2) - S(100)*a*b**S(2)*c + S(15)*b**S(4))/(S(1280)*c**S(3)*sqrt(x)), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(x)*(a*x + b*x**S(3) + c*x**S(5))**(S(3)/2), x), x, -a**(S(1)/4)*sqrt(x)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(S(84)*a**S(2)*c**S(2) - S(57)*a*b**S(2)*c + S(8)*b**S(4))*elliptic_e(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(315)*c**(S(11)/4)*sqrt(a*x + b*x**S(3) + c*x**S(5))) + a**(S(1)/4)*sqrt(x)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(S(4)*sqrt(a)*b*sqrt(c)*(-S(6)*a*c + b**S(2)) + S(84)*a**S(2)*c**S(2) - S(57)*a*b**S(2)*c + S(8)*b**S(4))*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(630)*c**(S(11)/4)*sqrt(a*x + b*x**S(3) + c*x**S(5))) + (S(3)*b + S(7)*c*x**S(2))*(a*x + b*x**S(3) + c*x**S(5))**(S(3)/2)/(S(63)*c*sqrt(x)) - sqrt(x)*(b*(-S(9)*a*c + S(4)*b**S(2)) + S(6)*c*x**S(2)*(-S(7)*a*c + S(2)*b**S(2)))*sqrt(a*x + b*x**S(3) + c*x**S(5))/(S(315)*c**S(2)) + x**(S(3)/2)*(a + b*x**S(2) + c*x**S(4))*(S(84)*a**S(2)*c**S(2) - S(57)*a*b**S(2)*c + S(8)*b**S(4))/(S(315)*c**(S(5)/2)*(sqrt(a) + sqrt(c)*x**S(2))*sqrt(a*x + b*x**S(3) + c*x**S(5))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a*x + b*x**S(3) + c*x**S(5))**(S(3)/2)/sqrt(x), x), x, (b + S(2)*c*x**S(2))*(a*x + b*x**S(3) + c*x**S(5))**(S(3)/2)/(S(16)*c*x**(S(3)/2)) - (b + S(2)*c*x**S(2))*(-S(12)*a*c + S(3)*b**S(2))*sqrt(a*x + b*x**S(3) + c*x**S(5))/(S(128)*c**S(2)*sqrt(x)) + S(3)*sqrt(x)*(-S(4)*a*c + b**S(2))**S(2)*sqrt(a + b*x**S(2) + c*x**S(4))*atanh((b + S(2)*c*x**S(2))/(S(2)*sqrt(c)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(256)*c**(S(5)/2)*sqrt(a*x + b*x**S(3) + c*x**S(5))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate((a*x + b*x**S(3) + c*x**S(5))**(S(3)/2)/x**(S(3)/2), x), x, S(2)*a**(S(1)/4)*b*sqrt(x)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(-S(8)*a*c + b**S(2))*elliptic_e(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(35)*c**(S(7)/4)*sqrt(a*x + b*x**S(3) + c*x**S(5))) - a**(S(1)/4)*sqrt(x)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(sqrt(a)*sqrt(c)*(-S(20)*a*c + b**S(2)) + S(2)*b*(-S(8)*a*c + b**S(2)))*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(70)*c**(S(7)/4)*sqrt(a*x + b*x**S(3) + c*x**S(5))) - S(2)*b*x**(S(3)/2)*(-S(8)*a*c + b**S(2))*(a + b*x**S(2) + c*x**S(4))/(S(35)*c**(S(3)/2)*(sqrt(a) + sqrt(c)*x**S(2))*sqrt(a*x + b*x**S(3) + c*x**S(5))) + (a*x + b*x**S(3) + c*x**S(5))**(S(3)/2)/(S(7)*sqrt(x)) + sqrt(x)*(S(10)*a*c + b**S(2) + S(3)*b*c*x**S(2))*sqrt(a*x + b*x**S(3) + c*x**S(5))/(S(35)*c), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(3)/2)/sqrt(a*x + b*x**S(3) + c*x**S(5)), x), x, sqrt(x)*sqrt(a + b*x**S(2) + c*x**S(4))*atanh((b + S(2)*c*x**S(2))/(S(2)*sqrt(c)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(2)*sqrt(c)*sqrt(a*x + b*x**S(3) + c*x**S(5))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(x)/sqrt(a*x + b*x**S(3) + c*x**S(5)), x), x, sqrt(x)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(2)*a**(S(1)/4)*c**(S(1)/4)*sqrt(a*x + b*x**S(3) + c*x**S(5))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(sqrt(x)*sqrt(a*x + b*x**S(3) + c*x**S(5))), x), x, -sqrt(x)*sqrt(a + b*x**S(2) + c*x**S(4))*atanh((S(2)*a + b*x**S(2))/(S(2)*sqrt(a)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(2)*sqrt(a)*sqrt(a*x + b*x**S(3) + c*x**S(5))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**(S(3)/2)*sqrt(a*x + b*x**S(3) + c*x**S(5))), x), x, sqrt(c)*x**(S(3)/2)*(a + b*x**S(2) + c*x**S(4))/(a*(sqrt(a) + sqrt(c)*x**S(2))*sqrt(a*x + b*x**S(3) + c*x**S(5))) - sqrt(a*x + b*x**S(3) + c*x**S(5))/(a*x**(S(3)/2)) - c**(S(1)/4)*sqrt(x)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*elliptic_e(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(a**(S(3)/4)*sqrt(a*x + b*x**S(3) + c*x**S(5))) + c**(S(1)/4)*sqrt(x)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(2)*a**(S(3)/4)*sqrt(a*x + b*x**S(3) + c*x**S(5))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(3)/2)/(a*x + b*x**S(3) + c*x**S(5))**(S(3)/2), x), x, -b*sqrt(c)*x**(S(3)/2)*(a + b*x**S(2) + c*x**S(4))/(a*(sqrt(a) + sqrt(c)*x**S(2))*(-S(4)*a*c + b**S(2))*sqrt(a*x + b*x**S(3) + c*x**S(5))) + x**(S(3)/2)*(-S(2)*a*c + b**S(2) + b*c*x**S(2))/(a*(-S(4)*a*c + b**S(2))*sqrt(a*x + b*x**S(3) + c*x**S(5))) + b*c**(S(1)/4)*sqrt(x)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*elliptic_e(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(a**(S(3)/4)*(-S(4)*a*c + b**S(2))*sqrt(a*x + b*x**S(3) + c*x**S(5))) - c**(S(1)/4)*sqrt(x)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(2)*a**(S(3)/4)*(-S(2)*sqrt(a)*sqrt(c) + b)*sqrt(a*x + b*x**S(3) + c*x**S(5))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(sqrt(x)/(a*x + b*x**S(3) + c*x**S(5))**(S(3)/2), x), x, sqrt(x)*(-S(2)*a*c + b**S(2) + b*c*x**S(2))/(a*(-S(4)*a*c + b**S(2))*sqrt(a*x + b*x**S(3) + c*x**S(5))) - sqrt(x)*sqrt(a + b*x**S(2) + c*x**S(4))*atanh((S(2)*a + b*x**S(2))/(S(2)*sqrt(a)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(2)*a**(S(3)/2)*sqrt(a*x + b*x**S(3) + c*x**S(5))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(sqrt(x)*(a*x + b*x**S(3) + c*x**S(5))**(S(3)/2)), x), x, (-S(2)*a*c + b**S(2) + b*c*x**S(2))/(a*sqrt(x)*(-S(4)*a*c + b**S(2))*sqrt(a*x + b*x**S(3) + c*x**S(5))) + S(2)*sqrt(c)*x**(S(3)/2)*(-S(3)*a*c + b**S(2))*(a + b*x**S(2) + c*x**S(4))/(a**S(2)*(sqrt(a) + sqrt(c)*x**S(2))*(-S(4)*a*c + b**S(2))*sqrt(a*x + b*x**S(3) + c*x**S(5))) - (-S(6)*a*c + S(2)*b**S(2))*sqrt(a*x + b*x**S(3) + c*x**S(5))/(a**S(2)*x**(S(3)/2)*(-S(4)*a*c + b**S(2))) - S(2)*c**(S(1)/4)*sqrt(x)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(-S(3)*a*c + b**S(2))*elliptic_e(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(a**(S(7)/4)*(-S(4)*a*c + b**S(2))*sqrt(a*x + b*x**S(3) + c*x**S(5))) + c**(S(1)/4)*sqrt(x)*sqrt((a + b*x**S(2) + c*x**S(4))/(sqrt(a) + sqrt(c)*x**S(2))**S(2))*(sqrt(a) + sqrt(c)*x**S(2))*(sqrt(a)*b*sqrt(c) - S(6)*a*c + S(2)*b**S(2))*elliptic_f(S(2)*atan(c**(S(1)/4)*x/a**(S(1)/4)), S(1)/2 - b/(S(4)*sqrt(a)*sqrt(c)))/(S(2)*a**(S(7)/4)*(-S(4)*a*c + b**S(2))*sqrt(a*x + b*x**S(3) + c*x**S(5))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(S(1)/(x**(S(3)/2)*(a*x + b*x**S(3) + c*x**S(5))**(S(3)/2)), x), x, (-S(2)*a*c + b**S(2) + b*c*x**S(2))/(a*x**(S(3)/2)*(-S(4)*a*c + b**S(2))*sqrt(a*x + b*x**S(3) + c*x**S(5))) - (-S(8)*a*c + S(3)*b**S(2))*sqrt(a*x + b*x**S(3) + c*x**S(5))/(S(2)*a**S(2)*x**(S(5)/2)*(-S(4)*a*c + b**S(2))) + S(3)*b*sqrt(x)*sqrt(a + b*x**S(2) + c*x**S(4))*atanh((S(2)*a + b*x**S(2))/(S(2)*sqrt(a)*sqrt(a + b*x**S(2) + c*x**S(4))))/(S(4)*a**(S(5)/2)*sqrt(a*x + b*x**S(3) + c*x**S(5))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x**(S(3)*n/S(2) + S(-3)/2)/(a*x**(n + S(-1)) + b*x**n + c*x**(n + S(1)))**(S(3)/2), x), x, -S(2)*x**(n/S(2) + S(-1)/2)*(b + S(2)*c*x)/((-S(4)*a*c + b**S(2))*sqrt(a*x**(n + S(-1)) + b*x**n + c*x**(n + S(1)))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x/sqrt(a*x + b*x**S(3) + c*x**S(5)), x), x, S(2)*x**S(2)*sqrt(S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))*AppellF1(S(3)/4, S(1)/2, S(1)/2, S(7)/4, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(3)*sqrt(a*x + b*x**S(3) + c*x**S(5))), expand=True, _diff=True, _numerical=True)
assert rubi_test(rubi_integrate(x*(d + e*x**S(2))/sqrt(a*x + b*x**S(3) + c*x**S(5)), x), x, S(2)*d*x**S(2)*sqrt(S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))*AppellF1(S(3)/4, S(1)/2, S(1)/2, S(7)/4, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(3)*sqrt(a*x + b*x**S(3) + c*x**S(5))) + S(2)*e*x**S(4)*sqrt(S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))) + S(1))*sqrt(S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))) + S(1))*AppellF1(S(7)/4, S(1)/2, S(1)/2, S(11)/4, -S(2)*c*x**S(2)/(b - sqrt(-S(4)*a*c + b**S(2))), -S(2)*c*x**S(2)/(b + sqrt(-S(4)*a*c + b**S(2))))/(S(7)*sqrt(a*x + b*x**S(3) + c*x**S(5))), expand=True, _diff=True, _numerical=True)
|
c6041840cc2a81726d29a8cce09561b8bfbb016f132d8faf741a4eeaec8c0e84 | from sympy.core import symbols, I
x, y, z = symbols('x,y,z')
p = 3*x**2*y*z**7 + 7*x*y*z**2 + 4*x + x*y**4
e = (x + y + z + 1)**32
def timeit_expand_nothing_todo():
p.expand()
def bench_expand_32():
"""(x+y+z+1)**32 -> expand"""
e.expand()
def timeit_expand_complex_number_1():
((2 + 3*I)**1000).expand(complex=True)
def timeit_expand_complex_number_2():
((2 + 3*I/4)**1000).expand(complex=True)
|
bc7cf28150f70ae9f9caf46bd9fcb8938be3aa499e05ecbc7cf9ab1febc4e22a | from sympy.core.numbers import Integer, Rational, integer_nthroot, igcd
from sympy import S, pi, oo
i3 = Integer(3)
i4 = Integer(4)
r34 = Rational(3, 4)
q45 = Rational(4, 5)
def timeit_Integer_create():
Integer(2)
def timeit_Integer_int():
int(i3)
def timeit_neg_one():
-S.One
def timeit_Integer_neg():
-i3
def timeit_Integer_abs():
abs(i3)
def timeit_Integer_sub():
i3 - i3
def timeit_abs_pi():
abs(pi)
def timeit_neg_oo():
-oo
def timeit_Integer_add_i1():
i3 + 1
def timeit_Integer_add_ij():
i3 + i4
def timeit_Integer_add_Rational():
i3 + r34
def timeit_Integer_mul_i4():
i3*4
def timeit_Integer_mul_ij():
i3*i4
def timeit_Integer_mul_Rational():
i3*r34
def timeit_Integer_eq_i3():
i3 == 3
def timeit_Integer_ed_Rational():
i3 == r34
def timeit_integer_nthroot():
integer_nthroot(100, 2)
def timeit_number_igcd_23_17():
igcd(23, 17)
def timeit_number_igcd_60_3600():
igcd(60, 3600)
def timeit_Rational_add_r1():
r34 + 1
def timeit_Rational_add_rq():
r34 + q45
|
7af7d9cd380e514befbe52b40d174365046ac489462df258ccabbc4033314a4b | from sympy.core import Symbol, Integer
x = Symbol('x')
i3 = Integer(3)
def timeit_x_is_integer():
x.is_integer
def timeit_Integer_is_irrational():
i3.is_irrational
|
1b98862278616e4931498da94b4f01346f78e66f66e1e665353d5a26eb46b793 | from sympy.core import sympify, Symbol
x = Symbol('x')
def timeit_sympify_1():
sympify(1)
def timeit_sympify_x():
sympify(x)
|
81fae7bca4972c2694a051713202619cb529eeb1bd3dafd84fb38a80eacf3fc1 | from sympy.core import Add, Mul, symbols
x, y, z = symbols('x,y,z')
def timeit_neg():
-x
def timeit_Add_x1():
x + 1
def timeit_Add_1x():
1 + x
def timeit_Add_x05():
x + 0.5
def timeit_Add_xy():
x + y
def timeit_Add_xyz():
Add(*[x, y, z])
def timeit_Mul_xy():
x*y
def timeit_Mul_xyz():
Mul(*[x, y, z])
def timeit_Div_xy():
x/y
def timeit_Div_2y():
2/y
|
605d2d4c9fc037f5b3d75aa27733386c8865c04844a9573e206546ad4c7a49a0 | from sympy.core import symbols, S
x, y = symbols('x,y')
def timeit_Symbol_meth_lookup():
x.diff # no call, just method lookup
def timeit_S_lookup():
S.Exp1
def timeit_Symbol_eq_xy():
x == y
|
53d06395a05efae887ec638e41a18a456d8bb0c552f1cf2a7c6fb82a073359f9 | from sympy import (Add, Basic, Expr, S, Symbol, Wild, Float, Integer, Rational, I,
sin, cos, tan, exp, log, nan, oo, sqrt, symbols, Integral, sympify,
WildFunction, Poly, Function, Derivative, Number, pi, NumberSymbol, zoo,
Piecewise, Mul, Pow, nsimplify, ratsimp, trigsimp, radsimp, powsimp,
simplify, together, collect, factorial, apart, combsimp, factor, refine,
cancel, Tuple, default_sort_key, DiracDelta, gamma, Dummy, Sum, E,
exp_polar, expand, diff, O, Heaviside, Si, Max, UnevaluatedExpr,
integrate, gammasimp, Gt)
from sympy.core.expr import ExprBuilder, unchanged
from sympy.core.function import AppliedUndef
from sympy.physics.secondquant import FockState
from sympy.physics.units import meter
from sympy.testing.pytest import raises, XFAIL
from sympy.abc import a, b, c, n, t, u, x, y, z
class DummyNumber:
"""
Minimal implementation of a number that works with SymPy.
If one has a Number class (e.g. Sage Integer, or some other custom class)
that one wants to work well with SymPy, one has to implement at least the
methods of this class DummyNumber, resp. its subclasses I5 and F1_1.
Basically, one just needs to implement either __int__() or __float__() and
then one needs to make sure that the class works with Python integers and
with itself.
"""
def __radd__(self, a):
if isinstance(a, (int, float)):
return a + self.number
return NotImplemented
def __truediv__(a, b):
return a.__div__(b)
def __rtruediv__(a, b):
return a.__rdiv__(b)
def __add__(self, a):
if isinstance(a, (int, float, DummyNumber)):
return self.number + a
return NotImplemented
def __rsub__(self, a):
if isinstance(a, (int, float)):
return a - self.number
return NotImplemented
def __sub__(self, a):
if isinstance(a, (int, float, DummyNumber)):
return self.number - a
return NotImplemented
def __rmul__(self, a):
if isinstance(a, (int, float)):
return a * self.number
return NotImplemented
def __mul__(self, a):
if isinstance(a, (int, float, DummyNumber)):
return self.number * a
return NotImplemented
def __rdiv__(self, a):
if isinstance(a, (int, float)):
return a / self.number
return NotImplemented
def __div__(self, a):
if isinstance(a, (int, float, DummyNumber)):
return self.number / a
return NotImplemented
def __rpow__(self, a):
if isinstance(a, (int, float)):
return a ** self.number
return NotImplemented
def __pow__(self, a):
if isinstance(a, (int, float, DummyNumber)):
return self.number ** a
return NotImplemented
def __pos__(self):
return self.number
def __neg__(self):
return - self.number
class I5(DummyNumber):
number = 5
def __int__(self):
return self.number
class F1_1(DummyNumber):
number = 1.1
def __float__(self):
return self.number
i5 = I5()
f1_1 = F1_1()
# basic sympy objects
basic_objs = [
Rational(2),
Float("1.3"),
x,
y,
pow(x, y)*y,
]
# all supported objects
all_objs = basic_objs + [
5,
5.5,
i5,
f1_1
]
def dotest(s):
for xo in all_objs:
for yo in all_objs:
s(xo, yo)
return True
def test_basic():
def j(a, b):
x = a
x = +a
x = -a
x = a + b
x = a - b
x = a*b
x = a/b
x = a**b
del x
assert dotest(j)
def test_ibasic():
def s(a, b):
x = a
x += b
x = a
x -= b
x = a
x *= b
x = a
x /= b
assert dotest(s)
class NonBasic:
'''This class represents an object that knows how to implement binary
operations like +, -, etc with Expr but is not a subclass of Basic itself.
The NonExpr subclass below does subclass Basic but not Expr.
For both NonBasic and NonExpr it should be possible for them to override
Expr.__add__ etc because Expr.__add__ should be returning NotImplemented
for non Expr classes. Otherwise Expr.__add__ would create meaningless
objects like Add(Integer(1), FiniteSet(2)) and it wouldn't be possible for
other classes to override these operations when interacting with Expr.
'''
def __add__(self, other):
return SpecialOp('+', self, other)
def __radd__(self, other):
return SpecialOp('+', other, self)
def __sub__(self, other):
return SpecialOp('-', self, other)
def __rsub__(self, other):
return SpecialOp('-', other, self)
def __mul__(self, other):
return SpecialOp('*', self, other)
def __rmul__(self, other):
return SpecialOp('*', other, self)
def __div__(self, other):
return SpecialOp('/', self, other)
def __rdiv__(self, other):
return SpecialOp('/', other, self)
__truediv__ = __div__
__rtruediv__ = __rdiv__
def __floordiv__(self, other):
return SpecialOp('//', self, other)
def __rfloordiv__(self, other):
return SpecialOp('//', other, self)
def __mod__(self, other):
return SpecialOp('%', self, other)
def __rmod__(self, other):
return SpecialOp('%', other, self)
def __divmod__(self, other):
return SpecialOp('divmod', self, other)
def __rdivmod__(self, other):
return SpecialOp('divmod', other, self)
def __pow__(self, other):
return SpecialOp('**', self, other)
def __rpow__(self, other):
return SpecialOp('**', other, self)
def __lt__(self, other):
return SpecialOp('<', self, other)
def __gt__(self, other):
return SpecialOp('>', self, other)
def __le__(self, other):
return SpecialOp('<=', self, other)
def __ge__(self, other):
return SpecialOp('>=', self, other)
class NonExpr(Basic, NonBasic):
'''Like NonBasic above except this is a subclass of Basic but not Expr'''
pass
class SpecialOp(Basic):
'''Represents the results of operations with NonBasic and NonExpr'''
def __new__(cls, op, arg1, arg2):
return Basic.__new__(cls, op, arg1, arg2)
class NonArithmetic(Basic):
'''Represents a Basic subclass that does not support arithmetic operations'''
pass
def test_cooperative_operations():
'''Tests that Expr uses binary operations cooperatively.
In particular it should be possible for non-Expr classes to override
binary operators like +, - etc when used with Expr instances. This should
work for non-Expr classes whether they are Basic subclasses or not. Also
non-Expr classes that do not define binary operators with Expr should give
TypeError.
'''
# A bunch of instances of Expr subclasses
exprs = [
Expr(),
S.Zero,
S.One,
S.Infinity,
S.NegativeInfinity,
S.ComplexInfinity,
S.Half,
Float(0.5),
Integer(2),
Symbol('x'),
Mul(2, Symbol('x')),
Add(2, Symbol('x')),
Pow(2, Symbol('x')),
]
for e in exprs:
# Test that these classes can override arithmetic operations in
# combination with various Expr types.
for ne in [NonBasic(), NonExpr()]:
results = [
(ne + e, ('+', ne, e)),
(e + ne, ('+', e, ne)),
(ne - e, ('-', ne, e)),
(e - ne, ('-', e, ne)),
(ne * e, ('*', ne, e)),
(e * ne, ('*', e, ne)),
(ne / e, ('/', ne, e)),
(e / ne, ('/', e, ne)),
(ne // e, ('//', ne, e)),
(e // ne, ('//', e, ne)),
(ne % e, ('%', ne, e)),
(e % ne, ('%', e, ne)),
(divmod(ne, e), ('divmod', ne, e)),
(divmod(e, ne), ('divmod', e, ne)),
(ne ** e, ('**', ne, e)),
(e ** ne, ('**', e, ne)),
(e < ne, ('>', ne, e)),
(ne < e, ('<', ne, e)),
(e > ne, ('<', ne, e)),
(ne > e, ('>', ne, e)),
(e <= ne, ('>=', ne, e)),
(ne <= e, ('<=', ne, e)),
(e >= ne, ('<=', ne, e)),
(ne >= e, ('>=', ne, e)),
]
for res, args in results:
assert type(res) is SpecialOp and res.args == args
# These classes do not support binary operators with Expr. Every
# operation should raise in combination with any of the Expr types.
for na in [NonArithmetic(), object()]:
raises(TypeError, lambda : e + na)
raises(TypeError, lambda : na + e)
raises(TypeError, lambda : e - na)
raises(TypeError, lambda : na - e)
raises(TypeError, lambda : e * na)
raises(TypeError, lambda : na * e)
raises(TypeError, lambda : e / na)
raises(TypeError, lambda : na / e)
raises(TypeError, lambda : e // na)
raises(TypeError, lambda : na // e)
raises(TypeError, lambda : e % na)
raises(TypeError, lambda : na % e)
raises(TypeError, lambda : divmod(e, na))
raises(TypeError, lambda : divmod(na, e))
raises(TypeError, lambda : e ** na)
raises(TypeError, lambda : na ** e)
raises(TypeError, lambda : e > na)
raises(TypeError, lambda : na > e)
raises(TypeError, lambda : e < na)
raises(TypeError, lambda : na < e)
raises(TypeError, lambda : e >= na)
raises(TypeError, lambda : na >= e)
raises(TypeError, lambda : e <= na)
raises(TypeError, lambda : na <= e)
def test_relational():
from sympy import Lt
assert (pi < 3) is S.false
assert (pi <= 3) is S.false
assert (pi > 3) is S.true
assert (pi >= 3) is S.true
assert (-pi < 3) is S.true
assert (-pi <= 3) is S.true
assert (-pi > 3) is S.false
assert (-pi >= 3) is S.false
r = Symbol('r', real=True)
assert (r - 2 < r - 3) is S.false
assert Lt(x + I, x + I + 2).func == Lt # issue 8288
def test_relational_assumptions():
from sympy import Lt, Gt, Le, Ge
m1 = Symbol("m1", nonnegative=False)
m2 = Symbol("m2", positive=False)
m3 = Symbol("m3", nonpositive=False)
m4 = Symbol("m4", negative=False)
assert (m1 < 0) == Lt(m1, 0)
assert (m2 <= 0) == Le(m2, 0)
assert (m3 > 0) == Gt(m3, 0)
assert (m4 >= 0) == Ge(m4, 0)
m1 = Symbol("m1", nonnegative=False, real=True)
m2 = Symbol("m2", positive=False, real=True)
m3 = Symbol("m3", nonpositive=False, real=True)
m4 = Symbol("m4", negative=False, real=True)
assert (m1 < 0) is S.true
assert (m2 <= 0) is S.true
assert (m3 > 0) is S.true
assert (m4 >= 0) is S.true
m1 = Symbol("m1", negative=True)
m2 = Symbol("m2", nonpositive=True)
m3 = Symbol("m3", positive=True)
m4 = Symbol("m4", nonnegative=True)
assert (m1 < 0) is S.true
assert (m2 <= 0) is S.true
assert (m3 > 0) is S.true
assert (m4 >= 0) is S.true
m1 = Symbol("m1", negative=False, real=True)
m2 = Symbol("m2", nonpositive=False, real=True)
m3 = Symbol("m3", positive=False, real=True)
m4 = Symbol("m4", nonnegative=False, real=True)
assert (m1 < 0) is S.false
assert (m2 <= 0) is S.false
assert (m3 > 0) is S.false
assert (m4 >= 0) is S.false
# See https://github.com/sympy/sympy/issues/17708
#def test_relational_noncommutative():
# from sympy import Lt, Gt, Le, Ge
# A, B = symbols('A,B', commutative=False)
# assert (A < B) == Lt(A, B)
# assert (A <= B) == Le(A, B)
# assert (A > B) == Gt(A, B)
# assert (A >= B) == Ge(A, B)
def test_basic_nostr():
for obj in basic_objs:
raises(TypeError, lambda: obj + '1')
raises(TypeError, lambda: obj - '1')
if obj == 2:
assert obj * '1' == '11'
else:
raises(TypeError, lambda: obj * '1')
raises(TypeError, lambda: obj / '1')
raises(TypeError, lambda: obj ** '1')
def test_series_expansion_for_uniform_order():
assert (1/x + y + x).series(x, 0, 0) == 1/x + O(1, x)
assert (1/x + y + x).series(x, 0, 1) == 1/x + y + O(x)
assert (1/x + 1 + x).series(x, 0, 0) == 1/x + O(1, x)
assert (1/x + 1 + x).series(x, 0, 1) == 1/x + 1 + O(x)
assert (1/x + x).series(x, 0, 0) == 1/x + O(1, x)
assert (1/x + y + y*x + x).series(x, 0, 0) == 1/x + O(1, x)
assert (1/x + y + y*x + x).series(x, 0, 1) == 1/x + y + O(x)
def test_leadterm():
assert (3 + 2*x**(log(3)/log(2) - 1)).leadterm(x) == (3, 0)
assert (1/x**2 + 1 + x + x**2).leadterm(x)[1] == -2
assert (1/x + 1 + x + x**2).leadterm(x)[1] == -1
assert (x**2 + 1/x).leadterm(x)[1] == -1
assert (1 + x**2).leadterm(x)[1] == 0
assert (x + 1).leadterm(x)[1] == 0
assert (x + x**2).leadterm(x)[1] == 1
assert (x**2).leadterm(x)[1] == 2
def test_as_leading_term():
assert (3 + 2*x**(log(3)/log(2) - 1)).as_leading_term(x) == 3
assert (1/x**2 + 1 + x + x**2).as_leading_term(x) == 1/x**2
assert (1/x + 1 + x + x**2).as_leading_term(x) == 1/x
assert (x**2 + 1/x).as_leading_term(x) == 1/x
assert (1 + x**2).as_leading_term(x) == 1
assert (x + 1).as_leading_term(x) == 1
assert (x + x**2).as_leading_term(x) == x
assert (x**2).as_leading_term(x) == x**2
assert (x + oo).as_leading_term(x) is oo
raises(ValueError, lambda: (x + 1).as_leading_term(1))
def test_leadterm2():
assert (x*cos(1)*cos(1 + sin(1)) + sin(1 + sin(1))).leadterm(x) == \
(sin(1 + sin(1)), 0)
def test_leadterm3():
assert (y + z + x).leadterm(x) == (y + z, 0)
def test_as_leading_term2():
assert (x*cos(1)*cos(1 + sin(1)) + sin(1 + sin(1))).as_leading_term(x) == \
sin(1 + sin(1))
def test_as_leading_term3():
assert (2 + pi + x).as_leading_term(x) == 2 + pi
assert (2*x + pi*x + x**2).as_leading_term(x) == (2 + pi)*x
def test_as_leading_term4():
# see issue 6843
n = Symbol('n', integer=True, positive=True)
r = -n**3/(2*n**2 + 4*n + 2) - n**2/(n**2 + 2*n + 1) + \
n**2/(n + 1) - n/(2*n**2 + 4*n + 2) + n/(n*x + x) + 2*n/(n + 1) - \
1 + 1/(n*x + x) + 1/(n + 1) - 1/x
assert r.as_leading_term(x).cancel() == n/2
def test_as_leading_term_stub():
class foo(Function):
pass
assert foo(1/x).as_leading_term(x) == foo(1/x)
assert foo(1).as_leading_term(x) == foo(1)
raises(NotImplementedError, lambda: foo(x).as_leading_term(x))
def test_as_leading_term_deriv_integral():
# related to issue 11313
assert Derivative(x ** 3, x).as_leading_term(x) == 3*x**2
assert Derivative(x ** 3, y).as_leading_term(x) == 0
assert Integral(x ** 3, x).as_leading_term(x) == x**4/4
assert Integral(x ** 3, y).as_leading_term(x) == y*x**3
assert Derivative(exp(x), x).as_leading_term(x) == 1
assert Derivative(log(x), x).as_leading_term(x) == (1/x).as_leading_term(x)
def test_atoms():
assert x.atoms() == {x}
assert (1 + x).atoms() == {x, S.One}
assert (1 + 2*cos(x)).atoms(Symbol) == {x}
assert (1 + 2*cos(x)).atoms(Symbol, Number) == {S.One, S(2), x}
assert (2*(x**(y**x))).atoms() == {S(2), x, y}
assert S.Half.atoms() == {S.Half}
assert S.Half.atoms(Symbol) == set()
assert sin(oo).atoms(oo) == set()
assert Poly(0, x).atoms() == {S.Zero, x}
assert Poly(1, x).atoms() == {S.One, x}
assert Poly(x, x).atoms() == {x}
assert Poly(x, x, y).atoms() == {x, y}
assert Poly(x + y, x, y).atoms() == {x, y}
assert Poly(x + y, x, y, z).atoms() == {x, y, z}
assert Poly(x + y*t, x, y, z).atoms() == {t, x, y, z}
assert (I*pi).atoms(NumberSymbol) == {pi}
assert (I*pi).atoms(NumberSymbol, I) == \
(I*pi).atoms(I, NumberSymbol) == {pi, I}
assert exp(exp(x)).atoms(exp) == {exp(exp(x)), exp(x)}
assert (1 + x*(2 + y) + exp(3 + z)).atoms(Add) == \
{1 + x*(2 + y) + exp(3 + z), 2 + y, 3 + z}
# issue 6132
f = Function('f')
e = (f(x) + sin(x) + 2)
assert e.atoms(AppliedUndef) == \
{f(x)}
assert e.atoms(AppliedUndef, Function) == \
{f(x), sin(x)}
assert e.atoms(Function) == \
{f(x), sin(x)}
assert e.atoms(AppliedUndef, Number) == \
{f(x), S(2)}
assert e.atoms(Function, Number) == \
{S(2), sin(x), f(x)}
def test_is_polynomial():
k = Symbol('k', nonnegative=True, integer=True)
assert Rational(2).is_polynomial(x, y, z) is True
assert (S.Pi).is_polynomial(x, y, z) is True
assert x.is_polynomial(x) is True
assert x.is_polynomial(y) is True
assert (x**2).is_polynomial(x) is True
assert (x**2).is_polynomial(y) is True
assert (x**(-2)).is_polynomial(x) is False
assert (x**(-2)).is_polynomial(y) is True
assert (2**x).is_polynomial(x) is False
assert (2**x).is_polynomial(y) is True
assert (x**k).is_polynomial(x) is False
assert (x**k).is_polynomial(k) is False
assert (x**x).is_polynomial(x) is False
assert (k**k).is_polynomial(k) is False
assert (k**x).is_polynomial(k) is False
assert (x**(-k)).is_polynomial(x) is False
assert ((2*x)**k).is_polynomial(x) is False
assert (x**2 + 3*x - 8).is_polynomial(x) is True
assert (x**2 + 3*x - 8).is_polynomial(y) is True
assert (x**2 + 3*x - 8).is_polynomial() is True
assert sqrt(x).is_polynomial(x) is False
assert (sqrt(x)**3).is_polynomial(x) is False
assert (x**2 + 3*x*sqrt(y) - 8).is_polynomial(x) is True
assert (x**2 + 3*x*sqrt(y) - 8).is_polynomial(y) is False
assert ((x**2)*(y**2) + x*(y**2) + y*x + exp(2)).is_polynomial() is True
assert ((x**2)*(y**2) + x*(y**2) + y*x + exp(x)).is_polynomial() is False
assert (
(x**2)*(y**2) + x*(y**2) + y*x + exp(2)).is_polynomial(x, y) is True
assert (
(x**2)*(y**2) + x*(y**2) + y*x + exp(x)).is_polynomial(x, y) is False
def test_is_rational_function():
assert Integer(1).is_rational_function() is True
assert Integer(1).is_rational_function(x) is True
assert Rational(17, 54).is_rational_function() is True
assert Rational(17, 54).is_rational_function(x) is True
assert (12/x).is_rational_function() is True
assert (12/x).is_rational_function(x) is True
assert (x/y).is_rational_function() is True
assert (x/y).is_rational_function(x) is True
assert (x/y).is_rational_function(x, y) is True
assert (x**2 + 1/x/y).is_rational_function() is True
assert (x**2 + 1/x/y).is_rational_function(x) is True
assert (x**2 + 1/x/y).is_rational_function(x, y) is True
assert (sin(y)/x).is_rational_function() is False
assert (sin(y)/x).is_rational_function(y) is False
assert (sin(y)/x).is_rational_function(x) is True
assert (sin(y)/x).is_rational_function(x, y) is False
assert (S.NaN).is_rational_function() is False
assert (S.Infinity).is_rational_function() is False
assert (S.NegativeInfinity).is_rational_function() is False
assert (S.ComplexInfinity).is_rational_function() is False
def test_is_meromorphic():
f = a/x**2 + b + x + c*x**2
assert f.is_meromorphic(x, 0) is True
assert f.is_meromorphic(x, 1) is True
assert f.is_meromorphic(x, zoo) is True
g = 3 + 2*x**(log(3)/log(2) - 1)
assert g.is_meromorphic(x, 0) is None
assert g.is_meromorphic(x, 1) is True
assert g.is_meromorphic(x, zoo) is None
n = Symbol('n', integer=True)
h = sin(1/x)**n*x
assert h.is_meromorphic(x, 0) is False
assert h.is_meromorphic(x, 1) is True
assert h.is_meromorphic(x, zoo) is True
e = log(x)**pi
assert e.is_meromorphic(x, 0) is False
assert e.is_meromorphic(x, 1) is False
assert e.is_meromorphic(x, 2) is True
assert e.is_meromorphic(x, zoo) is False
assert (log(x)**a).is_meromorphic(x, 0) is False
assert (log(x)**a).is_meromorphic(x, 1) is None
assert (a**log(x)).is_meromorphic(x, 0) is None
assert (3**log(x)).is_meromorphic(x, 0) is False
assert (3**log(x)).is_meromorphic(x, 1) is True
def test_is_algebraic_expr():
assert sqrt(3).is_algebraic_expr(x) is True
assert sqrt(3).is_algebraic_expr() is True
eq = ((1 + x**2)/(1 - y**2))**(S.One/3)
assert eq.is_algebraic_expr(x) is True
assert eq.is_algebraic_expr(y) is True
assert (sqrt(x) + y**(S(2)/3)).is_algebraic_expr(x) is True
assert (sqrt(x) + y**(S(2)/3)).is_algebraic_expr(y) is True
assert (sqrt(x) + y**(S(2)/3)).is_algebraic_expr() is True
assert (cos(y)/sqrt(x)).is_algebraic_expr() is False
assert (cos(y)/sqrt(x)).is_algebraic_expr(x) is True
assert (cos(y)/sqrt(x)).is_algebraic_expr(y) is False
assert (cos(y)/sqrt(x)).is_algebraic_expr(x, y) is False
def test_SAGE1():
#see https://github.com/sympy/sympy/issues/3346
class MyInt:
def _sympy_(self):
return Integer(5)
m = MyInt()
e = Rational(2)*m
assert e == 10
raises(TypeError, lambda: Rational(2)*MyInt)
def test_SAGE2():
class MyInt:
def __int__(self):
return 5
assert sympify(MyInt()) == 5
e = Rational(2)*MyInt()
assert e == 10
raises(TypeError, lambda: Rational(2)*MyInt)
def test_SAGE3():
class MySymbol:
def __rmul__(self, other):
return ('mys', other, self)
o = MySymbol()
e = x*o
assert e == ('mys', x, o)
def test_len():
e = x*y
assert len(e.args) == 2
e = x + y + z
assert len(e.args) == 3
def test_doit():
a = Integral(x**2, x)
assert isinstance(a.doit(), Integral) is False
assert isinstance(a.doit(integrals=True), Integral) is False
assert isinstance(a.doit(integrals=False), Integral) is True
assert (2*Integral(x, x)).doit() == x**2
def test_attribute_error():
raises(AttributeError, lambda: x.cos())
raises(AttributeError, lambda: x.sin())
raises(AttributeError, lambda: x.exp())
def test_args():
assert (x*y).args in ((x, y), (y, x))
assert (x + y).args in ((x, y), (y, x))
assert (x*y + 1).args in ((x*y, 1), (1, x*y))
assert sin(x*y).args == (x*y,)
assert sin(x*y).args[0] == x*y
assert (x**y).args == (x, y)
assert (x**y).args[0] == x
assert (x**y).args[1] == y
def test_noncommutative_expand_issue_3757():
A, B, C = symbols('A,B,C', commutative=False)
assert A*B - B*A != 0
assert (A*(A + B)*B).expand() == A**2*B + A*B**2
assert (A*(A + B + C)*B).expand() == A**2*B + A*B**2 + A*C*B
def test_as_numer_denom():
a, b, c = symbols('a, b, c')
assert nan.as_numer_denom() == (nan, 1)
assert oo.as_numer_denom() == (oo, 1)
assert (-oo).as_numer_denom() == (-oo, 1)
assert zoo.as_numer_denom() == (zoo, 1)
assert (-zoo).as_numer_denom() == (zoo, 1)
assert x.as_numer_denom() == (x, 1)
assert (1/x).as_numer_denom() == (1, x)
assert (x/y).as_numer_denom() == (x, y)
assert (x/2).as_numer_denom() == (x, 2)
assert (x*y/z).as_numer_denom() == (x*y, z)
assert (x/(y*z)).as_numer_denom() == (x, y*z)
assert S.Half.as_numer_denom() == (1, 2)
assert (1/y**2).as_numer_denom() == (1, y**2)
assert (x/y**2).as_numer_denom() == (x, y**2)
assert ((x**2 + 1)/y).as_numer_denom() == (x**2 + 1, y)
assert (x*(y + 1)/y**7).as_numer_denom() == (x*(y + 1), y**7)
assert (x**-2).as_numer_denom() == (1, x**2)
assert (a/x + b/2/x + c/3/x).as_numer_denom() == \
(6*a + 3*b + 2*c, 6*x)
assert (a/x + b/2/x + c/3/y).as_numer_denom() == \
(2*c*x + y*(6*a + 3*b), 6*x*y)
assert (a/x + b/2/x + c/.5/x).as_numer_denom() == \
(2*a + b + 4.0*c, 2*x)
# this should take no more than a few seconds
assert int(log(Add(*[Dummy()/i/x for i in range(1, 705)]
).as_numer_denom()[1]/x).n(4)) == 705
for i in [S.Infinity, S.NegativeInfinity, S.ComplexInfinity]:
assert (i + x/3).as_numer_denom() == \
(x + i, 3)
assert (S.Infinity + x/3 + y/4).as_numer_denom() == \
(4*x + 3*y + S.Infinity, 12)
assert (oo*x + zoo*y).as_numer_denom() == \
(zoo*y + oo*x, 1)
A, B, C = symbols('A,B,C', commutative=False)
assert (A*B*C**-1).as_numer_denom() == (A*B*C**-1, 1)
assert (A*B*C**-1/x).as_numer_denom() == (A*B*C**-1, x)
assert (C**-1*A*B).as_numer_denom() == (C**-1*A*B, 1)
assert (C**-1*A*B/x).as_numer_denom() == (C**-1*A*B, x)
assert ((A*B*C)**-1).as_numer_denom() == ((A*B*C)**-1, 1)
assert ((A*B*C)**-1/x).as_numer_denom() == ((A*B*C)**-1, x)
def test_trunc():
import math
x, y = symbols('x y')
assert math.trunc(2) == 2
assert math.trunc(4.57) == 4
assert math.trunc(-5.79) == -5
assert math.trunc(pi) == 3
assert math.trunc(log(7)) == 1
assert math.trunc(exp(5)) == 148
assert math.trunc(cos(pi)) == -1
assert math.trunc(sin(5)) == 0
raises(TypeError, lambda: math.trunc(x))
raises(TypeError, lambda: math.trunc(x + y**2))
raises(TypeError, lambda: math.trunc(oo))
def test_as_independent():
assert S.Zero.as_independent(x, as_Add=True) == (0, 0)
assert S.Zero.as_independent(x, as_Add=False) == (0, 0)
assert (2*x*sin(x) + y + x).as_independent(x) == (y, x + 2*x*sin(x))
assert (2*x*sin(x) + y + x).as_independent(y) == (x + 2*x*sin(x), y)
assert (2*x*sin(x) + y + x).as_independent(x, y) == (0, y + x + 2*x*sin(x))
assert (x*sin(x)*cos(y)).as_independent(x) == (cos(y), x*sin(x))
assert (x*sin(x)*cos(y)).as_independent(y) == (x*sin(x), cos(y))
assert (x*sin(x)*cos(y)).as_independent(x, y) == (1, x*sin(x)*cos(y))
assert (sin(x)).as_independent(x) == (1, sin(x))
assert (sin(x)).as_independent(y) == (sin(x), 1)
assert (2*sin(x)).as_independent(x) == (2, sin(x))
assert (2*sin(x)).as_independent(y) == (2*sin(x), 1)
# issue 4903 = 1766b
n1, n2, n3 = symbols('n1 n2 n3', commutative=False)
assert (n1 + n1*n2).as_independent(n2) == (n1, n1*n2)
assert (n2*n1 + n1*n2).as_independent(n2) == (0, n1*n2 + n2*n1)
assert (n1*n2*n1).as_independent(n2) == (n1, n2*n1)
assert (n1*n2*n1).as_independent(n1) == (1, n1*n2*n1)
assert (3*x).as_independent(x, as_Add=True) == (0, 3*x)
assert (3*x).as_independent(x, as_Add=False) == (3, x)
assert (3 + x).as_independent(x, as_Add=True) == (3, x)
assert (3 + x).as_independent(x, as_Add=False) == (1, 3 + x)
# issue 5479
assert (3*x).as_independent(Symbol) == (3, x)
# issue 5648
assert (n1*x*y).as_independent(x) == (n1*y, x)
assert ((x + n1)*(x - y)).as_independent(x) == (1, (x + n1)*(x - y))
assert ((x + n1)*(x - y)).as_independent(y) == (x + n1, x - y)
assert (DiracDelta(x - n1)*DiracDelta(x - y)).as_independent(x) \
== (1, DiracDelta(x - n1)*DiracDelta(x - y))
assert (x*y*n1*n2*n3).as_independent(n2) == (x*y*n1, n2*n3)
assert (x*y*n1*n2*n3).as_independent(n1) == (x*y, n1*n2*n3)
assert (x*y*n1*n2*n3).as_independent(n3) == (x*y*n1*n2, n3)
assert (DiracDelta(x - n1)*DiracDelta(y - n1)*DiracDelta(x - n2)).as_independent(y) == \
(DiracDelta(x - n1)*DiracDelta(x - n2), DiracDelta(y - n1))
# issue 5784
assert (x + Integral(x, (x, 1, 2))).as_independent(x, strict=True) == \
(Integral(x, (x, 1, 2)), x)
eq = Add(x, -x, 2, -3, evaluate=False)
assert eq.as_independent(x) == (-1, Add(x, -x, evaluate=False))
eq = Mul(x, 1/x, 2, -3, evaluate=False)
eq.as_independent(x) == (-6, Mul(x, 1/x, evaluate=False))
assert (x*y).as_independent(z, as_Add=True) == (x*y, 0)
@XFAIL
def test_call_2():
# TODO UndefinedFunction does not subclass Expr
f = Function('f')
assert (2*f)(x) == 2*f(x)
def test_replace():
f = log(sin(x)) + tan(sin(x**2))
assert f.replace(sin, cos) == log(cos(x)) + tan(cos(x**2))
assert f.replace(
sin, lambda a: sin(2*a)) == log(sin(2*x)) + tan(sin(2*x**2))
a = Wild('a')
b = Wild('b')
assert f.replace(sin(a), cos(a)) == log(cos(x)) + tan(cos(x**2))
assert f.replace(
sin(a), lambda a: sin(2*a)) == log(sin(2*x)) + tan(sin(2*x**2))
# test exact
assert (2*x).replace(a*x + b, b - a, exact=True) == 2*x
assert (2*x).replace(a*x + b, b - a) == 2*x
assert (2*x).replace(a*x + b, b - a, exact=False) == 2/x
assert (2*x).replace(a*x + b, lambda a, b: b - a, exact=True) == 2*x
assert (2*x).replace(a*x + b, lambda a, b: b - a) == 2*x
assert (2*x).replace(a*x + b, lambda a, b: b - a, exact=False) == 2/x
g = 2*sin(x**3)
assert g.replace(
lambda expr: expr.is_Number, lambda expr: expr**2) == 4*sin(x**9)
assert cos(x).replace(cos, sin, map=True) == (sin(x), {cos(x): sin(x)})
assert sin(x).replace(cos, sin) == sin(x)
cond, func = lambda x: x.is_Mul, lambda x: 2*x
assert (x*y).replace(cond, func, map=True) == (2*x*y, {x*y: 2*x*y})
assert (x*(1 + x*y)).replace(cond, func, map=True) == \
(2*x*(2*x*y + 1), {x*(2*x*y + 1): 2*x*(2*x*y + 1), x*y: 2*x*y})
assert (y*sin(x)).replace(sin, lambda expr: sin(expr)/y, map=True) == \
(sin(x), {sin(x): sin(x)/y})
# if not simultaneous then y*sin(x) -> y*sin(x)/y = sin(x) -> sin(x)/y
assert (y*sin(x)).replace(sin, lambda expr: sin(expr)/y,
simultaneous=False) == sin(x)/y
assert (x**2 + O(x**3)).replace(Pow, lambda b, e: b**e/e) == O(1, x)
assert (x**2 + O(x**3)).replace(Pow, lambda b, e: b**e/e,
simultaneous=False) == x**2/2 + O(x**3)
assert (x*(x*y + 3)).replace(lambda x: x.is_Mul, lambda x: 2 + x) == \
x*(x*y + 5) + 2
e = (x*y + 1)*(2*x*y + 1) + 1
assert e.replace(cond, func, map=True) == (
2*((2*x*y + 1)*(4*x*y + 1)) + 1,
{2*x*y: 4*x*y, x*y: 2*x*y, (2*x*y + 1)*(4*x*y + 1):
2*((2*x*y + 1)*(4*x*y + 1))})
assert x.replace(x, y) == y
assert (x + 1).replace(1, 2) == x + 2
# https://groups.google.com/forum/#!topic/sympy/8wCgeC95tz0
n1, n2, n3 = symbols('n1:4', commutative=False)
f = Function('f')
assert (n1*f(n2)).replace(f, lambda x: x) == n1*n2
assert (n3*f(n2)).replace(f, lambda x: x) == n3*n2
# issue 16725
assert S.Zero.replace(Wild('x'), 1) == 1
# let the user override the default decision of False
assert S.Zero.replace(Wild('x'), 1, exact=True) == 0
def test_find():
expr = (x + y + 2 + sin(3*x))
assert expr.find(lambda u: u.is_Integer) == {S(2), S(3)}
assert expr.find(lambda u: u.is_Symbol) == {x, y}
assert expr.find(lambda u: u.is_Integer, group=True) == {S(2): 1, S(3): 1}
assert expr.find(lambda u: u.is_Symbol, group=True) == {x: 2, y: 1}
assert expr.find(Integer) == {S(2), S(3)}
assert expr.find(Symbol) == {x, y}
assert expr.find(Integer, group=True) == {S(2): 1, S(3): 1}
assert expr.find(Symbol, group=True) == {x: 2, y: 1}
a = Wild('a')
expr = sin(sin(x)) + sin(x) + cos(x) + x
assert expr.find(lambda u: type(u) is sin) == {sin(x), sin(sin(x))}
assert expr.find(
lambda u: type(u) is sin, group=True) == {sin(x): 2, sin(sin(x)): 1}
assert expr.find(sin(a)) == {sin(x), sin(sin(x))}
assert expr.find(sin(a), group=True) == {sin(x): 2, sin(sin(x)): 1}
assert expr.find(sin) == {sin(x), sin(sin(x))}
assert expr.find(sin, group=True) == {sin(x): 2, sin(sin(x)): 1}
def test_count():
expr = (x + y + 2 + sin(3*x))
assert expr.count(lambda u: u.is_Integer) == 2
assert expr.count(lambda u: u.is_Symbol) == 3
assert expr.count(Integer) == 2
assert expr.count(Symbol) == 3
assert expr.count(2) == 1
a = Wild('a')
assert expr.count(sin) == 1
assert expr.count(sin(a)) == 1
assert expr.count(lambda u: type(u) is sin) == 1
f = Function('f')
assert f(x).count(f(x)) == 1
assert f(x).diff(x).count(f(x)) == 1
assert f(x).diff(x).count(x) == 2
def test_has_basics():
f = Function('f')
g = Function('g')
p = Wild('p')
assert sin(x).has(x)
assert sin(x).has(sin)
assert not sin(x).has(y)
assert not sin(x).has(cos)
assert f(x).has(x)
assert f(x).has(f)
assert not f(x).has(y)
assert not f(x).has(g)
assert f(x).diff(x).has(x)
assert f(x).diff(x).has(f)
assert f(x).diff(x).has(Derivative)
assert not f(x).diff(x).has(y)
assert not f(x).diff(x).has(g)
assert not f(x).diff(x).has(sin)
assert (x**2).has(Symbol)
assert not (x**2).has(Wild)
assert (2*p).has(Wild)
assert not x.has()
def test_has_multiple():
f = x**2*y + sin(2**t + log(z))
assert f.has(x)
assert f.has(y)
assert f.has(z)
assert f.has(t)
assert not f.has(u)
assert f.has(x, y, z, t)
assert f.has(x, y, z, t, u)
i = Integer(4400)
assert not i.has(x)
assert (i*x**i).has(x)
assert not (i*y**i).has(x)
assert (i*y**i).has(x, y)
assert not (i*y**i).has(x, z)
def test_has_piecewise():
f = (x*y + 3/y)**(3 + 2)
g = Function('g')
h = Function('h')
p = Piecewise((g(x), x < -1), (1, x <= 1), (f, True))
assert p.has(x)
assert p.has(y)
assert not p.has(z)
assert p.has(1)
assert p.has(3)
assert not p.has(4)
assert p.has(f)
assert p.has(g)
assert not p.has(h)
def test_has_iterative():
A, B, C = symbols('A,B,C', commutative=False)
f = x*gamma(x)*sin(x)*exp(x*y)*A*B*C*cos(x*A*B)
assert f.has(x)
assert f.has(x*y)
assert f.has(x*sin(x))
assert not f.has(x*sin(y))
assert f.has(x*A)
assert f.has(x*A*B)
assert not f.has(x*A*C)
assert f.has(x*A*B*C)
assert not f.has(x*A*C*B)
assert f.has(x*sin(x)*A*B*C)
assert not f.has(x*sin(x)*A*C*B)
assert not f.has(x*sin(y)*A*B*C)
assert f.has(x*gamma(x))
assert not f.has(x + sin(x))
assert (x & y & z).has(x & z)
def test_has_integrals():
f = Integral(x**2 + sin(x*y*z), (x, 0, x + y + z))
assert f.has(x + y)
assert f.has(x + z)
assert f.has(y + z)
assert f.has(x*y)
assert f.has(x*z)
assert f.has(y*z)
assert not f.has(2*x + y)
assert not f.has(2*x*y)
def test_has_tuple():
f = Function('f')
g = Function('g')
h = Function('h')
assert Tuple(x, y).has(x)
assert not Tuple(x, y).has(z)
assert Tuple(f(x), g(x)).has(x)
assert not Tuple(f(x), g(x)).has(y)
assert Tuple(f(x), g(x)).has(f)
assert Tuple(f(x), g(x)).has(f(x))
assert not Tuple(f, g).has(x)
assert Tuple(f, g).has(f)
assert not Tuple(f, g).has(h)
assert Tuple(True).has(True) is True # .has(1) will also be True
def test_has_units():
from sympy.physics.units import m, s
assert (x*m/s).has(x)
assert (x*m/s).has(y, z) is False
def test_has_polys():
poly = Poly(x**2 + x*y*sin(z), x, y, t)
assert poly.has(x)
assert poly.has(x, y, z)
assert poly.has(x, y, z, t)
def test_has_physics():
assert FockState((x, y)).has(x)
def test_as_poly_as_expr():
f = x**2 + 2*x*y
assert f.as_poly().as_expr() == f
assert f.as_poly(x, y).as_expr() == f
assert (f + sin(x)).as_poly(x, y) is None
p = Poly(f, x, y)
assert p.as_poly() == p
raises(AttributeError, lambda: Tuple(x, x).as_poly(x))
raises(AttributeError, lambda: Tuple(x ** 2, x, y).as_poly(x))
def test_nonzero():
assert bool(S.Zero) is False
assert bool(S.One) is True
assert bool(x) is True
assert bool(x + y) is True
assert bool(x - x) is False
assert bool(x*y) is True
assert bool(x*1) is True
assert bool(x*0) is False
def test_is_number():
assert Float(3.14).is_number is True
assert Integer(737).is_number is True
assert Rational(3, 2).is_number is True
assert Rational(8).is_number is True
assert x.is_number is False
assert (2*x).is_number is False
assert (x + y).is_number is False
assert log(2).is_number is True
assert log(x).is_number is False
assert (2 + log(2)).is_number is True
assert (8 + log(2)).is_number is True
assert (2 + log(x)).is_number is False
assert (8 + log(2) + x).is_number is False
assert (1 + x**2/x - x).is_number is True
assert Tuple(Integer(1)).is_number is False
assert Add(2, x).is_number is False
assert Mul(3, 4).is_number is True
assert Pow(log(2), 2).is_number is True
assert oo.is_number is True
g = WildFunction('g')
assert g.is_number is False
assert (2*g).is_number is False
assert (x**2).subs(x, 3).is_number is True
# test extensibility of .is_number
# on subinstances of Basic
class A(Basic):
pass
a = A()
assert a.is_number is False
def test_as_coeff_add():
assert S(2).as_coeff_add() == (2, ())
assert S(3.0).as_coeff_add() == (0, (S(3.0),))
assert S(-3.0).as_coeff_add() == (0, (S(-3.0),))
assert x.as_coeff_add() == (0, (x,))
assert (x - 1).as_coeff_add() == (-1, (x,))
assert (x + 1).as_coeff_add() == (1, (x,))
assert (x + 2).as_coeff_add() == (2, (x,))
assert (x + y).as_coeff_add(y) == (x, (y,))
assert (3*x).as_coeff_add(y) == (3*x, ())
# don't do expansion
e = (x + y)**2
assert e.as_coeff_add(y) == (0, (e,))
def test_as_coeff_mul():
assert S(2).as_coeff_mul() == (2, ())
assert S(3.0).as_coeff_mul() == (1, (S(3.0),))
assert S(-3.0).as_coeff_mul() == (-1, (S(3.0),))
assert S(-3.0).as_coeff_mul(rational=False) == (-S(3.0), ())
assert x.as_coeff_mul() == (1, (x,))
assert (-x).as_coeff_mul() == (-1, (x,))
assert (2*x).as_coeff_mul() == (2, (x,))
assert (x*y).as_coeff_mul(y) == (x, (y,))
assert (3 + x).as_coeff_mul() == (1, (3 + x,))
assert (3 + x).as_coeff_mul(y) == (3 + x, ())
# don't do expansion
e = exp(x + y)
assert e.as_coeff_mul(y) == (1, (e,))
e = 2**(x + y)
assert e.as_coeff_mul(y) == (1, (e,))
assert (1.1*x).as_coeff_mul(rational=False) == (1.1, (x,))
assert (1.1*x).as_coeff_mul() == (1, (1.1, x))
assert (-oo*x).as_coeff_mul(rational=True) == (-1, (oo, x))
def test_as_coeff_exponent():
assert (3*x**4).as_coeff_exponent(x) == (3, 4)
assert (2*x**3).as_coeff_exponent(x) == (2, 3)
assert (4*x**2).as_coeff_exponent(x) == (4, 2)
assert (6*x**1).as_coeff_exponent(x) == (6, 1)
assert (3*x**0).as_coeff_exponent(x) == (3, 0)
assert (2*x**0).as_coeff_exponent(x) == (2, 0)
assert (1*x**0).as_coeff_exponent(x) == (1, 0)
assert (0*x**0).as_coeff_exponent(x) == (0, 0)
assert (-1*x**0).as_coeff_exponent(x) == (-1, 0)
assert (-2*x**0).as_coeff_exponent(x) == (-2, 0)
assert (2*x**3 + pi*x**3).as_coeff_exponent(x) == (2 + pi, 3)
assert (x*log(2)/(2*x + pi*x)).as_coeff_exponent(x) == \
(log(2)/(2 + pi), 0)
# issue 4784
D = Derivative
f = Function('f')
fx = D(f(x), x)
assert fx.as_coeff_exponent(f(x)) == (fx, 0)
def test_extractions():
assert ((x*y)**3).extract_multiplicatively(x**2 * y) == x*y**2
assert ((x*y)**3).extract_multiplicatively(x**4 * y) is None
assert (2*x).extract_multiplicatively(2) == x
assert (2*x).extract_multiplicatively(3) is None
assert (2*x).extract_multiplicatively(-1) is None
assert (S.Half*x).extract_multiplicatively(3) == x/6
assert (sqrt(x)).extract_multiplicatively(x) is None
assert (sqrt(x)).extract_multiplicatively(1/x) is None
assert x.extract_multiplicatively(-x) is None
assert (-2 - 4*I).extract_multiplicatively(-2) == 1 + 2*I
assert (-2 - 4*I).extract_multiplicatively(3) is None
assert (-2*x - 4*y - 8).extract_multiplicatively(-2) == x + 2*y + 4
assert (-2*x*y - 4*x**2*y).extract_multiplicatively(-2*y) == 2*x**2 + x
assert (2*x*y + 4*x**2*y).extract_multiplicatively(2*y) == 2*x**2 + x
assert (-4*y**2*x).extract_multiplicatively(-3*y) is None
assert (2*x).extract_multiplicatively(1) == 2*x
assert (-oo).extract_multiplicatively(5) is -oo
assert (oo).extract_multiplicatively(5) is oo
assert ((x*y)**3).extract_additively(1) is None
assert (x + 1).extract_additively(x) == 1
assert (x + 1).extract_additively(2*x) is None
assert (x + 1).extract_additively(-x) is None
assert (-x + 1).extract_additively(2*x) is None
assert (2*x + 3).extract_additively(x) == x + 3
assert (2*x + 3).extract_additively(2) == 2*x + 1
assert (2*x + 3).extract_additively(3) == 2*x
assert (2*x + 3).extract_additively(-2) is None
assert (2*x + 3).extract_additively(3*x) is None
assert (2*x + 3).extract_additively(2*x) == 3
assert x.extract_additively(0) == x
assert S(2).extract_additively(x) is None
assert S(2.).extract_additively(2) is S.Zero
assert S(2*x + 3).extract_additively(x + 1) == x + 2
assert S(2*x + 3).extract_additively(y + 1) is None
assert S(2*x - 3).extract_additively(x + 1) is None
assert S(2*x - 3).extract_additively(y + z) is None
assert ((a + 1)*x*4 + y).extract_additively(x).expand() == \
4*a*x + 3*x + y
assert ((a + 1)*x*4 + 3*y).extract_additively(x + 2*y).expand() == \
4*a*x + 3*x + y
assert (y*(x + 1)).extract_additively(x + 1) is None
assert ((y + 1)*(x + 1) + 3).extract_additively(x + 1) == \
y*(x + 1) + 3
assert ((x + y)*(x + 1) + x + y + 3).extract_additively(x + y) == \
x*(x + y) + 3
assert (x + y + 2*((x + y)*(x + 1)) + 3).extract_additively((x + y)*(x + 1)) == \
x + y + (x + 1)*(x + y) + 3
assert ((y + 1)*(x + 2*y + 1) + 3).extract_additively(y + 1) == \
(x + 2*y)*(y + 1) + 3
n = Symbol("n", integer=True)
assert (Integer(-3)).could_extract_minus_sign() is True
assert (-n*x + x).could_extract_minus_sign() != \
(n*x - x).could_extract_minus_sign()
assert (x - y).could_extract_minus_sign() != \
(-x + y).could_extract_minus_sign()
assert (1 - x - y).could_extract_minus_sign() is True
assert (1 - x + y).could_extract_minus_sign() is False
assert ((-x - x*y)/y).could_extract_minus_sign() is True
assert (-(x + x*y)/y).could_extract_minus_sign() is True
assert ((x + x*y)/(-y)).could_extract_minus_sign() is True
assert ((x + x*y)/y).could_extract_minus_sign() is False
assert (x*(-x - x**3)).could_extract_minus_sign() is True
assert ((-x - y)/(x + y)).could_extract_minus_sign() is True
class sign_invariant(Function, Expr):
nargs = 1
def __neg__(self):
return self
foo = sign_invariant(x)
assert foo == -foo
assert foo.could_extract_minus_sign() is False
# The results of each of these will vary on different machines, e.g.
# the first one might be False and the other (then) is true or vice versa,
# so both are included.
assert ((-x - y)/(x - y)).could_extract_minus_sign() is False or \
((-x - y)/(y - x)).could_extract_minus_sign() is False
assert (x - y).could_extract_minus_sign() is False
assert (-x + y).could_extract_minus_sign() is True
# check that result is canonical
eq = (3*x + 15*y).extract_multiplicatively(3)
assert eq.args == eq.func(*eq.args).args
def test_nan_extractions():
for r in (1, 0, I, nan):
assert nan.extract_additively(r) is None
assert nan.extract_multiplicatively(r) is None
def test_coeff():
assert (x + 1).coeff(x + 1) == 1
assert (3*x).coeff(0) == 0
assert (z*(1 + x)*x**2).coeff(1 + x) == z*x**2
assert (1 + 2*x*x**(1 + x)).coeff(x*x**(1 + x)) == 2
assert (1 + 2*x**(y + z)).coeff(x**(y + z)) == 2
assert (3 + 2*x + 4*x**2).coeff(1) == 0
assert (3 + 2*x + 4*x**2).coeff(-1) == 0
assert (3 + 2*x + 4*x**2).coeff(x) == 2
assert (3 + 2*x + 4*x**2).coeff(x**2) == 4
assert (3 + 2*x + 4*x**2).coeff(x**3) == 0
assert (-x/8 + x*y).coeff(x) == Rational(-1, 8) + y
assert (-x/8 + x*y).coeff(-x) == S.One/8
assert (4*x).coeff(2*x) == 0
assert (2*x).coeff(2*x) == 1
assert (-oo*x).coeff(x*oo) == -1
assert (10*x).coeff(x, 0) == 0
assert (10*x).coeff(10*x, 0) == 0
n1, n2 = symbols('n1 n2', commutative=False)
assert (n1*n2).coeff(n1) == 1
assert (n1*n2).coeff(n2) == n1
assert (n1*n2 + x*n1).coeff(n1) == 1 # 1*n1*(n2+x)
assert (n2*n1 + x*n1).coeff(n1) == n2 + x
assert (n2*n1 + x*n1**2).coeff(n1) == n2
assert (n1**x).coeff(n1) == 0
assert (n1*n2 + n2*n1).coeff(n1) == 0
assert (2*(n1 + n2)*n2).coeff(n1 + n2, right=1) == n2
assert (2*(n1 + n2)*n2).coeff(n1 + n2, right=0) == 2
f = Function('f')
assert (2*f(x) + 3*f(x).diff(x)).coeff(f(x)) == 2
expr = z*(x + y)**2
expr2 = z*(x + y)**2 + z*(2*x + 2*y)**2
assert expr.coeff(z) == (x + y)**2
assert expr.coeff(x + y) == 0
assert expr2.coeff(z) == (x + y)**2 + (2*x + 2*y)**2
assert (x + y + 3*z).coeff(1) == x + y
assert (-x + 2*y).coeff(-1) == x
assert (x - 2*y).coeff(-1) == 2*y
assert (3 + 2*x + 4*x**2).coeff(1) == 0
assert (-x - 2*y).coeff(2) == -y
assert (x + sqrt(2)*x).coeff(sqrt(2)) == x
assert (3 + 2*x + 4*x**2).coeff(x) == 2
assert (3 + 2*x + 4*x**2).coeff(x**2) == 4
assert (3 + 2*x + 4*x**2).coeff(x**3) == 0
assert (z*(x + y)**2).coeff((x + y)**2) == z
assert (z*(x + y)**2).coeff(x + y) == 0
assert (2 + 2*x + (x + 1)*y).coeff(x + 1) == y
assert (x + 2*y + 3).coeff(1) == x
assert (x + 2*y + 3).coeff(x, 0) == 2*y + 3
assert (x**2 + 2*y + 3*x).coeff(x**2, 0) == 2*y + 3*x
assert x.coeff(0, 0) == 0
assert x.coeff(x, 0) == 0
n, m, o, l = symbols('n m o l', commutative=False)
assert n.coeff(n) == 1
assert y.coeff(n) == 0
assert (3*n).coeff(n) == 3
assert (2 + n).coeff(x*m) == 0
assert (2*x*n*m).coeff(x) == 2*n*m
assert (2 + n).coeff(x*m*n + y) == 0
assert (2*x*n*m).coeff(3*n) == 0
assert (n*m + m*n*m).coeff(n) == 1 + m
assert (n*m + m*n*m).coeff(n, right=True) == m # = (1 + m)*n*m
assert (n*m + m*n).coeff(n) == 0
assert (n*m + o*m*n).coeff(m*n) == o
assert (n*m + o*m*n).coeff(m*n, right=1) == 1
assert (n*m + n*m*n).coeff(n*m, right=1) == 1 + n # = n*m*(n + 1)
assert (x*y).coeff(z, 0) == x*y
def test_coeff2():
r, kappa = symbols('r, kappa')
psi = Function("psi")
g = 1/r**2 * (2*r*psi(r).diff(r, 1) + r**2 * psi(r).diff(r, 2))
g = g.expand()
assert g.coeff(psi(r).diff(r)) == 2/r
def test_coeff2_0():
r, kappa = symbols('r, kappa')
psi = Function("psi")
g = 1/r**2 * (2*r*psi(r).diff(r, 1) + r**2 * psi(r).diff(r, 2))
g = g.expand()
assert g.coeff(psi(r).diff(r, 2)) == 1
def test_coeff_expand():
expr = z*(x + y)**2
expr2 = z*(x + y)**2 + z*(2*x + 2*y)**2
assert expr.coeff(z) == (x + y)**2
assert expr2.coeff(z) == (x + y)**2 + (2*x + 2*y)**2
def test_integrate():
assert x.integrate(x) == x**2/2
assert x.integrate((x, 0, 1)) == S.Half
def test_as_base_exp():
assert x.as_base_exp() == (x, S.One)
assert (x*y*z).as_base_exp() == (x*y*z, S.One)
assert (x + y + z).as_base_exp() == (x + y + z, S.One)
assert ((x + y)**z).as_base_exp() == (x + y, z)
def test_issue_4963():
assert hasattr(Mul(x, y), "is_commutative")
assert hasattr(Mul(x, y, evaluate=False), "is_commutative")
assert hasattr(Pow(x, y), "is_commutative")
assert hasattr(Pow(x, y, evaluate=False), "is_commutative")
expr = Mul(Pow(2, 2, evaluate=False), 3, evaluate=False) + 1
assert hasattr(expr, "is_commutative")
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 radsimp(1/(a + b*sqrt(c)), symbolic=False) == \
(1/(a + b*sqrt(c))).radsimp(symbolic=False)
assert powsimp(x**y*x**z*y**z, combine='all') == \
(x**y*x**z*y**z).powsimp(combine='all')
assert (x**t*y**t).powsimp(force=True) == (x*y)**t
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 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 gammasimp(gamma(x)/gamma(x-5)) == (gamma(x)/gamma(x-5)).gammasimp()
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_as_powers_dict():
assert x.as_powers_dict() == {x: 1}
assert (x**y*z).as_powers_dict() == {x: y, z: 1}
assert Mul(2, 2, evaluate=False).as_powers_dict() == {S(2): S(2)}
assert (x*y).as_powers_dict()[z] == 0
assert (x + y).as_powers_dict()[z] == 0
def test_as_coefficients_dict():
check = [S.One, x, y, x*y, 1]
assert [Add(3*x, 2*x, y, 3).as_coefficients_dict()[i] for i in check] == \
[3, 5, 1, 0, 3]
assert [Add(3*x, 2*x, y, 3, evaluate=False).as_coefficients_dict()[i]
for i in check] == [3, 5, 1, 0, 3]
assert [(3*x*y).as_coefficients_dict()[i] for i in check] == \
[0, 0, 0, 3, 0]
assert [(3.0*x*y).as_coefficients_dict()[i] for i in check] == \
[0, 0, 0, 3.0, 0]
assert (3.0*x*y).as_coefficients_dict()[3.0*x*y] == 0
def test_args_cnc():
A = symbols('A', commutative=False)
assert (x + A).args_cnc() == \
[[], [x + A]]
assert (x + a).args_cnc() == \
[[a + x], []]
assert (x*a).args_cnc() == \
[[a, x], []]
assert (x*y*A*(A + 1)).args_cnc(cset=True) == \
[{x, y}, [A, 1 + A]]
assert Mul(x, x, evaluate=False).args_cnc(cset=True, warn=False) == \
[{x}, []]
assert Mul(x, x**2, evaluate=False).args_cnc(cset=True, warn=False) == \
[{x, x**2}, []]
raises(ValueError, lambda: Mul(x, x, evaluate=False).args_cnc(cset=True))
assert Mul(x, y, x, evaluate=False).args_cnc() == \
[[x, y, x], []]
# always split -1 from leading number
assert (-1.*x).args_cnc() == [[-1, 1.0, x], []]
def test_new_rawargs():
n = Symbol('n', commutative=False)
a = x + n
assert a.is_commutative is False
assert a._new_rawargs(x).is_commutative
assert a._new_rawargs(x, y).is_commutative
assert a._new_rawargs(x, n).is_commutative is False
assert a._new_rawargs(x, y, n).is_commutative is False
m = x*n
assert m.is_commutative is False
assert m._new_rawargs(x).is_commutative
assert m._new_rawargs(n).is_commutative is False
assert m._new_rawargs(x, y).is_commutative
assert m._new_rawargs(x, n).is_commutative is False
assert m._new_rawargs(x, y, n).is_commutative is False
assert m._new_rawargs(x, n, reeval=False).is_commutative is False
assert m._new_rawargs(S.One) is S.One
def test_issue_5226():
assert Add(evaluate=False) == 0
assert Mul(evaluate=False) == 1
assert Mul(x + y, evaluate=False).is_Add
def test_free_symbols():
# free_symbols should return the free symbols of an object
assert S.One.free_symbols == set()
assert x.free_symbols == {x}
assert Integral(x, (x, 1, y)).free_symbols == {y}
assert (-Integral(x, (x, 1, y))).free_symbols == {y}
assert meter.free_symbols == set()
assert (meter**x).free_symbols == {x}
def test_issue_5300():
x = Symbol('x', commutative=False)
assert x*sqrt(2)/sqrt(6) == x*sqrt(3)/3
def test_floordiv():
from sympy.functions.elementary.integers import floor
assert x // y == floor(x / y)
def test_as_coeff_Mul():
assert S.Zero.as_coeff_Mul() == (S.One, S.Zero)
assert Integer(3).as_coeff_Mul() == (Integer(3), Integer(1))
assert Rational(3, 4).as_coeff_Mul() == (Rational(3, 4), Integer(1))
assert Float(5.0).as_coeff_Mul() == (Float(5.0), Integer(1))
assert (Integer(3)*x).as_coeff_Mul() == (Integer(3), x)
assert (Rational(3, 4)*x).as_coeff_Mul() == (Rational(3, 4), x)
assert (Float(5.0)*x).as_coeff_Mul() == (Float(5.0), x)
assert (Integer(3)*x*y).as_coeff_Mul() == (Integer(3), x*y)
assert (Rational(3, 4)*x*y).as_coeff_Mul() == (Rational(3, 4), x*y)
assert (Float(5.0)*x*y).as_coeff_Mul() == (Float(5.0), x*y)
assert (x).as_coeff_Mul() == (S.One, x)
assert (x*y).as_coeff_Mul() == (S.One, x*y)
assert (-oo*x).as_coeff_Mul(rational=True) == (-1, oo*x)
def test_as_coeff_Add():
assert Integer(3).as_coeff_Add() == (Integer(3), Integer(0))
assert Rational(3, 4).as_coeff_Add() == (Rational(3, 4), Integer(0))
assert Float(5.0).as_coeff_Add() == (Float(5.0), Integer(0))
assert (Integer(3) + x).as_coeff_Add() == (Integer(3), x)
assert (Rational(3, 4) + x).as_coeff_Add() == (Rational(3, 4), x)
assert (Float(5.0) + x).as_coeff_Add() == (Float(5.0), x)
assert (Float(5.0) + x).as_coeff_Add(rational=True) == (0, Float(5.0) + x)
assert (Integer(3) + x + y).as_coeff_Add() == (Integer(3), x + y)
assert (Rational(3, 4) + x + y).as_coeff_Add() == (Rational(3, 4), x + y)
assert (Float(5.0) + x + y).as_coeff_Add() == (Float(5.0), x + y)
assert (x).as_coeff_Add() == (S.Zero, x)
assert (x*y).as_coeff_Add() == (S.Zero, x*y)
def test_expr_sorting():
f, g = symbols('f,g', cls=Function)
exprs = [1/x**2, 1/x, sqrt(sqrt(x)), sqrt(x), x, sqrt(x)**3, x**2]
assert sorted(exprs, key=default_sort_key) == exprs
exprs = [x, 2*x, 2*x**2, 2*x**3, x**n, 2*x**n, sin(x), sin(x)**n,
sin(x**2), cos(x), cos(x**2), tan(x)]
assert sorted(exprs, key=default_sort_key) == exprs
exprs = [x + 1, x**2 + x + 1, x**3 + x**2 + x + 1]
assert sorted(exprs, key=default_sort_key) == exprs
exprs = [S(4), x - 3*I/2, x + 3*I/2, x - 4*I + 1, x + 4*I + 1]
assert sorted(exprs, key=default_sort_key) == exprs
exprs = [f(1), f(2), f(3), f(1, 2, 3), g(1), g(2), g(3), g(1, 2, 3)]
assert sorted(exprs, key=default_sort_key) == exprs
exprs = [f(x), g(x), exp(x), sin(x), cos(x), factorial(x)]
assert sorted(exprs, key=default_sort_key) == exprs
exprs = [Tuple(x, y), Tuple(x, z), Tuple(x, y, z)]
assert sorted(exprs, key=default_sort_key) == exprs
exprs = [[3], [1, 2]]
assert sorted(exprs, key=default_sort_key) == exprs
exprs = [[1, 2], [2, 3]]
assert sorted(exprs, key=default_sort_key) == exprs
exprs = [[1, 2], [1, 2, 3]]
assert sorted(exprs, key=default_sort_key) == exprs
exprs = [{x: -y}, {x: y}]
assert sorted(exprs, key=default_sort_key) == exprs
exprs = [{1}, {1, 2}]
assert sorted(exprs, key=default_sort_key) == exprs
a, b = exprs = [Dummy('x'), Dummy('x')]
assert sorted([b, a], key=default_sort_key) == exprs
def test_as_ordered_factors():
f, g = symbols('f,g', cls=Function)
assert x.as_ordered_factors() == [x]
assert (2*x*x**n*sin(x)*cos(x)).as_ordered_factors() \
== [Integer(2), x, x**n, sin(x), cos(x)]
args = [f(1), f(2), f(3), f(1, 2, 3), g(1), g(2), g(3), g(1, 2, 3)]
expr = Mul(*args)
assert expr.as_ordered_factors() == args
A, B = symbols('A,B', commutative=False)
assert (A*B).as_ordered_factors() == [A, B]
assert (B*A).as_ordered_factors() == [B, A]
def test_as_ordered_terms():
f, g = symbols('f,g', cls=Function)
assert x.as_ordered_terms() == [x]
assert (sin(x)**2*cos(x) + sin(x)*cos(x)**2 + 1).as_ordered_terms() \
== [sin(x)**2*cos(x), sin(x)*cos(x)**2, 1]
args = [f(1), f(2), f(3), f(1, 2, 3), g(1), g(2), g(3), g(1, 2, 3)]
expr = Add(*args)
assert expr.as_ordered_terms() == args
assert (1 + 4*sqrt(3)*pi*x).as_ordered_terms() == [4*pi*x*sqrt(3), 1]
assert ( 2 + 3*I).as_ordered_terms() == [2, 3*I]
assert (-2 + 3*I).as_ordered_terms() == [-2, 3*I]
assert ( 2 - 3*I).as_ordered_terms() == [2, -3*I]
assert (-2 - 3*I).as_ordered_terms() == [-2, -3*I]
assert ( 4 + 3*I).as_ordered_terms() == [4, 3*I]
assert (-4 + 3*I).as_ordered_terms() == [-4, 3*I]
assert ( 4 - 3*I).as_ordered_terms() == [4, -3*I]
assert (-4 - 3*I).as_ordered_terms() == [-4, -3*I]
f = x**2*y**2 + x*y**4 + y + 2
assert f.as_ordered_terms(order="lex") == [x**2*y**2, x*y**4, y, 2]
assert f.as_ordered_terms(order="grlex") == [x*y**4, x**2*y**2, y, 2]
assert f.as_ordered_terms(order="rev-lex") == [2, y, x*y**4, x**2*y**2]
assert f.as_ordered_terms(order="rev-grlex") == [2, y, x**2*y**2, x*y**4]
k = symbols('k')
assert k.as_ordered_terms(data=True) == ([(k, ((1.0, 0.0), (1,), ()))], [k])
def test_sort_key_atomic_expr():
from sympy.physics.units import m, s
assert sorted([-m, s], key=lambda arg: arg.sort_key()) == [-m, s]
def test_eval_interval():
assert exp(x)._eval_interval(*Tuple(x, 0, 1)) == exp(1) - exp(0)
# issue 4199
# first subs and limit gives NaN
a = x/y
assert a._eval_interval(x, S.Zero, oo)._eval_interval(y, oo, S.Zero) is S.NaN
# second subs and limit gives NaN
assert a._eval_interval(x, S.Zero, oo)._eval_interval(y, S.Zero, oo) is S.NaN
# difference gives S.NaN
a = x - y
assert a._eval_interval(x, S.One, oo)._eval_interval(y, oo, S.One) is S.NaN
raises(ValueError, lambda: x._eval_interval(x, None, None))
a = -y*Heaviside(x - y)
assert a._eval_interval(x, -oo, oo) == -y
assert a._eval_interval(x, oo, -oo) == y
def test_eval_interval_zoo():
# Test that limit is used when zoo is returned
assert Si(1/x)._eval_interval(x, S.Zero, S.One) == -pi/2 + Si(1)
def test_primitive():
assert (3*(x + 1)**2).primitive() == (3, (x + 1)**2)
assert (6*x + 2).primitive() == (2, 3*x + 1)
assert (x/2 + 3).primitive() == (S.Half, x + 6)
eq = (6*x + 2)*(x/2 + 3)
assert eq.primitive()[0] == 1
eq = (2 + 2*x)**2
assert eq.primitive()[0] == 1
assert (4.0*x).primitive() == (1, 4.0*x)
assert (4.0*x + y/2).primitive() == (S.Half, 8.0*x + y)
assert (-2*x).primitive() == (2, -x)
assert Add(5*z/7, 0.5*x, 3*y/2, evaluate=False).primitive() == \
(S.One/14, 7.0*x + 21*y + 10*z)
for i in [S.Infinity, S.NegativeInfinity, S.ComplexInfinity]:
assert (i + x/3).primitive() == \
(S.One/3, i + x)
assert (S.Infinity + 2*x/3 + 4*y/7).primitive() == \
(S.One/21, 14*x + 12*y + oo)
assert S.Zero.primitive() == (S.One, S.Zero)
def test_issue_5843():
a = 1 + x
assert (2*a).extract_multiplicatively(a) == 2
assert (4*a).extract_multiplicatively(2*a) == 2
assert ((3*a)*(2*a)).extract_multiplicatively(a) == 6*a
def test_is_constant():
from sympy.solvers.solvers import checksol
Sum(x, (x, 1, 10)).is_constant() is True
Sum(x, (x, 1, n)).is_constant() is False
Sum(x, (x, 1, n)).is_constant(y) is True
Sum(x, (x, 1, n)).is_constant(n) is False
Sum(x, (x, 1, n)).is_constant(x) is True
eq = a*cos(x)**2 + a*sin(x)**2 - a
eq.is_constant() is True
assert eq.subs({x: pi, a: 2}) == eq.subs({x: pi, a: 3}) == 0
assert x.is_constant() is False
assert x.is_constant(y) is True
assert checksol(x, x, Sum(x, (x, 1, n))) is False
assert checksol(x, x, Sum(x, (x, 1, n))) is False
f = Function('f')
assert f(1).is_constant
assert checksol(x, x, f(x)) is False
assert Pow(x, S.Zero, evaluate=False).is_constant() is True # == 1
assert Pow(S.Zero, x, evaluate=False).is_constant() is False # == 0 or 1
assert (2**x).is_constant() is False
assert Pow(S(2), S(3), evaluate=False).is_constant() is True
z1, z2 = symbols('z1 z2', zero=True)
assert (z1 + 2*z2).is_constant() is True
assert meter.is_constant() is True
assert (3*meter).is_constant() is True
assert (x*meter).is_constant() is False
def test_equals():
assert (-3 - sqrt(5) + (-sqrt(10)/2 - sqrt(2)/2)**2).equals(0)
assert (x**2 - 1).equals((x + 1)*(x - 1))
assert (cos(x)**2 + sin(x)**2).equals(1)
assert (a*cos(x)**2 + a*sin(x)**2).equals(a)
r = sqrt(2)
assert (-1/(r + r*x) + 1/r/(1 + x)).equals(0)
assert factorial(x + 1).equals((x + 1)*factorial(x))
assert sqrt(3).equals(2*sqrt(3)) is False
assert (sqrt(5)*sqrt(3)).equals(sqrt(3)) is False
assert (sqrt(5) + sqrt(3)).equals(0) is False
assert (sqrt(5) + pi).equals(0) is False
assert meter.equals(0) is False
assert (3*meter**2).equals(0) is False
eq = -(-1)**(S(3)/4)*6**(S.One/4) + (-6)**(S.One/4)*I
if eq != 0: # if canonicalization makes this zero, skip the test
assert eq.equals(0)
assert sqrt(x).equals(0) is False
# from integrate(x*sqrt(1 + 2*x), x);
# diff is zero only when assumptions allow
i = 2*sqrt(2)*x**(S(5)/2)*(1 + 1/(2*x))**(S(5)/2)/5 + \
2*sqrt(2)*x**(S(3)/2)*(1 + 1/(2*x))**(S(5)/2)/(-6 - 3/x)
ans = sqrt(2*x + 1)*(6*x**2 + x - 1)/15
diff = i - ans
assert diff.equals(0) is False
assert diff.subs(x, Rational(-1, 2)/2) == 7*sqrt(2)/120
# there are regions for x for which the expression is True, for
# example, when x < -1/2 or x > 0 the expression is zero
p = Symbol('p', positive=True)
assert diff.subs(x, p).equals(0) is True
assert diff.subs(x, -1).equals(0) is True
# prove via minimal_polynomial or self-consistency
eq = sqrt(1 + sqrt(3)) + sqrt(3 + 3*sqrt(3)) - sqrt(10 + 6*sqrt(3))
assert eq.equals(0)
q = 3**Rational(1, 3) + 3
p = expand(q**3)**Rational(1, 3)
assert (p - q).equals(0)
# issue 6829
# eq = q*x + q/4 + x**4 + x**3 + 2*x**2 - S.One/3
# z = eq.subs(x, solve(eq, x)[0])
q = symbols('q')
z = (q*(-sqrt(-2*(-(q - S(7)/8)**S(2)/8 - S(2197)/13824)**(S.One/3) -
S(13)/12)/2 - sqrt((2*q - S(7)/4)/sqrt(-2*(-(q - S(7)/8)**S(2)/8 -
S(2197)/13824)**(S.One/3) - S(13)/12) + 2*(-(q - S(7)/8)**S(2)/8 -
S(2197)/13824)**(S.One/3) - S(13)/6)/2 - S.One/4) + q/4 + (-sqrt(-2*(-(q
- S(7)/8)**S(2)/8 - S(2197)/13824)**(S.One/3) - S(13)/12)/2 - sqrt((2*q
- S(7)/4)/sqrt(-2*(-(q - S(7)/8)**S(2)/8 - S(2197)/13824)**(S.One/3) -
S(13)/12) + 2*(-(q - S(7)/8)**S(2)/8 - S(2197)/13824)**(S.One/3) -
S(13)/6)/2 - S.One/4)**4 + (-sqrt(-2*(-(q - S(7)/8)**S(2)/8 -
S(2197)/13824)**(S.One/3) - S(13)/12)/2 - sqrt((2*q -
S(7)/4)/sqrt(-2*(-(q - S(7)/8)**S(2)/8 - S(2197)/13824)**(S.One/3) -
S(13)/12) + 2*(-(q - S(7)/8)**S(2)/8 - S(2197)/13824)**(S.One/3) -
S(13)/6)/2 - S.One/4)**3 + 2*(-sqrt(-2*(-(q - S(7)/8)**S(2)/8 -
S(2197)/13824)**(S.One/3) - S(13)/12)/2 - sqrt((2*q -
S(7)/4)/sqrt(-2*(-(q - S(7)/8)**S(2)/8 - S(2197)/13824)**(S.One/3) -
S(13)/12) + 2*(-(q - S(7)/8)**S(2)/8 - S(2197)/13824)**(S.One/3) -
S(13)/6)/2 - S.One/4)**2 - Rational(1, 3))
assert z.equals(0)
def test_random():
from sympy import posify, lucas
assert posify(x)[0]._random() is not None
assert lucas(n)._random(2, -2, 0, -1, 1) is None
# issue 8662
assert Piecewise((Max(x, y), z))._random() is None
def test_round():
from sympy.abc import x
assert str(Float('0.1249999').round(2)) == '0.12'
d20 = 12345678901234567890
ans = S(d20).round(2)
assert ans.is_Integer and ans == d20
ans = S(d20).round(-2)
assert ans.is_Integer and ans == 12345678901234567900
assert str(S('1/7').round(4)) == '0.1429'
assert str(S('.[12345]').round(4)) == '0.1235'
assert str(S('.1349').round(2)) == '0.13'
n = S(12345)
ans = n.round()
assert ans.is_Integer
assert ans == n
ans = n.round(1)
assert ans.is_Integer
assert ans == n
ans = n.round(4)
assert ans.is_Integer
assert ans == n
assert n.round(-1) == 12340
r = Float(str(n)).round(-4)
assert r == 10000
assert n.round(-5) == 0
assert str((pi + sqrt(2)).round(2)) == '4.56'
assert (10*(pi + sqrt(2))).round(-1) == 50
raises(TypeError, lambda: round(x + 2, 2))
assert str(S(2.3).round(1)) == '2.3'
# rounding in SymPy (as in Decimal) should be
# exact for the given precision; we check here
# that when a 5 follows the last digit that
# the rounded digit will be even.
for i in range(-99, 100):
# construct a decimal that ends in 5, e.g. 123 -> 0.1235
s = str(abs(i))
p = len(s) # we are going to round to the last digit of i
n = '0.%s5' % s # put a 5 after i's digits
j = p + 2 # 2 for '0.'
if i < 0: # 1 for '-'
j += 1
n = '-' + n
v = str(Float(n).round(p))[:j] # pertinent digits
if v.endswith('.'):
continue # it ends with 0 which is even
L = int(v[-1]) # last digit
assert L % 2 == 0, (n, '->', v)
assert (Float(.3, 3) + 2*pi).round() == 7
assert (Float(.3, 3) + 2*pi*100).round() == 629
assert (pi + 2*E*I).round() == 3 + 5*I
# don't let request for extra precision give more than
# what is known (in this case, only 3 digits)
assert str((Float(.03, 3) + 2*pi/100).round(5)) == '0.0928'
assert str((Float(.03, 3) + 2*pi/100).round(4)) == '0.0928'
assert S.Zero.round() == 0
a = (Add(1, Float('1.' + '9'*27, ''), evaluate=0))
assert a.round(10) == Float('3.0000000000', '')
assert a.round(25) == Float('3.0000000000000000000000000', '')
assert a.round(26) == Float('3.00000000000000000000000000', '')
assert a.round(27) == Float('2.999999999999999999999999999', '')
assert a.round(30) == Float('2.999999999999999999999999999', '')
raises(TypeError, lambda: x.round())
f = Function('f')
raises(TypeError, lambda: f(1).round())
# exact magnitude of 10
assert str(S.One.round()) == '1'
assert str(S(100).round()) == '100'
# applied to real and imaginary portions
assert (2*pi + E*I).round() == 6 + 3*I
assert (2*pi + I/10).round() == 6
assert (pi/10 + 2*I).round() == 2*I
# the lhs re and im parts are Float with dps of 2
# and those on the right have dps of 15 so they won't compare
# equal unless we use string or compare components (which will
# then coerce the floats to the same precision) or re-create
# the floats
assert str((pi/10 + E*I).round(2)) == '0.31 + 2.72*I'
assert str((pi/10 + E*I).round(2).as_real_imag()) == '(0.31, 2.72)'
assert str((pi/10 + E*I).round(2)) == '0.31 + 2.72*I'
# issue 6914
assert (I**(I + 3)).round(3) == Float('-0.208', '')*I
# issue 8720
assert S(-123.6).round() == -124
assert S(-1.5).round() == -2
assert S(-100.5).round() == -100
assert S(-1.5 - 10.5*I).round() == -2 - 10*I
# issue 7961
assert str(S(0.006).round(2)) == '0.01'
assert str(S(0.00106).round(4)) == '0.0011'
# issue 8147
assert S.NaN.round() is S.NaN
assert S.Infinity.round() is S.Infinity
assert S.NegativeInfinity.round() is S.NegativeInfinity
assert S.ComplexInfinity.round() is S.ComplexInfinity
# check that types match
for i in range(2):
f = float(i)
# 2 args
assert all(type(round(i, p)) is int for p in (-1, 0, 1))
assert all(S(i).round(p).is_Integer for p in (-1, 0, 1))
assert all(type(round(f, p)) is float for p in (-1, 0, 1))
assert all(S(f).round(p).is_Float for p in (-1, 0, 1))
# 1 arg (p is None)
assert type(round(i)) is int
assert S(i).round().is_Integer
assert type(round(f)) is int
assert S(f).round().is_Integer
def test_held_expression_UnevaluatedExpr():
x = symbols("x")
he = UnevaluatedExpr(1/x)
e1 = x*he
assert isinstance(e1, Mul)
assert e1.args == (x, he)
assert e1.doit() == 1
assert UnevaluatedExpr(Derivative(x, x)).doit(deep=False
) == Derivative(x, x)
assert UnevaluatedExpr(Derivative(x, x)).doit() == 1
xx = Mul(x, x, evaluate=False)
assert xx != x**2
ue2 = UnevaluatedExpr(xx)
assert isinstance(ue2, UnevaluatedExpr)
assert ue2.args == (xx,)
assert ue2.doit() == x**2
assert ue2.doit(deep=False) == xx
x2 = UnevaluatedExpr(2)*2
assert type(x2) is Mul
assert x2.args == (2, UnevaluatedExpr(2))
def test_round_exception_nostr():
# Don't use the string form of the expression in the round exception, as
# it's too slow
s = Symbol('bad')
try:
s.round()
except TypeError as e:
assert 'bad' not in str(e)
else:
# Did not raise
raise AssertionError("Did not raise")
def test_extract_branch_factor():
assert exp_polar(2.0*I*pi).extract_branch_factor() == (1, 1)
def test_identity_removal():
assert Add.make_args(x + 0) == (x,)
assert Mul.make_args(x*1) == (x,)
def test_float_0():
assert Float(0.0) + 1 == Float(1.0)
@XFAIL
def test_float_0_fail():
assert Float(0.0)*x == Float(0.0)
assert (x + Float(0.0)).is_Add
def test_issue_6325():
ans = (b**2 + z**2 - (b*(a + b*t) + z*(c + t*z))**2/(
(a + b*t)**2 + (c + t*z)**2))/sqrt((a + b*t)**2 + (c + t*z)**2)
e = sqrt((a + b*t)**2 + (c + z*t)**2)
assert diff(e, t, 2) == ans
e.diff(t, 2) == ans
assert diff(e, t, 2, simplify=False) != ans
def test_issue_7426():
f1 = a % c
f2 = x % z
assert f1.equals(f2) is None
def test_issue_11122():
x = Symbol('x', extended_positive=False)
assert unchanged(Gt, x, 0) # (x > 0)
# (x > 0) should remain unevaluated after PR #16956
x = Symbol('x', positive=False, real=True)
assert (x > 0) is S.false
def test_issue_10651():
x = Symbol('x', real=True)
e1 = (-1 + x)/(1 - x)
e3 = (4*x**2 - 4)/((1 - x)*(1 + x))
e4 = 1/(cos(x)**2) - (tan(x))**2
x = Symbol('x', positive=True)
e5 = (1 + x)/x
assert e1.is_constant() is None
assert e3.is_constant() is None
assert e4.is_constant() is None
assert e5.is_constant() is False
def test_issue_10161():
x = symbols('x', real=True)
assert x*abs(x)*abs(x) == x**3
def test_issue_10755():
x = symbols('x')
raises(TypeError, lambda: int(log(x)))
raises(TypeError, lambda: log(x).round(2))
def test_issue_11877():
x = symbols('x')
assert integrate(log(S.Half - x), (x, 0, S.Half)) == Rational(-1, 2) -log(2)/2
def test_normal():
x = symbols('x')
e = Mul(S.Half, 1 + x, evaluate=False)
assert e.normal() == e
def test_expr():
x = symbols('x')
raises(TypeError, lambda: tan(x).series(x, 2, oo, "+"))
def test_ExprBuilder():
eb = ExprBuilder(Mul)
eb.args.extend([x, x])
assert eb.build() == x**2
def test_non_string_equality():
# Expressions should not compare equal to strings
x = symbols('x')
one = sympify(1)
assert (x == 'x') is False
assert (x != 'x') is True
assert (one == '1') is False
assert (one != '1') is True
assert (x + 1 == 'x + 1') is False
assert (x + 1 != 'x + 1') is True
# Make sure == doesn't try to convert the resulting expression to a string
# (e.g., by calling sympify() instead of _sympify())
class BadRepr:
def __repr__(self):
raise RuntimeError
assert (x == BadRepr()) is False
assert (x != BadRepr()) is True
|
ffcc7891cf0a3cba525329103ab2744e1629f236f27a4e5cb29405f7a49701d0 | from sympy.core.compatibility import (default_sort_key, as_int, ordered,
iterable, NotIterable)
from sympy.core.singleton import S
from sympy.testing.pytest import raises
from sympy.abc import x
def test_default_sort_key():
func = lambda x: x
assert sorted([func, x, func], key=default_sort_key) == [func, func, x]
class C:
def __repr__(self):
return 'x.y'
func = C()
assert sorted([x, func], key=default_sort_key) == [func, x]
def test_as_int():
raises(ValueError, lambda : as_int(True))
raises(ValueError, lambda : as_int(1.1))
raises(ValueError, lambda : as_int([]))
raises(ValueError, lambda : as_int(S.NaN))
raises(ValueError, lambda : as_int(S.Infinity))
raises(ValueError, lambda : as_int(S.NegativeInfinity))
raises(ValueError, lambda : as_int(S.ComplexInfinity))
# for the following, limited precision makes int(arg) == arg
# but the int value is not necessarily what a user might have
# expected; Q.prime is more nuanced in its response for
# expressions which might be complex representations of an
# integer. This is not -- by design -- as_ints role.
raises(ValueError, lambda : as_int(1e23))
raises(ValueError, lambda : as_int(S('1.'+'0'*20+'1')))
assert as_int(True, strict=False) == 1
def test_iterable():
assert iterable(0) is False
assert iterable(1) is False
assert iterable(None) is False
class Test1(NotIterable):
pass
assert iterable(Test1()) is False
class Test2(NotIterable):
_iterable = True
assert iterable(Test2()) is True
class Test3:
pass
assert iterable(Test3()) is False
class Test4:
_iterable = True
assert iterable(Test4()) is True
class Test5:
def __iter__(self):
yield 1
assert iterable(Test5()) is True
class Test6(Test5):
_iterable = False
assert iterable(Test6()) is False
def test_ordered():
# Issue 7210 - this had been failing with python2/3 problems
assert (list(ordered([{1:3, 2:4, 9:10}, {1:3}])) == \
[{1: 3}, {1: 3, 2: 4, 9: 10}])
# warnings should not be raised for identical items
l = [1, 1]
assert list(ordered(l, warn=True)) == l
l = [[1], [2], [1]]
assert list(ordered(l, warn=True)) == [[1], [1], [2]]
raises(ValueError, lambda: list(ordered(['a', 'ab'], keys=[lambda x: x[0]],
default=False, warn=True)))
|
5fc567f4f94665b0727ca9317afbc10b482d81d62594577f0c41f06e5908e42e | """Test whether all elements of cls.args are instances of Basic. """
# NOTE: keep tests sorted by (module, class name) key. If a class can't
# be instantiated, add it here anyway with @SKIP("abstract class) (see
# e.g. Function).
import os
import re
from sympy import (Basic, S, symbols, sqrt, sin, oo, Interval, exp, Lambda, pi,
Eq, log, Function, Rational)
from sympy.testing.pytest import XFAIL, SKIP
x, y, z = symbols('x,y,z')
def test_all_classes_are_tested():
this = os.path.split(__file__)[0]
path = os.path.join(this, os.pardir, os.pardir)
sympy_path = os.path.abspath(path)
prefix = os.path.split(sympy_path)[0] + os.sep
re_cls = re.compile(r"^class ([A-Za-z][A-Za-z0-9_]*)\s*\(", re.MULTILINE)
modules = {}
for root, dirs, files in os.walk(sympy_path):
module = root.replace(prefix, "").replace(os.sep, ".")
for file in files:
if file.startswith(("_", "test_", "bench_")):
continue
if not file.endswith(".py"):
continue
with open(os.path.join(root, file), "r", encoding='utf-8') as f:
text = f.read()
submodule = module + '.' + file[:-3]
names = re_cls.findall(text)
if not names:
continue
try:
mod = __import__(submodule, fromlist=names)
except ImportError:
continue
def is_Basic(name):
cls = getattr(mod, name)
if hasattr(cls, '_sympy_deprecated_func'):
cls = cls._sympy_deprecated_func
return issubclass(cls, Basic)
names = list(filter(is_Basic, names))
if names:
modules[submodule] = names
ns = globals()
failed = []
for module, names in modules.items():
mod = module.replace('.', '__')
for name in names:
test = 'test_' + mod + '__' + name
if test not in ns:
failed.append(module + '.' + name)
assert not failed, "Missing classes: %s. Please add tests for these to sympy/core/tests/test_args.py." % ", ".join(failed)
def _test_args(obj):
all_basic = all(isinstance(arg, Basic) for arg in obj.args)
# Ideally obj.func(*obj.args) would always recreate the object, but for
# now, we only require it for objects with non-empty .args
recreatable = not obj.args or obj.func(*obj.args) == obj
return all_basic and recreatable
def test_sympy__assumptions__assume__AppliedPredicate():
from sympy.assumptions.assume import AppliedPredicate, Predicate
from sympy import Q
assert _test_args(AppliedPredicate(Predicate("test"), 2))
assert _test_args(Q.is_true(True))
def test_sympy__assumptions__assume__Predicate():
from sympy.assumptions.assume import Predicate
assert _test_args(Predicate("test"))
def test_sympy__assumptions__sathandlers__UnevaluatedOnFree():
from sympy.assumptions.sathandlers import UnevaluatedOnFree
from sympy import Q
assert _test_args(UnevaluatedOnFree(Q.positive))
def test_sympy__assumptions__sathandlers__AllArgs():
from sympy.assumptions.sathandlers import AllArgs
from sympy import Q
assert _test_args(AllArgs(Q.positive))
def test_sympy__assumptions__sathandlers__AnyArgs():
from sympy.assumptions.sathandlers import AnyArgs
from sympy import Q
assert _test_args(AnyArgs(Q.positive))
def test_sympy__assumptions__sathandlers__ExactlyOneArg():
from sympy.assumptions.sathandlers import ExactlyOneArg
from sympy import Q
assert _test_args(ExactlyOneArg(Q.positive))
def test_sympy__assumptions__sathandlers__CheckOldAssump():
from sympy.assumptions.sathandlers import CheckOldAssump
from sympy import Q
assert _test_args(CheckOldAssump(Q.positive))
def test_sympy__assumptions__sathandlers__CheckIsPrime():
from sympy.assumptions.sathandlers import CheckIsPrime
from sympy import Q
# Input must be a number
assert _test_args(CheckIsPrime(Q.positive))
@SKIP("abstract Class")
def test_sympy__codegen__ast__AssignmentBase():
from sympy.codegen.ast import AssignmentBase
assert _test_args(AssignmentBase(x, 1))
@SKIP("abstract Class")
def test_sympy__codegen__ast__AugmentedAssignment():
from sympy.codegen.ast import AugmentedAssignment
assert _test_args(AugmentedAssignment(x, 1))
def test_sympy__codegen__ast__AddAugmentedAssignment():
from sympy.codegen.ast import AddAugmentedAssignment
assert _test_args(AddAugmentedAssignment(x, 1))
def test_sympy__codegen__ast__SubAugmentedAssignment():
from sympy.codegen.ast import SubAugmentedAssignment
assert _test_args(SubAugmentedAssignment(x, 1))
def test_sympy__codegen__ast__MulAugmentedAssignment():
from sympy.codegen.ast import MulAugmentedAssignment
assert _test_args(MulAugmentedAssignment(x, 1))
def test_sympy__codegen__ast__DivAugmentedAssignment():
from sympy.codegen.ast import DivAugmentedAssignment
assert _test_args(DivAugmentedAssignment(x, 1))
def test_sympy__codegen__ast__ModAugmentedAssignment():
from sympy.codegen.ast import ModAugmentedAssignment
assert _test_args(ModAugmentedAssignment(x, 1))
def test_sympy__codegen__ast__CodeBlock():
from sympy.codegen.ast import CodeBlock, Assignment
assert _test_args(CodeBlock(Assignment(x, 1), Assignment(y, 2)))
def test_sympy__codegen__ast__For():
from sympy.codegen.ast import For, CodeBlock, AddAugmentedAssignment
from sympy import Range
assert _test_args(For(x, Range(10), CodeBlock(AddAugmentedAssignment(y, 1))))
def test_sympy__codegen__ast__Token():
from sympy.codegen.ast import Token
assert _test_args(Token())
def test_sympy__codegen__ast__ContinueToken():
from sympy.codegen.ast import ContinueToken
assert _test_args(ContinueToken())
def test_sympy__codegen__ast__BreakToken():
from sympy.codegen.ast import BreakToken
assert _test_args(BreakToken())
def test_sympy__codegen__ast__NoneToken():
from sympy.codegen.ast import NoneToken
assert _test_args(NoneToken())
def test_sympy__codegen__ast__String():
from sympy.codegen.ast import String
assert _test_args(String('foobar'))
def test_sympy__codegen__ast__QuotedString():
from sympy.codegen.ast import QuotedString
assert _test_args(QuotedString('foobar'))
def test_sympy__codegen__ast__Comment():
from sympy.codegen.ast import Comment
assert _test_args(Comment('this is a comment'))
def test_sympy__codegen__ast__Node():
from sympy.codegen.ast import Node
assert _test_args(Node())
assert _test_args(Node(attrs={1, 2, 3}))
def test_sympy__codegen__ast__Type():
from sympy.codegen.ast import Type
assert _test_args(Type('float128'))
def test_sympy__codegen__ast__IntBaseType():
from sympy.codegen.ast import IntBaseType
assert _test_args(IntBaseType('bigint'))
def test_sympy__codegen__ast___SizedIntType():
from sympy.codegen.ast import _SizedIntType
assert _test_args(_SizedIntType('int128', 128))
def test_sympy__codegen__ast__SignedIntType():
from sympy.codegen.ast import SignedIntType
assert _test_args(SignedIntType('int128_with_sign', 128))
def test_sympy__codegen__ast__UnsignedIntType():
from sympy.codegen.ast import UnsignedIntType
assert _test_args(UnsignedIntType('unt128', 128))
def test_sympy__codegen__ast__FloatBaseType():
from sympy.codegen.ast import FloatBaseType
assert _test_args(FloatBaseType('positive_real'))
def test_sympy__codegen__ast__FloatType():
from sympy.codegen.ast import FloatType
assert _test_args(FloatType('float242', 242, nmant=142, nexp=99))
def test_sympy__codegen__ast__ComplexBaseType():
from sympy.codegen.ast import ComplexBaseType
assert _test_args(ComplexBaseType('positive_cmplx'))
def test_sympy__codegen__ast__ComplexType():
from sympy.codegen.ast import ComplexType
assert _test_args(ComplexType('complex42', 42, nmant=15, nexp=5))
def test_sympy__codegen__ast__Attribute():
from sympy.codegen.ast import Attribute
assert _test_args(Attribute('noexcept'))
def test_sympy__codegen__ast__Variable():
from sympy.codegen.ast import Variable, Type, value_const
assert _test_args(Variable(x))
assert _test_args(Variable(y, Type('float32'), {value_const}))
assert _test_args(Variable(z, type=Type('float64')))
def test_sympy__codegen__ast__Pointer():
from sympy.codegen.ast import Pointer, Type, pointer_const
assert _test_args(Pointer(x))
assert _test_args(Pointer(y, type=Type('float32')))
assert _test_args(Pointer(z, Type('float64'), {pointer_const}))
def test_sympy__codegen__ast__Declaration():
from sympy.codegen.ast import Declaration, Variable, Type
vx = Variable(x, type=Type('float'))
assert _test_args(Declaration(vx))
def test_sympy__codegen__ast__While():
from sympy.codegen.ast import While, AddAugmentedAssignment
assert _test_args(While(abs(x) < 1, [AddAugmentedAssignment(x, -1)]))
def test_sympy__codegen__ast__Scope():
from sympy.codegen.ast import Scope, AddAugmentedAssignment
assert _test_args(Scope([AddAugmentedAssignment(x, -1)]))
def test_sympy__codegen__ast__Stream():
from sympy.codegen.ast import Stream
assert _test_args(Stream('stdin'))
def test_sympy__codegen__ast__Print():
from sympy.codegen.ast import Print
assert _test_args(Print([x, y]))
assert _test_args(Print([x, y], "%d %d"))
def test_sympy__codegen__ast__FunctionPrototype():
from sympy.codegen.ast import FunctionPrototype, real, Declaration, Variable
inp_x = Declaration(Variable(x, type=real))
assert _test_args(FunctionPrototype(real, 'pwer', [inp_x]))
def test_sympy__codegen__ast__FunctionDefinition():
from sympy.codegen.ast import FunctionDefinition, real, Declaration, Variable, Assignment
inp_x = Declaration(Variable(x, type=real))
assert _test_args(FunctionDefinition(real, 'pwer', [inp_x], [Assignment(x, x**2)]))
def test_sympy__codegen__ast__Return():
from sympy.codegen.ast import Return
assert _test_args(Return(x))
def test_sympy__codegen__ast__FunctionCall():
from sympy.codegen.ast import FunctionCall
assert _test_args(FunctionCall('pwer', [x]))
def test_sympy__codegen__ast__Element():
from sympy.codegen.ast import Element
assert _test_args(Element('x', range(3)))
def test_sympy__codegen__cnodes__CommaOperator():
from sympy.codegen.cnodes import CommaOperator
assert _test_args(CommaOperator(1, 2))
def test_sympy__codegen__cnodes__goto():
from sympy.codegen.cnodes import goto
assert _test_args(goto('early_exit'))
def test_sympy__codegen__cnodes__Label():
from sympy.codegen.cnodes import Label
assert _test_args(Label('early_exit'))
def test_sympy__codegen__cnodes__PreDecrement():
from sympy.codegen.cnodes import PreDecrement
assert _test_args(PreDecrement(x))
def test_sympy__codegen__cnodes__PostDecrement():
from sympy.codegen.cnodes import PostDecrement
assert _test_args(PostDecrement(x))
def test_sympy__codegen__cnodes__PreIncrement():
from sympy.codegen.cnodes import PreIncrement
assert _test_args(PreIncrement(x))
def test_sympy__codegen__cnodes__PostIncrement():
from sympy.codegen.cnodes import PostIncrement
assert _test_args(PostIncrement(x))
def test_sympy__codegen__cnodes__struct():
from sympy.codegen.ast import real, Variable
from sympy.codegen.cnodes import struct
assert _test_args(struct(declarations=[
Variable(x, type=real),
Variable(y, type=real)
]))
def test_sympy__codegen__cnodes__union():
from sympy.codegen.ast import float32, int32, Variable
from sympy.codegen.cnodes import union
assert _test_args(union(declarations=[
Variable(x, type=float32),
Variable(y, type=int32)
]))
def test_sympy__codegen__cxxnodes__using():
from sympy.codegen.cxxnodes import using
assert _test_args(using('std::vector'))
assert _test_args(using('std::vector', 'vec'))
def test_sympy__codegen__fnodes__Program():
from sympy.codegen.fnodes import Program
assert _test_args(Program('foobar', []))
def test_sympy__codegen__fnodes__Module():
from sympy.codegen.fnodes import Module
assert _test_args(Module('foobar', [], []))
def test_sympy__codegen__fnodes__Subroutine():
from sympy.codegen.fnodes import Subroutine
x = symbols('x', real=True)
assert _test_args(Subroutine('foo', [x], []))
def test_sympy__codegen__fnodes__GoTo():
from sympy.codegen.fnodes import GoTo
assert _test_args(GoTo([10]))
assert _test_args(GoTo([10, 20], x > 1))
def test_sympy__codegen__fnodes__FortranReturn():
from sympy.codegen.fnodes import FortranReturn
assert _test_args(FortranReturn(10))
def test_sympy__codegen__fnodes__Extent():
from sympy.codegen.fnodes import Extent
assert _test_args(Extent())
assert _test_args(Extent(None))
assert _test_args(Extent(':'))
assert _test_args(Extent(-3, 4))
assert _test_args(Extent(x, y))
def test_sympy__codegen__fnodes__use_rename():
from sympy.codegen.fnodes import use_rename
assert _test_args(use_rename('loc', 'glob'))
def test_sympy__codegen__fnodes__use():
from sympy.codegen.fnodes import use
assert _test_args(use('modfoo', only='bar'))
def test_sympy__codegen__fnodes__SubroutineCall():
from sympy.codegen.fnodes import SubroutineCall
assert _test_args(SubroutineCall('foo', ['bar', 'baz']))
def test_sympy__codegen__fnodes__Do():
from sympy.codegen.fnodes import Do
assert _test_args(Do([], 'i', 1, 42))
def test_sympy__codegen__fnodes__ImpliedDoLoop():
from sympy.codegen.fnodes import ImpliedDoLoop
assert _test_args(ImpliedDoLoop('i', 'i', 1, 42))
def test_sympy__codegen__fnodes__ArrayConstructor():
from sympy.codegen.fnodes import ArrayConstructor
assert _test_args(ArrayConstructor([1, 2, 3]))
from sympy.codegen.fnodes import ImpliedDoLoop
idl = ImpliedDoLoop('i', 'i', 1, 42)
assert _test_args(ArrayConstructor([1, idl, 3]))
def test_sympy__codegen__fnodes__sum_():
from sympy.codegen.fnodes import sum_
assert _test_args(sum_('arr'))
def test_sympy__codegen__fnodes__product_():
from sympy.codegen.fnodes import product_
assert _test_args(product_('arr'))
@XFAIL
def test_sympy__combinatorics__graycode__GrayCode():
from sympy.combinatorics.graycode import GrayCode
# an integer is given and returned from GrayCode as the arg
assert _test_args(GrayCode(3, start='100'))
assert _test_args(GrayCode(3, rank=1))
def test_sympy__combinatorics__subsets__Subset():
from sympy.combinatorics.subsets import Subset
assert _test_args(Subset([0, 1], [0, 1, 2, 3]))
assert _test_args(Subset(['c', 'd'], ['a', 'b', 'c', 'd']))
def test_sympy__combinatorics__permutations__Permutation():
from sympy.combinatorics.permutations import Permutation
assert _test_args(Permutation([0, 1, 2, 3]))
def test_sympy__combinatorics__permutations__AppliedPermutation():
from sympy.combinatorics.permutations import Permutation
from sympy.combinatorics.permutations import AppliedPermutation
p = Permutation([0, 1, 2, 3])
assert _test_args(AppliedPermutation(p, 1))
def test_sympy__combinatorics__perm_groups__PermutationGroup():
from sympy.combinatorics.permutations import Permutation
from sympy.combinatorics.perm_groups import PermutationGroup
assert _test_args(PermutationGroup([Permutation([0, 1])]))
def test_sympy__combinatorics__polyhedron__Polyhedron():
from sympy.combinatorics.permutations import Permutation
from sympy.combinatorics.polyhedron import Polyhedron
from sympy.abc import w, x, y, z
pgroup = [Permutation([[0, 1, 2], [3]]),
Permutation([[0, 1, 3], [2]]),
Permutation([[0, 2, 3], [1]]),
Permutation([[1, 2, 3], [0]]),
Permutation([[0, 1], [2, 3]]),
Permutation([[0, 2], [1, 3]]),
Permutation([[0, 3], [1, 2]]),
Permutation([[0, 1, 2, 3]])]
corners = [w, x, y, z]
faces = [(w, x, y), (w, y, z), (w, z, x), (x, y, z)]
assert _test_args(Polyhedron(corners, faces, pgroup))
@XFAIL
def test_sympy__combinatorics__prufer__Prufer():
from sympy.combinatorics.prufer import Prufer
assert _test_args(Prufer([[0, 1], [0, 2], [0, 3]], 4))
def test_sympy__combinatorics__partitions__Partition():
from sympy.combinatorics.partitions import Partition
assert _test_args(Partition([1]))
@XFAIL
def test_sympy__combinatorics__partitions__IntegerPartition():
from sympy.combinatorics.partitions import IntegerPartition
assert _test_args(IntegerPartition([1]))
def test_sympy__concrete__products__Product():
from sympy.concrete.products import Product
assert _test_args(Product(x, (x, 0, 10)))
assert _test_args(Product(x, (x, 0, y), (y, 0, 10)))
@SKIP("abstract Class")
def test_sympy__concrete__expr_with_limits__ExprWithLimits():
from sympy.concrete.expr_with_limits import ExprWithLimits
assert _test_args(ExprWithLimits(x, (x, 0, 10)))
assert _test_args(ExprWithLimits(x*y, (x, 0, 10.),(y,1.,3)))
@SKIP("abstract Class")
def test_sympy__concrete__expr_with_limits__AddWithLimits():
from sympy.concrete.expr_with_limits import AddWithLimits
assert _test_args(AddWithLimits(x, (x, 0, 10)))
assert _test_args(AddWithLimits(x*y, (x, 0, 10),(y,1,3)))
@SKIP("abstract Class")
def test_sympy__concrete__expr_with_intlimits__ExprWithIntLimits():
from sympy.concrete.expr_with_intlimits import ExprWithIntLimits
assert _test_args(ExprWithIntLimits(x, (x, 0, 10)))
assert _test_args(ExprWithIntLimits(x*y, (x, 0, 10),(y,1,3)))
def test_sympy__concrete__summations__Sum():
from sympy.concrete.summations import Sum
assert _test_args(Sum(x, (x, 0, 10)))
assert _test_args(Sum(x, (x, 0, y), (y, 0, 10)))
def test_sympy__core__add__Add():
from sympy.core.add import Add
assert _test_args(Add(x, y, z, 2))
def test_sympy__core__basic__Atom():
from sympy.core.basic import Atom
assert _test_args(Atom())
def test_sympy__core__basic__Basic():
from sympy.core.basic import Basic
assert _test_args(Basic())
def test_sympy__core__containers__Dict():
from sympy.core.containers import Dict
assert _test_args(Dict({x: y, y: z}))
def test_sympy__core__containers__Tuple():
from sympy.core.containers import Tuple
assert _test_args(Tuple(x, y, z, 2))
def test_sympy__core__expr__AtomicExpr():
from sympy.core.expr import AtomicExpr
assert _test_args(AtomicExpr())
def test_sympy__core__expr__Expr():
from sympy.core.expr import Expr
assert _test_args(Expr())
def test_sympy__core__expr__UnevaluatedExpr():
from sympy.core.expr import UnevaluatedExpr
from sympy.abc import x
assert _test_args(UnevaluatedExpr(x))
def test_sympy__core__function__Application():
from sympy.core.function import Application
assert _test_args(Application(1, 2, 3))
def test_sympy__core__function__AppliedUndef():
from sympy.core.function import AppliedUndef
assert _test_args(AppliedUndef(1, 2, 3))
def test_sympy__core__function__Derivative():
from sympy.core.function import Derivative
assert _test_args(Derivative(2, x, y, 3))
@SKIP("abstract class")
def test_sympy__core__function__Function():
pass
def test_sympy__core__function__Lambda():
assert _test_args(Lambda((x, y), x + y + z))
def test_sympy__core__function__Subs():
from sympy.core.function import Subs
assert _test_args(Subs(x + y, x, 2))
def test_sympy__core__function__WildFunction():
from sympy.core.function import WildFunction
assert _test_args(WildFunction('f'))
def test_sympy__core__mod__Mod():
from sympy.core.mod import Mod
assert _test_args(Mod(x, 2))
def test_sympy__core__mul__Mul():
from sympy.core.mul import Mul
assert _test_args(Mul(2, x, y, z))
def test_sympy__core__numbers__Catalan():
from sympy.core.numbers import Catalan
assert _test_args(Catalan())
def test_sympy__core__numbers__ComplexInfinity():
from sympy.core.numbers import ComplexInfinity
assert _test_args(ComplexInfinity())
def test_sympy__core__numbers__EulerGamma():
from sympy.core.numbers import EulerGamma
assert _test_args(EulerGamma())
def test_sympy__core__numbers__Exp1():
from sympy.core.numbers import Exp1
assert _test_args(Exp1())
def test_sympy__core__numbers__Float():
from sympy.core.numbers import Float
assert _test_args(Float(1.23))
def test_sympy__core__numbers__GoldenRatio():
from sympy.core.numbers import GoldenRatio
assert _test_args(GoldenRatio())
def test_sympy__core__numbers__TribonacciConstant():
from sympy.core.numbers import TribonacciConstant
assert _test_args(TribonacciConstant())
def test_sympy__core__numbers__Half():
from sympy.core.numbers import Half
assert _test_args(Half())
def test_sympy__core__numbers__ImaginaryUnit():
from sympy.core.numbers import ImaginaryUnit
assert _test_args(ImaginaryUnit())
def test_sympy__core__numbers__Infinity():
from sympy.core.numbers import Infinity
assert _test_args(Infinity())
def test_sympy__core__numbers__Integer():
from sympy.core.numbers import Integer
assert _test_args(Integer(7))
@SKIP("abstract class")
def test_sympy__core__numbers__IntegerConstant():
pass
def test_sympy__core__numbers__NaN():
from sympy.core.numbers import NaN
assert _test_args(NaN())
def test_sympy__core__numbers__NegativeInfinity():
from sympy.core.numbers import NegativeInfinity
assert _test_args(NegativeInfinity())
def test_sympy__core__numbers__NegativeOne():
from sympy.core.numbers import NegativeOne
assert _test_args(NegativeOne())
def test_sympy__core__numbers__Number():
from sympy.core.numbers import Number
assert _test_args(Number(1, 7))
def test_sympy__core__numbers__NumberSymbol():
from sympy.core.numbers import NumberSymbol
assert _test_args(NumberSymbol())
def test_sympy__core__numbers__One():
from sympy.core.numbers import One
assert _test_args(One())
def test_sympy__core__numbers__Pi():
from sympy.core.numbers import Pi
assert _test_args(Pi())
def test_sympy__core__numbers__Rational():
from sympy.core.numbers import Rational
assert _test_args(Rational(1, 7))
@SKIP("abstract class")
def test_sympy__core__numbers__RationalConstant():
pass
def test_sympy__core__numbers__Zero():
from sympy.core.numbers import Zero
assert _test_args(Zero())
@SKIP("abstract class")
def test_sympy__core__operations__AssocOp():
pass
@SKIP("abstract class")
def test_sympy__core__operations__LatticeOp():
pass
def test_sympy__core__power__Pow():
from sympy.core.power import Pow
assert _test_args(Pow(x, 2))
def test_sympy__algebras__quaternion__Quaternion():
from sympy.algebras.quaternion import Quaternion
assert _test_args(Quaternion(x, 1, 2, 3))
def test_sympy__core__relational__Equality():
from sympy.core.relational import Equality
assert _test_args(Equality(x, 2))
def test_sympy__core__relational__GreaterThan():
from sympy.core.relational import GreaterThan
assert _test_args(GreaterThan(x, 2))
def test_sympy__core__relational__LessThan():
from sympy.core.relational import LessThan
assert _test_args(LessThan(x, 2))
@SKIP("abstract class")
def test_sympy__core__relational__Relational():
pass
def test_sympy__core__relational__StrictGreaterThan():
from sympy.core.relational import StrictGreaterThan
assert _test_args(StrictGreaterThan(x, 2))
def test_sympy__core__relational__StrictLessThan():
from sympy.core.relational import StrictLessThan
assert _test_args(StrictLessThan(x, 2))
def test_sympy__core__relational__Unequality():
from sympy.core.relational import Unequality
assert _test_args(Unequality(x, 2))
def test_sympy__sandbox__indexed_integrals__IndexedIntegral():
from sympy.tensor import IndexedBase, Idx
from sympy.sandbox.indexed_integrals import IndexedIntegral
A = IndexedBase('A')
i, j = symbols('i j', integer=True)
a1, a2 = symbols('a1:3', cls=Idx)
assert _test_args(IndexedIntegral(A[a1], A[a2]))
assert _test_args(IndexedIntegral(A[i], A[j]))
def test_sympy__calculus__util__AccumulationBounds():
from sympy.calculus.util import AccumulationBounds
assert _test_args(AccumulationBounds(0, 1))
def test_sympy__sets__ordinals__OmegaPower():
from sympy.sets.ordinals import OmegaPower
assert _test_args(OmegaPower(1, 1))
def test_sympy__sets__ordinals__Ordinal():
from sympy.sets.ordinals import Ordinal, OmegaPower
assert _test_args(Ordinal(OmegaPower(2, 1)))
def test_sympy__sets__ordinals__OrdinalOmega():
from sympy.sets.ordinals import OrdinalOmega
assert _test_args(OrdinalOmega())
def test_sympy__sets__ordinals__OrdinalZero():
from sympy.sets.ordinals import OrdinalZero
assert _test_args(OrdinalZero())
def test_sympy__sets__powerset__PowerSet():
from sympy.sets.powerset import PowerSet
from sympy.core.singleton import S
assert _test_args(PowerSet(S.EmptySet))
def test_sympy__sets__sets__EmptySet():
from sympy.sets.sets import EmptySet
assert _test_args(EmptySet())
def test_sympy__sets__sets__UniversalSet():
from sympy.sets.sets import UniversalSet
assert _test_args(UniversalSet())
def test_sympy__sets__sets__FiniteSet():
from sympy.sets.sets import FiniteSet
assert _test_args(FiniteSet(x, y, z))
def test_sympy__sets__sets__Interval():
from sympy.sets.sets import Interval
assert _test_args(Interval(0, 1))
def test_sympy__sets__sets__ProductSet():
from sympy.sets.sets import ProductSet, Interval
assert _test_args(ProductSet(Interval(0, 1), Interval(0, 1)))
@SKIP("does it make sense to test this?")
def test_sympy__sets__sets__Set():
from sympy.sets.sets import Set
assert _test_args(Set())
def test_sympy__sets__sets__Intersection():
from sympy.sets.sets import Intersection, Interval
from sympy.core.symbol import Symbol
x = Symbol('x')
y = Symbol('y')
S = Intersection(Interval(0, x), Interval(y, 1))
assert isinstance(S, Intersection)
assert _test_args(S)
def test_sympy__sets__sets__Union():
from sympy.sets.sets import Union, Interval
assert _test_args(Union(Interval(0, 1), Interval(2, 3)))
def test_sympy__sets__sets__Complement():
from sympy.sets.sets import Complement
assert _test_args(Complement(Interval(0, 2), Interval(0, 1)))
def test_sympy__sets__sets__SymmetricDifference():
from sympy.sets.sets import FiniteSet, SymmetricDifference
assert _test_args(SymmetricDifference(FiniteSet(1, 2, 3), \
FiniteSet(2, 3, 4)))
def test_sympy__sets__sets__DisjointUnion():
from sympy.sets.sets import FiniteSet, DisjointUnion
assert _test_args(DisjointUnion(FiniteSet(1, 2, 3), \
FiniteSet(2, 3, 4)))
def test_sympy__core__trace__Tr():
from sympy.core.trace import Tr
a, b = symbols('a b')
assert _test_args(Tr(a + b))
def test_sympy__sets__setexpr__SetExpr():
from sympy.sets.setexpr import SetExpr
assert _test_args(SetExpr(Interval(0, 1)))
def test_sympy__sets__fancysets__Rationals():
from sympy.sets.fancysets import Rationals
assert _test_args(Rationals())
def test_sympy__sets__fancysets__Naturals():
from sympy.sets.fancysets import Naturals
assert _test_args(Naturals())
def test_sympy__sets__fancysets__Naturals0():
from sympy.sets.fancysets import Naturals0
assert _test_args(Naturals0())
def test_sympy__sets__fancysets__Integers():
from sympy.sets.fancysets import Integers
assert _test_args(Integers())
def test_sympy__sets__fancysets__Reals():
from sympy.sets.fancysets import Reals
assert _test_args(Reals())
def test_sympy__sets__fancysets__Complexes():
from sympy.sets.fancysets import Complexes
assert _test_args(Complexes())
def test_sympy__sets__fancysets__ComplexRegion():
from sympy.sets.fancysets import ComplexRegion
from sympy import S
from sympy.sets import Interval
a = Interval(0, 1)
b = Interval(2, 3)
theta = Interval(0, 2*S.Pi)
assert _test_args(ComplexRegion(a*b))
assert _test_args(ComplexRegion(a*theta, polar=True))
def test_sympy__sets__fancysets__CartesianComplexRegion():
from sympy.sets.fancysets import CartesianComplexRegion
from sympy.sets import Interval
a = Interval(0, 1)
b = Interval(2, 3)
assert _test_args(CartesianComplexRegion(a*b))
def test_sympy__sets__fancysets__PolarComplexRegion():
from sympy.sets.fancysets import PolarComplexRegion
from sympy import S
from sympy.sets import Interval
a = Interval(0, 1)
theta = Interval(0, 2*S.Pi)
assert _test_args(PolarComplexRegion(a*theta))
def test_sympy__sets__fancysets__ImageSet():
from sympy.sets.fancysets import ImageSet
from sympy import S, Symbol
x = Symbol('x')
assert _test_args(ImageSet(Lambda(x, x**2), S.Naturals))
def test_sympy__sets__fancysets__Range():
from sympy.sets.fancysets import Range
assert _test_args(Range(1, 5, 1))
def test_sympy__sets__conditionset__ConditionSet():
from sympy.sets.conditionset import ConditionSet
from sympy import S, Symbol
x = Symbol('x')
assert _test_args(ConditionSet(x, Eq(x**2, 1), S.Reals))
def test_sympy__sets__contains__Contains():
from sympy.sets.fancysets import Range
from sympy.sets.contains import Contains
assert _test_args(Contains(x, Range(0, 10, 2)))
# STATS
from sympy.stats.crv_types import NormalDistribution
nd = NormalDistribution(0, 1)
from sympy.stats.frv_types import DieDistribution
die = DieDistribution(6)
def test_sympy__stats__crv__ContinuousDomain():
from sympy.stats.crv import ContinuousDomain
assert _test_args(ContinuousDomain({x}, Interval(-oo, oo)))
def test_sympy__stats__crv__SingleContinuousDomain():
from sympy.stats.crv import SingleContinuousDomain
assert _test_args(SingleContinuousDomain(x, Interval(-oo, oo)))
def test_sympy__stats__crv__ProductContinuousDomain():
from sympy.stats.crv import SingleContinuousDomain, ProductContinuousDomain
D = SingleContinuousDomain(x, Interval(-oo, oo))
E = SingleContinuousDomain(y, Interval(0, oo))
assert _test_args(ProductContinuousDomain(D, E))
def test_sympy__stats__crv__ConditionalContinuousDomain():
from sympy.stats.crv import (SingleContinuousDomain,
ConditionalContinuousDomain)
D = SingleContinuousDomain(x, Interval(-oo, oo))
assert _test_args(ConditionalContinuousDomain(D, x > 0))
def test_sympy__stats__crv__ContinuousPSpace():
from sympy.stats.crv import ContinuousPSpace, SingleContinuousDomain
D = SingleContinuousDomain(x, Interval(-oo, oo))
assert _test_args(ContinuousPSpace(D, nd))
def test_sympy__stats__crv__SingleContinuousPSpace():
from sympy.stats.crv import SingleContinuousPSpace
assert _test_args(SingleContinuousPSpace(x, nd))
@SKIP("abstract class")
def test_sympy__stats__crv__SingleContinuousDistribution():
pass
def test_sympy__stats__drv__SingleDiscreteDomain():
from sympy.stats.drv import SingleDiscreteDomain
assert _test_args(SingleDiscreteDomain(x, S.Naturals))
def test_sympy__stats__drv__ProductDiscreteDomain():
from sympy.stats.drv import SingleDiscreteDomain, ProductDiscreteDomain
X = SingleDiscreteDomain(x, S.Naturals)
Y = SingleDiscreteDomain(y, S.Integers)
assert _test_args(ProductDiscreteDomain(X, Y))
def test_sympy__stats__drv__SingleDiscretePSpace():
from sympy.stats.drv import SingleDiscretePSpace
from sympy.stats.drv_types import PoissonDistribution
assert _test_args(SingleDiscretePSpace(x, PoissonDistribution(1)))
def test_sympy__stats__drv__DiscretePSpace():
from sympy.stats.drv import DiscretePSpace, SingleDiscreteDomain
density = Lambda(x, 2**(-x))
domain = SingleDiscreteDomain(x, S.Naturals)
assert _test_args(DiscretePSpace(domain, density))
def test_sympy__stats__drv__ConditionalDiscreteDomain():
from sympy.stats.drv import ConditionalDiscreteDomain, SingleDiscreteDomain
X = SingleDiscreteDomain(x, S.Naturals0)
assert _test_args(ConditionalDiscreteDomain(X, x > 2))
def test_sympy__stats__joint_rv__JointPSpace():
from sympy.stats.joint_rv import JointPSpace, JointDistribution
assert _test_args(JointPSpace('X', JointDistribution(1)))
def test_sympy__stats__joint_rv__JointRandomSymbol():
from sympy.stats.joint_rv import JointRandomSymbol
assert _test_args(JointRandomSymbol(x))
def test_sympy__stats__joint_rv__JointDistributionHandmade():
from sympy import Indexed
from sympy.stats.joint_rv import JointDistributionHandmade
x1, x2 = (Indexed('x', i) for i in (1, 2))
assert _test_args(JointDistributionHandmade(x1 + x2, S.Reals**2))
def test_sympy__stats__joint_rv__MarginalDistribution():
from sympy.stats.rv import RandomSymbol
from sympy.stats.joint_rv import MarginalDistribution
r = RandomSymbol(S('r'))
assert _test_args(MarginalDistribution(r, (r,)))
def test_sympy__stats__joint_rv__CompoundDistribution():
from sympy.stats.joint_rv import CompoundDistribution
from sympy.stats.drv_types import PoissonDistribution
r = PoissonDistribution(x)
assert _test_args(CompoundDistribution(PoissonDistribution(r)))
@SKIP("abstract class")
def test_sympy__stats__drv__SingleDiscreteDistribution():
pass
@SKIP("abstract class")
def test_sympy__stats__drv__DiscreteDistribution():
pass
@SKIP("abstract class")
def test_sympy__stats__drv__DiscreteDomain():
pass
def test_sympy__stats__rv__RandomDomain():
from sympy.stats.rv import RandomDomain
from sympy.sets.sets import FiniteSet
assert _test_args(RandomDomain(FiniteSet(x), FiniteSet(1, 2, 3)))
def test_sympy__stats__rv__SingleDomain():
from sympy.stats.rv import SingleDomain
from sympy.sets.sets import FiniteSet
assert _test_args(SingleDomain(x, FiniteSet(1, 2, 3)))
def test_sympy__stats__rv__ConditionalDomain():
from sympy.stats.rv import ConditionalDomain, RandomDomain
from sympy.sets.sets import FiniteSet
D = RandomDomain(FiniteSet(x), FiniteSet(1, 2))
assert _test_args(ConditionalDomain(D, x > 1))
def test_sympy__stats__rv__PSpace():
from sympy.stats.rv import PSpace, RandomDomain
from sympy import FiniteSet
D = RandomDomain(FiniteSet(x), FiniteSet(1, 2, 3, 4, 5, 6))
assert _test_args(PSpace(D, die))
@SKIP("abstract Class")
def test_sympy__stats__rv__SinglePSpace():
pass
def test_sympy__stats__rv__RandomSymbol():
from sympy.stats.rv import RandomSymbol
from sympy.stats.crv import SingleContinuousPSpace
A = SingleContinuousPSpace(x, nd)
assert _test_args(RandomSymbol(x, A))
@SKIP("abstract Class")
def test_sympy__stats__rv__ProductPSpace():
pass
def test_sympy__stats__rv__IndependentProductPSpace():
from sympy.stats.rv import IndependentProductPSpace
from sympy.stats.crv import SingleContinuousPSpace
A = SingleContinuousPSpace(x, nd)
B = SingleContinuousPSpace(y, nd)
assert _test_args(IndependentProductPSpace(A, B))
def test_sympy__stats__rv__ProductDomain():
from sympy.stats.rv import ProductDomain, SingleDomain
D = SingleDomain(x, Interval(-oo, oo))
E = SingleDomain(y, Interval(0, oo))
assert _test_args(ProductDomain(D, E))
def test_sympy__stats__symbolic_probability__Probability():
from sympy.stats.symbolic_probability import Probability
from sympy.stats import Normal
X = Normal('X', 0, 1)
assert _test_args(Probability(X > 0))
def test_sympy__stats__symbolic_probability__Expectation():
from sympy.stats.symbolic_probability import Expectation
from sympy.stats import Normal
X = Normal('X', 0, 1)
assert _test_args(Expectation(X > 0))
def test_sympy__stats__symbolic_probability__Covariance():
from sympy.stats.symbolic_probability import Covariance
from sympy.stats import Normal
X = Normal('X', 0, 1)
Y = Normal('Y', 0, 3)
assert _test_args(Covariance(X, Y))
def test_sympy__stats__symbolic_probability__Variance():
from sympy.stats.symbolic_probability import Variance
from sympy.stats import Normal
X = Normal('X', 0, 1)
assert _test_args(Variance(X))
def test_sympy__stats__frv_types__DiscreteUniformDistribution():
from sympy.stats.frv_types import DiscreteUniformDistribution
from sympy.core.containers import Tuple
assert _test_args(DiscreteUniformDistribution(Tuple(*list(range(6)))))
def test_sympy__stats__frv_types__DieDistribution():
assert _test_args(die)
def test_sympy__stats__frv_types__BernoulliDistribution():
from sympy.stats.frv_types import BernoulliDistribution
assert _test_args(BernoulliDistribution(S.Half, 0, 1))
def test_sympy__stats__frv_types__BinomialDistribution():
from sympy.stats.frv_types import BinomialDistribution
assert _test_args(BinomialDistribution(5, S.Half, 1, 0))
def test_sympy__stats__frv_types__BetaBinomialDistribution():
from sympy.stats.frv_types import BetaBinomialDistribution
assert _test_args(BetaBinomialDistribution(5, 1, 1))
def test_sympy__stats__frv_types__HypergeometricDistribution():
from sympy.stats.frv_types import HypergeometricDistribution
assert _test_args(HypergeometricDistribution(10, 5, 3))
def test_sympy__stats__frv_types__RademacherDistribution():
from sympy.stats.frv_types import RademacherDistribution
assert _test_args(RademacherDistribution())
def test_sympy__stats__frv__FiniteDomain():
from sympy.stats.frv import FiniteDomain
assert _test_args(FiniteDomain({(x, 1), (x, 2)})) # x can be 1 or 2
def test_sympy__stats__frv__SingleFiniteDomain():
from sympy.stats.frv import SingleFiniteDomain
assert _test_args(SingleFiniteDomain(x, {1, 2})) # x can be 1 or 2
def test_sympy__stats__frv__ProductFiniteDomain():
from sympy.stats.frv import SingleFiniteDomain, ProductFiniteDomain
xd = SingleFiniteDomain(x, {1, 2})
yd = SingleFiniteDomain(y, {1, 2})
assert _test_args(ProductFiniteDomain(xd, yd))
def test_sympy__stats__frv__ConditionalFiniteDomain():
from sympy.stats.frv import SingleFiniteDomain, ConditionalFiniteDomain
xd = SingleFiniteDomain(x, {1, 2})
assert _test_args(ConditionalFiniteDomain(xd, x > 1))
def test_sympy__stats__frv__FinitePSpace():
from sympy.stats.frv import FinitePSpace, SingleFiniteDomain
xd = SingleFiniteDomain(x, {1, 2, 3, 4, 5, 6})
assert _test_args(FinitePSpace(xd, {(x, 1): S.Half, (x, 2): S.Half}))
xd = SingleFiniteDomain(x, {1, 2})
assert _test_args(FinitePSpace(xd, {(x, 1): S.Half, (x, 2): S.Half}))
def test_sympy__stats__frv__SingleFinitePSpace():
from sympy.stats.frv import SingleFinitePSpace
from sympy import Symbol
assert _test_args(SingleFinitePSpace(Symbol('x'), die))
def test_sympy__stats__frv__ProductFinitePSpace():
from sympy.stats.frv import SingleFinitePSpace, ProductFinitePSpace
from sympy import Symbol
xp = SingleFinitePSpace(Symbol('x'), die)
yp = SingleFinitePSpace(Symbol('y'), die)
assert _test_args(ProductFinitePSpace(xp, yp))
@SKIP("abstract class")
def test_sympy__stats__frv__SingleFiniteDistribution():
pass
@SKIP("abstract class")
def test_sympy__stats__crv__ContinuousDistribution():
pass
def test_sympy__stats__frv_types__FiniteDistributionHandmade():
from sympy.stats.frv_types import FiniteDistributionHandmade
from sympy import Dict
assert _test_args(FiniteDistributionHandmade(Dict({1: 1})))
def test_sympy__stats__crv_types__ContinuousDistributionHandmade():
from sympy.stats.crv_types import ContinuousDistributionHandmade
from sympy import Interval, Lambda
from sympy.abc import x
assert _test_args(ContinuousDistributionHandmade(Lambda(x, 2*x),
Interval(0, 1)))
def test_sympy__stats__drv_types__DiscreteDistributionHandmade():
from sympy.stats.drv_types import DiscreteDistributionHandmade
from sympy import Lambda, FiniteSet
from sympy.abc import x
assert _test_args(DiscreteDistributionHandmade(Lambda(x, Rational(1, 10)),
FiniteSet(*range(10))))
def test_sympy__stats__rv__Density():
from sympy.stats.rv import Density
from sympy.stats.crv_types import Normal
assert _test_args(Density(Normal('x', 0, 1)))
def test_sympy__stats__crv_types__ArcsinDistribution():
from sympy.stats.crv_types import ArcsinDistribution
assert _test_args(ArcsinDistribution(0, 1))
def test_sympy__stats__crv_types__BeniniDistribution():
from sympy.stats.crv_types import BeniniDistribution
assert _test_args(BeniniDistribution(1, 1, 1))
def test_sympy__stats__crv_types__BetaDistribution():
from sympy.stats.crv_types import BetaDistribution
assert _test_args(BetaDistribution(1, 1))
def test_sympy__stats__crv_types__BetaNoncentralDistribution():
from sympy.stats.crv_types import BetaNoncentralDistribution
assert _test_args(BetaNoncentralDistribution(1, 1, 1))
def test_sympy__stats__crv_types__BetaPrimeDistribution():
from sympy.stats.crv_types import BetaPrimeDistribution
assert _test_args(BetaPrimeDistribution(1, 1))
def test_sympy__stats__crv_types__BoundedParetoDistribution():
from sympy.stats.crv_types import BoundedParetoDistribution
assert _test_args(BoundedParetoDistribution(1, 1, 2))
def test_sympy__stats__crv_types__CauchyDistribution():
from sympy.stats.crv_types import CauchyDistribution
assert _test_args(CauchyDistribution(0, 1))
def test_sympy__stats__crv_types__ChiDistribution():
from sympy.stats.crv_types import ChiDistribution
assert _test_args(ChiDistribution(1))
def test_sympy__stats__crv_types__ChiNoncentralDistribution():
from sympy.stats.crv_types import ChiNoncentralDistribution
assert _test_args(ChiNoncentralDistribution(1,1))
def test_sympy__stats__crv_types__ChiSquaredDistribution():
from sympy.stats.crv_types import ChiSquaredDistribution
assert _test_args(ChiSquaredDistribution(1))
def test_sympy__stats__crv_types__DagumDistribution():
from sympy.stats.crv_types import DagumDistribution
assert _test_args(DagumDistribution(1, 1, 1))
def test_sympy__stats__crv_types__ExGaussianDistribution():
from sympy.stats.crv_types import ExGaussianDistribution
assert _test_args(ExGaussianDistribution(1, 1, 1))
def test_sympy__stats__crv_types__ExponentialDistribution():
from sympy.stats.crv_types import ExponentialDistribution
assert _test_args(ExponentialDistribution(1))
def test_sympy__stats__crv_types__ExponentialPowerDistribution():
from sympy.stats.crv_types import ExponentialPowerDistribution
assert _test_args(ExponentialPowerDistribution(0, 1, 1))
def test_sympy__stats__crv_types__FDistributionDistribution():
from sympy.stats.crv_types import FDistributionDistribution
assert _test_args(FDistributionDistribution(1, 1))
def test_sympy__stats__crv_types__FisherZDistribution():
from sympy.stats.crv_types import FisherZDistribution
assert _test_args(FisherZDistribution(1, 1))
def test_sympy__stats__crv_types__FrechetDistribution():
from sympy.stats.crv_types import FrechetDistribution
assert _test_args(FrechetDistribution(1, 1, 1))
def test_sympy__stats__crv_types__GammaInverseDistribution():
from sympy.stats.crv_types import GammaInverseDistribution
assert _test_args(GammaInverseDistribution(1, 1))
def test_sympy__stats__crv_types__GammaDistribution():
from sympy.stats.crv_types import GammaDistribution
assert _test_args(GammaDistribution(1, 1))
def test_sympy__stats__crv_types__GumbelDistribution():
from sympy.stats.crv_types import GumbelDistribution
assert _test_args(GumbelDistribution(1, 1, False))
def test_sympy__stats__crv_types__GompertzDistribution():
from sympy.stats.crv_types import GompertzDistribution
assert _test_args(GompertzDistribution(1, 1))
def test_sympy__stats__crv_types__KumaraswamyDistribution():
from sympy.stats.crv_types import KumaraswamyDistribution
assert _test_args(KumaraswamyDistribution(1, 1))
def test_sympy__stats__crv_types__LaplaceDistribution():
from sympy.stats.crv_types import LaplaceDistribution
assert _test_args(LaplaceDistribution(0, 1))
def test_sympy__stats__crv_types__LevyDistribution():
from sympy.stats.crv_types import LevyDistribution
assert _test_args(LevyDistribution(0, 1))
def test_sympy__stats__crv_types__LogisticDistribution():
from sympy.stats.crv_types import LogisticDistribution
assert _test_args(LogisticDistribution(0, 1))
def test_sympy__stats__crv_types__LogLogisticDistribution():
from sympy.stats.crv_types import LogLogisticDistribution
assert _test_args(LogLogisticDistribution(1, 1))
def test_sympy__stats__crv_types__LogNormalDistribution():
from sympy.stats.crv_types import LogNormalDistribution
assert _test_args(LogNormalDistribution(0, 1))
def test_sympy__stats__crv_types__LomaxDistribution():
from sympy.stats.crv_types import LomaxDistribution
assert _test_args(LomaxDistribution(1, 2))
def test_sympy__stats__crv_types__MaxwellDistribution():
from sympy.stats.crv_types import MaxwellDistribution
assert _test_args(MaxwellDistribution(1))
def test_sympy__stats__crv_types__MoyalDistribution():
from sympy.stats.crv_types import MoyalDistribution
assert _test_args(MoyalDistribution(1,2))
def test_sympy__stats__crv_types__NakagamiDistribution():
from sympy.stats.crv_types import NakagamiDistribution
assert _test_args(NakagamiDistribution(1, 1))
def test_sympy__stats__crv_types__NormalDistribution():
from sympy.stats.crv_types import NormalDistribution
assert _test_args(NormalDistribution(0, 1))
def test_sympy__stats__crv_types__GaussianInverseDistribution():
from sympy.stats.crv_types import GaussianInverseDistribution
assert _test_args(GaussianInverseDistribution(1, 1))
def test_sympy__stats__crv_types__ParetoDistribution():
from sympy.stats.crv_types import ParetoDistribution
assert _test_args(ParetoDistribution(1, 1))
def test_sympy__stats__crv_types__PowerFunctionDistribution():
from sympy.stats.crv_types import PowerFunctionDistribution
assert _test_args(PowerFunctionDistribution(2,0,1))
def test_sympy__stats__crv_types__QuadraticUDistribution():
from sympy.stats.crv_types import QuadraticUDistribution
assert _test_args(QuadraticUDistribution(1, 2))
def test_sympy__stats__crv_types__RaisedCosineDistribution():
from sympy.stats.crv_types import RaisedCosineDistribution
assert _test_args(RaisedCosineDistribution(1, 1))
def test_sympy__stats__crv_types__RayleighDistribution():
from sympy.stats.crv_types import RayleighDistribution
assert _test_args(RayleighDistribution(1))
def test_sympy__stats__crv_types__ReciprocalDistribution():
from sympy.stats.crv_types import ReciprocalDistribution
assert _test_args(ReciprocalDistribution(5, 30))
def test_sympy__stats__crv_types__ShiftedGompertzDistribution():
from sympy.stats.crv_types import ShiftedGompertzDistribution
assert _test_args(ShiftedGompertzDistribution(1, 1))
def test_sympy__stats__crv_types__StudentTDistribution():
from sympy.stats.crv_types import StudentTDistribution
assert _test_args(StudentTDistribution(1))
def test_sympy__stats__crv_types__TrapezoidalDistribution():
from sympy.stats.crv_types import TrapezoidalDistribution
assert _test_args(TrapezoidalDistribution(1, 2, 3, 4))
def test_sympy__stats__crv_types__TriangularDistribution():
from sympy.stats.crv_types import TriangularDistribution
assert _test_args(TriangularDistribution(-1, 0, 1))
def test_sympy__stats__crv_types__UniformDistribution():
from sympy.stats.crv_types import UniformDistribution
assert _test_args(UniformDistribution(0, 1))
def test_sympy__stats__crv_types__UniformSumDistribution():
from sympy.stats.crv_types import UniformSumDistribution
assert _test_args(UniformSumDistribution(1))
def test_sympy__stats__crv_types__VonMisesDistribution():
from sympy.stats.crv_types import VonMisesDistribution
assert _test_args(VonMisesDistribution(1, 1))
def test_sympy__stats__crv_types__WeibullDistribution():
from sympy.stats.crv_types import WeibullDistribution
assert _test_args(WeibullDistribution(1, 1))
def test_sympy__stats__crv_types__WignerSemicircleDistribution():
from sympy.stats.crv_types import WignerSemicircleDistribution
assert _test_args(WignerSemicircleDistribution(1))
def test_sympy__stats__drv_types__GeometricDistribution():
from sympy.stats.drv_types import GeometricDistribution
assert _test_args(GeometricDistribution(.5))
def test_sympy__stats__drv_types__HermiteDistribution():
from sympy.stats.drv_types import HermiteDistribution
assert _test_args(HermiteDistribution(1, 2))
def test_sympy__stats__drv_types__LogarithmicDistribution():
from sympy.stats.drv_types import LogarithmicDistribution
assert _test_args(LogarithmicDistribution(.5))
def test_sympy__stats__drv_types__NegativeBinomialDistribution():
from sympy.stats.drv_types import NegativeBinomialDistribution
assert _test_args(NegativeBinomialDistribution(.5, .5))
def test_sympy__stats__drv_types__PoissonDistribution():
from sympy.stats.drv_types import PoissonDistribution
assert _test_args(PoissonDistribution(1))
def test_sympy__stats__drv_types__SkellamDistribution():
from sympy.stats.drv_types import SkellamDistribution
assert _test_args(SkellamDistribution(1, 1))
def test_sympy__stats__drv_types__YuleSimonDistribution():
from sympy.stats.drv_types import YuleSimonDistribution
assert _test_args(YuleSimonDistribution(.5))
def test_sympy__stats__drv_types__ZetaDistribution():
from sympy.stats.drv_types import ZetaDistribution
assert _test_args(ZetaDistribution(1.5))
def test_sympy__stats__joint_rv__JointDistribution():
from sympy.stats.joint_rv import JointDistribution
assert _test_args(JointDistribution(1, 2, 3, 4))
def test_sympy__stats__joint_rv_types__MultivariateNormalDistribution():
from sympy.stats.joint_rv_types import MultivariateNormalDistribution
assert _test_args(
MultivariateNormalDistribution([0, 1], [[1, 0],[0, 1]]))
def test_sympy__stats__joint_rv_types__MultivariateLaplaceDistribution():
from sympy.stats.joint_rv_types import MultivariateLaplaceDistribution
assert _test_args(MultivariateLaplaceDistribution([0, 1], [[1, 0],[0, 1]]))
def test_sympy__stats__joint_rv_types__MultivariateTDistribution():
from sympy.stats.joint_rv_types import MultivariateTDistribution
assert _test_args(MultivariateTDistribution([0, 1], [[1, 0],[0, 1]], 1))
def test_sympy__stats__joint_rv_types__NormalGammaDistribution():
from sympy.stats.joint_rv_types import NormalGammaDistribution
assert _test_args(NormalGammaDistribution(1, 2, 3, 4))
def test_sympy__stats__joint_rv_types__GeneralizedMultivariateLogGammaDistribution():
from sympy.stats.joint_rv_types import GeneralizedMultivariateLogGammaDistribution
v, l, mu = (4, [1, 2, 3, 4], [1, 2, 3, 4])
assert _test_args(GeneralizedMultivariateLogGammaDistribution(S.Half, v, l, mu))
def test_sympy__stats__joint_rv_types__MultivariateBetaDistribution():
from sympy.stats.joint_rv_types import MultivariateBetaDistribution
assert _test_args(MultivariateBetaDistribution([1, 2, 3]))
def test_sympy__stats__joint_rv_types__MultivariateEwensDistribution():
from sympy.stats.joint_rv_types import MultivariateEwensDistribution
assert _test_args(MultivariateEwensDistribution(5, 1))
def test_sympy__stats__joint_rv_types__MultinomialDistribution():
from sympy.stats.joint_rv_types import MultinomialDistribution
assert _test_args(MultinomialDistribution(5, [0.5, 0.1, 0.3]))
def test_sympy__stats__joint_rv_types__NegativeMultinomialDistribution():
from sympy.stats.joint_rv_types import NegativeMultinomialDistribution
assert _test_args(NegativeMultinomialDistribution(5, [0.5, 0.1, 0.3]))
def test_sympy__stats__rv__RandomIndexedSymbol():
from sympy.stats.rv import RandomIndexedSymbol, pspace
from sympy.stats.stochastic_process_types import DiscreteMarkovChain
X = DiscreteMarkovChain("X")
assert _test_args(RandomIndexedSymbol(X[0].symbol, pspace(X[0])))
def test_sympy__stats__rv__RandomMatrixSymbol():
from sympy.stats.rv import RandomMatrixSymbol
from sympy.stats.random_matrix import RandomMatrixPSpace
pspace = RandomMatrixPSpace('P')
assert _test_args(RandomMatrixSymbol('M', 3, 3, pspace))
def test_sympy__stats__stochastic_process__StochasticPSpace():
from sympy.stats.stochastic_process import StochasticPSpace
from sympy.stats.stochastic_process_types import StochasticProcess
from sympy.stats.frv_types import BernoulliDistribution
assert _test_args(StochasticPSpace("Y", StochasticProcess("Y", [1, 2, 3]), BernoulliDistribution(S.Half, 1, 0)))
def test_sympy__stats__stochastic_process_types__StochasticProcess():
from sympy.stats.stochastic_process_types import StochasticProcess
assert _test_args(StochasticProcess("Y", [1, 2, 3]))
def test_sympy__stats__stochastic_process_types__MarkovProcess():
from sympy.stats.stochastic_process_types import MarkovProcess
assert _test_args(MarkovProcess("Y", [1, 2, 3]))
def test_sympy__stats__stochastic_process_types__DiscreteTimeStochasticProcess():
from sympy.stats.stochastic_process_types import DiscreteTimeStochasticProcess
assert _test_args(DiscreteTimeStochasticProcess("Y", [1, 2, 3]))
def test_sympy__stats__stochastic_process_types__ContinuousTimeStochasticProcess():
from sympy.stats.stochastic_process_types import ContinuousTimeStochasticProcess
assert _test_args(ContinuousTimeStochasticProcess("Y", [1, 2, 3]))
def test_sympy__stats__stochastic_process_types__TransitionMatrixOf():
from sympy.stats.stochastic_process_types import TransitionMatrixOf, DiscreteMarkovChain
from sympy import MatrixSymbol
DMC = DiscreteMarkovChain("Y")
assert _test_args(TransitionMatrixOf(DMC, MatrixSymbol('T', 3, 3)))
def test_sympy__stats__stochastic_process_types__GeneratorMatrixOf():
from sympy.stats.stochastic_process_types import GeneratorMatrixOf, ContinuousMarkovChain
from sympy import MatrixSymbol
DMC = ContinuousMarkovChain("Y")
assert _test_args(GeneratorMatrixOf(DMC, MatrixSymbol('T', 3, 3)))
def test_sympy__stats__stochastic_process_types__StochasticStateSpaceOf():
from sympy.stats.stochastic_process_types import StochasticStateSpaceOf, DiscreteMarkovChain
DMC = DiscreteMarkovChain("Y")
assert _test_args(StochasticStateSpaceOf(DMC, [0, 1, 2]))
def test_sympy__stats__stochastic_process_types__DiscreteMarkovChain():
from sympy.stats.stochastic_process_types import DiscreteMarkovChain
from sympy import MatrixSymbol
assert _test_args(DiscreteMarkovChain("Y", [0, 1, 2], MatrixSymbol('T', 3, 3)))
def test_sympy__stats__stochastic_process_types__ContinuousMarkovChain():
from sympy.stats.stochastic_process_types import ContinuousMarkovChain
from sympy import MatrixSymbol
assert _test_args(ContinuousMarkovChain("Y", [0, 1, 2], MatrixSymbol('T', 3, 3)))
def test_sympy__stats__stochastic_process_types__BernoulliProcess():
from sympy.stats.stochastic_process_types import BernoulliProcess
assert _test_args(BernoulliProcess("B", 0.5, 1, 0))
def test_sympy__stats__random_matrix__RandomMatrixPSpace():
from sympy.stats.random_matrix import RandomMatrixPSpace
from sympy.stats.random_matrix_models import RandomMatrixEnsemble
assert _test_args(RandomMatrixPSpace('P', RandomMatrixEnsemble('R', 3)))
def test_sympy__stats__random_matrix_models__RandomMatrixEnsemble():
from sympy.stats.random_matrix_models import RandomMatrixEnsemble
assert _test_args(RandomMatrixEnsemble('R', 3))
def test_sympy__stats__random_matrix_models__GaussianEnsemble():
from sympy.stats.random_matrix_models import GaussianEnsemble
assert _test_args(GaussianEnsemble('G', 3))
def test_sympy__stats__random_matrix_models__GaussianUnitaryEnsemble():
from sympy.stats import GaussianUnitaryEnsemble
assert _test_args(GaussianUnitaryEnsemble('U', 3))
def test_sympy__stats__random_matrix_models__GaussianOrthogonalEnsemble():
from sympy.stats import GaussianOrthogonalEnsemble
assert _test_args(GaussianOrthogonalEnsemble('U', 3))
def test_sympy__stats__random_matrix_models__GaussianSymplecticEnsemble():
from sympy.stats import GaussianSymplecticEnsemble
assert _test_args(GaussianSymplecticEnsemble('U', 3))
def test_sympy__stats__random_matrix_models__CircularEnsemble():
from sympy.stats import CircularEnsemble
assert _test_args(CircularEnsemble('C', 3))
def test_sympy__stats__random_matrix_models__CircularUnitaryEnsemble():
from sympy.stats import CircularUnitaryEnsemble
assert _test_args(CircularUnitaryEnsemble('U', 3))
def test_sympy__stats__random_matrix_models__CircularOrthogonalEnsemble():
from sympy.stats import CircularOrthogonalEnsemble
assert _test_args(CircularOrthogonalEnsemble('O', 3))
def test_sympy__stats__random_matrix_models__CircularSymplecticEnsemble():
from sympy.stats import CircularSymplecticEnsemble
assert _test_args(CircularSymplecticEnsemble('S', 3))
def test_sympy__core__symbol__Dummy():
from sympy.core.symbol import Dummy
assert _test_args(Dummy('t'))
def test_sympy__core__symbol__Symbol():
from sympy.core.symbol import Symbol
assert _test_args(Symbol('t'))
def test_sympy__core__symbol__Wild():
from sympy.core.symbol import Wild
assert _test_args(Wild('x', exclude=[x]))
@SKIP("abstract class")
def test_sympy__functions__combinatorial__factorials__CombinatorialFunction():
pass
def test_sympy__functions__combinatorial__factorials__FallingFactorial():
from sympy.functions.combinatorial.factorials import FallingFactorial
assert _test_args(FallingFactorial(2, x))
def test_sympy__functions__combinatorial__factorials__MultiFactorial():
from sympy.functions.combinatorial.factorials import MultiFactorial
assert _test_args(MultiFactorial(x))
def test_sympy__functions__combinatorial__factorials__RisingFactorial():
from sympy.functions.combinatorial.factorials import RisingFactorial
assert _test_args(RisingFactorial(2, x))
def test_sympy__functions__combinatorial__factorials__binomial():
from sympy.functions.combinatorial.factorials import binomial
assert _test_args(binomial(2, x))
def test_sympy__functions__combinatorial__factorials__subfactorial():
from sympy.functions.combinatorial.factorials import subfactorial
assert _test_args(subfactorial(1))
def test_sympy__functions__combinatorial__factorials__factorial():
from sympy.functions.combinatorial.factorials import factorial
assert _test_args(factorial(x))
def test_sympy__functions__combinatorial__factorials__factorial2():
from sympy.functions.combinatorial.factorials import factorial2
assert _test_args(factorial2(x))
def test_sympy__functions__combinatorial__numbers__bell():
from sympy.functions.combinatorial.numbers import bell
assert _test_args(bell(x, y))
def test_sympy__functions__combinatorial__numbers__bernoulli():
from sympy.functions.combinatorial.numbers import bernoulli
assert _test_args(bernoulli(x))
def test_sympy__functions__combinatorial__numbers__catalan():
from sympy.functions.combinatorial.numbers import catalan
assert _test_args(catalan(x))
def test_sympy__functions__combinatorial__numbers__genocchi():
from sympy.functions.combinatorial.numbers import genocchi
assert _test_args(genocchi(x))
def test_sympy__functions__combinatorial__numbers__euler():
from sympy.functions.combinatorial.numbers import euler
assert _test_args(euler(x))
def test_sympy__functions__combinatorial__numbers__carmichael():
from sympy.functions.combinatorial.numbers import carmichael
assert _test_args(carmichael(x))
def test_sympy__functions__combinatorial__numbers__fibonacci():
from sympy.functions.combinatorial.numbers import fibonacci
assert _test_args(fibonacci(x))
def test_sympy__functions__combinatorial__numbers__tribonacci():
from sympy.functions.combinatorial.numbers import tribonacci
assert _test_args(tribonacci(x))
def test_sympy__functions__combinatorial__numbers__harmonic():
from sympy.functions.combinatorial.numbers import harmonic
assert _test_args(harmonic(x, 2))
def test_sympy__functions__combinatorial__numbers__lucas():
from sympy.functions.combinatorial.numbers import lucas
assert _test_args(lucas(x))
def test_sympy__functions__combinatorial__numbers__partition():
from sympy.core.symbol import Symbol
from sympy.functions.combinatorial.numbers import partition
assert _test_args(partition(Symbol('a', integer=True)))
def test_sympy__functions__elementary__complexes__Abs():
from sympy.functions.elementary.complexes import Abs
assert _test_args(Abs(x))
def test_sympy__functions__elementary__complexes__adjoint():
from sympy.functions.elementary.complexes import adjoint
assert _test_args(adjoint(x))
def test_sympy__functions__elementary__complexes__arg():
from sympy.functions.elementary.complexes import arg
assert _test_args(arg(x))
def test_sympy__functions__elementary__complexes__conjugate():
from sympy.functions.elementary.complexes import conjugate
assert _test_args(conjugate(x))
def test_sympy__functions__elementary__complexes__im():
from sympy.functions.elementary.complexes import im
assert _test_args(im(x))
def test_sympy__functions__elementary__complexes__re():
from sympy.functions.elementary.complexes import re
assert _test_args(re(x))
def test_sympy__functions__elementary__complexes__sign():
from sympy.functions.elementary.complexes import sign
assert _test_args(sign(x))
def test_sympy__functions__elementary__complexes__polar_lift():
from sympy.functions.elementary.complexes import polar_lift
assert _test_args(polar_lift(x))
def test_sympy__functions__elementary__complexes__periodic_argument():
from sympy.functions.elementary.complexes import periodic_argument
assert _test_args(periodic_argument(x, y))
def test_sympy__functions__elementary__complexes__principal_branch():
from sympy.functions.elementary.complexes import principal_branch
assert _test_args(principal_branch(x, y))
def test_sympy__functions__elementary__complexes__transpose():
from sympy.functions.elementary.complexes import transpose
assert _test_args(transpose(x))
def test_sympy__functions__elementary__exponential__LambertW():
from sympy.functions.elementary.exponential import LambertW
assert _test_args(LambertW(2))
@SKIP("abstract class")
def test_sympy__functions__elementary__exponential__ExpBase():
pass
def test_sympy__functions__elementary__exponential__exp():
from sympy.functions.elementary.exponential import exp
assert _test_args(exp(2))
def test_sympy__functions__elementary__exponential__exp_polar():
from sympy.functions.elementary.exponential import exp_polar
assert _test_args(exp_polar(2))
def test_sympy__functions__elementary__exponential__log():
from sympy.functions.elementary.exponential import log
assert _test_args(log(2))
@SKIP("abstract class")
def test_sympy__functions__elementary__hyperbolic__HyperbolicFunction():
pass
@SKIP("abstract class")
def test_sympy__functions__elementary__hyperbolic__ReciprocalHyperbolicFunction():
pass
@SKIP("abstract class")
def test_sympy__functions__elementary__hyperbolic__InverseHyperbolicFunction():
pass
def test_sympy__functions__elementary__hyperbolic__acosh():
from sympy.functions.elementary.hyperbolic import acosh
assert _test_args(acosh(2))
def test_sympy__functions__elementary__hyperbolic__acoth():
from sympy.functions.elementary.hyperbolic import acoth
assert _test_args(acoth(2))
def test_sympy__functions__elementary__hyperbolic__asinh():
from sympy.functions.elementary.hyperbolic import asinh
assert _test_args(asinh(2))
def test_sympy__functions__elementary__hyperbolic__atanh():
from sympy.functions.elementary.hyperbolic import atanh
assert _test_args(atanh(2))
def test_sympy__functions__elementary__hyperbolic__asech():
from sympy.functions.elementary.hyperbolic import asech
assert _test_args(asech(2))
def test_sympy__functions__elementary__hyperbolic__acsch():
from sympy.functions.elementary.hyperbolic import acsch
assert _test_args(acsch(2))
def test_sympy__functions__elementary__hyperbolic__cosh():
from sympy.functions.elementary.hyperbolic import cosh
assert _test_args(cosh(2))
def test_sympy__functions__elementary__hyperbolic__coth():
from sympy.functions.elementary.hyperbolic import coth
assert _test_args(coth(2))
def test_sympy__functions__elementary__hyperbolic__csch():
from sympy.functions.elementary.hyperbolic import csch
assert _test_args(csch(2))
def test_sympy__functions__elementary__hyperbolic__sech():
from sympy.functions.elementary.hyperbolic import sech
assert _test_args(sech(2))
def test_sympy__functions__elementary__hyperbolic__sinh():
from sympy.functions.elementary.hyperbolic import sinh
assert _test_args(sinh(2))
def test_sympy__functions__elementary__hyperbolic__tanh():
from sympy.functions.elementary.hyperbolic import tanh
assert _test_args(tanh(2))
@SKIP("does this work at all?")
def test_sympy__functions__elementary__integers__RoundFunction():
from sympy.functions.elementary.integers import RoundFunction
assert _test_args(RoundFunction())
def test_sympy__functions__elementary__integers__ceiling():
from sympy.functions.elementary.integers import ceiling
assert _test_args(ceiling(x))
def test_sympy__functions__elementary__integers__floor():
from sympy.functions.elementary.integers import floor
assert _test_args(floor(x))
def test_sympy__functions__elementary__integers__frac():
from sympy.functions.elementary.integers import frac
assert _test_args(frac(x))
def test_sympy__functions__elementary__miscellaneous__IdentityFunction():
from sympy.functions.elementary.miscellaneous import IdentityFunction
assert _test_args(IdentityFunction())
def test_sympy__functions__elementary__miscellaneous__Max():
from sympy.functions.elementary.miscellaneous import Max
assert _test_args(Max(x, 2))
def test_sympy__functions__elementary__miscellaneous__Min():
from sympy.functions.elementary.miscellaneous import Min
assert _test_args(Min(x, 2))
@SKIP("abstract class")
def test_sympy__functions__elementary__miscellaneous__MinMaxBase():
pass
def test_sympy__functions__elementary__piecewise__ExprCondPair():
from sympy.functions.elementary.piecewise import ExprCondPair
assert _test_args(ExprCondPair(1, True))
def test_sympy__functions__elementary__piecewise__Piecewise():
from sympy.functions.elementary.piecewise import Piecewise
assert _test_args(Piecewise((1, x >= 0), (0, True)))
@SKIP("abstract class")
def test_sympy__functions__elementary__trigonometric__TrigonometricFunction():
pass
@SKIP("abstract class")
def test_sympy__functions__elementary__trigonometric__ReciprocalTrigonometricFunction():
pass
@SKIP("abstract class")
def test_sympy__functions__elementary__trigonometric__InverseTrigonometricFunction():
pass
def test_sympy__functions__elementary__trigonometric__acos():
from sympy.functions.elementary.trigonometric import acos
assert _test_args(acos(2))
def test_sympy__functions__elementary__trigonometric__acot():
from sympy.functions.elementary.trigonometric import acot
assert _test_args(acot(2))
def test_sympy__functions__elementary__trigonometric__asin():
from sympy.functions.elementary.trigonometric import asin
assert _test_args(asin(2))
def test_sympy__functions__elementary__trigonometric__asec():
from sympy.functions.elementary.trigonometric import asec
assert _test_args(asec(2))
def test_sympy__functions__elementary__trigonometric__acsc():
from sympy.functions.elementary.trigonometric import acsc
assert _test_args(acsc(2))
def test_sympy__functions__elementary__trigonometric__atan():
from sympy.functions.elementary.trigonometric import atan
assert _test_args(atan(2))
def test_sympy__functions__elementary__trigonometric__atan2():
from sympy.functions.elementary.trigonometric import atan2
assert _test_args(atan2(2, 3))
def test_sympy__functions__elementary__trigonometric__cos():
from sympy.functions.elementary.trigonometric import cos
assert _test_args(cos(2))
def test_sympy__functions__elementary__trigonometric__csc():
from sympy.functions.elementary.trigonometric import csc
assert _test_args(csc(2))
def test_sympy__functions__elementary__trigonometric__cot():
from sympy.functions.elementary.trigonometric import cot
assert _test_args(cot(2))
def test_sympy__functions__elementary__trigonometric__sin():
assert _test_args(sin(2))
def test_sympy__functions__elementary__trigonometric__sinc():
from sympy.functions.elementary.trigonometric import sinc
assert _test_args(sinc(2))
def test_sympy__functions__elementary__trigonometric__sec():
from sympy.functions.elementary.trigonometric import sec
assert _test_args(sec(2))
def test_sympy__functions__elementary__trigonometric__tan():
from sympy.functions.elementary.trigonometric import tan
assert _test_args(tan(2))
@SKIP("abstract class")
def test_sympy__functions__special__bessel__BesselBase():
pass
@SKIP("abstract class")
def test_sympy__functions__special__bessel__SphericalBesselBase():
pass
@SKIP("abstract class")
def test_sympy__functions__special__bessel__SphericalHankelBase():
pass
def test_sympy__functions__special__bessel__besseli():
from sympy.functions.special.bessel import besseli
assert _test_args(besseli(x, 1))
def test_sympy__functions__special__bessel__besselj():
from sympy.functions.special.bessel import besselj
assert _test_args(besselj(x, 1))
def test_sympy__functions__special__bessel__besselk():
from sympy.functions.special.bessel import besselk
assert _test_args(besselk(x, 1))
def test_sympy__functions__special__bessel__bessely():
from sympy.functions.special.bessel import bessely
assert _test_args(bessely(x, 1))
def test_sympy__functions__special__bessel__hankel1():
from sympy.functions.special.bessel import hankel1
assert _test_args(hankel1(x, 1))
def test_sympy__functions__special__bessel__hankel2():
from sympy.functions.special.bessel import hankel2
assert _test_args(hankel2(x, 1))
def test_sympy__functions__special__bessel__jn():
from sympy.functions.special.bessel import jn
assert _test_args(jn(0, x))
def test_sympy__functions__special__bessel__yn():
from sympy.functions.special.bessel import yn
assert _test_args(yn(0, x))
def test_sympy__functions__special__bessel__hn1():
from sympy.functions.special.bessel import hn1
assert _test_args(hn1(0, x))
def test_sympy__functions__special__bessel__hn2():
from sympy.functions.special.bessel import hn2
assert _test_args(hn2(0, x))
def test_sympy__functions__special__bessel__AiryBase():
pass
def test_sympy__functions__special__bessel__airyai():
from sympy.functions.special.bessel import airyai
assert _test_args(airyai(2))
def test_sympy__functions__special__bessel__airybi():
from sympy.functions.special.bessel import airybi
assert _test_args(airybi(2))
def test_sympy__functions__special__bessel__airyaiprime():
from sympy.functions.special.bessel import airyaiprime
assert _test_args(airyaiprime(2))
def test_sympy__functions__special__bessel__airybiprime():
from sympy.functions.special.bessel import airybiprime
assert _test_args(airybiprime(2))
def test_sympy__functions__special__bessel__marcumq():
from sympy.functions.special.bessel import marcumq
assert _test_args(marcumq(x, y, z))
def test_sympy__functions__special__elliptic_integrals__elliptic_k():
from sympy.functions.special.elliptic_integrals import elliptic_k as K
assert _test_args(K(x))
def test_sympy__functions__special__elliptic_integrals__elliptic_f():
from sympy.functions.special.elliptic_integrals import elliptic_f as F
assert _test_args(F(x, y))
def test_sympy__functions__special__elliptic_integrals__elliptic_e():
from sympy.functions.special.elliptic_integrals import elliptic_e as E
assert _test_args(E(x))
assert _test_args(E(x, y))
def test_sympy__functions__special__elliptic_integrals__elliptic_pi():
from sympy.functions.special.elliptic_integrals import elliptic_pi as P
assert _test_args(P(x, y))
assert _test_args(P(x, y, z))
def test_sympy__functions__special__delta_functions__DiracDelta():
from sympy.functions.special.delta_functions import DiracDelta
assert _test_args(DiracDelta(x, 1))
def test_sympy__functions__special__singularity_functions__SingularityFunction():
from sympy.functions.special.singularity_functions import SingularityFunction
assert _test_args(SingularityFunction(x, y, z))
def test_sympy__functions__special__delta_functions__Heaviside():
from sympy.functions.special.delta_functions import Heaviside
assert _test_args(Heaviside(x))
def test_sympy__functions__special__error_functions__erf():
from sympy.functions.special.error_functions import erf
assert _test_args(erf(2))
def test_sympy__functions__special__error_functions__erfc():
from sympy.functions.special.error_functions import erfc
assert _test_args(erfc(2))
def test_sympy__functions__special__error_functions__erfi():
from sympy.functions.special.error_functions import erfi
assert _test_args(erfi(2))
def test_sympy__functions__special__error_functions__erf2():
from sympy.functions.special.error_functions import erf2
assert _test_args(erf2(2, 3))
def test_sympy__functions__special__error_functions__erfinv():
from sympy.functions.special.error_functions import erfinv
assert _test_args(erfinv(2))
def test_sympy__functions__special__error_functions__erfcinv():
from sympy.functions.special.error_functions import erfcinv
assert _test_args(erfcinv(2))
def test_sympy__functions__special__error_functions__erf2inv():
from sympy.functions.special.error_functions import erf2inv
assert _test_args(erf2inv(2, 3))
@SKIP("abstract class")
def test_sympy__functions__special__error_functions__FresnelIntegral():
pass
def test_sympy__functions__special__error_functions__fresnels():
from sympy.functions.special.error_functions import fresnels
assert _test_args(fresnels(2))
def test_sympy__functions__special__error_functions__fresnelc():
from sympy.functions.special.error_functions import fresnelc
assert _test_args(fresnelc(2))
def test_sympy__functions__special__error_functions__erfs():
from sympy.functions.special.error_functions import _erfs
assert _test_args(_erfs(2))
def test_sympy__functions__special__error_functions__Ei():
from sympy.functions.special.error_functions import Ei
assert _test_args(Ei(2))
def test_sympy__functions__special__error_functions__li():
from sympy.functions.special.error_functions import li
assert _test_args(li(2))
def test_sympy__functions__special__error_functions__Li():
from sympy.functions.special.error_functions import Li
assert _test_args(Li(2))
@SKIP("abstract class")
def test_sympy__functions__special__error_functions__TrigonometricIntegral():
pass
def test_sympy__functions__special__error_functions__Si():
from sympy.functions.special.error_functions import Si
assert _test_args(Si(2))
def test_sympy__functions__special__error_functions__Ci():
from sympy.functions.special.error_functions import Ci
assert _test_args(Ci(2))
def test_sympy__functions__special__error_functions__Shi():
from sympy.functions.special.error_functions import Shi
assert _test_args(Shi(2))
def test_sympy__functions__special__error_functions__Chi():
from sympy.functions.special.error_functions import Chi
assert _test_args(Chi(2))
def test_sympy__functions__special__error_functions__expint():
from sympy.functions.special.error_functions import expint
assert _test_args(expint(y, x))
def test_sympy__functions__special__gamma_functions__gamma():
from sympy.functions.special.gamma_functions import gamma
assert _test_args(gamma(x))
def test_sympy__functions__special__gamma_functions__loggamma():
from sympy.functions.special.gamma_functions import loggamma
assert _test_args(loggamma(2))
def test_sympy__functions__special__gamma_functions__lowergamma():
from sympy.functions.special.gamma_functions import lowergamma
assert _test_args(lowergamma(x, 2))
def test_sympy__functions__special__gamma_functions__polygamma():
from sympy.functions.special.gamma_functions import polygamma
assert _test_args(polygamma(x, 2))
def test_sympy__functions__special__gamma_functions__digamma():
from sympy.functions.special.gamma_functions import digamma
assert _test_args(digamma(x))
def test_sympy__functions__special__gamma_functions__trigamma():
from sympy.functions.special.gamma_functions import trigamma
assert _test_args(trigamma(x))
def test_sympy__functions__special__gamma_functions__uppergamma():
from sympy.functions.special.gamma_functions import uppergamma
assert _test_args(uppergamma(x, 2))
def test_sympy__functions__special__gamma_functions__multigamma():
from sympy.functions.special.gamma_functions import multigamma
assert _test_args(multigamma(x, 1))
def test_sympy__functions__special__beta_functions__beta():
from sympy.functions.special.beta_functions import beta
assert _test_args(beta(x, x))
def test_sympy__functions__special__mathieu_functions__MathieuBase():
pass
def test_sympy__functions__special__mathieu_functions__mathieus():
from sympy.functions.special.mathieu_functions import mathieus
assert _test_args(mathieus(1, 1, 1))
def test_sympy__functions__special__mathieu_functions__mathieuc():
from sympy.functions.special.mathieu_functions import mathieuc
assert _test_args(mathieuc(1, 1, 1))
def test_sympy__functions__special__mathieu_functions__mathieusprime():
from sympy.functions.special.mathieu_functions import mathieusprime
assert _test_args(mathieusprime(1, 1, 1))
def test_sympy__functions__special__mathieu_functions__mathieucprime():
from sympy.functions.special.mathieu_functions import mathieucprime
assert _test_args(mathieucprime(1, 1, 1))
@SKIP("abstract class")
def test_sympy__functions__special__hyper__TupleParametersBase():
pass
@SKIP("abstract class")
def test_sympy__functions__special__hyper__TupleArg():
pass
def test_sympy__functions__special__hyper__hyper():
from sympy.functions.special.hyper import hyper
assert _test_args(hyper([1, 2, 3], [4, 5], x))
def test_sympy__functions__special__hyper__meijerg():
from sympy.functions.special.hyper import meijerg
assert _test_args(meijerg([1, 2, 3], [4, 5], [6], [], x))
@SKIP("abstract class")
def test_sympy__functions__special__hyper__HyperRep():
pass
def test_sympy__functions__special__hyper__HyperRep_power1():
from sympy.functions.special.hyper import HyperRep_power1
assert _test_args(HyperRep_power1(x, y))
def test_sympy__functions__special__hyper__HyperRep_power2():
from sympy.functions.special.hyper import HyperRep_power2
assert _test_args(HyperRep_power2(x, y))
def test_sympy__functions__special__hyper__HyperRep_log1():
from sympy.functions.special.hyper import HyperRep_log1
assert _test_args(HyperRep_log1(x))
def test_sympy__functions__special__hyper__HyperRep_atanh():
from sympy.functions.special.hyper import HyperRep_atanh
assert _test_args(HyperRep_atanh(x))
def test_sympy__functions__special__hyper__HyperRep_asin1():
from sympy.functions.special.hyper import HyperRep_asin1
assert _test_args(HyperRep_asin1(x))
def test_sympy__functions__special__hyper__HyperRep_asin2():
from sympy.functions.special.hyper import HyperRep_asin2
assert _test_args(HyperRep_asin2(x))
def test_sympy__functions__special__hyper__HyperRep_sqrts1():
from sympy.functions.special.hyper import HyperRep_sqrts1
assert _test_args(HyperRep_sqrts1(x, y))
def test_sympy__functions__special__hyper__HyperRep_sqrts2():
from sympy.functions.special.hyper import HyperRep_sqrts2
assert _test_args(HyperRep_sqrts2(x, y))
def test_sympy__functions__special__hyper__HyperRep_log2():
from sympy.functions.special.hyper import HyperRep_log2
assert _test_args(HyperRep_log2(x))
def test_sympy__functions__special__hyper__HyperRep_cosasin():
from sympy.functions.special.hyper import HyperRep_cosasin
assert _test_args(HyperRep_cosasin(x, y))
def test_sympy__functions__special__hyper__HyperRep_sinasin():
from sympy.functions.special.hyper import HyperRep_sinasin
assert _test_args(HyperRep_sinasin(x, y))
def test_sympy__functions__special__hyper__appellf1():
from sympy.functions.special.hyper import appellf1
a, b1, b2, c, x, y = symbols('a b1 b2 c x y')
assert _test_args(appellf1(a, b1, b2, c, x, y))
@SKIP("abstract class")
def test_sympy__functions__special__polynomials__OrthogonalPolynomial():
pass
def test_sympy__functions__special__polynomials__jacobi():
from sympy.functions.special.polynomials import jacobi
assert _test_args(jacobi(x, 2, 2, 2))
def test_sympy__functions__special__polynomials__gegenbauer():
from sympy.functions.special.polynomials import gegenbauer
assert _test_args(gegenbauer(x, 2, 2))
def test_sympy__functions__special__polynomials__chebyshevt():
from sympy.functions.special.polynomials import chebyshevt
assert _test_args(chebyshevt(x, 2))
def test_sympy__functions__special__polynomials__chebyshevt_root():
from sympy.functions.special.polynomials import chebyshevt_root
assert _test_args(chebyshevt_root(3, 2))
def test_sympy__functions__special__polynomials__chebyshevu():
from sympy.functions.special.polynomials import chebyshevu
assert _test_args(chebyshevu(x, 2))
def test_sympy__functions__special__polynomials__chebyshevu_root():
from sympy.functions.special.polynomials import chebyshevu_root
assert _test_args(chebyshevu_root(3, 2))
def test_sympy__functions__special__polynomials__hermite():
from sympy.functions.special.polynomials import hermite
assert _test_args(hermite(x, 2))
def test_sympy__functions__special__polynomials__legendre():
from sympy.functions.special.polynomials import legendre
assert _test_args(legendre(x, 2))
def test_sympy__functions__special__polynomials__assoc_legendre():
from sympy.functions.special.polynomials import assoc_legendre
assert _test_args(assoc_legendre(x, 0, y))
def test_sympy__functions__special__polynomials__laguerre():
from sympy.functions.special.polynomials import laguerre
assert _test_args(laguerre(x, 2))
def test_sympy__functions__special__polynomials__assoc_laguerre():
from sympy.functions.special.polynomials import assoc_laguerre
assert _test_args(assoc_laguerre(x, 0, y))
def test_sympy__functions__special__spherical_harmonics__Ynm():
from sympy.functions.special.spherical_harmonics import Ynm
assert _test_args(Ynm(1, 1, x, y))
def test_sympy__functions__special__spherical_harmonics__Znm():
from sympy.functions.special.spherical_harmonics import Znm
assert _test_args(Znm(1, 1, x, y))
def test_sympy__functions__special__tensor_functions__LeviCivita():
from sympy.functions.special.tensor_functions import LeviCivita
assert _test_args(LeviCivita(x, y, 2))
def test_sympy__functions__special__tensor_functions__KroneckerDelta():
from sympy.functions.special.tensor_functions import KroneckerDelta
assert _test_args(KroneckerDelta(x, y))
def test_sympy__functions__special__zeta_functions__dirichlet_eta():
from sympy.functions.special.zeta_functions import dirichlet_eta
assert _test_args(dirichlet_eta(x))
def test_sympy__functions__special__zeta_functions__zeta():
from sympy.functions.special.zeta_functions import zeta
assert _test_args(zeta(101))
def test_sympy__functions__special__zeta_functions__lerchphi():
from sympy.functions.special.zeta_functions import lerchphi
assert _test_args(lerchphi(x, y, z))
def test_sympy__functions__special__zeta_functions__polylog():
from sympy.functions.special.zeta_functions import polylog
assert _test_args(polylog(x, y))
def test_sympy__functions__special__zeta_functions__stieltjes():
from sympy.functions.special.zeta_functions import stieltjes
assert _test_args(stieltjes(x, y))
def test_sympy__integrals__integrals__Integral():
from sympy.integrals.integrals import Integral
assert _test_args(Integral(2, (x, 0, 1)))
def test_sympy__integrals__risch__NonElementaryIntegral():
from sympy.integrals.risch import NonElementaryIntegral
assert _test_args(NonElementaryIntegral(exp(-x**2), x))
@SKIP("abstract class")
def test_sympy__integrals__transforms__IntegralTransform():
pass
def test_sympy__integrals__transforms__MellinTransform():
from sympy.integrals.transforms import MellinTransform
assert _test_args(MellinTransform(2, x, y))
def test_sympy__integrals__transforms__InverseMellinTransform():
from sympy.integrals.transforms import InverseMellinTransform
assert _test_args(InverseMellinTransform(2, x, y, 0, 1))
def test_sympy__integrals__transforms__LaplaceTransform():
from sympy.integrals.transforms import LaplaceTransform
assert _test_args(LaplaceTransform(2, x, y))
def test_sympy__integrals__transforms__InverseLaplaceTransform():
from sympy.integrals.transforms import InverseLaplaceTransform
assert _test_args(InverseLaplaceTransform(2, x, y, 0))
@SKIP("abstract class")
def test_sympy__integrals__transforms__FourierTypeTransform():
pass
def test_sympy__integrals__transforms__InverseFourierTransform():
from sympy.integrals.transforms import InverseFourierTransform
assert _test_args(InverseFourierTransform(2, x, y))
def test_sympy__integrals__transforms__FourierTransform():
from sympy.integrals.transforms import FourierTransform
assert _test_args(FourierTransform(2, x, y))
@SKIP("abstract class")
def test_sympy__integrals__transforms__SineCosineTypeTransform():
pass
def test_sympy__integrals__transforms__InverseSineTransform():
from sympy.integrals.transforms import InverseSineTransform
assert _test_args(InverseSineTransform(2, x, y))
def test_sympy__integrals__transforms__SineTransform():
from sympy.integrals.transforms import SineTransform
assert _test_args(SineTransform(2, x, y))
def test_sympy__integrals__transforms__InverseCosineTransform():
from sympy.integrals.transforms import InverseCosineTransform
assert _test_args(InverseCosineTransform(2, x, y))
def test_sympy__integrals__transforms__CosineTransform():
from sympy.integrals.transforms import CosineTransform
assert _test_args(CosineTransform(2, x, y))
@SKIP("abstract class")
def test_sympy__integrals__transforms__HankelTypeTransform():
pass
def test_sympy__integrals__transforms__InverseHankelTransform():
from sympy.integrals.transforms import InverseHankelTransform
assert _test_args(InverseHankelTransform(2, x, y, 0))
def test_sympy__integrals__transforms__HankelTransform():
from sympy.integrals.transforms import HankelTransform
assert _test_args(HankelTransform(2, x, y, 0))
@XFAIL
def test_sympy__liealgebras__cartan_type__CartanType_generator():
from sympy.liealgebras.cartan_type import CartanType_generator
assert _test_args(CartanType_generator("A2"))
@XFAIL
def test_sympy__liealgebras__cartan_type__Standard_Cartan():
from sympy.liealgebras.cartan_type import Standard_Cartan
assert _test_args(Standard_Cartan("A", 2))
@XFAIL
def test_sympy__liealgebras__weyl_group__WeylGroup():
from sympy.liealgebras.weyl_group import WeylGroup
assert _test_args(WeylGroup("B4"))
@XFAIL
def test_sympy__liealgebras__root_system__RootSystem():
from sympy.liealgebras.root_system import RootSystem
assert _test_args(RootSystem("A2"))
@XFAIL
def test_sympy__liealgebras__type_a__TypeA():
from sympy.liealgebras.type_a import TypeA
assert _test_args(TypeA(2))
@XFAIL
def test_sympy__liealgebras__type_b__TypeB():
from sympy.liealgebras.type_b import TypeB
assert _test_args(TypeB(4))
@XFAIL
def test_sympy__liealgebras__type_c__TypeC():
from sympy.liealgebras.type_c import TypeC
assert _test_args(TypeC(4))
@XFAIL
def test_sympy__liealgebras__type_d__TypeD():
from sympy.liealgebras.type_d import TypeD
assert _test_args(TypeD(4))
@XFAIL
def test_sympy__liealgebras__type_e__TypeE():
from sympy.liealgebras.type_e import TypeE
assert _test_args(TypeE(6))
@XFAIL
def test_sympy__liealgebras__type_f__TypeF():
from sympy.liealgebras.type_f import TypeF
assert _test_args(TypeF(4))
@XFAIL
def test_sympy__liealgebras__type_g__TypeG():
from sympy.liealgebras.type_g import TypeG
assert _test_args(TypeG(2))
def test_sympy__logic__boolalg__And():
from sympy.logic.boolalg import And
assert _test_args(And(x, y, 1))
@SKIP("abstract class")
def test_sympy__logic__boolalg__Boolean():
pass
def test_sympy__logic__boolalg__BooleanFunction():
from sympy.logic.boolalg import BooleanFunction
assert _test_args(BooleanFunction(1, 2, 3))
@SKIP("abstract class")
def test_sympy__logic__boolalg__BooleanAtom():
pass
def test_sympy__logic__boolalg__BooleanTrue():
from sympy.logic.boolalg import true
assert _test_args(true)
def test_sympy__logic__boolalg__BooleanFalse():
from sympy.logic.boolalg import false
assert _test_args(false)
def test_sympy__logic__boolalg__Equivalent():
from sympy.logic.boolalg import Equivalent
assert _test_args(Equivalent(x, 2))
def test_sympy__logic__boolalg__ITE():
from sympy.logic.boolalg import ITE
assert _test_args(ITE(x, y, 1))
def test_sympy__logic__boolalg__Implies():
from sympy.logic.boolalg import Implies
assert _test_args(Implies(x, y))
def test_sympy__logic__boolalg__Nand():
from sympy.logic.boolalg import Nand
assert _test_args(Nand(x, y, 1))
def test_sympy__logic__boolalg__Nor():
from sympy.logic.boolalg import Nor
assert _test_args(Nor(x, y))
def test_sympy__logic__boolalg__Not():
from sympy.logic.boolalg import Not
assert _test_args(Not(x))
def test_sympy__logic__boolalg__Or():
from sympy.logic.boolalg import Or
assert _test_args(Or(x, y))
def test_sympy__logic__boolalg__Xor():
from sympy.logic.boolalg import Xor
assert _test_args(Xor(x, y, 2))
def test_sympy__logic__boolalg__Xnor():
from sympy.logic.boolalg import Xnor
assert _test_args(Xnor(x, y, 2))
def test_sympy__matrices__matrices__DeferredVector():
from sympy.matrices.matrices import DeferredVector
assert _test_args(DeferredVector("X"))
@SKIP("abstract class")
def test_sympy__matrices__expressions__matexpr__MatrixBase():
pass
def test_sympy__matrices__immutable__ImmutableDenseMatrix():
from sympy.matrices.immutable import ImmutableDenseMatrix
m = ImmutableDenseMatrix([[1, 2], [3, 4]])
assert _test_args(m)
assert _test_args(Basic(*list(m)))
m = ImmutableDenseMatrix(1, 1, [1])
assert _test_args(m)
assert _test_args(Basic(*list(m)))
m = ImmutableDenseMatrix(2, 2, lambda i, j: 1)
assert m[0, 0] is S.One
m = ImmutableDenseMatrix(2, 2, lambda i, j: 1/(1 + i) + 1/(1 + j))
assert m[1, 1] is S.One # true div. will give 1.0 if i,j not sympified
assert _test_args(m)
assert _test_args(Basic(*list(m)))
def test_sympy__matrices__immutable__ImmutableSparseMatrix():
from sympy.matrices.immutable import ImmutableSparseMatrix
m = ImmutableSparseMatrix([[1, 2], [3, 4]])
assert _test_args(m)
assert _test_args(Basic(*list(m)))
m = ImmutableSparseMatrix(1, 1, {(0, 0): 1})
assert _test_args(m)
assert _test_args(Basic(*list(m)))
m = ImmutableSparseMatrix(1, 1, [1])
assert _test_args(m)
assert _test_args(Basic(*list(m)))
m = ImmutableSparseMatrix(2, 2, lambda i, j: 1)
assert m[0, 0] is S.One
m = ImmutableSparseMatrix(2, 2, lambda i, j: 1/(1 + i) + 1/(1 + j))
assert m[1, 1] is S.One # true div. will give 1.0 if i,j not sympified
assert _test_args(m)
assert _test_args(Basic(*list(m)))
def test_sympy__matrices__expressions__slice__MatrixSlice():
from sympy.matrices.expressions.slice import MatrixSlice
from sympy.matrices.expressions import MatrixSymbol
X = MatrixSymbol('X', 4, 4)
assert _test_args(MatrixSlice(X, (0, 2), (0, 2)))
def test_sympy__matrices__expressions__applyfunc__ElementwiseApplyFunction():
from sympy.matrices.expressions.applyfunc import ElementwiseApplyFunction
from sympy.matrices.expressions import MatrixSymbol
X = MatrixSymbol("X", x, x)
func = Lambda(x, x**2)
assert _test_args(ElementwiseApplyFunction(func, X))
def test_sympy__matrices__expressions__blockmatrix__BlockDiagMatrix():
from sympy.matrices.expressions.blockmatrix import BlockDiagMatrix
from sympy.matrices.expressions import MatrixSymbol
X = MatrixSymbol('X', x, x)
Y = MatrixSymbol('Y', y, y)
assert _test_args(BlockDiagMatrix(X, Y))
def test_sympy__matrices__expressions__blockmatrix__BlockMatrix():
from sympy.matrices.expressions.blockmatrix import BlockMatrix
from sympy.matrices.expressions import MatrixSymbol, ZeroMatrix
X = MatrixSymbol('X', x, x)
Y = MatrixSymbol('Y', y, y)
Z = MatrixSymbol('Z', x, y)
O = ZeroMatrix(y, x)
assert _test_args(BlockMatrix([[X, Z], [O, Y]]))
def test_sympy__matrices__expressions__inverse__Inverse():
from sympy.matrices.expressions.inverse import Inverse
from sympy.matrices.expressions import MatrixSymbol
assert _test_args(Inverse(MatrixSymbol('A', 3, 3)))
def test_sympy__matrices__expressions__matadd__MatAdd():
from sympy.matrices.expressions.matadd import MatAdd
from sympy.matrices.expressions import MatrixSymbol
X = MatrixSymbol('X', x, y)
Y = MatrixSymbol('Y', x, y)
assert _test_args(MatAdd(X, Y))
def test_sympy__matrices__expressions__matexpr__Identity():
from sympy.matrices.expressions.matexpr import Identity
assert _test_args(Identity(3))
def test_sympy__matrices__expressions__matexpr__GenericIdentity():
from sympy.matrices.expressions.matexpr import GenericIdentity
assert _test_args(GenericIdentity())
@SKIP("abstract class")
def test_sympy__matrices__expressions__matexpr__MatrixExpr():
pass
def test_sympy__matrices__expressions__matexpr__MatrixElement():
from sympy.matrices.expressions.matexpr import MatrixSymbol, MatrixElement
from sympy import S
assert _test_args(MatrixElement(MatrixSymbol('A', 3, 5), S(2), S(3)))
def test_sympy__matrices__expressions__matexpr__MatrixSymbol():
from sympy.matrices.expressions.matexpr import MatrixSymbol
assert _test_args(MatrixSymbol('A', 3, 5))
def test_sympy__matrices__expressions__matexpr__ZeroMatrix():
from sympy.matrices.expressions.matexpr import ZeroMatrix
assert _test_args(ZeroMatrix(3, 5))
def test_sympy__matrices__expressions__matexpr__OneMatrix():
from sympy.matrices.expressions.matexpr import OneMatrix
assert _test_args(OneMatrix(3, 5))
def test_sympy__matrices__expressions__matexpr__GenericZeroMatrix():
from sympy.matrices.expressions.matexpr import GenericZeroMatrix
assert _test_args(GenericZeroMatrix())
def test_sympy__matrices__expressions__matmul__MatMul():
from sympy.matrices.expressions.matmul import MatMul
from sympy.matrices.expressions import MatrixSymbol
X = MatrixSymbol('X', x, y)
Y = MatrixSymbol('Y', y, x)
assert _test_args(MatMul(X, Y))
def test_sympy__matrices__expressions__dotproduct__DotProduct():
from sympy.matrices.expressions.dotproduct import DotProduct
from sympy.matrices.expressions import MatrixSymbol
X = MatrixSymbol('X', x, 1)
Y = MatrixSymbol('Y', x, 1)
assert _test_args(DotProduct(X, Y))
def test_sympy__matrices__expressions__diagonal__DiagonalMatrix():
from sympy.matrices.expressions.diagonal import DiagonalMatrix
from sympy.matrices.expressions import MatrixSymbol
x = MatrixSymbol('x', 10, 1)
assert _test_args(DiagonalMatrix(x))
def test_sympy__matrices__expressions__diagonal__DiagonalOf():
from sympy.matrices.expressions.diagonal import DiagonalOf
from sympy.matrices.expressions import MatrixSymbol
X = MatrixSymbol('x', 10, 10)
assert _test_args(DiagonalOf(X))
def test_sympy__matrices__expressions__diagonal__DiagMatrix():
from sympy.matrices.expressions.diagonal import DiagMatrix
from sympy.matrices.expressions import MatrixSymbol
x = MatrixSymbol('x', 10, 1)
assert _test_args(DiagMatrix(x))
def test_sympy__matrices__expressions__hadamard__HadamardProduct():
from sympy.matrices.expressions.hadamard import HadamardProduct
from sympy.matrices.expressions import MatrixSymbol
X = MatrixSymbol('X', x, y)
Y = MatrixSymbol('Y', x, y)
assert _test_args(HadamardProduct(X, Y))
def test_sympy__matrices__expressions__hadamard__HadamardPower():
from sympy.matrices.expressions.hadamard import HadamardPower
from sympy.matrices.expressions import MatrixSymbol
from sympy import Symbol
X = MatrixSymbol('X', x, y)
n = Symbol("n")
assert _test_args(HadamardPower(X, n))
def test_sympy__matrices__expressions__kronecker__KroneckerProduct():
from sympy.matrices.expressions.kronecker import KroneckerProduct
from sympy.matrices.expressions import MatrixSymbol
X = MatrixSymbol('X', x, y)
Y = MatrixSymbol('Y', x, y)
assert _test_args(KroneckerProduct(X, Y))
def test_sympy__matrices__expressions__matpow__MatPow():
from sympy.matrices.expressions.matpow import MatPow
from sympy.matrices.expressions import MatrixSymbol
X = MatrixSymbol('X', x, x)
assert _test_args(MatPow(X, 2))
def test_sympy__matrices__expressions__transpose__Transpose():
from sympy.matrices.expressions.transpose import Transpose
from sympy.matrices.expressions import MatrixSymbol
assert _test_args(Transpose(MatrixSymbol('A', 3, 5)))
def test_sympy__matrices__expressions__adjoint__Adjoint():
from sympy.matrices.expressions.adjoint import Adjoint
from sympy.matrices.expressions import MatrixSymbol
assert _test_args(Adjoint(MatrixSymbol('A', 3, 5)))
def test_sympy__matrices__expressions__trace__Trace():
from sympy.matrices.expressions.trace import Trace
from sympy.matrices.expressions import MatrixSymbol
assert _test_args(Trace(MatrixSymbol('A', 3, 3)))
def test_sympy__matrices__expressions__determinant__Determinant():
from sympy.matrices.expressions.determinant import Determinant
from sympy.matrices.expressions import MatrixSymbol
assert _test_args(Determinant(MatrixSymbol('A', 3, 3)))
def test_sympy__matrices__expressions__funcmatrix__FunctionMatrix():
from sympy.matrices.expressions.funcmatrix import FunctionMatrix
from sympy import symbols
i, j = symbols('i,j')
assert _test_args(FunctionMatrix(3, 3, Lambda((i, j), i - j) ))
def test_sympy__matrices__expressions__fourier__DFT():
from sympy.matrices.expressions.fourier import DFT
from sympy import S
assert _test_args(DFT(S(2)))
def test_sympy__matrices__expressions__fourier__IDFT():
from sympy.matrices.expressions.fourier import IDFT
from sympy import S
assert _test_args(IDFT(S(2)))
from sympy.matrices.expressions import MatrixSymbol
X = MatrixSymbol('X', 10, 10)
def test_sympy__matrices__expressions__factorizations__LofLU():
from sympy.matrices.expressions.factorizations import LofLU
assert _test_args(LofLU(X))
def test_sympy__matrices__expressions__factorizations__UofLU():
from sympy.matrices.expressions.factorizations import UofLU
assert _test_args(UofLU(X))
def test_sympy__matrices__expressions__factorizations__QofQR():
from sympy.matrices.expressions.factorizations import QofQR
assert _test_args(QofQR(X))
def test_sympy__matrices__expressions__factorizations__RofQR():
from sympy.matrices.expressions.factorizations import RofQR
assert _test_args(RofQR(X))
def test_sympy__matrices__expressions__factorizations__LofCholesky():
from sympy.matrices.expressions.factorizations import LofCholesky
assert _test_args(LofCholesky(X))
def test_sympy__matrices__expressions__factorizations__UofCholesky():
from sympy.matrices.expressions.factorizations import UofCholesky
assert _test_args(UofCholesky(X))
def test_sympy__matrices__expressions__factorizations__EigenVectors():
from sympy.matrices.expressions.factorizations import EigenVectors
assert _test_args(EigenVectors(X))
def test_sympy__matrices__expressions__factorizations__EigenValues():
from sympy.matrices.expressions.factorizations import EigenValues
assert _test_args(EigenValues(X))
def test_sympy__matrices__expressions__factorizations__UofSVD():
from sympy.matrices.expressions.factorizations import UofSVD
assert _test_args(UofSVD(X))
def test_sympy__matrices__expressions__factorizations__VofSVD():
from sympy.matrices.expressions.factorizations import VofSVD
assert _test_args(VofSVD(X))
def test_sympy__matrices__expressions__factorizations__SofSVD():
from sympy.matrices.expressions.factorizations import SofSVD
assert _test_args(SofSVD(X))
@SKIP("abstract class")
def test_sympy__matrices__expressions__factorizations__Factorization():
pass
def test_sympy__matrices__expressions__permutation__PermutationMatrix():
from sympy.combinatorics import Permutation
from sympy.matrices.expressions.permutation import PermutationMatrix
assert _test_args(PermutationMatrix(Permutation([2, 0, 1])))
def test_sympy__matrices__expressions__permutation__MatrixPermute():
from sympy.combinatorics import Permutation
from sympy.matrices.expressions.matexpr import MatrixSymbol
from sympy.matrices.expressions.permutation import MatrixPermute
A = MatrixSymbol('A', 3, 3)
assert _test_args(MatrixPermute(A, Permutation([2, 0, 1])))
def test_sympy__physics__vector__frame__CoordinateSym():
from sympy.physics.vector import CoordinateSym
from sympy.physics.vector import ReferenceFrame
assert _test_args(CoordinateSym('R_x', ReferenceFrame('R'), 0))
def test_sympy__physics__paulialgebra__Pauli():
from sympy.physics.paulialgebra import Pauli
assert _test_args(Pauli(1))
def test_sympy__physics__quantum__anticommutator__AntiCommutator():
from sympy.physics.quantum.anticommutator import AntiCommutator
assert _test_args(AntiCommutator(x, y))
def test_sympy__physics__quantum__cartesian__PositionBra3D():
from sympy.physics.quantum.cartesian import PositionBra3D
assert _test_args(PositionBra3D(x, y, z))
def test_sympy__physics__quantum__cartesian__PositionKet3D():
from sympy.physics.quantum.cartesian import PositionKet3D
assert _test_args(PositionKet3D(x, y, z))
def test_sympy__physics__quantum__cartesian__PositionState3D():
from sympy.physics.quantum.cartesian import PositionState3D
assert _test_args(PositionState3D(x, y, z))
def test_sympy__physics__quantum__cartesian__PxBra():
from sympy.physics.quantum.cartesian import PxBra
assert _test_args(PxBra(x, y, z))
def test_sympy__physics__quantum__cartesian__PxKet():
from sympy.physics.quantum.cartesian import PxKet
assert _test_args(PxKet(x, y, z))
def test_sympy__physics__quantum__cartesian__PxOp():
from sympy.physics.quantum.cartesian import PxOp
assert _test_args(PxOp(x, y, z))
def test_sympy__physics__quantum__cartesian__XBra():
from sympy.physics.quantum.cartesian import XBra
assert _test_args(XBra(x))
def test_sympy__physics__quantum__cartesian__XKet():
from sympy.physics.quantum.cartesian import XKet
assert _test_args(XKet(x))
def test_sympy__physics__quantum__cartesian__XOp():
from sympy.physics.quantum.cartesian import XOp
assert _test_args(XOp(x))
def test_sympy__physics__quantum__cartesian__YOp():
from sympy.physics.quantum.cartesian import YOp
assert _test_args(YOp(x))
def test_sympy__physics__quantum__cartesian__ZOp():
from sympy.physics.quantum.cartesian import ZOp
assert _test_args(ZOp(x))
def test_sympy__physics__quantum__cg__CG():
from sympy.physics.quantum.cg import CG
from sympy import S
assert _test_args(CG(Rational(3, 2), Rational(3, 2), S.Half, Rational(-1, 2), 1, 1))
def test_sympy__physics__quantum__cg__Wigner3j():
from sympy.physics.quantum.cg import Wigner3j
assert _test_args(Wigner3j(6, 0, 4, 0, 2, 0))
def test_sympy__physics__quantum__cg__Wigner6j():
from sympy.physics.quantum.cg import Wigner6j
assert _test_args(Wigner6j(1, 2, 3, 2, 1, 2))
def test_sympy__physics__quantum__cg__Wigner9j():
from sympy.physics.quantum.cg import Wigner9j
assert _test_args(Wigner9j(2, 1, 1, Rational(3, 2), S.Half, 1, S.Half, S.Half, 0))
def test_sympy__physics__quantum__circuitplot__Mz():
from sympy.physics.quantum.circuitplot import Mz
assert _test_args(Mz(0))
def test_sympy__physics__quantum__circuitplot__Mx():
from sympy.physics.quantum.circuitplot import Mx
assert _test_args(Mx(0))
def test_sympy__physics__quantum__commutator__Commutator():
from sympy.physics.quantum.commutator import Commutator
A, B = symbols('A,B', commutative=False)
assert _test_args(Commutator(A, B))
def test_sympy__physics__quantum__constants__HBar():
from sympy.physics.quantum.constants import HBar
assert _test_args(HBar())
def test_sympy__physics__quantum__dagger__Dagger():
from sympy.physics.quantum.dagger import Dagger
from sympy.physics.quantum.state import Ket
assert _test_args(Dagger(Dagger(Ket('psi'))))
def test_sympy__physics__quantum__gate__CGate():
from sympy.physics.quantum.gate import CGate, Gate
assert _test_args(CGate((0, 1), Gate(2)))
def test_sympy__physics__quantum__gate__CGateS():
from sympy.physics.quantum.gate import CGateS, Gate
assert _test_args(CGateS((0, 1), Gate(2)))
def test_sympy__physics__quantum__gate__CNotGate():
from sympy.physics.quantum.gate import CNotGate
assert _test_args(CNotGate(0, 1))
def test_sympy__physics__quantum__gate__Gate():
from sympy.physics.quantum.gate import Gate
assert _test_args(Gate(0))
def test_sympy__physics__quantum__gate__HadamardGate():
from sympy.physics.quantum.gate import HadamardGate
assert _test_args(HadamardGate(0))
def test_sympy__physics__quantum__gate__IdentityGate():
from sympy.physics.quantum.gate import IdentityGate
assert _test_args(IdentityGate(0))
def test_sympy__physics__quantum__gate__OneQubitGate():
from sympy.physics.quantum.gate import OneQubitGate
assert _test_args(OneQubitGate(0))
def test_sympy__physics__quantum__gate__PhaseGate():
from sympy.physics.quantum.gate import PhaseGate
assert _test_args(PhaseGate(0))
def test_sympy__physics__quantum__gate__SwapGate():
from sympy.physics.quantum.gate import SwapGate
assert _test_args(SwapGate(0, 1))
def test_sympy__physics__quantum__gate__TGate():
from sympy.physics.quantum.gate import TGate
assert _test_args(TGate(0))
def test_sympy__physics__quantum__gate__TwoQubitGate():
from sympy.physics.quantum.gate import TwoQubitGate
assert _test_args(TwoQubitGate(0))
def test_sympy__physics__quantum__gate__UGate():
from sympy.physics.quantum.gate import UGate
from sympy.matrices.immutable import ImmutableDenseMatrix
from sympy import Integer, Tuple
assert _test_args(
UGate(Tuple(Integer(1)), ImmutableDenseMatrix([[1, 0], [0, 2]])))
def test_sympy__physics__quantum__gate__XGate():
from sympy.physics.quantum.gate import XGate
assert _test_args(XGate(0))
def test_sympy__physics__quantum__gate__YGate():
from sympy.physics.quantum.gate import YGate
assert _test_args(YGate(0))
def test_sympy__physics__quantum__gate__ZGate():
from sympy.physics.quantum.gate import ZGate
assert _test_args(ZGate(0))
@SKIP("TODO: sympy.physics")
def test_sympy__physics__quantum__grover__OracleGate():
from sympy.physics.quantum.grover import OracleGate
assert _test_args(OracleGate())
def test_sympy__physics__quantum__grover__WGate():
from sympy.physics.quantum.grover import WGate
assert _test_args(WGate(1))
def test_sympy__physics__quantum__hilbert__ComplexSpace():
from sympy.physics.quantum.hilbert import ComplexSpace
assert _test_args(ComplexSpace(x))
def test_sympy__physics__quantum__hilbert__DirectSumHilbertSpace():
from sympy.physics.quantum.hilbert import DirectSumHilbertSpace, ComplexSpace, FockSpace
c = ComplexSpace(2)
f = FockSpace()
assert _test_args(DirectSumHilbertSpace(c, f))
def test_sympy__physics__quantum__hilbert__FockSpace():
from sympy.physics.quantum.hilbert import FockSpace
assert _test_args(FockSpace())
def test_sympy__physics__quantum__hilbert__HilbertSpace():
from sympy.physics.quantum.hilbert import HilbertSpace
assert _test_args(HilbertSpace())
def test_sympy__physics__quantum__hilbert__L2():
from sympy.physics.quantum.hilbert import L2
from sympy import oo, Interval
assert _test_args(L2(Interval(0, oo)))
def test_sympy__physics__quantum__hilbert__TensorPowerHilbertSpace():
from sympy.physics.quantum.hilbert import TensorPowerHilbertSpace, FockSpace
f = FockSpace()
assert _test_args(TensorPowerHilbertSpace(f, 2))
def test_sympy__physics__quantum__hilbert__TensorProductHilbertSpace():
from sympy.physics.quantum.hilbert import TensorProductHilbertSpace, FockSpace, ComplexSpace
c = ComplexSpace(2)
f = FockSpace()
assert _test_args(TensorProductHilbertSpace(f, c))
def test_sympy__physics__quantum__innerproduct__InnerProduct():
from sympy.physics.quantum import Bra, Ket, InnerProduct
b = Bra('b')
k = Ket('k')
assert _test_args(InnerProduct(b, k))
def test_sympy__physics__quantum__operator__DifferentialOperator():
from sympy.physics.quantum.operator import DifferentialOperator
from sympy import Derivative, Function
f = Function('f')
assert _test_args(DifferentialOperator(1/x*Derivative(f(x), x), f(x)))
def test_sympy__physics__quantum__operator__HermitianOperator():
from sympy.physics.quantum.operator import HermitianOperator
assert _test_args(HermitianOperator('H'))
def test_sympy__physics__quantum__operator__IdentityOperator():
from sympy.physics.quantum.operator import IdentityOperator
assert _test_args(IdentityOperator(5))
def test_sympy__physics__quantum__operator__Operator():
from sympy.physics.quantum.operator import Operator
assert _test_args(Operator('A'))
def test_sympy__physics__quantum__operator__OuterProduct():
from sympy.physics.quantum.operator import OuterProduct
from sympy.physics.quantum import Ket, Bra
b = Bra('b')
k = Ket('k')
assert _test_args(OuterProduct(k, b))
def test_sympy__physics__quantum__operator__UnitaryOperator():
from sympy.physics.quantum.operator import UnitaryOperator
assert _test_args(UnitaryOperator('U'))
def test_sympy__physics__quantum__piab__PIABBra():
from sympy.physics.quantum.piab import PIABBra
assert _test_args(PIABBra('B'))
def test_sympy__physics__quantum__boson__BosonOp():
from sympy.physics.quantum.boson import BosonOp
assert _test_args(BosonOp('a'))
assert _test_args(BosonOp('a', False))
def test_sympy__physics__quantum__boson__BosonFockKet():
from sympy.physics.quantum.boson import BosonFockKet
assert _test_args(BosonFockKet(1))
def test_sympy__physics__quantum__boson__BosonFockBra():
from sympy.physics.quantum.boson import BosonFockBra
assert _test_args(BosonFockBra(1))
def test_sympy__physics__quantum__boson__BosonCoherentKet():
from sympy.physics.quantum.boson import BosonCoherentKet
assert _test_args(BosonCoherentKet(1))
def test_sympy__physics__quantum__boson__BosonCoherentBra():
from sympy.physics.quantum.boson import BosonCoherentBra
assert _test_args(BosonCoherentBra(1))
def test_sympy__physics__quantum__fermion__FermionOp():
from sympy.physics.quantum.fermion import FermionOp
assert _test_args(FermionOp('c'))
assert _test_args(FermionOp('c', False))
def test_sympy__physics__quantum__fermion__FermionFockKet():
from sympy.physics.quantum.fermion import FermionFockKet
assert _test_args(FermionFockKet(1))
def test_sympy__physics__quantum__fermion__FermionFockBra():
from sympy.physics.quantum.fermion import FermionFockBra
assert _test_args(FermionFockBra(1))
def test_sympy__physics__quantum__pauli__SigmaOpBase():
from sympy.physics.quantum.pauli import SigmaOpBase
assert _test_args(SigmaOpBase())
def test_sympy__physics__quantum__pauli__SigmaX():
from sympy.physics.quantum.pauli import SigmaX
assert _test_args(SigmaX())
def test_sympy__physics__quantum__pauli__SigmaY():
from sympy.physics.quantum.pauli import SigmaY
assert _test_args(SigmaY())
def test_sympy__physics__quantum__pauli__SigmaZ():
from sympy.physics.quantum.pauli import SigmaZ
assert _test_args(SigmaZ())
def test_sympy__physics__quantum__pauli__SigmaMinus():
from sympy.physics.quantum.pauli import SigmaMinus
assert _test_args(SigmaMinus())
def test_sympy__physics__quantum__pauli__SigmaPlus():
from sympy.physics.quantum.pauli import SigmaPlus
assert _test_args(SigmaPlus())
def test_sympy__physics__quantum__pauli__SigmaZKet():
from sympy.physics.quantum.pauli import SigmaZKet
assert _test_args(SigmaZKet(0))
def test_sympy__physics__quantum__pauli__SigmaZBra():
from sympy.physics.quantum.pauli import SigmaZBra
assert _test_args(SigmaZBra(0))
def test_sympy__physics__quantum__piab__PIABHamiltonian():
from sympy.physics.quantum.piab import PIABHamiltonian
assert _test_args(PIABHamiltonian('P'))
def test_sympy__physics__quantum__piab__PIABKet():
from sympy.physics.quantum.piab import PIABKet
assert _test_args(PIABKet('K'))
def test_sympy__physics__quantum__qexpr__QExpr():
from sympy.physics.quantum.qexpr import QExpr
assert _test_args(QExpr(0))
def test_sympy__physics__quantum__qft__Fourier():
from sympy.physics.quantum.qft import Fourier
assert _test_args(Fourier(0, 1))
def test_sympy__physics__quantum__qft__IQFT():
from sympy.physics.quantum.qft import IQFT
assert _test_args(IQFT(0, 1))
def test_sympy__physics__quantum__qft__QFT():
from sympy.physics.quantum.qft import QFT
assert _test_args(QFT(0, 1))
def test_sympy__physics__quantum__qft__RkGate():
from sympy.physics.quantum.qft import RkGate
assert _test_args(RkGate(0, 1))
def test_sympy__physics__quantum__qubit__IntQubit():
from sympy.physics.quantum.qubit import IntQubit
assert _test_args(IntQubit(0))
def test_sympy__physics__quantum__qubit__IntQubitBra():
from sympy.physics.quantum.qubit import IntQubitBra
assert _test_args(IntQubitBra(0))
def test_sympy__physics__quantum__qubit__IntQubitState():
from sympy.physics.quantum.qubit import IntQubitState, QubitState
assert _test_args(IntQubitState(QubitState(0, 1)))
def test_sympy__physics__quantum__qubit__Qubit():
from sympy.physics.quantum.qubit import Qubit
assert _test_args(Qubit(0, 0, 0))
def test_sympy__physics__quantum__qubit__QubitBra():
from sympy.physics.quantum.qubit import QubitBra
assert _test_args(QubitBra('1', 0))
def test_sympy__physics__quantum__qubit__QubitState():
from sympy.physics.quantum.qubit import QubitState
assert _test_args(QubitState(0, 1))
def test_sympy__physics__quantum__density__Density():
from sympy.physics.quantum.density import Density
from sympy.physics.quantum.state import Ket
assert _test_args(Density([Ket(0), 0.5], [Ket(1), 0.5]))
@SKIP("TODO: sympy.physics.quantum.shor: Cmod Not Implemented")
def test_sympy__physics__quantum__shor__CMod():
from sympy.physics.quantum.shor import CMod
assert _test_args(CMod())
def test_sympy__physics__quantum__spin__CoupledSpinState():
from sympy.physics.quantum.spin import CoupledSpinState
assert _test_args(CoupledSpinState(1, 0, (1, 1)))
assert _test_args(CoupledSpinState(1, 0, (1, S.Half, S.Half)))
assert _test_args(CoupledSpinState(
1, 0, (1, S.Half, S.Half), ((2, 3, S.Half), (1, 2, 1)) ))
j, m, j1, j2, j3, j12, x = symbols('j m j1:4 j12 x')
assert CoupledSpinState(
j, m, (j1, j2, j3)).subs(j2, x) == CoupledSpinState(j, m, (j1, x, j3))
assert CoupledSpinState(j, m, (j1, j2, j3), ((1, 3, j12), (1, 2, j)) ).subs(j12, x) == \
CoupledSpinState(j, m, (j1, j2, j3), ((1, 3, x), (1, 2, j)) )
def test_sympy__physics__quantum__spin__J2Op():
from sympy.physics.quantum.spin import J2Op
assert _test_args(J2Op('J'))
def test_sympy__physics__quantum__spin__JminusOp():
from sympy.physics.quantum.spin import JminusOp
assert _test_args(JminusOp('J'))
def test_sympy__physics__quantum__spin__JplusOp():
from sympy.physics.quantum.spin import JplusOp
assert _test_args(JplusOp('J'))
def test_sympy__physics__quantum__spin__JxBra():
from sympy.physics.quantum.spin import JxBra
assert _test_args(JxBra(1, 0))
def test_sympy__physics__quantum__spin__JxBraCoupled():
from sympy.physics.quantum.spin import JxBraCoupled
assert _test_args(JxBraCoupled(1, 0, (1, 1)))
def test_sympy__physics__quantum__spin__JxKet():
from sympy.physics.quantum.spin import JxKet
assert _test_args(JxKet(1, 0))
def test_sympy__physics__quantum__spin__JxKetCoupled():
from sympy.physics.quantum.spin import JxKetCoupled
assert _test_args(JxKetCoupled(1, 0, (1, 1)))
def test_sympy__physics__quantum__spin__JxOp():
from sympy.physics.quantum.spin import JxOp
assert _test_args(JxOp('J'))
def test_sympy__physics__quantum__spin__JyBra():
from sympy.physics.quantum.spin import JyBra
assert _test_args(JyBra(1, 0))
def test_sympy__physics__quantum__spin__JyBraCoupled():
from sympy.physics.quantum.spin import JyBraCoupled
assert _test_args(JyBraCoupled(1, 0, (1, 1)))
def test_sympy__physics__quantum__spin__JyKet():
from sympy.physics.quantum.spin import JyKet
assert _test_args(JyKet(1, 0))
def test_sympy__physics__quantum__spin__JyKetCoupled():
from sympy.physics.quantum.spin import JyKetCoupled
assert _test_args(JyKetCoupled(1, 0, (1, 1)))
def test_sympy__physics__quantum__spin__JyOp():
from sympy.physics.quantum.spin import JyOp
assert _test_args(JyOp('J'))
def test_sympy__physics__quantum__spin__JzBra():
from sympy.physics.quantum.spin import JzBra
assert _test_args(JzBra(1, 0))
def test_sympy__physics__quantum__spin__JzBraCoupled():
from sympy.physics.quantum.spin import JzBraCoupled
assert _test_args(JzBraCoupled(1, 0, (1, 1)))
def test_sympy__physics__quantum__spin__JzKet():
from sympy.physics.quantum.spin import JzKet
assert _test_args(JzKet(1, 0))
def test_sympy__physics__quantum__spin__JzKetCoupled():
from sympy.physics.quantum.spin import JzKetCoupled
assert _test_args(JzKetCoupled(1, 0, (1, 1)))
def test_sympy__physics__quantum__spin__JzOp():
from sympy.physics.quantum.spin import JzOp
assert _test_args(JzOp('J'))
def test_sympy__physics__quantum__spin__Rotation():
from sympy.physics.quantum.spin import Rotation
assert _test_args(Rotation(pi, 0, pi/2))
def test_sympy__physics__quantum__spin__SpinState():
from sympy.physics.quantum.spin import SpinState
assert _test_args(SpinState(1, 0))
def test_sympy__physics__quantum__spin__WignerD():
from sympy.physics.quantum.spin import WignerD
assert _test_args(WignerD(0, 1, 2, 3, 4, 5))
def test_sympy__physics__quantum__state__Bra():
from sympy.physics.quantum.state import Bra
assert _test_args(Bra(0))
def test_sympy__physics__quantum__state__BraBase():
from sympy.physics.quantum.state import BraBase
assert _test_args(BraBase(0))
def test_sympy__physics__quantum__state__Ket():
from sympy.physics.quantum.state import Ket
assert _test_args(Ket(0))
def test_sympy__physics__quantum__state__KetBase():
from sympy.physics.quantum.state import KetBase
assert _test_args(KetBase(0))
def test_sympy__physics__quantum__state__State():
from sympy.physics.quantum.state import State
assert _test_args(State(0))
def test_sympy__physics__quantum__state__StateBase():
from sympy.physics.quantum.state import StateBase
assert _test_args(StateBase(0))
def test_sympy__physics__quantum__state__OrthogonalBra():
from sympy.physics.quantum.state import OrthogonalBra
assert _test_args(OrthogonalBra(0))
def test_sympy__physics__quantum__state__OrthogonalKet():
from sympy.physics.quantum.state import OrthogonalKet
assert _test_args(OrthogonalKet(0))
def test_sympy__physics__quantum__state__OrthogonalState():
from sympy.physics.quantum.state import OrthogonalState
assert _test_args(OrthogonalState(0))
def test_sympy__physics__quantum__state__TimeDepBra():
from sympy.physics.quantum.state import TimeDepBra
assert _test_args(TimeDepBra('psi', 't'))
def test_sympy__physics__quantum__state__TimeDepKet():
from sympy.physics.quantum.state import TimeDepKet
assert _test_args(TimeDepKet('psi', 't'))
def test_sympy__physics__quantum__state__TimeDepState():
from sympy.physics.quantum.state import TimeDepState
assert _test_args(TimeDepState('psi', 't'))
def test_sympy__physics__quantum__state__Wavefunction():
from sympy.physics.quantum.state import Wavefunction
from sympy.functions import sin
from sympy import Piecewise
n = 1
L = 1
g = Piecewise((0, x < 0), (0, x > L), (sqrt(2//L)*sin(n*pi*x/L), True))
assert _test_args(Wavefunction(g, x))
def test_sympy__physics__quantum__tensorproduct__TensorProduct():
from sympy.physics.quantum.tensorproduct import TensorProduct
assert _test_args(TensorProduct(x, y))
def test_sympy__physics__quantum__identitysearch__GateIdentity():
from sympy.physics.quantum.gate import X
from sympy.physics.quantum.identitysearch import GateIdentity
assert _test_args(GateIdentity(X(0), X(0)))
def test_sympy__physics__quantum__sho1d__SHOOp():
from sympy.physics.quantum.sho1d import SHOOp
assert _test_args(SHOOp('a'))
def test_sympy__physics__quantum__sho1d__RaisingOp():
from sympy.physics.quantum.sho1d import RaisingOp
assert _test_args(RaisingOp('a'))
def test_sympy__physics__quantum__sho1d__LoweringOp():
from sympy.physics.quantum.sho1d import LoweringOp
assert _test_args(LoweringOp('a'))
def test_sympy__physics__quantum__sho1d__NumberOp():
from sympy.physics.quantum.sho1d import NumberOp
assert _test_args(NumberOp('N'))
def test_sympy__physics__quantum__sho1d__Hamiltonian():
from sympy.physics.quantum.sho1d import Hamiltonian
assert _test_args(Hamiltonian('H'))
def test_sympy__physics__quantum__sho1d__SHOState():
from sympy.physics.quantum.sho1d import SHOState
assert _test_args(SHOState(0))
def test_sympy__physics__quantum__sho1d__SHOKet():
from sympy.physics.quantum.sho1d import SHOKet
assert _test_args(SHOKet(0))
def test_sympy__physics__quantum__sho1d__SHOBra():
from sympy.physics.quantum.sho1d import SHOBra
assert _test_args(SHOBra(0))
def test_sympy__physics__secondquant__AnnihilateBoson():
from sympy.physics.secondquant import AnnihilateBoson
assert _test_args(AnnihilateBoson(0))
def test_sympy__physics__secondquant__AnnihilateFermion():
from sympy.physics.secondquant import AnnihilateFermion
assert _test_args(AnnihilateFermion(0))
@SKIP("abstract class")
def test_sympy__physics__secondquant__Annihilator():
pass
def test_sympy__physics__secondquant__AntiSymmetricTensor():
from sympy.physics.secondquant import AntiSymmetricTensor
i, j = symbols('i j', below_fermi=True)
a, b = symbols('a b', above_fermi=True)
assert _test_args(AntiSymmetricTensor('v', (a, i), (b, j)))
def test_sympy__physics__secondquant__BosonState():
from sympy.physics.secondquant import BosonState
assert _test_args(BosonState((0, 1)))
@SKIP("abstract class")
def test_sympy__physics__secondquant__BosonicOperator():
pass
def test_sympy__physics__secondquant__Commutator():
from sympy.physics.secondquant import Commutator
assert _test_args(Commutator(x, y))
def test_sympy__physics__secondquant__CreateBoson():
from sympy.physics.secondquant import CreateBoson
assert _test_args(CreateBoson(0))
def test_sympy__physics__secondquant__CreateFermion():
from sympy.physics.secondquant import CreateFermion
assert _test_args(CreateFermion(0))
@SKIP("abstract class")
def test_sympy__physics__secondquant__Creator():
pass
def test_sympy__physics__secondquant__Dagger():
from sympy.physics.secondquant import Dagger
from sympy import I
assert _test_args(Dagger(2*I))
def test_sympy__physics__secondquant__FermionState():
from sympy.physics.secondquant import FermionState
assert _test_args(FermionState((0, 1)))
def test_sympy__physics__secondquant__FermionicOperator():
from sympy.physics.secondquant import FermionicOperator
assert _test_args(FermionicOperator(0))
def test_sympy__physics__secondquant__FockState():
from sympy.physics.secondquant import FockState
assert _test_args(FockState((0, 1)))
def test_sympy__physics__secondquant__FockStateBosonBra():
from sympy.physics.secondquant import FockStateBosonBra
assert _test_args(FockStateBosonBra((0, 1)))
def test_sympy__physics__secondquant__FockStateBosonKet():
from sympy.physics.secondquant import FockStateBosonKet
assert _test_args(FockStateBosonKet((0, 1)))
def test_sympy__physics__secondquant__FockStateBra():
from sympy.physics.secondquant import FockStateBra
assert _test_args(FockStateBra((0, 1)))
def test_sympy__physics__secondquant__FockStateFermionBra():
from sympy.physics.secondquant import FockStateFermionBra
assert _test_args(FockStateFermionBra((0, 1)))
def test_sympy__physics__secondquant__FockStateFermionKet():
from sympy.physics.secondquant import FockStateFermionKet
assert _test_args(FockStateFermionKet((0, 1)))
def test_sympy__physics__secondquant__FockStateKet():
from sympy.physics.secondquant import FockStateKet
assert _test_args(FockStateKet((0, 1)))
def test_sympy__physics__secondquant__InnerProduct():
from sympy.physics.secondquant import InnerProduct
from sympy.physics.secondquant import FockStateKet, FockStateBra
assert _test_args(InnerProduct(FockStateBra((0, 1)), FockStateKet((0, 1))))
def test_sympy__physics__secondquant__NO():
from sympy.physics.secondquant import NO, F, Fd
assert _test_args(NO(Fd(x)*F(y)))
def test_sympy__physics__secondquant__PermutationOperator():
from sympy.physics.secondquant import PermutationOperator
assert _test_args(PermutationOperator(0, 1))
def test_sympy__physics__secondquant__SqOperator():
from sympy.physics.secondquant import SqOperator
assert _test_args(SqOperator(0))
def test_sympy__physics__secondquant__TensorSymbol():
from sympy.physics.secondquant import TensorSymbol
assert _test_args(TensorSymbol(x))
def test_sympy__physics__units__dimensions__Dimension():
from sympy.physics.units.dimensions import Dimension
assert _test_args(Dimension("length", "L"))
def test_sympy__physics__units__dimensions__DimensionSystem():
from sympy.physics.units.dimensions import DimensionSystem
from sympy.physics.units.definitions.dimension_definitions import length, time, velocity
assert _test_args(DimensionSystem((length, time), (velocity,)))
def test_sympy__physics__units__quantities__Quantity():
from sympy.physics.units.quantities import Quantity
assert _test_args(Quantity("dam"))
def test_sympy__physics__units__prefixes__Prefix():
from sympy.physics.units.prefixes import Prefix
assert _test_args(Prefix('kilo', 'k', 3))
def test_sympy__core__numbers__AlgebraicNumber():
from sympy.core.numbers import AlgebraicNumber
assert _test_args(AlgebraicNumber(sqrt(2), [1, 2, 3]))
def test_sympy__polys__polytools__GroebnerBasis():
from sympy.polys.polytools import GroebnerBasis
assert _test_args(GroebnerBasis([x, y, z], x, y, z))
def test_sympy__polys__polytools__Poly():
from sympy.polys.polytools import Poly
assert _test_args(Poly(2, x, y))
def test_sympy__polys__polytools__PurePoly():
from sympy.polys.polytools import PurePoly
assert _test_args(PurePoly(2, x, y))
@SKIP('abstract class')
def test_sympy__polys__rootoftools__RootOf():
pass
def test_sympy__polys__rootoftools__ComplexRootOf():
from sympy.polys.rootoftools import ComplexRootOf
assert _test_args(ComplexRootOf(x**3 + x + 1, 0))
def test_sympy__polys__rootoftools__RootSum():
from sympy.polys.rootoftools import RootSum
assert _test_args(RootSum(x**3 + x + 1, sin))
def test_sympy__series__limits__Limit():
from sympy.series.limits import Limit
assert _test_args(Limit(x, x, 0, dir='-'))
def test_sympy__series__order__Order():
from sympy.series.order import Order
assert _test_args(Order(1, x, y))
@SKIP('Abstract Class')
def test_sympy__series__sequences__SeqBase():
pass
def test_sympy__series__sequences__EmptySequence():
# Need to imort the instance from series not the class from
# series.sequence
from sympy.series import EmptySequence
assert _test_args(EmptySequence)
@SKIP('Abstract Class')
def test_sympy__series__sequences__SeqExpr():
pass
def test_sympy__series__sequences__SeqPer():
from sympy.series.sequences import SeqPer
assert _test_args(SeqPer((1, 2, 3), (0, 10)))
def test_sympy__series__sequences__SeqFormula():
from sympy.series.sequences import SeqFormula
assert _test_args(SeqFormula(x**2, (0, 10)))
def test_sympy__series__sequences__RecursiveSeq():
from sympy.series.sequences import RecursiveSeq
y = Function("y")
n = symbols("n")
assert _test_args(RecursiveSeq(y(n - 1) + y(n - 2), y(n), n, (0, 1)))
assert _test_args(RecursiveSeq(y(n - 1) + y(n - 2), y(n), n))
def test_sympy__series__sequences__SeqExprOp():
from sympy.series.sequences import SeqExprOp, sequence
s1 = sequence((1, 2, 3))
s2 = sequence(x**2)
assert _test_args(SeqExprOp(s1, s2))
def test_sympy__series__sequences__SeqAdd():
from sympy.series.sequences import SeqAdd, sequence
s1 = sequence((1, 2, 3))
s2 = sequence(x**2)
assert _test_args(SeqAdd(s1, s2))
def test_sympy__series__sequences__SeqMul():
from sympy.series.sequences import SeqMul, sequence
s1 = sequence((1, 2, 3))
s2 = sequence(x**2)
assert _test_args(SeqMul(s1, s2))
@SKIP('Abstract Class')
def test_sympy__series__series_class__SeriesBase():
pass
def test_sympy__series__fourier__FourierSeries():
from sympy.series.fourier import fourier_series
assert _test_args(fourier_series(x, (x, -pi, pi)))
def test_sympy__series__fourier__FiniteFourierSeries():
from sympy.series.fourier import fourier_series
assert _test_args(fourier_series(sin(pi*x), (x, -1, 1)))
def test_sympy__series__formal__FormalPowerSeries():
from sympy.series.formal import fps
assert _test_args(fps(log(1 + x), x))
def test_sympy__series__formal__Coeff():
from sympy.series.formal import fps
assert _test_args(fps(x**2 + x + 1, x))
@SKIP('Abstract Class')
def test_sympy__series__formal__FiniteFormalPowerSeries():
pass
def test_sympy__series__formal__FormalPowerSeriesProduct():
from sympy.series.formal import fps
f1, f2 = fps(sin(x)), fps(exp(x))
assert _test_args(f1.product(f2, x))
def test_sympy__series__formal__FormalPowerSeriesCompose():
from sympy.series.formal import fps
f1, f2 = fps(exp(x)), fps(sin(x))
assert _test_args(f1.compose(f2, x))
def test_sympy__series__formal__FormalPowerSeriesInverse():
from sympy.series.formal import fps
f1 = fps(exp(x))
assert _test_args(f1.inverse(x))
def test_sympy__simplify__hyperexpand__Hyper_Function():
from sympy.simplify.hyperexpand import Hyper_Function
assert _test_args(Hyper_Function([2], [1]))
def test_sympy__simplify__hyperexpand__G_Function():
from sympy.simplify.hyperexpand import G_Function
assert _test_args(G_Function([2], [1], [], []))
@SKIP("abstract class")
def test_sympy__tensor__array__ndim_array__ImmutableNDimArray():
pass
def test_sympy__tensor__array__dense_ndim_array__ImmutableDenseNDimArray():
from sympy.tensor.array.dense_ndim_array import ImmutableDenseNDimArray
densarr = ImmutableDenseNDimArray(range(10, 34), (2, 3, 4))
assert _test_args(densarr)
def test_sympy__tensor__array__sparse_ndim_array__ImmutableSparseNDimArray():
from sympy.tensor.array.sparse_ndim_array import ImmutableSparseNDimArray
sparr = ImmutableSparseNDimArray(range(10, 34), (2, 3, 4))
assert _test_args(sparr)
def test_sympy__tensor__array__array_comprehension__ArrayComprehension():
from sympy.tensor.array.array_comprehension import ArrayComprehension
arrcom = ArrayComprehension(x, (x, 1, 5))
assert _test_args(arrcom)
def test_sympy__tensor__array__array_comprehension__ArrayComprehensionMap():
from sympy.tensor.array.array_comprehension import ArrayComprehensionMap
arrcomma = ArrayComprehensionMap(lambda: 0, (x, 1, 5))
assert _test_args(arrcomma)
def test_sympy__tensor__array__arrayop__Flatten():
from sympy.tensor.array.arrayop import Flatten
from sympy.tensor.array.dense_ndim_array import ImmutableDenseNDimArray
fla = Flatten(ImmutableDenseNDimArray(range(24)).reshape(2, 3, 4))
assert _test_args(fla)
def test_sympy__tensor__functions__TensorProduct():
from sympy.tensor.functions import TensorProduct
A = MatrixSymbol('A', 3, 3)
B = MatrixSymbol('B', 3, 3)
tp = TensorProduct(A, B)
assert _test_args(tp)
def test_sympy__tensor__indexed__Idx():
from sympy.tensor.indexed import Idx
assert _test_args(Idx('test'))
assert _test_args(Idx(1, (0, 10)))
def test_sympy__tensor__indexed__Indexed():
from sympy.tensor.indexed import Indexed, Idx
assert _test_args(Indexed('A', Idx('i'), Idx('j')))
def test_sympy__tensor__indexed__IndexedBase():
from sympy.tensor.indexed import IndexedBase
assert _test_args(IndexedBase('A', shape=(x, y)))
assert _test_args(IndexedBase('A', 1))
assert _test_args(IndexedBase('A')[0, 1])
def test_sympy__tensor__tensor__TensorIndexType():
from sympy.tensor.tensor import TensorIndexType
assert _test_args(TensorIndexType('Lorentz'))
@SKIP("deprecated class")
def test_sympy__tensor__tensor__TensorType():
pass
def test_sympy__tensor__tensor__TensorSymmetry():
from sympy.tensor.tensor import TensorSymmetry, get_symmetric_group_sgs
assert _test_args(TensorSymmetry(get_symmetric_group_sgs(2)))
def test_sympy__tensor__tensor__TensorHead():
from sympy.tensor.tensor import TensorIndexType, TensorSymmetry, get_symmetric_group_sgs, TensorHead
Lorentz = TensorIndexType('Lorentz', dummy_name='L')
sym = TensorSymmetry(get_symmetric_group_sgs(1))
assert _test_args(TensorHead('p', [Lorentz], sym, 0))
def test_sympy__tensor__tensor__TensorIndex():
from sympy.tensor.tensor import TensorIndexType, TensorIndex
Lorentz = TensorIndexType('Lorentz', dummy_name='L')
assert _test_args(TensorIndex('i', Lorentz))
@SKIP("abstract class")
def test_sympy__tensor__tensor__TensExpr():
pass
def test_sympy__tensor__tensor__TensAdd():
from sympy.tensor.tensor import TensorIndexType, TensorSymmetry, get_symmetric_group_sgs, tensor_indices, TensAdd, tensor_heads
Lorentz = TensorIndexType('Lorentz', dummy_name='L')
a, b = tensor_indices('a,b', Lorentz)
sym = TensorSymmetry(get_symmetric_group_sgs(1))
p, q = tensor_heads('p,q', [Lorentz], sym)
t1 = p(a)
t2 = q(a)
assert _test_args(TensAdd(t1, t2))
def test_sympy__tensor__tensor__Tensor():
from sympy.tensor.tensor import TensorIndexType, TensorSymmetry, get_symmetric_group_sgs, tensor_indices, TensorHead
Lorentz = TensorIndexType('Lorentz', dummy_name='L')
a, b = tensor_indices('a,b', Lorentz)
sym = TensorSymmetry(get_symmetric_group_sgs(1))
p = TensorHead('p', [Lorentz], sym)
assert _test_args(p(a))
def test_sympy__tensor__tensor__TensMul():
from sympy.tensor.tensor import TensorIndexType, TensorSymmetry, get_symmetric_group_sgs, tensor_indices, tensor_heads
Lorentz = TensorIndexType('Lorentz', dummy_name='L')
a, b = tensor_indices('a,b', Lorentz)
sym = TensorSymmetry(get_symmetric_group_sgs(1))
p, q = tensor_heads('p, q', [Lorentz], sym)
assert _test_args(3*p(a)*q(b))
def test_sympy__tensor__tensor__TensorElement():
from sympy.tensor.tensor import TensorIndexType, TensorHead, TensorElement
L = TensorIndexType("L")
A = TensorHead("A", [L, L])
telem = TensorElement(A(x, y), {x: 1})
assert _test_args(telem)
def test_sympy__tensor__toperators__PartialDerivative():
from sympy.tensor.tensor import TensorIndexType, tensor_indices, TensorHead
from sympy.tensor.toperators import PartialDerivative
Lorentz = TensorIndexType('Lorentz', dummy_name='L')
a, b = tensor_indices('a,b', Lorentz)
A = TensorHead("A", [Lorentz])
assert _test_args(PartialDerivative(A(a), A(b)))
def test_as_coeff_add():
assert (7, (3*x, 4*x**2)) == (7 + 3*x + 4*x**2).as_coeff_add()
def test_sympy__geometry__curve__Curve():
from sympy.geometry.curve import Curve
assert _test_args(Curve((x, 1), (x, 0, 1)))
def test_sympy__geometry__point__Point():
from sympy.geometry.point import Point
assert _test_args(Point(0, 1))
def test_sympy__geometry__point__Point2D():
from sympy.geometry.point import Point2D
assert _test_args(Point2D(0, 1))
def test_sympy__geometry__point__Point3D():
from sympy.geometry.point import Point3D
assert _test_args(Point3D(0, 1, 2))
def test_sympy__geometry__ellipse__Ellipse():
from sympy.geometry.ellipse import Ellipse
assert _test_args(Ellipse((0, 1), 2, 3))
def test_sympy__geometry__ellipse__Circle():
from sympy.geometry.ellipse import Circle
assert _test_args(Circle((0, 1), 2))
def test_sympy__geometry__parabola__Parabola():
from sympy.geometry.parabola import Parabola
from sympy.geometry.line import Line
assert _test_args(Parabola((0, 0), Line((2, 3), (4, 3))))
@SKIP("abstract class")
def test_sympy__geometry__line__LinearEntity():
pass
def test_sympy__geometry__line__Line():
from sympy.geometry.line import Line
assert _test_args(Line((0, 1), (2, 3)))
def test_sympy__geometry__line__Ray():
from sympy.geometry.line import Ray
assert _test_args(Ray((0, 1), (2, 3)))
def test_sympy__geometry__line__Segment():
from sympy.geometry.line import Segment
assert _test_args(Segment((0, 1), (2, 3)))
@SKIP("abstract class")
def test_sympy__geometry__line__LinearEntity2D():
pass
def test_sympy__geometry__line__Line2D():
from sympy.geometry.line import Line2D
assert _test_args(Line2D((0, 1), (2, 3)))
def test_sympy__geometry__line__Ray2D():
from sympy.geometry.line import Ray2D
assert _test_args(Ray2D((0, 1), (2, 3)))
def test_sympy__geometry__line__Segment2D():
from sympy.geometry.line import Segment2D
assert _test_args(Segment2D((0, 1), (2, 3)))
@SKIP("abstract class")
def test_sympy__geometry__line__LinearEntity3D():
pass
def test_sympy__geometry__line__Line3D():
from sympy.geometry.line import Line3D
assert _test_args(Line3D((0, 1, 1), (2, 3, 4)))
def test_sympy__geometry__line__Segment3D():
from sympy.geometry.line import Segment3D
assert _test_args(Segment3D((0, 1, 1), (2, 3, 4)))
def test_sympy__geometry__line__Ray3D():
from sympy.geometry.line import Ray3D
assert _test_args(Ray3D((0, 1, 1), (2, 3, 4)))
def test_sympy__geometry__plane__Plane():
from sympy.geometry.plane import Plane
assert _test_args(Plane((1, 1, 1), (-3, 4, -2), (1, 2, 3)))
def test_sympy__geometry__polygon__Polygon():
from sympy.geometry.polygon import Polygon
assert _test_args(Polygon((0, 1), (2, 3), (4, 5), (6, 7)))
def test_sympy__geometry__polygon__RegularPolygon():
from sympy.geometry.polygon import RegularPolygon
assert _test_args(RegularPolygon((0, 1), 2, 3, 4))
def test_sympy__geometry__polygon__Triangle():
from sympy.geometry.polygon import Triangle
assert _test_args(Triangle((0, 1), (2, 3), (4, 5)))
def test_sympy__geometry__entity__GeometryEntity():
from sympy.geometry.entity import GeometryEntity
from sympy.geometry.point import Point
assert _test_args(GeometryEntity(Point(1, 0), 1, [1, 2]))
@SKIP("abstract class")
def test_sympy__geometry__entity__GeometrySet():
pass
def test_sympy__diffgeom__diffgeom__Manifold():
from sympy.diffgeom import Manifold
assert _test_args(Manifold('name', 3))
def test_sympy__diffgeom__diffgeom__Patch():
from sympy.diffgeom import Manifold, Patch
assert _test_args(Patch('name', Manifold('name', 3)))
def test_sympy__diffgeom__diffgeom__CoordSystem():
from sympy.diffgeom import Manifold, Patch, CoordSystem
assert _test_args(CoordSystem('name', Patch('name', Manifold('name', 3))))
@XFAIL
def test_sympy__diffgeom__diffgeom__Point():
from sympy.diffgeom import Manifold, Patch, CoordSystem, Point
assert _test_args(Point(
CoordSystem('name', Patch('name', Manifold('name', 3))), [x, y]))
def test_sympy__diffgeom__diffgeom__BaseScalarField():
from sympy.diffgeom import Manifold, Patch, CoordSystem, BaseScalarField
cs = CoordSystem('name', Patch('name', Manifold('name', 3)))
assert _test_args(BaseScalarField(cs, 0))
def test_sympy__diffgeom__diffgeom__BaseVectorField():
from sympy.diffgeom import Manifold, Patch, CoordSystem, BaseVectorField
cs = CoordSystem('name', Patch('name', Manifold('name', 3)))
assert _test_args(BaseVectorField(cs, 0))
def test_sympy__diffgeom__diffgeom__Differential():
from sympy.diffgeom import Manifold, Patch, CoordSystem, BaseScalarField, Differential
cs = CoordSystem('name', Patch('name', Manifold('name', 3)))
assert _test_args(Differential(BaseScalarField(cs, 0)))
def test_sympy__diffgeom__diffgeom__Commutator():
from sympy.diffgeom import Manifold, Patch, CoordSystem, BaseVectorField, Commutator
cs = CoordSystem('name', Patch('name', Manifold('name', 3)))
cs1 = CoordSystem('name1', Patch('name', Manifold('name', 3)))
v = BaseVectorField(cs, 0)
v1 = BaseVectorField(cs1, 0)
assert _test_args(Commutator(v, v1))
def test_sympy__diffgeom__diffgeom__TensorProduct():
from sympy.diffgeom import Manifold, Patch, CoordSystem, BaseScalarField, Differential, TensorProduct
cs = CoordSystem('name', Patch('name', Manifold('name', 3)))
d = Differential(BaseScalarField(cs, 0))
assert _test_args(TensorProduct(d, d))
def test_sympy__diffgeom__diffgeom__WedgeProduct():
from sympy.diffgeom import Manifold, Patch, CoordSystem, BaseScalarField, Differential, WedgeProduct
cs = CoordSystem('name', Patch('name', Manifold('name', 3)))
d = Differential(BaseScalarField(cs, 0))
d1 = Differential(BaseScalarField(cs, 1))
assert _test_args(WedgeProduct(d, d1))
def test_sympy__diffgeom__diffgeom__LieDerivative():
from sympy.diffgeom import Manifold, Patch, CoordSystem, BaseScalarField, Differential, BaseVectorField, LieDerivative
cs = CoordSystem('name', Patch('name', Manifold('name', 3)))
d = Differential(BaseScalarField(cs, 0))
v = BaseVectorField(cs, 0)
assert _test_args(LieDerivative(v, d))
@XFAIL
def test_sympy__diffgeom__diffgeom__BaseCovarDerivativeOp():
from sympy.diffgeom import Manifold, Patch, CoordSystem, BaseCovarDerivativeOp
cs = CoordSystem('name', Patch('name', Manifold('name', 3)))
assert _test_args(BaseCovarDerivativeOp(cs, 0, [[[0, ]*3, ]*3, ]*3))
def test_sympy__diffgeom__diffgeom__CovarDerivativeOp():
from sympy.diffgeom import Manifold, Patch, CoordSystem, BaseVectorField, CovarDerivativeOp
cs = CoordSystem('name', Patch('name', Manifold('name', 3)))
v = BaseVectorField(cs, 0)
_test_args(CovarDerivativeOp(v, [[[0, ]*3, ]*3, ]*3))
def test_sympy__categories__baseclasses__Class():
from sympy.categories.baseclasses import Class
assert _test_args(Class())
def test_sympy__categories__baseclasses__Object():
from sympy.categories import Object
assert _test_args(Object("A"))
@XFAIL
def test_sympy__categories__baseclasses__Morphism():
from sympy.categories import Object, Morphism
assert _test_args(Morphism(Object("A"), Object("B")))
def test_sympy__categories__baseclasses__IdentityMorphism():
from sympy.categories import Object, IdentityMorphism
assert _test_args(IdentityMorphism(Object("A")))
def test_sympy__categories__baseclasses__NamedMorphism():
from sympy.categories import Object, NamedMorphism
assert _test_args(NamedMorphism(Object("A"), Object("B"), "f"))
def test_sympy__categories__baseclasses__CompositeMorphism():
from sympy.categories import Object, NamedMorphism, CompositeMorphism
A = Object("A")
B = Object("B")
C = Object("C")
f = NamedMorphism(A, B, "f")
g = NamedMorphism(B, C, "g")
assert _test_args(CompositeMorphism(f, g))
def test_sympy__categories__baseclasses__Diagram():
from sympy.categories import Object, NamedMorphism, Diagram
A = Object("A")
B = Object("B")
f = NamedMorphism(A, B, "f")
d = Diagram([f])
assert _test_args(d)
def test_sympy__categories__baseclasses__Category():
from sympy.categories import Object, NamedMorphism, Diagram, Category
A = Object("A")
B = Object("B")
C = Object("C")
f = NamedMorphism(A, B, "f")
g = NamedMorphism(B, C, "g")
d1 = Diagram([f, g])
d2 = Diagram([f])
K = Category("K", commutative_diagrams=[d1, d2])
assert _test_args(K)
def test_sympy__ntheory__factor___totient():
from sympy.ntheory.factor_ import totient
k = symbols('k', integer=True)
t = totient(k)
assert _test_args(t)
def test_sympy__ntheory__factor___reduced_totient():
from sympy.ntheory.factor_ import reduced_totient
k = symbols('k', integer=True)
t = reduced_totient(k)
assert _test_args(t)
def test_sympy__ntheory__factor___divisor_sigma():
from sympy.ntheory.factor_ import divisor_sigma
k = symbols('k', integer=True)
n = symbols('n', integer=True)
t = divisor_sigma(n, k)
assert _test_args(t)
def test_sympy__ntheory__factor___udivisor_sigma():
from sympy.ntheory.factor_ import udivisor_sigma
k = symbols('k', integer=True)
n = symbols('n', integer=True)
t = udivisor_sigma(n, k)
assert _test_args(t)
def test_sympy__ntheory__factor___primenu():
from sympy.ntheory.factor_ import primenu
n = symbols('n', integer=True)
t = primenu(n)
assert _test_args(t)
def test_sympy__ntheory__factor___primeomega():
from sympy.ntheory.factor_ import primeomega
n = symbols('n', integer=True)
t = primeomega(n)
assert _test_args(t)
def test_sympy__ntheory__residue_ntheory__mobius():
from sympy.ntheory import mobius
assert _test_args(mobius(2))
def test_sympy__ntheory__generate__primepi():
from sympy.ntheory import primepi
n = symbols('n')
t = primepi(n)
assert _test_args(t)
def test_sympy__physics__optics__waves__TWave():
from sympy.physics.optics import TWave
A, f, phi = symbols('A, f, phi')
assert _test_args(TWave(A, f, phi))
def test_sympy__physics__optics__gaussopt__BeamParameter():
from sympy.physics.optics import BeamParameter
assert _test_args(BeamParameter(530e-9, 1, w=1e-3))
def test_sympy__physics__optics__medium__Medium():
from sympy.physics.optics import Medium
assert _test_args(Medium('m'))
def test_sympy__codegen__array_utils__CodegenArrayContraction():
from sympy.codegen.array_utils import CodegenArrayContraction
from sympy import IndexedBase
A = symbols("A", cls=IndexedBase)
assert _test_args(CodegenArrayContraction(A, (0, 1)))
def test_sympy__codegen__array_utils__CodegenArrayDiagonal():
from sympy.codegen.array_utils import CodegenArrayDiagonal
from sympy import IndexedBase
A = symbols("A", cls=IndexedBase)
assert _test_args(CodegenArrayDiagonal(A, (0, 1)))
def test_sympy__codegen__array_utils__CodegenArrayTensorProduct():
from sympy.codegen.array_utils import CodegenArrayTensorProduct
from sympy import IndexedBase
A, B = symbols("A B", cls=IndexedBase)
assert _test_args(CodegenArrayTensorProduct(A, B))
def test_sympy__codegen__array_utils__CodegenArrayElementwiseAdd():
from sympy.codegen.array_utils import CodegenArrayElementwiseAdd
from sympy import IndexedBase
A, B = symbols("A B", cls=IndexedBase)
assert _test_args(CodegenArrayElementwiseAdd(A, B))
def test_sympy__codegen__array_utils__CodegenArrayPermuteDims():
from sympy.codegen.array_utils import CodegenArrayPermuteDims
from sympy import IndexedBase
A = symbols("A", cls=IndexedBase)
assert _test_args(CodegenArrayPermuteDims(A, (1, 0)))
def test_sympy__codegen__ast__Assignment():
from sympy.codegen.ast import Assignment
assert _test_args(Assignment(x, y))
def test_sympy__codegen__cfunctions__expm1():
from sympy.codegen.cfunctions import expm1
assert _test_args(expm1(x))
def test_sympy__codegen__cfunctions__log1p():
from sympy.codegen.cfunctions import log1p
assert _test_args(log1p(x))
def test_sympy__codegen__cfunctions__exp2():
from sympy.codegen.cfunctions import exp2
assert _test_args(exp2(x))
def test_sympy__codegen__cfunctions__log2():
from sympy.codegen.cfunctions import log2
assert _test_args(log2(x))
def test_sympy__codegen__cfunctions__fma():
from sympy.codegen.cfunctions import fma
assert _test_args(fma(x, y, z))
def test_sympy__codegen__cfunctions__log10():
from sympy.codegen.cfunctions import log10
assert _test_args(log10(x))
def test_sympy__codegen__cfunctions__Sqrt():
from sympy.codegen.cfunctions import Sqrt
assert _test_args(Sqrt(x))
def test_sympy__codegen__cfunctions__Cbrt():
from sympy.codegen.cfunctions import Cbrt
assert _test_args(Cbrt(x))
def test_sympy__codegen__cfunctions__hypot():
from sympy.codegen.cfunctions import hypot
assert _test_args(hypot(x, y))
def test_sympy__codegen__fnodes__FFunction():
from sympy.codegen.fnodes import FFunction
assert _test_args(FFunction('f'))
def test_sympy__codegen__fnodes__F95Function():
from sympy.codegen.fnodes import F95Function
assert _test_args(F95Function('f'))
def test_sympy__codegen__fnodes__isign():
from sympy.codegen.fnodes import isign
assert _test_args(isign(1, x))
def test_sympy__codegen__fnodes__dsign():
from sympy.codegen.fnodes import dsign
assert _test_args(dsign(1, x))
def test_sympy__codegen__fnodes__cmplx():
from sympy.codegen.fnodes import cmplx
assert _test_args(cmplx(x, y))
def test_sympy__codegen__fnodes__kind():
from sympy.codegen.fnodes import kind
assert _test_args(kind(x))
def test_sympy__codegen__fnodes__merge():
from sympy.codegen.fnodes import merge
assert _test_args(merge(1, 2, Eq(x, 0)))
def test_sympy__codegen__fnodes___literal():
from sympy.codegen.fnodes import _literal
assert _test_args(_literal(1))
def test_sympy__codegen__fnodes__literal_sp():
from sympy.codegen.fnodes import literal_sp
assert _test_args(literal_sp(1))
def test_sympy__codegen__fnodes__literal_dp():
from sympy.codegen.fnodes import literal_dp
assert _test_args(literal_dp(1))
def test_sympy__codegen__matrix_nodes__MatrixSolve():
from sympy.matrices import MatrixSymbol
from sympy.codegen.matrix_nodes import MatrixSolve
A = MatrixSymbol('A', 3, 3)
v = MatrixSymbol('x', 3, 1)
assert _test_args(MatrixSolve(A, v))
def test_sympy__vector__coordsysrect__CoordSys3D():
from sympy.vector.coordsysrect import CoordSys3D
assert _test_args(CoordSys3D('C'))
def test_sympy__vector__point__Point():
from sympy.vector.point import Point
assert _test_args(Point('P'))
def test_sympy__vector__basisdependent__BasisDependent():
#from sympy.vector.basisdependent import BasisDependent
#These classes have been created to maintain an OOP hierarchy
#for Vectors and Dyadics. Are NOT meant to be initialized
pass
def test_sympy__vector__basisdependent__BasisDependentMul():
#from sympy.vector.basisdependent import BasisDependentMul
#These classes have been created to maintain an OOP hierarchy
#for Vectors and Dyadics. Are NOT meant to be initialized
pass
def test_sympy__vector__basisdependent__BasisDependentAdd():
#from sympy.vector.basisdependent import BasisDependentAdd
#These classes have been created to maintain an OOP hierarchy
#for Vectors and Dyadics. Are NOT meant to be initialized
pass
def test_sympy__vector__basisdependent__BasisDependentZero():
#from sympy.vector.basisdependent import BasisDependentZero
#These classes have been created to maintain an OOP hierarchy
#for Vectors and Dyadics. Are NOT meant to be initialized
pass
def test_sympy__vector__vector__BaseVector():
from sympy.vector.vector import BaseVector
from sympy.vector.coordsysrect import CoordSys3D
C = CoordSys3D('C')
assert _test_args(BaseVector(0, C, ' ', ' '))
def test_sympy__vector__vector__VectorAdd():
from sympy.vector.vector import VectorAdd, VectorMul
from sympy.vector.coordsysrect import CoordSys3D
C = CoordSys3D('C')
from sympy.abc import a, b, c, x, y, z
v1 = a*C.i + b*C.j + c*C.k
v2 = x*C.i + y*C.j + z*C.k
assert _test_args(VectorAdd(v1, v2))
assert _test_args(VectorMul(x, v1))
def test_sympy__vector__vector__VectorMul():
from sympy.vector.vector import VectorMul
from sympy.vector.coordsysrect import CoordSys3D
C = CoordSys3D('C')
from sympy.abc import a
assert _test_args(VectorMul(a, C.i))
def test_sympy__vector__vector__VectorZero():
from sympy.vector.vector import VectorZero
assert _test_args(VectorZero())
def test_sympy__vector__vector__Vector():
#from sympy.vector.vector import Vector
#Vector is never to be initialized using args
pass
def test_sympy__vector__vector__Cross():
from sympy.vector.vector import Cross
from sympy.vector.coordsysrect import CoordSys3D
C = CoordSys3D('C')
_test_args(Cross(C.i, C.j))
def test_sympy__vector__vector__Dot():
from sympy.vector.vector import Dot
from sympy.vector.coordsysrect import CoordSys3D
C = CoordSys3D('C')
_test_args(Dot(C.i, C.j))
def test_sympy__vector__dyadic__Dyadic():
#from sympy.vector.dyadic import Dyadic
#Dyadic is never to be initialized using args
pass
def test_sympy__vector__dyadic__BaseDyadic():
from sympy.vector.dyadic import BaseDyadic
from sympy.vector.coordsysrect import CoordSys3D
C = CoordSys3D('C')
assert _test_args(BaseDyadic(C.i, C.j))
def test_sympy__vector__dyadic__DyadicMul():
from sympy.vector.dyadic import BaseDyadic, DyadicMul
from sympy.vector.coordsysrect import CoordSys3D
C = CoordSys3D('C')
assert _test_args(DyadicMul(3, BaseDyadic(C.i, C.j)))
def test_sympy__vector__dyadic__DyadicAdd():
from sympy.vector.dyadic import BaseDyadic, DyadicAdd
from sympy.vector.coordsysrect import CoordSys3D
C = CoordSys3D('C')
assert _test_args(2 * DyadicAdd(BaseDyadic(C.i, C.i),
BaseDyadic(C.i, C.j)))
def test_sympy__vector__dyadic__DyadicZero():
from sympy.vector.dyadic import DyadicZero
assert _test_args(DyadicZero())
def test_sympy__vector__deloperator__Del():
from sympy.vector.deloperator import Del
assert _test_args(Del())
def test_sympy__vector__operators__Curl():
from sympy.vector.operators import Curl
from sympy.vector.coordsysrect import CoordSys3D
C = CoordSys3D('C')
assert _test_args(Curl(C.i))
def test_sympy__vector__operators__Laplacian():
from sympy.vector.operators import Laplacian
from sympy.vector.coordsysrect import CoordSys3D
C = CoordSys3D('C')
assert _test_args(Laplacian(C.i))
def test_sympy__vector__operators__Divergence():
from sympy.vector.operators import Divergence
from sympy.vector.coordsysrect import CoordSys3D
C = CoordSys3D('C')
assert _test_args(Divergence(C.i))
def test_sympy__vector__operators__Gradient():
from sympy.vector.operators import Gradient
from sympy.vector.coordsysrect import CoordSys3D
C = CoordSys3D('C')
assert _test_args(Gradient(C.x))
def test_sympy__vector__orienters__Orienter():
#from sympy.vector.orienters import Orienter
#Not to be initialized
pass
def test_sympy__vector__orienters__ThreeAngleOrienter():
#from sympy.vector.orienters import ThreeAngleOrienter
#Not to be initialized
pass
def test_sympy__vector__orienters__AxisOrienter():
from sympy.vector.orienters import AxisOrienter
from sympy.vector.coordsysrect import CoordSys3D
C = CoordSys3D('C')
assert _test_args(AxisOrienter(x, C.i))
def test_sympy__vector__orienters__BodyOrienter():
from sympy.vector.orienters import BodyOrienter
assert _test_args(BodyOrienter(x, y, z, '123'))
def test_sympy__vector__orienters__SpaceOrienter():
from sympy.vector.orienters import SpaceOrienter
assert _test_args(SpaceOrienter(x, y, z, '123'))
def test_sympy__vector__orienters__QuaternionOrienter():
from sympy.vector.orienters import QuaternionOrienter
a, b, c, d = symbols('a b c d')
assert _test_args(QuaternionOrienter(a, b, c, d))
def test_sympy__vector__scalar__BaseScalar():
from sympy.vector.scalar import BaseScalar
from sympy.vector.coordsysrect import CoordSys3D
C = CoordSys3D('C')
assert _test_args(BaseScalar(0, C, ' ', ' '))
def test_sympy__physics__wigner__Wigner3j():
from sympy.physics.wigner import Wigner3j
assert _test_args(Wigner3j(0, 0, 0, 0, 0, 0))
def test_sympy__integrals__rubi__symbol__matchpyWC():
from sympy.integrals.rubi.symbol import matchpyWC
assert _test_args(matchpyWC(1, True, 'a'))
def test_sympy__integrals__rubi__utility_function__rubi_unevaluated_expr():
from sympy.integrals.rubi.utility_function import rubi_unevaluated_expr
a = symbols('a')
assert _test_args(rubi_unevaluated_expr(a))
def test_sympy__integrals__rubi__utility_function__rubi_exp():
from sympy.integrals.rubi.utility_function import rubi_exp
assert _test_args(rubi_exp(5))
def test_sympy__integrals__rubi__utility_function__rubi_log():
from sympy.integrals.rubi.utility_function import rubi_log
assert _test_args(rubi_log(5))
def test_sympy__integrals__rubi__utility_function__Int():
from sympy.integrals.rubi.utility_function import Int
assert _test_args(Int(5, x))
def test_sympy__integrals__rubi__utility_function__Util_Coefficient():
from sympy.integrals.rubi.utility_function import Util_Coefficient
a, x = symbols('a x')
assert _test_args(Util_Coefficient(a, x))
def test_sympy__integrals__rubi__utility_function__Gamma():
from sympy.integrals.rubi.utility_function import Gamma
assert _test_args(Gamma(5))
def test_sympy__integrals__rubi__utility_function__Util_Part():
from sympy.integrals.rubi.utility_function import Util_Part
a, b = symbols('a b')
assert _test_args(Util_Part(a + b, 0))
def test_sympy__integrals__rubi__utility_function__PolyGamma():
from sympy.integrals.rubi.utility_function import PolyGamma
assert _test_args(PolyGamma(1, 1))
def test_sympy__integrals__rubi__utility_function__ProductLog():
from sympy.integrals.rubi.utility_function import ProductLog
assert _test_args(ProductLog(1))
def test_sympy__combinatorics__schur_number__SchurNumber():
from sympy.combinatorics.schur_number import SchurNumber
assert _test_args(SchurNumber(1))
def test_sympy__combinatorics__perm_groups__SymmetricPermutationGroup():
from sympy.combinatorics.perm_groups import SymmetricPermutationGroup
assert _test_args(SymmetricPermutationGroup(5))
def test_sympy__combinatorics__perm_groups__Coset():
from sympy.combinatorics.permutations import Permutation
from sympy.combinatorics.perm_groups import PermutationGroup, Coset
a = Permutation(1, 2)
b = Permutation(0, 1)
G = PermutationGroup([a, b])
assert _test_args(Coset(a, G))
|
4bba1140c1df81d4f52d3a47048a71e45945133251a7a097acf602470f1a71e5 | from sympy import (Symbol, Wild, GreaterThan, LessThan, StrictGreaterThan,
StrictLessThan, pi, I, Rational, sympify, symbols, Dummy)
from sympy.core.symbol import _uniquely_named_symbol, _symbol
from sympy.testing.pytest import raises
from sympy.core.symbol import disambiguate
def test_Symbol():
a = Symbol("a")
x1 = Symbol("x")
x2 = Symbol("x")
xdummy1 = Dummy("x")
xdummy2 = Dummy("x")
assert a != x1
assert a != x2
assert x1 == x2
assert x1 != xdummy1
assert xdummy1 != xdummy2
assert Symbol("x") == Symbol("x")
assert Dummy("x") != Dummy("x")
d = symbols('d', cls=Dummy)
assert isinstance(d, Dummy)
c, d = symbols('c,d', cls=Dummy)
assert isinstance(c, Dummy)
assert isinstance(d, Dummy)
raises(TypeError, lambda: Symbol())
def test_Dummy():
assert Dummy() != Dummy()
def test_Dummy_force_dummy_index():
raises(AssertionError, lambda: Dummy(dummy_index=1))
assert Dummy('d', dummy_index=2) == Dummy('d', dummy_index=2)
assert Dummy('d1', dummy_index=2) != Dummy('d2', dummy_index=2)
d1 = Dummy('d', dummy_index=3)
d2 = Dummy('d')
# might fail if d1 were created with dummy_index >= 10**6
assert d1 != d2
d3 = Dummy('d', dummy_index=3)
assert d1 == d3
assert Dummy()._count == Dummy('d', dummy_index=3)._count
def test_lt_gt():
from sympy import sympify as S
x, y = Symbol('x'), Symbol('y')
assert (x >= y) == GreaterThan(x, y)
assert (x >= 0) == GreaterThan(x, 0)
assert (x <= y) == LessThan(x, y)
assert (x <= 0) == LessThan(x, 0)
assert (0 <= x) == GreaterThan(x, 0)
assert (0 >= x) == LessThan(x, 0)
assert (S(0) >= x) == GreaterThan(0, x)
assert (S(0) <= x) == LessThan(0, x)
assert (x > y) == StrictGreaterThan(x, y)
assert (x > 0) == StrictGreaterThan(x, 0)
assert (x < y) == StrictLessThan(x, y)
assert (x < 0) == StrictLessThan(x, 0)
assert (0 < x) == StrictGreaterThan(x, 0)
assert (0 > x) == StrictLessThan(x, 0)
assert (S(0) > x) == StrictGreaterThan(0, x)
assert (S(0) < x) == StrictLessThan(0, x)
e = x**2 + 4*x + 1
assert (e >= 0) == GreaterThan(e, 0)
assert (0 <= e) == GreaterThan(e, 0)
assert (e > 0) == StrictGreaterThan(e, 0)
assert (0 < e) == StrictGreaterThan(e, 0)
assert (e <= 0) == LessThan(e, 0)
assert (0 >= e) == LessThan(e, 0)
assert (e < 0) == StrictLessThan(e, 0)
assert (0 > e) == StrictLessThan(e, 0)
assert (S(0) >= e) == GreaterThan(0, e)
assert (S(0) <= e) == LessThan(0, e)
assert (S(0) < e) == StrictLessThan(0, e)
assert (S(0) > e) == StrictGreaterThan(0, e)
def test_no_len():
# there should be no len for numbers
x = Symbol('x')
raises(TypeError, lambda: len(x))
def test_ineq_unequal():
S = sympify
x, y, z = symbols('x,y,z')
e = (
S(-1) >= x, S(-1) >= y, S(-1) >= z,
S(-1) > x, S(-1) > y, S(-1) > z,
S(-1) <= x, S(-1) <= y, S(-1) <= z,
S(-1) < x, S(-1) < y, S(-1) < z,
S(0) >= x, S(0) >= y, S(0) >= z,
S(0) > x, S(0) > y, S(0) > z,
S(0) <= x, S(0) <= y, S(0) <= z,
S(0) < x, S(0) < y, S(0) < z,
S('3/7') >= x, S('3/7') >= y, S('3/7') >= z,
S('3/7') > x, S('3/7') > y, S('3/7') > z,
S('3/7') <= x, S('3/7') <= y, S('3/7') <= z,
S('3/7') < x, S('3/7') < y, S('3/7') < z,
S(1.5) >= x, S(1.5) >= y, S(1.5) >= z,
S(1.5) > x, S(1.5) > y, S(1.5) > z,
S(1.5) <= x, S(1.5) <= y, S(1.5) <= z,
S(1.5) < x, S(1.5) < y, S(1.5) < z,
S(2) >= x, S(2) >= y, S(2) >= z,
S(2) > x, S(2) > y, S(2) > z,
S(2) <= x, S(2) <= y, S(2) <= z,
S(2) < x, S(2) < y, S(2) < z,
x >= -1, y >= -1, z >= -1,
x > -1, y > -1, z > -1,
x <= -1, y <= -1, z <= -1,
x < -1, y < -1, z < -1,
x >= 0, y >= 0, z >= 0,
x > 0, y > 0, z > 0,
x <= 0, y <= 0, z <= 0,
x < 0, y < 0, z < 0,
x >= 1.5, y >= 1.5, z >= 1.5,
x > 1.5, y > 1.5, z > 1.5,
x <= 1.5, y <= 1.5, z <= 1.5,
x < 1.5, y < 1.5, z < 1.5,
x >= 2, y >= 2, z >= 2,
x > 2, y > 2, z > 2,
x <= 2, y <= 2, z <= 2,
x < 2, y < 2, z < 2,
x >= y, x >= z, y >= x, y >= z, z >= x, z >= y,
x > y, x > z, y > x, y > z, z > x, z > y,
x <= y, x <= z, y <= x, y <= z, z <= x, z <= y,
x < y, x < z, y < x, y < z, z < x, z < y,
x - pi >= y + z, y - pi >= x + z, z - pi >= x + y,
x - pi > y + z, y - pi > x + z, z - pi > x + y,
x - pi <= y + z, y - pi <= x + z, z - pi <= x + y,
x - pi < y + z, y - pi < x + z, z - pi < x + y,
True, False
)
left_e = e[:-1]
for i, e1 in enumerate( left_e ):
for e2 in e[i + 1:]:
assert e1 != e2
def test_Wild_properties():
# these tests only include Atoms
x = Symbol("x")
y = Symbol("y")
p = Symbol("p", positive=True)
k = Symbol("k", integer=True)
n = Symbol("n", integer=True, positive=True)
given_patterns = [ x, y, p, k, -k, n, -n, sympify(-3), sympify(3),
pi, Rational(3, 2), I ]
integerp = lambda k: k.is_integer
positivep = lambda k: k.is_positive
symbolp = lambda k: k.is_Symbol
realp = lambda k: k.is_extended_real
S = Wild("S", properties=[symbolp])
R = Wild("R", properties=[realp])
Y = Wild("Y", exclude=[x, p, k, n])
P = Wild("P", properties=[positivep])
K = Wild("K", properties=[integerp])
N = Wild("N", properties=[positivep, integerp])
given_wildcards = [ S, R, Y, P, K, N ]
goodmatch = {
S: (x, y, p, k, n),
R: (p, k, -k, n, -n, -3, 3, pi, Rational(3, 2)),
Y: (y, -3, 3, pi, Rational(3, 2), I ),
P: (p, n, 3, pi, Rational(3, 2)),
K: (k, -k, n, -n, -3, 3),
N: (n, 3)}
for A in given_wildcards:
for pat in given_patterns:
d = pat.match(A)
if pat in goodmatch[A]:
assert d[A] in goodmatch[A]
else:
assert d is None
def test_symbols():
x = Symbol('x')
y = Symbol('y')
z = Symbol('z')
assert symbols('x') == x
assert symbols('x ') == x
assert symbols(' x ') == x
assert symbols('x,') == (x,)
assert symbols('x, ') == (x,)
assert symbols('x ,') == (x,)
assert symbols('x , y') == (x, y)
assert symbols('x,y,z') == (x, y, z)
assert symbols('x y z') == (x, y, z)
assert symbols('x,y,z,') == (x, y, z)
assert symbols('x y z ') == (x, y, z)
xyz = Symbol('xyz')
abc = Symbol('abc')
assert symbols('xyz') == xyz
assert symbols('xyz,') == (xyz,)
assert symbols('xyz,abc') == (xyz, abc)
assert symbols(('xyz',)) == (xyz,)
assert symbols(('xyz,',)) == ((xyz,),)
assert symbols(('x,y,z,',)) == ((x, y, z),)
assert symbols(('xyz', 'abc')) == (xyz, abc)
assert symbols(('xyz,abc',)) == ((xyz, abc),)
assert symbols(('xyz,abc', 'x,y,z')) == ((xyz, abc), (x, y, z))
assert symbols(('x', 'y', 'z')) == (x, y, z)
assert symbols(['x', 'y', 'z']) == [x, y, z]
assert symbols({'x', 'y', 'z'}) == {x, y, z}
raises(ValueError, lambda: symbols(''))
raises(ValueError, lambda: symbols(','))
raises(ValueError, lambda: symbols('x,,y,,z'))
raises(ValueError, lambda: symbols(('x', '', 'y', '', 'z')))
a, b = symbols('x,y', real=True)
assert a.is_real and b.is_real
x0 = Symbol('x0')
x1 = Symbol('x1')
x2 = Symbol('x2')
y0 = Symbol('y0')
y1 = Symbol('y1')
assert symbols('x0:0') == ()
assert symbols('x0:1') == (x0,)
assert symbols('x0:2') == (x0, x1)
assert symbols('x0:3') == (x0, x1, x2)
assert symbols('x:0') == ()
assert symbols('x:1') == (x0,)
assert symbols('x:2') == (x0, x1)
assert symbols('x:3') == (x0, x1, x2)
assert symbols('x1:1') == ()
assert symbols('x1:2') == (x1,)
assert symbols('x1:3') == (x1, x2)
assert symbols('x1:3,x,y,z') == (x1, x2, x, y, z)
assert symbols('x:3,y:2') == (x0, x1, x2, y0, y1)
assert symbols(('x:3', 'y:2')) == ((x0, x1, x2), (y0, y1))
a = Symbol('a')
b = Symbol('b')
c = Symbol('c')
d = Symbol('d')
assert symbols('x:z') == (x, y, z)
assert symbols('a:d,x:z') == (a, b, c, d, x, y, z)
assert symbols(('a:d', 'x:z')) == ((a, b, c, d), (x, y, z))
aa = Symbol('aa')
ab = Symbol('ab')
ac = Symbol('ac')
ad = Symbol('ad')
assert symbols('aa:d') == (aa, ab, ac, ad)
assert symbols('aa:d,x:z') == (aa, ab, ac, ad, x, y, z)
assert symbols(('aa:d','x:z')) == ((aa, ab, ac, ad), (x, y, z))
# issue 6675
def sym(s):
return str(symbols(s))
assert sym('a0:4') == '(a0, a1, a2, a3)'
assert sym('a2:4,b1:3') == '(a2, a3, b1, b2)'
assert sym('a1(2:4)') == '(a12, a13)'
assert sym('a0:2.0:2') == '(a0.0, a0.1, a1.0, a1.1)'
assert sym('aa:cz') == '(aaz, abz, acz)'
assert sym('aa:c0:2') == '(aa0, aa1, ab0, ab1, ac0, ac1)'
assert sym('aa:ba:b') == '(aaa, aab, aba, abb)'
assert sym('a:3b') == '(a0b, a1b, a2b)'
assert sym('a-1:3b') == '(a-1b, a-2b)'
assert sym(r'a:2\,:2' + chr(0)) == '(a0,0%s, a0,1%s, a1,0%s, a1,1%s)' % (
(chr(0),)*4)
assert sym('x(:a:3)') == '(x(a0), x(a1), x(a2))'
assert sym('x(:c):1') == '(xa0, xb0, xc0)'
assert sym('x((:a)):3') == '(x(a)0, x(a)1, x(a)2)'
assert sym('x(:a:3') == '(x(a0, x(a1, x(a2)'
assert sym(':2') == '(0, 1)'
assert sym(':b') == '(a, b)'
assert sym(':b:2') == '(a0, a1, b0, b1)'
assert sym(':2:2') == '(00, 01, 10, 11)'
assert sym(':b:b') == '(aa, ab, ba, bb)'
raises(ValueError, lambda: symbols(':'))
raises(ValueError, lambda: symbols('a:'))
raises(ValueError, lambda: symbols('::'))
raises(ValueError, lambda: symbols('a::'))
raises(ValueError, lambda: symbols(':a:'))
raises(ValueError, lambda: symbols('::a'))
def test_symbols_become_functions_issue_3539():
from sympy.abc import alpha, phi, beta, t
raises(TypeError, lambda: beta(2))
raises(TypeError, lambda: beta(2.5))
raises(TypeError, lambda: phi(2.5))
raises(TypeError, lambda: alpha(2.5))
raises(TypeError, lambda: phi(t))
def test_unicode():
xu = Symbol('x')
x = Symbol('x')
assert x == xu
raises(TypeError, lambda: Symbol(1))
def test__uniquely_named_symbol_and__symbol():
F = _uniquely_named_symbol
x = Symbol('x')
assert F(x) == x
assert F('x') == x
assert str(F('x', x)) == '_x'
assert str(F('x', (x + 1, 1/x))) == '_x'
_x = Symbol('x', real=True)
assert F(('x', _x)) == _x
assert F((x, _x)) == _x
assert F('x', real=True).is_real
y = Symbol('y')
assert F(('x', y), real=True).is_real
r = Symbol('x', real=True)
assert F(('x', r)).is_real
assert F(('x', r), real=False).is_real
assert F('x1', Symbol('x1'),
compare=lambda i: str(i).rstrip('1')).name == 'x1'
assert F('x1', Symbol('x1'),
modify=lambda i: i + '_').name == 'x1_'
assert _symbol(x, _x) == x
def test_disambiguate():
x, y, y_1, _x, x_1, x_2 = symbols('x y y_1 _x x_1 x_2')
t1 = Dummy('y'), _x, Dummy('x'), Dummy('x')
t2 = Dummy('x'), Dummy('x')
t3 = Dummy('x'), Dummy('y')
t4 = x, Dummy('x')
t5 = Symbol('x', integer=True), x, Symbol('x_1')
assert disambiguate(*t1) == (y, x_2, x, x_1)
assert disambiguate(*t2) == (x, x_1)
assert disambiguate(*t3) == (x, y)
assert disambiguate(*t4) == (x_1, x)
assert disambiguate(*t5) == (t5[0], x_2, x_1)
assert disambiguate(*t5)[0] != x # assumptions are retained
t6 = _x, Dummy('x')/y
t7 = y*Dummy('y'), y
assert disambiguate(*t6) == (x_1, x/y)
assert disambiguate(*t7) == (y*y_1, y_1)
assert disambiguate(Dummy('x_1'), Dummy('x_1')
) == (x_1, Symbol('x_1_1'))
|
c88d8a3ddfea4e68c922c3f7e503a64fd7b37f1c1dd5680efc265f0561a27ff3 | import numbers as nums
import decimal
from sympy import (Rational, Symbol, Float, I, sqrt, cbrt, oo, nan, pi, E,
Integer, S, factorial, Catalan, EulerGamma, GoldenRatio,
TribonacciConstant, cos, exp,
Number, zoo, log, Mul, Pow, Tuple, latex, Gt, Lt, Ge, Le,
AlgebraicNumber, simplify, sin, fibonacci, RealField,
sympify, srepr, Dummy, Sum)
from sympy.core.logic import fuzzy_not
from sympy.core.numbers import (igcd, ilcm, igcdex, seterr,
igcd2, igcd_lehmer, mpf_norm, comp, mod_inverse)
from sympy.core.power import integer_nthroot, isqrt, integer_log
from sympy.polys.domains.groundtypes import PythonRational
from sympy.utilities.decorator import conserve_mpmath_dps
from sympy.utilities.iterables import permutations
from sympy.testing.pytest import XFAIL, raises
from mpmath import mpf
from mpmath.rational import mpq
import mpmath
from sympy.core import numbers
t = Symbol('t', real=False)
_ninf = float(-oo)
_inf = float(oo)
def same_and_same_prec(a, b):
# stricter matching for Floats
return a == b and a._prec == b._prec
def test_seterr():
seterr(divide=True)
raises(ValueError, lambda: S.Zero/S.Zero)
seterr(divide=False)
assert S.Zero / S.Zero is S.NaN
def test_mod():
x = S.Half
y = Rational(3, 4)
z = Rational(5, 18043)
assert x % x == 0
assert x % y == S.Half
assert x % z == Rational(3, 36086)
assert y % x == Rational(1, 4)
assert y % y == 0
assert y % z == Rational(9, 72172)
assert z % x == Rational(5, 18043)
assert z % y == Rational(5, 18043)
assert z % z == 0
a = Float(2.6)
assert (a % .2) == 0.0
assert (a % 2).round(15) == 0.6
assert (a % 0.5).round(15) == 0.1
p = Symbol('p', infinite=True)
assert oo % oo is nan
assert zoo % oo is nan
assert 5 % oo is nan
assert p % 5 is nan
# In these two tests, if the precision of m does
# not match the precision of the ans, then it is
# likely that the change made now gives an answer
# with degraded accuracy.
r = Rational(500, 41)
f = Float('.36', 3)
m = r % f
ans = Float(r % Rational(f), 3)
assert m == ans and m._prec == ans._prec
f = Float('8.36', 3)
m = f % r
ans = Float(Rational(f) % r, 3)
assert m == ans and m._prec == ans._prec
s = S.Zero
assert s % float(1) == 0.0
# No rounding required since these numbers can be represented
# exactly.
assert Rational(3, 4) % Float(1.1) == 0.75
assert Float(1.5) % Rational(5, 4) == 0.25
assert Rational(5, 4).__rmod__(Float('1.5')) == 0.25
assert Float('1.5').__rmod__(Float('2.75')) == Float('1.25')
assert 2.75 % Float('1.5') == Float('1.25')
a = Integer(7)
b = Integer(4)
assert type(a % b) == Integer
assert a % b == Integer(3)
assert Integer(1) % Rational(2, 3) == Rational(1, 3)
assert Rational(7, 5) % Integer(1) == Rational(2, 5)
assert Integer(2) % 1.5 == 0.5
assert Integer(3).__rmod__(Integer(10)) == Integer(1)
assert Integer(10) % 4 == Integer(2)
assert 15 % Integer(4) == Integer(3)
def test_divmod():
assert divmod(S(12), S(8)) == Tuple(1, 4)
assert divmod(-S(12), S(8)) == Tuple(-2, 4)
assert divmod(S.Zero, S.One) == Tuple(0, 0)
raises(ZeroDivisionError, lambda: divmod(S.Zero, S.Zero))
raises(ZeroDivisionError, lambda: divmod(S.One, S.Zero))
assert divmod(S(12), 8) == Tuple(1, 4)
assert divmod(12, S(8)) == Tuple(1, 4)
assert divmod(S("2"), S("3/2")) == Tuple(S("1"), S("1/2"))
assert divmod(S("3/2"), S("2")) == Tuple(S("0"), S("3/2"))
assert divmod(S("2"), S("3.5")) == Tuple(S("0"), S("2"))
assert divmod(S("3.5"), S("2")) == Tuple(S("1"), S("1.5"))
assert divmod(S("2"), S("1/3")) == Tuple(S("6"), S("0"))
assert divmod(S("1/3"), S("2")) == Tuple(S("0"), S("1/3"))
assert divmod(S("2"), S("1/10")) == Tuple(S("20"), S("0"))
assert divmod(S("2"), S(".1"))[0] == 19
assert divmod(S("0.1"), S("2")) == Tuple(S("0"), S("0.1"))
assert divmod(S("2"), 2) == Tuple(S("1"), S("0"))
assert divmod(2, S("2")) == Tuple(S("1"), S("0"))
assert divmod(S("2"), 1.5) == Tuple(S("1"), S("0.5"))
assert divmod(1.5, S("2")) == Tuple(S("0"), S("1.5"))
assert divmod(0.3, S("2")) == Tuple(S("0"), S("0.3"))
assert divmod(S("3/2"), S("3.5")) == Tuple(S("0"), S("3/2"))
assert divmod(S("3.5"), S("3/2")) == Tuple(S("2"), S("0.5"))
assert divmod(S("3/2"), S("1/3")) == Tuple(S("4"), S("1/6"))
assert divmod(S("1/3"), S("3/2")) == Tuple(S("0"), S("1/3"))
assert divmod(S("3/2"), S("0.1"))[0] == 14
assert divmod(S("0.1"), S("3/2")) == Tuple(S("0"), S("0.1"))
assert divmod(S("3/2"), 2) == Tuple(S("0"), S("3/2"))
assert divmod(2, S("3/2")) == Tuple(S("1"), S("1/2"))
assert divmod(S("3/2"), 1.5) == Tuple(S("1"), S("0"))
assert divmod(1.5, S("3/2")) == Tuple(S("1"), S("0"))
assert divmod(S("3/2"), 0.3) == Tuple(S("5"), S("0"))
assert divmod(0.3, S("3/2")) == Tuple(S("0"), S("0.3"))
assert divmod(S("1/3"), S("3.5")) == Tuple(S("0"), S("1/3"))
assert divmod(S("3.5"), S("0.1")) == Tuple(S("35"), S("0"))
assert divmod(S("0.1"), S("3.5")) == Tuple(S("0"), S("0.1"))
assert divmod(S("3.5"), 2) == Tuple(S("1"), S("1.5"))
assert divmod(2, S("3.5")) == Tuple(S("0"), S("2"))
assert divmod(S("3.5"), 1.5) == Tuple(S("2"), S("0.5"))
assert divmod(1.5, S("3.5")) == Tuple(S("0"), S("1.5"))
assert divmod(0.3, S("3.5")) == Tuple(S("0"), S("0.3"))
assert divmod(S("0.1"), S("1/3")) == Tuple(S("0"), S("0.1"))
assert divmod(S("1/3"), 2) == Tuple(S("0"), S("1/3"))
assert divmod(2, S("1/3")) == Tuple(S("6"), S("0"))
assert divmod(S("1/3"), 1.5) == Tuple(S("0"), S("1/3"))
assert divmod(0.3, S("1/3")) == Tuple(S("0"), S("0.3"))
assert divmod(S("0.1"), 2) == Tuple(S("0"), S("0.1"))
assert divmod(2, S("0.1"))[0] == 19
assert divmod(S("0.1"), 1.5) == Tuple(S("0"), S("0.1"))
assert divmod(1.5, S("0.1")) == Tuple(S("15"), S("0"))
assert divmod(S("0.1"), 0.3) == Tuple(S("0"), S("0.1"))
assert str(divmod(S("2"), 0.3)) == '(6, 0.2)'
assert str(divmod(S("3.5"), S("1/3"))) == '(10, 0.166666666666667)'
assert str(divmod(S("3.5"), 0.3)) == '(11, 0.2)'
assert str(divmod(S("1/3"), S("0.1"))) == '(3, 0.0333333333333333)'
assert str(divmod(1.5, S("1/3"))) == '(4, 0.166666666666667)'
assert str(divmod(S("1/3"), 0.3)) == '(1, 0.0333333333333333)'
assert str(divmod(0.3, S("0.1"))) == '(2, 0.1)'
assert divmod(-3, S(2)) == (-2, 1)
assert divmod(S(-3), S(2)) == (-2, 1)
assert divmod(S(-3), 2) == (-2, 1)
assert divmod(S(4), S(-3.1)) == Tuple(-2, -2.2)
assert divmod(S(4), S(-2.1)) == divmod(4, -2.1)
assert divmod(S(-8), S(-2.5) ) == Tuple(3 , -0.5)
assert divmod(oo, 1) == (S.NaN, S.NaN)
assert divmod(S.NaN, 1) == (S.NaN, S.NaN)
assert divmod(1, S.NaN) == (S.NaN, S.NaN)
ans = [(-1, oo), (-1, oo), (0, 0), (0, 1), (0, 2)]
OO = float('inf')
ANS = [tuple(map(float, i)) for i in ans]
assert [divmod(i, oo) for i in range(-2, 3)] == ans
ans = [(0, -2), (0, -1), (0, 0), (-1, -oo), (-1, -oo)]
ANS = [tuple(map(float, i)) for i in ans]
assert [divmod(i, -oo) for i in range(-2, 3)] == ans
assert [divmod(i, -OO) for i in range(-2, 3)] == ANS
assert divmod(S(3.5), S(-2)) == divmod(3.5, -2)
assert divmod(-S(3.5), S(-2)) == divmod(-3.5, -2)
def test_igcd():
assert igcd(0, 0) == 0
assert igcd(0, 1) == 1
assert igcd(1, 0) == 1
assert igcd(0, 7) == 7
assert igcd(7, 0) == 7
assert igcd(7, 1) == 1
assert igcd(1, 7) == 1
assert igcd(-1, 0) == 1
assert igcd(0, -1) == 1
assert igcd(-1, -1) == 1
assert igcd(-1, 7) == 1
assert igcd(7, -1) == 1
assert igcd(8, 2) == 2
assert igcd(4, 8) == 4
assert igcd(8, 16) == 8
assert igcd(7, -3) == 1
assert igcd(-7, 3) == 1
assert igcd(-7, -3) == 1
assert igcd(*[10, 20, 30]) == 10
raises(TypeError, lambda: igcd())
raises(TypeError, lambda: igcd(2))
raises(ValueError, lambda: igcd(0, None))
raises(ValueError, lambda: igcd(1, 2.2))
for args in permutations((45.1, 1, 30)):
raises(ValueError, lambda: igcd(*args))
for args in permutations((1, 2, None)):
raises(ValueError, lambda: igcd(*args))
def test_igcd_lehmer():
a, b = fibonacci(10001), fibonacci(10000)
# len(str(a)) == 2090
# small divisors, long Euclidean sequence
assert igcd_lehmer(a, b) == 1
c = fibonacci(100)
assert igcd_lehmer(a*c, b*c) == c
# big divisor
assert igcd_lehmer(a, 10**1000) == 1
# swapping argmument
assert igcd_lehmer(1, 2) == igcd_lehmer(2, 1)
def test_igcd2():
# short loop
assert igcd2(2**100 - 1, 2**99 - 1) == 1
# Lehmer's algorithm
a, b = int(fibonacci(10001)), int(fibonacci(10000))
assert igcd2(a, b) == 1
def test_ilcm():
assert ilcm(0, 0) == 0
assert ilcm(1, 0) == 0
assert ilcm(0, 1) == 0
assert ilcm(1, 1) == 1
assert ilcm(2, 1) == 2
assert ilcm(8, 2) == 8
assert ilcm(8, 6) == 24
assert ilcm(8, 7) == 56
assert ilcm(*[10, 20, 30]) == 60
raises(ValueError, lambda: ilcm(8.1, 7))
raises(ValueError, lambda: ilcm(8, 7.1))
raises(TypeError, lambda: ilcm(8))
def test_igcdex():
assert igcdex(2, 3) == (-1, 1, 1)
assert igcdex(10, 12) == (-1, 1, 2)
assert igcdex(100, 2004) == (-20, 1, 4)
assert igcdex(0, 0) == (0, 1, 0)
assert igcdex(1, 0) == (1, 0, 1)
def _strictly_equal(a, b):
return (a.p, a.q, type(a.p), type(a.q)) == \
(b.p, b.q, type(b.p), type(b.q))
def _test_rational_new(cls):
"""
Tests that are common between Integer and Rational.
"""
assert cls(0) is S.Zero
assert cls(1) is S.One
assert cls(-1) is S.NegativeOne
# These look odd, but are similar to int():
assert cls('1') is S.One
assert cls('-1') is S.NegativeOne
i = Integer(10)
assert _strictly_equal(i, cls('10'))
assert _strictly_equal(i, cls('10'))
assert _strictly_equal(i, cls(int(10)))
assert _strictly_equal(i, cls(i))
raises(TypeError, lambda: cls(Symbol('x')))
def test_Integer_new():
"""
Test for Integer constructor
"""
_test_rational_new(Integer)
assert _strictly_equal(Integer(0.9), S.Zero)
assert _strictly_equal(Integer(10.5), Integer(10))
raises(ValueError, lambda: Integer("10.5"))
assert Integer(Rational('1.' + '9'*20)) == 1
def test_Rational_new():
""""
Test for Rational constructor
"""
_test_rational_new(Rational)
n1 = S.Half
assert n1 == Rational(Integer(1), 2)
assert n1 == Rational(Integer(1), Integer(2))
assert n1 == Rational(1, Integer(2))
assert n1 == Rational(S.Half)
assert 1 == Rational(n1, n1)
assert Rational(3, 2) == Rational(S.Half, Rational(1, 3))
assert Rational(3, 1) == Rational(1, Rational(1, 3))
n3_4 = Rational(3, 4)
assert Rational('3/4') == n3_4
assert -Rational('-3/4') == n3_4
assert Rational('.76').limit_denominator(4) == n3_4
assert Rational(19, 25).limit_denominator(4) == n3_4
assert Rational('19/25').limit_denominator(4) == n3_4
assert Rational(1.0, 3) == Rational(1, 3)
assert Rational(1, 3.0) == Rational(1, 3)
assert Rational(Float(0.5)) == S.Half
assert Rational('1e2/1e-2') == Rational(10000)
assert Rational('1 234') == Rational(1234)
assert Rational('1/1 234') == Rational(1, 1234)
assert Rational(-1, 0) is S.ComplexInfinity
assert Rational(1, 0) is S.ComplexInfinity
# Make sure Rational doesn't lose precision on Floats
assert Rational(pi.evalf(100)).evalf(100) == pi.evalf(100)
raises(TypeError, lambda: Rational('3**3'))
raises(TypeError, lambda: Rational('1/2 + 2/3'))
# handle fractions.Fraction instances
try:
import fractions
assert Rational(fractions.Fraction(1, 2)) == S.Half
except ImportError:
pass
assert Rational(mpq(2, 6)) == Rational(1, 3)
assert Rational(PythonRational(2, 6)) == Rational(1, 3)
def test_Number_new():
""""
Test for Number constructor
"""
# Expected behavior on numbers and strings
assert Number(1) is S.One
assert Number(2).__class__ is Integer
assert Number(-622).__class__ is Integer
assert Number(5, 3).__class__ is Rational
assert Number(5.3).__class__ is Float
assert Number('1') is S.One
assert Number('2').__class__ is Integer
assert Number('-622').__class__ is Integer
assert Number('5/3').__class__ is Rational
assert Number('5.3').__class__ is Float
raises(ValueError, lambda: Number('cos'))
raises(TypeError, lambda: Number(cos))
a = Rational(3, 5)
assert Number(a) is a # Check idempotence on Numbers
u = ['inf', '-inf', 'nan', 'iNF', '+inf']
v = [oo, -oo, nan, oo, oo]
for i, a in zip(u, v):
assert Number(i) is a, (i, Number(i), a)
def test_Number_cmp():
n1 = Number(1)
n2 = Number(2)
n3 = Number(-3)
assert n1 < n2
assert n1 <= n2
assert n3 < n1
assert n2 > n3
assert n2 >= n3
raises(TypeError, lambda: n1 < S.NaN)
raises(TypeError, lambda: n1 <= S.NaN)
raises(TypeError, lambda: n1 > S.NaN)
raises(TypeError, lambda: n1 >= S.NaN)
def test_Rational_cmp():
n1 = Rational(1, 4)
n2 = Rational(1, 3)
n3 = Rational(2, 4)
n4 = Rational(2, -4)
n5 = Rational(0)
n6 = Rational(1)
n7 = Rational(3)
n8 = Rational(-3)
assert n8 < n5
assert n5 < n6
assert n6 < n7
assert n8 < n7
assert n7 > n8
assert (n1 + 1)**n2 < 2
assert ((n1 + n6)/n7) < 1
assert n4 < n3
assert n2 < n3
assert n1 < n2
assert n3 > n1
assert not n3 < n1
assert not (Rational(-1) > 0)
assert Rational(-1) < 0
raises(TypeError, lambda: n1 < S.NaN)
raises(TypeError, lambda: n1 <= S.NaN)
raises(TypeError, lambda: n1 > S.NaN)
raises(TypeError, lambda: n1 >= S.NaN)
def test_Float():
def eq(a, b):
t = Float("1.0E-15")
return (-t < a - b < t)
zeros = (0, S.Zero, 0., Float(0))
for i, j in permutations(zeros, 2):
assert i == j
for z in zeros:
assert z in zeros
assert S.Zero.is_zero
a = Float(2) ** Float(3)
assert eq(a.evalf(), Float(8))
assert eq((pi ** -1).evalf(), Float("0.31830988618379067"))
a = Float(2) ** Float(4)
assert eq(a.evalf(), Float(16))
assert (S(.3) == S(.5)) is False
mpf = (0, 5404319552844595, -52, 53)
x_str = Float((0, '13333333333333', -52, 53))
x2_str = Float((0, '26666666666666', -53, 54))
x_hex = Float((0, int(0x13333333333333), -52, 53))
x_dec = Float(mpf)
assert x_str == x_hex == x_dec == Float(1.2)
# x2_str was entered slightly malformed in that the mantissa
# was even -- it should be odd and the even part should be
# included with the exponent, but this is resolved by normalization
# ONLY IF REQUIREMENTS of mpf_norm are met: the bitcount must
# be exact: double the mantissa ==> increase bc by 1
assert Float(1.2)._mpf_ == mpf
assert x2_str._mpf_ == mpf
assert Float((0, int(0), -123, -1)) is S.NaN
assert Float((0, int(0), -456, -2)) is S.Infinity
assert Float((1, int(0), -789, -3)) is S.NegativeInfinity
# if you don't give the full signature, it's not special
assert Float((0, int(0), -123)) == Float(0)
assert Float((0, int(0), -456)) == Float(0)
assert Float((1, int(0), -789)) == Float(0)
raises(ValueError, lambda: Float((0, 7, 1, 3), ''))
assert Float('0.0').is_finite is True
assert Float('0.0').is_negative is False
assert Float('0.0').is_positive is False
assert Float('0.0').is_infinite is False
assert Float('0.0').is_zero is True
# rationality properties
# if the integer test fails then the use of intlike
# should be removed from gamma_functions.py
assert Float(1).is_integer is False
assert Float(1).is_rational is None
assert Float(1).is_irrational is None
assert sqrt(2).n(15).is_rational is None
assert sqrt(2).n(15).is_irrational is None
# do not automatically evalf
def teq(a):
assert (a.evalf() == a) is False
assert (a.evalf() != a) is True
assert (a == a.evalf()) is False
assert (a != a.evalf()) is True
teq(pi)
teq(2*pi)
teq(cos(0.1, evaluate=False))
# long integer
i = 12345678901234567890
assert same_and_same_prec(Float(12, ''), Float('12', ''))
assert same_and_same_prec(Float(Integer(i), ''), Float(i, ''))
assert same_and_same_prec(Float(i, ''), Float(str(i), 20))
assert same_and_same_prec(Float(str(i)), Float(i, ''))
assert same_and_same_prec(Float(i), Float(i, ''))
# inexact floats (repeating binary = denom not multiple of 2)
# cannot have precision greater than 15
assert Float(.125, 22) == .125
assert Float(2.0, 22) == 2
assert float(Float('.12500000000000001', '')) == .125
raises(ValueError, lambda: Float(.12500000000000001, ''))
# allow spaces
Float('123 456.123 456') == Float('123456.123456')
Integer('123 456') == Integer('123456')
Rational('123 456.123 456') == Rational('123456.123456')
assert Float(' .3e2') == Float('0.3e2')
# allow underscore
assert Float('1_23.4_56') == Float('123.456')
assert Float('1_23.4_5_6', 12) == Float('123.456', 12)
# ...but not in all cases (per Py 3.6)
raises(ValueError, lambda: Float('_1'))
raises(ValueError, lambda: Float('1_'))
raises(ValueError, lambda: Float('1_.'))
raises(ValueError, lambda: Float('1._'))
raises(ValueError, lambda: Float('1__2'))
raises(ValueError, lambda: Float('_inf'))
# allow auto precision detection
assert Float('.1', '') == Float(.1, 1)
assert Float('.125', '') == Float(.125, 3)
assert Float('.100', '') == Float(.1, 3)
assert Float('2.0', '') == Float('2', 2)
raises(ValueError, lambda: Float("12.3d-4", ""))
raises(ValueError, lambda: Float(12.3, ""))
raises(ValueError, lambda: Float('.'))
raises(ValueError, lambda: Float('-.'))
zero = Float('0.0')
assert Float('-0') == zero
assert Float('.0') == zero
assert Float('-.0') == zero
assert Float('-0.0') == zero
assert Float(0.0) == zero
assert Float(0) == zero
assert Float(0, '') == Float('0', '')
assert Float(1) == Float(1.0)
assert Float(S.Zero) == zero
assert Float(S.One) == Float(1.0)
assert Float(decimal.Decimal('0.1'), 3) == Float('.1', 3)
assert Float(decimal.Decimal('nan')) is S.NaN
assert Float(decimal.Decimal('Infinity')) is S.Infinity
assert Float(decimal.Decimal('-Infinity')) is S.NegativeInfinity
assert '{:.3f}'.format(Float(4.236622)) == '4.237'
assert '{:.35f}'.format(Float(pi.n(40), 40)) == \
'3.14159265358979323846264338327950288'
# unicode
assert Float('0.73908513321516064100000000') == \
Float('0.73908513321516064100000000')
assert Float('0.73908513321516064100000000', 28) == \
Float('0.73908513321516064100000000', 28)
# binary precision
# Decimal value 0.1 cannot be expressed precisely as a base 2 fraction
a = Float(S.One/10, dps=15)
b = Float(S.One/10, dps=16)
p = Float(S.One/10, precision=53)
q = Float(S.One/10, precision=54)
assert a._mpf_ == p._mpf_
assert not a._mpf_ == q._mpf_
assert not b._mpf_ == q._mpf_
# Precision specifying errors
raises(ValueError, lambda: Float("1.23", dps=3, precision=10))
raises(ValueError, lambda: Float("1.23", dps="", precision=10))
raises(ValueError, lambda: Float("1.23", dps=3, precision=""))
raises(ValueError, lambda: Float("1.23", dps="", precision=""))
# from NumberSymbol
assert same_and_same_prec(Float(pi, 32), pi.evalf(32))
assert same_and_same_prec(Float(Catalan), Catalan.evalf())
# oo and nan
u = ['inf', '-inf', 'nan', 'iNF', '+inf']
v = [oo, -oo, nan, oo, oo]
for i, a in zip(u, v):
assert Float(i) is a
@conserve_mpmath_dps
def test_float_mpf():
import mpmath
mpmath.mp.dps = 100
mp_pi = mpmath.pi()
assert Float(mp_pi, 100) == Float(mp_pi._mpf_, 100) == pi.evalf(100)
mpmath.mp.dps = 15
assert Float(mp_pi, 100) == Float(mp_pi._mpf_, 100) == pi.evalf(100)
def test_Float_RealElement():
repi = RealField(dps=100)(pi.evalf(100))
# We still have to pass the precision because Float doesn't know what
# RealElement is, but make sure it keeps full precision from the result.
assert Float(repi, 100) == pi.evalf(100)
def test_Float_default_to_highprec_from_str():
s = str(pi.evalf(128))
assert same_and_same_prec(Float(s), Float(s, ''))
def test_Float_eval():
a = Float(3.2)
assert (a**2).is_Float
def test_Float_issue_2107():
a = Float(0.1, 10)
b = Float("0.1", 10)
assert a - a == 0
assert a + (-a) == 0
assert S.Zero + a - a == 0
assert S.Zero + a + (-a) == 0
assert b - b == 0
assert b + (-b) == 0
assert S.Zero + b - b == 0
assert S.Zero + b + (-b) == 0
def test_issue_14289():
from sympy.polys.numberfields import to_number_field
a = 1 - sqrt(2)
b = to_number_field(a)
assert b.as_expr() == a
assert b.minpoly(a).expand() == 0
def test_Float_from_tuple():
a = Float((0, '1L', 0, 1))
b = Float((0, '1', 0, 1))
assert a == b
def test_Infinity():
assert oo != 1
assert 1*oo is oo
assert 1 != oo
assert oo != -oo
assert oo != Symbol("x")**3
assert oo + 1 is oo
assert 2 + oo is oo
assert 3*oo + 2 is oo
assert S.Half**oo == 0
assert S.Half**(-oo) is oo
assert -oo*3 is -oo
assert oo + oo is oo
assert -oo + oo*(-5) is -oo
assert 1/oo == 0
assert 1/(-oo) == 0
assert 8/oo == 0
assert oo % 2 is nan
assert 2 % oo is nan
assert oo/oo is nan
assert oo/-oo is nan
assert -oo/oo is nan
assert -oo/-oo is nan
assert oo - oo is nan
assert oo - -oo is oo
assert -oo - oo is -oo
assert -oo - -oo is nan
assert oo + -oo is nan
assert -oo + oo is nan
assert oo + oo is oo
assert -oo + oo is nan
assert oo + -oo is nan
assert -oo + -oo is -oo
assert oo*oo is oo
assert -oo*oo is -oo
assert oo*-oo is -oo
assert -oo*-oo is oo
assert oo/0 is oo
assert -oo/0 is -oo
assert 0/oo == 0
assert 0/-oo == 0
assert oo*0 is nan
assert -oo*0 is nan
assert 0*oo is nan
assert 0*-oo is nan
assert oo + 0 is oo
assert -oo + 0 is -oo
assert 0 + oo is oo
assert 0 + -oo is -oo
assert oo - 0 is oo
assert -oo - 0 is -oo
assert 0 - oo is -oo
assert 0 - -oo is oo
assert oo/2 is oo
assert -oo/2 is -oo
assert oo/-2 is -oo
assert -oo/-2 is oo
assert oo*2 is oo
assert -oo*2 is -oo
assert oo*-2 is -oo
assert 2/oo == 0
assert 2/-oo == 0
assert -2/oo == 0
assert -2/-oo == 0
assert 2*oo is oo
assert 2*-oo is -oo
assert -2*oo is -oo
assert -2*-oo is oo
assert 2 + oo is oo
assert 2 - oo is -oo
assert -2 + oo is oo
assert -2 - oo is -oo
assert 2 + -oo is -oo
assert 2 - -oo is oo
assert -2 + -oo is -oo
assert -2 - -oo is oo
assert S(2) + oo is oo
assert S(2) - oo is -oo
assert oo/I == -oo*I
assert -oo/I == oo*I
assert oo*float(1) == _inf and (oo*float(1)) is oo
assert -oo*float(1) == _ninf and (-oo*float(1)) is -oo
assert oo/float(1) == _inf and (oo/float(1)) is oo
assert -oo/float(1) == _ninf and (-oo/float(1)) is -oo
assert oo*float(-1) == _ninf and (oo*float(-1)) is -oo
assert -oo*float(-1) == _inf and (-oo*float(-1)) is oo
assert oo/float(-1) == _ninf and (oo/float(-1)) is -oo
assert -oo/float(-1) == _inf and (-oo/float(-1)) is oo
assert oo + float(1) == _inf and (oo + float(1)) is oo
assert -oo + float(1) == _ninf and (-oo + float(1)) is -oo
assert oo - float(1) == _inf and (oo - float(1)) is oo
assert -oo - float(1) == _ninf and (-oo - float(1)) is -oo
assert float(1)*oo == _inf and (float(1)*oo) is oo
assert float(1)*-oo == _ninf and (float(1)*-oo) is -oo
assert float(1)/oo == 0
assert float(1)/-oo == 0
assert float(-1)*oo == _ninf and (float(-1)*oo) is -oo
assert float(-1)*-oo == _inf and (float(-1)*-oo) is oo
assert float(-1)/oo == 0
assert float(-1)/-oo == 0
assert float(1) + oo is oo
assert float(1) + -oo is -oo
assert float(1) - oo is -oo
assert float(1) - -oo is oo
assert oo == float(oo)
assert (oo != float(oo)) is False
assert type(float(oo)) is float
assert -oo == float(-oo)
assert (-oo != float(-oo)) is False
assert type(float(-oo)) is float
assert Float('nan') is nan
assert nan*1.0 is nan
assert -1.0*nan is nan
assert nan*oo is nan
assert nan*-oo is nan
assert nan/oo is nan
assert nan/-oo is nan
assert nan + oo is nan
assert nan + -oo is nan
assert nan - oo is nan
assert nan - -oo is nan
assert -oo * S.Zero is nan
assert oo*nan is nan
assert -oo*nan is nan
assert oo/nan is nan
assert -oo/nan is nan
assert oo + nan is nan
assert -oo + nan is nan
assert oo - nan is nan
assert -oo - nan is nan
assert S.Zero * oo is nan
assert oo.is_Rational is False
assert isinstance(oo, Rational) is False
assert S.One/oo == 0
assert -S.One/oo == 0
assert S.One/-oo == 0
assert -S.One/-oo == 0
assert S.One*oo is oo
assert -S.One*oo is -oo
assert S.One*-oo is -oo
assert -S.One*-oo is oo
assert S.One/nan is nan
assert S.One - -oo is oo
assert S.One + nan is nan
assert S.One - nan is nan
assert nan - S.One is nan
assert nan/S.One is nan
assert -oo - S.One is -oo
def test_Infinity_2():
x = Symbol('x')
assert oo*x != oo
assert oo*(pi - 1) is oo
assert oo*(1 - pi) is -oo
assert (-oo)*x != -oo
assert (-oo)*(pi - 1) is -oo
assert (-oo)*(1 - pi) is oo
assert (-1)**S.NaN is S.NaN
assert oo - _inf is S.NaN
assert oo + _ninf is S.NaN
assert oo*0 is S.NaN
assert oo/_inf is S.NaN
assert oo/_ninf is S.NaN
assert oo**S.NaN is S.NaN
assert -oo + _inf is S.NaN
assert -oo - _ninf is S.NaN
assert -oo*S.NaN is S.NaN
assert -oo*0 is S.NaN
assert -oo/_inf is S.NaN
assert -oo/_ninf is S.NaN
assert -oo/S.NaN is S.NaN
assert abs(-oo) is oo
assert all((-oo)**i is S.NaN for i in (oo, -oo, S.NaN))
assert (-oo)**3 is -oo
assert (-oo)**2 is oo
assert abs(S.ComplexInfinity) is oo
def test_Mul_Infinity_Zero():
assert Float(0)*_inf is nan
assert Float(0)*_ninf is nan
assert Float(0)*_inf is nan
assert Float(0)*_ninf is nan
assert _inf*Float(0) is nan
assert _ninf*Float(0) is nan
assert _inf*Float(0) is nan
assert _ninf*Float(0) is nan
def test_Div_By_Zero():
assert 1/S.Zero is zoo
assert 1/Float(0) is zoo
assert 0/S.Zero is nan
assert 0/Float(0) is nan
assert S.Zero/0 is nan
assert Float(0)/0 is nan
assert -1/S.Zero is zoo
assert -1/Float(0) is zoo
def test_Infinity_inequations():
assert oo > pi
assert not (oo < pi)
assert exp(-3) < oo
assert _inf > pi
assert not (_inf < pi)
assert exp(-3) < _inf
raises(TypeError, lambda: oo < I)
raises(TypeError, lambda: oo <= I)
raises(TypeError, lambda: oo > I)
raises(TypeError, lambda: oo >= I)
raises(TypeError, lambda: -oo < I)
raises(TypeError, lambda: -oo <= I)
raises(TypeError, lambda: -oo > I)
raises(TypeError, lambda: -oo >= I)
raises(TypeError, lambda: I < oo)
raises(TypeError, lambda: I <= oo)
raises(TypeError, lambda: I > oo)
raises(TypeError, lambda: I >= oo)
raises(TypeError, lambda: I < -oo)
raises(TypeError, lambda: I <= -oo)
raises(TypeError, lambda: I > -oo)
raises(TypeError, lambda: I >= -oo)
assert oo > -oo and oo >= -oo
assert (oo < -oo) == False and (oo <= -oo) == False
assert -oo < oo and -oo <= oo
assert (-oo > oo) == False and (-oo >= oo) == False
assert (oo < oo) == False # issue 7775
assert (oo > oo) == False
assert (-oo > -oo) == False and (-oo < -oo) == False
assert oo >= oo and oo <= oo and -oo >= -oo and -oo <= -oo
assert (-oo < -_inf) == False
assert (oo > _inf) == False
assert -oo >= -_inf
assert oo <= _inf
x = Symbol('x')
b = Symbol('b', finite=True, real=True)
assert (x < oo) == Lt(x, oo) # issue 7775
assert b < oo and b > -oo and b <= oo and b >= -oo
assert oo > b and oo >= b and (oo < b) == False and (oo <= b) == False
assert (-oo > b) == False and (-oo >= b) == False and -oo < b and -oo <= b
assert (oo < x) == Lt(oo, x) and (oo > x) == Gt(oo, x)
assert (oo <= x) == Le(oo, x) and (oo >= x) == Ge(oo, x)
assert (-oo < x) == Lt(-oo, x) and (-oo > x) == Gt(-oo, x)
assert (-oo <= x) == Le(-oo, x) and (-oo >= x) == Ge(-oo, x)
def test_NaN():
assert nan is nan
assert nan != 1
assert 1*nan is nan
assert 1 != nan
assert -nan is nan
assert oo != Symbol("x")**3
assert 2 + nan is nan
assert 3*nan + 2 is nan
assert -nan*3 is nan
assert nan + nan is nan
assert -nan + nan*(-5) is nan
assert 8/nan is nan
raises(TypeError, lambda: nan > 0)
raises(TypeError, lambda: nan < 0)
raises(TypeError, lambda: nan >= 0)
raises(TypeError, lambda: nan <= 0)
raises(TypeError, lambda: 0 < nan)
raises(TypeError, lambda: 0 > nan)
raises(TypeError, lambda: 0 <= nan)
raises(TypeError, lambda: 0 >= nan)
assert nan**0 == 1 # as per IEEE 754
assert 1**nan is nan # IEEE 754 is not the best choice for symbolic work
# test Pow._eval_power's handling of NaN
assert Pow(nan, 0, evaluate=False)**2 == 1
for n in (1, 1., S.One, S.NegativeOne, Float(1)):
assert n + nan is nan
assert n - nan is nan
assert nan + n is nan
assert nan - n is nan
assert n/nan is nan
assert nan/n is nan
def test_special_numbers():
assert isinstance(S.NaN, Number) is True
assert isinstance(S.Infinity, Number) is True
assert isinstance(S.NegativeInfinity, Number) is True
assert S.NaN.is_number is True
assert S.Infinity.is_number is True
assert S.NegativeInfinity.is_number is True
assert S.ComplexInfinity.is_number is True
assert isinstance(S.NaN, Rational) is False
assert isinstance(S.Infinity, Rational) is False
assert isinstance(S.NegativeInfinity, Rational) is False
assert S.NaN.is_rational is not True
assert S.Infinity.is_rational is not True
assert S.NegativeInfinity.is_rational is not True
def test_powers():
assert integer_nthroot(1, 2) == (1, True)
assert integer_nthroot(1, 5) == (1, True)
assert integer_nthroot(2, 1) == (2, True)
assert integer_nthroot(2, 2) == (1, False)
assert integer_nthroot(2, 5) == (1, False)
assert integer_nthroot(4, 2) == (2, True)
assert integer_nthroot(123**25, 25) == (123, True)
assert integer_nthroot(123**25 + 1, 25) == (123, False)
assert integer_nthroot(123**25 - 1, 25) == (122, False)
assert integer_nthroot(1, 1) == (1, True)
assert integer_nthroot(0, 1) == (0, True)
assert integer_nthroot(0, 3) == (0, True)
assert integer_nthroot(10000, 1) == (10000, True)
assert integer_nthroot(4, 2) == (2, True)
assert integer_nthroot(16, 2) == (4, True)
assert integer_nthroot(26, 2) == (5, False)
assert integer_nthroot(1234567**7, 7) == (1234567, True)
assert integer_nthroot(1234567**7 + 1, 7) == (1234567, False)
assert integer_nthroot(1234567**7 - 1, 7) == (1234566, False)
b = 25**1000
assert integer_nthroot(b, 1000) == (25, True)
assert integer_nthroot(b + 1, 1000) == (25, False)
assert integer_nthroot(b - 1, 1000) == (24, False)
c = 10**400
c2 = c**2
assert integer_nthroot(c2, 2) == (c, True)
assert integer_nthroot(c2 + 1, 2) == (c, False)
assert integer_nthroot(c2 - 1, 2) == (c - 1, False)
assert integer_nthroot(2, 10**10) == (1, False)
p, r = integer_nthroot(int(factorial(10000)), 100)
assert p % (10**10) == 5322420655
assert not r
# Test that this is fast
assert integer_nthroot(2, 10**10) == (1, False)
# output should be int if possible
assert type(integer_nthroot(2**61, 2)[0]) is int
def test_integer_nthroot_overflow():
assert integer_nthroot(10**(50*50), 50) == (10**50, True)
assert integer_nthroot(10**100000, 10000) == (10**10, True)
def test_integer_log():
raises(ValueError, lambda: integer_log(2, 1))
raises(ValueError, lambda: integer_log(0, 2))
raises(ValueError, lambda: integer_log(1.1, 2))
raises(ValueError, lambda: integer_log(1, 2.2))
assert integer_log(1, 2) == (0, True)
assert integer_log(1, 3) == (0, True)
assert integer_log(2, 3) == (0, False)
assert integer_log(3, 3) == (1, True)
assert integer_log(3*2, 3) == (1, False)
assert integer_log(3**2, 3) == (2, True)
assert integer_log(3*4, 3) == (2, False)
assert integer_log(3**3, 3) == (3, True)
assert integer_log(27, 5) == (2, False)
assert integer_log(2, 3) == (0, False)
assert integer_log(-4, -2) == (2, False)
assert integer_log(27, -3) == (3, False)
assert integer_log(-49, 7) == (0, False)
assert integer_log(-49, -7) == (2, False)
def test_isqrt():
from math import sqrt as _sqrt
limit = 4503599761588223
assert int(_sqrt(limit)) == integer_nthroot(limit, 2)[0]
assert int(_sqrt(limit + 1)) != integer_nthroot(limit + 1, 2)[0]
assert isqrt(limit + 1) == integer_nthroot(limit + 1, 2)[0]
assert isqrt(limit + S.Half) == integer_nthroot(limit, 2)[0]
assert isqrt(limit + 1 + S.Half) == integer_nthroot(limit + 1, 2)[0]
assert isqrt(limit + 2 + S.Half) == integer_nthroot(limit + 2, 2)[0]
# Regression tests for https://github.com/sympy/sympy/issues/17034
assert isqrt(4503599761588224) == 67108864
assert isqrt(9999999999999999) == 99999999
# Other corner cases, especially involving non-integers.
raises(ValueError, lambda: isqrt(-1))
raises(ValueError, lambda: isqrt(-10**1000))
raises(ValueError, lambda: isqrt(Rational(-1, 2)))
tiny = Rational(1, 10**1000)
raises(ValueError, lambda: isqrt(-tiny))
assert isqrt(1-tiny) == 0
assert isqrt(4503599761588224-tiny) == 67108864
assert isqrt(10**100 - tiny) == 10**50 - 1
# Check that using an inaccurate math.sqrt doesn't affect the results.
from sympy.core import power
old_sqrt = power._sqrt
power._sqrt = lambda x: 2.999999999
try:
assert isqrt(9) == 3
assert isqrt(10000) == 100
finally:
power._sqrt = old_sqrt
def test_powers_Integer():
"""Test Integer._eval_power"""
# check infinity
assert S.One ** S.Infinity is S.NaN
assert S.NegativeOne** S.Infinity is S.NaN
assert S(2) ** S.Infinity is S.Infinity
assert S(-2)** S.Infinity == S.Infinity + S.Infinity * S.ImaginaryUnit
assert S(0) ** S.Infinity is S.Zero
# check Nan
assert S.One ** S.NaN is S.NaN
assert S.NegativeOne ** S.NaN is S.NaN
# check for exact roots
assert S.NegativeOne ** Rational(6, 5) == - (-1)**(S.One/5)
assert sqrt(S(4)) == 2
assert sqrt(S(-4)) == I * 2
assert S(16) ** Rational(1, 4) == 2
assert S(-16) ** Rational(1, 4) == 2 * (-1)**Rational(1, 4)
assert S(9) ** Rational(3, 2) == 27
assert S(-9) ** Rational(3, 2) == -27*I
assert S(27) ** Rational(2, 3) == 9
assert S(-27) ** Rational(2, 3) == 9 * (S.NegativeOne ** Rational(2, 3))
assert (-2) ** Rational(-2, 1) == Rational(1, 4)
# not exact roots
assert sqrt(-3) == I*sqrt(3)
assert (3) ** (Rational(3, 2)) == 3 * sqrt(3)
assert (-3) ** (Rational(3, 2)) == - 3 * sqrt(-3)
assert (-3) ** (Rational(5, 2)) == 9 * I * sqrt(3)
assert (-3) ** (Rational(7, 2)) == - I * 27 * sqrt(3)
assert (2) ** (Rational(3, 2)) == 2 * sqrt(2)
assert (2) ** (Rational(-3, 2)) == sqrt(2) / 4
assert (81) ** (Rational(2, 3)) == 9 * (S(3) ** (Rational(2, 3)))
assert (-81) ** (Rational(2, 3)) == 9 * (S(-3) ** (Rational(2, 3)))
assert (-3) ** Rational(-7, 3) == \
-(-1)**Rational(2, 3)*3**Rational(2, 3)/27
assert (-3) ** Rational(-2, 3) == \
-(-1)**Rational(1, 3)*3**Rational(1, 3)/3
# join roots
assert sqrt(6) + sqrt(24) == 3*sqrt(6)
assert sqrt(2) * sqrt(3) == sqrt(6)
# separate symbols & constansts
x = Symbol("x")
assert sqrt(49 * x) == 7 * sqrt(x)
assert sqrt((3 - sqrt(pi)) ** 2) == 3 - sqrt(pi)
# check that it is fast for big numbers
assert (2**64 + 1) ** Rational(4, 3)
assert (2**64 + 1) ** Rational(17, 25)
# negative rational power and negative base
assert (-3) ** Rational(-7, 3) == \
-(-1)**Rational(2, 3)*3**Rational(2, 3)/27
assert (-3) ** Rational(-2, 3) == \
-(-1)**Rational(1, 3)*3**Rational(1, 3)/3
assert (-2) ** Rational(-10, 3) == \
(-1)**Rational(2, 3)*2**Rational(2, 3)/16
assert abs(Pow(-2, Rational(-10, 3)).n() -
Pow(-2, Rational(-10, 3), evaluate=False).n()) < 1e-16
# negative base and rational power with some simplification
assert (-8) ** Rational(2, 5) == \
2*(-1)**Rational(2, 5)*2**Rational(1, 5)
assert (-4) ** Rational(9, 5) == \
-8*(-1)**Rational(4, 5)*2**Rational(3, 5)
assert S(1234).factors() == {617: 1, 2: 1}
assert Rational(2*3, 3*5*7).factors() == {2: 1, 5: -1, 7: -1}
# test that eval_power factors numbers bigger than
# the current limit in factor_trial_division (2**15)
from sympy import nextprime
n = nextprime(2**15)
assert sqrt(n**2) == n
assert sqrt(n**3) == n*sqrt(n)
assert sqrt(4*n) == 2*sqrt(n)
# check that factors of base with powers sharing gcd with power are removed
assert (2**4*3)**Rational(1, 6) == 2**Rational(2, 3)*3**Rational(1, 6)
assert (2**4*3)**Rational(5, 6) == 8*2**Rational(1, 3)*3**Rational(5, 6)
# check that bases sharing a gcd are exptracted
assert 2**Rational(1, 3)*3**Rational(1, 4)*6**Rational(1, 5) == \
2**Rational(8, 15)*3**Rational(9, 20)
assert sqrt(8)*24**Rational(1, 3)*6**Rational(1, 5) == \
4*2**Rational(7, 10)*3**Rational(8, 15)
assert sqrt(8)*(-24)**Rational(1, 3)*(-6)**Rational(1, 5) == \
4*(-3)**Rational(8, 15)*2**Rational(7, 10)
assert 2**Rational(1, 3)*2**Rational(8, 9) == 2*2**Rational(2, 9)
assert 2**Rational(2, 3)*6**Rational(1, 3) == 2*3**Rational(1, 3)
assert 2**Rational(2, 3)*6**Rational(8, 9) == \
2*2**Rational(5, 9)*3**Rational(8, 9)
assert (-2)**Rational(2, S(3))*(-4)**Rational(1, S(3)) == -2*2**Rational(1, 3)
assert 3*Pow(3, 2, evaluate=False) == 3**3
assert 3*Pow(3, Rational(-1, 3), evaluate=False) == 3**Rational(2, 3)
assert (-2)**Rational(1, 3)*(-3)**Rational(1, 4)*(-5)**Rational(5, 6) == \
-(-1)**Rational(5, 12)*2**Rational(1, 3)*3**Rational(1, 4) * \
5**Rational(5, 6)
assert Integer(-2)**Symbol('', even=True) == \
Integer(2)**Symbol('', even=True)
assert (-1)**Float(.5) == 1.0*I
def test_powers_Rational():
"""Test Rational._eval_power"""
# check infinity
assert S.Half ** S.Infinity == 0
assert Rational(3, 2) ** S.Infinity is S.Infinity
assert Rational(-1, 2) ** S.Infinity == 0
assert Rational(-3, 2) ** S.Infinity == \
S.Infinity + S.Infinity * S.ImaginaryUnit
# check Nan
assert Rational(3, 4) ** S.NaN is S.NaN
assert Rational(-2, 3) ** S.NaN is S.NaN
# exact roots on numerator
assert sqrt(Rational(4, 3)) == 2 * sqrt(3) / 3
assert Rational(4, 3) ** Rational(3, 2) == 8 * sqrt(3) / 9
assert sqrt(Rational(-4, 3)) == I * 2 * sqrt(3) / 3
assert Rational(-4, 3) ** Rational(3, 2) == - I * 8 * sqrt(3) / 9
assert Rational(27, 2) ** Rational(1, 3) == 3 * (2 ** Rational(2, 3)) / 2
assert Rational(5**3, 8**3) ** Rational(4, 3) == Rational(5**4, 8**4)
# exact root on denominator
assert sqrt(Rational(1, 4)) == S.Half
assert sqrt(Rational(1, -4)) == I * S.Half
assert sqrt(Rational(3, 4)) == sqrt(3) / 2
assert sqrt(Rational(3, -4)) == I * sqrt(3) / 2
assert Rational(5, 27) ** Rational(1, 3) == (5 ** Rational(1, 3)) / 3
# not exact roots
assert sqrt(S.Half) == sqrt(2) / 2
assert sqrt(Rational(-4, 7)) == I * sqrt(Rational(4, 7))
assert Rational(-3, 2)**Rational(-7, 3) == \
-4*(-1)**Rational(2, 3)*2**Rational(1, 3)*3**Rational(2, 3)/27
assert Rational(-3, 2)**Rational(-2, 3) == \
-(-1)**Rational(1, 3)*2**Rational(2, 3)*3**Rational(1, 3)/3
assert Rational(-3, 2)**Rational(-10, 3) == \
8*(-1)**Rational(2, 3)*2**Rational(1, 3)*3**Rational(2, 3)/81
assert abs(Pow(Rational(-2, 3), Rational(-7, 4)).n() -
Pow(Rational(-2, 3), Rational(-7, 4), evaluate=False).n()) < 1e-16
# negative integer power and negative rational base
assert Rational(-2, 3) ** Rational(-2, 1) == Rational(9, 4)
a = Rational(1, 10)
assert a**Float(a, 2) == Float(a, 2)**Float(a, 2)
assert Rational(-2, 3)**Symbol('', even=True) == \
Rational(2, 3)**Symbol('', even=True)
def test_powers_Float():
assert str((S('-1/10')**S('3/10')).n()) == str(Float(-.1)**(.3))
def test_abs1():
assert Rational(1, 6) != Rational(-1, 6)
assert abs(Rational(1, 6)) == abs(Rational(-1, 6))
def test_accept_int():
assert Float(4) == 4
def test_dont_accept_str():
assert Float("0.2") != "0.2"
assert not (Float("0.2") == "0.2")
def test_int():
a = Rational(5)
assert int(a) == 5
a = Rational(9, 10)
assert int(a) == int(-a) == 0
assert 1/(-1)**Rational(2, 3) == -(-1)**Rational(1, 3)
assert int(pi) == 3
assert int(E) == 2
assert int(GoldenRatio) == 1
assert int(TribonacciConstant) == 2
# issue 10368
a = Rational(32442016954, 78058255275)
assert type(int(a)) is type(int(-a)) is int
def test_real_bug():
x = Symbol("x")
assert str(2.0*x*x) in ["(2.0*x)*x", "2.0*x**2", "2.00000000000000*x**2"]
assert str(2.1*x*x) != "(2.0*x)*x"
def test_bug_sqrt():
assert ((sqrt(Rational(2)) + 1)*(sqrt(Rational(2)) - 1)).expand() == 1
def test_pi_Pi():
"Test that pi (instance) is imported, but Pi (class) is not"
from sympy import pi # noqa
with raises(ImportError):
from sympy import Pi # noqa
def test_no_len():
# there should be no len for numbers
raises(TypeError, lambda: len(Rational(2)))
raises(TypeError, lambda: len(Rational(2, 3)))
raises(TypeError, lambda: len(Integer(2)))
def test_issue_3321():
assert sqrt(Rational(1, 5)) == Rational(1, 5)**S.Half
assert 5 * sqrt(Rational(1, 5)) == sqrt(5)
def test_issue_3692():
assert ((-1)**Rational(1, 6)).expand(complex=True) == I/2 + sqrt(3)/2
assert ((-5)**Rational(1, 6)).expand(complex=True) == \
5**Rational(1, 6)*I/2 + 5**Rational(1, 6)*sqrt(3)/2
assert ((-64)**Rational(1, 6)).expand(complex=True) == I + sqrt(3)
def test_issue_3423():
x = Symbol("x")
assert sqrt(x - 1).as_base_exp() == (x - 1, S.Half)
assert sqrt(x - 1) != I*sqrt(1 - x)
def test_issue_3449():
x = Symbol("x")
assert sqrt(x - 1).subs(x, 5) == 2
def test_issue_13890():
x = Symbol("x")
e = (-x/4 - S.One/12)**x - 1
f = simplify(e)
a = Rational(9, 5)
assert abs(e.subs(x,a).evalf() - f.subs(x,a).evalf()) < 1e-15
def test_Integer_factors():
def F(i):
return Integer(i).factors()
assert F(1) == {}
assert F(2) == {2: 1}
assert F(3) == {3: 1}
assert F(4) == {2: 2}
assert F(5) == {5: 1}
assert F(6) == {2: 1, 3: 1}
assert F(7) == {7: 1}
assert F(8) == {2: 3}
assert F(9) == {3: 2}
assert F(10) == {2: 1, 5: 1}
assert F(11) == {11: 1}
assert F(12) == {2: 2, 3: 1}
assert F(13) == {13: 1}
assert F(14) == {2: 1, 7: 1}
assert F(15) == {3: 1, 5: 1}
assert F(16) == {2: 4}
assert F(17) == {17: 1}
assert F(18) == {2: 1, 3: 2}
assert F(19) == {19: 1}
assert F(20) == {2: 2, 5: 1}
assert F(21) == {3: 1, 7: 1}
assert F(22) == {2: 1, 11: 1}
assert F(23) == {23: 1}
assert F(24) == {2: 3, 3: 1}
assert F(25) == {5: 2}
assert F(26) == {2: 1, 13: 1}
assert F(27) == {3: 3}
assert F(28) == {2: 2, 7: 1}
assert F(29) == {29: 1}
assert F(30) == {2: 1, 3: 1, 5: 1}
assert F(31) == {31: 1}
assert F(32) == {2: 5}
assert F(33) == {3: 1, 11: 1}
assert F(34) == {2: 1, 17: 1}
assert F(35) == {5: 1, 7: 1}
assert F(36) == {2: 2, 3: 2}
assert F(37) == {37: 1}
assert F(38) == {2: 1, 19: 1}
assert F(39) == {3: 1, 13: 1}
assert F(40) == {2: 3, 5: 1}
assert F(41) == {41: 1}
assert F(42) == {2: 1, 3: 1, 7: 1}
assert F(43) == {43: 1}
assert F(44) == {2: 2, 11: 1}
assert F(45) == {3: 2, 5: 1}
assert F(46) == {2: 1, 23: 1}
assert F(47) == {47: 1}
assert F(48) == {2: 4, 3: 1}
assert F(49) == {7: 2}
assert F(50) == {2: 1, 5: 2}
assert F(51) == {3: 1, 17: 1}
def test_Rational_factors():
def F(p, q, visual=None):
return Rational(p, q).factors(visual=visual)
assert F(2, 3) == {2: 1, 3: -1}
assert F(2, 9) == {2: 1, 3: -2}
assert F(2, 15) == {2: 1, 3: -1, 5: -1}
assert F(6, 10) == {3: 1, 5: -1}
def test_issue_4107():
assert pi*(E + 10) + pi*(-E - 10) != 0
assert pi*(E + 10**10) + pi*(-E - 10**10) != 0
assert pi*(E + 10**20) + pi*(-E - 10**20) != 0
assert pi*(E + 10**80) + pi*(-E - 10**80) != 0
assert (pi*(E + 10) + pi*(-E - 10)).expand() == 0
assert (pi*(E + 10**10) + pi*(-E - 10**10)).expand() == 0
assert (pi*(E + 10**20) + pi*(-E - 10**20)).expand() == 0
assert (pi*(E + 10**80) + pi*(-E - 10**80)).expand() == 0
def test_IntegerInteger():
a = Integer(4)
b = Integer(a)
assert a == b
def test_Rational_gcd_lcm_cofactors():
assert Integer(4).gcd(2) == Integer(2)
assert Integer(4).lcm(2) == Integer(4)
assert Integer(4).gcd(Integer(2)) == Integer(2)
assert Integer(4).lcm(Integer(2)) == Integer(4)
a, b = 720**99911, 480**12342
assert Integer(a).lcm(b) == a*b/Integer(a).gcd(b)
assert Integer(4).gcd(3) == Integer(1)
assert Integer(4).lcm(3) == Integer(12)
assert Integer(4).gcd(Integer(3)) == Integer(1)
assert Integer(4).lcm(Integer(3)) == Integer(12)
assert Rational(4, 3).gcd(2) == Rational(2, 3)
assert Rational(4, 3).lcm(2) == Integer(4)
assert Rational(4, 3).gcd(Integer(2)) == Rational(2, 3)
assert Rational(4, 3).lcm(Integer(2)) == Integer(4)
assert Integer(4).gcd(Rational(2, 9)) == Rational(2, 9)
assert Integer(4).lcm(Rational(2, 9)) == Integer(4)
assert Rational(4, 3).gcd(Rational(2, 9)) == Rational(2, 9)
assert Rational(4, 3).lcm(Rational(2, 9)) == Rational(4, 3)
assert Rational(4, 5).gcd(Rational(2, 9)) == Rational(2, 45)
assert Rational(4, 5).lcm(Rational(2, 9)) == Integer(4)
assert Rational(5, 9).lcm(Rational(3, 7)) == Rational(Integer(5).lcm(3),Integer(9).gcd(7))
assert Integer(4).cofactors(2) == (Integer(2), Integer(2), Integer(1))
assert Integer(4).cofactors(Integer(2)) == \
(Integer(2), Integer(2), Integer(1))
assert Integer(4).gcd(Float(2.0)) == S.One
assert Integer(4).lcm(Float(2.0)) == Float(8.0)
assert Integer(4).cofactors(Float(2.0)) == (S.One, Integer(4), Float(2.0))
assert S.Half.gcd(Float(2.0)) == S.One
assert S.Half.lcm(Float(2.0)) == Float(1.0)
assert S.Half.cofactors(Float(2.0)) == \
(S.One, S.Half, Float(2.0))
def test_Float_gcd_lcm_cofactors():
assert Float(2.0).gcd(Integer(4)) == S.One
assert Float(2.0).lcm(Integer(4)) == Float(8.0)
assert Float(2.0).cofactors(Integer(4)) == (S.One, Float(2.0), Integer(4))
assert Float(2.0).gcd(S.Half) == S.One
assert Float(2.0).lcm(S.Half) == Float(1.0)
assert Float(2.0).cofactors(S.Half) == \
(S.One, Float(2.0), S.Half)
def test_issue_4611():
assert abs(pi._evalf(50) - 3.14159265358979) < 1e-10
assert abs(E._evalf(50) - 2.71828182845905) < 1e-10
assert abs(Catalan._evalf(50) - 0.915965594177219) < 1e-10
assert abs(EulerGamma._evalf(50) - 0.577215664901533) < 1e-10
assert abs(GoldenRatio._evalf(50) - 1.61803398874989) < 1e-10
assert abs(TribonacciConstant._evalf(50) - 1.83928675521416) < 1e-10
x = Symbol("x")
assert (pi + x).evalf() == pi.evalf() + x
assert (E + x).evalf() == E.evalf() + x
assert (Catalan + x).evalf() == Catalan.evalf() + x
assert (EulerGamma + x).evalf() == EulerGamma.evalf() + x
assert (GoldenRatio + x).evalf() == GoldenRatio.evalf() + x
assert (TribonacciConstant + x).evalf() == TribonacciConstant.evalf() + x
@conserve_mpmath_dps
def test_conversion_to_mpmath():
assert mpmath.mpmathify(Integer(1)) == mpmath.mpf(1)
assert mpmath.mpmathify(S.Half) == mpmath.mpf(0.5)
assert mpmath.mpmathify(Float('1.23', 15)) == mpmath.mpf('1.23')
assert mpmath.mpmathify(I) == mpmath.mpc(1j)
assert mpmath.mpmathify(1 + 2*I) == mpmath.mpc(1 + 2j)
assert mpmath.mpmathify(1.0 + 2*I) == mpmath.mpc(1 + 2j)
assert mpmath.mpmathify(1 + 2.0*I) == mpmath.mpc(1 + 2j)
assert mpmath.mpmathify(1.0 + 2.0*I) == mpmath.mpc(1 + 2j)
assert mpmath.mpmathify(S.Half + S.Half*I) == mpmath.mpc(0.5 + 0.5j)
assert mpmath.mpmathify(2*I) == mpmath.mpc(2j)
assert mpmath.mpmathify(2.0*I) == mpmath.mpc(2j)
assert mpmath.mpmathify(S.Half*I) == mpmath.mpc(0.5j)
mpmath.mp.dps = 100
assert mpmath.mpmathify(pi.evalf(100) + pi.evalf(100)*I) == mpmath.pi + mpmath.pi*mpmath.j
assert mpmath.mpmathify(pi.evalf(100)*I) == mpmath.pi*mpmath.j
def test_relational():
# real
x = S(.1)
assert (x != cos) is True
assert (x == cos) is False
# rational
x = Rational(1, 3)
assert (x != cos) is True
assert (x == cos) is False
# integer defers to rational so these tests are omitted
# number symbol
x = pi
assert (x != cos) is True
assert (x == cos) is False
def test_Integer_as_index():
assert 'hello'[Integer(2):] == 'llo'
def test_Rational_int():
assert int( Rational(7, 5)) == 1
assert int( S.Half) == 0
assert int(Rational(-1, 2)) == 0
assert int(-Rational(7, 5)) == -1
def test_zoo():
b = Symbol('b', finite=True)
nz = Symbol('nz', nonzero=True)
p = Symbol('p', positive=True)
n = Symbol('n', negative=True)
im = Symbol('i', imaginary=True)
c = Symbol('c', complex=True)
pb = Symbol('pb', positive=True, finite=True)
nb = Symbol('nb', negative=True, finite=True)
imb = Symbol('ib', imaginary=True, finite=True)
for i in [I, S.Infinity, S.NegativeInfinity, S.Zero, S.One, S.Pi, S.Half, S(3), log(3),
b, nz, p, n, im, pb, nb, imb, c]:
if i.is_finite and (i.is_real or i.is_imaginary):
assert i + zoo is zoo
assert i - zoo is zoo
assert zoo + i is zoo
assert zoo - i is zoo
elif i.is_finite is not False:
assert (i + zoo).is_Add
assert (i - zoo).is_Add
assert (zoo + i).is_Add
assert (zoo - i).is_Add
else:
assert (i + zoo) is S.NaN
assert (i - zoo) is S.NaN
assert (zoo + i) is S.NaN
assert (zoo - i) is S.NaN
if fuzzy_not(i.is_zero) and (i.is_extended_real or i.is_imaginary):
assert i*zoo is zoo
assert zoo*i is zoo
elif i.is_zero:
assert i*zoo is S.NaN
assert zoo*i is S.NaN
else:
assert (i*zoo).is_Mul
assert (zoo*i).is_Mul
if fuzzy_not((1/i).is_zero) and (i.is_real or i.is_imaginary):
assert zoo/i is zoo
elif (1/i).is_zero:
assert zoo/i is S.NaN
elif i.is_zero:
assert zoo/i is zoo
else:
assert (zoo/i).is_Mul
assert (I*oo).is_Mul # allow directed infinity
assert zoo + zoo is S.NaN
assert zoo * zoo is zoo
assert zoo - zoo is S.NaN
assert zoo/zoo is S.NaN
assert zoo**zoo is S.NaN
assert zoo**0 is S.One
assert zoo**2 is zoo
assert 1/zoo is S.Zero
assert Mul.flatten([S.NegativeOne, oo, S(0)]) == ([S.NaN], [], None)
def test_issue_4122():
x = Symbol('x', nonpositive=True)
assert oo + x is oo
x = Symbol('x', extended_nonpositive=True)
assert (oo + x).is_Add
x = Symbol('x', finite=True)
assert (oo + x).is_Add # x could be imaginary
x = Symbol('x', nonnegative=True)
assert oo + x is oo
x = Symbol('x', extended_nonnegative=True)
assert oo + x is oo
x = Symbol('x', finite=True, real=True)
assert oo + x is oo
# similarly for negative infinity
x = Symbol('x', nonnegative=True)
assert -oo + x is -oo
x = Symbol('x', extended_nonnegative=True)
assert (-oo + x).is_Add
x = Symbol('x', finite=True)
assert (-oo + x).is_Add
x = Symbol('x', nonpositive=True)
assert -oo + x is -oo
x = Symbol('x', extended_nonpositive=True)
assert -oo + x is -oo
x = Symbol('x', finite=True, real=True)
assert -oo + x is -oo
def test_GoldenRatio_expand():
assert GoldenRatio.expand(func=True) == S.Half + sqrt(5)/2
def test_TribonacciConstant_expand():
assert TribonacciConstant.expand(func=True) == \
(1 + cbrt(19 - 3*sqrt(33)) + cbrt(19 + 3*sqrt(33))) / 3
def test_as_content_primitive():
assert S.Zero.as_content_primitive() == (1, 0)
assert S.Half.as_content_primitive() == (S.Half, 1)
assert (Rational(-1, 2)).as_content_primitive() == (S.Half, -1)
assert S(3).as_content_primitive() == (3, 1)
assert S(3.1).as_content_primitive() == (1, 3.1)
def test_hashing_sympy_integers():
# Test for issue 5072
assert {Integer(3)} == {int(3)}
assert hash(Integer(4)) == hash(int(4))
def test_rounding_issue_4172():
assert int((E**100).round()) == \
26881171418161354484126255515800135873611119
assert int((pi**100).round()) == \
51878483143196131920862615246303013562686760680406
assert int((Rational(1)/EulerGamma**100).round()) == \
734833795660954410469466
@XFAIL
def test_mpmath_issues():
from mpmath.libmp.libmpf import _normalize
import mpmath.libmp as mlib
rnd = mlib.round_nearest
mpf = (0, int(0), -123, -1, 53, rnd) # nan
assert _normalize(mpf, 53) != (0, int(0), 0, 0)
mpf = (0, int(0), -456, -2, 53, rnd) # +inf
assert _normalize(mpf, 53) != (0, int(0), 0, 0)
mpf = (1, int(0), -789, -3, 53, rnd) # -inf
assert _normalize(mpf, 53) != (0, int(0), 0, 0)
from mpmath.libmp.libmpf import fnan
assert mlib.mpf_eq(fnan, fnan)
def test_Catalan_EulerGamma_prec():
n = GoldenRatio
f = Float(n.n(), 5)
assert f._mpf_ == (0, int(212079), -17, 18)
assert f._prec == 20
assert n._as_mpf_val(20) == f._mpf_
n = EulerGamma
f = Float(n.n(), 5)
assert f._mpf_ == (0, int(302627), -19, 19)
assert f._prec == 20
assert n._as_mpf_val(20) == f._mpf_
def test_Catalan_rewrite():
k = Dummy('k', integer=True, nonnegative=True)
assert Catalan.rewrite(Sum).dummy_eq(
Sum((-1)**k/(2*k + 1)**2, (k, 0, oo)))
assert Catalan.rewrite() == Catalan
def test_bool_eq():
assert 0 == False
assert S(0) == False
assert S(0) != S.false
assert 1 == True
assert S.One == True
assert S.One != S.true
def test_Float_eq():
# all .5 values are the same
assert Float(.5, 10) == Float(.5, 11) == Float(.5, 1)
# but floats that aren't exact in base-2 still
# don't compare the same because they have different
# underlying mpf values
assert Float(.12, 3) != Float(.12, 4)
assert Float(.12, 3) != .12
assert 0.12 != Float(.12, 3)
assert Float('.12', 22) != .12
# issue 11707
# but Float/Rational -- except for 0 --
# are exact so Rational(x) = Float(y) only if
# Rational(x) == Rational(Float(y))
assert Float('1.1') != Rational(11, 10)
assert Rational(11, 10) != Float('1.1')
# coverage
assert not Float(3) == 2
assert not Float(2**2) == S.Half
assert Float(2**2) == 4
assert not Float(2**-2) == 1
assert Float(2**-1) == S.Half
assert not Float(2*3) == 3
assert not Float(2*3) == S.Half
assert Float(2*3) == 6
assert not Float(2*3) == 8
assert Float(.75) == Rational(3, 4)
assert Float(5/18) == 5/18
# 4473
assert Float(2.) != 3
assert Float((0,1,-3)) == S.One/8
assert Float((0,1,-3)) != S.One/9
# 16196
assert 2 == Float(2) # as per Python
# but in a computation...
assert t**2 != t**2.0
def test_int_NumberSymbols():
assert [int(i) for i in [pi, EulerGamma, E, GoldenRatio, Catalan]] == \
[3, 0, 2, 1, 0]
def test_issue_6640():
from mpmath.libmp.libmpf import finf, fninf
# fnan is not included because Float no longer returns fnan,
# but otherwise, the same sort of test could apply
assert Float(finf).is_zero is False
assert Float(fninf).is_zero is False
assert bool(Float(0)) is False
def test_issue_6349():
assert Float('23.e3', '')._prec == 10
assert Float('23e3', '')._prec == 20
assert Float('23000', '')._prec == 20
assert Float('-23000', '')._prec == 20
def test_mpf_norm():
assert mpf_norm((1, 0, 1, 0), 10) == mpf('0')._mpf_
assert Float._new((1, 0, 1, 0), 10)._mpf_ == mpf('0')._mpf_
def test_latex():
assert latex(pi) == r"\pi"
assert latex(E) == r"e"
assert latex(GoldenRatio) == r"\phi"
assert latex(TribonacciConstant) == r"\text{TribonacciConstant}"
assert latex(EulerGamma) == r"\gamma"
assert latex(oo) == r"\infty"
assert latex(-oo) == r"-\infty"
assert latex(zoo) == r"\tilde{\infty}"
assert latex(nan) == r"\text{NaN}"
assert latex(I) == r"i"
def test_issue_7742():
assert -oo % 1 is nan
def test_simplify_AlgebraicNumber():
A = AlgebraicNumber
e = 3**(S.One/6)*(3 + (135 + 78*sqrt(3))**Rational(2, 3))/(45 + 26*sqrt(3))**(S.One/3)
assert simplify(A(e)) == A(12) # wester test_C20
e = (41 + 29*sqrt(2))**(S.One/5)
assert simplify(A(e)) == A(1 + sqrt(2)) # wester test_C21
e = (3 + 4*I)**Rational(3, 2)
assert simplify(A(e)) == A(2 + 11*I) # issue 4401
def test_Float_idempotence():
x = Float('1.23', '')
y = Float(x)
z = Float(x, 15)
assert same_and_same_prec(y, x)
assert not same_and_same_prec(z, x)
x = Float(10**20)
y = Float(x)
z = Float(x, 15)
assert same_and_same_prec(y, x)
assert not same_and_same_prec(z, x)
def test_comp1():
# sqrt(2) = 1.414213 5623730950...
a = sqrt(2).n(7)
assert comp(a, 1.4142129) is False
assert comp(a, 1.4142130)
# ...
assert comp(a, 1.4142141)
assert comp(a, 1.4142142) is False
assert comp(sqrt(2).n(2), '1.4')
assert comp(sqrt(2).n(2), Float(1.4, 2), '')
assert comp(sqrt(2).n(2), 1.4, '')
assert comp(sqrt(2).n(2), Float(1.4, 3), '') is False
assert comp(sqrt(2) + sqrt(3)*I, 1.4 + 1.7*I, .1)
assert not comp(sqrt(2) + sqrt(3)*I, (1.5 + 1.7*I)*0.89, .1)
assert comp(sqrt(2) + sqrt(3)*I, (1.5 + 1.7*I)*0.90, .1)
assert comp(sqrt(2) + sqrt(3)*I, (1.5 + 1.7*I)*1.07, .1)
assert not comp(sqrt(2) + sqrt(3)*I, (1.5 + 1.7*I)*1.08, .1)
assert [(i, j)
for i in range(130, 150)
for j in range(170, 180)
if comp((sqrt(2)+ I*sqrt(3)).n(3), i/100. + I*j/100.)] == [
(141, 173), (142, 173)]
raises(ValueError, lambda: comp(t, '1'))
raises(ValueError, lambda: comp(t, 1))
assert comp(0, 0.0)
assert comp(.5, S.Half)
assert comp(2 + sqrt(2), 2.0 + sqrt(2))
assert not comp(0, 1)
assert not comp(2, sqrt(2))
assert not comp(2 + I, 2.0 + sqrt(2))
assert not comp(2.0 + sqrt(2), 2 + I)
assert not comp(2.0 + sqrt(2), sqrt(3))
assert comp(1/pi.n(4), 0.3183, 1e-5)
assert not comp(1/pi.n(4), 0.3183, 8e-6)
def test_issue_9491():
assert oo**zoo is nan
def test_issue_10063():
assert 2**Float(3) == Float(8)
def test_issue_10020():
assert oo**I is S.NaN
assert oo**(1 + I) is S.ComplexInfinity
assert oo**(-1 + I) is S.Zero
assert (-oo)**I is S.NaN
assert (-oo)**(-1 + I) is S.Zero
assert oo**t == Pow(oo, t, evaluate=False)
assert (-oo)**t == Pow(-oo, t, evaluate=False)
def test_invert_numbers():
assert S(2).invert(5) == 3
assert S(2).invert(Rational(5, 2)) == S.Half
assert S(2).invert(5.) == 0.5
assert S(2).invert(S(5)) == 3
assert S(2.).invert(5) == 0.5
assert S(sqrt(2)).invert(5) == 1/sqrt(2)
assert S(sqrt(2)).invert(sqrt(3)) == 1/sqrt(2)
def test_mod_inverse():
assert mod_inverse(3, 11) == 4
assert mod_inverse(5, 11) == 9
assert mod_inverse(21124921, 521512) == 7713
assert mod_inverse(124215421, 5125) == 2981
assert mod_inverse(214, 12515) == 1579
assert mod_inverse(5823991, 3299) == 1442
assert mod_inverse(123, 44) == 39
assert mod_inverse(2, 5) == 3
assert mod_inverse(-2, 5) == 2
assert mod_inverse(2, -5) == -2
assert mod_inverse(-2, -5) == -3
assert mod_inverse(-3, -7) == -5
x = Symbol('x')
assert S(2).invert(x) == S.Half
raises(TypeError, lambda: mod_inverse(2, x))
raises(ValueError, lambda: mod_inverse(2, S.Half))
raises(ValueError, lambda: mod_inverse(2, cos(1)**2 + sin(1)**2))
def test_golden_ratio_rewrite_as_sqrt():
assert GoldenRatio.rewrite(sqrt) == S.Half + sqrt(5)*S.Half
def test_tribonacci_constant_rewrite_as_sqrt():
assert TribonacciConstant.rewrite(sqrt) == \
(1 + cbrt(19 - 3*sqrt(33)) + cbrt(19 + 3*sqrt(33))) / 3
def test_comparisons_with_unknown_type():
class Foo:
"""
Class that is unaware of Basic, and relies on both classes returning
the NotImplemented singleton for equivalence to evaluate to False.
"""
ni, nf, nr = Integer(3), Float(1.0), Rational(1, 3)
foo = Foo()
for n in ni, nf, nr, oo, -oo, zoo, nan:
assert n != foo
assert foo != n
assert not n == foo
assert not foo == n
raises(TypeError, lambda: n < foo)
raises(TypeError, lambda: foo > n)
raises(TypeError, lambda: n > foo)
raises(TypeError, lambda: foo < n)
raises(TypeError, lambda: n <= foo)
raises(TypeError, lambda: foo >= n)
raises(TypeError, lambda: n >= foo)
raises(TypeError, lambda: foo <= n)
class Bar:
"""
Class that considers itself equal to any instance of Number except
infinities and nans, and relies on sympy types returning the
NotImplemented singleton for symmetric equality relations.
"""
def __eq__(self, other):
if other in (oo, -oo, zoo, nan):
return False
if isinstance(other, Number):
return True
return NotImplemented
def __ne__(self, other):
return not self == other
bar = Bar()
for n in ni, nf, nr:
assert n == bar
assert bar == n
assert not n != bar
assert not bar != n
for n in oo, -oo, zoo, nan:
assert n != bar
assert bar != n
assert not n == bar
assert not bar == n
for n in ni, nf, nr, oo, -oo, zoo, nan:
raises(TypeError, lambda: n < bar)
raises(TypeError, lambda: bar > n)
raises(TypeError, lambda: n > bar)
raises(TypeError, lambda: bar < n)
raises(TypeError, lambda: n <= bar)
raises(TypeError, lambda: bar >= n)
raises(TypeError, lambda: n >= bar)
raises(TypeError, lambda: bar <= n)
def test_NumberSymbol_comparison():
from sympy.core.tests.test_relational import rel_check
rpi = Rational('905502432259640373/288230376151711744')
fpi = Float(float(pi))
assert rel_check(rpi, fpi)
def test_Integer_precision():
# Make sure Integer inputs for keyword args work
assert Float('1.0', dps=Integer(15))._prec == 53
assert Float('1.0', precision=Integer(15))._prec == 15
assert type(Float('1.0', precision=Integer(15))._prec) == int
assert sympify(srepr(Float('1.0', precision=15))) == Float('1.0', precision=15)
def test_numpy_to_float():
from sympy.testing.pytest import skip
from sympy.external import import_module
np = import_module('numpy')
if not np:
skip('numpy not installed. Abort numpy tests.')
def check_prec_and_relerr(npval, ratval):
prec = np.finfo(npval).nmant + 1
x = Float(npval)
assert x._prec == prec
y = Float(ratval, precision=prec)
assert abs((x - y)/y) < 2**(-(prec + 1))
check_prec_and_relerr(np.float16(2.0/3), Rational(2, 3))
check_prec_and_relerr(np.float32(2.0/3), Rational(2, 3))
check_prec_and_relerr(np.float64(2.0/3), Rational(2, 3))
# extended precision, on some arch/compilers:
x = np.longdouble(2)/3
check_prec_and_relerr(x, Rational(2, 3))
y = Float(x, precision=10)
assert same_and_same_prec(y, Float(Rational(2, 3), precision=10))
raises(TypeError, lambda: Float(np.complex64(1+2j)))
raises(TypeError, lambda: Float(np.complex128(1+2j)))
def test_Integer_ceiling_floor():
a = Integer(4)
assert a.floor() == a
assert a.ceiling() == a
def test_ComplexInfinity():
assert zoo.floor() is zoo
assert zoo.ceiling() is zoo
assert zoo**zoo is S.NaN
def test_Infinity_floor_ceiling_power():
assert oo.floor() is oo
assert oo.ceiling() is oo
assert oo**S.NaN is S.NaN
assert oo**zoo is S.NaN
def test_One_power():
assert S.One**12 is S.One
assert S.NegativeOne**S.NaN is S.NaN
def test_NegativeInfinity():
assert (-oo).floor() is -oo
assert (-oo).ceiling() is -oo
assert (-oo)**11 is -oo
assert (-oo)**12 is oo
def test_issue_6133():
raises(TypeError, lambda: (-oo < None))
raises(TypeError, lambda: (S(-2) < None))
raises(TypeError, lambda: (oo < None))
raises(TypeError, lambda: (oo > None))
raises(TypeError, lambda: (S(2) < None))
def test_abc():
x = numbers.Float(5)
assert(isinstance(x, nums.Number))
assert(isinstance(x, numbers.Number))
assert(isinstance(x, nums.Real))
y = numbers.Rational(1, 3)
assert(isinstance(y, nums.Number))
assert(y.numerator() == 1)
assert(y.denominator() == 3)
assert(isinstance(y, nums.Rational))
z = numbers.Integer(3)
assert(isinstance(z, nums.Number))
def test_floordiv():
assert S(2)//S.Half == 4
|
a889dccda0200d86ecbfced1db5397d915d2f248a774981187453e29c1c48117 | from sympy import (Lambda, Symbol, Function, Derivative, Subs, sqrt,
log, exp, Rational, Float, sin, cos, acos, diff, I, re, im,
E, expand, pi, O, Sum, S, polygamma, loggamma, expint,
Tuple, Dummy, Eq, Expr, symbols, nfloat, Piecewise, Indexed,
Matrix, Basic, Dict, oo, zoo, nan, Pow)
from sympy.core.basic import _aresame
from sympy.core.cache import clear_cache
from sympy.core.expr import unchanged
from sympy.core.function import (PoleError, _mexpand, arity,
BadSignatureError, BadArgumentsError)
from sympy.core.sympify import sympify
from sympy.matrices import MutableMatrix, ImmutableMatrix
from sympy.sets.sets import FiniteSet
from sympy.solvers.solveset import solveset
from sympy.tensor.array import NDimArray
from sympy.utilities.iterables import subsets, variations
from sympy.testing.pytest import XFAIL, raises, warns_deprecated_sympy
from sympy.abc import t, w, x, y, z
f, g, h = symbols('f g h', cls=Function)
_xi_1, _xi_2, _xi_3 = [Dummy() for i in range(3)]
def test_f_expand_complex():
x = Symbol('x', real=True)
assert f(x).expand(complex=True) == I*im(f(x)) + re(f(x))
assert exp(x).expand(complex=True) == exp(x)
assert exp(I*x).expand(complex=True) == cos(x) + I*sin(x)
assert exp(z).expand(complex=True) == cos(im(z))*exp(re(z)) + \
I*sin(im(z))*exp(re(z))
def test_bug1():
e = sqrt(-log(w))
assert e.subs(log(w), -x) == sqrt(x)
e = sqrt(-5*log(w))
assert e.subs(log(w), -x) == sqrt(5*x)
def test_general_function():
nu = Function('nu')
e = nu(x)
edx = e.diff(x)
edy = e.diff(y)
edxdx = e.diff(x).diff(x)
edxdy = e.diff(x).diff(y)
assert e == nu(x)
assert edx != nu(x)
assert edx == diff(nu(x), x)
assert edy == 0
assert edxdx == diff(diff(nu(x), x), x)
assert edxdy == 0
def test_general_function_nullary():
nu = Function('nu')
e = nu()
edx = e.diff(x)
edxdx = e.diff(x).diff(x)
assert e == nu()
assert edx != nu()
assert edx == 0
assert edxdx == 0
def test_derivative_subs_bug():
e = diff(g(x), x)
assert e.subs(g(x), f(x)) != e
assert e.subs(g(x), f(x)) == Derivative(f(x), x)
assert e.subs(g(x), -f(x)) == Derivative(-f(x), x)
assert e.subs(x, y) == Derivative(g(y), y)
def test_derivative_subs_self_bug():
d = diff(f(x), x)
assert d.subs(d, y) == y
def test_derivative_linearity():
assert diff(-f(x), x) == -diff(f(x), x)
assert diff(8*f(x), x) == 8*diff(f(x), x)
assert diff(8*f(x), x) != 7*diff(f(x), x)
assert diff(8*f(x)*x, x) == 8*f(x) + 8*x*diff(f(x), x)
assert diff(8*f(x)*y*x, x).expand() == 8*y*f(x) + 8*y*x*diff(f(x), x)
def test_derivative_evaluate():
assert Derivative(sin(x), x) != diff(sin(x), x)
assert Derivative(sin(x), x).doit() == diff(sin(x), x)
assert Derivative(Derivative(f(x), x), x) == diff(f(x), x, x)
assert Derivative(sin(x), x, 0) == sin(x)
assert Derivative(sin(x), (x, y), (x, -y)) == sin(x)
def test_diff_symbols():
assert diff(f(x, y, z), x, y, z) == Derivative(f(x, y, z), x, y, z)
assert diff(f(x, y, z), x, x, x) == Derivative(f(x, y, z), x, x, x) == Derivative(f(x, y, z), (x, 3))
assert diff(f(x, y, z), x, 3) == Derivative(f(x, y, z), x, 3)
# issue 5028
assert [diff(-z + x/y, sym) for sym in (z, x, y)] == [-1, 1/y, -x/y**2]
assert diff(f(x, y, z), x, y, z, 2) == Derivative(f(x, y, z), x, y, z, z)
assert diff(f(x, y, z), x, y, z, 2, evaluate=False) == \
Derivative(f(x, y, z), x, y, z, z)
assert Derivative(f(x, y, z), x, y, z)._eval_derivative(z) == \
Derivative(f(x, y, z), x, y, z, z)
assert Derivative(Derivative(f(x, y, z), x), y)._eval_derivative(z) == \
Derivative(f(x, y, z), x, y, z)
raises(TypeError, lambda: cos(x).diff((x, y)).variables)
assert cos(x).diff((x, y))._wrt_variables == [x]
def test_Function():
class myfunc(Function):
@classmethod
def eval(cls): # zero args
return
assert myfunc.nargs == FiniteSet(0)
assert myfunc().nargs == FiniteSet(0)
raises(TypeError, lambda: myfunc(x).nargs)
class myfunc(Function):
@classmethod
def eval(cls, x): # one arg
return
assert myfunc.nargs == FiniteSet(1)
assert myfunc(x).nargs == FiniteSet(1)
raises(TypeError, lambda: myfunc(x, y).nargs)
class myfunc(Function):
@classmethod
def eval(cls, *x): # star args
return
assert myfunc.nargs == S.Naturals0
assert myfunc(x).nargs == S.Naturals0
def test_nargs():
f = Function('f')
assert f.nargs == S.Naturals0
assert f(1).nargs == S.Naturals0
assert Function('f', nargs=2)(1, 2).nargs == FiniteSet(2)
assert sin.nargs == FiniteSet(1)
assert sin(2).nargs == FiniteSet(1)
assert log.nargs == FiniteSet(1, 2)
assert log(2).nargs == FiniteSet(1, 2)
assert Function('f', nargs=2).nargs == FiniteSet(2)
assert Function('f', nargs=0).nargs == FiniteSet(0)
assert Function('f', nargs=(0, 1)).nargs == FiniteSet(0, 1)
assert Function('f', nargs=None).nargs == S.Naturals0
raises(ValueError, lambda: Function('f', nargs=()))
def test_nargs_inheritance():
class f1(Function):
nargs = 2
class f2(f1):
pass
class f3(f2):
pass
class f4(f3):
nargs = 1,2
class f5(f4):
pass
class f6(f5):
pass
class f7(f6):
nargs=None
class f8(f7):
pass
class f9(f8):
pass
class f10(f9):
nargs = 1
class f11(f10):
pass
assert f1.nargs == FiniteSet(2)
assert f2.nargs == FiniteSet(2)
assert f3.nargs == FiniteSet(2)
assert f4.nargs == FiniteSet(1, 2)
assert f5.nargs == FiniteSet(1, 2)
assert f6.nargs == FiniteSet(1, 2)
assert f7.nargs == S.Naturals0
assert f8.nargs == S.Naturals0
assert f9.nargs == S.Naturals0
assert f10.nargs == FiniteSet(1)
assert f11.nargs == FiniteSet(1)
def test_arity():
f = lambda x, y: 1
assert arity(f) == 2
def f(x, y, z=None):
pass
assert arity(f) == (2, 3)
assert arity(lambda *x: x) is None
assert arity(log) == (1, 2)
def test_Lambda():
e = Lambda(x, x**2)
assert e(4) == 16
assert e(x) == x**2
assert e(y) == y**2
assert Lambda((), 42)() == 42
assert unchanged(Lambda, (), 42)
assert Lambda((), 42) != Lambda((), 43)
assert Lambda((), f(x))() == f(x)
assert Lambda((), 42).nargs == FiniteSet(0)
assert unchanged(Lambda, (x,), x**2)
assert Lambda(x, x**2) == Lambda((x,), x**2)
assert Lambda(x, x**2) == Lambda(y, y**2)
assert Lambda(x, x**2) != Lambda(y, y**2 + 1)
assert Lambda((x, y), x**y) == Lambda((y, x), y**x)
assert Lambda((x, y), x**y) != Lambda((x, y), y**x)
assert Lambda((x, y), x**y)(x, y) == x**y
assert Lambda((x, y), x**y)(3, 3) == 3**3
assert Lambda((x, y), x**y)(x, 3) == x**3
assert Lambda((x, y), x**y)(3, y) == 3**y
assert Lambda(x, f(x))(x) == f(x)
assert Lambda(x, x**2)(e(x)) == x**4
assert e(e(x)) == x**4
x1, x2 = (Indexed('x', i) for i in (1, 2))
assert Lambda((x1, x2), x1 + x2)(x, y) == x + y
assert Lambda((x, y), x + y).nargs == FiniteSet(2)
p = x, y, z, t
assert Lambda(p, t*(x + y + z))(*p) == t * (x + y + z)
assert Lambda(x, 2*x) + Lambda(y, 2*y) == 2*Lambda(x, 2*x)
assert Lambda(x, 2*x) not in [ Lambda(x, x) ]
raises(BadSignatureError, lambda: Lambda(1, x))
assert Lambda(x, 1)(1) is S.One
raises(BadSignatureError, lambda: Lambda((x, x), x + 2))
raises(BadSignatureError, lambda: Lambda(((x, x), y), x))
raises(BadSignatureError, lambda: Lambda(((y, x), x), x))
raises(BadSignatureError, lambda: Lambda(((y, 1), 2), x))
with warns_deprecated_sympy():
assert Lambda([x, y], x+y) == Lambda((x, y), x+y)
flam = Lambda( ((x, y),) , x + y)
assert flam((2, 3)) == 5
flam = Lambda( ((x, y), z) , x + y + z)
assert flam((2, 3), 1) == 6
flam = Lambda( (((x,y),z),) , x+y+z)
assert flam( ((2,3),1) ) == 6
raises(BadArgumentsError, lambda: flam(1, 2, 3))
flam = Lambda( (x,), (x, x))
assert flam(1,) == (1, 1)
assert flam((1,)) == ((1,), (1,))
flam = Lambda( ((x,),) , (x, x))
raises(BadArgumentsError, lambda: flam(1))
assert flam((1,)) == (1, 1)
# Previously TypeError was raised so this is potentially needed for
# backwards compatibility.
assert issubclass(BadSignatureError, TypeError)
assert issubclass(BadArgumentsError, TypeError)
# These are tested to see they don't raise:
hash(Lambda(x, 2*x))
hash(Lambda(x, x)) # IdentityFunction subclass
def test_IdentityFunction():
assert Lambda(x, x) is Lambda(y, y) is S.IdentityFunction
assert Lambda(x, 2*x) is not S.IdentityFunction
assert Lambda((x, y), x) is not S.IdentityFunction
def test_Lambda_symbols():
assert Lambda(x, 2*x).free_symbols == set()
assert Lambda(x, x*y).free_symbols == {y}
assert Lambda((), 42).free_symbols == set()
assert Lambda((), x*y).free_symbols == {x,y}
def test_functionclas_symbols():
assert f.free_symbols == set()
def test_Lambda_arguments():
raises(TypeError, lambda: Lambda(x, 2*x)(x, y))
raises(TypeError, lambda: Lambda((x, y), x + y)(x))
raises(TypeError, lambda: Lambda((), 42)(x))
def test_Lambda_equality():
assert Lambda(x, 2*x) == Lambda(y, 2*y)
# although variables are casts as Dummies, the expressions
# should still compare equal
assert Lambda((x, y), 2*x) == Lambda((x, y), 2*x)
assert Lambda(x, 2*x) != Lambda((x, y), 2*x)
assert Lambda(x, 2*x) != 2*x
def test_Subs():
assert Subs(1, (), ()) is S.One
# check null subs influence on hashing
assert Subs(x, y, z) != Subs(x, y, 1)
# neutral subs works
assert Subs(x, x, 1).subs(x, y).has(y)
# self mapping var/point
assert Subs(Derivative(f(x), (x, 2)), x, x).doit() == f(x).diff(x, x)
assert Subs(x, x, 0).has(x) # it's a structural answer
assert not Subs(x, x, 0).free_symbols
assert Subs(Subs(x + y, x, 2), y, 1) == Subs(x + y, (x, y), (2, 1))
assert Subs(x, (x,), (0,)) == Subs(x, x, 0)
assert Subs(x, x, 0) == Subs(y, y, 0)
assert Subs(x, x, 0).subs(x, 1) == Subs(x, x, 0)
assert Subs(y, x, 0).subs(y, 1) == Subs(1, x, 0)
assert Subs(f(x), x, 0).doit() == f(0)
assert Subs(f(x**2), x**2, 0).doit() == f(0)
assert Subs(f(x, y, z), (x, y, z), (0, 1, 1)) != \
Subs(f(x, y, z), (x, y, z), (0, 0, 1))
assert Subs(x, y, 2).subs(x, y).doit() == 2
assert Subs(f(x, y), (x, y, z), (0, 1, 1)) != \
Subs(f(x, y) + z, (x, y, z), (0, 1, 0))
assert Subs(f(x, y), (x, y), (0, 1)).doit() == f(0, 1)
assert Subs(Subs(f(x, y), x, 0), y, 1).doit() == f(0, 1)
raises(ValueError, lambda: Subs(f(x, y), (x, y), (0, 0, 1)))
raises(ValueError, lambda: Subs(f(x, y), (x, x, y), (0, 0, 1)))
assert len(Subs(f(x, y), (x, y), (0, 1)).variables) == 2
assert Subs(f(x, y), (x, y), (0, 1)).point == Tuple(0, 1)
assert Subs(f(x), x, 0) == Subs(f(y), y, 0)
assert Subs(f(x, y), (x, y), (0, 1)) == Subs(f(x, y), (y, x), (1, 0))
assert Subs(f(x)*y, (x, y), (0, 1)) == Subs(f(y)*x, (y, x), (0, 1))
assert Subs(f(x)*y, (x, y), (1, 1)) == Subs(f(y)*x, (x, y), (1, 1))
assert Subs(f(x), x, 0).subs(x, 1).doit() == f(0)
assert Subs(f(x), x, y).subs(y, 0) == Subs(f(x), x, 0)
assert Subs(y*f(x), x, y).subs(y, 2) == Subs(2*f(x), x, 2)
assert (2 * Subs(f(x), x, 0)).subs(Subs(f(x), x, 0), y) == 2*y
assert Subs(f(x), x, 0).free_symbols == set()
assert Subs(f(x, y), x, z).free_symbols == {y, z}
assert Subs(f(x).diff(x), x, 0).doit(), Subs(f(x).diff(x), x, 0)
assert Subs(1 + f(x).diff(x), x, 0).doit(), 1 + Subs(f(x).diff(x), x, 0)
assert Subs(y*f(x, y).diff(x), (x, y), (0, 2)).doit() == \
2*Subs(Derivative(f(x, 2), x), x, 0)
assert Subs(y**2*f(x), x, 0).diff(y) == 2*y*f(0)
e = Subs(y**2*f(x), x, y)
assert e.diff(y) == e.doit().diff(y) == y**2*Derivative(f(y), y) + 2*y*f(y)
assert Subs(f(x), x, 0) + Subs(f(x), x, 0) == 2*Subs(f(x), x, 0)
e1 = Subs(z*f(x), x, 1)
e2 = Subs(z*f(y), y, 1)
assert e1 + e2 == 2*e1
assert e1.__hash__() == e2.__hash__()
assert Subs(z*f(x + 1), x, 1) not in [ e1, e2 ]
assert Derivative(f(x), x).subs(x, g(x)) == Derivative(f(g(x)), g(x))
assert Derivative(f(x), x).subs(x, x + y) == Subs(Derivative(f(x), x),
x, x + y)
assert Subs(f(x)*cos(y) + z, (x, y), (0, pi/3)).n(2) == \
Subs(f(x)*cos(y) + z, (x, y), (0, pi/3)).evalf(2) == \
z + Rational('1/2').n(2)*f(0)
assert f(x).diff(x).subs(x, 0).subs(x, y) == f(x).diff(x).subs(x, 0)
assert (x*f(x).diff(x).subs(x, 0)).subs(x, y) == y*f(x).diff(x).subs(x, 0)
assert Subs(Derivative(g(x)**2, g(x), x), g(x), exp(x)
).doit() == 2*exp(x)
assert Subs(Derivative(g(x)**2, g(x), x), g(x), exp(x)
).doit(deep=False) == 2*Derivative(exp(x), x)
assert Derivative(f(x, g(x)), x).doit() == Derivative(
f(x, g(x)), g(x))*Derivative(g(x), x) + Subs(Derivative(
f(y, g(x)), y), y, x)
def test_doitdoit():
done = Derivative(f(x, g(x)), x, g(x)).doit()
assert done == done.doit()
@XFAIL
def test_Subs2():
# this reflects a limitation of subs(), probably won't fix
assert Subs(f(x), x**2, x).doit() == f(sqrt(x))
def test_expand_function():
assert expand(x + y) == x + y
assert expand(x + y, complex=True) == I*im(x) + I*im(y) + re(x) + re(y)
assert expand((x + y)**11, modulus=11) == x**11 + y**11
def test_function_comparable():
assert sin(x).is_comparable is False
assert cos(x).is_comparable is False
assert sin(Float('0.1')).is_comparable is True
assert cos(Float('0.1')).is_comparable is True
assert sin(E).is_comparable is True
assert cos(E).is_comparable is True
assert sin(Rational(1, 3)).is_comparable is True
assert cos(Rational(1, 3)).is_comparable is True
def test_function_comparable_infinities():
assert sin(oo).is_comparable is False
assert sin(-oo).is_comparable is False
assert sin(zoo).is_comparable is False
assert sin(nan).is_comparable is False
def test_deriv1():
# These all require derivatives evaluated at a point (issue 4719) to work.
# See issue 4624
assert f(2*x).diff(x) == 2*Subs(Derivative(f(x), x), x, 2*x)
assert (f(x)**3).diff(x) == 3*f(x)**2*f(x).diff(x)
assert (f(2*x)**3).diff(x) == 6*f(2*x)**2*Subs(
Derivative(f(x), x), x, 2*x)
assert f(2 + x).diff(x) == Subs(Derivative(f(x), x), x, x + 2)
assert f(2 + 3*x).diff(x) == 3*Subs(
Derivative(f(x), x), x, 3*x + 2)
assert f(3*sin(x)).diff(x) == 3*cos(x)*Subs(
Derivative(f(x), x), x, 3*sin(x))
# See issue 8510
assert f(x, x + z).diff(x) == (
Subs(Derivative(f(y, x + z), y), y, x) +
Subs(Derivative(f(x, y), y), y, x + z))
assert f(x, x**2).diff(x) == (
2*x*Subs(Derivative(f(x, y), y), y, x**2) +
Subs(Derivative(f(y, x**2), y), y, x))
# but Subs is not always necessary
assert f(x, g(y)).diff(g(y)) == Derivative(f(x, g(y)), g(y))
def test_deriv2():
assert (x**3).diff(x) == 3*x**2
assert (x**3).diff(x, evaluate=False) != 3*x**2
assert (x**3).diff(x, evaluate=False) == Derivative(x**3, x)
assert diff(x**3, x) == 3*x**2
assert diff(x**3, x, evaluate=False) != 3*x**2
assert diff(x**3, x, evaluate=False) == Derivative(x**3, x)
def test_func_deriv():
assert f(x).diff(x) == Derivative(f(x), x)
# issue 4534
assert f(x, y).diff(x, y) - f(x, y).diff(y, x) == 0
assert Derivative(f(x, y), x, y).args[1:] == ((x, 1), (y, 1))
assert Derivative(f(x, y), y, x).args[1:] == ((y, 1), (x, 1))
assert (Derivative(f(x, y), x, y) - Derivative(f(x, y), y, x)).doit() == 0
def test_suppressed_evaluation():
a = sin(0, evaluate=False)
assert a != 0
assert a.func is sin
assert a.args == (0,)
def test_function_evalf():
def eq(a, b, eps):
return abs(a - b) < eps
assert eq(sin(1).evalf(15), Float("0.841470984807897"), 1e-13)
assert eq(
sin(2).evalf(25), Float("0.9092974268256816953960199", 25), 1e-23)
assert eq(sin(1 + I).evalf(
15), Float("1.29845758141598") + Float("0.634963914784736")*I, 1e-13)
assert eq(exp(1 + I).evalf(15), Float(
"1.46869393991588") + Float("2.28735528717884239")*I, 1e-13)
assert eq(exp(-0.5 + 1.5*I).evalf(15), Float(
"0.0429042815937374") + Float("0.605011292285002")*I, 1e-13)
assert eq(log(pi + sqrt(2)*I).evalf(
15), Float("1.23699044022052") + Float("0.422985442737893")*I, 1e-13)
assert eq(cos(100).evalf(15), Float("0.86231887228768"), 1e-13)
def test_extensibility_eval():
class MyFunc(Function):
@classmethod
def eval(cls, *args):
return (0, 0, 0)
assert MyFunc(0) == (0, 0, 0)
def test_function_non_commutative():
x = Symbol('x', commutative=False)
assert f(x).is_commutative is False
assert sin(x).is_commutative is False
assert exp(x).is_commutative is False
assert log(x).is_commutative is False
assert f(x).is_complex is False
assert sin(x).is_complex is False
assert exp(x).is_complex is False
assert log(x).is_complex is False
def test_function_complex():
x = Symbol('x', complex=True)
xzf = Symbol('x', complex=True, zero=False)
assert f(x).is_commutative is True
assert sin(x).is_commutative is True
assert exp(x).is_commutative is True
assert log(x).is_commutative is True
assert f(x).is_complex is None
assert sin(x).is_complex is True
assert exp(x).is_complex is True
assert log(x).is_complex is None
assert log(xzf).is_complex is True
def test_function__eval_nseries():
n = Symbol('n')
assert sin(x)._eval_nseries(x, 2, None) == x + O(x**2)
assert sin(x + 1)._eval_nseries(x, 2, None) == x*cos(1) + sin(1) + O(x**2)
assert sin(pi*(1 - x))._eval_nseries(x, 2, None) == pi*x + O(x**2)
assert acos(1 - x**2)._eval_nseries(x, 2, None) == sqrt(2)*sqrt(x**2) + O(x**2)
assert polygamma(n, x + 1)._eval_nseries(x, 2, None) == \
polygamma(n, 1) + polygamma(n + 1, 1)*x + O(x**2)
raises(PoleError, lambda: sin(1/x)._eval_nseries(x, 2, None))
assert acos(1 - x)._eval_nseries(x, 2, None) == sqrt(2)*sqrt(x) + O(x)
assert acos(1 + x)._eval_nseries(x, 2, None) == sqrt(2)*sqrt(-x) + O(x) # XXX: wrong, branch cuts
assert loggamma(1/x)._eval_nseries(x, 0, None) == \
log(x)/2 - log(x)/x - 1/x + O(1, x)
assert loggamma(log(1/x)).nseries(x, n=1, logx=y) == loggamma(-y)
# issue 6725:
assert expint(Rational(3, 2), -x)._eval_nseries(x, 5, None) == \
2 - 2*sqrt(pi)*sqrt(-x) - 2*x - x**2/3 - x**3/15 - x**4/84 + O(x**5)
assert sin(sqrt(x))._eval_nseries(x, 3, None) == \
sqrt(x) - x**Rational(3, 2)/6 + x**Rational(5, 2)/120 + O(x**3)
def test_doit():
n = Symbol('n', integer=True)
f = Sum(2 * n * x, (n, 1, 3))
d = Derivative(f, x)
assert d.doit() == 12
assert d.doit(deep=False) == Sum(2*n, (n, 1, 3))
def test_evalf_default():
from sympy.functions.special.gamma_functions import polygamma
assert type(sin(4.0)) == Float
assert type(re(sin(I + 1.0))) == Float
assert type(im(sin(I + 1.0))) == Float
assert type(sin(4)) == sin
assert type(polygamma(2.0, 4.0)) == Float
assert type(sin(Rational(1, 4))) == sin
def test_issue_5399():
args = [x, y, S(2), S.Half]
def ok(a):
"""Return True if the input args for diff are ok"""
if not a:
return False
if a[0].is_Symbol is False:
return False
s_at = [i for i in range(len(a)) if a[i].is_Symbol]
n_at = [i for i in range(len(a)) if not a[i].is_Symbol]
# every symbol is followed by symbol or int
# every number is followed by a symbol
return (all(a[i + 1].is_Symbol or a[i + 1].is_Integer
for i in s_at if i + 1 < len(a)) and
all(a[i + 1].is_Symbol
for i in n_at if i + 1 < len(a)))
eq = x**10*y**8
for a in subsets(args):
for v in variations(a, len(a)):
if ok(v):
eq.diff(*v) # does not raise
else:
raises(ValueError, lambda: eq.diff(*v))
def test_derivative_numerically():
from random import random
z0 = random() + I*random()
assert abs(Derivative(sin(x), x).doit_numerically(z0) - cos(z0)) < 1e-15
def test_fdiff_argument_index_error():
from sympy.core.function import ArgumentIndexError
class myfunc(Function):
nargs = 1 # define since there is no eval routine
def fdiff(self, idx):
raise ArgumentIndexError
mf = myfunc(x)
assert mf.diff(x) == Derivative(mf, x)
raises(TypeError, lambda: myfunc(x, x))
def test_deriv_wrt_function():
x = f(t)
xd = diff(x, t)
xdd = diff(xd, t)
y = g(t)
yd = diff(y, t)
assert diff(x, t) == xd
assert diff(2 * x + 4, t) == 2 * xd
assert diff(2 * x + 4 + y, t) == 2 * xd + yd
assert diff(2 * x + 4 + y * x, t) == 2 * xd + x * yd + xd * y
assert diff(2 * x + 4 + y * x, x) == 2 + y
assert (diff(4 * x**2 + 3 * x + x * y, t) == 3 * xd + x * yd + xd * y +
8 * x * xd)
assert (diff(4 * x**2 + 3 * xd + x * y, t) == 3 * xdd + x * yd + xd * y +
8 * x * xd)
assert diff(4 * x**2 + 3 * xd + x * y, xd) == 3
assert diff(4 * x**2 + 3 * xd + x * y, xdd) == 0
assert diff(sin(x), t) == xd * cos(x)
assert diff(exp(x), t) == xd * exp(x)
assert diff(sqrt(x), t) == xd / (2 * sqrt(x))
def test_diff_wrt_value():
assert Expr()._diff_wrt is False
assert x._diff_wrt is True
assert f(x)._diff_wrt is True
assert Derivative(f(x), x)._diff_wrt is True
assert Derivative(x**2, x)._diff_wrt is False
def test_diff_wrt():
fx = f(x)
dfx = diff(f(x), x)
ddfx = diff(f(x), x, x)
assert diff(sin(fx) + fx**2, fx) == cos(fx) + 2*fx
assert diff(sin(dfx) + dfx**2, dfx) == cos(dfx) + 2*dfx
assert diff(sin(ddfx) + ddfx**2, ddfx) == cos(ddfx) + 2*ddfx
assert diff(fx**2, dfx) == 0
assert diff(fx**2, ddfx) == 0
assert diff(dfx**2, fx) == 0
assert diff(dfx**2, ddfx) == 0
assert diff(ddfx**2, dfx) == 0
assert diff(fx*dfx*ddfx, fx) == dfx*ddfx
assert diff(fx*dfx*ddfx, dfx) == fx*ddfx
assert diff(fx*dfx*ddfx, ddfx) == fx*dfx
assert diff(f(x), x).diff(f(x)) == 0
assert (sin(f(x)) - cos(diff(f(x), x))).diff(f(x)) == cos(f(x))
assert diff(sin(fx), fx, x) == diff(sin(fx), x, fx)
# Chain rule cases
assert f(g(x)).diff(x) == \
Derivative(g(x), x)*Derivative(f(g(x)), g(x))
assert diff(f(g(x), h(y)), x) == \
Derivative(g(x), x)*Derivative(f(g(x), h(y)), g(x))
assert diff(f(g(x), h(x)), x) == (
Derivative(f(g(x), h(x)), g(x))*Derivative(g(x), x) +
Derivative(f(g(x), h(x)), h(x))*Derivative(h(x), x))
assert f(
sin(x)).diff(x) == cos(x)*Subs(Derivative(f(x), x), x, sin(x))
assert diff(f(g(x)), g(x)) == Derivative(f(g(x)), g(x))
def test_diff_wrt_func_subs():
assert f(g(x)).diff(x).subs(g, Lambda(x, 2*x)).doit() == f(2*x).diff(x)
def test_subs_in_derivative():
expr = sin(x*exp(y))
u = Function('u')
v = Function('v')
assert Derivative(expr, y).subs(expr, y) == Derivative(y, y)
assert Derivative(expr, y).subs(y, x).doit() == \
Derivative(expr, y).doit().subs(y, x)
assert Derivative(f(x, y), y).subs(y, x) == Subs(Derivative(f(x, y), y), y, x)
assert Derivative(f(x, y), y).subs(x, y) == Subs(Derivative(f(x, y), y), x, y)
assert Derivative(f(x, y), y).subs(y, g(x, y)) == Subs(Derivative(f(x, y), y), y, g(x, y)).doit()
assert Derivative(f(x, y), y).subs(x, g(x, y)) == Subs(Derivative(f(x, y), y), x, g(x, y))
assert Derivative(f(x, y), g(y)).subs(x, g(x, y)) == Derivative(f(g(x, y), y), g(y))
assert Derivative(f(u(x), h(y)), h(y)).subs(h(y), g(x, y)) == \
Subs(Derivative(f(u(x), h(y)), h(y)), h(y), g(x, y)).doit()
assert Derivative(f(x, y), y).subs(y, z) == Derivative(f(x, z), z)
assert Derivative(f(x, y), y).subs(y, g(y)) == Derivative(f(x, g(y)), g(y))
assert Derivative(f(g(x), h(y)), h(y)).subs(h(y), u(y)) == \
Derivative(f(g(x), u(y)), u(y))
assert Derivative(f(x, f(x, x)), f(x, x)).subs(
f, Lambda((x, y), x + y)) == Subs(
Derivative(z + x, z), z, 2*x)
assert Subs(Derivative(f(f(x)), x), f, cos).doit() == sin(x)*sin(cos(x))
assert Subs(Derivative(f(f(x)), f(x)), f, cos).doit() == -sin(cos(x))
# Issue 13791. No comparison (it's a long formula) but this used to raise an exception.
assert isinstance(v(x, y, u(x, y)).diff(y).diff(x).diff(y), Expr)
# This is also related to issues 13791 and 13795; issue 15190
F = Lambda((x, y), exp(2*x + 3*y))
abstract = f(x, f(x, x)).diff(x, 2)
concrete = F(x, F(x, x)).diff(x, 2)
assert (abstract.subs(f, F).doit() - concrete).simplify() == 0
# don't introduce a new symbol if not necessary
assert x in f(x).diff(x).subs(x, 0).atoms()
# case (4)
assert Derivative(f(x,f(x,y)), x, y).subs(x, g(y)
) == Subs(Derivative(f(x, f(x, y)), x, y), x, g(y))
assert Derivative(f(x, x), x).subs(x, 0
) == Subs(Derivative(f(x, x), x), x, 0)
# issue 15194
assert Derivative(f(y, g(x)), (x, z)).subs(z, x
) == Derivative(f(y, g(x)), (x, x))
df = f(x).diff(x)
assert df.subs(df, 1) is S.One
assert df.diff(df) is S.One
dxy = Derivative(f(x, y), x, y)
dyx = Derivative(f(x, y), y, x)
assert dxy.subs(Derivative(f(x, y), y, x), 1) is S.One
assert dxy.diff(dyx) is S.One
assert Derivative(f(x, y), x, 2, y, 3).subs(
dyx, g(x, y)) == Derivative(g(x, y), x, 1, y, 2)
assert Derivative(f(x, x - y), y).subs(x, x + y) == Subs(
Derivative(f(x, x - y), y), x, x + y)
def test_diff_wrt_not_allowed():
# issue 7027 included
for wrt in (
cos(x), re(x), x**2, x*y, 1 + x,
Derivative(cos(x), x), Derivative(f(f(x)), x)):
raises(ValueError, lambda: diff(f(x), wrt))
# if we don't differentiate wrt then don't raise error
assert diff(exp(x*y), x*y, 0) == exp(x*y)
def test_klein_gordon_lagrangian():
m = Symbol('m')
phi = f(x, t)
L = -(diff(phi, t)**2 - diff(phi, x)**2 - m**2*phi**2)/2
eqna = Eq(
diff(L, phi) - diff(L, diff(phi, x), x) - diff(L, diff(phi, t), t), 0)
eqnb = Eq(diff(phi, t, t) - diff(phi, x, x) + m**2*phi, 0)
assert eqna == eqnb
def test_sho_lagrangian():
m = Symbol('m')
k = Symbol('k')
x = f(t)
L = m*diff(x, t)**2/2 - k*x**2/2
eqna = Eq(diff(L, x), diff(L, diff(x, t), t))
eqnb = Eq(-k*x, m*diff(x, t, t))
assert eqna == eqnb
assert diff(L, x, t) == diff(L, t, x)
assert diff(L, diff(x, t), t) == m*diff(x, t, 2)
assert diff(L, t, diff(x, t)) == -k*x + m*diff(x, t, 2)
def test_straight_line():
F = f(x)
Fd = F.diff(x)
L = sqrt(1 + Fd**2)
assert diff(L, F) == 0
assert diff(L, Fd) == Fd/sqrt(1 + Fd**2)
def test_sort_variable():
vsort = Derivative._sort_variable_count
def vsort0(*v, **kw):
reverse = kw.get('reverse', False)
return [i[0] for i in vsort([(i, 0) for i in (
reversed(v) if reverse else v)])]
for R in range(2):
assert vsort0(y, x, reverse=R) == [x, y]
assert vsort0(f(x), x, reverse=R) == [x, f(x)]
assert vsort0(f(y), f(x), reverse=R) == [f(x), f(y)]
assert vsort0(g(x), f(y), reverse=R) == [f(y), g(x)]
assert vsort0(f(x, y), f(x), reverse=R) == [f(x), f(x, y)]
fx = f(x).diff(x)
assert vsort0(fx, y, reverse=R) == [y, fx]
fy = f(y).diff(y)
assert vsort0(fy, fx, reverse=R) == [fx, fy]
fxx = fx.diff(x)
assert vsort0(fxx, fx, reverse=R) == [fx, fxx]
assert vsort0(Basic(x), f(x), reverse=R) == [f(x), Basic(x)]
assert vsort0(Basic(y), Basic(x), reverse=R) == [Basic(x), Basic(y)]
assert vsort0(Basic(y, z), Basic(x), reverse=R) == [
Basic(x), Basic(y, z)]
assert vsort0(fx, x, reverse=R) == [
x, fx] if R else [fx, x]
assert vsort0(Basic(x), x, reverse=R) == [
x, Basic(x)] if R else [Basic(x), x]
assert vsort0(Basic(f(x)), f(x), reverse=R) == [
f(x), Basic(f(x))] if R else [Basic(f(x)), f(x)]
assert vsort0(Basic(x, z), Basic(x), reverse=R) == [
Basic(x), Basic(x, z)] if R else [Basic(x, z), Basic(x)]
assert vsort([]) == []
assert _aresame(vsort([(x, 1)]), [Tuple(x, 1)])
assert vsort([(x, y), (x, z)]) == [(x, y + z)]
assert vsort([(y, 1), (x, 1 + y)]) == [(x, 1 + y), (y, 1)]
# coverage complete; legacy tests below
assert vsort([(x, 3), (y, 2), (z, 1)]) == [(x, 3), (y, 2), (z, 1)]
assert vsort([(h(x), 1), (g(x), 1), (f(x), 1)]) == [
(f(x), 1), (g(x), 1), (h(x), 1)]
assert vsort([(z, 1), (y, 2), (x, 3), (h(x), 1), (g(x), 1),
(f(x), 1)]) == [(x, 3), (y, 2), (z, 1), (f(x), 1), (g(x), 1),
(h(x), 1)]
assert vsort([(x, 1), (f(x), 1), (y, 1), (f(y), 1)]) == [(x, 1),
(y, 1), (f(x), 1), (f(y), 1)]
assert vsort([(y, 1), (x, 2), (g(x), 1), (f(x), 1), (z, 1),
(h(x), 1), (y, 2), (x, 1)]) == [(x, 3), (y, 3), (z, 1),
(f(x), 1), (g(x), 1), (h(x), 1)]
assert vsort([(z, 1), (y, 1), (f(x), 1), (x, 1), (f(x), 1),
(g(x), 1)]) == [(x, 1), (y, 1), (z, 1), (f(x), 2), (g(x), 1)]
assert vsort([(z, 1), (y, 2), (f(x), 1), (x, 2), (f(x), 2),
(g(x), 1), (z, 2), (z, 1), (y, 1), (x, 1)]) == [(x, 3), (y, 3),
(z, 4), (f(x), 3), (g(x), 1)]
assert vsort(((y, 2), (x, 1), (y, 1), (x, 1))) == [(x, 2), (y, 3)]
assert isinstance(vsort([(x, 3), (y, 2), (z, 1)])[0], Tuple)
assert vsort([(x, 1), (f(x), 1), (x, 1)]) == [(x, 2), (f(x), 1)]
assert vsort([(y, 2), (x, 3), (z, 1)]) == [(x, 3), (y, 2), (z, 1)]
assert vsort([(h(y), 1), (g(x), 1), (f(x), 1)]) == [
(f(x), 1), (g(x), 1), (h(y), 1)]
assert vsort([(x, 1), (y, 1), (x, 1)]) == [(x, 2), (y, 1)]
assert vsort([(f(x), 1), (f(y), 1), (f(x), 1)]) == [
(f(x), 2), (f(y), 1)]
dfx = f(x).diff(x)
self = [(dfx, 1), (x, 1)]
assert vsort(self) == self
assert vsort([
(dfx, 1), (y, 1), (f(x), 1), (x, 1), (f(y), 1), (x, 1)]) == [
(y, 1), (f(x), 1), (f(y), 1), (dfx, 1), (x, 2)]
dfy = f(y).diff(y)
assert vsort([(dfy, 1), (dfx, 1)]) == [(dfx, 1), (dfy, 1)]
d2fx = dfx.diff(x)
assert vsort([(d2fx, 1), (dfx, 1)]) == [(dfx, 1), (d2fx, 1)]
def test_multiple_derivative():
# Issue #15007
assert f(x, y).diff(y, y, x, y, x
) == Derivative(f(x, y), (x, 2), (y, 3))
def test_unhandled():
class MyExpr(Expr):
def _eval_derivative(self, s):
if not s.name.startswith('xi'):
return self
else:
return None
eq = MyExpr(f(x), y, z)
assert diff(eq, x, y, f(x), z) == Derivative(eq, f(x))
assert diff(eq, f(x), x) == Derivative(eq, f(x))
assert f(x, y).diff(x,(y, z)) == Derivative(f(x, y), x, (y, z))
assert f(x, y).diff(x,(y, 0)) == Derivative(f(x, y), x)
def test_nfloat():
from sympy.core.basic import _aresame
from sympy.polys.rootoftools import rootof
x = Symbol("x")
eq = x**Rational(4, 3) + 4*x**(S.One/3)/3
assert _aresame(nfloat(eq), x**Rational(4, 3) + (4.0/3)*x**(S.One/3))
assert _aresame(nfloat(eq, exponent=True), x**(4.0/3) + (4.0/3)*x**(1.0/3))
eq = x**Rational(4, 3) + 4*x**(x/3)/3
assert _aresame(nfloat(eq), x**Rational(4, 3) + (4.0/3)*x**(x/3))
big = 12345678901234567890
# specify precision to match value used in nfloat
Float_big = Float(big, 15)
assert _aresame(nfloat(big), Float_big)
assert _aresame(nfloat(big*x), Float_big*x)
assert _aresame(nfloat(x**big, exponent=True), x**Float_big)
assert nfloat(cos(x + sqrt(2))) == cos(x + nfloat(sqrt(2)))
# issue 6342
f = S('x*lamda + lamda**3*(x/2 + 1/2) + lamda**2 + 1/4')
assert not any(a.free_symbols for a in solveset(f.subs(x, -0.139)))
# issue 6632
assert nfloat(-100000*sqrt(2500000001) + 5000000001) == \
9.99999999800000e-11
# issue 7122
eq = cos(3*x**4 + y)*rootof(x**5 + 3*x**3 + 1, 0)
assert str(nfloat(eq, exponent=False, n=1)) == '-0.7*cos(3.0*x**4 + y)'
# issue 10933
for ti in (dict, Dict):
d = ti({S.Half: S.Half})
n = nfloat(d)
assert isinstance(n, ti)
assert _aresame(list(n.items()).pop(), (S.Half, Float(.5)))
for ti in (dict, Dict):
d = ti({S.Half: S.Half})
n = nfloat(d, dkeys=True)
assert isinstance(n, ti)
assert _aresame(list(n.items()).pop(), (Float(.5), Float(.5)))
d = [S.Half]
n = nfloat(d)
assert type(n) is list
assert _aresame(n[0], Float(.5))
assert _aresame(nfloat(Eq(x, S.Half)).rhs, Float(.5))
assert _aresame(nfloat(S(True)), S(True))
assert _aresame(nfloat(Tuple(S.Half))[0], Float(.5))
assert nfloat(Eq((3 - I)**2/2 + I, 0)) == S.false
# pass along kwargs
assert nfloat([{S.Half: x}], dkeys=True) == [{Float(0.5): x}]
# Issue 17706
A = MutableMatrix([[1, 2], [3, 4]])
B = MutableMatrix(
[[Float('1.0', precision=53), Float('2.0', precision=53)],
[Float('3.0', precision=53), Float('4.0', precision=53)]])
assert _aresame(nfloat(A), B)
A = ImmutableMatrix([[1, 2], [3, 4]])
B = ImmutableMatrix(
[[Float('1.0', precision=53), Float('2.0', precision=53)],
[Float('3.0', precision=53), Float('4.0', precision=53)]])
assert _aresame(nfloat(A), B)
def test_issue_7068():
from sympy.abc import a, b
f = Function('f')
y1 = Dummy('y')
y2 = Dummy('y')
func1 = f(a + y1 * b)
func2 = f(a + y2 * b)
func1_y = func1.diff(y1)
func2_y = func2.diff(y2)
assert func1_y != func2_y
z1 = Subs(f(a), a, y1)
z2 = Subs(f(a), a, y2)
assert z1 != z2
def test_issue_7231():
from sympy.abc import a
ans1 = f(x).series(x, a)
res = (f(a) + (-a + x)*Subs(Derivative(f(y), y), y, a) +
(-a + x)**2*Subs(Derivative(f(y), y, y), y, a)/2 +
(-a + x)**3*Subs(Derivative(f(y), y, y, y),
y, a)/6 +
(-a + x)**4*Subs(Derivative(f(y), y, y, y, y),
y, a)/24 +
(-a + x)**5*Subs(Derivative(f(y), y, y, y, y, y),
y, a)/120 + O((-a + x)**6, (x, a)))
assert res == ans1
ans2 = f(x).series(x, a)
assert res == ans2
def test_issue_7687():
from sympy.core.function import Function
from sympy.abc import x
f = Function('f')(x)
ff = Function('f')(x)
match_with_cache = ff.matches(f)
assert isinstance(f, type(ff))
clear_cache()
ff = Function('f')(x)
assert isinstance(f, type(ff))
assert match_with_cache == ff.matches(f)
def test_issue_7688():
from sympy.core.function import Function, UndefinedFunction
f = Function('f') # actually an UndefinedFunction
clear_cache()
class A(UndefinedFunction):
pass
a = A('f')
assert isinstance(a, type(f))
def test_mexpand():
from sympy.abc import x
assert _mexpand(None) is None
assert _mexpand(1) is S.One
assert _mexpand(x*(x + 1)**2) == (x*(x + 1)**2).expand()
def test_issue_8469():
# This should not take forever to run
N = 40
def g(w, theta):
return 1/(1+exp(w-theta))
ws = symbols(['w%i'%i for i in range(N)])
import functools
expr = functools.reduce(g, ws)
assert isinstance(expr, Pow)
def test_issue_12996():
# foo=True imitates the sort of arguments that Derivative can get
# from Integral when it passes doit to the expression
assert Derivative(im(x), x).doit(foo=True) == Derivative(im(x), x)
def test_should_evalf():
# This should not take forever to run (see #8506)
assert isinstance(sin((1.0 + 1.0*I)**10000 + 1), sin)
def test_Derivative_as_finite_difference():
# Central 1st derivative at gridpoint
x, h = symbols('x h', real=True)
dfdx = f(x).diff(x)
assert (dfdx.as_finite_difference([x-2, x-1, x, x+1, x+2]) -
(S.One/12*(f(x-2)-f(x+2)) + Rational(2, 3)*(f(x+1)-f(x-1)))).simplify() == 0
# Central 1st derivative "half-way"
assert (dfdx.as_finite_difference() -
(f(x + S.Half)-f(x - S.Half))).simplify() == 0
assert (dfdx.as_finite_difference(h) -
(f(x + h/S(2))-f(x - h/S(2)))/h).simplify() == 0
assert (dfdx.as_finite_difference([x - 3*h, x-h, x+h, x + 3*h]) -
(S(9)/(8*2*h)*(f(x+h) - f(x-h)) +
S.One/(24*2*h)*(f(x - 3*h) - f(x + 3*h)))).simplify() == 0
# One sided 1st derivative at gridpoint
assert (dfdx.as_finite_difference([0, 1, 2], 0) -
(Rational(-3, 2)*f(0) + 2*f(1) - f(2)/2)).simplify() == 0
assert (dfdx.as_finite_difference([x, x+h], x) -
(f(x+h) - f(x))/h).simplify() == 0
assert (dfdx.as_finite_difference([x-h, x, x+h], x-h) -
(-S(3)/(2*h)*f(x-h) + 2/h*f(x) -
S.One/(2*h)*f(x+h))).simplify() == 0
# One sided 1st derivative "half-way"
assert (dfdx.as_finite_difference([x-h, x+h, x + 3*h, x + 5*h, x + 7*h])
- 1/(2*h)*(-S(11)/(12)*f(x-h) + S(17)/(24)*f(x+h)
+ Rational(3, 8)*f(x + 3*h) - Rational(5, 24)*f(x + 5*h)
+ S.One/24*f(x + 7*h))).simplify() == 0
d2fdx2 = f(x).diff(x, 2)
# Central 2nd derivative at gridpoint
assert (d2fdx2.as_finite_difference([x-h, x, x+h]) -
h**-2 * (f(x-h) + f(x+h) - 2*f(x))).simplify() == 0
assert (d2fdx2.as_finite_difference([x - 2*h, x-h, x, x+h, x + 2*h]) -
h**-2 * (Rational(-1, 12)*(f(x - 2*h) + f(x + 2*h)) +
Rational(4, 3)*(f(x+h) + f(x-h)) - Rational(5, 2)*f(x))).simplify() == 0
# Central 2nd derivative "half-way"
assert (d2fdx2.as_finite_difference([x - 3*h, x-h, x+h, x + 3*h]) -
(2*h)**-2 * (S.Half*(f(x - 3*h) + f(x + 3*h)) -
S.Half*(f(x+h) + f(x-h)))).simplify() == 0
# One sided 2nd derivative at gridpoint
assert (d2fdx2.as_finite_difference([x, x+h, x + 2*h, x + 3*h]) -
h**-2 * (2*f(x) - 5*f(x+h) +
4*f(x+2*h) - f(x+3*h))).simplify() == 0
# One sided 2nd derivative at "half-way"
assert (d2fdx2.as_finite_difference([x-h, x+h, x + 3*h, x + 5*h]) -
(2*h)**-2 * (Rational(3, 2)*f(x-h) - Rational(7, 2)*f(x+h) + Rational(5, 2)*f(x + 3*h) -
S.Half*f(x + 5*h))).simplify() == 0
d3fdx3 = f(x).diff(x, 3)
# Central 3rd derivative at gridpoint
assert (d3fdx3.as_finite_difference() -
(-f(x - Rational(3, 2)) + 3*f(x - S.Half) -
3*f(x + S.Half) + f(x + Rational(3, 2)))).simplify() == 0
assert (d3fdx3.as_finite_difference(
[x - 3*h, x - 2*h, x-h, x, x+h, x + 2*h, x + 3*h]) -
h**-3 * (S.One/8*(f(x - 3*h) - f(x + 3*h)) - f(x - 2*h) +
f(x + 2*h) + Rational(13, 8)*(f(x-h) - f(x+h)))).simplify() == 0
# Central 3rd derivative at "half-way"
assert (d3fdx3.as_finite_difference([x - 3*h, x-h, x+h, x + 3*h]) -
(2*h)**-3 * (f(x + 3*h)-f(x - 3*h) +
3*(f(x-h)-f(x+h)))).simplify() == 0
# One sided 3rd derivative at gridpoint
assert (d3fdx3.as_finite_difference([x, x+h, x + 2*h, x + 3*h]) -
h**-3 * (f(x + 3*h)-f(x) + 3*(f(x+h)-f(x + 2*h)))).simplify() == 0
# One sided 3rd derivative at "half-way"
assert (d3fdx3.as_finite_difference([x-h, x+h, x + 3*h, x + 5*h]) -
(2*h)**-3 * (f(x + 5*h)-f(x-h) +
3*(f(x+h)-f(x + 3*h)))).simplify() == 0
# issue 11007
y = Symbol('y', real=True)
d2fdxdy = f(x, y).diff(x, y)
ref0 = Derivative(f(x + S.Half, y), y) - Derivative(f(x - S.Half, y), y)
assert (d2fdxdy.as_finite_difference(wrt=x) - ref0).simplify() == 0
half = S.Half
xm, xp, ym, yp = x-half, x+half, y-half, y+half
ref2 = f(xm, ym) + f(xp, yp) - f(xp, ym) - f(xm, yp)
assert (d2fdxdy.as_finite_difference() - ref2).simplify() == 0
def test_issue_11159():
# Tests Application._eval_subs
expr1 = E
expr0 = expr1 * expr1
expr1 = expr0.subs(expr1,expr0)
assert expr0 == expr1
def test_issue_12005():
e1 = Subs(Derivative(f(x), x), x, x)
assert e1.diff(x) == Derivative(f(x), x, x)
e2 = Subs(Derivative(f(x), x), x, x**2 + 1)
assert e2.diff(x) == 2*x*Subs(Derivative(f(x), x, x), x, x**2 + 1)
e3 = Subs(Derivative(f(x) + y**2 - y, y), y, y**2)
assert e3.diff(y) == 4*y
e4 = Subs(Derivative(f(x + y), y), y, (x**2))
assert e4.diff(y) is S.Zero
e5 = Subs(Derivative(f(x), x), (y, z), (y, z))
assert e5.diff(x) == Derivative(f(x), x, x)
assert f(g(x)).diff(g(x), g(x)) == Derivative(f(g(x)), g(x), g(x))
def test_issue_13843():
x = symbols('x')
f = Function('f')
m, n = symbols('m n', integer=True)
assert Derivative(Derivative(f(x), (x, m)), (x, n)) == Derivative(f(x), (x, m + n))
assert Derivative(Derivative(f(x), (x, m+5)), (x, n+3)) == Derivative(f(x), (x, m + n + 8))
assert Derivative(f(x), (x, n)).doit() == Derivative(f(x), (x, n))
def test_order_could_be_zero():
x, y = symbols('x, y')
n = symbols('n', integer=True, nonnegative=True)
m = symbols('m', integer=True, positive=True)
assert diff(y, (x, n)) == Piecewise((y, Eq(n, 0)), (0, True))
assert diff(y, (x, n + 1)) is S.Zero
assert diff(y, (x, m)) is S.Zero
def test_undefined_function_eq():
f = Function('f')
f2 = Function('f')
g = Function('g')
f_real = Function('f', is_real=True)
# This test may only be meaningful if the cache is turned off
assert f == f2
assert hash(f) == hash(f2)
assert f == f
assert f != g
assert f != f_real
def test_function_assumptions():
x = Symbol('x')
f = Function('f')
f_real = Function('f', real=True)
f_real1 = Function('f', real=1)
f_real_inherit = Function(Symbol('f', real=True))
assert f_real == f_real1 # assumptions are sanitized
assert f != f_real
assert f(x) != f_real(x)
assert f(x).is_real is None
assert f_real(x).is_real is True
assert f_real_inherit(x).is_real is True and f_real_inherit.name == 'f'
# Can also do it this way, but it won't be equal to f_real because of the
# way UndefinedFunction.__new__ works. Any non-recognized assumptions
# are just added literally as something which is used in the hash
f_real2 = Function('f', is_real=True)
assert f_real2(x).is_real is True
def test_undef_fcn_float_issue_6938():
f = Function('ceil')
assert not f(0.3).is_number
f = Function('sin')
assert not f(0.3).is_number
assert not f(pi).evalf().is_number
x = Symbol('x')
assert not f(x).evalf(subs={x:1.2}).is_number
def test_undefined_function_eval():
# Issue 15170. Make sure UndefinedFunction with eval defined works
# properly. The issue there was that the hash was determined before _nargs
# was set, which is included in the hash, hence changing the hash. The
# class is added to sympy.core.core.all_classes before the hash is
# changed, meaning "temp in all_classes" would fail, causing sympify(temp(t))
# to give a new class. We will eventually remove all_classes, but make
# sure this continues to work.
fdiff = lambda self, argindex=1: cos(self.args[argindex - 1])
eval = classmethod(lambda cls, t: None)
_imp_ = classmethod(lambda cls, t: sin(t))
temp = Function('temp', fdiff=fdiff, eval=eval, _imp_=_imp_)
expr = temp(t)
assert sympify(expr) == expr
assert type(sympify(expr)).fdiff.__name__ == "<lambda>"
assert expr.diff(t) == cos(t)
def test_issue_15241():
F = f(x)
Fx = F.diff(x)
assert (F + x*Fx).diff(x, Fx) == 2
assert (F + x*Fx).diff(Fx, x) == 1
assert (x*F + x*Fx*F).diff(F, x) == x*Fx.diff(x) + Fx + 1
assert (x*F + x*Fx*F).diff(x, F) == x*Fx.diff(x) + Fx + 1
y = f(x)
G = f(y)
Gy = G.diff(y)
assert (G + y*Gy).diff(y, Gy) == 2
assert (G + y*Gy).diff(Gy, y) == 1
assert (y*G + y*Gy*G).diff(G, y) == y*Gy.diff(y) + Gy + 1
assert (y*G + y*Gy*G).diff(y, G) == y*Gy.diff(y) + Gy + 1
def test_issue_15226():
assert Subs(Derivative(f(y), x, y), y, g(x)).doit() != 0
def test_issue_7027():
for wrt in (cos(x), re(x), Derivative(cos(x), x)):
raises(ValueError, lambda: diff(f(x), wrt))
def test_derivative_quick_exit():
assert f(x).diff(y) == 0
assert f(x).diff(y, f(x)) == 0
assert f(x).diff(x, f(y)) == 0
assert f(f(x)).diff(x, f(x), f(y)) == 0
assert f(f(x)).diff(x, f(x), y) == 0
assert f(x).diff(g(x)) == 0
assert f(x).diff(x, f(x).diff(x)) == 1
df = f(x).diff(x)
assert f(x).diff(df) == 0
dg = g(x).diff(x)
assert dg.diff(df).doit() == 0
def test_issue_15084_13166():
eq = f(x, g(x))
assert eq.diff((g(x), y)) == Derivative(f(x, g(x)), (g(x), y))
# issue 13166
assert eq.diff(x, 2).doit() == (
(Derivative(f(x, g(x)), (g(x), 2))*Derivative(g(x), x) +
Subs(Derivative(f(x, _xi_2), _xi_2, x), _xi_2, g(x)))*Derivative(g(x),
x) + Derivative(f(x, g(x)), g(x))*Derivative(g(x), (x, 2)) +
Derivative(g(x), x)*Subs(Derivative(f(_xi_1, g(x)), _xi_1, g(x)),
_xi_1, x) + Subs(Derivative(f(_xi_1, g(x)), (_xi_1, 2)), _xi_1, x))
# issue 6681
assert diff(f(x, t, g(x, t)), x).doit() == (
Derivative(f(x, t, g(x, t)), g(x, t))*Derivative(g(x, t), x) +
Subs(Derivative(f(_xi_1, t, g(x, t)), _xi_1), _xi_1, x))
# make sure the order doesn't matter when using diff
assert eq.diff(x, g(x)) == eq.diff(g(x), x)
def test_negative_counts():
# issue 13873
raises(ValueError, lambda: sin(x).diff(x, -1))
def test_Derivative__new__():
raises(TypeError, lambda: f(x).diff((x, 2), 0))
assert f(x, y).diff([(x, y), 0]) == f(x, y)
assert f(x, y).diff([(x, y), 1]) == NDimArray([
Derivative(f(x, y), x), Derivative(f(x, y), y)])
assert f(x,y).diff(y, (x, z), y, x) == Derivative(
f(x, y), (x, z + 1), (y, 2))
assert Matrix([x]).diff(x, 2) == Matrix([0]) # is_zero exit
def test_issue_14719_10150():
class V(Expr):
_diff_wrt = True
is_scalar = False
assert V().diff(V()) == Derivative(V(), V())
assert (2*V()).diff(V()) == 2*Derivative(V(), V())
class X(Expr):
_diff_wrt = True
assert X().diff(X()) == 1
assert (2*X()).diff(X()) == 2
def test_noncommutative_issue_15131():
x = Symbol('x', commutative=False)
t = Symbol('t', commutative=False)
fx = Function('Fx', commutative=False)(x)
ft = Function('Ft', commutative=False)(t)
A = Symbol('A', commutative=False)
eq = fx * A * ft
eqdt = eq.diff(t)
assert eqdt.args[-1] == ft.diff(t)
def test_Subs_Derivative():
a = Derivative(f(g(x), h(x)), g(x), h(x),x)
b = Derivative(Derivative(f(g(x), h(x)), g(x), h(x)),x)
c = f(g(x), h(x)).diff(g(x), h(x), x)
d = f(g(x), h(x)).diff(g(x), h(x)).diff(x)
e = Derivative(f(g(x), h(x)), x)
eqs = (a, b, c, d, e)
subs = lambda arg: arg.subs(f, Lambda((x, y), exp(x + y))
).subs(g(x), 1/x).subs(h(x), x**3)
ans = 3*x**2*exp(1/x)*exp(x**3) - exp(1/x)*exp(x**3)/x**2
assert all(subs(i).doit().expand() == ans for i in eqs)
assert all(subs(i.doit()).doit().expand() == ans for i in eqs)
def test_issue_15360():
f = Function('f')
assert f.name == 'f'
def test_issue_15947():
assert f._diff_wrt is False
raises(TypeError, lambda: f(f))
raises(TypeError, lambda: f(x).diff(f))
def test_Derivative_free_symbols():
f = Function('f')
n = Symbol('n', integer=True, positive=True)
assert diff(f(x), (x, n)).free_symbols == {n, x}
def test_issue_10503():
f = exp(x**3)*cos(x**6)
assert f.series(x, 0, 14) == 1 + x**3 + x**6/2 + x**9/6 - 11*x**12/24 + O(x**14)
|
ea517966548526b38e9cbcb8124913d4466d60114fe230a9a05d22f83193b6d9 | """This tests sympy/core/basic.py with (ideally) no reference to subclasses
of Basic or Atom."""
import collections
import sys
from sympy.core.basic import (Basic, Atom, preorder_traversal, as_Basic,
_atomic, _aresame)
from sympy.core.singleton import S
from sympy.core.symbol import symbols, Symbol
from sympy.core.sympify import SympifyError
from sympy.core.function import Function, Lambda
from sympy.core.compatibility import default_sort_key
from sympy import sin, Q, cos, gamma, Tuple, Integral, Sum
from sympy.functions.elementary.exponential import exp
from sympy.testing.pytest import raises
from sympy.core import I, pi
b1 = Basic()
b2 = Basic(b1)
b3 = Basic(b2)
b21 = Basic(b2, b1)
def test__aresame():
assert not _aresame(Basic([]), Basic())
assert not _aresame(Basic([]), Basic(()))
assert not _aresame(Basic(2), Basic(2.))
def test_structure():
assert b21.args == (b2, b1)
assert b21.func(*b21.args) == b21
assert bool(b1)
def test_equality():
instances = [b1, b2, b3, b21, Basic(b1, b1, b1), Basic]
for i, b_i in enumerate(instances):
for j, b_j in enumerate(instances):
assert (b_i == b_j) == (i == j)
assert (b_i != b_j) == (i != j)
assert Basic() != []
assert not(Basic() == [])
assert Basic() != 0
assert not(Basic() == 0)
class Foo:
"""
Class that is unaware of Basic, and relies on both classes returning
the NotImplemented singleton for equivalence to evaluate to False.
"""
b = Basic()
foo = Foo()
assert b != foo
assert foo != b
assert not b == foo
assert not foo == b
class Bar:
"""
Class that considers itself equal to any instance of Basic, and relies
on Basic returning the NotImplemented singleton in order to achieve
a symmetric equivalence relation.
"""
def __eq__(self, other):
if isinstance(other, Basic):
return True
return NotImplemented
def __ne__(self, other):
return not self == other
bar = Bar()
assert b == bar
assert bar == b
assert not b != bar
assert not bar != b
def test_matches_basic():
instances = [Basic(b1, b1, b2), Basic(b1, b2, b1), Basic(b2, b1, b1),
Basic(b1, b2), Basic(b2, b1), b2, b1]
for i, b_i in enumerate(instances):
for j, b_j in enumerate(instances):
if i == j:
assert b_i.matches(b_j) == {}
else:
assert b_i.matches(b_j) is None
assert b1.match(b1) == {}
def test_has():
assert b21.has(b1)
assert b21.has(b3, b1)
assert b21.has(Basic)
assert not b1.has(b21, b3)
assert not b21.has()
raises(SympifyError, lambda: Symbol("x").has("x"))
def test_subs():
assert b21.subs(b2, b1) == Basic(b1, b1)
assert b21.subs(b2, b21) == Basic(b21, b1)
assert b3.subs(b2, b1) == b2
assert b21.subs([(b2, b1), (b1, b2)]) == Basic(b2, b2)
assert b21.subs({b1: b2, b2: b1}) == Basic(b2, b2)
if sys.version_info >= (3, 4):
assert b21.subs(collections.ChainMap({b1: b2}, {b2: b1})) == Basic(b2, b2)
assert b21.subs(collections.OrderedDict([(b2, b1), (b1, b2)])) == Basic(b2, b2)
raises(ValueError, lambda: b21.subs('bad arg'))
raises(ValueError, lambda: b21.subs(b1, b2, b3))
# dict(b1=foo) creates a string 'b1' but leaves foo unchanged; subs
# will convert the first to a symbol but will raise an error if foo
# cannot be sympified; sympification is strict if foo is not string
raises(ValueError, lambda: b21.subs(b1='bad arg'))
assert Symbol("text").subs({"text": b1}) == b1
assert Symbol("s").subs({"s": 1}) == 1
def test_subs_with_unicode_symbols():
expr = Symbol('var1')
replaced = expr.subs('var1', 'x')
assert replaced.name == 'x'
replaced = expr.subs('var1', 'x')
assert replaced.name == 'x'
def test_atoms():
assert b21.atoms() == {Basic()}
def test_free_symbols_empty():
assert b21.free_symbols == set()
def test_doit():
assert b21.doit() == b21
assert b21.doit(deep=False) == b21
def test_S():
assert repr(S) == 'S'
def test_xreplace():
assert b21.xreplace({b2: b1}) == Basic(b1, b1)
assert b21.xreplace({b2: b21}) == Basic(b21, b1)
assert b3.xreplace({b2: b1}) == b2
assert Basic(b1, b2).xreplace({b1: b2, b2: b1}) == Basic(b2, b1)
assert Atom(b1).xreplace({b1: b2}) == Atom(b1)
assert Atom(b1).xreplace({Atom(b1): b2}) == b2
raises(TypeError, lambda: b1.xreplace())
raises(TypeError, lambda: b1.xreplace([b1, b2]))
for f in (exp, Function('f')):
assert f.xreplace({}) == f
assert f.xreplace({}, hack2=True) == f
assert f.xreplace({f: b1}) == b1
assert f.xreplace({f: b1}, hack2=True) == b1
def test_preorder_traversal():
expr = Basic(b21, b3)
assert list(
preorder_traversal(expr)) == [expr, b21, b2, b1, b1, b3, b2, b1]
assert list(preorder_traversal(('abc', ('d', 'ef')))) == [
('abc', ('d', 'ef')), 'abc', ('d', 'ef'), 'd', 'ef']
result = []
pt = preorder_traversal(expr)
for i in pt:
result.append(i)
if i == b2:
pt.skip()
assert result == [expr, b21, b2, b1, b3, b2]
w, x, y, z = symbols('w:z')
expr = z + w*(x + y)
assert list(preorder_traversal([expr], keys=default_sort_key)) == \
[[w*(x + y) + z], w*(x + y) + z, z, w*(x + y), w, x + y, x, y]
assert list(preorder_traversal((x + y)*z, keys=True)) == \
[z*(x + y), z, x + y, x, y]
def test_sorted_args():
x = symbols('x')
assert b21._sorted_args == b21.args
raises(AttributeError, lambda: x._sorted_args)
def test_call():
x, y = symbols('x y')
# See the long history of this in issues 5026 and 5105.
raises(TypeError, lambda: sin(x)({ x : 1, sin(x) : 2}))
raises(TypeError, lambda: sin(x)(1))
# No effect as there are no callables
assert sin(x).rcall(1) == sin(x)
assert (1 + sin(x)).rcall(1) == 1 + sin(x)
# Effect in the pressence of callables
l = Lambda(x, 2*x)
assert (l + x).rcall(y) == 2*y + x
assert (x**l).rcall(2) == x**4
# TODO UndefinedFunction does not subclass Expr
#f = Function('f')
#assert (2*f)(x) == 2*f(x)
assert (Q.real & Q.positive).rcall(x) == Q.real(x) & Q.positive(x)
def test_rewrite():
x, y, z = symbols('x y z')
a, b = symbols('a b')
f1 = sin(x) + cos(x)
assert f1.rewrite(cos,exp) == exp(I*x)/2 + sin(x) + exp(-I*x)/2
assert f1.rewrite([cos],sin) == sin(x) + sin(x + pi/2, evaluate=False)
f2 = sin(x) + cos(y)/gamma(z)
assert f2.rewrite(sin,exp) == -I*(exp(I*x) - exp(-I*x))/2 + cos(y)/gamma(z)
assert f1.rewrite() == f1
def test_literal_evalf_is_number_is_zero_is_comparable():
from sympy.integrals.integrals import Integral
from sympy.core.symbol import symbols
from sympy.core.function import Function
from sympy.functions.elementary.trigonometric import cos, sin
x = symbols('x')
f = Function('f')
# issue 5033
assert f.is_number is False
# issue 6646
assert f(1).is_number is False
i = Integral(0, (x, x, x))
# expressions that are symbolically 0 can be difficult to prove
# so in case there is some easy way to know if something is 0
# it should appear in the is_zero property for that object;
# if is_zero is true evalf should always be able to compute that
# zero
assert i.n() == 0
assert i.is_zero
assert i.is_number is False
assert i.evalf(2, strict=False) == 0
# issue 10268
n = sin(1)**2 + cos(1)**2 - 1
assert n.is_comparable is False
assert n.n(2).is_comparable is False
assert n.n(2).n(2).is_comparable
def test_as_Basic():
assert as_Basic(1) is S.One
assert as_Basic(()) == Tuple()
raises(TypeError, lambda: as_Basic([]))
def test_atomic():
g, h = map(Function, 'gh')
x = symbols('x')
assert _atomic(g(x + h(x))) == {g(x + h(x))}
assert _atomic(g(x + h(x)), recursive=True) == {h(x), x, g(x + h(x))}
assert _atomic(1) == set()
assert _atomic(Basic(1,2)) == {Basic(1, 2)}
def test_as_dummy():
u, v, x, y, z, _0, _1 = symbols('u v x y z _0 _1')
assert Lambda(x, x + 1).as_dummy() == Lambda(_0, _0 + 1)
assert Lambda(x, x + _0).as_dummy() == Lambda(_1, _0 + _1)
assert (1 + Sum(x, (x, 1, x))).as_dummy() == 1 + Sum(_0, (_0, 1, x))
def test_canonical_variables():
x, i0, i1 = symbols('x _:2')
assert Integral(x, (x, x + 1)).canonical_variables == {x: i0}
assert Integral(x, (x, x + i0)).canonical_variables == {x: i1}
def test_replace_exceptions():
from sympy import Wild
x, y = symbols('x y')
e = (x**2 + x*y)
raises(TypeError, lambda: e.replace(sin, 2))
b = Wild('b')
c = Wild('c')
raises(TypeError, lambda: e.replace(b*c, c.is_real))
raises(TypeError, lambda: e.replace(b.is_real, 1))
raises(TypeError, lambda: e.replace(lambda d: d.is_Number, 1))
|
085fb90b775a0f04a15dc438cc96ec66eb60ae9f053dec0f14e77b08ddbd41d8 | from sympy import Symbol, Dummy, Rational, exp
def test_equal():
b = Symbol("b")
a = Symbol("a")
e1 = a + b
e2 = 2*a*b
e3 = a**3*b**2
e4 = a*b + b*a
assert not e1 == e2
assert not e1 == e2
assert e1 != e2
assert e2 == e4
assert e2 != e3
assert not e2 == e3
x = Symbol("x")
e1 = exp(x + 1/x)
y = Symbol("x")
e2 = exp(y + 1/y)
assert e1 == e2
assert not e1 != e2
y = Symbol("y")
e2 = exp(y + 1/y)
assert not e1 == e2
assert e1 != e2
e5 = Rational(3) + 2*x - x - x
assert e5 == 3
assert 3 == e5
assert e5 != 4
assert 4 != e5
assert e5 != 3 + x
assert 3 + x != e5
def test_expevalbug():
x = Symbol("x")
e1 = exp(1*x)
e3 = exp(x)
assert e1 == e3
def test_cmp_bug1():
class T:
pass
t = T()
x = Symbol("x")
assert not (x == t)
assert (x != t)
def test_cmp_bug2():
class T:
pass
t = T()
assert not (Symbol == t)
assert (Symbol != t)
def test_cmp_issue_4357():
""" Check that Basic subclasses can be compared with sympifiable objects.
https://github.com/sympy/sympy/issues/4357
"""
assert not (Symbol == 1)
assert (Symbol != 1)
assert not (Symbol == 'x')
assert (Symbol != 'x')
def test_dummy_eq():
x = Symbol('x')
y = Symbol('y')
u = Dummy('u')
assert (u**2 + 1).dummy_eq(x**2 + 1) is True
assert ((u**2 + 1) == (x**2 + 1)) is False
assert (u**2 + y).dummy_eq(x**2 + y, x) is True
assert (u**2 + y).dummy_eq(x**2 + y, y) is False
|
60464c67ed75e9516716a278f21f5b42c1767e586207ae6dae766f26c45287fa | from sympy.core.facts import (deduce_alpha_implications,
apply_beta_to_alpha_route, rules_2prereq, FactRules, FactKB)
from sympy.core.logic import And, Not
from sympy.testing.pytest import raises
T = True
F = False
U = None
def test_deduce_alpha_implications():
def D(i):
I = deduce_alpha_implications(i)
P = rules_2prereq({
(k, True): {(v, True) for v in S} for k, S in I.items()})
return I, P
# transitivity
I, P = D([('a', 'b'), ('b', 'c')])
assert I == {'a': {'b', 'c'}, 'b': {'c'}, Not('b'):
{Not('a')}, Not('c'): {Not('a'), Not('b')}}
assert P == {'a': {'b', 'c'}, 'b': {'a', 'c'}, 'c': {'a', 'b'}}
# Duplicate entry
I, P = D([('a', 'b'), ('b', 'c'), ('b', 'c')])
assert I == {'a': {'b', 'c'}, 'b': {'c'}, Not('b'): {Not('a')}, Not('c'): {Not('a'), Not('b')}}
assert P == {'a': {'b', 'c'}, 'b': {'a', 'c'}, 'c': {'a', 'b'}}
# see if it is tolerant to cycles
assert D([('a', 'a'), ('a', 'a')]) == ({}, {})
assert D([('a', 'b'), ('b', 'a')]) == (
{'a': {'b'}, 'b': {'a'}, Not('a'): {Not('b')}, Not('b'): {Not('a')}},
{'a': {'b'}, 'b': {'a'}})
# see if it catches inconsistency
raises(ValueError, lambda: D([('a', Not('a'))]))
raises(ValueError, lambda: D([('a', 'b'), ('b', Not('a'))]))
raises(ValueError, lambda: D([('a', 'b'), ('b', 'c'), ('b', 'na'),
('na', Not('a'))]))
# see if it handles implications with negations
I, P = D([('a', Not('b')), ('c', 'b')])
assert I == {'a': {Not('b'), Not('c')}, 'b': {Not('a')}, 'c': {'b', Not('a')}, Not('b'): {Not('c')}}
assert P == {'a': {'b', 'c'}, 'b': {'a', 'c'}, 'c': {'a', 'b'}}
I, P = D([(Not('a'), 'b'), ('a', 'c')])
assert I == {'a': {'c'}, Not('a'): {'b'}, Not('b'): {'a',
'c'}, Not('c'): {Not('a'), 'b'},}
assert P == {'a': {'b', 'c'}, 'b': {'a', 'c'}, 'c': {'a', 'b'}}
# Long deductions
I, P = D([('a', 'b'), ('b', 'c'), ('c', 'd'), ('d', 'e')])
assert I == {'a': {'b', 'c', 'd', 'e'}, 'b': {'c', 'd', 'e'},
'c': {'d', 'e'}, 'd': {'e'}, Not('b'): {Not('a')},
Not('c'): {Not('a'), Not('b')}, Not('d'): {Not('a'), Not('b'),
Not('c')}, Not('e'): {Not('a'), Not('b'), Not('c'), Not('d')}}
assert P == {'a': {'b', 'c', 'd', 'e'}, 'b': {'a', 'c', 'd',
'e'}, 'c': {'a', 'b', 'd', 'e'}, 'd': {'a', 'b', 'c', 'e'},
'e': {'a', 'b', 'c', 'd'}}
# something related to real-world
I, P = D([('rat', 'real'), ('int', 'rat')])
assert I == {'int': {'rat', 'real'}, 'rat': {'real'},
Not('real'): {Not('rat'), Not('int')}, Not('rat'): {Not('int')}}
assert P == {'rat': {'int', 'real'}, 'real': {'int', 'rat'},
'int': {'rat', 'real'}}
# TODO move me to appropriate place
def test_apply_beta_to_alpha_route():
APPLY = apply_beta_to_alpha_route
# indicates empty alpha-chain with attached beta-rule #bidx
def Q(bidx):
return (set(), [bidx])
# x -> a &(a,b) -> x -- x -> a
A = {'x': {'a'}}
B = [(And('a', 'b'), 'x')]
assert APPLY(A, B) == {'x': ({'a'}, []), 'a': Q(0), 'b': Q(0)}
# x -> a &(a,!x) -> b -- x -> a
A = {'x': {'a'}}
B = [(And('a', Not('x')), 'b')]
assert APPLY(A, B) == {'x': ({'a'}, []), Not('x'): Q(0), 'a': Q(0)}
# x -> a b &(a,b) -> c -- x -> a b c
A = {'x': {'a', 'b'}}
B = [(And('a', 'b'), 'c')]
assert APPLY(A, B) == \
{'x': ({'a', 'b', 'c'}, []), 'a': Q(0), 'b': Q(0)}
# x -> a &(a,b) -> y -- x -> a [#0]
A = {'x': {'a'}}
B = [(And('a', 'b'), 'y')]
assert APPLY(A, B) == {'x': ({'a'}, [0]), 'a': Q(0), 'b': Q(0)}
# x -> a b c &(a,b) -> c -- x -> a b c
A = {'x': {'a', 'b', 'c'}}
B = [(And('a', 'b'), 'c')]
assert APPLY(A, B) == \
{'x': ({'a', 'b', 'c'}, []), 'a': Q(0), 'b': Q(0)}
# x -> a b &(a,b,c) -> y -- x -> a b [#0]
A = {'x': {'a', 'b'}}
B = [(And('a', 'b', 'c'), 'y')]
assert APPLY(A, B) == \
{'x': ({'a', 'b'}, [0]), 'a': Q(0), 'b': Q(0), 'c': Q(0)}
# x -> a b &(a,b) -> c -- x -> a b c d
# c -> d c -> d
A = {'x': {'a', 'b'}, 'c': {'d'}}
B = [(And('a', 'b'), 'c')]
assert APPLY(A, B) == {'x': ({'a', 'b', 'c', 'd'}, []),
'c': ({'d'}, []), 'a': Q(0), 'b': Q(0)}
# x -> a b &(a,b) -> c -- x -> a b c d e
# c -> d &(c,d) -> e c -> d e
A = {'x': {'a', 'b'}, 'c': {'d'}}
B = [(And('a', 'b'), 'c'), (And('c', 'd'), 'e')]
assert APPLY(A, B) == {'x': ({'a', 'b', 'c', 'd', 'e'}, []),
'c': ({'d', 'e'}, []), 'a': Q(0), 'b': Q(0), 'd': Q(1)}
# x -> a b &(a,y) -> z -- x -> a b y z
# &(a,b) -> y
A = {'x': {'a', 'b'}}
B = [(And('a', 'y'), 'z'), (And('a', 'b'), 'y')]
assert APPLY(A, B) == {'x': ({'a', 'b', 'y', 'z'}, []),
'a': (set(), [0, 1]), 'y': Q(0), 'b': Q(1)}
# x -> a b &(a,!b) -> c -- x -> a b
A = {'x': {'a', 'b'}}
B = [(And('a', Not('b')), 'c')]
assert APPLY(A, B) == \
{'x': ({'a', 'b'}, []), 'a': Q(0), Not('b'): Q(0)}
# !x -> !a !b &(!a,b) -> c -- !x -> !a !b
A = {Not('x'): {Not('a'), Not('b')}}
B = [(And(Not('a'), 'b'), 'c')]
assert APPLY(A, B) == \
{Not('x'): ({Not('a'), Not('b')}, []), Not('a'): Q(0), 'b': Q(0)}
# x -> a b &(b,c) -> !a -- x -> a b
A = {'x': {'a', 'b'}}
B = [(And('b', 'c'), Not('a'))]
assert APPLY(A, B) == {'x': ({'a', 'b'}, []), 'b': Q(0), 'c': Q(0)}
# x -> a b &(a, b) -> c -- x -> a b c p
# c -> p a
A = {'x': {'a', 'b'}, 'c': {'p', 'a'}}
B = [(And('a', 'b'), 'c')]
assert APPLY(A, B) == {'x': ({'a', 'b', 'c', 'p'}, []),
'c': ({'p', 'a'}, []), 'a': Q(0), 'b': Q(0)}
def test_FactRules_parse():
f = FactRules('a -> b')
assert f.prereq == {'b': {'a'}, 'a': {'b'}}
f = FactRules('a -> !b')
assert f.prereq == {'b': {'a'}, 'a': {'b'}}
f = FactRules('!a -> b')
assert f.prereq == {'b': {'a'}, 'a': {'b'}}
f = FactRules('!a -> !b')
assert f.prereq == {'b': {'a'}, 'a': {'b'}}
f = FactRules('!z == nz')
assert f.prereq == {'z': {'nz'}, 'nz': {'z'}}
def test_FactRules_parse2():
raises(ValueError, lambda: FactRules('a -> !a'))
def test_FactRules_deduce():
f = FactRules(['a -> b', 'b -> c', 'b -> d', 'c -> e'])
def D(facts):
kb = FactKB(f)
kb.deduce_all_facts(facts)
return kb
assert D({'a': T}) == {'a': T, 'b': T, 'c': T, 'd': T, 'e': T}
assert D({'b': T}) == { 'b': T, 'c': T, 'd': T, 'e': T}
assert D({'c': T}) == { 'c': T, 'e': T}
assert D({'d': T}) == { 'd': T }
assert D({'e': T}) == { 'e': T}
assert D({'a': F}) == {'a': F }
assert D({'b': F}) == {'a': F, 'b': F }
assert D({'c': F}) == {'a': F, 'b': F, 'c': F }
assert D({'d': F}) == {'a': F, 'b': F, 'd': F }
assert D({'a': U}) == {'a': U} # XXX ok?
def test_FactRules_deduce2():
# pos/neg/zero, but the rules are not sufficient to derive all relations
f = FactRules(['pos -> !neg', 'pos -> !z'])
def D(facts):
kb = FactKB(f)
kb.deduce_all_facts(facts)
return kb
assert D({'pos': T}) == {'pos': T, 'neg': F, 'z': F}
assert D({'pos': F}) == {'pos': F }
assert D({'neg': T}) == {'pos': F, 'neg': T }
assert D({'neg': F}) == { 'neg': F }
assert D({'z': T}) == {'pos': F, 'z': T}
assert D({'z': F}) == { 'z': F}
# pos/neg/zero. rules are sufficient to derive all relations
f = FactRules(['pos -> !neg', 'neg -> !pos', 'pos -> !z', 'neg -> !z'])
assert D({'pos': T}) == {'pos': T, 'neg': F, 'z': F}
assert D({'pos': F}) == {'pos': F }
assert D({'neg': T}) == {'pos': F, 'neg': T, 'z': F}
assert D({'neg': F}) == { 'neg': F }
assert D({'z': T}) == {'pos': F, 'neg': F, 'z': T}
assert D({'z': F}) == { 'z': F}
def test_FactRules_deduce_multiple():
# deduction that involves _several_ starting points
f = FactRules(['real == pos | npos'])
def D(facts):
kb = FactKB(f)
kb.deduce_all_facts(facts)
return kb
assert D({'real': T}) == {'real': T}
assert D({'real': F}) == {'real': F, 'pos': F, 'npos': F}
assert D({'pos': T}) == {'real': T, 'pos': T}
assert D({'npos': T}) == {'real': T, 'npos': T}
# --- key tests below ---
assert D({'pos': F, 'npos': F}) == {'real': F, 'pos': F, 'npos': F}
assert D({'real': T, 'pos': F}) == {'real': T, 'pos': F, 'npos': T}
assert D({'real': T, 'npos': F}) == {'real': T, 'pos': T, 'npos': F}
assert D({'pos': T, 'npos': F}) == {'real': T, 'pos': T, 'npos': F}
assert D({'pos': F, 'npos': T}) == {'real': T, 'pos': F, 'npos': T}
def test_FactRules_deduce_multiple2():
f = FactRules(['real == neg | zero | pos'])
def D(facts):
kb = FactKB(f)
kb.deduce_all_facts(facts)
return kb
assert D({'real': T}) == {'real': T}
assert D({'real': F}) == {'real': F, 'neg': F, 'zero': F, 'pos': F}
assert D({'neg': T}) == {'real': T, 'neg': T}
assert D({'zero': T}) == {'real': T, 'zero': T}
assert D({'pos': T}) == {'real': T, 'pos': T}
# --- key tests below ---
assert D({'neg': F, 'zero': F, 'pos': F}) == {'real': F, 'neg': F,
'zero': F, 'pos': F}
assert D({'real': T, 'neg': F}) == {'real': T, 'neg': F}
assert D({'real': T, 'zero': F}) == {'real': T, 'zero': F}
assert D({'real': T, 'pos': F}) == {'real': T, 'pos': F}
assert D({'real': T, 'zero': F, 'pos': F}) == {'real': T,
'neg': T, 'zero': F, 'pos': F}
assert D({'real': T, 'neg': F, 'pos': F}) == {'real': T,
'neg': F, 'zero': T, 'pos': F}
assert D({'real': T, 'neg': F, 'zero': F }) == {'real': T,
'neg': F, 'zero': F, 'pos': T}
assert D({'neg': T, 'zero': F, 'pos': F}) == {'real': T, 'neg': T,
'zero': F, 'pos': F}
assert D({'neg': F, 'zero': T, 'pos': F}) == {'real': T, 'neg': F,
'zero': T, 'pos': F}
assert D({'neg': F, 'zero': F, 'pos': T}) == {'real': T, 'neg': F,
'zero': F, 'pos': T}
def test_FactRules_deduce_base():
# deduction that starts from base
f = FactRules(['real == neg | zero | pos',
'neg -> real & !zero & !pos',
'pos -> real & !zero & !neg'])
base = FactKB(f)
base.deduce_all_facts({'real': T, 'neg': F})
assert base == {'real': T, 'neg': F}
base.deduce_all_facts({'zero': F})
assert base == {'real': T, 'neg': F, 'zero': F, 'pos': T}
def test_FactRules_deduce_staticext():
# verify that static beta-extensions deduction takes place
f = FactRules(['real == neg | zero | pos',
'neg -> real & !zero & !pos',
'pos -> real & !zero & !neg',
'nneg == real & !neg',
'npos == real & !pos'])
assert ('npos', True) in f.full_implications[('neg', True)]
assert ('nneg', True) in f.full_implications[('pos', True)]
assert ('nneg', True) in f.full_implications[('zero', True)]
assert ('npos', True) in f.full_implications[('zero', True)]
|
3f2cc9637f4f62d6d107f314aed642d04dffc5a3059ce86009c6222fd914b314 | from sympy import Symbol, Mul, symbols, Basic
from sympy.testing.pytest import XFAIL
class SymbolInMulOnce(Symbol):
# Test class for a symbol that can only appear once in a `Mul` expression.
pass
Basic._constructor_postprocessor_mapping[SymbolInMulOnce] = {
"Mul": [lambda x: x],
"Pow": [lambda x: x.base if isinstance(x.base, SymbolInMulOnce) else x],
"Add": [lambda x: x],
}
def _postprocess_SymbolRemovesOtherSymbols(expr):
args = tuple(i for i in expr.args if not isinstance(i, Symbol) or isinstance(i, SymbolRemovesOtherSymbols))
if args == expr.args:
return expr
return Mul.fromiter(args)
class SymbolRemovesOtherSymbols(Symbol):
# Test class for a symbol that removes other symbols in `Mul`.
pass
Basic._constructor_postprocessor_mapping[SymbolRemovesOtherSymbols] = {
"Mul": [_postprocess_SymbolRemovesOtherSymbols],
}
class SubclassSymbolInMulOnce(SymbolInMulOnce):
pass
class SubclassSymbolRemovesOtherSymbols(SymbolRemovesOtherSymbols):
pass
def test_constructor_postprocessors1():
x = SymbolInMulOnce("x")
y = SymbolInMulOnce("y")
assert isinstance(3*x, Mul)
assert (3*x).args == (3, x)
assert x*x == x
assert 3*x*x == 3*x
assert 2*x*x + x == 3*x
assert x**3*y*y == x*y
assert x**5 + y*x**3 == x + x*y
w = SymbolRemovesOtherSymbols("w")
assert x*w == w
assert (3*w).args == (3, w)
assert set((w + x).args) == {x, w}
def test_constructor_postprocessors2():
x = SubclassSymbolInMulOnce("x")
y = SubclassSymbolInMulOnce("y")
assert isinstance(3*x, Mul)
assert (3*x).args == (3, x)
assert x*x == x
assert 3*x*x == 3*x
assert 2*x*x + x == 3*x
assert x**3*y*y == x*y
assert x**5 + y*x**3 == x + x*y
w = SubclassSymbolRemovesOtherSymbols("w")
assert x*w == w
assert (3*w).args == (3, w)
assert set((w + x).args) == {x, w}
@XFAIL
def test_subexpression_postprocessors():
# The postprocessors used to work with subexpressions, but the
# functionality was removed. See #15948.
a = symbols("a")
x = SymbolInMulOnce("x")
w = SymbolRemovesOtherSymbols("w")
assert 3*a*w**2 == 3*w**2
assert 3*a*x**3*w**2 == 3*w**2
x = SubclassSymbolInMulOnce("x")
w = SubclassSymbolRemovesOtherSymbols("w")
assert 3*a*w**2 == 3*w**2
assert 3*a*x**3*w**2 == 3*w**2
|
f737308265fee3d5a7289d93bfa895673938d2f29fd27cfbe6336f7841fd2112 | from sympy.core import (
Rational, Symbol, S, Float, Integer, Mul, Number, Pow,
Basic, I, nan, pi, symbols, oo, zoo, N)
from sympy.core.tests.test_evalf import NS
from sympy.core.function import expand_multinomial
from sympy.functions.elementary.miscellaneous import sqrt, cbrt
from sympy.functions.elementary.exponential import exp, log
from sympy.functions.special.error_functions import erf
from sympy.functions.elementary.trigonometric import (
sin, cos, tan, sec, csc, sinh, cosh, tanh, atan)
from sympy.series.order import O
from sympy.core.expr import unchanged
def test_rational():
a = Rational(1, 5)
r = sqrt(5)/5
assert sqrt(a) == r
assert 2*sqrt(a) == 2*r
r = a*a**S.Half
assert a**Rational(3, 2) == r
assert 2*a**Rational(3, 2) == 2*r
r = a**5*a**Rational(2, 3)
assert a**Rational(17, 3) == r
assert 2 * a**Rational(17, 3) == 2*r
def test_large_rational():
e = (Rational(123712**12 - 1, 7) + Rational(1, 7))**Rational(1, 3)
assert e == 234232585392159195136 * (Rational(1, 7)**Rational(1, 3))
def test_negative_real():
def feq(a, b):
return abs(a - b) < 1E-10
assert feq(S.One / Float(-0.5), -Integer(2))
def test_expand():
x = Symbol('x')
assert (2**(-1 - x)).expand() == S.Half*2**(-x)
def test_issue_3449():
#test if powers are simplified correctly
#see also issue 3995
x = Symbol('x')
assert ((x**Rational(1, 3))**Rational(2)) == x**Rational(2, 3)
assert (
(x**Rational(3))**Rational(2, 5)) == (x**Rational(3))**Rational(2, 5)
a = Symbol('a', real=True)
b = Symbol('b', real=True)
assert (a**2)**b == (abs(a)**b)**2
assert sqrt(1/a) != 1/sqrt(a) # e.g. for a = -1
assert (a**3)**Rational(1, 3) != a
assert (x**a)**b != x**(a*b) # e.g. x = -1, a=2, b=1/2
assert (x**.5)**b == x**(.5*b)
assert (x**.5)**.5 == x**.25
assert (x**2.5)**.5 != x**1.25 # e.g. for x = 5*I
k = Symbol('k', integer=True)
m = Symbol('m', integer=True)
assert (x**k)**m == x**(k*m)
assert Number(5)**Rational(2, 3) == Number(25)**Rational(1, 3)
assert (x**.5)**2 == x**1.0
assert (x**2)**k == (x**k)**2 == x**(2*k)
a = Symbol('a', positive=True)
assert (a**3)**Rational(2, 5) == a**Rational(6, 5)
assert (a**2)**b == (a**b)**2
assert (a**Rational(2, 3))**x == a**(x*Rational(2, 3)) != (a**x)**Rational(2, 3)
def test_issue_3866():
assert --sqrt(sqrt(5) - 1) == sqrt(sqrt(5) - 1)
def test_negative_one():
x = Symbol('x', complex=True)
y = Symbol('y', complex=True)
assert 1/x**y == x**(-y)
def test_issue_4362():
neg = Symbol('neg', negative=True)
nonneg = Symbol('nonneg', nonnegative=True)
any = Symbol('any')
num, den = sqrt(1/neg).as_numer_denom()
assert num == sqrt(-1)
assert den == sqrt(-neg)
num, den = sqrt(1/nonneg).as_numer_denom()
assert num == 1
assert den == sqrt(nonneg)
num, den = sqrt(1/any).as_numer_denom()
assert num == sqrt(1/any)
assert den == 1
def eqn(num, den, pow):
return (num/den)**pow
npos = 1
nneg = -1
dpos = 2 - sqrt(3)
dneg = 1 - sqrt(3)
assert dpos > 0 and dneg < 0 and npos > 0 and nneg < 0
# pos or neg integer
eq = eqn(npos, dpos, 2)
assert eq.is_Pow and eq.as_numer_denom() == (1, dpos**2)
eq = eqn(npos, dneg, 2)
assert eq.is_Pow and eq.as_numer_denom() == (1, dneg**2)
eq = eqn(nneg, dpos, 2)
assert eq.is_Pow and eq.as_numer_denom() == (1, dpos**2)
eq = eqn(nneg, dneg, 2)
assert eq.is_Pow and eq.as_numer_denom() == (1, dneg**2)
eq = eqn(npos, dpos, -2)
assert eq.is_Pow and eq.as_numer_denom() == (dpos**2, 1)
eq = eqn(npos, dneg, -2)
assert eq.is_Pow and eq.as_numer_denom() == (dneg**2, 1)
eq = eqn(nneg, dpos, -2)
assert eq.is_Pow and eq.as_numer_denom() == (dpos**2, 1)
eq = eqn(nneg, dneg, -2)
assert eq.is_Pow and eq.as_numer_denom() == (dneg**2, 1)
# pos or neg rational
pow = S.Half
eq = eqn(npos, dpos, pow)
assert eq.is_Pow and eq.as_numer_denom() == (npos**pow, dpos**pow)
eq = eqn(npos, dneg, pow)
assert eq.is_Pow is False and eq.as_numer_denom() == ((-npos)**pow, (-dneg)**pow)
eq = eqn(nneg, dpos, pow)
assert not eq.is_Pow or eq.as_numer_denom() == (nneg**pow, dpos**pow)
eq = eqn(nneg, dneg, pow)
assert eq.is_Pow and eq.as_numer_denom() == ((-nneg)**pow, (-dneg)**pow)
eq = eqn(npos, dpos, -pow)
assert eq.is_Pow and eq.as_numer_denom() == (dpos**pow, npos**pow)
eq = eqn(npos, dneg, -pow)
assert eq.is_Pow is False and eq.as_numer_denom() == (-(-npos)**pow*(-dneg)**pow, npos)
eq = eqn(nneg, dpos, -pow)
assert not eq.is_Pow or eq.as_numer_denom() == (dpos**pow, nneg**pow)
eq = eqn(nneg, dneg, -pow)
assert eq.is_Pow and eq.as_numer_denom() == ((-dneg)**pow, (-nneg)**pow)
# unknown exponent
pow = 2*any
eq = eqn(npos, dpos, pow)
assert eq.is_Pow and eq.as_numer_denom() == (npos**pow, dpos**pow)
eq = eqn(npos, dneg, pow)
assert eq.is_Pow and eq.as_numer_denom() == ((-npos)**pow, (-dneg)**pow)
eq = eqn(nneg, dpos, pow)
assert eq.is_Pow and eq.as_numer_denom() == (nneg**pow, dpos**pow)
eq = eqn(nneg, dneg, pow)
assert eq.is_Pow and eq.as_numer_denom() == ((-nneg)**pow, (-dneg)**pow)
eq = eqn(npos, dpos, -pow)
assert eq.as_numer_denom() == (dpos**pow, npos**pow)
eq = eqn(npos, dneg, -pow)
assert eq.is_Pow and eq.as_numer_denom() == ((-dneg)**pow, (-npos)**pow)
eq = eqn(nneg, dpos, -pow)
assert eq.is_Pow and eq.as_numer_denom() == (dpos**pow, nneg**pow)
eq = eqn(nneg, dneg, -pow)
assert eq.is_Pow and eq.as_numer_denom() == ((-dneg)**pow, (-nneg)**pow)
x = Symbol('x')
y = Symbol('y')
assert ((1/(1 + x/3))**(-S.One)).as_numer_denom() == (3 + x, 3)
notp = Symbol('notp', positive=False) # not positive does not imply real
b = ((1 + x/notp)**-2)
assert (b**(-y)).as_numer_denom() == (1, b**y)
assert (b**(-S.One)).as_numer_denom() == ((notp + x)**2, notp**2)
nonp = Symbol('nonp', nonpositive=True)
assert (((1 + x/nonp)**-2)**(-S.One)).as_numer_denom() == ((-nonp -
x)**2, nonp**2)
n = Symbol('n', negative=True)
assert (x**n).as_numer_denom() == (1, x**-n)
assert sqrt(1/n).as_numer_denom() == (S.ImaginaryUnit, sqrt(-n))
n = Symbol('0 or neg', nonpositive=True)
# if x and n are split up without negating each term and n is negative
# then the answer might be wrong; if n is 0 it won't matter since
# 1/oo and 1/zoo are both zero as is sqrt(0)/sqrt(-x) unless x is also
# zero (in which case the negative sign doesn't matter):
# 1/sqrt(1/-1) = -I but sqrt(-1)/sqrt(1) = I
assert (1/sqrt(x/n)).as_numer_denom() == (sqrt(-n), sqrt(-x))
c = Symbol('c', complex=True)
e = sqrt(1/c)
assert e.as_numer_denom() == (e, 1)
i = Symbol('i', integer=True)
assert ((1 + x/y)**i).as_numer_denom() == ((x + y)**i, y**i)
def test_Pow_signs():
"""Cf. issues 4595 and 5250"""
x = Symbol('x')
y = Symbol('y')
n = Symbol('n', even=True)
assert (3 - y)**2 != (y - 3)**2
assert (3 - y)**n != (y - 3)**n
assert (-3 + y - x)**2 != (3 - y + x)**2
assert (y - 3)**3 != -(3 - y)**3
def test_power_with_noncommutative_mul_as_base():
x = Symbol('x', commutative=False)
y = Symbol('y', commutative=False)
assert not (x*y)**3 == x**3*y**3
assert (2*x*y)**3 == 8*(x*y)**3
def test_power_rewrite_exp():
assert (I**I).rewrite(exp) == exp(-pi/2)
expr = (2 + 3*I)**(4 + 5*I)
assert expr.rewrite(exp) == exp((4 + 5*I)*(log(sqrt(13)) + I*atan(Rational(3, 2))))
assert expr.rewrite(exp).expand() == \
169*exp(5*I*log(13)/2)*exp(4*I*atan(Rational(3, 2)))*exp(-5*atan(Rational(3, 2)))
assert ((6 + 7*I)**5).rewrite(exp) == 7225*sqrt(85)*exp(5*I*atan(Rational(7, 6)))
expr = 5**(6 + 7*I)
assert expr.rewrite(exp) == exp((6 + 7*I)*log(5))
assert expr.rewrite(exp).expand() == 15625*exp(7*I*log(5))
assert Pow(123, 789, evaluate=False).rewrite(exp) == 123**789
assert (1**I).rewrite(exp) == 1**I
assert (0**I).rewrite(exp) == 0**I
expr = (-2)**(2 + 5*I)
assert expr.rewrite(exp) == exp((2 + 5*I)*(log(2) + I*pi))
assert expr.rewrite(exp).expand() == 4*exp(-5*pi)*exp(5*I*log(2))
assert ((-2)**S(-5)).rewrite(exp) == (-2)**S(-5)
x, y = symbols('x y')
assert (x**y).rewrite(exp) == exp(y*log(x))
assert (7**x).rewrite(exp) == exp(x*log(7), evaluate=False)
assert ((2 + 3*I)**x).rewrite(exp) == exp(x*(log(sqrt(13)) + I*atan(Rational(3, 2))))
assert (y**(5 + 6*I)).rewrite(exp) == exp(log(y)*(5 + 6*I))
assert all((1/func(x)).rewrite(exp) == 1/(func(x).rewrite(exp)) for func in
(sin, cos, tan, sec, csc, sinh, cosh, tanh))
def test_zero():
x = Symbol('x')
y = Symbol('y')
assert 0**x != 0
assert 0**(2*x) == 0**x
assert 0**(1.0*x) == 0**x
assert 0**(2.0*x) == 0**x
assert (0**(2 - x)).as_base_exp() == (0, 2 - x)
assert 0**(x - 2) != S.Infinity**(2 - x)
assert 0**(2*x*y) == 0**(x*y)
assert 0**(-2*x*y) == S.ComplexInfinity**(x*y)
def test_pow_as_base_exp():
x = Symbol('x')
assert (S.Infinity**(2 - x)).as_base_exp() == (S.Infinity, 2 - x)
assert (S.Infinity**(x - 2)).as_base_exp() == (S.Infinity, x - 2)
p = S.Half**x
assert p.base, p.exp == p.as_base_exp() == (S(2), -x)
# issue 8344:
assert Pow(1, 2, evaluate=False).as_base_exp() == (S.One, S(2))
def test_issue_6100_12942_4473():
x = Symbol('x')
y = Symbol('y')
assert x**1.0 != x
assert x != x**1.0
assert True != x**1.0
assert x**1.0 is not True
assert x is not True
assert x*y != (x*y)**1.0
# Pow != Symbol
assert (x**1.0)**1.0 != x
assert (x**1.0)**2.0 != x**2
b = Basic()
assert Pow(b, 1.0, evaluate=False) != b
# if the following gets distributed as a Mul (x**1.0*y**1.0 then
# __eq__ methods could be added to Symbol and Pow to detect the
# power-of-1.0 case.
assert ((x*y)**1.0).func is Pow
def test_issue_6208():
from sympy import root, Rational
I = S.ImaginaryUnit
assert sqrt(33**(I*Rational(9, 10))) == -33**(I*Rational(9, 20))
assert root((6*I)**(2*I), 3).as_base_exp()[1] == Rational(1, 3) # != 2*I/3
assert root((6*I)**(I/3), 3).as_base_exp()[1] == I/9
assert sqrt(exp(3*I)) == exp(I*Rational(3, 2))
assert sqrt(-sqrt(3)*(1 + 2*I)) == sqrt(sqrt(3))*sqrt(-1 - 2*I)
assert sqrt(exp(5*I)) == -exp(I*Rational(5, 2))
assert root(exp(5*I), 3).exp == Rational(1, 3)
def test_issue_6990():
x = Symbol('x')
a = Symbol('a')
b = Symbol('b')
assert (sqrt(a + b*x + x**2)).series(x, 0, 3).removeO() == \
b*x/(2*sqrt(a)) + x**2*(1/(2*sqrt(a)) - \
b**2/(8*a**Rational(3, 2))) + sqrt(a)
def test_issue_6068():
x = Symbol('x')
assert sqrt(sin(x)).series(x, 0, 7) == \
sqrt(x) - x**Rational(5, 2)/12 + x**Rational(9, 2)/1440 - \
x**Rational(13, 2)/24192 + O(x**7)
assert sqrt(sin(x)).series(x, 0, 9) == \
sqrt(x) - x**Rational(5, 2)/12 + x**Rational(9, 2)/1440 - \
x**Rational(13, 2)/24192 - 67*x**Rational(17, 2)/29030400 + O(x**9)
assert sqrt(sin(x**3)).series(x, 0, 19) == \
x**Rational(3, 2) - x**Rational(15, 2)/12 + x**Rational(27, 2)/1440 + O(x**19)
assert sqrt(sin(x**3)).series(x, 0, 20) == \
x**Rational(3, 2) - x**Rational(15, 2)/12 + x**Rational(27, 2)/1440 - \
x**Rational(39, 2)/24192 + O(x**20)
def test_issue_6782():
x = Symbol('x')
assert sqrt(sin(x**3)).series(x, 0, 7) == x**Rational(3, 2) + O(x**7)
assert sqrt(sin(x**4)).series(x, 0, 3) == x**2 + O(x**3)
def test_issue_6653():
x = Symbol('x')
assert (1 / sqrt(1 + sin(x**2))).series(x, 0, 3) == 1 - x**2/2 + O(x**3)
def test_issue_6429():
x = Symbol('x')
c = Symbol('c')
f = (c**2 + x)**(0.5)
assert f.series(x, x0=0, n=1) == (c**2)**0.5 + O(x)
assert f.taylor_term(0, x) == (c**2)**0.5
assert f.taylor_term(1, x) == 0.5*x*(c**2)**(-0.5)
assert f.taylor_term(2, x) == -0.125*x**2*(c**2)**(-1.5)
def test_issue_7638():
f = pi/log(sqrt(2))
assert ((1 + I)**(I*f/2))**0.3 == (1 + I)**(0.15*I*f)
# if 1/3 -> 1.0/3 this should fail since it cannot be shown that the
# sign will be +/-1; for the previous "small arg" case, it didn't matter
# that this could not be proved
assert (1 + I)**(4*I*f) == ((1 + I)**(12*I*f))**Rational(1, 3)
assert (((1 + I)**(I*(1 + 7*f)))**Rational(1, 3)).exp == Rational(1, 3)
r = symbols('r', real=True)
assert sqrt(r**2) == abs(r)
assert cbrt(r**3) != r
assert sqrt(Pow(2*I, 5*S.Half)) != (2*I)**Rational(5, 4)
p = symbols('p', positive=True)
assert cbrt(p**2) == p**Rational(2, 3)
assert NS(((0.2 + 0.7*I)**(0.7 + 1.0*I))**(0.5 - 0.1*I), 1) == '0.4 + 0.2*I'
assert sqrt(1/(1 + I)) == sqrt(1 - I)/sqrt(2) # or 1/sqrt(1 + I)
e = 1/(1 - sqrt(2))
assert sqrt(e) == I/sqrt(-1 + sqrt(2))
assert e**Rational(-1, 2) == -I*sqrt(-1 + sqrt(2))
assert sqrt((cos(1)**2 + sin(1)**2 - 1)**(3 + I)).exp in [S.Half,
Rational(3, 2) + I/2]
assert sqrt(r**Rational(4, 3)) != r**Rational(2, 3)
assert sqrt((p + I)**Rational(4, 3)) == (p + I)**Rational(2, 3)
assert sqrt((p - p**2*I)**2) == p - p**2*I
assert sqrt((p + r*I)**2) != p + r*I
e = (1 + I/5)
assert sqrt(e**5) == e**(5*S.Half)
assert sqrt(e**6) == e**3
assert sqrt((1 + I*r)**6) != (1 + I*r)**3
def test_issue_8582():
assert 1**oo is nan
assert 1**(-oo) is nan
assert 1**zoo is nan
assert 1**(oo + I) is nan
assert 1**(1 + I*oo) is nan
assert 1**(oo + I*oo) is nan
def test_issue_8650():
n = Symbol('n', integer=True, nonnegative=True)
assert (n**n).is_positive is True
x = 5*n + 5
assert (x**(5*(n + 1))).is_positive is True
def test_issue_13914():
b = Symbol('b')
assert (-1)**zoo is nan
assert 2**zoo is nan
assert (S.Half)**(1 + zoo) is nan
assert I**(zoo + I) is nan
assert b**(I + zoo) is nan
def test_better_sqrt():
n = Symbol('n', integer=True, nonnegative=True)
assert sqrt(3 + 4*I) == 2 + I
assert sqrt(3 - 4*I) == 2 - I
assert sqrt(-3 - 4*I) == 1 - 2*I
assert sqrt(-3 + 4*I) == 1 + 2*I
assert sqrt(32 + 24*I) == 6 + 2*I
assert sqrt(32 - 24*I) == 6 - 2*I
assert sqrt(-32 - 24*I) == 2 - 6*I
assert sqrt(-32 + 24*I) == 2 + 6*I
# triple (3, 4, 5):
# parity of 3 matches parity of 5 and
# den, 4, is a square
assert sqrt((3 + 4*I)/4) == 1 + I/2
# triple (8, 15, 17)
# parity of 8 doesn't match parity of 17 but
# den/2, 8/2, is a square
assert sqrt((8 + 15*I)/8) == (5 + 3*I)/4
# handle the denominator
assert sqrt((3 - 4*I)/25) == (2 - I)/5
assert sqrt((3 - 4*I)/26) == (2 - I)/sqrt(26)
# mul
# issue #12739
assert sqrt((3 + 4*I)/(3 - 4*I)) == (3 + 4*I)/5
assert sqrt(2/(3 + 4*I)) == sqrt(2)/5*(2 - I)
assert sqrt(n/(3 + 4*I)).subs(n, 2) == sqrt(2)/5*(2 - I)
assert sqrt(-2/(3 + 4*I)) == sqrt(2)/5*(1 + 2*I)
assert sqrt(-n/(3 + 4*I)).subs(n, 2) == sqrt(2)/5*(1 + 2*I)
# power
assert sqrt(1/(3 + I*4)) == (2 - I)/5
assert sqrt(1/(3 - I)) == sqrt(10)*sqrt(3 + I)/10
# symbolic
i = symbols('i', imaginary=True)
assert sqrt(3/i) == Mul(sqrt(3), 1/sqrt(i), evaluate=False)
# multiples of 1/2; don't make this too automatic
assert sqrt(3 + 4*I)**3 == (2 + I)**3
assert Pow(3 + 4*I, Rational(3, 2)) == 2 + 11*I
assert Pow(6 + 8*I, Rational(3, 2)) == 2*sqrt(2)*(2 + 11*I)
n, d = (3 + 4*I), (3 - 4*I)**3
a = n/d
assert a.args == (1/d, n)
eq = sqrt(a)
assert eq.args == (a, S.Half)
assert expand_multinomial(eq) == sqrt((-117 + 44*I)*(3 + 4*I))/125
assert eq.expand() == (7 - 24*I)/125
# issue 12775
# pos im part
assert sqrt(2*I) == (1 + I)
assert sqrt(2*9*I) == Mul(3, 1 + I, evaluate=False)
assert Pow(2*I, 3*S.Half) == (1 + I)**3
# neg im part
assert sqrt(-I/2) == Mul(S.Half, 1 - I, evaluate=False)
# fractional im part
assert Pow(Rational(-9, 2)*I, Rational(3, 2)) == 27*(1 - I)**3/8
def test_issue_2993():
x = Symbol('x')
assert str((2.3*x - 4)**0.3) == '1.5157165665104*(0.575*x - 1)**0.3'
assert str((2.3*x + 4)**0.3) == '1.5157165665104*(0.575*x + 1)**0.3'
assert str((-2.3*x + 4)**0.3) == '1.5157165665104*(1 - 0.575*x)**0.3'
assert str((-2.3*x - 4)**0.3) == '1.5157165665104*(-0.575*x - 1)**0.3'
assert str((2.3*x - 2)**0.3) == '1.28386201800527*(x - 0.869565217391304)**0.3'
assert str((-2.3*x - 2)**0.3) == '1.28386201800527*(-x - 0.869565217391304)**0.3'
assert str((-2.3*x + 2)**0.3) == '1.28386201800527*(0.869565217391304 - x)**0.3'
assert str((2.3*x + 2)**0.3) == '1.28386201800527*(x + 0.869565217391304)**0.3'
assert str((2.3*x - 4)**Rational(1, 3)) == '2**(2/3)*(0.575*x - 1)**(1/3)'
eq = (2.3*x + 4)
assert eq**2 == 16*(0.575*x + 1)**2
assert (1/eq).args == (eq, -1) # don't change trivial power
# issue 17735
q=.5*exp(x) - .5*exp(-x) + 0.1
assert int((q**2).subs(x, 1)) == 1
# issue 17756
y = Symbol('y')
assert len(sqrt(x/(x + y)**2 + Float('0.008', 30)).subs(y, pi.n(25)).atoms(Float)) == 2
# issue 17756
a, b, c, d, e, f, g = symbols('a:g')
expr = sqrt(1 + a*(c**4 + g*d - 2*g*e - f*(-g + d))**2/
(c**3*b**2*(d - 3*e + 2*f)**2))/2
r = [
(a, N('0.0170992456333788667034850458615', 30)),
(b, N('0.0966594956075474769169134801223', 30)),
(c, N('0.390911862903463913632151616184', 30)),
(d, N('0.152812084558656566271750185933', 30)),
(e, N('0.137562344465103337106561623432', 30)),
(f, N('0.174259178881496659302933610355', 30)),
(g, N('0.220745448491223779615401870086', 30))]
tru = expr.n(30, subs=dict(r))
seq = expr.subs(r)
# although `tru` is the right way to evaluate
# expr with numerical values, `seq` will have
# significant loss of precision if extraction of
# the largest coefficient of a power's base's terms
# is done improperly
assert seq == tru
def test_issue_17450():
assert (erf(cosh(1)**7)**I).is_real is None
assert (erf(cosh(1)**7)**I).is_imaginary is False
assert (Pow(exp(1+sqrt(2)), ((1-sqrt(2))*I*pi), evaluate=False)).is_real is None
assert ((-10)**(10*I*pi/3)).is_real is False
assert ((-5)**(4*I*pi)).is_real is False
def test_issue_18190():
assert sqrt(1 / tan(1 + I)) == 1 / sqrt(tan(1 + I))
def test_issue_14815():
x = Symbol('x', real=True)
assert sqrt(x).is_extended_negative is False
x = Symbol('x', real=False)
assert sqrt(x).is_extended_negative is None
x = Symbol('x', complex=True)
assert sqrt(x).is_extended_negative is False
x = Symbol('x', extended_real=True)
assert sqrt(x).is_extended_negative is False
assert sqrt(zoo, evaluate=False).is_extended_negative is None
assert sqrt(nan, evaluate=False).is_extended_negative is None
def test_issue_18509():
assert unchanged(Mul, oo, 1/pi**oo)
assert (1/pi**oo).is_extended_positive == False
def test_issue_18762():
e, p = symbols('e p')
g0 = sqrt(1 + e**2 - 2*e*cos(p))
assert len(g0.series(e, 1, 3).args) == 4
|
df94532007a6891cb16696f3be918d654ede1cb42578ecca86fbc3f2880a33af | from sympy import I, sqrt, log, exp, sin, asin, factorial, Mod, pi, oo
from sympy.core import Symbol, S, Rational, Integer, Dummy, Wild, Pow
from sympy.core.assumptions import (assumptions, check_assumptions,
failing_assumptions, common_assumptions)
from sympy.core.facts import InconsistentAssumptions
from sympy import simplify
from sympy.testing.pytest import raises, XFAIL
def test_symbol_unset():
x = Symbol('x', real=True, integer=True)
assert x.is_real is True
assert x.is_integer is True
assert x.is_imaginary is False
assert x.is_noninteger is False
assert x.is_number is False
def test_zero():
z = Integer(0)
assert z.is_commutative is True
assert z.is_integer is True
assert z.is_rational is True
assert z.is_algebraic is True
assert z.is_transcendental is False
assert z.is_real is True
assert z.is_complex is True
assert z.is_noninteger is False
assert z.is_irrational is False
assert z.is_imaginary is False
assert z.is_positive is False
assert z.is_negative is False
assert z.is_nonpositive is True
assert z.is_nonnegative is True
assert z.is_even is True
assert z.is_odd is False
assert z.is_finite is True
assert z.is_infinite is False
assert z.is_comparable is True
assert z.is_prime is False
assert z.is_composite is False
assert z.is_number is True
def test_one():
z = Integer(1)
assert z.is_commutative is True
assert z.is_integer is True
assert z.is_rational is True
assert z.is_algebraic is True
assert z.is_transcendental is False
assert z.is_real is True
assert z.is_complex is True
assert z.is_noninteger is False
assert z.is_irrational is False
assert z.is_imaginary is False
assert z.is_positive is True
assert z.is_negative is False
assert z.is_nonpositive is False
assert z.is_nonnegative is True
assert z.is_even is False
assert z.is_odd is True
assert z.is_finite is True
assert z.is_infinite is False
assert z.is_comparable is True
assert z.is_prime is False
assert z.is_number is True
assert z.is_composite is False # issue 8807
def test_negativeone():
z = Integer(-1)
assert z.is_commutative is True
assert z.is_integer is True
assert z.is_rational is True
assert z.is_algebraic is True
assert z.is_transcendental is False
assert z.is_real is True
assert z.is_complex is True
assert z.is_noninteger is False
assert z.is_irrational is False
assert z.is_imaginary is False
assert z.is_positive is False
assert z.is_negative is True
assert z.is_nonpositive is True
assert z.is_nonnegative is False
assert z.is_even is False
assert z.is_odd is True
assert z.is_finite is True
assert z.is_infinite is False
assert z.is_comparable is True
assert z.is_prime is False
assert z.is_composite is False
assert z.is_number is True
def test_infinity():
oo = S.Infinity
assert oo.is_commutative is True
assert oo.is_integer is False
assert oo.is_rational is False
assert oo.is_algebraic is False
assert oo.is_transcendental is False
assert oo.is_extended_real is True
assert oo.is_real is False
assert oo.is_complex is False
assert oo.is_noninteger is True
assert oo.is_irrational is False
assert oo.is_imaginary is False
assert oo.is_nonzero is False
assert oo.is_positive is False
assert oo.is_negative is False
assert oo.is_nonpositive is False
assert oo.is_nonnegative is False
assert oo.is_extended_nonzero is True
assert oo.is_extended_positive is True
assert oo.is_extended_negative is False
assert oo.is_extended_nonpositive is False
assert oo.is_extended_nonnegative is True
assert oo.is_even is False
assert oo.is_odd is False
assert oo.is_finite is False
assert oo.is_infinite is True
assert oo.is_comparable is True
assert oo.is_prime is False
assert oo.is_composite is False
assert oo.is_number is True
def test_neg_infinity():
mm = S.NegativeInfinity
assert mm.is_commutative is True
assert mm.is_integer is False
assert mm.is_rational is False
assert mm.is_algebraic is False
assert mm.is_transcendental is False
assert mm.is_extended_real is True
assert mm.is_real is False
assert mm.is_complex is False
assert mm.is_noninteger is True
assert mm.is_irrational is False
assert mm.is_imaginary is False
assert mm.is_nonzero is False
assert mm.is_positive is False
assert mm.is_negative is False
assert mm.is_nonpositive is False
assert mm.is_nonnegative is False
assert mm.is_extended_nonzero is True
assert mm.is_extended_positive is False
assert mm.is_extended_negative is True
assert mm.is_extended_nonpositive is True
assert mm.is_extended_nonnegative is False
assert mm.is_even is False
assert mm.is_odd is False
assert mm.is_finite is False
assert mm.is_infinite is True
assert mm.is_comparable is True
assert mm.is_prime is False
assert mm.is_composite is False
assert mm.is_number is True
def test_zoo():
zoo = S.ComplexInfinity
assert zoo.is_complex is False
assert zoo.is_real is False
assert zoo.is_prime is False
def test_nan():
nan = S.NaN
assert nan.is_commutative is True
assert nan.is_integer is None
assert nan.is_rational is None
assert nan.is_algebraic is None
assert nan.is_transcendental is None
assert nan.is_real is None
assert nan.is_complex is None
assert nan.is_noninteger is None
assert nan.is_irrational is None
assert nan.is_imaginary is None
assert nan.is_positive is None
assert nan.is_negative is None
assert nan.is_nonpositive is None
assert nan.is_nonnegative is None
assert nan.is_even is None
assert nan.is_odd is None
assert nan.is_finite is None
assert nan.is_infinite is None
assert nan.is_comparable is False
assert nan.is_prime is None
assert nan.is_composite is None
assert nan.is_number is True
def test_pos_rational():
r = Rational(3, 4)
assert r.is_commutative is True
assert r.is_integer is False
assert r.is_rational is True
assert r.is_algebraic is True
assert r.is_transcendental is False
assert r.is_real is True
assert r.is_complex is True
assert r.is_noninteger is True
assert r.is_irrational is False
assert r.is_imaginary is False
assert r.is_positive is True
assert r.is_negative is False
assert r.is_nonpositive is False
assert r.is_nonnegative is True
assert r.is_even is False
assert r.is_odd is False
assert r.is_finite is True
assert r.is_infinite is False
assert r.is_comparable is True
assert r.is_prime is False
assert r.is_composite is False
r = Rational(1, 4)
assert r.is_nonpositive is False
assert r.is_positive is True
assert r.is_negative is False
assert r.is_nonnegative is True
r = Rational(5, 4)
assert r.is_negative is False
assert r.is_positive is True
assert r.is_nonpositive is False
assert r.is_nonnegative is True
r = Rational(5, 3)
assert r.is_nonnegative is True
assert r.is_positive is True
assert r.is_negative is False
assert r.is_nonpositive is False
def test_neg_rational():
r = Rational(-3, 4)
assert r.is_positive is False
assert r.is_nonpositive is True
assert r.is_negative is True
assert r.is_nonnegative is False
r = Rational(-1, 4)
assert r.is_nonpositive is True
assert r.is_positive is False
assert r.is_negative is True
assert r.is_nonnegative is False
r = Rational(-5, 4)
assert r.is_negative is True
assert r.is_positive is False
assert r.is_nonpositive is True
assert r.is_nonnegative is False
r = Rational(-5, 3)
assert r.is_nonnegative is False
assert r.is_positive is False
assert r.is_negative is True
assert r.is_nonpositive is True
def test_pi():
z = S.Pi
assert z.is_commutative is True
assert z.is_integer is False
assert z.is_rational is False
assert z.is_algebraic is False
assert z.is_transcendental is True
assert z.is_real is True
assert z.is_complex is True
assert z.is_noninteger is True
assert z.is_irrational is True
assert z.is_imaginary is False
assert z.is_positive is True
assert z.is_negative is False
assert z.is_nonpositive is False
assert z.is_nonnegative is True
assert z.is_even is False
assert z.is_odd is False
assert z.is_finite is True
assert z.is_infinite is False
assert z.is_comparable is True
assert z.is_prime is False
assert z.is_composite is False
def test_E():
z = S.Exp1
assert z.is_commutative is True
assert z.is_integer is False
assert z.is_rational is False
assert z.is_algebraic is False
assert z.is_transcendental is True
assert z.is_real is True
assert z.is_complex is True
assert z.is_noninteger is True
assert z.is_irrational is True
assert z.is_imaginary is False
assert z.is_positive is True
assert z.is_negative is False
assert z.is_nonpositive is False
assert z.is_nonnegative is True
assert z.is_even is False
assert z.is_odd is False
assert z.is_finite is True
assert z.is_infinite is False
assert z.is_comparable is True
assert z.is_prime is False
assert z.is_composite is False
def test_I():
z = S.ImaginaryUnit
assert z.is_commutative is True
assert z.is_integer is False
assert z.is_rational is False
assert z.is_algebraic is True
assert z.is_transcendental is False
assert z.is_real is False
assert z.is_complex is True
assert z.is_noninteger is False
assert z.is_irrational is False
assert z.is_imaginary is True
assert z.is_positive is False
assert z.is_negative is False
assert z.is_nonpositive is False
assert z.is_nonnegative is False
assert z.is_even is False
assert z.is_odd is False
assert z.is_finite is True
assert z.is_infinite is False
assert z.is_comparable is False
assert z.is_prime is False
assert z.is_composite is False
def test_symbol_real_false():
# issue 3848
a = Symbol('a', real=False)
assert a.is_real is False
assert a.is_integer is False
assert a.is_zero is False
assert a.is_negative is False
assert a.is_positive is False
assert a.is_nonnegative is False
assert a.is_nonpositive is False
assert a.is_nonzero is False
assert a.is_extended_negative is None
assert a.is_extended_positive is None
assert a.is_extended_nonnegative is None
assert a.is_extended_nonpositive is None
assert a.is_extended_nonzero is None
def test_symbol_extended_real_false():
# issue 3848
a = Symbol('a', extended_real=False)
assert a.is_real is False
assert a.is_integer is False
assert a.is_zero is False
assert a.is_negative is False
assert a.is_positive is False
assert a.is_nonnegative is False
assert a.is_nonpositive is False
assert a.is_nonzero is False
assert a.is_extended_negative is False
assert a.is_extended_positive is False
assert a.is_extended_nonnegative is False
assert a.is_extended_nonpositive is False
assert a.is_extended_nonzero is False
def test_symbol_imaginary():
a = Symbol('a', imaginary=True)
assert a.is_real is False
assert a.is_integer is False
assert a.is_negative is False
assert a.is_positive is False
assert a.is_nonnegative is False
assert a.is_nonpositive is False
assert a.is_zero is False
assert a.is_nonzero is False # since nonzero -> real
def test_symbol_zero():
x = Symbol('x', zero=True)
assert x.is_positive is False
assert x.is_nonpositive
assert x.is_negative is False
assert x.is_nonnegative
assert x.is_zero is True
# TODO Change to x.is_nonzero is None
# See https://github.com/sympy/sympy/pull/9583
assert x.is_nonzero is False
assert x.is_finite is True
def test_symbol_positive():
x = Symbol('x', positive=True)
assert x.is_positive is True
assert x.is_nonpositive is False
assert x.is_negative is False
assert x.is_nonnegative is True
assert x.is_zero is False
assert x.is_nonzero is True
def test_neg_symbol_positive():
x = -Symbol('x', positive=True)
assert x.is_positive is False
assert x.is_nonpositive is True
assert x.is_negative is True
assert x.is_nonnegative is False
assert x.is_zero is False
assert x.is_nonzero is True
def test_symbol_nonpositive():
x = Symbol('x', nonpositive=True)
assert x.is_positive is False
assert x.is_nonpositive is True
assert x.is_negative is None
assert x.is_nonnegative is None
assert x.is_zero is None
assert x.is_nonzero is None
def test_neg_symbol_nonpositive():
x = -Symbol('x', nonpositive=True)
assert x.is_positive is None
assert x.is_nonpositive is None
assert x.is_negative is False
assert x.is_nonnegative is True
assert x.is_zero is None
assert x.is_nonzero is None
def test_symbol_falsepositive():
x = Symbol('x', positive=False)
assert x.is_positive is False
assert x.is_nonpositive is None
assert x.is_negative is None
assert x.is_nonnegative is None
assert x.is_zero is None
assert x.is_nonzero is None
def test_symbol_falsepositive_mul():
# To test pull request 9379
# Explicit handling of arg.is_positive=False was added to Mul._eval_is_positive
x = 2*Symbol('x', positive=False)
assert x.is_positive is False # This was None before
assert x.is_nonpositive is None
assert x.is_negative is None
assert x.is_nonnegative is None
assert x.is_zero is None
assert x.is_nonzero is None
@XFAIL
def test_symbol_infinitereal_mul():
ix = Symbol('ix', infinite=True, extended_real=True)
assert (-ix).is_extended_positive is None
def test_neg_symbol_falsepositive():
x = -Symbol('x', positive=False)
assert x.is_positive is None
assert x.is_nonpositive is None
assert x.is_negative is False
assert x.is_nonnegative is None
assert x.is_zero is None
assert x.is_nonzero is None
def test_neg_symbol_falsenegative():
# To test pull request 9379
# Explicit handling of arg.is_negative=False was added to Mul._eval_is_positive
x = -Symbol('x', negative=False)
assert x.is_positive is False # This was None before
assert x.is_nonpositive is None
assert x.is_negative is None
assert x.is_nonnegative is None
assert x.is_zero is None
assert x.is_nonzero is None
def test_symbol_falsepositive_real():
x = Symbol('x', positive=False, real=True)
assert x.is_positive is False
assert x.is_nonpositive is True
assert x.is_negative is None
assert x.is_nonnegative is None
assert x.is_zero is None
assert x.is_nonzero is None
def test_neg_symbol_falsepositive_real():
x = -Symbol('x', positive=False, real=True)
assert x.is_positive is None
assert x.is_nonpositive is None
assert x.is_negative is False
assert x.is_nonnegative is True
assert x.is_zero is None
assert x.is_nonzero is None
def test_symbol_falsenonnegative():
x = Symbol('x', nonnegative=False)
assert x.is_positive is False
assert x.is_nonpositive is None
assert x.is_negative is None
assert x.is_nonnegative is False
assert x.is_zero is False
assert x.is_nonzero is None
@XFAIL
def test_neg_symbol_falsenonnegative():
x = -Symbol('x', nonnegative=False)
assert x.is_positive is None
assert x.is_nonpositive is False # this currently returns None
assert x.is_negative is False # this currently returns None
assert x.is_nonnegative is None
assert x.is_zero is False # this currently returns None
assert x.is_nonzero is True # this currently returns None
def test_symbol_falsenonnegative_real():
x = Symbol('x', nonnegative=False, real=True)
assert x.is_positive is False
assert x.is_nonpositive is True
assert x.is_negative is True
assert x.is_nonnegative is False
assert x.is_zero is False
assert x.is_nonzero is True
def test_neg_symbol_falsenonnegative_real():
x = -Symbol('x', nonnegative=False, real=True)
assert x.is_positive is True
assert x.is_nonpositive is False
assert x.is_negative is False
assert x.is_nonnegative is True
assert x.is_zero is False
assert x.is_nonzero is True
def test_prime():
assert S.NegativeOne.is_prime is False
assert S(-2).is_prime is False
assert S(-4).is_prime is False
assert S.Zero.is_prime is False
assert S.One.is_prime is False
assert S(2).is_prime is True
assert S(17).is_prime is True
assert S(4).is_prime is False
def test_composite():
assert S.NegativeOne.is_composite is False
assert S(-2).is_composite is False
assert S(-4).is_composite is False
assert S.Zero.is_composite is False
assert S(2).is_composite is False
assert S(17).is_composite is False
assert S(4).is_composite is True
x = Dummy(integer=True, positive=True, prime=False)
assert x.is_composite is None # x could be 1
assert (x + 1).is_composite is None
x = Dummy(positive=True, even=True, prime=False)
assert x.is_integer is True
assert x.is_composite is True
def test_prime_symbol():
x = Symbol('x', prime=True)
assert x.is_prime is True
assert x.is_integer is True
assert x.is_positive is True
assert x.is_negative is False
assert x.is_nonpositive is False
assert x.is_nonnegative is True
x = Symbol('x', prime=False)
assert x.is_prime is False
assert x.is_integer is None
assert x.is_positive is None
assert x.is_negative is None
assert x.is_nonpositive is None
assert x.is_nonnegative is None
def test_symbol_noncommutative():
x = Symbol('x', commutative=True)
assert x.is_complex is None
x = Symbol('x', commutative=False)
assert x.is_integer is False
assert x.is_rational is False
assert x.is_algebraic is False
assert x.is_irrational is False
assert x.is_real is False
assert x.is_complex is False
def test_other_symbol():
x = Symbol('x', integer=True)
assert x.is_integer is True
assert x.is_real is True
assert x.is_finite is True
x = Symbol('x', integer=True, nonnegative=True)
assert x.is_integer is True
assert x.is_nonnegative is True
assert x.is_negative is False
assert x.is_positive is None
assert x.is_finite is True
x = Symbol('x', integer=True, nonpositive=True)
assert x.is_integer is True
assert x.is_nonpositive is True
assert x.is_positive is False
assert x.is_negative is None
assert x.is_finite is True
x = Symbol('x', odd=True)
assert x.is_odd is True
assert x.is_even is False
assert x.is_integer is True
assert x.is_finite is True
x = Symbol('x', odd=False)
assert x.is_odd is False
assert x.is_even is None
assert x.is_integer is None
assert x.is_finite is None
x = Symbol('x', even=True)
assert x.is_even is True
assert x.is_odd is False
assert x.is_integer is True
assert x.is_finite is True
x = Symbol('x', even=False)
assert x.is_even is False
assert x.is_odd is None
assert x.is_integer is None
assert x.is_finite is None
x = Symbol('x', integer=True, nonnegative=True)
assert x.is_integer is True
assert x.is_nonnegative is True
assert x.is_finite is True
x = Symbol('x', integer=True, nonpositive=True)
assert x.is_integer is True
assert x.is_nonpositive is True
assert x.is_finite is True
x = Symbol('x', rational=True)
assert x.is_real is True
assert x.is_finite is True
x = Symbol('x', rational=False)
assert x.is_real is None
assert x.is_finite is None
x = Symbol('x', irrational=True)
assert x.is_real is True
assert x.is_finite is True
x = Symbol('x', irrational=False)
assert x.is_real is None
assert x.is_finite is None
with raises(AttributeError):
x.is_real = False
x = Symbol('x', algebraic=True)
assert x.is_transcendental is False
x = Symbol('x', transcendental=True)
assert x.is_algebraic is False
assert x.is_rational is False
assert x.is_integer is False
def test_issue_3825():
"""catch: hash instability"""
x = Symbol("x")
y = Symbol("y")
a1 = x + y
a2 = y + x
a2.is_comparable
h1 = hash(a1)
h2 = hash(a2)
assert h1 == h2
def test_issue_4822():
z = (-1)**Rational(1, 3)*(1 - I*sqrt(3))
assert z.is_real in [True, None]
def test_hash_vs_typeinfo():
"""seemingly different typeinfo, but in fact equal"""
# the following two are semantically equal
x1 = Symbol('x', even=True)
x2 = Symbol('x', integer=True, odd=False)
assert hash(x1) == hash(x2)
assert x1 == x2
def test_hash_vs_typeinfo_2():
"""different typeinfo should mean !eq"""
# the following two are semantically different
x = Symbol('x')
x1 = Symbol('x', even=True)
assert x != x1
assert hash(x) != hash(x1) # This might fail with very low probability
def test_hash_vs_eq():
"""catch: different hash for equal objects"""
a = 1 + S.Pi # important: do not fold it into a Number instance
ha = hash(a) # it should be Add/Mul/... to trigger the bug
a.is_positive # this uses .evalf() and deduces it is positive
assert a.is_positive is True
# be sure that hash stayed the same
assert ha == hash(a)
# now b should be the same expression
b = a.expand(trig=True)
hb = hash(b)
assert a == b
assert ha == hb
def test_Add_is_pos_neg():
# these cover lines not covered by the rest of tests in core
n = Symbol('n', extended_negative=True, infinite=True)
nn = Symbol('n', extended_nonnegative=True, infinite=True)
np = Symbol('n', extended_nonpositive=True, infinite=True)
p = Symbol('p', extended_positive=True, infinite=True)
r = Dummy(extended_real=True, finite=False)
x = Symbol('x')
xf = Symbol('xf', finite=True)
assert (n + p).is_extended_positive is None
assert (n + x).is_extended_positive is None
assert (p + x).is_extended_positive is None
assert (n + p).is_extended_negative is None
assert (n + x).is_extended_negative is None
assert (p + x).is_extended_negative is None
assert (n + xf).is_extended_positive is False
assert (p + xf).is_extended_positive is True
assert (n + xf).is_extended_negative is True
assert (p + xf).is_extended_negative is False
assert (x - S.Infinity).is_extended_negative is None # issue 7798
# issue 8046, 16.2
assert (p + nn).is_extended_positive
assert (n + np).is_extended_negative
assert (p + r).is_extended_positive is None
def test_Add_is_imaginary():
nn = Dummy(nonnegative=True)
assert (I*nn + I).is_imaginary # issue 8046, 17
def test_Add_is_algebraic():
a = Symbol('a', algebraic=True)
b = Symbol('a', algebraic=True)
na = Symbol('na', algebraic=False)
nb = Symbol('nb', algebraic=False)
x = Symbol('x')
assert (a + b).is_algebraic
assert (na + nb).is_algebraic is None
assert (a + na).is_algebraic is False
assert (a + x).is_algebraic is None
assert (na + x).is_algebraic is None
def test_Mul_is_algebraic():
a = Symbol('a', algebraic=True)
b = Symbol('b', algebraic=True)
na = Symbol('na', algebraic=False)
an = Symbol('an', algebraic=True, nonzero=True)
nb = Symbol('nb', algebraic=False)
x = Symbol('x')
assert (a*b).is_algebraic is True
assert (na*nb).is_algebraic is None
assert (a*na).is_algebraic is None
assert (an*na).is_algebraic is False
assert (a*x).is_algebraic is None
assert (na*x).is_algebraic is None
def test_Pow_is_algebraic():
e = Symbol('e', algebraic=True)
assert Pow(1, e, evaluate=False).is_algebraic
assert Pow(0, e, evaluate=False).is_algebraic
a = Symbol('a', algebraic=True)
azf = Symbol('azf', algebraic=True, zero=False)
na = Symbol('na', algebraic=False)
ia = Symbol('ia', algebraic=True, irrational=True)
ib = Symbol('ib', algebraic=True, irrational=True)
r = Symbol('r', rational=True)
x = Symbol('x')
assert (a**2).is_algebraic is True
assert (a**r).is_algebraic is None
assert (azf**r).is_algebraic is True
assert (a**x).is_algebraic is None
assert (na**r).is_algebraic is None
assert (ia**r).is_algebraic is True
assert (ia**ib).is_algebraic is False
assert (a**e).is_algebraic is None
# Gelfond-Schneider constant:
assert Pow(2, sqrt(2), evaluate=False).is_algebraic is False
assert Pow(S.GoldenRatio, sqrt(3), evaluate=False).is_algebraic is False
# issue 8649
t = Symbol('t', real=True, transcendental=True)
n = Symbol('n', integer=True)
assert (t**n).is_algebraic is None
assert (t**n).is_integer is None
assert (pi**3).is_algebraic is False
r = Symbol('r', zero=True)
assert (pi**r).is_algebraic is True
def test_Mul_is_prime_composite():
x = Symbol('x', positive=True, integer=True)
y = Symbol('y', positive=True, integer=True)
assert (x*y).is_prime is None
assert ( (x+1)*(y+1) ).is_prime is False
assert ( (x+1)*(y+1) ).is_composite is True
x = Symbol('x', positive=True)
assert ( (x+1)*(y+1) ).is_prime is None
assert ( (x+1)*(y+1) ).is_composite is None
def test_Pow_is_pos_neg():
z = Symbol('z', real=True)
w = Symbol('w', nonpositive=True)
assert (S.NegativeOne**S(2)).is_positive is True
assert (S.One**z).is_positive is True
assert (S.NegativeOne**S(3)).is_positive is False
assert (S.Zero**S.Zero).is_positive is True # 0**0 is 1
assert (w**S(3)).is_positive is False
assert (w**S(2)).is_positive is None
assert (I**2).is_positive is False
assert (I**4).is_positive is True
# tests emerging from #16332 issue
p = Symbol('p', zero=True)
q = Symbol('q', zero=False, real=True)
j = Symbol('j', zero=False, even=True)
x = Symbol('x', zero=True)
y = Symbol('y', zero=True)
assert (p**q).is_positive is False
assert (p**q).is_negative is False
assert (p**j).is_positive is False
assert (x**y).is_positive is True # 0**0
assert (x**y).is_negative is False
def test_Pow_is_prime_composite():
x = Symbol('x', positive=True, integer=True)
y = Symbol('y', positive=True, integer=True)
assert (x**y).is_prime is None
assert ( x**(y+1) ).is_prime is False
assert ( x**(y+1) ).is_composite is None
assert ( (x+1)**(y+1) ).is_composite is True
assert ( (-x-1)**(2*y) ).is_composite is True
x = Symbol('x', positive=True)
assert (x**y).is_prime is None
def test_Mul_is_infinite():
x = Symbol('x')
f = Symbol('f', finite=True)
i = Symbol('i', infinite=True)
z = Dummy(zero=True)
nzf = Dummy(finite=True, zero=False)
from sympy import Mul
assert (x*f).is_finite is None
assert (x*i).is_finite is None
assert (f*i).is_finite is None
assert (x*f*i).is_finite is None
assert (z*i).is_finite is None
assert (nzf*i).is_finite is False
assert (z*f).is_finite is True
assert Mul(0, f, evaluate=False).is_finite is True
assert Mul(0, i, evaluate=False).is_finite is None
assert (x*f).is_infinite is None
assert (x*i).is_infinite is None
assert (f*i).is_infinite is None
assert (x*f*i).is_infinite is None
assert (z*i).is_infinite is S.NaN.is_infinite
assert (nzf*i).is_infinite is True
assert (z*f).is_infinite is False
assert Mul(0, f, evaluate=False).is_infinite is False
assert Mul(0, i, evaluate=False).is_infinite is S.NaN.is_infinite
def test_Add_is_infinite():
x = Symbol('x')
f = Symbol('f', finite=True)
i = Symbol('i', infinite=True)
i2 = Symbol('i2', infinite=True)
z = Dummy(zero=True)
nzf = Dummy(finite=True, zero=False)
from sympy import Add
assert (x+f).is_finite is None
assert (x+i).is_finite is None
assert (f+i).is_finite is False
assert (x+f+i).is_finite is None
assert (z+i).is_finite is False
assert (nzf+i).is_finite is False
assert (z+f).is_finite is True
assert (i+i2).is_finite is None
assert Add(0, f, evaluate=False).is_finite is True
assert Add(0, i, evaluate=False).is_finite is False
assert (x+f).is_infinite is None
assert (x+i).is_infinite is None
assert (f+i).is_infinite is True
assert (x+f+i).is_infinite is None
assert (z+i).is_infinite is True
assert (nzf+i).is_infinite is True
assert (z+f).is_infinite is False
assert (i+i2).is_infinite is None
assert Add(0, f, evaluate=False).is_infinite is False
assert Add(0, i, evaluate=False).is_infinite is True
def test_special_is_rational():
i = Symbol('i', integer=True)
i2 = Symbol('i2', integer=True)
ni = Symbol('ni', integer=True, nonzero=True)
r = Symbol('r', rational=True)
rn = Symbol('r', rational=True, nonzero=True)
nr = Symbol('nr', irrational=True)
x = Symbol('x')
assert sqrt(3).is_rational is False
assert (3 + sqrt(3)).is_rational is False
assert (3*sqrt(3)).is_rational is False
assert exp(3).is_rational is False
assert exp(ni).is_rational is False
assert exp(rn).is_rational is False
assert exp(x).is_rational is None
assert exp(log(3), evaluate=False).is_rational is True
assert log(exp(3), evaluate=False).is_rational is True
assert log(3).is_rational is False
assert log(ni + 1).is_rational is False
assert log(rn + 1).is_rational is False
assert log(x).is_rational is None
assert (sqrt(3) + sqrt(5)).is_rational is None
assert (sqrt(3) + S.Pi).is_rational is False
assert (x**i).is_rational is None
assert (i**i).is_rational is True
assert (i**i2).is_rational is None
assert (r**i).is_rational is None
assert (r**r).is_rational is None
assert (r**x).is_rational is None
assert (nr**i).is_rational is None # issue 8598
assert (nr**Symbol('z', zero=True)).is_rational
assert sin(1).is_rational is False
assert sin(ni).is_rational is False
assert sin(rn).is_rational is False
assert sin(x).is_rational is None
assert asin(r).is_rational is False
assert sin(asin(3), evaluate=False).is_rational is True
@XFAIL
def test_issue_6275():
x = Symbol('x')
# both zero or both Muls...but neither "change would be very appreciated.
# This is similar to x/x => 1 even though if x = 0, it is really nan.
assert isinstance(x*0, type(0*S.Infinity))
if 0*S.Infinity is S.NaN:
b = Symbol('b', finite=None)
assert (b*0).is_zero is None
def test_sanitize_assumptions():
# issue 6666
for cls in (Symbol, Dummy, Wild):
x = cls('x', real=1, positive=0)
assert x.is_real is True
assert x.is_positive is False
assert cls('', real=True, positive=None).is_positive is None
raises(ValueError, lambda: cls('', commutative=None))
raises(ValueError, lambda: Symbol._sanitize(dict(commutative=None)))
def test_special_assumptions():
e = -3 - sqrt(5) + (-sqrt(10)/2 - sqrt(2)/2)**2
assert simplify(e < 0) is S.false
assert simplify(e > 0) is S.false
assert (e == 0) is False # it's not a literal 0
assert e.equals(0) is True
def test_inconsistent():
# cf. issues 5795 and 5545
raises(InconsistentAssumptions, lambda: Symbol('x', real=True,
commutative=False))
def test_issue_6631():
assert ((-1)**(I)).is_real is True
assert ((-1)**(I*2)).is_real is True
assert ((-1)**(I/2)).is_real is True
assert ((-1)**(I*S.Pi)).is_real is True
assert (I**(I + 2)).is_real is True
def test_issue_2730():
assert (1/(1 + I)).is_real is False
def test_issue_4149():
assert (3 + I).is_complex
assert (3 + I).is_imaginary is False
assert (3*I + S.Pi*I).is_imaginary
# as Zero.is_imaginary is False, see issue 7649
y = Symbol('y', real=True)
assert (3*I + S.Pi*I + y*I).is_imaginary is None
p = Symbol('p', positive=True)
assert (3*I + S.Pi*I + p*I).is_imaginary
n = Symbol('n', negative=True)
assert (-3*I - S.Pi*I + n*I).is_imaginary
i = Symbol('i', imaginary=True)
assert ([(i**a).is_imaginary for a in range(4)] ==
[False, True, False, True])
# tests from the PR #7887:
e = S("-sqrt(3)*I/2 + 0.866025403784439*I")
assert e.is_real is False
assert e.is_imaginary
def test_issue_2920():
n = Symbol('n', negative=True)
assert sqrt(n).is_imaginary
def test_issue_7899():
x = Symbol('x', real=True)
assert (I*x).is_real is None
assert ((x - I)*(x - 1)).is_zero is None
assert ((x - I)*(x - 1)).is_real is None
@XFAIL
def test_issue_7993():
x = Dummy(integer=True)
y = Dummy(noninteger=True)
assert (x - y).is_zero is False
def test_issue_8075():
raises(InconsistentAssumptions, lambda: Dummy(zero=True, finite=False))
raises(InconsistentAssumptions, lambda: Dummy(zero=True, infinite=True))
def test_issue_8642():
x = Symbol('x', real=True, integer=False)
assert (x*2).is_integer is None, (x*2).is_integer
def test_issues_8632_8633_8638_8675_8992():
p = Dummy(integer=True, positive=True)
nn = Dummy(integer=True, nonnegative=True)
assert (p - S.Half).is_positive
assert (p - 1).is_nonnegative
assert (nn + 1).is_positive
assert (-p + 1).is_nonpositive
assert (-nn - 1).is_negative
prime = Dummy(prime=True)
assert (prime - 2).is_nonnegative
assert (prime - 3).is_nonnegative is None
even = Dummy(positive=True, even=True)
assert (even - 2).is_nonnegative
p = Dummy(positive=True)
assert (p/(p + 1) - 1).is_negative
assert ((p + 2)**3 - S.Half).is_positive
n = Dummy(negative=True)
assert (n - 3).is_nonpositive
def test_issue_9115_9150():
n = Dummy('n', integer=True, nonnegative=True)
assert (factorial(n) >= 1) == True
assert (factorial(n) < 1) == False
assert factorial(n + 1).is_even is None
assert factorial(n + 2).is_even is True
assert factorial(n + 2) >= 2
def test_issue_9165():
z = Symbol('z', zero=True)
f = Symbol('f', finite=False)
assert 0/z is S.NaN
assert 0*(1/z) is S.NaN
assert 0*f is S.NaN
def test_issue_10024():
x = Dummy('x')
assert Mod(x, 2*pi).is_zero is None
def test_issue_10302():
x = Symbol('x')
r = Symbol('r', real=True)
u = -(3*2**pi)**(1/pi) + 2*3**(1/pi)
i = u + u*I
assert i.is_real is None # w/o simplification this should fail
assert (u + i).is_zero is None
assert (1 + i).is_zero is False
a = Dummy('a', zero=True)
assert (a + I).is_zero is False
assert (a + r*I).is_zero is None
assert (a + I).is_imaginary
assert (a + x + I).is_imaginary is None
assert (a + r*I + I).is_imaginary is None
def test_complex_reciprocal_imaginary():
assert (1 / (4 + 3*I)).is_imaginary is False
def test_issue_16313():
x = Symbol('x', extended_real=False)
k = Symbol('k', real=True)
l = Symbol('l', real=True, zero=False)
assert (-x).is_real is False
assert (k*x).is_real is None # k can be zero also
assert (l*x).is_real is False
assert (l*x*x).is_real is None # since x*x can be a real number
assert (-x).is_positive is False
def test_issue_16579():
# extended_real -> finite | infinite
x = Symbol('x', extended_real=True, infinite=False)
y = Symbol('y', extended_real=True, finite=False)
assert x.is_finite is True
assert y.is_infinite is True
# With PR 16978, complex now implies finite
c = Symbol('c', complex=True)
assert c.is_finite is True
raises(InconsistentAssumptions, lambda: Dummy(complex=True, finite=False))
# Now infinite == !finite
nf = Symbol('nf', finite=False)
assert nf.is_infinite is True
def test_issue_17556():
z = I*oo
assert z.is_imaginary is False
assert z.is_finite is False
def test_assumptions_copy():
assert assumptions(Symbol('x'), dict(commutative=True)
) == {'commutative': True}
assert assumptions(Symbol('x'), ['integer']) == {}
assert assumptions(Symbol('x'), ['commutative']
) == {'commutative': True}
assert assumptions(Symbol('x')) == {'commutative': True}
assert assumptions(1)['positive']
assert assumptions(3 + I) == {
'algebraic': True,
'commutative': True,
'complex': True,
'composite': False,
'even': False,
'extended_negative': False,
'extended_nonnegative': False,
'extended_nonpositive': False,
'extended_nonzero': False,
'extended_positive': False,
'extended_real': False,
'finite': True,
'imaginary': False,
'infinite': False,
'integer': False,
'irrational': False,
'negative': False,
'noninteger': False,
'nonnegative': False,
'nonpositive': False,
'nonzero': False,
'odd': False,
'positive': False,
'prime': False,
'rational': False,
'real': False,
'transcendental': False,
'zero': False}
def test_check_assumptions():
x = Symbol('x', positive=True)
assert check_assumptions(1, x) is True
assert check_assumptions(1, 1) is True
assert check_assumptions(-1, 1) is False
i = Symbol('i', integer=True)
# don't know if i is positive (or prime, etc...)
assert check_assumptions(i, 1) is None
assert check_assumptions(Dummy(integer=None), integer=True) is None
assert check_assumptions(Dummy(integer=None), integer=False) is None
assert check_assumptions(Dummy(integer=False), integer=True) is False
assert check_assumptions(Dummy(integer=True), integer=False) is False
# no T/F assumptions to check
assert check_assumptions(Dummy(integer=False), integer=None) is True
raises(ValueError, lambda: check_assumptions(2*x, x, positive=True))
def test_failing_assumptions():
x = Symbol('x', real=True, positive=True)
y = Symbol('y')
assert failing_assumptions(6*x + y, **x.assumptions0) == \
{'real': None, 'imaginary': None, 'complex': None, 'hermitian': None,
'positive': None, 'nonpositive': None, 'nonnegative': None, 'nonzero': None,
'negative': None, 'zero': None, 'extended_real': None, 'finite': None,
'infinite': None, 'extended_negative': None, 'extended_nonnegative': None,
'extended_nonpositive': None, 'extended_nonzero': None,
'extended_positive': None }
def test_common_assumptions():
assert common_assumptions([0, 1, 2]
) == {'algebraic': True, 'irrational': False, 'hermitian':
True, 'extended_real': True, 'real': True, 'extended_negative':
False, 'extended_nonnegative': True, 'integer': True,
'rational': True, 'imaginary': False, 'complex': True,
'commutative': True,'noninteger': False, 'composite': False,
'infinite': False, 'nonnegative': True, 'finite': True,
'transcendental': False,'negative': False}
assert common_assumptions([0, 1, 2], 'positive integer'.split()
) == {'integer': True}
assert common_assumptions([0, 1, 2], []) == {}
assert common_assumptions([], ['integer']) == {}
assert common_assumptions([0], ['integer']) == {'integer': True}
|
f3c28d74d039828b8efe56369bb01b5150667a8715c4f27a7803f3e1f84d212a | from sympy.testing.pytest import XFAIL, raises, warns_deprecated_sympy
from sympy import (S, Symbol, symbols, nan, oo, I, pi, Float, And, Or,
Not, Implies, Xor, zoo, sqrt, Rational, simplify, Function,
log, cos, sin, Add, Mul, Pow, floor, ceiling, trigsimp, Reals)
from sympy.core.relational import (Relational, Equality, Unequality,
GreaterThan, LessThan, StrictGreaterThan,
StrictLessThan, Rel, Eq, Lt, Le,
Gt, Ge, Ne)
from sympy.sets.sets import Interval, FiniteSet
from itertools import combinations
x, y, z, t = symbols('x,y,z,t')
def rel_check(a, b):
from sympy.testing.pytest import raises
assert a.is_number and b.is_number
for do in range(len({type(a), type(b)})):
if S.NaN in (a, b):
v = [(a == b), (a != b)]
assert len(set(v)) == 1 and v[0] == False
assert not (a != b) and not (a == b)
assert raises(TypeError, lambda: a < b)
assert raises(TypeError, lambda: a <= b)
assert raises(TypeError, lambda: a > b)
assert raises(TypeError, lambda: a >= b)
else:
E = [(a == b), (a != b)]
assert len(set(E)) == 2
v = [
(a < b), (a <= b), (a > b), (a >= b)]
i = [
[True, True, False, False],
[False, True, False, True], # <-- i == 1
[False, False, True, True]].index(v)
if i == 1:
assert E[0] or (a.is_Float != b.is_Float) # ugh
else:
assert E[1]
a, b = b, a
return True
def test_rel_ne():
assert Relational(x, y, '!=') == Ne(x, y)
# issue 6116
p = Symbol('p', positive=True)
assert Ne(p, 0) is S.true
def test_rel_subs():
e = Relational(x, y, '==')
e = e.subs(x, z)
assert isinstance(e, Equality)
assert e.lhs == z
assert e.rhs == y
e = Relational(x, y, '>=')
e = e.subs(x, z)
assert isinstance(e, GreaterThan)
assert e.lhs == z
assert e.rhs == y
e = Relational(x, y, '<=')
e = e.subs(x, z)
assert isinstance(e, LessThan)
assert e.lhs == z
assert e.rhs == y
e = Relational(x, y, '>')
e = e.subs(x, z)
assert isinstance(e, StrictGreaterThan)
assert e.lhs == z
assert e.rhs == y
e = Relational(x, y, '<')
e = e.subs(x, z)
assert isinstance(e, StrictLessThan)
assert e.lhs == z
assert e.rhs == y
e = Eq(x, 0)
assert e.subs(x, 0) is S.true
assert e.subs(x, 1) is S.false
def test_wrappers():
e = x + x**2
res = Relational(y, e, '==')
assert Rel(y, x + x**2, '==') == res
assert Eq(y, x + x**2) == res
res = Relational(y, e, '<')
assert Lt(y, x + x**2) == res
res = Relational(y, e, '<=')
assert Le(y, x + x**2) == res
res = Relational(y, e, '>')
assert Gt(y, x + x**2) == res
res = Relational(y, e, '>=')
assert Ge(y, x + x**2) == res
res = Relational(y, e, '!=')
assert Ne(y, x + x**2) == res
def test_Eq_Ne():
assert Eq(x, x) # issue 5719
with warns_deprecated_sympy():
assert Eq(x) == Eq(x, 0)
# issue 6116
p = Symbol('p', positive=True)
assert Eq(p, 0) is S.false
# issue 13348; 19048
# SymPy is strict about 0 and 1 not being
# interpreted as Booleans
assert Eq(True, 1) is S.false
assert Eq(False, 0) is S.false
assert Eq(~x, 0) is S.false
assert Eq(~x, 1) is S.false
assert Ne(True, 1) is S.true
assert Ne(False, 0) is S.true
assert Ne(~x, 0) is S.true
assert Ne(~x, 1) is S.true
assert Eq((), 1) is S.false
assert Ne((), 1) is S.true
def test_as_poly():
from sympy.polys.polytools import Poly
# Only Eq should have an as_poly method:
assert Eq(x, 1).as_poly() == Poly(x - 1, x, domain='ZZ')
raises(AttributeError, lambda: Ne(x, 1).as_poly())
raises(AttributeError, lambda: Ge(x, 1).as_poly())
raises(AttributeError, lambda: Gt(x, 1).as_poly())
raises(AttributeError, lambda: Le(x, 1).as_poly())
raises(AttributeError, lambda: Lt(x, 1).as_poly())
def test_rel_Infinity():
# NOTE: All of these are actually handled by sympy.core.Number, and do
# not create Relational objects.
assert (oo > oo) is S.false
assert (oo > -oo) is S.true
assert (oo > 1) is S.true
assert (oo < oo) is S.false
assert (oo < -oo) is S.false
assert (oo < 1) is S.false
assert (oo >= oo) is S.true
assert (oo >= -oo) is S.true
assert (oo >= 1) is S.true
assert (oo <= oo) is S.true
assert (oo <= -oo) is S.false
assert (oo <= 1) is S.false
assert (-oo > oo) is S.false
assert (-oo > -oo) is S.false
assert (-oo > 1) is S.false
assert (-oo < oo) is S.true
assert (-oo < -oo) is S.false
assert (-oo < 1) is S.true
assert (-oo >= oo) is S.false
assert (-oo >= -oo) is S.true
assert (-oo >= 1) is S.false
assert (-oo <= oo) is S.true
assert (-oo <= -oo) is S.true
assert (-oo <= 1) is S.true
def test_infinite_symbol_inequalities():
x = Symbol('x', extended_positive=True, infinite=True)
y = Symbol('y', extended_positive=True, infinite=True)
z = Symbol('z', extended_negative=True, infinite=True)
w = Symbol('w', extended_negative=True, infinite=True)
inf_set = (x, y, oo)
ninf_set = (z, w, -oo)
for inf1 in inf_set:
assert (inf1 < 1) is S.false
assert (inf1 > 1) is S.true
assert (inf1 <= 1) is S.false
assert (inf1 >= 1) is S.true
for inf2 in inf_set:
assert (inf1 < inf2) is S.false
assert (inf1 > inf2) is S.false
assert (inf1 <= inf2) is S.true
assert (inf1 >= inf2) is S.true
for ninf1 in ninf_set:
assert (inf1 < ninf1) is S.false
assert (inf1 > ninf1) is S.true
assert (inf1 <= ninf1) is S.false
assert (inf1 >= ninf1) is S.true
assert (ninf1 < inf1) is S.true
assert (ninf1 > inf1) is S.false
assert (ninf1 <= inf1) is S.true
assert (ninf1 >= inf1) is S.false
for ninf1 in ninf_set:
assert (ninf1 < 1) is S.true
assert (ninf1 > 1) is S.false
assert (ninf1 <= 1) is S.true
assert (ninf1 >= 1) is S.false
for ninf2 in ninf_set:
assert (ninf1 < ninf2) is S.false
assert (ninf1 > ninf2) is S.false
assert (ninf1 <= ninf2) is S.true
assert (ninf1 >= ninf2) is S.true
def test_bool():
assert Eq(0, 0) is S.true
assert Eq(1, 0) is S.false
assert Ne(0, 0) is S.false
assert Ne(1, 0) is S.true
assert Lt(0, 1) is S.true
assert Lt(1, 0) is S.false
assert Le(0, 1) is S.true
assert Le(1, 0) is S.false
assert Le(0, 0) is S.true
assert Gt(1, 0) is S.true
assert Gt(0, 1) is S.false
assert Ge(1, 0) is S.true
assert Ge(0, 1) is S.false
assert Ge(1, 1) is S.true
assert Eq(I, 2) is S.false
assert Ne(I, 2) is S.true
raises(TypeError, lambda: Gt(I, 2))
raises(TypeError, lambda: Ge(I, 2))
raises(TypeError, lambda: Lt(I, 2))
raises(TypeError, lambda: Le(I, 2))
a = Float('.000000000000000000001', '')
b = Float('.0000000000000000000001', '')
assert Eq(pi + a, pi + b) is S.false
def test_rich_cmp():
assert (x < y) == Lt(x, y)
assert (x <= y) == Le(x, y)
assert (x > y) == Gt(x, y)
assert (x >= y) == Ge(x, y)
def test_doit():
from sympy import Symbol
p = Symbol('p', positive=True)
n = Symbol('n', negative=True)
np = Symbol('np', nonpositive=True)
nn = Symbol('nn', nonnegative=True)
assert Gt(p, 0).doit() is S.true
assert Gt(p, 1).doit() == Gt(p, 1)
assert Ge(p, 0).doit() is S.true
assert Le(p, 0).doit() is S.false
assert Lt(n, 0).doit() is S.true
assert Le(np, 0).doit() is S.true
assert Gt(nn, 0).doit() == Gt(nn, 0)
assert Lt(nn, 0).doit() is S.false
assert Eq(x, 0).doit() == Eq(x, 0)
def test_new_relational():
x = Symbol('x')
assert Eq(x, 0) == Relational(x, 0) # None ==> Equality
assert Eq(x, 0) == Relational(x, 0, '==')
assert Eq(x, 0) == Relational(x, 0, 'eq')
assert Eq(x, 0) == Equality(x, 0)
assert Eq(x, 0) != Relational(x, 1) # None ==> Equality
assert Eq(x, 0) != Relational(x, 1, '==')
assert Eq(x, 0) != Relational(x, 1, 'eq')
assert Eq(x, 0) != Equality(x, 1)
assert Eq(x, -1) == Relational(x, -1) # None ==> Equality
assert Eq(x, -1) == Relational(x, -1, '==')
assert Eq(x, -1) == Relational(x, -1, 'eq')
assert Eq(x, -1) == Equality(x, -1)
assert Eq(x, -1) != Relational(x, 1) # None ==> Equality
assert Eq(x, -1) != Relational(x, 1, '==')
assert Eq(x, -1) != Relational(x, 1, 'eq')
assert Eq(x, -1) != Equality(x, 1)
assert Ne(x, 0) == Relational(x, 0, '!=')
assert Ne(x, 0) == Relational(x, 0, '<>')
assert Ne(x, 0) == Relational(x, 0, 'ne')
assert Ne(x, 0) == Unequality(x, 0)
assert Ne(x, 0) != Relational(x, 1, '!=')
assert Ne(x, 0) != Relational(x, 1, '<>')
assert Ne(x, 0) != Relational(x, 1, 'ne')
assert Ne(x, 0) != Unequality(x, 1)
assert Ge(x, 0) == Relational(x, 0, '>=')
assert Ge(x, 0) == Relational(x, 0, 'ge')
assert Ge(x, 0) == GreaterThan(x, 0)
assert Ge(x, 1) != Relational(x, 0, '>=')
assert Ge(x, 1) != Relational(x, 0, 'ge')
assert Ge(x, 1) != GreaterThan(x, 0)
assert (x >= 1) == Relational(x, 1, '>=')
assert (x >= 1) == Relational(x, 1, 'ge')
assert (x >= 1) == GreaterThan(x, 1)
assert (x >= 0) != Relational(x, 1, '>=')
assert (x >= 0) != Relational(x, 1, 'ge')
assert (x >= 0) != GreaterThan(x, 1)
assert Le(x, 0) == Relational(x, 0, '<=')
assert Le(x, 0) == Relational(x, 0, 'le')
assert Le(x, 0) == LessThan(x, 0)
assert Le(x, 1) != Relational(x, 0, '<=')
assert Le(x, 1) != Relational(x, 0, 'le')
assert Le(x, 1) != LessThan(x, 0)
assert (x <= 1) == Relational(x, 1, '<=')
assert (x <= 1) == Relational(x, 1, 'le')
assert (x <= 1) == LessThan(x, 1)
assert (x <= 0) != Relational(x, 1, '<=')
assert (x <= 0) != Relational(x, 1, 'le')
assert (x <= 0) != LessThan(x, 1)
assert Gt(x, 0) == Relational(x, 0, '>')
assert Gt(x, 0) == Relational(x, 0, 'gt')
assert Gt(x, 0) == StrictGreaterThan(x, 0)
assert Gt(x, 1) != Relational(x, 0, '>')
assert Gt(x, 1) != Relational(x, 0, 'gt')
assert Gt(x, 1) != StrictGreaterThan(x, 0)
assert (x > 1) == Relational(x, 1, '>')
assert (x > 1) == Relational(x, 1, 'gt')
assert (x > 1) == StrictGreaterThan(x, 1)
assert (x > 0) != Relational(x, 1, '>')
assert (x > 0) != Relational(x, 1, 'gt')
assert (x > 0) != StrictGreaterThan(x, 1)
assert Lt(x, 0) == Relational(x, 0, '<')
assert Lt(x, 0) == Relational(x, 0, 'lt')
assert Lt(x, 0) == StrictLessThan(x, 0)
assert Lt(x, 1) != Relational(x, 0, '<')
assert Lt(x, 1) != Relational(x, 0, 'lt')
assert Lt(x, 1) != StrictLessThan(x, 0)
assert (x < 1) == Relational(x, 1, '<')
assert (x < 1) == Relational(x, 1, 'lt')
assert (x < 1) == StrictLessThan(x, 1)
assert (x < 0) != Relational(x, 1, '<')
assert (x < 0) != Relational(x, 1, 'lt')
assert (x < 0) != StrictLessThan(x, 1)
# finally, some fuzz testing
from random import randint
for i in range(100):
while 1:
strtype, length = (chr, 65535) if randint(0, 1) else (chr, 255)
relation_type = strtype(randint(0, length))
if randint(0, 1):
relation_type += strtype(randint(0, length))
if relation_type not in ('==', 'eq', '!=', '<>', 'ne', '>=', 'ge',
'<=', 'le', '>', 'gt', '<', 'lt', ':=',
'+=', '-=', '*=', '/=', '%='):
break
raises(ValueError, lambda: Relational(x, 1, relation_type))
assert all(Relational(x, 0, op).rel_op == '==' for op in ('eq', '=='))
assert all(Relational(x, 0, op).rel_op == '!='
for op in ('ne', '<>', '!='))
assert all(Relational(x, 0, op).rel_op == '>' for op in ('gt', '>'))
assert all(Relational(x, 0, op).rel_op == '<' for op in ('lt', '<'))
assert all(Relational(x, 0, op).rel_op == '>=' for op in ('ge', '>='))
assert all(Relational(x, 0, op).rel_op == '<=' for op in ('le', '<='))
def test_relational_arithmetic():
for cls in [Eq, Ne, Le, Lt, Ge, Gt]:
rel = cls(x, y)
raises(TypeError, lambda: 0+rel)
raises(TypeError, lambda: 1*rel)
raises(TypeError, lambda: 1**rel)
raises(TypeError, lambda: rel**1)
raises(TypeError, lambda: Add(0, rel))
raises(TypeError, lambda: Mul(1, rel))
raises(TypeError, lambda: Pow(1, rel))
raises(TypeError, lambda: Pow(rel, 1))
def test_relational_bool_output():
# https://github.com/sympy/sympy/issues/5931
raises(TypeError, lambda: bool(x > 3))
raises(TypeError, lambda: bool(x >= 3))
raises(TypeError, lambda: bool(x < 3))
raises(TypeError, lambda: bool(x <= 3))
raises(TypeError, lambda: bool(Eq(x, 3)))
raises(TypeError, lambda: bool(Ne(x, 3)))
def test_relational_logic_symbols():
# See issue 6204
assert (x < y) & (z < t) == And(x < y, z < t)
assert (x < y) | (z < t) == Or(x < y, z < t)
assert ~(x < y) == Not(x < y)
assert (x < y) >> (z < t) == Implies(x < y, z < t)
assert (x < y) << (z < t) == Implies(z < t, x < y)
assert (x < y) ^ (z < t) == Xor(x < y, z < t)
assert isinstance((x < y) & (z < t), And)
assert isinstance((x < y) | (z < t), Or)
assert isinstance(~(x < y), GreaterThan)
assert isinstance((x < y) >> (z < t), Implies)
assert isinstance((x < y) << (z < t), Implies)
assert isinstance((x < y) ^ (z < t), (Or, Xor))
def test_univariate_relational_as_set():
assert (x > 0).as_set() == Interval(0, oo, True, True)
assert (x >= 0).as_set() == Interval(0, oo)
assert (x < 0).as_set() == Interval(-oo, 0, True, True)
assert (x <= 0).as_set() == Interval(-oo, 0)
assert Eq(x, 0).as_set() == FiniteSet(0)
assert Ne(x, 0).as_set() == Interval(-oo, 0, True, True) + \
Interval(0, oo, True, True)
assert (x**2 >= 4).as_set() == Interval(-oo, -2) + Interval(2, oo)
@XFAIL
def test_multivariate_relational_as_set():
assert (x*y >= 0).as_set() == Interval(0, oo)*Interval(0, oo) + \
Interval(-oo, 0)*Interval(-oo, 0)
def test_Not():
assert Not(Equality(x, y)) == Unequality(x, y)
assert Not(Unequality(x, y)) == Equality(x, y)
assert Not(StrictGreaterThan(x, y)) == LessThan(x, y)
assert Not(StrictLessThan(x, y)) == GreaterThan(x, y)
assert Not(GreaterThan(x, y)) == StrictLessThan(x, y)
assert Not(LessThan(x, y)) == StrictGreaterThan(x, y)
def test_evaluate():
assert str(Eq(x, x, evaluate=False)) == 'Eq(x, x)'
assert Eq(x, x, evaluate=False).doit() == S.true
assert str(Ne(x, x, evaluate=False)) == 'Ne(x, x)'
assert Ne(x, x, evaluate=False).doit() == S.false
assert str(Ge(x, x, evaluate=False)) == 'x >= x'
assert str(Le(x, x, evaluate=False)) == 'x <= x'
assert str(Gt(x, x, evaluate=False)) == 'x > x'
assert str(Lt(x, x, evaluate=False)) == 'x < x'
def assert_all_ineq_raise_TypeError(a, b):
raises(TypeError, lambda: a > b)
raises(TypeError, lambda: a >= b)
raises(TypeError, lambda: a < b)
raises(TypeError, lambda: a <= b)
raises(TypeError, lambda: b > a)
raises(TypeError, lambda: b >= a)
raises(TypeError, lambda: b < a)
raises(TypeError, lambda: b <= a)
def assert_all_ineq_give_class_Inequality(a, b):
"""All inequality operations on `a` and `b` result in class Inequality."""
from sympy.core.relational import _Inequality as Inequality
assert isinstance(a > b, Inequality)
assert isinstance(a >= b, Inequality)
assert isinstance(a < b, Inequality)
assert isinstance(a <= b, Inequality)
assert isinstance(b > a, Inequality)
assert isinstance(b >= a, Inequality)
assert isinstance(b < a, Inequality)
assert isinstance(b <= a, Inequality)
def test_imaginary_compare_raises_TypeError():
# See issue #5724
assert_all_ineq_raise_TypeError(I, x)
def test_complex_compare_not_real():
# two cases which are not real
y = Symbol('y', imaginary=True)
z = Symbol('z', complex=True, extended_real=False)
for w in (y, z):
assert_all_ineq_raise_TypeError(2, w)
# some cases which should remain un-evaluated
t = Symbol('t')
x = Symbol('x', real=True)
z = Symbol('z', complex=True)
for w in (x, z, t):
assert_all_ineq_give_class_Inequality(2, w)
def test_imaginary_and_inf_compare_raises_TypeError():
# See pull request #7835
y = Symbol('y', imaginary=True)
assert_all_ineq_raise_TypeError(oo, y)
assert_all_ineq_raise_TypeError(-oo, y)
def test_complex_pure_imag_not_ordered():
raises(TypeError, lambda: 2*I < 3*I)
# more generally
x = Symbol('x', real=True, nonzero=True)
y = Symbol('y', imaginary=True)
z = Symbol('z', complex=True)
assert_all_ineq_raise_TypeError(I, y)
t = I*x # an imaginary number, should raise errors
assert_all_ineq_raise_TypeError(2, t)
t = -I*y # a real number, so no errors
assert_all_ineq_give_class_Inequality(2, t)
t = I*z # unknown, should be unevaluated
assert_all_ineq_give_class_Inequality(2, t)
def test_x_minus_y_not_same_as_x_lt_y():
"""
A consequence of pull request #7792 is that `x - y < 0` and `x < y`
are not synonymous.
"""
x = I + 2
y = I + 3
raises(TypeError, lambda: x < y)
assert x - y < 0
ineq = Lt(x, y, evaluate=False)
raises(TypeError, lambda: ineq.doit())
assert ineq.lhs - ineq.rhs < 0
t = Symbol('t', imaginary=True)
x = 2 + t
y = 3 + t
ineq = Lt(x, y, evaluate=False)
raises(TypeError, lambda: ineq.doit())
assert ineq.lhs - ineq.rhs < 0
# this one should give error either way
x = I + 2
y = 2*I + 3
raises(TypeError, lambda: x < y)
raises(TypeError, lambda: x - y < 0)
def test_nan_equality_exceptions():
# See issue #7774
import random
assert Equality(nan, nan) is S.false
assert Unequality(nan, nan) is S.true
# See issue #7773
A = (x, S.Zero, S.One/3, pi, oo, -oo)
assert Equality(nan, random.choice(A)) is S.false
assert Equality(random.choice(A), nan) is S.false
assert Unequality(nan, random.choice(A)) is S.true
assert Unequality(random.choice(A), nan) is S.true
def test_nan_inequality_raise_errors():
# See discussion in pull request #7776. We test inequalities with
# a set including examples of various classes.
for q in (x, S.Zero, S(10), S.One/3, pi, S(1.3), oo, -oo, nan):
assert_all_ineq_raise_TypeError(q, nan)
def test_nan_complex_inequalities():
# Comparisons of NaN with non-real raise errors, we're not too
# fussy whether its the NaN error or complex error.
for r in (I, zoo, Symbol('z', imaginary=True)):
assert_all_ineq_raise_TypeError(r, nan)
def test_complex_infinity_inequalities():
raises(TypeError, lambda: zoo > 0)
raises(TypeError, lambda: zoo >= 0)
raises(TypeError, lambda: zoo < 0)
raises(TypeError, lambda: zoo <= 0)
def test_inequalities_symbol_name_same():
"""Using the operator and functional forms should give same results."""
# We test all combinations from a set
# FIXME: could replace with random selection after test passes
A = (x, y, S.Zero, S.One/3, pi, oo, -oo)
for a in A:
for b in A:
assert Gt(a, b) == (a > b)
assert Lt(a, b) == (a < b)
assert Ge(a, b) == (a >= b)
assert Le(a, b) == (a <= b)
for b in (y, S.Zero, S.One/3, pi, oo, -oo):
assert Gt(x, b, evaluate=False) == (x > b)
assert Lt(x, b, evaluate=False) == (x < b)
assert Ge(x, b, evaluate=False) == (x >= b)
assert Le(x, b, evaluate=False) == (x <= b)
for b in (y, S.Zero, S.One/3, pi, oo, -oo):
assert Gt(b, x, evaluate=False) == (b > x)
assert Lt(b, x, evaluate=False) == (b < x)
assert Ge(b, x, evaluate=False) == (b >= x)
assert Le(b, x, evaluate=False) == (b <= x)
def test_inequalities_symbol_name_same_complex():
"""Using the operator and functional forms should give same results.
With complex non-real numbers, both should raise errors.
"""
# FIXME: could replace with random selection after test passes
for a in (x, S.Zero, S.One/3, pi, oo, Rational(1, 3)):
raises(TypeError, lambda: Gt(a, I))
raises(TypeError, lambda: a > I)
raises(TypeError, lambda: Lt(a, I))
raises(TypeError, lambda: a < I)
raises(TypeError, lambda: Ge(a, I))
raises(TypeError, lambda: a >= I)
raises(TypeError, lambda: Le(a, I))
raises(TypeError, lambda: a <= I)
def test_inequalities_cant_sympify_other():
# see issue 7833
from operator import gt, lt, ge, le
bar = "foo"
for a in (x, S.Zero, S.One/3, pi, I, zoo, oo, -oo, nan, Rational(1, 3)):
for op in (lt, gt, le, ge):
raises(TypeError, lambda: op(a, bar))
def test_ineq_avoid_wild_symbol_flip():
# see issue #7951, we try to avoid this internally, e.g., by using
# __lt__ instead of "<".
from sympy.core.symbol import Wild
p = symbols('p', cls=Wild)
# x > p might flip, but Gt should not:
assert Gt(x, p) == Gt(x, p, evaluate=False)
# Previously failed as 'p > x':
e = Lt(x, y).subs({y: p})
assert e == Lt(x, p, evaluate=False)
# Previously failed as 'p <= x':
e = Ge(x, p).doit()
assert e == Ge(x, p, evaluate=False)
def test_issue_8245():
a = S("6506833320952669167898688709329/5070602400912917605986812821504")
assert rel_check(a, a.n(10))
assert rel_check(a, a.n(20))
assert rel_check(a, a.n())
# prec of 30 is enough to fully capture a as mpf
assert Float(a, 30) == Float(str(a.p), '')/Float(str(a.q), '')
for i in range(31):
r = Rational(Float(a, i))
f = Float(r)
assert (f < a) == (Rational(f) < a)
# test sign handling
assert (-f < -a) == (Rational(-f) < -a)
# test equivalence handling
isa = Float(a.p,'')/Float(a.q,'')
assert isa <= a
assert not isa < a
assert isa >= a
assert not isa > a
assert isa > 0
a = sqrt(2)
r = Rational(str(a.n(30)))
assert rel_check(a, r)
a = sqrt(2)
r = Rational(str(a.n(29)))
assert rel_check(a, r)
assert Eq(log(cos(2)**2 + sin(2)**2), 0) == True
def test_issue_8449():
p = Symbol('p', nonnegative=True)
assert Lt(-oo, p)
assert Ge(-oo, p) is S.false
assert Gt(oo, -p)
assert Le(oo, -p) is S.false
def test_simplify_relational():
assert simplify(x*(y + 1) - x*y - x + 1 < x) == (x > 1)
assert simplify(x*(y + 1) - x*y - x - 1 < x) == (x > -1)
assert simplify(x < x*(y + 1) - x*y - x + 1) == (x < 1)
r = S.One < x
# canonical operations are not the same as simplification,
# so if there is no simplification, canonicalization will
# be done unless the measure forbids it
assert simplify(r) == r.canonical
assert simplify(r, ratio=0) != r.canonical
# this is not a random test; in _eval_simplify
# this will simplify to S.false and that is the
# reason for the 'if r.is_Relational' in Relational's
# _eval_simplify routine
assert simplify(-(2**(pi*Rational(3, 2)) + 6**pi)**(1/pi) +
2*(2**(pi/2) + 3**pi)**(1/pi) < 0) is S.false
# canonical at least
assert Eq(y, x).simplify() == Eq(x, y)
assert Eq(x - 1, 0).simplify() == Eq(x, 1)
assert Eq(x - 1, x).simplify() == S.false
assert Eq(2*x - 1, x).simplify() == Eq(x, 1)
assert Eq(2*x, 4).simplify() == Eq(x, 2)
z = cos(1)**2 + sin(1)**2 - 1 # z.is_zero is None
assert Eq(z*x, 0).simplify() == S.true
assert Ne(y, x).simplify() == Ne(x, y)
assert Ne(x - 1, 0).simplify() == Ne(x, 1)
assert Ne(x - 1, x).simplify() == S.true
assert Ne(2*x - 1, x).simplify() == Ne(x, 1)
assert Ne(2*x, 4).simplify() == Ne(x, 2)
assert Ne(z*x, 0).simplify() == S.false
# No real-valued assumptions
assert Ge(y, x).simplify() == Le(x, y)
assert Ge(x - 1, 0).simplify() == Ge(x, 1)
assert Ge(x - 1, x).simplify() == S.false
assert Ge(2*x - 1, x).simplify() == Ge(x, 1)
assert Ge(2*x, 4).simplify() == Ge(x, 2)
assert Ge(z*x, 0).simplify() == S.true
assert Ge(x, -2).simplify() == Ge(x, -2)
assert Ge(-x, -2).simplify() == Le(x, 2)
assert Ge(x, 2).simplify() == Ge(x, 2)
assert Ge(-x, 2).simplify() == Le(x, -2)
assert Le(y, x).simplify() == Ge(x, y)
assert Le(x - 1, 0).simplify() == Le(x, 1)
assert Le(x - 1, x).simplify() == S.true
assert Le(2*x - 1, x).simplify() == Le(x, 1)
assert Le(2*x, 4).simplify() == Le(x, 2)
assert Le(z*x, 0).simplify() == S.true
assert Le(x, -2).simplify() == Le(x, -2)
assert Le(-x, -2).simplify() == Ge(x, 2)
assert Le(x, 2).simplify() == Le(x, 2)
assert Le(-x, 2).simplify() == Ge(x, -2)
assert Gt(y, x).simplify() == Lt(x, y)
assert Gt(x - 1, 0).simplify() == Gt(x, 1)
assert Gt(x - 1, x).simplify() == S.false
assert Gt(2*x - 1, x).simplify() == Gt(x, 1)
assert Gt(2*x, 4).simplify() == Gt(x, 2)
assert Gt(z*x, 0).simplify() == S.false
assert Gt(x, -2).simplify() == Gt(x, -2)
assert Gt(-x, -2).simplify() == Lt(x, 2)
assert Gt(x, 2).simplify() == Gt(x, 2)
assert Gt(-x, 2).simplify() == Lt(x, -2)
assert Lt(y, x).simplify() == Gt(x, y)
assert Lt(x - 1, 0).simplify() == Lt(x, 1)
assert Lt(x - 1, x).simplify() == S.true
assert Lt(2*x - 1, x).simplify() == Lt(x, 1)
assert Lt(2*x, 4).simplify() == Lt(x, 2)
assert Lt(z*x, 0).simplify() == S.false
assert Lt(x, -2).simplify() == Lt(x, -2)
assert Lt(-x, -2).simplify() == Gt(x, 2)
assert Lt(x, 2).simplify() == Lt(x, 2)
assert Lt(-x, 2).simplify() == Gt(x, -2)
def test_equals():
w, x, y, z = symbols('w:z')
f = Function('f')
assert Eq(x, 1).equals(Eq(x*(y + 1) - x*y - x + 1, x))
assert Eq(x, y).equals(x < y, True) == False
assert Eq(x, f(1)).equals(Eq(x, f(2)), True) == f(1) - f(2)
assert Eq(f(1), y).equals(Eq(f(2), y), True) == f(1) - f(2)
assert Eq(x, f(1)).equals(Eq(f(2), x), True) == f(1) - f(2)
assert Eq(f(1), x).equals(Eq(x, f(2)), True) == f(1) - f(2)
assert Eq(w, x).equals(Eq(y, z), True) == False
assert Eq(f(1), f(2)).equals(Eq(f(3), f(4)), True) == f(1) - f(3)
assert (x < y).equals(y > x, True) == True
assert (x < y).equals(y >= x, True) == False
assert (x < y).equals(z < y, True) == False
assert (x < y).equals(x < z, True) == False
assert (x < f(1)).equals(x < f(2), True) == f(1) - f(2)
assert (f(1) < x).equals(f(2) < x, True) == f(1) - f(2)
def test_reversed():
assert (x < y).reversed == (y > x)
assert (x <= y).reversed == (y >= x)
assert Eq(x, y, evaluate=False).reversed == Eq(y, x, evaluate=False)
assert Ne(x, y, evaluate=False).reversed == Ne(y, x, evaluate=False)
assert (x >= y).reversed == (y <= x)
assert (x > y).reversed == (y < x)
def test_canonical():
c = [i.canonical for i in (
x + y < z,
x + 2 > 3,
x < 2,
S(2) > x,
x**2 > -x/y,
Gt(3, 2, evaluate=False)
)]
assert [i.canonical for i in c] == c
assert [i.reversed.canonical for i in c] == c
assert not any(i.lhs.is_Number and not i.rhs.is_Number for i in c)
c = [i.reversed.func(i.rhs, i.lhs, evaluate=False).canonical for i in c]
assert [i.canonical for i in c] == c
assert [i.reversed.canonical for i in c] == c
assert not any(i.lhs.is_Number and not i.rhs.is_Number for i in c)
@XFAIL
def test_issue_8444_nonworkingtests():
x = symbols('x', real=True)
assert (x <= oo) == (x >= -oo) == True
x = symbols('x')
assert x >= floor(x)
assert (x < floor(x)) == False
assert x <= ceiling(x)
assert (x > ceiling(x)) == False
def test_issue_8444_workingtests():
x = symbols('x')
assert Gt(x, floor(x)) == Gt(x, floor(x), evaluate=False)
assert Ge(x, floor(x)) == Ge(x, floor(x), evaluate=False)
assert Lt(x, ceiling(x)) == Lt(x, ceiling(x), evaluate=False)
assert Le(x, ceiling(x)) == Le(x, ceiling(x), evaluate=False)
i = symbols('i', integer=True)
assert (i > floor(i)) == False
assert (i < ceiling(i)) == False
def test_issue_10304():
d = cos(1)**2 + sin(1)**2 - 1
assert d.is_comparable is False # if this fails, find a new d
e = 1 + d*I
assert simplify(Eq(e, 0)) is S.false
def test_issue_18412():
d = (Rational(1, 6) + z / 4 / y)
assert Eq(x, pi * y**3 * d).replace(y**3, z) == Eq(x, pi * z * d)
def test_issue_10401():
x = symbols('x')
fin = symbols('inf', finite=True)
inf = symbols('inf', infinite=True)
inf2 = symbols('inf2', infinite=True)
infx = symbols('infx', infinite=True, extended_real=True)
# Used in the commented tests below:
#infx2 = symbols('infx2', infinite=True, extended_real=True)
infnx = symbols('inf~x', infinite=True, extended_real=False)
infnx2 = symbols('inf~x2', infinite=True, extended_real=False)
infp = symbols('infp', infinite=True, extended_positive=True)
infp1 = symbols('infp1', infinite=True, extended_positive=True)
infn = symbols('infn', infinite=True, extended_negative=True)
zero = symbols('z', zero=True)
nonzero = symbols('nz', zero=False, finite=True)
assert Eq(1/(1/x + 1), 1).func is Eq
assert Eq(1/(1/x + 1), 1).subs(x, S.ComplexInfinity) is S.true
assert Eq(1/(1/fin + 1), 1) is S.false
T, F = S.true, S.false
assert Eq(fin, inf) is F
assert Eq(inf, inf2) not in (T, F) and inf != inf2
assert Eq(1 + inf, 2 + inf2) not in (T, F) and inf != inf2
assert Eq(infp, infp1) is T
assert Eq(infp, infn) is F
assert Eq(1 + I*oo, I*oo) is F
assert Eq(I*oo, 1 + I*oo) is F
assert Eq(1 + I*oo, 2 + I*oo) is F
assert Eq(1 + I*oo, 2 + I*infx) is F
assert Eq(1 + I*oo, 2 + infx) is F
# FIXME: The test below fails because (-infx).is_extended_positive is True
# (should be None)
#assert Eq(1 + I*infx, 1 + I*infx2) not in (T, F) and infx != infx2
#
assert Eq(zoo, sqrt(2) + I*oo) is F
assert Eq(zoo, oo) is F
r = Symbol('r', real=True)
i = Symbol('i', imaginary=True)
assert Eq(i*I, r) not in (T, F)
assert Eq(infx, infnx) is F
assert Eq(infnx, infnx2) not in (T, F) and infnx != infnx2
assert Eq(zoo, oo) is F
assert Eq(inf/inf2, 0) is F
assert Eq(inf/fin, 0) is F
assert Eq(fin/inf, 0) is T
assert Eq(zero/nonzero, 0) is T and ((zero/nonzero) != 0)
# The commented out test below is incorrect because:
assert zoo == -zoo
assert Eq(zoo, -zoo) is T
assert Eq(oo, -oo) is F
assert Eq(inf, -inf) not in (T, F)
assert Eq(fin/(fin + 1), 1) is S.false
o = symbols('o', odd=True)
assert Eq(o, 2*o) is S.false
p = symbols('p', positive=True)
assert Eq(p/(p - 1), 1) is F
def test_issue_10633():
assert Eq(True, False) == False
assert Eq(False, True) == False
assert Eq(True, True) == True
assert Eq(False, False) == True
def test_issue_10927():
x = symbols('x')
assert str(Eq(x, oo)) == 'Eq(x, oo)'
assert str(Eq(x, -oo)) == 'Eq(x, -oo)'
def test_issues_13081_12583_12534():
# 13081
r = Rational('905502432259640373/288230376151711744')
assert (r < pi) is S.false
assert (r > pi) is S.true
# 12583
v = sqrt(2)
u = sqrt(v) + 2/sqrt(10 - 8/sqrt(2 - v) + 4*v*(1/sqrt(2 - v) - 1))
assert (u >= 0) is S.true
# 12534; Rational vs NumberSymbol
# here are some precisions for which Rational forms
# at a lower and higher precision bracket the value of pi
# e.g. for p = 20:
# Rational(pi.n(p + 1)).n(25) = 3.14159265358979323846 2834
# pi.n(25) = 3.14159265358979323846 2643
# Rational(pi.n(p )).n(25) = 3.14159265358979323846 1987
assert [p for p in range(20, 50) if
(Rational(pi.n(p)) < pi) and
(pi < Rational(pi.n(p + 1)))] == [20, 24, 27, 33, 37, 43, 48]
# pick one such precision and affirm that the reversed operation
# gives the opposite result, i.e. if x < y is true then x > y
# must be false
for i in (20, 21):
v = pi.n(i)
assert rel_check(Rational(v), pi)
assert rel_check(v, pi)
assert rel_check(pi.n(20), pi.n(21))
# Float vs Rational
# the rational form is less than the floating representation
# at the same precision
assert [i for i in range(15, 50) if Rational(pi.n(i)) > pi.n(i)] == []
# this should be the same if we reverse the relational
assert [i for i in range(15, 50) if pi.n(i) < Rational(pi.n(i))] == []
def test_issue_18188():
from sympy.sets.conditionset import ConditionSet
result1 = Eq(x*cos(x) - 3*sin(x), 0)
assert result1.as_set() == ConditionSet(x, Eq(x*cos(x) - 3*sin(x), 0), Reals)
result2 = Eq(x**2 + sqrt(x*2) + sin(x), 0)
assert result2.as_set() == ConditionSet(x, Eq(sqrt(2)*sqrt(x) + x**2 + sin(x), 0), Reals)
def test_binary_symbols():
ans = {x}
for f in Eq, Ne:
for t in S.true, S.false:
eq = f(x, S.true)
assert eq.binary_symbols == ans
assert eq.reversed.binary_symbols == ans
assert f(x, 1).binary_symbols == set()
def test_rel_args():
# can't have Boolean args; this is automatic for True/False
# with Python 3 and we confirm that SymPy does the same
# for true/false
for op in ['<', '<=', '>', '>=']:
for b in (S.true, x < 1, And(x, y)):
for v in (0.1, 1, 2**32, t, S.One):
raises(TypeError, lambda: Relational(b, v, op))
def test_Equality_rewrite_as_Add():
eq = Eq(x + y, y - x)
assert eq.rewrite(Add) == 2*x
assert eq.rewrite(Add, evaluate=None).args == (x, x, y, -y)
assert eq.rewrite(Add, evaluate=False).args == (x, y, x, -y)
def test_issue_15847():
a = Ne(x*(x+y), x**2 + x*y)
assert simplify(a) == False
def test_negated_property():
eq = Eq(x, y)
assert eq.negated == Ne(x, y)
eq = Ne(x, y)
assert eq.negated == Eq(x, y)
eq = Ge(x + y, y - x)
assert eq.negated == Lt(x + y, y - x)
for f in (Eq, Ne, Ge, Gt, Le, Lt):
assert f(x, y).negated.negated == f(x, y)
def test_reversedsign_property():
eq = Eq(x, y)
assert eq.reversedsign == Eq(-x, -y)
eq = Ne(x, y)
assert eq.reversedsign == Ne(-x, -y)
eq = Ge(x + y, y - x)
assert eq.reversedsign == Le(-x - y, x - y)
for f in (Eq, Ne, Ge, Gt, Le, Lt):
assert f(x, y).reversedsign.reversedsign == f(x, y)
for f in (Eq, Ne, Ge, Gt, Le, Lt):
assert f(-x, y).reversedsign.reversedsign == f(-x, y)
for f in (Eq, Ne, Ge, Gt, Le, Lt):
assert f(x, -y).reversedsign.reversedsign == f(x, -y)
for f in (Eq, Ne, Ge, Gt, Le, Lt):
assert f(-x, -y).reversedsign.reversedsign == f(-x, -y)
def test_reversed_reversedsign_property():
for f in (Eq, Ne, Ge, Gt, Le, Lt):
assert f(x, y).reversed.reversedsign == f(x, y).reversedsign.reversed
for f in (Eq, Ne, Ge, Gt, Le, Lt):
assert f(-x, y).reversed.reversedsign == f(-x, y).reversedsign.reversed
for f in (Eq, Ne, Ge, Gt, Le, Lt):
assert f(x, -y).reversed.reversedsign == f(x, -y).reversedsign.reversed
for f in (Eq, Ne, Ge, Gt, Le, Lt):
assert f(-x, -y).reversed.reversedsign == \
f(-x, -y).reversedsign.reversed
def test_improved_canonical():
def test_different_forms(listofforms):
for form1, form2 in combinations(listofforms, 2):
assert form1.canonical == form2.canonical
def generate_forms(expr):
return [expr, expr.reversed, expr.reversedsign,
expr.reversed.reversedsign]
test_different_forms(generate_forms(x > -y))
test_different_forms(generate_forms(x >= -y))
test_different_forms(generate_forms(Eq(x, -y)))
test_different_forms(generate_forms(Ne(x, -y)))
test_different_forms(generate_forms(pi < x))
test_different_forms(generate_forms(pi - 5*y < -x + 2*y**2 - 7))
assert (pi >= x).canonical == (x <= pi)
def test_set_equality_canonical():
a, b, c = symbols('a b c')
A = Eq(FiniteSet(a, b, c), FiniteSet(1, 2, 3))
B = Ne(FiniteSet(a, b, c), FiniteSet(4, 5, 6))
assert A.canonical == A.reversed
assert B.canonical == B.reversed
def test_trigsimp():
# issue 16736
s, c = sin(2*x), cos(2*x)
eq = Eq(s, c)
assert trigsimp(eq) == eq # no rearrangement of sides
# simplification of sides might result in
# an unevaluated Eq
changed = trigsimp(Eq(s + c, sqrt(2)))
assert isinstance(changed, Eq)
assert changed.subs(x, pi/8) is S.true
# or an evaluated one
assert trigsimp(Eq(cos(x)**2 + sin(x)**2, 1)) is S.true
def test_polynomial_relation_simplification():
assert Ge(3*x*(x + 1) + 4, 3*x).simplify() in [Ge(x**2, -Rational(4,3)), Le(-x**2, Rational(4, 3))]
assert Le(-(3*x*(x + 1) + 4), -3*x).simplify() in [Ge(x**2, -Rational(4,3)), Le(-x**2, Rational(4, 3))]
assert ((x**2+3)*(x**2-1)+3*x >= 2*x**2).simplify() in [(x**4 + 3*x >= 3), (-x**4 - 3*x <= -3)]
def test_multivariate_linear_function_simplification():
assert Ge(x + y, x - y).simplify() == Ge(y, 0)
assert Le(-x + y, -x - y).simplify() == Le(y, 0)
assert Eq(2*x + y, 2*x + y - 3).simplify() == False
assert (2*x + y > 2*x + y - 3).simplify() == True
assert (2*x + y < 2*x + y - 3).simplify() == False
assert (2*x + y < 2*x + y + 3).simplify() == True
a, b, c, d, e, f, g = symbols('a b c d e f g')
assert Lt(a + b + c + 2*d, 3*d - f + g). simplify() == Lt(a, -b - c + d - f + g)
def test_nonpolymonial_relations():
assert Eq(cos(x), 0).simplify() == Eq(cos(x), 0)
|
0f6e57bb922ac98763ff59a4b200751290073fb28b712b99360ab8c8973c7651 | #this module tests that sympy works with true division turned on
from sympy import Rational, Symbol, Float
def test_truediv():
assert 1/2 != 0
assert Rational(1)/2 != 0
def dotest(s):
x = Symbol("x")
y = Symbol("y")
l = [
Rational(2),
Float("1.3"),
x,
y,
pow(x, y)*y,
5,
5.5
]
for x in l:
for y in l:
s(x, y)
return True
def test_basic():
def s(a, b):
x = a
x = +a
x = -a
x = a + b
x = a - b
x = a*b
x = a/b
x = a**b
del x
assert dotest(s)
def test_ibasic():
def s(a, b):
x = a
x += b
x = a
x -= b
x = a
x *= b
x = a
x /= b
assert dotest(s)
|
0a786a7dfeb3e911758d982c73e049a704b0e13cdc31e0018ed577a6c43cc13c | from collections import defaultdict
from sympy import Matrix, Tuple, symbols, sympify, Basic, Dict, S, FiniteSet, Integer
from sympy.core.compatibility import is_sequence, iterable
from sympy.core.containers import tuple_wrapper
from sympy.core.expr import unchanged
from sympy.core.function import Function, Lambda
from sympy.core.relational import Eq
from sympy.testing.pytest import raises
from sympy.abc import x, y
def test_Tuple():
t = (1, 2, 3, 4)
st = Tuple(*t)
assert set(sympify(t)) == set(st)
assert len(t) == len(st)
assert set(sympify(t[:2])) == set(st[:2])
assert isinstance(st[:], Tuple)
assert st == Tuple(1, 2, 3, 4)
assert st.func(*st.args) == st
p, q, r, s = symbols('p q r s')
t2 = (p, q, r, s)
st2 = Tuple(*t2)
assert st2.atoms() == set(t2)
assert st == st2.subs({p: 1, q: 2, r: 3, s: 4})
# issue 5505
assert all(isinstance(arg, Basic) for arg in st.args)
assert Tuple(p, 1).subs(p, 0) == Tuple(0, 1)
assert Tuple(p, Tuple(p, 1)).subs(p, 0) == Tuple(0, Tuple(0, 1))
assert Tuple(t2) == Tuple(Tuple(*t2))
assert Tuple.fromiter(t2) == Tuple(*t2)
assert Tuple.fromiter(x for x in range(4)) == Tuple(0, 1, 2, 3)
assert st2.fromiter(st2.args) == st2
def test_Tuple_contains():
t1, t2 = Tuple(1), Tuple(2)
assert t1 in Tuple(1, 2, 3, t1, Tuple(t2))
assert t2 not in Tuple(1, 2, 3, t1, Tuple(t2))
def test_Tuple_concatenation():
assert Tuple(1, 2) + Tuple(3, 4) == Tuple(1, 2, 3, 4)
assert (1, 2) + Tuple(3, 4) == Tuple(1, 2, 3, 4)
assert Tuple(1, 2) + (3, 4) == Tuple(1, 2, 3, 4)
raises(TypeError, lambda: Tuple(1, 2) + 3)
raises(TypeError, lambda: 1 + Tuple(2, 3))
#the Tuple case in __radd__ is only reached when a subclass is involved
class Tuple2(Tuple):
def __radd__(self, other):
return Tuple.__radd__(self, other + other)
assert Tuple(1, 2) + Tuple2(3, 4) == Tuple(1, 2, 1, 2, 3, 4)
assert Tuple2(1, 2) + Tuple(3, 4) == Tuple(1, 2, 3, 4)
def test_Tuple_equality():
assert not isinstance(Tuple(1, 2), tuple)
assert (Tuple(1, 2) == (1, 2)) is True
assert (Tuple(1, 2) != (1, 2)) is False
assert (Tuple(1, 2) == (1, 3)) is False
assert (Tuple(1, 2) != (1, 3)) is True
assert (Tuple(1, 2) == Tuple(1, 2)) is True
assert (Tuple(1, 2) != Tuple(1, 2)) is False
assert (Tuple(1, 2) == Tuple(1, 3)) is False
assert (Tuple(1, 2) != Tuple(1, 3)) is True
def test_Tuple_Eq():
assert Eq(Tuple(), Tuple()) is S.true
assert Eq(Tuple(1), 1) is S.false
assert Eq(Tuple(1, 2), Tuple(1)) is S.false
assert Eq(Tuple(1), Tuple(1)) is S.true
assert Eq(Tuple(1, 2), Tuple(1, 3)) is S.false
assert Eq(Tuple(1, 2), Tuple(1, 2)) is S.true
assert unchanged(Eq, Tuple(1, x), Tuple(1, 2))
assert Eq(Tuple(1, x), Tuple(1, 2)).subs(x, 2) is S.true
assert unchanged(Eq, Tuple(1, 2), x)
f = Function('f')
assert unchanged(Eq, Tuple(1), f(x))
assert Eq(Tuple(1), f(x)).subs(x, 1).subs(f, Lambda(y, (y,))) is S.true
def test_Tuple_comparision():
assert (Tuple(1, 3) >= Tuple(-10, 30)) is S.true
assert (Tuple(1, 3) <= Tuple(-10, 30)) is S.false
assert (Tuple(1, 3) >= Tuple(1, 3)) is S.true
assert (Tuple(1, 3) <= Tuple(1, 3)) is S.true
def test_Tuple_tuple_count():
assert Tuple(0, 1, 2, 3).tuple_count(4) == 0
assert Tuple(0, 4, 1, 2, 3).tuple_count(4) == 1
assert Tuple(0, 4, 1, 4, 2, 3).tuple_count(4) == 2
assert Tuple(0, 4, 1, 4, 2, 4, 3).tuple_count(4) == 3
def test_Tuple_index():
assert Tuple(4, 0, 1, 2, 3).index(4) == 0
assert Tuple(0, 4, 1, 2, 3).index(4) == 1
assert Tuple(0, 1, 4, 2, 3).index(4) == 2
assert Tuple(0, 1, 2, 4, 3).index(4) == 3
assert Tuple(0, 1, 2, 3, 4).index(4) == 4
raises(ValueError, lambda: Tuple(0, 1, 2, 3).index(4))
raises(ValueError, lambda: Tuple(4, 0, 1, 2, 3).index(4, 1))
raises(ValueError, lambda: Tuple(0, 1, 2, 3, 4).index(4, 1, 4))
def test_Tuple_mul():
assert Tuple(1, 2, 3)*2 == Tuple(1, 2, 3, 1, 2, 3)
assert 2*Tuple(1, 2, 3) == Tuple(1, 2, 3, 1, 2, 3)
assert Tuple(1, 2, 3)*Integer(2) == Tuple(1, 2, 3, 1, 2, 3)
assert Integer(2)*Tuple(1, 2, 3) == Tuple(1, 2, 3, 1, 2, 3)
raises(TypeError, lambda: Tuple(1, 2, 3)*S.Half)
raises(TypeError, lambda: S.Half*Tuple(1, 2, 3))
def test_tuple_wrapper():
@tuple_wrapper
def wrap_tuples_and_return(*t):
return t
p = symbols('p')
assert wrap_tuples_and_return(p, 1) == (p, 1)
assert wrap_tuples_and_return((p, 1)) == (Tuple(p, 1),)
assert wrap_tuples_and_return(1, (p, 2), 3) == (1, Tuple(p, 2), 3)
def test_iterable_is_sequence():
ordered = [list(), tuple(), Tuple(), Matrix([[]])]
unordered = [set()]
not_sympy_iterable = [{}, '', '']
assert all(is_sequence(i) for i in ordered)
assert all(not is_sequence(i) for i in unordered)
assert all(iterable(i) for i in ordered + unordered)
assert all(not iterable(i) for i in not_sympy_iterable)
assert all(iterable(i, exclude=None) for i in not_sympy_iterable)
def test_Dict():
x, y, z = symbols('x y z')
d = Dict({x: 1, y: 2, z: 3})
assert d[x] == 1
assert d[y] == 2
raises(KeyError, lambda: d[2])
assert len(d) == 3
assert set(d.keys()) == {x, y, z}
assert set(d.values()) == {S.One, S(2), S(3)}
assert d.get(5, 'default') == 'default'
assert x in d and z in d and not 5 in d
assert d.has(x) and d.has(1) # SymPy Basic .has method
# Test input types
# input - a python dict
# input - items as args - SymPy style
assert (Dict({x: 1, y: 2, z: 3}) ==
Dict((x, 1), (y, 2), (z, 3)))
raises(TypeError, lambda: Dict(((x, 1), (y, 2), (z, 3))))
with raises(NotImplementedError):
d[5] = 6 # assert immutability
assert set(
d.items()) == {Tuple(x, S.One), Tuple(y, S(2)), Tuple(z, S(3))}
assert set(d) == {x, y, z}
assert str(d) == '{x: 1, y: 2, z: 3}'
assert d.__repr__() == '{x: 1, y: 2, z: 3}'
# Test creating a Dict from a Dict.
d = Dict({x: 1, y: 2, z: 3})
assert d == Dict(d)
# Test for supporting defaultdict
d = defaultdict(int)
assert d[x] == 0
assert d[y] == 0
assert d[z] == 0
assert Dict(d)
d = Dict(d)
assert len(d) == 3
assert set(d.keys()) == {x, y, z}
assert set(d.values()) == {S.Zero, S.Zero, S.Zero}
def test_issue_5788():
args = [(1, 2), (2, 1)]
for o in [Dict, Tuple, FiniteSet]:
# __eq__ and arg handling
if o != Tuple:
assert o(*args) == o(*reversed(args))
pair = [o(*args), o(*reversed(args))]
assert sorted(pair) == sorted(reversed(pair))
assert set(o(*args)) # doesn't fail
|
74bcfb1ff4ac08a0ae5907f7dcd26ab821a694250a1d7cf6236c4fbe2582c8dc | from sympy import (Symbol, exp, Integer, Float, sin, cos, log, Poly, Lambda,
Function, I, S, sqrt, srepr, Rational, Tuple, Matrix, Interval, Add, Mul,
Pow, Or, true, false, Abs, pi, Range, Xor)
from sympy.abc import x, y
from sympy.core.sympify import (sympify, _sympify, SympifyError, kernS,
CantSympify)
from sympy.core.decorators import _sympifyit
from sympy.external import import_module
from sympy.testing.pytest import raises, XFAIL, skip, warns_deprecated_sympy
from sympy.utilities.decorator import conserve_mpmath_dps
from sympy.geometry import Point, Line
from sympy.functions.combinatorial.factorials import factorial, factorial2
from sympy.abc import _clash, _clash1, _clash2
from sympy.core.compatibility import exec_, HAS_GMPY
from sympy.sets import FiniteSet, EmptySet
from sympy.tensor.array.dense_ndim_array import ImmutableDenseNDimArray
import mpmath
from collections import defaultdict, OrderedDict
from mpmath.rational import mpq
numpy = import_module('numpy')
def test_issue_3538():
v = sympify("exp(x)")
assert v == exp(x)
assert type(v) == type(exp(x))
assert str(type(v)) == str(type(exp(x)))
def test_sympify1():
assert sympify("x") == Symbol("x")
assert sympify(" x") == Symbol("x")
assert sympify(" x ") == Symbol("x")
# issue 4877
n1 = S.Half
assert sympify('--.5') == n1
assert sympify('-1/2') == -n1
assert sympify('-+--.5') == -n1
assert sympify('-.[3]') == Rational(-1, 3)
assert sympify('.[3]') == Rational(1, 3)
assert sympify('+.[3]') == Rational(1, 3)
assert sympify('+0.[3]*10**-2') == Rational(1, 300)
assert sympify('.[052631578947368421]') == Rational(1, 19)
assert sympify('.0[526315789473684210]') == Rational(1, 19)
assert sympify('.034[56]') == Rational(1711, 49500)
# options to make reals into rationals
assert sympify('1.22[345]', rational=True) == \
1 + Rational(22, 100) + Rational(345, 99900)
assert sympify('2/2.6', rational=True) == Rational(10, 13)
assert sympify('2.6/2', rational=True) == Rational(13, 10)
assert sympify('2.6e2/17', rational=True) == Rational(260, 17)
assert sympify('2.6e+2/17', rational=True) == Rational(260, 17)
assert sympify('2.6e-2/17', rational=True) == Rational(26, 17000)
assert sympify('2.1+3/4', rational=True) == \
Rational(21, 10) + Rational(3, 4)
assert sympify('2.234456', rational=True) == Rational(279307, 125000)
assert sympify('2.234456e23', rational=True) == 223445600000000000000000
assert sympify('2.234456e-23', rational=True) == \
Rational(279307, 12500000000000000000000000000)
assert sympify('-2.234456e-23', rational=True) == \
Rational(-279307, 12500000000000000000000000000)
assert sympify('12345678901/17', rational=True) == \
Rational(12345678901, 17)
assert sympify('1/.3 + x', rational=True) == Rational(10, 3) + x
# make sure longs in fractions work
assert sympify('222222222222/11111111111') == \
Rational(222222222222, 11111111111)
# ... even if they come from repetend notation
assert sympify('1/.2[123456789012]') == Rational(333333333333, 70781892967)
# ... or from high precision reals
assert sympify('.1234567890123456', rational=True) == \
Rational(19290123283179, 156250000000000)
def test_sympify_Fraction():
try:
import fractions
except ImportError:
pass
else:
value = sympify(fractions.Fraction(101, 127))
assert value == Rational(101, 127) and type(value) is Rational
def test_sympify_gmpy():
if HAS_GMPY:
if HAS_GMPY == 2:
import gmpy2 as gmpy
elif HAS_GMPY == 1:
import gmpy
value = sympify(gmpy.mpz(1000001))
assert value == Integer(1000001) and type(value) is Integer
value = sympify(gmpy.mpq(101, 127))
assert value == Rational(101, 127) and type(value) is Rational
@conserve_mpmath_dps
def test_sympify_mpmath():
value = sympify(mpmath.mpf(1.0))
assert value == Float(1.0) and type(value) is Float
mpmath.mp.dps = 12
assert sympify(
mpmath.pi).epsilon_eq(Float("3.14159265359"), Float("1e-12")) == True
assert sympify(
mpmath.pi).epsilon_eq(Float("3.14159265359"), Float("1e-13")) == False
mpmath.mp.dps = 6
assert sympify(
mpmath.pi).epsilon_eq(Float("3.14159"), Float("1e-5")) == True
assert sympify(
mpmath.pi).epsilon_eq(Float("3.14159"), Float("1e-6")) == False
assert sympify(mpmath.mpc(1.0 + 2.0j)) == Float(1.0) + Float(2.0)*I
assert sympify(mpq(1, 2)) == S.Half
def test_sympify2():
class A:
def _sympy_(self):
return Symbol("x")**3
a = A()
assert _sympify(a) == x**3
assert sympify(a) == x**3
assert a == x**3
def test_sympify3():
assert sympify("x**3") == x**3
assert sympify("x^3") == x**3
assert sympify("1/2") == Integer(1)/2
raises(SympifyError, lambda: _sympify('x**3'))
raises(SympifyError, lambda: _sympify('1/2'))
def test_sympify_keywords():
raises(SympifyError, lambda: sympify('if'))
raises(SympifyError, lambda: sympify('for'))
raises(SympifyError, lambda: sympify('while'))
raises(SympifyError, lambda: sympify('lambda'))
def test_sympify_float():
assert sympify("1e-64") != 0
assert sympify("1e-20000") != 0
def test_sympify_bool():
assert sympify(True) is true
assert sympify(False) is false
def test_sympyify_iterables():
ans = [Rational(3, 10), Rational(1, 5)]
assert sympify(['.3', '.2'], rational=True) == ans
assert sympify(dict(x=0, y=1)) == {x: 0, y: 1}
assert sympify(['1', '2', ['3', '4']]) == [S(1), S(2), [S(3), S(4)]]
@XFAIL
def test_issue_16772():
# because there is a converter for tuple, the
# args are only sympified without the flags being passed
# along; list, on the other hand, is not converted
# with a converter so its args are traversed later
ans = [Rational(3, 10), Rational(1, 5)]
assert sympify(tuple(['.3', '.2']), rational=True) == Tuple(*ans)
def test_issue_16859():
class no(float, CantSympify):
pass
raises(SympifyError, lambda: sympify(no(1.2)))
def test_sympify4():
class A:
def _sympy_(self):
return Symbol("x")
a = A()
assert _sympify(a)**3 == x**3
assert sympify(a)**3 == x**3
assert a == x
def test_sympify_text():
assert sympify('some') == Symbol('some')
assert sympify('core') == Symbol('core')
assert sympify('True') is True
assert sympify('False') is False
assert sympify('Poly') == Poly
assert sympify('sin') == sin
def test_sympify_function():
assert sympify('factor(x**2-1, x)') == -(1 - x)*(x + 1)
assert sympify('sin(pi/2)*cos(pi)') == -Integer(1)
def test_sympify_poly():
p = Poly(x**2 + x + 1, x)
assert _sympify(p) is p
assert sympify(p) is p
def test_sympify_factorial():
assert sympify('x!') == factorial(x)
assert sympify('(x+1)!') == factorial(x + 1)
assert sympify('(1 + y*(x + 1))!') == factorial(1 + y*(x + 1))
assert sympify('(1 + y*(x + 1)!)^2') == (1 + y*factorial(x + 1))**2
assert sympify('y*x!') == y*factorial(x)
assert sympify('x!!') == factorial2(x)
assert sympify('(x+1)!!') == factorial2(x + 1)
assert sympify('(1 + y*(x + 1))!!') == factorial2(1 + y*(x + 1))
assert sympify('(1 + y*(x + 1)!!)^2') == (1 + y*factorial2(x + 1))**2
assert sympify('y*x!!') == y*factorial2(x)
assert sympify('factorial2(x)!') == factorial(factorial2(x))
raises(SympifyError, lambda: sympify("+!!"))
raises(SympifyError, lambda: sympify(")!!"))
raises(SympifyError, lambda: sympify("!"))
raises(SympifyError, lambda: sympify("(!)"))
raises(SympifyError, lambda: sympify("x!!!"))
def test_sage():
# how to effectivelly test for the _sage_() method without having SAGE
# installed?
assert hasattr(x, "_sage_")
assert hasattr(Integer(3), "_sage_")
assert hasattr(sin(x), "_sage_")
assert hasattr(cos(x), "_sage_")
assert hasattr(x**2, "_sage_")
assert hasattr(x + y, "_sage_")
assert hasattr(exp(x), "_sage_")
assert hasattr(log(x), "_sage_")
def test_issue_3595():
assert sympify("a_") == Symbol("a_")
assert sympify("_a") == Symbol("_a")
def test_lambda():
x = Symbol('x')
assert sympify('lambda: 1') == Lambda((), 1)
assert sympify('lambda x: x') == Lambda(x, x)
assert sympify('lambda x: 2*x') == Lambda(x, 2*x)
assert sympify('lambda x, y: 2*x+y') == Lambda((x, y), 2*x + y)
def test_lambda_raises():
raises(SympifyError, lambda: sympify("lambda *args: args")) # args argument error
raises(SympifyError, lambda: sympify("lambda **kwargs: kwargs[0]")) # kwargs argument error
raises(SympifyError, lambda: sympify("lambda x = 1: x")) # Keyword argument error
with raises(SympifyError):
_sympify('lambda: 1')
def test_sympify_raises():
raises(SympifyError, lambda: sympify("fx)"))
class A:
def __str__(self):
return 'x'
with warns_deprecated_sympy():
assert sympify(A()) == Symbol('x')
def test__sympify():
x = Symbol('x')
f = Function('f')
# positive _sympify
assert _sympify(x) is x
assert _sympify(f) is f
assert _sympify(1) == Integer(1)
assert _sympify(0.5) == Float("0.5")
assert _sympify(1 + 1j) == 1.0 + I*1.0
class A:
def _sympy_(self):
return Integer(5)
a = A()
assert _sympify(a) == Integer(5)
# negative _sympify
raises(SympifyError, lambda: _sympify('1'))
raises(SympifyError, lambda: _sympify([1, 2, 3]))
def test_sympifyit():
x = Symbol('x')
y = Symbol('y')
@_sympifyit('b', NotImplemented)
def add(a, b):
return a + b
assert add(x, 1) == x + 1
assert add(x, 0.5) == x + Float('0.5')
assert add(x, y) == x + y
assert add(x, '1') == NotImplemented
@_sympifyit('b')
def add_raises(a, b):
return a + b
assert add_raises(x, 1) == x + 1
assert add_raises(x, 0.5) == x + Float('0.5')
assert add_raises(x, y) == x + y
raises(SympifyError, lambda: add_raises(x, '1'))
def test_int_float():
class F1_1:
def __float__(self):
return 1.1
class F1_1b:
"""
This class is still a float, even though it also implements __int__().
"""
def __float__(self):
return 1.1
def __int__(self):
return 1
class F1_1c:
"""
This class is still a float, because it implements _sympy_()
"""
def __float__(self):
return 1.1
def __int__(self):
return 1
def _sympy_(self):
return Float(1.1)
class I5:
def __int__(self):
return 5
class I5b:
"""
This class implements both __int__() and __float__(), so it will be
treated as Float in SymPy. One could change this behavior, by using
float(a) == int(a), but deciding that integer-valued floats represent
exact numbers is arbitrary and often not correct, so we do not do it.
If, in the future, we decide to do it anyway, the tests for I5b need to
be changed.
"""
def __float__(self):
return 5.0
def __int__(self):
return 5
class I5c:
"""
This class implements both __int__() and __float__(), but also
a _sympy_() method, so it will be Integer.
"""
def __float__(self):
return 5.0
def __int__(self):
return 5
def _sympy_(self):
return Integer(5)
i5 = I5()
i5b = I5b()
i5c = I5c()
f1_1 = F1_1()
f1_1b = F1_1b()
f1_1c = F1_1c()
assert sympify(i5) == 5
assert isinstance(sympify(i5), Integer)
assert sympify(i5b) == 5
assert isinstance(sympify(i5b), Float)
assert sympify(i5c) == 5
assert isinstance(sympify(i5c), Integer)
assert abs(sympify(f1_1) - 1.1) < 1e-5
assert abs(sympify(f1_1b) - 1.1) < 1e-5
assert abs(sympify(f1_1c) - 1.1) < 1e-5
assert _sympify(i5) == 5
assert isinstance(_sympify(i5), Integer)
assert _sympify(i5b) == 5
assert isinstance(_sympify(i5b), Float)
assert _sympify(i5c) == 5
assert isinstance(_sympify(i5c), Integer)
assert abs(_sympify(f1_1) - 1.1) < 1e-5
assert abs(_sympify(f1_1b) - 1.1) < 1e-5
assert abs(_sympify(f1_1c) - 1.1) < 1e-5
def test_evaluate_false():
cases = {
'2 + 3': Add(2, 3, evaluate=False),
'2**2 / 3': Mul(Pow(2, 2, evaluate=False), Pow(3, -1, evaluate=False), evaluate=False),
'2 + 3 * 5': Add(2, Mul(3, 5, evaluate=False), evaluate=False),
'2 - 3 * 5': Add(2, Mul(-1, Mul(3, 5,evaluate=False), evaluate=False), evaluate=False),
'1 / 3': Mul(1, Pow(3, -1, evaluate=False), evaluate=False),
'True | False': Or(True, False, evaluate=False),
'1 + 2 + 3 + 5*3 + integrate(x)': Add(1, 2, 3, Mul(5, 3, evaluate=False), x**2/2, evaluate=False),
'2 * 4 * 6 + 8': Add(Mul(2, 4, 6, evaluate=False), 8, evaluate=False),
'2 - 8 / 4': Add(2, Mul(-1, Mul(8, Pow(4, -1, evaluate=False), evaluate=False), evaluate=False), evaluate=False),
'2 - 2**2': Add(2, Mul(-1, Pow(2, 2, evaluate=False), evaluate=False), evaluate=False),
}
for case, result in cases.items():
assert sympify(case, evaluate=False) == result
def test_issue_4133():
a = sympify('Integer(4)')
assert a == Integer(4)
assert a.is_Integer
def test_issue_3982():
a = [3, 2.0]
assert sympify(a) == [Integer(3), Float(2.0)]
assert sympify(tuple(a)) == Tuple(Integer(3), Float(2.0))
assert sympify(set(a)) == FiniteSet(Integer(3), Float(2.0))
def test_S_sympify():
assert S(1)/2 == sympify(1)/2
assert (-2)**(S(1)/2) == sqrt(2)*I
def test_issue_4788():
assert srepr(S(1.0 + 0J)) == srepr(S(1.0)) == srepr(Float(1.0))
def test_issue_4798_None():
assert S(None) is None
def test_issue_3218():
assert sympify("x+\ny") == x + y
def test_issue_4988_builtins():
C = Symbol('C')
vars = {'C': C}
exp1 = sympify('C')
assert exp1 == C # Make sure it did not get mixed up with sympy.C
exp2 = sympify('C', vars)
assert exp2 == C # Make sure it did not get mixed up with sympy.C
def test_geometry():
p = sympify(Point(0, 1))
assert p == Point(0, 1) and isinstance(p, Point)
L = sympify(Line(p, (1, 0)))
assert L == Line((0, 1), (1, 0)) and isinstance(L, Line)
def test_kernS():
s = '-1 - 2*(-(-x + 1/x)/(x*(x - 1/x)**2) - 1/(x*(x - 1/x)))'
# when 1497 is fixed, this no longer should pass: the expression
# should be unchanged
assert -1 - 2*(-(-x + 1/x)/(x*(x - 1/x)**2) - 1/(x*(x - 1/x))) == -1
# sympification should not allow the constant to enter a Mul
# or else the structure can change dramatically
ss = kernS(s)
assert ss != -1 and ss.simplify() == -1
s = '-1 - 2*(-(-x + 1/x)/(x*(x - 1/x)**2) - 1/(x*(x - 1/x)))'.replace(
'x', '_kern')
ss = kernS(s)
assert ss != -1 and ss.simplify() == -1
# issue 6687
assert kernS('Interval(-1,-2 - 4*(-3))') == Interval(-1, 10)
assert kernS('_kern') == Symbol('_kern')
assert kernS('E**-(x)') == exp(-x)
e = 2*(x + y)*y
assert kernS(['2*(x + y)*y', ('2*(x + y)*y',)]) == [e, (e,)]
assert kernS('-(2*sin(x)**2 + 2*sin(x)*cos(x))*y/2') == \
-y*(2*sin(x)**2 + 2*sin(x)*cos(x))/2
# issue 15132
assert kernS('(1 - x)/(1 - x*(1-y))') == kernS('(1-x)/(1-(1-y)*x)')
assert kernS('(1-2**-(4+1)*(1-y)*x)') == (1 - x*(1 - y)/32)
assert kernS('(1-2**(4+1)*(1-y)*x)') == (1 - 32*x*(1 - y))
assert kernS('(1-2.*(1-y)*x)') == 1 - 2.*x*(1 - y)
one = kernS('x - (x - 1)')
assert one != 1 and one.expand() == 1
def test_issue_6540_6552():
assert S('[[1/3,2], (2/5,)]') == [[Rational(1, 3), 2], (Rational(2, 5),)]
assert S('[[2/6,2], (2/4,)]') == [[Rational(1, 3), 2], (S.Half,)]
assert S('[[[2*(1)]]]') == [[[2]]]
assert S('Matrix([2*(1)])') == Matrix([2])
def test_issue_6046():
assert str(S("Q & C", locals=_clash1)) == 'C & Q'
assert str(S('pi(x)', locals=_clash2)) == 'pi(x)'
assert str(S('pi(C, Q)', locals=_clash)) == 'pi(C, Q)'
locals = {}
exec_("from sympy.abc import Q, C", locals)
assert str(S('C&Q', locals)) == 'C & Q'
def test_issue_8821_highprec_from_str():
s = str(pi.evalf(128))
p = sympify(s)
assert Abs(sin(p)) < 1e-127
def test_issue_10295():
if not numpy:
skip("numpy not installed.")
A = numpy.array([[1, 3, -1],
[0, 1, 7]])
sA = S(A)
assert sA.shape == (2, 3)
for (ri, ci), val in numpy.ndenumerate(A):
assert sA[ri, ci] == val
B = numpy.array([-7, x, 3*y**2])
sB = S(B)
assert sB.shape == (3,)
assert B[0] == sB[0] == -7
assert B[1] == sB[1] == x
assert B[2] == sB[2] == 3*y**2
C = numpy.arange(0, 24)
C.resize(2,3,4)
sC = S(C)
assert sC[0, 0, 0].is_integer
assert sC[0, 0, 0] == 0
a1 = numpy.array([1, 2, 3])
a2 = numpy.array([i for i in range(24)])
a2.resize(2, 4, 3)
assert sympify(a1) == ImmutableDenseNDimArray([1, 2, 3])
assert sympify(a2) == ImmutableDenseNDimArray([i for i in range(24)], (2, 4, 3))
def test_Range():
# Only works in Python 3 where range returns a range type
assert sympify(range(10)) == Range(10)
assert _sympify(range(10)) == Range(10)
def test_sympify_set():
n = Symbol('n')
assert sympify({n}) == FiniteSet(n)
assert sympify(set()) == EmptySet
def test_sympify_numpy():
if not numpy:
skip('numpy not installed. Abort numpy tests.')
np = numpy
def equal(x, y):
return x == y and type(x) == type(y)
assert sympify(np.bool_(1)) is S(True)
try:
assert equal(
sympify(np.int_(1234567891234567891)), S(1234567891234567891))
assert equal(
sympify(np.intp(1234567891234567891)), S(1234567891234567891))
except OverflowError:
# May fail on 32-bit systems: Python int too large to convert to C long
pass
assert equal(sympify(np.intc(1234567891)), S(1234567891))
assert equal(sympify(np.int8(-123)), S(-123))
assert equal(sympify(np.int16(-12345)), S(-12345))
assert equal(sympify(np.int32(-1234567891)), S(-1234567891))
assert equal(
sympify(np.int64(-1234567891234567891)), S(-1234567891234567891))
assert equal(sympify(np.uint8(123)), S(123))
assert equal(sympify(np.uint16(12345)), S(12345))
assert equal(sympify(np.uint32(1234567891)), S(1234567891))
assert equal(
sympify(np.uint64(1234567891234567891)), S(1234567891234567891))
assert equal(sympify(np.float32(1.123456)), Float(1.123456, precision=24))
assert equal(sympify(np.float64(1.1234567891234)),
Float(1.1234567891234, precision=53))
assert equal(sympify(np.longdouble(1.123456789)),
Float(1.123456789, precision=80))
assert equal(sympify(np.complex64(1 + 2j)), S(1.0 + 2.0*I))
assert equal(sympify(np.complex128(1 + 2j)), S(1.0 + 2.0*I))
assert equal(sympify(np.longcomplex(1 + 2j)), S(1.0 + 2.0*I))
#float96 does not exist on all platforms
if hasattr(np, 'float96'):
assert equal(sympify(np.float96(1.123456789)),
Float(1.123456789, precision=80))
#float128 does not exist on all platforms
if hasattr(np, 'float128'):
assert equal(sympify(np.float128(1.123456789123)),
Float(1.123456789123, precision=80))
@XFAIL
def test_sympify_rational_numbers_set():
ans = [Rational(3, 10), Rational(1, 5)]
assert sympify({'.3', '.2'}, rational=True) == FiniteSet(*ans)
def test_issue_13924():
if not numpy:
skip("numpy not installed.")
a = sympify(numpy.array([1]))
assert isinstance(a, ImmutableDenseNDimArray)
assert a[0] == 1
def test_numpy_sympify_args():
# Issue 15098. Make sure sympify args work with numpy types (like numpy.str_)
if not numpy:
skip("numpy not installed.")
a = sympify(numpy.str_('a'))
assert type(a) is Symbol
assert a == Symbol('a')
class CustomSymbol(Symbol):
pass
a = sympify(numpy.str_('a'), {"Symbol": CustomSymbol})
assert isinstance(a, CustomSymbol)
a = sympify(numpy.str_('x^y'))
assert a == x**y
a = sympify(numpy.str_('x^y'), convert_xor=False)
assert a == Xor(x, y)
raises(SympifyError, lambda: sympify(numpy.str_('x'), strict=True))
a = sympify(numpy.str_('1.1'))
assert isinstance(a, Float)
assert a == 1.1
a = sympify(numpy.str_('1.1'), rational=True)
assert isinstance(a, Rational)
assert a == Rational(11, 10)
a = sympify(numpy.str_('x + x'))
assert isinstance(a, Mul)
assert a == 2*x
a = sympify(numpy.str_('x + x'), evaluate=False)
assert isinstance(a, Add)
assert a == Add(x, x, evaluate=False)
def test_issue_5939():
a = Symbol('a')
b = Symbol('b')
assert sympify('''a+\nb''') == a + b
def test_issue_16759():
d = sympify({.5: 1})
assert S.Half not in d
assert Float(.5) in d
assert d[.5] is S.One
d = sympify(OrderedDict({.5: 1}))
assert S.Half not in d
assert Float(.5) in d
assert d[.5] is S.One
d = sympify(defaultdict(int, {.5: 1}))
assert S.Half not in d
assert Float(.5) in d
assert d[.5] is S.One
def test_issue_17811():
a = Function('a')
assert sympify('a(x)*5', evaluate=False) == Mul(a(x), 5, evaluate=False)
def test_issue_14706():
if not numpy:
skip("numpy not installed.")
z1 = numpy.zeros((1, 1), dtype=numpy.float)
z2 = numpy.zeros((2, 2), dtype=numpy.float)
z3 = numpy.zeros((), dtype=numpy.float)
y1 = numpy.ones((1, 1), dtype=numpy.float)
y2 = numpy.ones((2, 2), dtype=numpy.float)
y3 = numpy.ones((), dtype=numpy.float)
assert numpy.all(x + z1 == numpy.full((1, 1), x))
assert numpy.all(x + z2 == numpy.full((2, 2), x))
assert numpy.all(z1 + x == numpy.full((1, 1), x))
assert numpy.all(z2 + x == numpy.full((2, 2), x))
for z in [z3,
numpy.int(0),
numpy.float(0),
numpy.complex(0)]:
assert x + z == x
assert z + x == x
assert isinstance(x + z, Symbol)
assert isinstance(z + x, Symbol)
# If these tests fail, then it means that numpy has finally
# fixed the issue of scalar conversion for rank>0 arrays
# which is mentioned in numpy/numpy#10404. In that case,
# some changes have to be made in sympify.py.
# Note: For future reference, for anyone who takes up this
# issue when numpy has finally fixed their side of the problem,
# the changes for this temporary fix were introduced in PR 18651
assert numpy.all(x + y1 == numpy.full((1, 1), x + 1.0))
assert numpy.all(x + y2 == numpy.full((2, 2), x + 1.0))
assert numpy.all(y1 + x == numpy.full((1, 1), x + 1.0))
assert numpy.all(y2 + x == numpy.full((2, 2), x + 1.0))
for y_ in [y3,
numpy.int(1),
numpy.float(1),
numpy.complex(1)]:
assert x + y_ == y_ + x
assert isinstance(x + y_, Add)
assert isinstance(y_ + x, Add)
assert x + numpy.array(x) == 2 * x
assert x + numpy.array([x]) == numpy.array([2*x], dtype=object)
assert sympify(numpy.array([1])) == ImmutableDenseNDimArray([1], 1)
assert sympify(numpy.array([[[1]]])) == ImmutableDenseNDimArray([1], (1, 1, 1))
assert sympify(z1) == ImmutableDenseNDimArray([0], (1, 1))
assert sympify(z2) == ImmutableDenseNDimArray([0, 0, 0, 0], (2, 2))
assert sympify(z3) == ImmutableDenseNDimArray([0], ())
assert sympify(z3, strict=True) == 0.0
raises(SympifyError, lambda: sympify(numpy.array([1]), strict=True))
raises(SympifyError, lambda: sympify(z1, strict=True))
raises(SympifyError, lambda: sympify(z2, strict=True))
|
c8dc4b9c3410140924d1645a17eaf1eb6dd30998442948da3b45aab8b9ad02b7 | from sympy import (Abs, Add, atan, ceiling, cos, E, Eq, exp, factor,
factorial, fibonacci, floor, Function, GoldenRatio, I, Integral,
integrate, log, Mul, N, oo, pi, Pow, product, Product,
Rational, S, Sum, simplify, sin, sqrt, sstr, sympify, Symbol, Max, nfloat, cosh, acosh, acos)
from sympy.core.numbers import comp
from sympy.core.evalf import (complex_accuracy, PrecisionExhausted,
scaled_zero, get_integer_part, as_mpmath, evalf)
from mpmath import inf, ninf
from mpmath.libmp.libmpf import from_float
from sympy.core.expr import unchanged
from sympy.testing.pytest import raises, XFAIL
from sympy.abc import n, x, y
def NS(e, n=15, **options):
return sstr(sympify(e).evalf(n, **options), full_prec=True)
def test_evalf_helpers():
assert complex_accuracy((from_float(2.0), None, 35, None)) == 35
assert complex_accuracy((from_float(2.0), from_float(10.0), 35, 100)) == 37
assert complex_accuracy(
(from_float(2.0), from_float(1000.0), 35, 100)) == 43
assert complex_accuracy((from_float(2.0), from_float(10.0), 100, 35)) == 35
assert complex_accuracy(
(from_float(2.0), from_float(1000.0), 100, 35)) == 35
def test_evalf_basic():
assert NS('pi', 15) == '3.14159265358979'
assert NS('2/3', 10) == '0.6666666667'
assert NS('355/113-pi', 6) == '2.66764e-7'
assert NS('16*atan(1/5)-4*atan(1/239)', 15) == '3.14159265358979'
def test_cancellation():
assert NS(Add(pi, Rational(1, 10**1000), -pi, evaluate=False), 15,
maxn=1200) == '1.00000000000000e-1000'
def test_evalf_powers():
assert NS('pi**(10**20)', 10) == '1.339148777e+49714987269413385435'
assert NS(pi**(10**100), 10) == ('4.946362032e+4971498726941338543512682882'
'9089887365167832438044244613405349992494711208'
'95526746555473864642912223')
assert NS('2**(1/10**50)', 15) == '1.00000000000000'
assert NS('2**(1/10**50)-1', 15) == '6.93147180559945e-51'
# Evaluation of Rump's ill-conditioned polynomial
def test_evalf_rump():
a = 1335*y**6/4 + x**2*(11*x**2*y**2 - y**6 - 121*y**4 - 2) + 11*y**8/2 + x/(2*y)
assert NS(a, 15, subs={x: 77617, y: 33096}) == '-0.827396059946821'
def test_evalf_complex():
assert NS('2*sqrt(pi)*I', 10) == '3.544907702*I'
assert NS('3+3*I', 15) == '3.00000000000000 + 3.00000000000000*I'
assert NS('E+pi*I', 15) == '2.71828182845905 + 3.14159265358979*I'
assert NS('pi * (3+4*I)', 15) == '9.42477796076938 + 12.5663706143592*I'
assert NS('I*(2+I)', 15) == '-1.00000000000000 + 2.00000000000000*I'
@XFAIL
def test_evalf_complex_bug():
assert NS('(pi+E*I)*(E+pi*I)', 15) in ('0.e-15 + 17.25866050002*I',
'0.e-17 + 17.25866050002*I', '-0.e-17 + 17.25866050002*I')
def test_evalf_complex_powers():
assert NS('(E+pi*I)**100000000000000000') == \
'-3.58896782867793e+61850354284995199 + 4.58581754997159e+61850354284995199*I'
# XXX: rewrite if a+a*I simplification introduced in sympy
#assert NS('(pi + pi*I)**2') in ('0.e-15 + 19.7392088021787*I', '0.e-16 + 19.7392088021787*I')
assert NS('(pi + pi*I)**2', chop=True) == '19.7392088021787*I'
assert NS(
'(pi + 1/10**8 + pi*I)**2') == '6.2831853e-8 + 19.7392088650106*I'
assert NS('(pi + 1/10**12 + pi*I)**2') == '6.283e-12 + 19.7392088021850*I'
assert NS('(pi + pi*I)**4', chop=True) == '-389.636364136010'
assert NS(
'(pi + 1/10**8 + pi*I)**4') == '-389.636366616512 + 2.4805021e-6*I'
assert NS('(pi + 1/10**12 + pi*I)**4') == '-389.636364136258 + 2.481e-10*I'
assert NS(
'(10000*pi + 10000*pi*I)**4', chop=True) == '-3.89636364136010e+18'
@XFAIL
def test_evalf_complex_powers_bug():
assert NS('(pi + pi*I)**4') == '-389.63636413601 + 0.e-14*I'
def test_evalf_exponentiation():
assert NS(sqrt(-pi)) == '1.77245385090552*I'
assert NS(Pow(pi*I, Rational(
1, 2), evaluate=False)) == '1.25331413731550 + 1.25331413731550*I'
assert NS(pi**I) == '0.413292116101594 + 0.910598499212615*I'
assert NS(pi**(E + I/3)) == '20.8438653991931 + 8.36343473930031*I'
assert NS((pi + I/3)**(E + I/3)) == '17.2442906093590 + 13.6839376767037*I'
assert NS(exp(pi)) == '23.1406926327793'
assert NS(exp(pi + E*I)) == '-21.0981542849657 + 9.50576358282422*I'
assert NS(pi**pi) == '36.4621596072079'
assert NS((-pi)**pi) == '-32.9138577418939 - 15.6897116534332*I'
assert NS((-pi)**(-pi)) == '-0.0247567717232697 + 0.0118013091280262*I'
# An example from Smith, "Multiple Precision Complex Arithmetic and Functions"
def test_evalf_complex_cancellation():
A = Rational('63287/100000')
B = Rational('52498/100000')
C = Rational('69301/100000')
D = Rational('83542/100000')
F = Rational('2231321613/2500000000')
# XXX: the number of returned mantissa digits in the real part could
# change with the implementation. What matters is that the returned digits are
# correct; those that are showing now are correct.
# >>> ((A+B*I)*(C+D*I)).expand()
# 64471/10000000000 + 2231321613*I/2500000000
# >>> 2231321613*4
# 8925286452L
assert NS((A + B*I)*(C + D*I), 6) == '6.44710e-6 + 0.892529*I'
assert NS((A + B*I)*(C + D*I), 10) == '6.447100000e-6 + 0.8925286452*I'
assert NS((A + B*I)*(
C + D*I) - F*I, 5) in ('6.4471e-6 + 0.e-14*I', '6.4471e-6 - 0.e-14*I')
def test_evalf_logs():
assert NS("log(3+pi*I)", 15) == '1.46877619736226 + 0.808448792630022*I'
assert NS("log(pi*I)", 15) == '1.14472988584940 + 1.57079632679490*I'
assert NS('log(-1 + 0.00001)', 2) == '-1.0e-5 + 3.1*I'
assert NS('log(100, 10, evaluate=False)', 15) == '2.00000000000000'
assert NS('-2*I*log(-(-1)**(S(1)/9))', 15) == '-5.58505360638185'
def test_evalf_trig():
assert NS('sin(1)', 15) == '0.841470984807897'
assert NS('cos(1)', 15) == '0.540302305868140'
assert NS('sin(10**-6)', 15) == '9.99999999999833e-7'
assert NS('cos(10**-6)', 15) == '0.999999999999500'
assert NS('sin(E*10**100)', 15) == '0.409160531722613'
# Some input near roots
assert NS(sin(exp(pi*sqrt(163))*pi), 15) == '-2.35596641936785e-12'
assert NS(sin(pi*10**100 + Rational(7, 10**5), evaluate=False), 15, maxn=120) == \
'6.99999999428333e-5'
assert NS(sin(Rational(7, 10**5), evaluate=False), 15) == \
'6.99999999428333e-5'
# Check detection of various false identities
def test_evalf_near_integers():
# Binet's formula
f = lambda n: ((1 + sqrt(5))**n)/(2**n * sqrt(5))
assert NS(f(5000) - fibonacci(5000), 10, maxn=1500) == '5.156009964e-1046'
# Some near-integer identities from
# http://mathworld.wolfram.com/AlmostInteger.html
assert NS('sin(2017*2**(1/5))', 15) == '-1.00000000000000'
assert NS('sin(2017*2**(1/5))', 20) == '-0.99999999999999997857'
assert NS('1+sin(2017*2**(1/5))', 15) == '2.14322287389390e-17'
assert NS('45 - 613*E/37 + 35/991', 15) == '6.03764498766326e-11'
def test_evalf_ramanujan():
assert NS(exp(pi*sqrt(163)) - 640320**3 - 744, 10) == '-7.499274028e-13'
# A related identity
A = 262537412640768744*exp(-pi*sqrt(163))
B = 196884*exp(-2*pi*sqrt(163))
C = 103378831900730205293632*exp(-3*pi*sqrt(163))
assert NS(1 - A - B + C, 10) == '1.613679005e-59'
# Input that for various reasons have failed at some point
def test_evalf_bugs():
assert NS(sin(1) + exp(-10**10), 10) == NS(sin(1), 10)
assert NS(exp(10**10) + sin(1), 10) == NS(exp(10**10), 10)
assert NS('expand_log(log(1+1/10**50))', 20) == '1.0000000000000000000e-50'
assert NS('log(10**100,10)', 10) == '100.0000000'
assert NS('log(2)', 10) == '0.6931471806'
assert NS(
'(sin(x)-x)/x**3', 15, subs={x: '1/10**50'}) == '-0.166666666666667'
assert NS(sin(1) + Rational(
1, 10**100)*I, 15) == '0.841470984807897 + 1.00000000000000e-100*I'
assert x.evalf() == x
assert NS((1 + I)**2*I, 6) == '-2.00000'
d = {n: (
-1)**Rational(6, 7), y: (-1)**Rational(4, 7), x: (-1)**Rational(2, 7)}
assert NS((x*(1 + y*(1 + n))).subs(d).evalf(), 6) == '0.346011 + 0.433884*I'
assert NS(((-I - sqrt(2)*I)**2).evalf()) == '-5.82842712474619'
assert NS((1 + I)**2*I, 15) == '-2.00000000000000'
# issue 4758 (1/2):
assert NS(pi.evalf(69) - pi) == '-4.43863937855894e-71'
# issue 4758 (2/2): With the bug present, this still only fails if the
# terms are in the order given here. This is not generally the case,
# because the order depends on the hashes of the terms.
assert NS(20 - 5008329267844*n**25 - 477638700*n**37 - 19*n,
subs={n: .01}) == '19.8100000000000'
assert NS(((x - 1)*(1 - x)**1000).n()
) == '(1.00000000000000 - x)**1000*(x - 1.00000000000000)'
assert NS((-x).n()) == '-x'
assert NS((-2*x).n()) == '-2.00000000000000*x'
assert NS((-2*x*y).n()) == '-2.00000000000000*x*y'
assert cos(x).n(subs={x: 1+I}) == cos(x).subs(x, 1+I).n()
# issue 6660. Also NaN != mpmath.nan
# In this order:
# 0*nan, 0/nan, 0*inf, 0/inf
# 0+nan, 0-nan, 0+inf, 0-inf
# >>> n = Some Number
# n*nan, n/nan, n*inf, n/inf
# n+nan, n-nan, n+inf, n-inf
assert (0*E**(oo)).n() is S.NaN
assert (0/E**(oo)).n() is S.Zero
assert (0+E**(oo)).n() is S.Infinity
assert (0-E**(oo)).n() is S.NegativeInfinity
assert (5*E**(oo)).n() is S.Infinity
assert (5/E**(oo)).n() is S.Zero
assert (5+E**(oo)).n() is S.Infinity
assert (5-E**(oo)).n() is S.NegativeInfinity
#issue 7416
assert as_mpmath(0.0, 10, {'chop': True}) == 0
#issue 5412
assert ((oo*I).n() == S.Infinity*I)
assert ((oo+oo*I).n() == S.Infinity + S.Infinity*I)
#issue 11518
assert NS(2*x**2.5, 5) == '2.0000*x**2.5000'
#issue 13076
assert NS(Mul(Max(0, y), x, evaluate=False).evalf()) == 'x*Max(0, y)'
def test_evalf_integer_parts():
a = floor(log(8)/log(2) - exp(-1000), evaluate=False)
b = floor(log(8)/log(2), evaluate=False)
assert a.evalf() == 3
assert b.evalf() == 3
# equals, as a fallback, can still fail but it might succeed as here
assert ceiling(10*(sin(1)**2 + cos(1)**2)) == 10
assert int(floor(factorial(50)/E, evaluate=False).evalf(70)) == \
int(11188719610782480504630258070757734324011354208865721592720336800)
assert int(ceiling(factorial(50)/E, evaluate=False).evalf(70)) == \
int(11188719610782480504630258070757734324011354208865721592720336801)
assert int(floor(GoldenRatio**999 / sqrt(5) + S.Half)
.evalf(1000)) == fibonacci(999)
assert int(floor(GoldenRatio**1000 / sqrt(5) + S.Half)
.evalf(1000)) == fibonacci(1000)
assert ceiling(x).evalf(subs={x: 3}) == 3
assert ceiling(x).evalf(subs={x: 3*I}) == 3.0*I
assert ceiling(x).evalf(subs={x: 2 + 3*I}) == 2.0 + 3.0*I
assert ceiling(x).evalf(subs={x: 3.}) == 3
assert ceiling(x).evalf(subs={x: 3.*I}) == 3.0*I
assert ceiling(x).evalf(subs={x: 2. + 3*I}) == 2.0 + 3.0*I
assert float((floor(1.5, evaluate=False)+1/9).evalf()) == 1 + 1/9
assert float((floor(0.5, evaluate=False)+20).evalf()) == 20
def test_evalf_trig_zero_detection():
a = sin(160*pi, evaluate=False)
t = a.evalf(maxn=100)
assert abs(t) < 1e-100
assert t._prec < 2
assert a.evalf(chop=True) == 0
raises(PrecisionExhausted, lambda: a.evalf(strict=True))
def test_evalf_sum():
assert Sum(n,(n,1,2)).evalf() == 3.
assert Sum(n,(n,1,2)).doit().evalf() == 3.
# the next test should return instantly
assert Sum(1/n,(n,1,2)).evalf() == 1.5
# issue 8219
assert Sum(E/factorial(n), (n, 0, oo)).evalf() == (E*E).evalf()
# issue 8254
assert Sum(2**n*n/factorial(n), (n, 0, oo)).evalf() == (2*E*E).evalf()
# issue 8411
s = Sum(1/x**2, (x, 100, oo))
assert s.n() == s.doit().n()
def test_evalf_divergent_series():
raises(ValueError, lambda: Sum(1/n, (n, 1, oo)).evalf())
raises(ValueError, lambda: Sum(n/(n**2 + 1), (n, 1, oo)).evalf())
raises(ValueError, lambda: Sum((-1)**n, (n, 1, oo)).evalf())
raises(ValueError, lambda: Sum((-1)**n, (n, 1, oo)).evalf())
raises(ValueError, lambda: Sum(n**2, (n, 1, oo)).evalf())
raises(ValueError, lambda: Sum(2**n, (n, 1, oo)).evalf())
raises(ValueError, lambda: Sum((-2)**n, (n, 1, oo)).evalf())
raises(ValueError, lambda: Sum((2*n + 3)/(3*n**2 + 4), (n, 0, oo)).evalf())
raises(ValueError, lambda: Sum((0.5*n**3)/(n**4 + 1), (n, 0, oo)).evalf())
def test_evalf_product():
assert Product(n, (n, 1, 10)).evalf() == 3628800.
assert comp(Product(1 - S.Half**2/n**2, (n, 1, oo)).n(5), 0.63662)
assert Product(n, (n, -1, 3)).evalf() == 0
def test_evalf_py_methods():
assert abs(float(pi + 1) - 4.1415926535897932) < 1e-10
assert abs(complex(pi + 1) - 4.1415926535897932) < 1e-10
assert abs(
complex(pi + E*I) - (3.1415926535897931 + 2.7182818284590451j)) < 1e-10
raises(TypeError, lambda: float(pi + x))
def test_evalf_power_subs_bugs():
assert (x**2).evalf(subs={x: 0}) == 0
assert sqrt(x).evalf(subs={x: 0}) == 0
assert (x**Rational(2, 3)).evalf(subs={x: 0}) == 0
assert (x**x).evalf(subs={x: 0}) == 1
assert (3**x).evalf(subs={x: 0}) == 1
assert exp(x).evalf(subs={x: 0}) == 1
assert ((2 + I)**x).evalf(subs={x: 0}) == 1
assert (0**x).evalf(subs={x: 0}) == 1
def test_evalf_arguments():
raises(TypeError, lambda: pi.evalf(method="garbage"))
def test_implemented_function_evalf():
from sympy.utilities.lambdify import implemented_function
f = Function('f')
f = implemented_function(f, lambda x: x + 1)
assert str(f(x)) == "f(x)"
assert str(f(2)) == "f(2)"
assert f(2).evalf() == 3
assert f(x).evalf() == f(x)
f = implemented_function(Function('sin'), lambda x: x + 1)
assert f(2).evalf() != sin(2)
del f._imp_ # XXX: due to caching _imp_ would influence all other tests
def test_evaluate_false():
for no in [0, False]:
assert Add(3, 2, evaluate=no).is_Add
assert Mul(3, 2, evaluate=no).is_Mul
assert Pow(3, 2, evaluate=no).is_Pow
assert Pow(y, 2, evaluate=True) - Pow(y, 2, evaluate=True) == 0
def test_evalf_relational():
assert Eq(x/5, y/10).evalf() == Eq(0.2*x, 0.1*y)
# if this first assertion fails it should be replaced with
# one that doesn't
assert unchanged(Eq, (3 - I)**2/2 + I, 0)
assert Eq((3 - I)**2/2 + I, 0).n() is S.false
assert nfloat(Eq((3 - I)**2 + I, 0)) == S.false
def test_issue_5486():
assert not cos(sqrt(0.5 + I)).n().is_Function
def test_issue_5486_bug():
from sympy import I, Expr
assert abs(Expr._from_mpmath(I._to_mpmath(15), 15) - I) < 1.0e-15
def test_bugs():
from sympy import polar_lift, re
assert abs(re((1 + I)**2)) < 1e-15
# anything that evalf's to 0 will do in place of polar_lift
assert abs(polar_lift(0)).n() == 0
def test_subs():
assert NS('besseli(-x, y) - besseli(x, y)', subs={x: 3.5, y: 20.0}) == \
'-4.92535585957223e-10'
assert NS('Piecewise((x, x>0)) + Piecewise((1-x, x>0))', subs={x: 0.1}) == \
'1.00000000000000'
raises(TypeError, lambda: x.evalf(subs=(x, 1)))
def test_issue_4956_5204():
# issue 4956
v = S('''(-27*12**(1/3)*sqrt(31)*I +
27*2**(2/3)*3**(1/3)*sqrt(31)*I)/(-2511*2**(2/3)*3**(1/3) +
(29*18**(1/3) + 9*2**(1/3)*3**(2/3)*sqrt(31)*I +
87*2**(1/3)*3**(1/6)*I)**2)''')
assert NS(v, 1) == '0.e-118 - 0.e-118*I'
# issue 5204
v = S('''-(357587765856 + 18873261792*249**(1/2) + 56619785376*I*83**(1/2) +
108755765856*I*3**(1/2) + 41281887168*6**(1/3)*(1422 +
54*249**(1/2))**(1/3) - 1239810624*6**(1/3)*249**(1/2)*(1422 +
54*249**(1/2))**(1/3) - 3110400000*I*6**(1/3)*83**(1/2)*(1422 +
54*249**(1/2))**(1/3) + 13478400000*I*3**(1/2)*6**(1/3)*(1422 +
54*249**(1/2))**(1/3) + 1274950152*6**(2/3)*(1422 +
54*249**(1/2))**(2/3) + 32347944*6**(2/3)*249**(1/2)*(1422 +
54*249**(1/2))**(2/3) - 1758790152*I*3**(1/2)*6**(2/3)*(1422 +
54*249**(1/2))**(2/3) - 304403832*I*6**(2/3)*83**(1/2)*(1422 +
4*249**(1/2))**(2/3))/(175732658352 + (1106028 + 25596*249**(1/2) +
76788*I*83**(1/2))**2)''')
assert NS(v, 5) == '0.077284 + 1.1104*I'
assert NS(v, 1) == '0.08 + 1.*I'
def test_old_docstring():
a = (E + pi*I)*(E - pi*I)
assert NS(a) == '17.2586605000200'
assert a.n() == 17.25866050002001
def test_issue_4806():
assert integrate(atan(x)**2, (x, -1, 1)).evalf().round(1) == 0.5
assert atan(0, evaluate=False).n() == 0
def test_evalf_mul():
# sympy should not try to expand this; it should be handled term-wise
# in evalf through mpmath
assert NS(product(1 + sqrt(n)*I, (n, 1, 500)), 1) == '5.e+567 + 2.e+568*I'
def test_scaled_zero():
a, b = (([0], 1, 100, 1), -1)
assert scaled_zero(100) == (a, b)
assert scaled_zero(a) == (0, 1, 100, 1)
a, b = (([1], 1, 100, 1), -1)
assert scaled_zero(100, -1) == (a, b)
assert scaled_zero(a) == (1, 1, 100, 1)
raises(ValueError, lambda: scaled_zero(scaled_zero(100)))
raises(ValueError, lambda: scaled_zero(100, 2))
raises(ValueError, lambda: scaled_zero(100, 0))
raises(ValueError, lambda: scaled_zero((1, 5, 1, 3)))
def test_chop_value():
for i in range(-27, 28):
assert (Pow(10, i)*2).n(chop=10**i) and not (Pow(10, i)).n(chop=10**i)
def test_infinities():
assert oo.evalf(chop=True) == inf
assert (-oo).evalf(chop=True) == ninf
def test_to_mpmath():
assert sqrt(3)._to_mpmath(20)._mpf_ == (0, int(908093), -19, 20)
assert S(3.2)._to_mpmath(20)._mpf_ == (0, int(838861), -18, 20)
def test_issue_6632_evalf():
add = (-100000*sqrt(2500000001) + 5000000001)
assert add.n() == 9.999999998e-11
assert (add*add).n() == 9.999999996e-21
def test_issue_4945():
from sympy.abc import H
from sympy import zoo
assert (H/0).evalf(subs={H:1}) == zoo*H
def test_evalf_integral():
# test that workprec has to increase in order to get a result other than 0
eps = Rational(1, 1000000)
assert Integral(sin(x), (x, -pi, pi + eps)).n(2)._prec == 10
def test_issue_8821_highprec_from_str():
s = str(pi.evalf(128))
p = N(s)
assert Abs(sin(p)) < 1e-15
p = N(s, 64)
assert Abs(sin(p)) < 1e-64
def test_issue_8853():
p = Symbol('x', even=True, positive=True)
assert floor(-p - S.Half).is_even == False
assert floor(-p + S.Half).is_even == True
assert ceiling(p - S.Half).is_even == True
assert ceiling(p + S.Half).is_even == False
assert get_integer_part(S.Half, -1, {}, True) == (0, 0)
assert get_integer_part(S.Half, 1, {}, True) == (1, 0)
assert get_integer_part(Rational(-1, 2), -1, {}, True) == (-1, 0)
assert get_integer_part(Rational(-1, 2), 1, {}, True) == (0, 0)
def test_issue_17681():
class identity_func(Function):
def _eval_evalf(self, *args, **kwargs):
return self.args[0].evalf(*args, **kwargs)
assert floor(identity_func(S(0))) == 0
assert get_integer_part(S(0), 1, {}, True) == (0, 0)
def test_issue_9326():
from sympy import Dummy
d1 = Dummy('d')
d2 = Dummy('d')
e = d1 + d2
assert e.evalf(subs = {d1: 1, d2: 2}) == 3
def test_issue_10323():
assert ceiling(sqrt(2**30 + 1)) == 2**15 + 1
def test_AssocOp_Function():
# the first arg of Min is not comparable in the imaginary part
raises(ValueError, lambda: S('''
Min(-sqrt(3)*cos(pi/18)/6 + re(1/((-1/2 - sqrt(3)*I/2)*(1/6 +
sqrt(3)*I/18)**(1/3)))/3 + sin(pi/18)/2 + 2 + I*(-cos(pi/18)/2 -
sqrt(3)*sin(pi/18)/6 + im(1/((-1/2 - sqrt(3)*I/2)*(1/6 +
sqrt(3)*I/18)**(1/3)))/3), re(1/((-1/2 + sqrt(3)*I/2)*(1/6 +
sqrt(3)*I/18)**(1/3)))/3 - sqrt(3)*cos(pi/18)/6 - sin(pi/18)/2 + 2 +
I*(im(1/((-1/2 + sqrt(3)*I/2)*(1/6 + sqrt(3)*I/18)**(1/3)))/3 -
sqrt(3)*sin(pi/18)/6 + cos(pi/18)/2))'''))
# if that is changed so a non-comparable number remains as
# an arg, then the Min/Max instantiation needs to be changed
# to watch out for non-comparable args when making simplifications
# and the following test should be added instead (with e being
# the sympified expression above):
# raises(ValueError, lambda: e._eval_evalf(2))
def test_issue_10395():
eq = x*Max(0, y)
assert nfloat(eq) == eq
eq = x*Max(y, -1.1)
assert nfloat(eq) == eq
assert Max(y, 4).n() == Max(4.0, y)
def test_issue_13098():
assert floor(log(S('9.'+'9'*20), 10)) == 0
assert ceiling(log(S('9.'+'9'*20), 10)) == 1
assert floor(log(20 - S('9.'+'9'*20), 10)) == 1
assert ceiling(log(20 - S('9.'+'9'*20), 10)) == 2
def test_issue_14601():
e = 5*x*y/2 - y*(35*(x**3)/2 - 15*x/2)
subst = {x:0.0, y:0.0}
e2 = e.evalf(subs=subst)
assert float(e2) == 0.0
assert float((x + x*(x**2 + x)).evalf(subs={x: 0.0})) == 0.0
def test_issue_11151():
z = S.Zero
e = Sum(z, (x, 1, 2))
assert e != z # it shouldn't evaluate
# when it does evaluate, this is what it should give
assert evalf(e, 15, {}) == \
evalf(z, 15, {}) == (None, None, 15, None)
# so this shouldn't fail
assert (e/2).n() == 0
# this was where the issue appeared
expr0 = Sum(x**2 + x, (x, 1, 2))
expr1 = Sum(0, (x, 1, 2))
expr2 = expr1/expr0
assert simplify(factor(expr2) - expr2) == 0
def test_issue_13425():
assert N('2**.5', 30) == N('sqrt(2)', 30)
assert N('x - x', 30) == 0
assert abs((N('pi*.1', 22)*10 - pi).n()) < 1e-22
def test_issue_17421():
assert N(acos(-I + acosh(cosh(cosh(1) + I)))) == 1.0*I
|
12d06b4a869a5f327f602f60c350ee7702514effa211854371a44af87d5cfc0c | from sympy import (abc, Add, cos, collect, Derivative, diff, exp, Float, Function,
I, Integer, log, Mul, oo, Poly, Rational, S, sin, sqrt, Symbol, symbols,
Wild, pi, meijerg
)
from sympy.testing.pytest import XFAIL
def test_symbol():
x = Symbol('x')
a, b, c, p, q = map(Wild, 'abcpq')
e = x
assert e.match(x) == {}
assert e.matches(x) == {}
assert e.match(a) == {a: x}
e = Rational(5)
assert e.match(c) == {c: 5}
assert e.match(e) == {}
assert e.match(e + 1) is None
def test_add():
x, y, a, b, c = map(Symbol, 'xyabc')
p, q, r = map(Wild, 'pqr')
e = a + b
assert e.match(p + b) == {p: a}
assert e.match(p + a) == {p: b}
e = 1 + b
assert e.match(p + b) == {p: 1}
e = a + b + c
assert e.match(a + p + c) == {p: b}
assert e.match(b + p + c) == {p: a}
e = a + b + c + x
assert e.match(a + p + x + c) == {p: b}
assert e.match(b + p + c + x) == {p: a}
assert e.match(b) is None
assert e.match(b + p) == {p: a + c + x}
assert e.match(a + p + c) == {p: b + x}
assert e.match(b + p + c) == {p: a + x}
e = 4*x + 5
assert e.match(4*x + p) == {p: 5}
assert e.match(3*x + p) == {p: x + 5}
assert e.match(p*x + 5) == {p: 4}
def test_power():
x, y, a, b, c = map(Symbol, 'xyabc')
p, q, r = map(Wild, 'pqr')
e = (x + y)**a
assert e.match(p**q) == {p: x + y, q: a}
assert e.match(p**p) is None
e = (x + y)**(x + y)
assert e.match(p**p) == {p: x + y}
assert e.match(p**q) == {p: x + y, q: x + y}
e = (2*x)**2
assert e.match(p*q**r) == {p: 4, q: x, r: 2}
e = Integer(1)
assert e.match(x**p) == {p: 0}
def test_match_exclude():
x = Symbol('x')
y = Symbol('y')
p = Wild("p")
q = Wild("q")
r = Wild("r")
e = Rational(6)
assert e.match(2*p) == {p: 3}
e = 3/(4*x + 5)
assert e.match(3/(p*x + q)) == {p: 4, q: 5}
e = 3/(4*x + 5)
assert e.match(p/(q*x + r)) == {p: 3, q: 4, r: 5}
e = 2/(x + 1)
assert e.match(p/(q*x + r)) == {p: 2, q: 1, r: 1}
e = 1/(x + 1)
assert e.match(p/(q*x + r)) == {p: 1, q: 1, r: 1}
e = 4*x + 5
assert e.match(p*x + q) == {p: 4, q: 5}
e = 4*x + 5*y + 6
assert e.match(p*x + q*y + r) == {p: 4, q: 5, r: 6}
a = Wild('a', exclude=[x])
e = 3*x
assert e.match(p*x) == {p: 3}
assert e.match(a*x) == {a: 3}
e = 3*x**2
assert e.match(p*x) == {p: 3*x}
assert e.match(a*x) is None
e = 3*x + 3 + 6/x
assert e.match(p*x**2 + p*x + 2*p) == {p: 3/x}
assert e.match(a*x**2 + a*x + 2*a) is None
def test_mul():
x, y, a, b, c = map(Symbol, 'xyabc')
p, q = map(Wild, 'pq')
e = 4*x
assert e.match(p*x) == {p: 4}
assert e.match(p*y) is None
assert e.match(e + p*y) == {p: 0}
e = a*x*b*c
assert e.match(p*x) == {p: a*b*c}
assert e.match(c*p*x) == {p: a*b}
e = (a + b)*(a + c)
assert e.match((p + b)*(p + c)) == {p: a}
e = x
assert e.match(p*x) == {p: 1}
e = exp(x)
assert e.match(x**p*exp(x*q)) == {p: 0, q: 1}
e = I*Poly(x, x)
assert e.match(I*p) == {p: x}
def test_mul_noncommutative():
x, y = symbols('x y')
A, B, C = symbols('A B C', commutative=False)
u, v = symbols('u v', cls=Wild)
w, z = symbols('w z', cls=Wild, commutative=False)
assert (u*v).matches(x) in ({v: x, u: 1}, {u: x, v: 1})
assert (u*v).matches(x*y) in ({v: y, u: x}, {u: y, v: x})
assert (u*v).matches(A) is None
assert (u*v).matches(A*B) is None
assert (u*v).matches(x*A) is None
assert (u*v).matches(x*y*A) is None
assert (u*v).matches(x*A*B) is None
assert (u*v).matches(x*y*A*B) is None
assert (v*w).matches(x) is None
assert (v*w).matches(x*y) is None
assert (v*w).matches(A) == {w: A, v: 1}
assert (v*w).matches(A*B) == {w: A*B, v: 1}
assert (v*w).matches(x*A) == {w: A, v: x}
assert (v*w).matches(x*y*A) == {w: A, v: x*y}
assert (v*w).matches(x*A*B) == {w: A*B, v: x}
assert (v*w).matches(x*y*A*B) == {w: A*B, v: x*y}
assert (v*w).matches(-x) is None
assert (v*w).matches(-x*y) is None
assert (v*w).matches(-A) == {w: A, v: -1}
assert (v*w).matches(-A*B) == {w: A*B, v: -1}
assert (v*w).matches(-x*A) == {w: A, v: -x}
assert (v*w).matches(-x*y*A) == {w: A, v: -x*y}
assert (v*w).matches(-x*A*B) == {w: A*B, v: -x}
assert (v*w).matches(-x*y*A*B) == {w: A*B, v: -x*y}
assert (w*z).matches(x) is None
assert (w*z).matches(x*y) is None
assert (w*z).matches(A) is None
assert (w*z).matches(A*B) == {w: A, z: B}
assert (w*z).matches(B*A) == {w: B, z: A}
assert (w*z).matches(A*B*C) in [{w: A, z: B*C}, {w: A*B, z: C}]
assert (w*z).matches(x*A) is None
assert (w*z).matches(x*y*A) is None
assert (w*z).matches(x*A*B) is None
assert (w*z).matches(x*y*A*B) is None
assert (w*A).matches(A) is None
assert (A*w*B).matches(A*B) is None
assert (u*w*z).matches(x) is None
assert (u*w*z).matches(x*y) is None
assert (u*w*z).matches(A) is None
assert (u*w*z).matches(A*B) == {u: 1, w: A, z: B}
assert (u*w*z).matches(B*A) == {u: 1, w: B, z: A}
assert (u*w*z).matches(x*A) is None
assert (u*w*z).matches(x*y*A) is None
assert (u*w*z).matches(x*A*B) == {u: x, w: A, z: B}
assert (u*w*z).matches(x*B*A) == {u: x, w: B, z: A}
assert (u*w*z).matches(x*y*A*B) == {u: x*y, w: A, z: B}
assert (u*w*z).matches(x*y*B*A) == {u: x*y, w: B, z: A}
assert (u*A).matches(x*A) == {u: x}
assert (u*A).matches(x*A*B) is None
assert (u*B).matches(x*A) is None
assert (u*A*B).matches(x*A*B) == {u: x}
assert (u*A*B).matches(x*B*A) is None
assert (u*A*B).matches(x*A) is None
assert (u*w*A).matches(x*A*B) is None
assert (u*w*B).matches(x*A*B) == {u: x, w: A}
assert (u*v*A*B).matches(x*A*B) in [{u: x, v: 1}, {v: x, u: 1}]
assert (u*v*A*B).matches(x*B*A) is None
assert (u*v*A*B).matches(u*v*A*C) is None
def test_mul_noncommutative_mismatch():
A, B, C = symbols('A B C', commutative=False)
w = symbols('w', cls=Wild, commutative=False)
assert (w*B*w).matches(A*B*A) == {w: A}
assert (w*B*w).matches(A*C*B*A*C) == {w: A*C}
assert (w*B*w).matches(A*C*B*A*B) is None
assert (w*B*w).matches(A*B*C) is None
assert (w*w*C).matches(A*B*C) is None
def test_mul_noncommutative_pow():
A, B, C = symbols('A B C', commutative=False)
w = symbols('w', cls=Wild, commutative=False)
assert (A*B*w).matches(A*B**2) == {w: B}
assert (A*(B**2)*w*(B**3)).matches(A*B**8) == {w: B**3}
assert (A*B*w*C).matches(A*(B**4)*C) == {w: B**3}
assert (A*B*(w**(-1))).matches(A*B*(C**(-1))) == {w: C}
assert (A*(B*w)**(-1)*C).matches(A*(B*C)**(-1)*C) == {w: C}
assert ((w**2)*B*C).matches((A**2)*B*C) == {w: A}
assert ((w**2)*B*(w**3)).matches((A**2)*B*(A**3)) == {w: A}
assert ((w**2)*B*(w**4)).matches((A**2)*B*(A**2)) is None
def test_complex():
a, b, c = map(Symbol, 'abc')
x, y = map(Wild, 'xy')
assert (1 + I).match(x + I) == {x: 1}
assert (a + I).match(x + I) == {x: a}
assert (2*I).match(x*I) == {x: 2}
assert (a*I).match(x*I) == {x: a}
assert (a*I).match(x*y) == {x: I, y: a}
assert (2*I).match(x*y) == {x: 2, y: I}
assert (a + b*I).match(x + y*I) == {x: a, y: b}
def test_functions():
from sympy.core.function import WildFunction
x = Symbol('x')
g = WildFunction('g')
p = Wild('p')
q = Wild('q')
f = cos(5*x)
notf = x
assert f.match(p*cos(q*x)) == {p: 1, q: 5}
assert f.match(p*g) == {p: 1, g: cos(5*x)}
assert notf.match(g) is None
@XFAIL
def test_functions_X1():
from sympy.core.function import WildFunction
x = Symbol('x')
g = WildFunction('g')
p = Wild('p')
q = Wild('q')
f = cos(5*x)
assert f.match(p*g(q*x)) == {p: 1, g: cos, q: 5}
def test_interface():
x, y = map(Symbol, 'xy')
p, q = map(Wild, 'pq')
assert (x + 1).match(p + 1) == {p: x}
assert (x*3).match(p*3) == {p: x}
assert (x**3).match(p**3) == {p: x}
assert (x*cos(y)).match(p*cos(q)) == {p: x, q: y}
assert (x*y).match(p*q) in [{p:x, q:y}, {p:y, q:x}]
assert (x + y).match(p + q) in [{p:x, q:y}, {p:y, q:x}]
assert (x*y + 1).match(p*q) in [{p:1, q:1 + x*y}, {p:1 + x*y, q:1}]
def test_derivative1():
x, y = map(Symbol, 'xy')
p, q = map(Wild, 'pq')
f = Function('f', nargs=1)
fd = Derivative(f(x), x)
assert fd.match(p) == {p: fd}
assert (fd + 1).match(p + 1) == {p: fd}
assert (fd).match(fd) == {}
assert (3*fd).match(p*fd) is not None
assert (3*fd - 1).match(p*fd + q) == {p: 3, q: -1}
def test_derivative_bug1():
f = Function("f")
x = Symbol("x")
a = Wild("a", exclude=[f, x])
b = Wild("b", exclude=[f])
pattern = a * Derivative(f(x), x, x) + b
expr = Derivative(f(x), x) + x**2
d1 = {b: x**2}
d2 = pattern.xreplace(d1).matches(expr, d1)
assert d2 is None
def test_derivative2():
f = Function("f")
x = Symbol("x")
a = Wild("a", exclude=[f, x])
b = Wild("b", exclude=[f])
e = Derivative(f(x), x)
assert e.match(Derivative(f(x), x)) == {}
assert e.match(Derivative(f(x), x, x)) is None
e = Derivative(f(x), x, x)
assert e.match(Derivative(f(x), x)) is None
assert e.match(Derivative(f(x), x, x)) == {}
e = Derivative(f(x), x) + x**2
assert e.match(a*Derivative(f(x), x) + b) == {a: 1, b: x**2}
assert e.match(a*Derivative(f(x), x, x) + b) is None
e = Derivative(f(x), x, x) + x**2
assert e.match(a*Derivative(f(x), x) + b) is None
assert e.match(a*Derivative(f(x), x, x) + b) == {a: 1, b: x**2}
def test_match_deriv_bug1():
n = Function('n')
l = Function('l')
x = Symbol('x')
p = Wild('p')
e = diff(l(x), x)/x - diff(diff(n(x), x), x)/2 - \
diff(n(x), x)**2/4 + diff(n(x), x)*diff(l(x), x)/4
e = e.subs(n(x), -l(x)).doit()
t = x*exp(-l(x))
t2 = t.diff(x, x)/t
assert e.match( (p*t2).expand() ) == {p: Rational(-1, 2)}
def test_match_bug2():
x, y = map(Symbol, 'xy')
p, q, r = map(Wild, 'pqr')
res = (x + y).match(p + q + r)
assert (p + q + r).subs(res) == x + y
def test_match_bug3():
x, a, b = map(Symbol, 'xab')
p = Wild('p')
assert (b*x*exp(a*x)).match(x*exp(p*x)) is None
def test_match_bug4():
x = Symbol('x')
p = Wild('p')
e = x
assert e.match(-p*x) == {p: -1}
def test_match_bug5():
x = Symbol('x')
p = Wild('p')
e = -x
assert e.match(-p*x) == {p: 1}
def test_match_bug6():
x = Symbol('x')
p = Wild('p')
e = x
assert e.match(3*p*x) == {p: Rational(1)/3}
def test_match_polynomial():
x = Symbol('x')
a = Wild('a', exclude=[x])
b = Wild('b', exclude=[x])
c = Wild('c', exclude=[x])
d = Wild('d', exclude=[x])
eq = 4*x**3 + 3*x**2 + 2*x + 1
pattern = a*x**3 + b*x**2 + c*x + d
assert eq.match(pattern) == {a: 4, b: 3, c: 2, d: 1}
assert (eq - 3*x**2).match(pattern) == {a: 4, b: 0, c: 2, d: 1}
assert (x + sqrt(2) + 3).match(a + b*x + c*x**2) == \
{b: 1, a: sqrt(2) + 3, c: 0}
def test_exclude():
x, y, a = map(Symbol, 'xya')
p = Wild('p', exclude=[1, x])
q = Wild('q')
r = Wild('r', exclude=[sin, y])
assert sin(x).match(r) is None
assert cos(y).match(r) is None
e = 3*x**2 + y*x + a
assert e.match(p*x**2 + q*x + r) == {p: 3, q: y, r: a}
e = x + 1
assert e.match(x + p) is None
assert e.match(p + 1) is None
assert e.match(x + 1 + p) == {p: 0}
e = cos(x) + 5*sin(y)
assert e.match(r) is None
assert e.match(cos(y) + r) is None
assert e.match(r + p*sin(q)) == {r: cos(x), p: 5, q: y}
def test_floats():
a, b = map(Wild, 'ab')
e = cos(0.12345, evaluate=False)**2
r = e.match(a*cos(b)**2)
assert r == {a: 1, b: Float(0.12345)}
def test_Derivative_bug1():
f = Function("f")
x = abc.x
a = Wild("a", exclude=[f(x)])
b = Wild("b", exclude=[f(x)])
eq = f(x).diff(x)
assert eq.match(a*Derivative(f(x), x) + b) == {a: 1, b: 0}
def test_match_wild_wild():
p = Wild('p')
q = Wild('q')
r = Wild('r')
assert p.match(q + r) in [ {q: p, r: 0}, {q: 0, r: p} ]
assert p.match(q*r) in [ {q: p, r: 1}, {q: 1, r: p} ]
p = Wild('p')
q = Wild('q', exclude=[p])
r = Wild('r')
assert p.match(q + r) == {q: 0, r: p}
assert p.match(q*r) == {q: 1, r: p}
p = Wild('p')
q = Wild('q', exclude=[p])
r = Wild('r', exclude=[p])
assert p.match(q + r) is None
assert p.match(q*r) is None
def test__combine_inverse():
x, y = symbols("x y")
assert Mul._combine_inverse(x*I*y, x*I) == y
assert Mul._combine_inverse(x*x**(1 + y), x**(1 + y)) == x
assert Mul._combine_inverse(x*I*y, y*I) == x
assert Mul._combine_inverse(oo*I*y, y*I) is oo
assert Mul._combine_inverse(oo*I*y, oo*I) == y
assert Mul._combine_inverse(oo*I*y, oo*I) == y
assert Mul._combine_inverse(oo*y, -oo) == -y
assert Mul._combine_inverse(-oo*y, oo) == -y
assert Add._combine_inverse(oo, oo) is S.Zero
assert Add._combine_inverse(oo*I, oo*I) is S.Zero
assert Add._combine_inverse(x*oo, x*oo) is S.Zero
assert Add._combine_inverse(-x*oo, -x*oo) is S.Zero
assert Add._combine_inverse((x - oo)*(x + oo), -oo)
def test_issue_3773():
x = symbols('x')
z, phi, r = symbols('z phi r')
c, A, B, N = symbols('c A B N', cls=Wild)
l = Wild('l', exclude=(0,))
eq = z * sin(2*phi) * r**7
matcher = c * sin(phi*N)**l * r**A * log(r)**B
assert eq.match(matcher) == {c: z, l: 1, N: 2, A: 7, B: 0}
assert (-eq).match(matcher) == {c: -z, l: 1, N: 2, A: 7, B: 0}
assert (x*eq).match(matcher) == {c: x*z, l: 1, N: 2, A: 7, B: 0}
assert (-7*x*eq).match(matcher) == {c: -7*x*z, l: 1, N: 2, A: 7, B: 0}
matcher = c*sin(phi*N)**l * r**A
assert eq.match(matcher) == {c: z, l: 1, N: 2, A: 7}
assert (-eq).match(matcher) == {c: -z, l: 1, N: 2, A: 7}
assert (x*eq).match(matcher) == {c: x*z, l: 1, N: 2, A: 7}
assert (-7*x*eq).match(matcher) == {c: -7*x*z, l: 1, N: 2, A: 7}
def test_issue_3883():
from sympy.abc import gamma, mu, x
f = (-gamma * (x - mu)**2 - log(gamma) + log(2*pi))/2
a, b, c = symbols('a b c', cls=Wild, exclude=(gamma,))
assert f.match(a * log(gamma) + b * gamma + c) == \
{a: Rational(-1, 2), b: -(x - mu)**2/2, c: log(2*pi)/2}
assert f.expand().collect(gamma).match(a * log(gamma) + b * gamma + c) == \
{a: Rational(-1, 2), b: (-(x - mu)**2/2).expand(), c: (log(2*pi)/2).expand()}
g1 = Wild('g1', exclude=[gamma])
g2 = Wild('g2', exclude=[gamma])
g3 = Wild('g3', exclude=[gamma])
assert f.expand().match(g1 * log(gamma) + g2 * gamma + g3) == \
{g3: log(2)/2 + log(pi)/2, g1: Rational(-1, 2), g2: -mu**2/2 + mu*x - x**2/2}
def test_issue_4418():
x = Symbol('x')
a, b, c = symbols('a b c', cls=Wild, exclude=(x,))
f, g = symbols('f g', cls=Function)
eq = diff(g(x)*f(x).diff(x), x)
assert eq.match(
g(x).diff(x)*f(x).diff(x) + g(x)*f(x).diff(x, x) + c) == {c: 0}
assert eq.match(a*g(x).diff(
x)*f(x).diff(x) + b*g(x)*f(x).diff(x, x) + c) == {a: 1, b: 1, c: 0}
def test_issue_4700():
f = Function('f')
x = Symbol('x')
a, b = symbols('a b', cls=Wild, exclude=(f(x),))
p = a*f(x) + b
eq1 = sin(x)
eq2 = f(x) + sin(x)
eq3 = f(x) + x + sin(x)
eq4 = x + sin(x)
assert eq1.match(p) == {a: 0, b: sin(x)}
assert eq2.match(p) == {a: 1, b: sin(x)}
assert eq3.match(p) == {a: 1, b: x + sin(x)}
assert eq4.match(p) == {a: 0, b: x + sin(x)}
def test_issue_5168():
a, b, c = symbols('a b c', cls=Wild)
x = Symbol('x')
f = Function('f')
assert x.match(a) == {a: x}
assert x.match(a*f(x)**c) == {a: x, c: 0}
assert x.match(a*b) == {a: 1, b: x}
assert x.match(a*b*f(x)**c) == {a: 1, b: x, c: 0}
assert (-x).match(a) == {a: -x}
assert (-x).match(a*f(x)**c) == {a: -x, c: 0}
assert (-x).match(a*b) == {a: -1, b: x}
assert (-x).match(a*b*f(x)**c) == {a: -1, b: x, c: 0}
assert (2*x).match(a) == {a: 2*x}
assert (2*x).match(a*f(x)**c) == {a: 2*x, c: 0}
assert (2*x).match(a*b) == {a: 2, b: x}
assert (2*x).match(a*b*f(x)**c) == {a: 2, b: x, c: 0}
assert (-2*x).match(a) == {a: -2*x}
assert (-2*x).match(a*f(x)**c) == {a: -2*x, c: 0}
assert (-2*x).match(a*b) == {a: -2, b: x}
assert (-2*x).match(a*b*f(x)**c) == {a: -2, b: x, c: 0}
def test_issue_4559():
x = Symbol('x')
e = Symbol('e')
w = Wild('w', exclude=[x])
y = Wild('y')
# this is as it should be
assert (3/x).match(w/y) == {w: 3, y: x}
assert (3*x).match(w*y) == {w: 3, y: x}
assert (x/3).match(y/w) == {w: 3, y: x}
assert (3*x).match(y/w) == {w: S.One/3, y: x}
assert (3*x).match(y/w) == {w: Rational(1, 3), y: x}
# these could be allowed to fail
assert (x/3).match(w/y) == {w: S.One/3, y: 1/x}
assert (3*x).match(w/y) == {w: 3, y: 1/x}
assert (3/x).match(w*y) == {w: 3, y: 1/x}
# Note that solve will give
# multiple roots but match only gives one:
#
# >>> solve(x**r-y**2,y)
# [-x**(r/2), x**(r/2)]
r = Symbol('r', rational=True)
assert (x**r).match(y**2) == {y: x**(r/2)}
assert (x**e).match(y**2) == {y: sqrt(x**e)}
# since (x**i = y) -> x = y**(1/i) where i is an integer
# the following should also be valid as long as y is not
# zero when i is negative.
a = Wild('a')
e = S.Zero
assert e.match(a) == {a: e}
assert e.match(1/a) is None
assert e.match(a**.3) is None
e = S(3)
assert e.match(1/a) == {a: 1/e}
assert e.match(1/a**2) == {a: 1/sqrt(e)}
e = pi
assert e.match(1/a) == {a: 1/e}
assert e.match(1/a**2) == {a: 1/sqrt(e)}
assert (-e).match(sqrt(a)) is None
assert (-e).match(a**2) == {a: I*sqrt(pi)}
# The pattern matcher doesn't know how to handle (x - a)**2 == (a - x)**2. To
# avoid ambiguity in actual applications, don't put a coefficient (including a
# minus sign) in front of a wild.
@XFAIL
def test_issue_4883():
a = Wild('a')
x = Symbol('x')
e = [i**2 for i in (x - 2, 2 - x)]
p = [i**2 for i in (x - a, a- x)]
for eq in e:
for pat in p:
assert eq.match(pat) == {a: 2}
def test_issue_4319():
x, y = symbols('x y')
p = -x*(S.One/8 - y)
ans = {S.Zero, y - S.One/8}
def ok(pat):
assert set(p.match(pat).values()) == ans
ok(Wild("coeff", exclude=[x])*x + Wild("rest"))
ok(Wild("w", exclude=[x])*x + Wild("rest"))
ok(Wild("coeff", exclude=[x])*x + Wild("rest"))
ok(Wild("w", exclude=[x])*x + Wild("rest"))
ok(Wild("e", exclude=[x])*x + Wild("rest"))
ok(Wild("ress", exclude=[x])*x + Wild("rest"))
ok(Wild("resu", exclude=[x])*x + Wild("rest"))
def test_issue_3778():
p, c, q = symbols('p c q', cls=Wild)
x = Symbol('x')
assert (sin(x)**2).match(sin(p)*sin(q)*c) == {q: x, c: 1, p: x}
assert (2*sin(x)).match(sin(p) + sin(q) + c) == {q: x, c: 0, p: x}
def test_issue_6103():
x = Symbol('x')
a = Wild('a')
assert (-I*x*oo).match(I*a*oo) == {a: -x}
def test_issue_3539():
a = Wild('a')
x = Symbol('x')
assert (x - 2).match(a - x) is None
assert (6/x).match(a*x) is None
assert (6/x**2).match(a/x) == {a: 6/x}
def test_gh_issue_2711():
x = Symbol('x')
f = meijerg(((), ()), ((0,), ()), x)
a = Wild('a')
b = Wild('b')
assert f.find(a) == {(S.Zero,), ((), ()), ((S.Zero,), ()), x, S.Zero,
(), meijerg(((), ()), ((S.Zero,), ()), x)}
assert f.find(a + b) == \
{meijerg(((), ()), ((S.Zero,), ()), x), x, S.Zero}
assert f.find(a**2) == {meijerg(((), ()), ((S.Zero,), ()), x), x}
def test_match_issue_17397():
f = Function("f")
x = Symbol("x")
a3 = Wild('a3', exclude=[f(x), f(x).diff(x), f(x).diff(x, 2)])
b3 = Wild('b3', exclude=[f(x), f(x).diff(x), f(x).diff(x, 2)])
c3 = Wild('c3', exclude=[f(x), f(x).diff(x), f(x).diff(x, 2)])
deq = a3*(f(x).diff(x, 2)) + b3*f(x).diff(x) + c3*f(x)
eq = (x-2)**2*(f(x).diff(x, 2)) + (x-2)*(f(x).diff(x)) + ((x-2)**2 - 4)*f(x)
r = collect(eq, [f(x).diff(x, 2), f(x).diff(x), f(x)]).match(deq)
assert r == {a3: (x - 2)**2, c3: (x - 2)**2 - 4, b3: x - 2}
eq =x*f(x) + x*Derivative(f(x), (x, 2)) - 4*f(x) + Derivative(f(x), x) \
- 4*Derivative(f(x), (x, 2)) - 2*Derivative(f(x), x)/x + 4*Derivative(f(x), (x, 2))/x
r = collect(eq, [f(x).diff(x, 2), f(x).diff(x), f(x)]).match(deq)
assert r == {a3: x - 4 + 4/x, b3: 1 - 2/x, c3: x - 4}
|
53da9446d25acca566f1c93935e0b5f7c3f0bc795db03f27787456ec8a539e79 | from sympy import (Basic, Symbol, sin, cos, atan, exp, sqrt, Rational,
Float, re, pi, sympify, Add, Mul, Pow, Mod, I, log, S, Max, symbols,
oo, zoo, Integer, sign, im, nan, Dummy, factorial, comp, floor
)
from sympy.core.parameters import distribute
from sympy.core.expr import unchanged
from sympy.utilities.iterables import cartes
from sympy.testing.pytest import XFAIL, raises
from sympy.testing.randtest import verify_numerically
a, c, x, y, z = symbols('a,c,x,y,z')
b = Symbol("b", positive=True)
def same_and_same_prec(a, b):
# stricter matching for Floats
return a == b and a._prec == b._prec
def test_bug1():
assert re(x) != x
x.series(x, 0, 1)
assert re(x) != x
def test_Symbol():
e = a*b
assert e == a*b
assert a*b*b == a*b**2
assert a*b*b + c == c + a*b**2
assert a*b*b - c == -c + a*b**2
x = Symbol('x', complex=True, real=False)
assert x.is_imaginary is None # could be I or 1 + I
x = Symbol('x', complex=True, imaginary=False)
assert x.is_real is None # could be 1 or 1 + I
x = Symbol('x', real=True)
assert x.is_complex
x = Symbol('x', imaginary=True)
assert x.is_complex
x = Symbol('x', real=False, imaginary=False)
assert x.is_complex is None # might be a non-number
def test_arit0():
p = Rational(5)
e = a*b
assert e == a*b
e = a*b + b*a
assert e == 2*a*b
e = a*b + b*a + a*b + p*b*a
assert e == 8*a*b
e = a*b + b*a + a*b + p*b*a + a
assert e == a + 8*a*b
e = a + a
assert e == 2*a
e = a + b + a
assert e == b + 2*a
e = a + b*b + a + b*b
assert e == 2*a + 2*b**2
e = a + Rational(2) + b*b + a + b*b + p
assert e == 7 + 2*a + 2*b**2
e = (a + b*b + a + b*b)*p
assert e == 5*(2*a + 2*b**2)
e = (a*b*c + c*b*a + b*a*c)*p
assert e == 15*a*b*c
e = (a*b*c + c*b*a + b*a*c)*p - Rational(15)*a*b*c
assert e == Rational(0)
e = Rational(50)*(a - a)
assert e == Rational(0)
e = b*a - b - a*b + b
assert e == Rational(0)
e = a*b + c**p
assert e == a*b + c**5
e = a/b
assert e == a*b**(-1)
e = a*2*2
assert e == 4*a
e = 2 + a*2/2
assert e == 2 + a
e = 2 - a - 2
assert e == -a
e = 2*a*2
assert e == 4*a
e = 2/a/2
assert e == a**(-1)
e = 2**a**2
assert e == 2**(a**2)
e = -(1 + a)
assert e == -1 - a
e = S.Half*(1 + a)
assert e == S.Half + a/2
def test_div():
e = a/b
assert e == a*b**(-1)
e = a/b + c/2
assert e == a*b**(-1) + Rational(1)/2*c
e = (1 - b)/(b - 1)
assert e == (1 + -b)*((-1) + b)**(-1)
def test_pow():
n1 = Rational(1)
n2 = Rational(2)
n5 = Rational(5)
e = a*a
assert e == a**2
e = a*a*a
assert e == a**3
e = a*a*a*a**Rational(6)
assert e == a**9
e = a*a*a*a**Rational(6) - a**Rational(9)
assert e == Rational(0)
e = a**(b - b)
assert e == Rational(1)
e = (a + Rational(1) - a)**b
assert e == Rational(1)
e = (a + b + c)**n2
assert e == (a + b + c)**2
assert e.expand() == 2*b*c + 2*a*c + 2*a*b + a**2 + c**2 + b**2
e = (a + b)**n2
assert e == (a + b)**2
assert e.expand() == 2*a*b + a**2 + b**2
e = (a + b)**(n1/n2)
assert e == sqrt(a + b)
assert e.expand() == sqrt(a + b)
n = n5**(n1/n2)
assert n == sqrt(5)
e = n*a*b - n*b*a
assert e == Rational(0)
e = n*a*b + n*b*a
assert e == 2*a*b*sqrt(5)
assert e.diff(a) == 2*b*sqrt(5)
assert e.diff(a) == 2*b*sqrt(5)
e = a/b**2
assert e == a*b**(-2)
assert sqrt(2*(1 + sqrt(2))) == (2*(1 + 2**S.Half))**S.Half
x = Symbol('x')
y = Symbol('y')
assert ((x*y)**3).expand() == y**3 * x**3
assert ((x*y)**-3).expand() == y**-3 * x**-3
assert (x**5*(3*x)**(3)).expand() == 27 * x**8
assert (x**5*(-3*x)**(3)).expand() == -27 * x**8
assert (x**5*(3*x)**(-3)).expand() == x**2 * Rational(1, 27)
assert (x**5*(-3*x)**(-3)).expand() == x**2 * Rational(-1, 27)
# expand_power_exp
assert (x**(y**(x + exp(x + y)) + z)).expand(deep=False) == \
x**z*x**(y**(x + exp(x + y)))
assert (x**(y**(x + exp(x + y)) + z)).expand() == \
x**z*x**(y**x*y**(exp(x)*exp(y)))
n = Symbol('n', even=False)
k = Symbol('k', even=True)
o = Symbol('o', odd=True)
assert unchanged(Pow, -1, x)
assert unchanged(Pow, -1, n)
assert (-2)**k == 2**k
assert (-1)**k == 1
assert (-1)**o == -1
def test_pow2():
# x**(2*y) is always (x**y)**2 but is only (x**2)**y if
# x.is_positive or y.is_integer
# let x = 1 to see why the following are not true.
assert (-x)**Rational(2, 3) != x**Rational(2, 3)
assert (-x)**Rational(5, 7) != -x**Rational(5, 7)
assert ((-x)**2)**Rational(1, 3) != ((-x)**Rational(1, 3))**2
assert sqrt(x**2) != x
def test_pow3():
assert sqrt(2)**3 == 2 * sqrt(2)
assert sqrt(2)**3 == sqrt(8)
def test_mod_pow():
for s, t, u, v in [(4, 13, 497, 445), (4, -3, 497, 365),
(3.2, 2.1, 1.9, 0.1031015682350942), (S(3)/2, 5, S(5)/6, S(3)/32)]:
assert pow(S(s), t, u) == v
assert pow(S(s), S(t), u) == v
assert pow(S(s), t, S(u)) == v
assert pow(S(s), S(t), S(u)) == v
assert pow(S(2), S(10000000000), S(3)) == 1
assert pow(x, y, z) == x**y%z
raises(TypeError, lambda: pow(S(4), "13", 497))
raises(TypeError, lambda: pow(S(4), 13, "497"))
def test_pow_E():
assert 2**(y/log(2)) == S.Exp1**y
assert 2**(y/log(2)/3) == S.Exp1**(y/3)
assert 3**(1/log(-3)) != S.Exp1
assert (3 + 2*I)**(1/(log(-3 - 2*I) + I*pi)) == S.Exp1
assert (4 + 2*I)**(1/(log(-4 - 2*I) + I*pi)) == S.Exp1
assert (3 + 2*I)**(1/(log(-3 - 2*I, 3)/2 + I*pi/log(3)/2)) == 9
assert (3 + 2*I)**(1/(log(3 + 2*I, 3)/2)) == 9
# every time tests are run they will affirm with a different random
# value that this identity holds
while 1:
b = x._random()
r, i = b.as_real_imag()
if i:
break
assert verify_numerically(b**(1/(log(-b) + sign(i)*I*pi).n()), S.Exp1)
def test_pow_issue_3516():
assert 4**Rational(1, 4) == sqrt(2)
def test_pow_im():
for m in (-2, -1, 2):
for d in (3, 4, 5):
b = m*I
for i in range(1, 4*d + 1):
e = Rational(i, d)
assert (b**e - b.n()**e.n()).n(2, chop=1e-10) == 0
e = Rational(7, 3)
assert (2*x*I)**e == 4*2**Rational(1, 3)*(I*x)**e # same as Wolfram Alpha
im = symbols('im', imaginary=True)
assert (2*im*I)**e == 4*2**Rational(1, 3)*(I*im)**e
args = [I, I, I, I, 2]
e = Rational(1, 3)
ans = 2**e
assert Mul(*args, evaluate=False)**e == ans
assert Mul(*args)**e == ans
args = [I, I, I, 2]
e = Rational(1, 3)
ans = 2**e*(-I)**e
assert Mul(*args, evaluate=False)**e == ans
assert Mul(*args)**e == ans
args.append(-3)
ans = (6*I)**e
assert Mul(*args, evaluate=False)**e == ans
assert Mul(*args)**e == ans
args.append(-1)
ans = (-6*I)**e
assert Mul(*args, evaluate=False)**e == ans
assert Mul(*args)**e == ans
args = [I, I, 2]
e = Rational(1, 3)
ans = (-2)**e
assert Mul(*args, evaluate=False)**e == ans
assert Mul(*args)**e == ans
args.append(-3)
ans = (6)**e
assert Mul(*args, evaluate=False)**e == ans
assert Mul(*args)**e == ans
args.append(-1)
ans = (-6)**e
assert Mul(*args, evaluate=False)**e == ans
assert Mul(*args)**e == ans
assert Mul(Pow(-1, Rational(3, 2), evaluate=False), I, I) == I
assert Mul(I*Pow(I, S.Half, evaluate=False)) == sqrt(I)*I
def test_real_mul():
assert Float(0) * pi * x == 0
assert set((Float(1) * pi * x).args) == {Float(1), pi, x}
def test_ncmul():
A = Symbol("A", commutative=False)
B = Symbol("B", commutative=False)
C = Symbol("C", commutative=False)
assert A*B != B*A
assert A*B*C != C*B*A
assert A*b*B*3*C == 3*b*A*B*C
assert A*b*B*3*C != 3*b*B*A*C
assert A*b*B*3*C == 3*A*B*C*b
assert A + B == B + A
assert (A + B)*C != C*(A + B)
assert C*(A + B)*C != C*C*(A + B)
assert A*A == A**2
assert (A + B)*(A + B) == (A + B)**2
assert A**-1 * A == 1
assert A/A == 1
assert A/(A**2) == 1/A
assert A/(1 + A) == A/(1 + A)
assert set((A + B + 2*(A + B)).args) == \
{A, B, 2*(A + B)}
def test_ncpow():
x = Symbol('x', commutative=False)
y = Symbol('y', commutative=False)
z = Symbol('z', commutative=False)
a = Symbol('a')
b = Symbol('b')
c = Symbol('c')
assert (x**2)*(y**2) != (y**2)*(x**2)
assert (x**-2)*y != y*(x**2)
assert 2**x*2**y != 2**(x + y)
assert 2**x*2**y*2**z != 2**(x + y + z)
assert 2**x*2**(2*x) == 2**(3*x)
assert 2**x*2**(2*x)*2**x == 2**(4*x)
assert exp(x)*exp(y) != exp(y)*exp(x)
assert exp(x)*exp(y)*exp(z) != exp(y)*exp(x)*exp(z)
assert exp(x)*exp(y)*exp(z) != exp(x + y + z)
assert x**a*x**b != x**(a + b)
assert x**a*x**b*x**c != x**(a + b + c)
assert x**3*x**4 == x**7
assert x**3*x**4*x**2 == x**9
assert x**a*x**(4*a) == x**(5*a)
assert x**a*x**(4*a)*x**a == x**(6*a)
def test_powerbug():
x = Symbol("x")
assert x**1 != (-x)**1
assert x**2 == (-x)**2
assert x**3 != (-x)**3
assert x**4 == (-x)**4
assert x**5 != (-x)**5
assert x**6 == (-x)**6
assert x**128 == (-x)**128
assert x**129 != (-x)**129
assert (2*x)**2 == (-2*x)**2
def test_Mul_doesnt_expand_exp():
x = Symbol('x')
y = Symbol('y')
assert unchanged(Mul, exp(x), exp(y))
assert unchanged(Mul, 2**x, 2**y)
assert x**2*x**3 == x**5
assert 2**x*3**x == 6**x
assert x**(y)*x**(2*y) == x**(3*y)
assert sqrt(2)*sqrt(2) == 2
assert 2**x*2**(2*x) == 2**(3*x)
assert sqrt(2)*2**Rational(1, 4)*5**Rational(3, 4) == 10**Rational(3, 4)
assert (x**(-log(5)/log(3))*x)/(x*x**( - log(5)/log(3))) == sympify(1)
def test_Mul_is_integer():
k = Symbol('k', integer=True)
n = Symbol('n', integer=True)
nr = Symbol('nr', rational=False)
nz = Symbol('nz', integer=True, zero=False)
nze = Symbol('nze', even=True, zero=False)
e = Symbol('e', even=True)
o = Symbol('o', odd=True)
i2 = Symbol('2', prime=True, even=True)
assert (k/3).is_integer is None
assert (nz/3).is_integer is None
assert (nr/3).is_integer is False
assert (x*k*n).is_integer is None
assert (e/o).is_integer is None
assert (o/e).is_integer is False
assert (o/i2).is_integer is False
assert Mul(o, 1/o, evaluate=False).is_integer is True
assert Mul(k, 1/k, evaluate=False).is_integer is None
assert Mul(nze, 1/nze, evaluate=False).is_integer is True
assert Mul(2., S.Half, evaluate=False).is_integer is False
s = 2**2**2**Pow(2, 1000, evaluate=False)
m = Mul(s, s, evaluate=False)
assert m.is_integer
def test_Add_Mul_is_integer():
x = Symbol('x')
k = Symbol('k', integer=True)
n = Symbol('n', integer=True)
nk = Symbol('nk', integer=False)
nr = Symbol('nr', rational=False)
nz = Symbol('nz', integer=True, zero=False)
assert (-nk).is_integer is None
assert (-nr).is_integer is False
assert (2*k).is_integer is True
assert (-k).is_integer is True
assert (k + nk).is_integer is False
assert (k + n).is_integer is True
assert (k + x).is_integer is None
assert (k + n*x).is_integer is None
assert (k + n/3).is_integer is None
assert (k + nz/3).is_integer is None
assert (k + nr/3).is_integer is False
assert ((1 + sqrt(3))*(-sqrt(3) + 1)).is_integer is not False
assert (1 + (1 + sqrt(3))*(-sqrt(3) + 1)).is_integer is not False
def test_Add_Mul_is_finite():
x = Symbol('x', extended_real=True, finite=False)
assert sin(x).is_finite is True
assert (x*sin(x)).is_finite is None
assert (x*atan(x)).is_finite is False
assert (1024*sin(x)).is_finite is True
assert (sin(x)*exp(x)).is_finite is None
assert (sin(x)*cos(x)).is_finite is True
assert (x*sin(x)*exp(x)).is_finite is None
assert (sin(x) - 67).is_finite is True
assert (sin(x) + exp(x)).is_finite is not True
assert (1 + x).is_finite is False
assert (1 + x**2 + (1 + x)*(1 - x)).is_finite is None
assert (sqrt(2)*(1 + x)).is_finite is False
assert (sqrt(2)*(1 + x)*(1 - x)).is_finite is False
def test_Mul_is_even_odd():
x = Symbol('x', integer=True)
y = Symbol('y', integer=True)
k = Symbol('k', odd=True)
n = Symbol('n', odd=True)
m = Symbol('m', even=True)
assert (2*x).is_even is True
assert (2*x).is_odd is False
assert (3*x).is_even is None
assert (3*x).is_odd is None
assert (k/3).is_integer is None
assert (k/3).is_even is None
assert (k/3).is_odd is None
assert (2*n).is_even is True
assert (2*n).is_odd is False
assert (2*m).is_even is True
assert (2*m).is_odd is False
assert (-n).is_even is False
assert (-n).is_odd is True
assert (k*n).is_even is False
assert (k*n).is_odd is True
assert (k*m).is_even is True
assert (k*m).is_odd is False
assert (k*n*m).is_even is True
assert (k*n*m).is_odd is False
assert (k*m*x).is_even is True
assert (k*m*x).is_odd is False
# issue 6791:
assert (x/2).is_integer is None
assert (k/2).is_integer is False
assert (m/2).is_integer is True
assert (x*y).is_even is None
assert (x*x).is_even is None
assert (x*(x + k)).is_even is True
assert (x*(x + m)).is_even is None
assert (x*y).is_odd is None
assert (x*x).is_odd is None
assert (x*(x + k)).is_odd is False
assert (x*(x + m)).is_odd is None
@XFAIL
def test_evenness_in_ternary_integer_product_with_odd():
# Tests that oddness inference is independent of term ordering.
# Term ordering at the point of testing depends on SymPy's symbol order, so
# we try to force a different order by modifying symbol names.
x = Symbol('x', integer=True)
y = Symbol('y', integer=True)
k = Symbol('k', odd=True)
assert (x*y*(y + k)).is_even is True
assert (y*x*(x + k)).is_even is True
def test_evenness_in_ternary_integer_product_with_even():
x = Symbol('x', integer=True)
y = Symbol('y', integer=True)
m = Symbol('m', even=True)
assert (x*y*(y + m)).is_even is None
@XFAIL
def test_oddness_in_ternary_integer_product_with_odd():
# Tests that oddness inference is independent of term ordering.
# Term ordering at the point of testing depends on SymPy's symbol order, so
# we try to force a different order by modifying symbol names.
x = Symbol('x', integer=True)
y = Symbol('y', integer=True)
k = Symbol('k', odd=True)
assert (x*y*(y + k)).is_odd is False
assert (y*x*(x + k)).is_odd is False
def test_oddness_in_ternary_integer_product_with_even():
x = Symbol('x', integer=True)
y = Symbol('y', integer=True)
m = Symbol('m', even=True)
assert (x*y*(y + m)).is_odd is None
def test_Mul_is_rational():
x = Symbol('x')
n = Symbol('n', integer=True)
m = Symbol('m', integer=True, nonzero=True)
assert (n/m).is_rational is True
assert (x/pi).is_rational is None
assert (x/n).is_rational is None
assert (m/pi).is_rational is False
r = Symbol('r', rational=True)
assert (pi*r).is_rational is None
# issue 8008
z = Symbol('z', zero=True)
i = Symbol('i', imaginary=True)
assert (z*i).is_rational is True
bi = Symbol('i', imaginary=True, finite=True)
assert (z*bi).is_zero is True
def test_Add_is_rational():
x = Symbol('x')
n = Symbol('n', rational=True)
m = Symbol('m', rational=True)
assert (n + m).is_rational is True
assert (x + pi).is_rational is None
assert (x + n).is_rational is None
assert (n + pi).is_rational is False
def test_Add_is_even_odd():
x = Symbol('x', integer=True)
k = Symbol('k', odd=True)
n = Symbol('n', odd=True)
m = Symbol('m', even=True)
assert (k + 7).is_even is True
assert (k + 7).is_odd is False
assert (-k + 7).is_even is True
assert (-k + 7).is_odd is False
assert (k - 12).is_even is False
assert (k - 12).is_odd is True
assert (-k - 12).is_even is False
assert (-k - 12).is_odd is True
assert (k + n).is_even is True
assert (k + n).is_odd is False
assert (k + m).is_even is False
assert (k + m).is_odd is True
assert (k + n + m).is_even is True
assert (k + n + m).is_odd is False
assert (k + n + x + m).is_even is None
assert (k + n + x + m).is_odd is None
def test_Mul_is_negative_positive():
x = Symbol('x', real=True)
y = Symbol('y', extended_real=False, complex=True)
z = Symbol('z', zero=True)
e = 2*z
assert e.is_Mul and e.is_positive is False and e.is_negative is False
neg = Symbol('neg', negative=True)
pos = Symbol('pos', positive=True)
nneg = Symbol('nneg', nonnegative=True)
npos = Symbol('npos', nonpositive=True)
assert neg.is_negative is True
assert (-neg).is_negative is False
assert (2*neg).is_negative is True
assert (2*pos)._eval_is_extended_negative() is False
assert (2*pos).is_negative is False
assert pos.is_negative is False
assert (-pos).is_negative is True
assert (2*pos).is_negative is False
assert (pos*neg).is_negative is True
assert (2*pos*neg).is_negative is True
assert (-pos*neg).is_negative is False
assert (pos*neg*y).is_negative is False # y.is_real=F; !real -> !neg
assert nneg.is_negative is False
assert (-nneg).is_negative is None
assert (2*nneg).is_negative is False
assert npos.is_negative is None
assert (-npos).is_negative is False
assert (2*npos).is_negative is None
assert (nneg*npos).is_negative is None
assert (neg*nneg).is_negative is None
assert (neg*npos).is_negative is False
assert (pos*nneg).is_negative is False
assert (pos*npos).is_negative is None
assert (npos*neg*nneg).is_negative is False
assert (npos*pos*nneg).is_negative is None
assert (-npos*neg*nneg).is_negative is None
assert (-npos*pos*nneg).is_negative is False
assert (17*npos*neg*nneg).is_negative is False
assert (17*npos*pos*nneg).is_negative is None
assert (neg*npos*pos*nneg).is_negative is False
assert (x*neg).is_negative is None
assert (nneg*npos*pos*x*neg).is_negative is None
assert neg.is_positive is False
assert (-neg).is_positive is True
assert (2*neg).is_positive is False
assert pos.is_positive is True
assert (-pos).is_positive is False
assert (2*pos).is_positive is True
assert (pos*neg).is_positive is False
assert (2*pos*neg).is_positive is False
assert (-pos*neg).is_positive is True
assert (-pos*neg*y).is_positive is False # y.is_real=F; !real -> !neg
assert nneg.is_positive is None
assert (-nneg).is_positive is False
assert (2*nneg).is_positive is None
assert npos.is_positive is False
assert (-npos).is_positive is None
assert (2*npos).is_positive is False
assert (nneg*npos).is_positive is False
assert (neg*nneg).is_positive is False
assert (neg*npos).is_positive is None
assert (pos*nneg).is_positive is None
assert (pos*npos).is_positive is False
assert (npos*neg*nneg).is_positive is None
assert (npos*pos*nneg).is_positive is False
assert (-npos*neg*nneg).is_positive is False
assert (-npos*pos*nneg).is_positive is None
assert (17*npos*neg*nneg).is_positive is None
assert (17*npos*pos*nneg).is_positive is False
assert (neg*npos*pos*nneg).is_positive is None
assert (x*neg).is_positive is None
assert (nneg*npos*pos*x*neg).is_positive is None
def test_Mul_is_negative_positive_2():
a = Symbol('a', nonnegative=True)
b = Symbol('b', nonnegative=True)
c = Symbol('c', nonpositive=True)
d = Symbol('d', nonpositive=True)
assert (a*b).is_nonnegative is True
assert (a*b).is_negative is False
assert (a*b).is_zero is None
assert (a*b).is_positive is None
assert (c*d).is_nonnegative is True
assert (c*d).is_negative is False
assert (c*d).is_zero is None
assert (c*d).is_positive is None
assert (a*c).is_nonpositive is True
assert (a*c).is_positive is False
assert (a*c).is_zero is None
assert (a*c).is_negative is None
def test_Mul_is_nonpositive_nonnegative():
x = Symbol('x', real=True)
k = Symbol('k', negative=True)
n = Symbol('n', positive=True)
u = Symbol('u', nonnegative=True)
v = Symbol('v', nonpositive=True)
assert k.is_nonpositive is True
assert (-k).is_nonpositive is False
assert (2*k).is_nonpositive is True
assert n.is_nonpositive is False
assert (-n).is_nonpositive is True
assert (2*n).is_nonpositive is False
assert (n*k).is_nonpositive is True
assert (2*n*k).is_nonpositive is True
assert (-n*k).is_nonpositive is False
assert u.is_nonpositive is None
assert (-u).is_nonpositive is True
assert (2*u).is_nonpositive is None
assert v.is_nonpositive is True
assert (-v).is_nonpositive is None
assert (2*v).is_nonpositive is True
assert (u*v).is_nonpositive is True
assert (k*u).is_nonpositive is True
assert (k*v).is_nonpositive is None
assert (n*u).is_nonpositive is None
assert (n*v).is_nonpositive is True
assert (v*k*u).is_nonpositive is None
assert (v*n*u).is_nonpositive is True
assert (-v*k*u).is_nonpositive is True
assert (-v*n*u).is_nonpositive is None
assert (17*v*k*u).is_nonpositive is None
assert (17*v*n*u).is_nonpositive is True
assert (k*v*n*u).is_nonpositive is None
assert (x*k).is_nonpositive is None
assert (u*v*n*x*k).is_nonpositive is None
assert k.is_nonnegative is False
assert (-k).is_nonnegative is True
assert (2*k).is_nonnegative is False
assert n.is_nonnegative is True
assert (-n).is_nonnegative is False
assert (2*n).is_nonnegative is True
assert (n*k).is_nonnegative is False
assert (2*n*k).is_nonnegative is False
assert (-n*k).is_nonnegative is True
assert u.is_nonnegative is True
assert (-u).is_nonnegative is None
assert (2*u).is_nonnegative is True
assert v.is_nonnegative is None
assert (-v).is_nonnegative is True
assert (2*v).is_nonnegative is None
assert (u*v).is_nonnegative is None
assert (k*u).is_nonnegative is None
assert (k*v).is_nonnegative is True
assert (n*u).is_nonnegative is True
assert (n*v).is_nonnegative is None
assert (v*k*u).is_nonnegative is True
assert (v*n*u).is_nonnegative is None
assert (-v*k*u).is_nonnegative is None
assert (-v*n*u).is_nonnegative is True
assert (17*v*k*u).is_nonnegative is True
assert (17*v*n*u).is_nonnegative is None
assert (k*v*n*u).is_nonnegative is True
assert (x*k).is_nonnegative is None
assert (u*v*n*x*k).is_nonnegative is None
def test_Add_is_negative_positive():
x = Symbol('x', real=True)
k = Symbol('k', negative=True)
n = Symbol('n', positive=True)
u = Symbol('u', nonnegative=True)
v = Symbol('v', nonpositive=True)
assert (k - 2).is_negative is True
assert (k + 17).is_negative is None
assert (-k - 5).is_negative is None
assert (-k + 123).is_negative is False
assert (k - n).is_negative is True
assert (k + n).is_negative is None
assert (-k - n).is_negative is None
assert (-k + n).is_negative is False
assert (k - n - 2).is_negative is True
assert (k + n + 17).is_negative is None
assert (-k - n - 5).is_negative is None
assert (-k + n + 123).is_negative is False
assert (-2*k + 123*n + 17).is_negative is False
assert (k + u).is_negative is None
assert (k + v).is_negative is True
assert (n + u).is_negative is False
assert (n + v).is_negative is None
assert (u - v).is_negative is False
assert (u + v).is_negative is None
assert (-u - v).is_negative is None
assert (-u + v).is_negative is None
assert (u - v + n + 2).is_negative is False
assert (u + v + n + 2).is_negative is None
assert (-u - v + n + 2).is_negative is None
assert (-u + v + n + 2).is_negative is None
assert (k + x).is_negative is None
assert (k + x - n).is_negative is None
assert (k - 2).is_positive is False
assert (k + 17).is_positive is None
assert (-k - 5).is_positive is None
assert (-k + 123).is_positive is True
assert (k - n).is_positive is False
assert (k + n).is_positive is None
assert (-k - n).is_positive is None
assert (-k + n).is_positive is True
assert (k - n - 2).is_positive is False
assert (k + n + 17).is_positive is None
assert (-k - n - 5).is_positive is None
assert (-k + n + 123).is_positive is True
assert (-2*k + 123*n + 17).is_positive is True
assert (k + u).is_positive is None
assert (k + v).is_positive is False
assert (n + u).is_positive is True
assert (n + v).is_positive is None
assert (u - v).is_positive is None
assert (u + v).is_positive is None
assert (-u - v).is_positive is None
assert (-u + v).is_positive is False
assert (u - v - n - 2).is_positive is None
assert (u + v - n - 2).is_positive is None
assert (-u - v - n - 2).is_positive is None
assert (-u + v - n - 2).is_positive is False
assert (n + x).is_positive is None
assert (n + x - k).is_positive is None
z = (-3 - sqrt(5) + (-sqrt(10)/2 - sqrt(2)/2)**2)
assert z.is_zero
z = sqrt(1 + sqrt(3)) + sqrt(3 + 3*sqrt(3)) - sqrt(10 + 6*sqrt(3))
assert z.is_zero
def test_Add_is_nonpositive_nonnegative():
x = Symbol('x', real=True)
k = Symbol('k', negative=True)
n = Symbol('n', positive=True)
u = Symbol('u', nonnegative=True)
v = Symbol('v', nonpositive=True)
assert (u - 2).is_nonpositive is None
assert (u + 17).is_nonpositive is False
assert (-u - 5).is_nonpositive is True
assert (-u + 123).is_nonpositive is None
assert (u - v).is_nonpositive is None
assert (u + v).is_nonpositive is None
assert (-u - v).is_nonpositive is None
assert (-u + v).is_nonpositive is True
assert (u - v - 2).is_nonpositive is None
assert (u + v + 17).is_nonpositive is None
assert (-u - v - 5).is_nonpositive is None
assert (-u + v - 123).is_nonpositive is True
assert (-2*u + 123*v - 17).is_nonpositive is True
assert (k + u).is_nonpositive is None
assert (k + v).is_nonpositive is True
assert (n + u).is_nonpositive is False
assert (n + v).is_nonpositive is None
assert (k - n).is_nonpositive is True
assert (k + n).is_nonpositive is None
assert (-k - n).is_nonpositive is None
assert (-k + n).is_nonpositive is False
assert (k - n + u + 2).is_nonpositive is None
assert (k + n + u + 2).is_nonpositive is None
assert (-k - n + u + 2).is_nonpositive is None
assert (-k + n + u + 2).is_nonpositive is False
assert (u + x).is_nonpositive is None
assert (v - x - n).is_nonpositive is None
assert (u - 2).is_nonnegative is None
assert (u + 17).is_nonnegative is True
assert (-u - 5).is_nonnegative is False
assert (-u + 123).is_nonnegative is None
assert (u - v).is_nonnegative is True
assert (u + v).is_nonnegative is None
assert (-u - v).is_nonnegative is None
assert (-u + v).is_nonnegative is None
assert (u - v + 2).is_nonnegative is True
assert (u + v + 17).is_nonnegative is None
assert (-u - v - 5).is_nonnegative is None
assert (-u + v - 123).is_nonnegative is False
assert (2*u - 123*v + 17).is_nonnegative is True
assert (k + u).is_nonnegative is None
assert (k + v).is_nonnegative is False
assert (n + u).is_nonnegative is True
assert (n + v).is_nonnegative is None
assert (k - n).is_nonnegative is False
assert (k + n).is_nonnegative is None
assert (-k - n).is_nonnegative is None
assert (-k + n).is_nonnegative is True
assert (k - n - u - 2).is_nonnegative is False
assert (k + n - u - 2).is_nonnegative is None
assert (-k - n - u - 2).is_nonnegative is None
assert (-k + n - u - 2).is_nonnegative is None
assert (u - x).is_nonnegative is None
assert (v + x + n).is_nonnegative is None
def test_Pow_is_integer():
x = Symbol('x')
k = Symbol('k', integer=True)
n = Symbol('n', integer=True, nonnegative=True)
m = Symbol('m', integer=True, positive=True)
assert (k**2).is_integer is True
assert (k**(-2)).is_integer is None
assert ((m + 1)**(-2)).is_integer is False
assert (m**(-1)).is_integer is None # issue 8580
assert (2**k).is_integer is None
assert (2**(-k)).is_integer is None
assert (2**n).is_integer is True
assert (2**(-n)).is_integer is None
assert (2**m).is_integer is True
assert (2**(-m)).is_integer is False
assert (x**2).is_integer is None
assert (2**x).is_integer is None
assert (k**n).is_integer is True
assert (k**(-n)).is_integer is None
assert (k**x).is_integer is None
assert (x**k).is_integer is None
assert (k**(n*m)).is_integer is True
assert (k**(-n*m)).is_integer is None
assert sqrt(3).is_integer is False
assert sqrt(.3).is_integer is False
assert Pow(3, 2, evaluate=False).is_integer is True
assert Pow(3, 0, evaluate=False).is_integer is True
assert Pow(3, -2, evaluate=False).is_integer is False
assert Pow(S.Half, 3, evaluate=False).is_integer is False
# decided by re-evaluating
assert Pow(3, S.Half, evaluate=False).is_integer is False
assert Pow(3, S.Half, evaluate=False).is_integer is False
assert Pow(4, S.Half, evaluate=False).is_integer is True
assert Pow(S.Half, -2, evaluate=False).is_integer is True
assert ((-1)**k).is_integer
# issue 8641
x = Symbol('x', real=True, integer=False)
assert (x**2).is_integer is None
# issue 10458
x = Symbol('x', positive=True)
assert (1/(x + 1)).is_integer is False
assert (1/(-x - 1)).is_integer is False
def test_Pow_is_real():
x = Symbol('x', real=True)
y = Symbol('y', real=True, positive=True)
assert (x**2).is_real is True
assert (x**3).is_real is True
assert (x**x).is_real is None
assert (y**x).is_real is True
assert (x**Rational(1, 3)).is_real is None
assert (y**Rational(1, 3)).is_real is True
assert sqrt(-1 - sqrt(2)).is_real is False
i = Symbol('i', imaginary=True)
assert (i**i).is_real is None
assert (I**i).is_extended_real is True
assert ((-I)**i).is_extended_real is True
assert (2**i).is_real is None # (2**(pi/log(2) * I)) is real, 2**I is not
assert (2**I).is_real is False
assert (2**-I).is_real is False
assert (i**2).is_extended_real is True
assert (i**3).is_extended_real is False
assert (i**x).is_real is None # could be (-I)**(2/3)
e = Symbol('e', even=True)
o = Symbol('o', odd=True)
k = Symbol('k', integer=True)
assert (i**e).is_extended_real is True
assert (i**o).is_extended_real is False
assert (i**k).is_real is None
assert (i**(4*k)).is_extended_real is True
x = Symbol("x", nonnegative=True)
y = Symbol("y", nonnegative=True)
assert im(x**y).expand(complex=True) is S.Zero
assert (x**y).is_real is True
i = Symbol('i', imaginary=True)
assert (exp(i)**I).is_extended_real is True
assert log(exp(i)).is_imaginary is None # i could be 2*pi*I
c = Symbol('c', complex=True)
assert log(c).is_real is None # c could be 0 or 2, too
assert log(exp(c)).is_real is None # log(0), log(E), ...
n = Symbol('n', negative=False)
assert log(n).is_real is None
n = Symbol('n', nonnegative=True)
assert log(n).is_real is None
assert sqrt(-I).is_real is False # issue 7843
i = Symbol('i', integer=True)
assert (1/(i-1)).is_real is None
assert (1/(i-1)).is_extended_real is None
def test_real_Pow():
k = Symbol('k', integer=True, nonzero=True)
assert (k**(I*pi/log(k))).is_real
def test_Pow_is_finite():
xe = Symbol('xe', extended_real=True)
xr = Symbol('xr', real=True)
p = Symbol('p', positive=True)
n = Symbol('n', negative=True)
i = Symbol('i', integer=True)
assert (xe**2).is_finite is None # xe could be oo
assert (xr**2).is_finite is True
assert (xe**xe).is_finite is None
assert (xr**xe).is_finite is None
assert (xe**xr).is_finite is None
# FIXME: The line below should be True rather than None
# assert (xr**xr).is_finite is True
assert (xr**xr).is_finite is None
assert (p**xe).is_finite is None
assert (p**xr).is_finite is True
assert (n**xe).is_finite is None
assert (n**xr).is_finite is True
assert (sin(xe)**2).is_finite is True
assert (sin(xr)**2).is_finite is True
assert (sin(xe)**xe).is_finite is None # xe, xr could be -pi
assert (sin(xr)**xr).is_finite is None
# FIXME: Should the line below be True rather than None?
assert (sin(xe)**exp(xe)).is_finite is None
assert (sin(xr)**exp(xr)).is_finite is True
assert (1/sin(xe)).is_finite is None # if zero, no, otherwise yes
assert (1/sin(xr)).is_finite is None
assert (1/exp(xe)).is_finite is None # xe could be -oo
assert (1/exp(xr)).is_finite is True
assert (1/S.Pi).is_finite is True
assert (1/(i-1)).is_finite is None
def test_Pow_is_even_odd():
x = Symbol('x')
k = Symbol('k', even=True)
n = Symbol('n', odd=True)
m = Symbol('m', integer=True, nonnegative=True)
p = Symbol('p', integer=True, positive=True)
assert ((-1)**n).is_odd
assert ((-1)**k).is_odd
assert ((-1)**(m - p)).is_odd
assert (k**2).is_even is True
assert (n**2).is_even is False
assert (2**k).is_even is None
assert (x**2).is_even is None
assert (k**m).is_even is None
assert (n**m).is_even is False
assert (k**p).is_even is True
assert (n**p).is_even is False
assert (m**k).is_even is None
assert (p**k).is_even is None
assert (m**n).is_even is None
assert (p**n).is_even is None
assert (k**x).is_even is None
assert (n**x).is_even is None
assert (k**2).is_odd is False
assert (n**2).is_odd is True
assert (3**k).is_odd is None
assert (k**m).is_odd is None
assert (n**m).is_odd is True
assert (k**p).is_odd is False
assert (n**p).is_odd is True
assert (m**k).is_odd is None
assert (p**k).is_odd is None
assert (m**n).is_odd is None
assert (p**n).is_odd is None
assert (k**x).is_odd is None
assert (n**x).is_odd is None
def test_Pow_is_negative_positive():
r = Symbol('r', real=True)
k = Symbol('k', integer=True, positive=True)
n = Symbol('n', even=True)
m = Symbol('m', odd=True)
x = Symbol('x')
assert (2**r).is_positive is True
assert ((-2)**r).is_positive is None
assert ((-2)**n).is_positive is True
assert ((-2)**m).is_positive is False
assert (k**2).is_positive is True
assert (k**(-2)).is_positive is True
assert (k**r).is_positive is True
assert ((-k)**r).is_positive is None
assert ((-k)**n).is_positive is True
assert ((-k)**m).is_positive is False
assert (2**r).is_negative is False
assert ((-2)**r).is_negative is None
assert ((-2)**n).is_negative is False
assert ((-2)**m).is_negative is True
assert (k**2).is_negative is False
assert (k**(-2)).is_negative is False
assert (k**r).is_negative is False
assert ((-k)**r).is_negative is None
assert ((-k)**n).is_negative is False
assert ((-k)**m).is_negative is True
assert (2**x).is_positive is None
assert (2**x).is_negative is None
def test_Pow_is_zero():
z = Symbol('z', zero=True)
e = z**2
assert e.is_zero
assert e.is_positive is False
assert e.is_negative is False
assert Pow(0, 0, evaluate=False).is_zero is False
assert Pow(0, 3, evaluate=False).is_zero
assert Pow(0, oo, evaluate=False).is_zero
assert Pow(0, -3, evaluate=False).is_zero is False
assert Pow(0, -oo, evaluate=False).is_zero is False
assert Pow(2, 2, evaluate=False).is_zero is False
a = Symbol('a', zero=False)
assert Pow(a, 3).is_zero is False # issue 7965
assert Pow(2, oo, evaluate=False).is_zero is False
assert Pow(2, -oo, evaluate=False).is_zero
assert Pow(S.Half, oo, evaluate=False).is_zero
assert Pow(S.Half, -oo, evaluate=False).is_zero is False
# All combinations of real/complex base/exponent
h = S.Half
T = True
F = False
N = None
pow_iszero = [
['**', 0, h, 1, 2, -h, -1,-2,-2*I,-I/2,I/2,1+I,oo,-oo,zoo],
[ 0, F, T, T, T, F, F, F, F, F, F, N, T, F, N],
[ h, F, F, F, F, F, F, F, F, F, F, F, T, F, N],
[ 1, F, F, F, F, F, F, F, F, F, F, F, F, F, N],
[ 2, F, F, F, F, F, F, F, F, F, F, F, F, T, N],
[ -h, F, F, F, F, F, F, F, F, F, F, F, T, F, N],
[ -1, F, F, F, F, F, F, F, F, F, F, F, F, F, N],
[ -2, F, F, F, F, F, F, F, F, F, F, F, F, T, N],
[-2*I, F, F, F, F, F, F, F, F, F, F, F, F, T, N],
[-I/2, F, F, F, F, F, F, F, F, F, F, F, T, F, N],
[ I/2, F, F, F, F, F, F, F, F, F, F, F, T, F, N],
[ 1+I, F, F, F, F, F, F, F, F, F, F, F, F, T, N],
[ oo, F, F, F, F, T, T, T, F, F, F, F, F, T, N],
[ -oo, F, F, F, F, T, T, T, F, F, F, F, F, T, N],
[ zoo, F, F, F, F, T, T, T, N, N, N, N, F, T, N]
]
def test_table(table):
n = len(table[0])
for row in range(1, n):
base = table[row][0]
for col in range(1, n):
exp = table[0][col]
is_zero = table[row][col]
# The actual test here:
assert Pow(base, exp, evaluate=False).is_zero is is_zero
test_table(pow_iszero)
# A zero symbol...
zo, zo2 = symbols('zo, zo2', zero=True)
# All combinations of finite symbols
zf, zf2 = symbols('zf, zf2', finite=True)
wf, wf2 = symbols('wf, wf2', nonzero=True)
xf, xf2 = symbols('xf, xf2', real=True)
yf, yf2 = symbols('yf, yf2', nonzero=True)
af, af2 = symbols('af, af2', positive=True)
bf, bf2 = symbols('bf, bf2', nonnegative=True)
cf, cf2 = symbols('cf, cf2', negative=True)
df, df2 = symbols('df, df2', nonpositive=True)
# Without finiteness:
zi, zi2 = symbols('zi, zi2')
wi, wi2 = symbols('wi, wi2', zero=False)
xi, xi2 = symbols('xi, xi2', extended_real=True)
yi, yi2 = symbols('yi, yi2', zero=False, extended_real=True)
ai, ai2 = symbols('ai, ai2', extended_positive=True)
bi, bi2 = symbols('bi, bi2', extended_nonnegative=True)
ci, ci2 = symbols('ci, ci2', extended_negative=True)
di, di2 = symbols('di, di2', extended_nonpositive=True)
pow_iszero_sym = [
['**',zo,wf,yf,af,cf,zf,xf,bf,df,zi,wi,xi,yi,ai,bi,ci,di],
[ zo2, F, N, N, T, F, N, N, N, F, N, N, N, N, T, N, F, F],
[ wf2, F, F, F, F, F, F, F, F, F, N, N, N, N, N, N, N, N],
[ yf2, F, F, F, F, F, F, F, F, F, N, N, N, N, N, N, N, N],
[ af2, F, F, F, F, F, F, F, F, F, N, N, N, N, N, N, N, N],
[ cf2, F, F, F, F, F, F, F, F, F, N, N, N, N, N, N, N, N],
[ zf2, N, N, N, N, F, N, N, N, N, N, N, N, N, N, N, N, N],
[ xf2, N, N, N, N, F, N, N, N, N, N, N, N, N, N, N, N, N],
[ bf2, N, N, N, N, F, N, N, N, N, N, N, N, N, N, N, N, N],
[ df2, N, N, N, N, F, N, N, N, N, N, N, N, N, N, N, N, N],
[ zi2, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N],
[ wi2, F, N, N, F, N, N, N, F, N, N, N, N, N, N, N, N, N],
[ xi2, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N],
[ yi2, F, N, N, F, N, N, N, F, N, N, N, N, N, N, N, N, N],
[ ai2, F, N, N, F, N, N, N, F, N, N, N, N, N, N, N, N, N],
[ bi2, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N],
[ ci2, F, N, N, F, N, N, N, F, N, N, N, N, N, N, N, N, N],
[ di2, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N, N]
]
test_table(pow_iszero_sym)
# In some cases (x**x).is_zero is different from (x**y).is_zero even if y
# has the same assumptions as x.
assert (zo ** zo).is_zero is False
assert (wf ** wf).is_zero is False
assert (yf ** yf).is_zero is False
assert (af ** af).is_zero is False
assert (cf ** cf).is_zero is False
assert (zf ** zf).is_zero is None
assert (xf ** xf).is_zero is None
assert (bf ** bf).is_zero is False # None in table
assert (df ** df).is_zero is None
assert (zi ** zi).is_zero is None
assert (wi ** wi).is_zero is None
assert (xi ** xi).is_zero is None
assert (yi ** yi).is_zero is None
assert (ai ** ai).is_zero is False # None in table
assert (bi ** bi).is_zero is False # None in table
assert (ci ** ci).is_zero is None
assert (di ** di).is_zero is None
def test_Pow_is_nonpositive_nonnegative():
x = Symbol('x', real=True)
k = Symbol('k', integer=True, nonnegative=True)
l = Symbol('l', integer=True, positive=True)
n = Symbol('n', even=True)
m = Symbol('m', odd=True)
assert (x**(4*k)).is_nonnegative is True
assert (2**x).is_nonnegative is True
assert ((-2)**x).is_nonnegative is None
assert ((-2)**n).is_nonnegative is True
assert ((-2)**m).is_nonnegative is False
assert (k**2).is_nonnegative is True
assert (k**(-2)).is_nonnegative is None
assert (k**k).is_nonnegative is True
assert (k**x).is_nonnegative is None # NOTE (0**x).is_real = U
assert (l**x).is_nonnegative is True
assert (l**x).is_positive is True
assert ((-k)**x).is_nonnegative is None
assert ((-k)**m).is_nonnegative is None
assert (2**x).is_nonpositive is False
assert ((-2)**x).is_nonpositive is None
assert ((-2)**n).is_nonpositive is False
assert ((-2)**m).is_nonpositive is True
assert (k**2).is_nonpositive is None
assert (k**(-2)).is_nonpositive is None
assert (k**x).is_nonpositive is None
assert ((-k)**x).is_nonpositive is None
assert ((-k)**n).is_nonpositive is None
assert (x**2).is_nonnegative is True
i = symbols('i', imaginary=True)
assert (i**2).is_nonpositive is True
assert (i**4).is_nonpositive is False
assert (i**3).is_nonpositive is False
assert (I**i).is_nonnegative is True
assert (exp(I)**i).is_nonnegative is True
assert ((-l)**n).is_nonnegative is True
assert ((-l)**m).is_nonpositive is True
assert ((-k)**n).is_nonnegative is None
assert ((-k)**m).is_nonpositive is None
def test_Mul_is_imaginary_real():
r = Symbol('r', real=True)
p = Symbol('p', positive=True)
i1 = Symbol('i1', imaginary=True)
i2 = Symbol('i2', imaginary=True)
x = Symbol('x')
assert I.is_imaginary is True
assert I.is_real is False
assert (-I).is_imaginary is True
assert (-I).is_real is False
assert (3*I).is_imaginary is True
assert (3*I).is_real is False
assert (I*I).is_imaginary is False
assert (I*I).is_real is True
e = (p + p*I)
j = Symbol('j', integer=True, zero=False)
assert (e**j).is_real is None
assert (e**(2*j)).is_real is None
assert (e**j).is_imaginary is None
assert (e**(2*j)).is_imaginary is None
assert (e**-1).is_imaginary is False
assert (e**2).is_imaginary
assert (e**3).is_imaginary is False
assert (e**4).is_imaginary is False
assert (e**5).is_imaginary is False
assert (e**-1).is_real is False
assert (e**2).is_real is False
assert (e**3).is_real is False
assert (e**4).is_real is True
assert (e**5).is_real is False
assert (e**3).is_complex
assert (r*i1).is_imaginary is None
assert (r*i1).is_real is None
assert (x*i1).is_imaginary is None
assert (x*i1).is_real is None
assert (i1*i2).is_imaginary is False
assert (i1*i2).is_real is True
assert (r*i1*i2).is_imaginary is False
assert (r*i1*i2).is_real is True
# Github's issue 5874:
nr = Symbol('nr', real=False, complex=True) # e.g. I or 1 + I
a = Symbol('a', real=True, nonzero=True)
b = Symbol('b', real=True)
assert (i1*nr).is_real is None
assert (a*nr).is_real is False
assert (b*nr).is_real is None
ni = Symbol('ni', imaginary=False, complex=True) # e.g. 2 or 1 + I
a = Symbol('a', real=True, nonzero=True)
b = Symbol('b', real=True)
assert (i1*ni).is_real is False
assert (a*ni).is_real is None
assert (b*ni).is_real is None
def test_Mul_hermitian_antihermitian():
a = Symbol('a', hermitian=True, zero=False)
b = Symbol('b', hermitian=True)
c = Symbol('c', hermitian=False)
d = Symbol('d', antihermitian=True)
e1 = Mul(a, b, c, evaluate=False)
e2 = Mul(b, a, c, evaluate=False)
e3 = Mul(a, b, c, d, evaluate=False)
e4 = Mul(b, a, c, d, evaluate=False)
e5 = Mul(a, c, evaluate=False)
e6 = Mul(a, c, d, evaluate=False)
assert e1.is_hermitian is None
assert e2.is_hermitian is None
assert e1.is_antihermitian is None
assert e2.is_antihermitian is None
assert e3.is_antihermitian is None
assert e4.is_antihermitian is None
assert e5.is_antihermitian is None
assert e6.is_antihermitian is None
def test_Add_is_comparable():
assert (x + y).is_comparable is False
assert (x + 1).is_comparable is False
assert (Rational(1, 3) - sqrt(8)).is_comparable is True
def test_Mul_is_comparable():
assert (x*y).is_comparable is False
assert (x*2).is_comparable is False
assert (sqrt(2)*Rational(1, 3)).is_comparable is True
def test_Pow_is_comparable():
assert (x**y).is_comparable is False
assert (x**2).is_comparable is False
assert (sqrt(Rational(1, 3))).is_comparable is True
def test_Add_is_positive_2():
e = Rational(1, 3) - sqrt(8)
assert e.is_positive is False
assert e.is_negative is True
e = pi - 1
assert e.is_positive is True
assert e.is_negative is False
def test_Add_is_irrational():
i = Symbol('i', irrational=True)
assert i.is_irrational is True
assert i.is_rational is False
assert (i + 1).is_irrational is True
assert (i + 1).is_rational is False
def test_Mul_is_irrational():
expr = Mul(1, 2, 3, evaluate=False)
assert expr.is_irrational is False
expr = Mul(1, I, I, evaluate=False)
assert expr.is_rational is None # I * I = -1 but *no evaluation allowed*
# sqrt(2) * I * I = -sqrt(2) is irrational but
# this can't be determined without evaluating the
# expression and the eval_is routines shouldn't do that
expr = Mul(sqrt(2), I, I, evaluate=False)
assert expr.is_irrational is None
def test_issue_3531():
# https://github.com/sympy/sympy/issues/3531
# https://github.com/sympy/sympy/pull/18116
class MightyNumeric(tuple):
def __rdiv__(self, other):
return "something"
def __rtruediv__(self, other):
return "something"
assert sympify(1)/MightyNumeric((1, 2)) == "something"
def test_issue_3531b():
class Foo:
def __init__(self):
self.field = 1.0
def __mul__(self, other):
self.field = self.field * other
def __rmul__(self, other):
self.field = other * self.field
f = Foo()
x = Symbol("x")
assert f*x == x*f
def test_bug3():
a = Symbol("a")
b = Symbol("b", positive=True)
e = 2*a + b
f = b + 2*a
assert e == f
def test_suppressed_evaluation():
a = Add(0, 3, 2, evaluate=False)
b = Mul(1, 3, 2, evaluate=False)
c = Pow(3, 2, evaluate=False)
assert a != 6
assert a.func is Add
assert a.args == (3, 2)
assert b != 6
assert b.func is Mul
assert b.args == (3, 2)
assert c != 9
assert c.func is Pow
assert c.args == (3, 2)
def test_AssocOp_doit():
a = Add(x,x, evaluate=False)
b = Mul(y,y, evaluate=False)
c = Add(b,b, evaluate=False)
d = Mul(a,a, evaluate=False)
assert c.doit(deep=False).func == Mul
assert c.doit(deep=False).args == (2,y,y)
assert c.doit().func == Mul
assert c.doit().args == (2, Pow(y,2))
assert d.doit(deep=False).func == Pow
assert d.doit(deep=False).args == (a, 2*S.One)
assert d.doit().func == Mul
assert d.doit().args == (4*S.One, Pow(x,2))
def test_Add_as_coeff_mul():
# issue 5524. These should all be (1, self)
assert (x + 1).as_coeff_mul() == (1, (x + 1,))
assert (x + 2).as_coeff_mul() == (1, (x + 2,))
assert (x + 3).as_coeff_mul() == (1, (x + 3,))
assert (x - 1).as_coeff_mul() == (1, (x - 1,))
assert (x - 2).as_coeff_mul() == (1, (x - 2,))
assert (x - 3).as_coeff_mul() == (1, (x - 3,))
n = Symbol('n', integer=True)
assert (n + 1).as_coeff_mul() == (1, (n + 1,))
assert (n + 2).as_coeff_mul() == (1, (n + 2,))
assert (n + 3).as_coeff_mul() == (1, (n + 3,))
assert (n - 1).as_coeff_mul() == (1, (n - 1,))
assert (n - 2).as_coeff_mul() == (1, (n - 2,))
assert (n - 3).as_coeff_mul() == (1, (n - 3,))
def test_Pow_as_coeff_mul_doesnt_expand():
assert exp(x + y).as_coeff_mul() == (1, (exp(x + y),))
assert exp(x + exp(x + y)) != exp(x + exp(x)*exp(y))
def test_issue_3514_18626():
assert sqrt(S.Half) * sqrt(6) == 2 * sqrt(3)/2
assert S.Half*sqrt(6)*sqrt(2) == sqrt(3)
assert sqrt(6)/2*sqrt(2) == sqrt(3)
assert sqrt(6)*sqrt(2)/2 == sqrt(3)
assert sqrt(8)**Rational(2, 3) == 2
def test_make_args():
assert Add.make_args(x) == (x,)
assert Mul.make_args(x) == (x,)
assert Add.make_args(x*y*z) == (x*y*z,)
assert Mul.make_args(x*y*z) == (x*y*z).args
assert Add.make_args(x + y + z) == (x + y + z).args
assert Mul.make_args(x + y + z) == (x + y + z,)
assert Add.make_args((x + y)**z) == ((x + y)**z,)
assert Mul.make_args((x + y)**z) == ((x + y)**z,)
def test_issue_5126():
assert (-2)**x*(-3)**x != 6**x
i = Symbol('i', integer=1)
assert (-2)**i*(-3)**i == 6**i
def test_Rational_as_content_primitive():
c, p = S.One, S.Zero
assert (c*p).as_content_primitive() == (c, p)
c, p = S.Half, S.One
assert (c*p).as_content_primitive() == (c, p)
def test_Add_as_content_primitive():
assert (x + 2).as_content_primitive() == (1, x + 2)
assert (3*x + 2).as_content_primitive() == (1, 3*x + 2)
assert (3*x + 3).as_content_primitive() == (3, x + 1)
assert (3*x + 6).as_content_primitive() == (3, x + 2)
assert (3*x + 2*y).as_content_primitive() == (1, 3*x + 2*y)
assert (3*x + 3*y).as_content_primitive() == (3, x + y)
assert (3*x + 6*y).as_content_primitive() == (3, x + 2*y)
assert (3/x + 2*x*y*z**2).as_content_primitive() == (1, 3/x + 2*x*y*z**2)
assert (3/x + 3*x*y*z**2).as_content_primitive() == (3, 1/x + x*y*z**2)
assert (3/x + 6*x*y*z**2).as_content_primitive() == (3, 1/x + 2*x*y*z**2)
assert (2*x/3 + 4*y/9).as_content_primitive() == \
(Rational(2, 9), 3*x + 2*y)
assert (2*x/3 + 2.5*y).as_content_primitive() == \
(Rational(1, 3), 2*x + 7.5*y)
# the coefficient may sort to a position other than 0
p = 3 + x + y
assert (2*p).expand().as_content_primitive() == (2, p)
assert (2.0*p).expand().as_content_primitive() == (1, 2.*p)
p *= -1
assert (2*p).expand().as_content_primitive() == (2, p)
def test_Mul_as_content_primitive():
assert (2*x).as_content_primitive() == (2, x)
assert (x*(2 + 2*x)).as_content_primitive() == (2, x*(1 + x))
assert (x*(2 + 2*y)*(3*x + 3)**2).as_content_primitive() == \
(18, x*(1 + y)*(x + 1)**2)
assert ((2 + 2*x)**2*(3 + 6*x) + S.Half).as_content_primitive() == \
(S.Half, 24*(x + 1)**2*(2*x + 1) + 1)
def test_Pow_as_content_primitive():
assert (x**y).as_content_primitive() == (1, x**y)
assert ((2*x + 2)**y).as_content_primitive() == \
(1, (Mul(2, (x + 1), evaluate=False))**y)
assert ((2*x + 2)**3).as_content_primitive() == (8, (x + 1)**3)
def test_issue_5460():
u = Mul(2, (1 + x), evaluate=False)
assert (2 + u).args == (2, u)
def test_product_irrational():
from sympy import I, pi
assert (I*pi).is_irrational is False
# The following used to be deduced from the above bug:
assert (I*pi).is_positive is False
def test_issue_5919():
assert (x/(y*(1 + y))).expand() == x/(y**2 + y)
def test_Mod():
assert Mod(x, 1).func is Mod
assert pi % pi is S.Zero
assert Mod(5, 3) == 2
assert Mod(-5, 3) == 1
assert Mod(5, -3) == -1
assert Mod(-5, -3) == -2
assert type(Mod(3.2, 2, evaluate=False)) == Mod
assert 5 % x == Mod(5, x)
assert x % 5 == Mod(x, 5)
assert x % y == Mod(x, y)
assert (x % y).subs({x: 5, y: 3}) == 2
assert Mod(nan, 1) is nan
assert Mod(1, nan) is nan
assert Mod(nan, nan) is nan
Mod(0, x) == 0
with raises(ZeroDivisionError):
Mod(x, 0)
k = Symbol('k', integer=True)
m = Symbol('m', integer=True, positive=True)
assert (x**m % x).func is Mod
assert (k**(-m) % k).func is Mod
assert k**m % k == 0
assert (-2*k)**m % k == 0
# Float handling
point3 = Float(3.3) % 1
assert (x - 3.3) % 1 == Mod(1.*x + 1 - point3, 1)
assert Mod(-3.3, 1) == 1 - point3
assert Mod(0.7, 1) == Float(0.7)
e = Mod(1.3, 1)
assert comp(e, .3) and e.is_Float
e = Mod(1.3, .7)
assert comp(e, .6) and e.is_Float
e = Mod(1.3, Rational(7, 10))
assert comp(e, .6) and e.is_Float
e = Mod(Rational(13, 10), 0.7)
assert comp(e, .6) and e.is_Float
e = Mod(Rational(13, 10), Rational(7, 10))
assert comp(e, .6) and e.is_Rational
# check that sign is right
r2 = sqrt(2)
r3 = sqrt(3)
for i in [-r3, -r2, r2, r3]:
for j in [-r3, -r2, r2, r3]:
assert verify_numerically(i % j, i.n() % j.n())
for _x in range(4):
for _y in range(9):
reps = [(x, _x), (y, _y)]
assert Mod(3*x + y, 9).subs(reps) == (3*_x + _y) % 9
# denesting
t = Symbol('t', real=True)
assert Mod(Mod(x, t), t) == Mod(x, t)
assert Mod(-Mod(x, t), t) == Mod(-x, t)
assert Mod(Mod(x, 2*t), t) == Mod(x, t)
assert Mod(-Mod(x, 2*t), t) == Mod(-x, t)
assert Mod(Mod(x, t), 2*t) == Mod(x, t)
assert Mod(-Mod(x, t), -2*t) == -Mod(x, t)
for i in [-4, -2, 2, 4]:
for j in [-4, -2, 2, 4]:
for k in range(4):
assert Mod(Mod(x, i), j).subs({x: k}) == (k % i) % j
assert Mod(-Mod(x, i), j).subs({x: k}) == -(k % i) % j
# known difference
assert Mod(5*sqrt(2), sqrt(5)) == 5*sqrt(2) - 3*sqrt(5)
p = symbols('p', positive=True)
assert Mod(2, p + 3) == 2
assert Mod(-2, p + 3) == p + 1
assert Mod(2, -p - 3) == -p - 1
assert Mod(-2, -p - 3) == -2
assert Mod(p + 5, p + 3) == 2
assert Mod(-p - 5, p + 3) == p + 1
assert Mod(p + 5, -p - 3) == -p - 1
assert Mod(-p - 5, -p - 3) == -2
assert Mod(p + 1, p - 1).func is Mod
# handling sums
assert (x + 3) % 1 == Mod(x, 1)
assert (x + 3.0) % 1 == Mod(1.*x, 1)
assert (x - S(33)/10) % 1 == Mod(x + S(7)/10, 1)
a = Mod(.6*x + y, .3*y)
b = Mod(0.1*y + 0.6*x, 0.3*y)
# Test that a, b are equal, with 1e-14 accuracy in coefficients
eps = 1e-14
assert abs((a.args[0] - b.args[0]).subs({x: 1, y: 1})) < eps
assert abs((a.args[1] - b.args[1]).subs({x: 1, y: 1})) < eps
assert (x + 1) % x == 1 % x
assert (x + y) % x == y % x
assert (x + y + 2) % x == (y + 2) % x
assert (a + 3*x + 1) % (2*x) == Mod(a + x + 1, 2*x)
assert (12*x + 18*y) % (3*x) == 3*Mod(6*y, x)
# gcd extraction
assert (-3*x) % (-2*y) == -Mod(3*x, 2*y)
assert (.6*pi) % (.3*x*pi) == 0.3*pi*Mod(2, x)
assert (.6*pi) % (.31*x*pi) == pi*Mod(0.6, 0.31*x)
assert (6*pi) % (.3*x*pi) == 0.3*pi*Mod(20, x)
assert (6*pi) % (.31*x*pi) == pi*Mod(6, 0.31*x)
assert (6*pi) % (.42*x*pi) == pi*Mod(6, 0.42*x)
assert (12*x) % (2*y) == 2*Mod(6*x, y)
assert (12*x) % (3*5*y) == 3*Mod(4*x, 5*y)
assert (12*x) % (15*x*y) == 3*x*Mod(4, 5*y)
assert (-2*pi) % (3*pi) == pi
assert (2*x + 2) % (x + 1) == 0
assert (x*(x + 1)) % (x + 1) == (x + 1)*Mod(x, 1)
assert Mod(5.0*x, 0.1*y) == 0.1*Mod(50*x, y)
i = Symbol('i', integer=True)
assert (3*i*x) % (2*i*y) == i*Mod(3*x, 2*y)
assert Mod(4*i, 4) == 0
# issue 8677
n = Symbol('n', integer=True, positive=True)
assert factorial(n) % n == 0
assert factorial(n + 2) % n == 0
assert (factorial(n + 4) % (n + 5)).func is Mod
# Wilson's theorem
factorial(18042, evaluate=False) % 18043 == 18042
p = Symbol('n', prime=True)
factorial(p - 1) % p == p - 1
factorial(p - 1) % -p == -1
(factorial(3, evaluate=False) % 4).doit() == 2
n = Symbol('n', composite=True, odd=True)
factorial(n - 1) % n == 0
# symbolic with known parity
n = Symbol('n', even=True)
assert Mod(n, 2) == 0
n = Symbol('n', odd=True)
assert Mod(n, 2) == 1
# issue 10963
assert (x**6000%400).args[1] == 400
#issue 13543
assert Mod(Mod(x + 1, 2) + 1 , 2) == Mod(x,2)
assert Mod(Mod(x + 2, 4)*(x + 4), 4) == Mod(x*(x + 2), 4)
assert Mod(Mod(x + 2, 4)*4, 4) == 0
# issue 15493
i, j = symbols('i j', integer=True, positive=True)
assert Mod(3*i, 2) == Mod(i, 2)
assert Mod(8*i/j, 4) == 4*Mod(2*i/j, 1)
assert Mod(8*i, 4) == 0
# rewrite
assert Mod(x, y).rewrite(floor) == x - y*floor(x/y)
assert ((x - Mod(x, y))/y).rewrite(floor) == floor(x/y)
def test_Mod_Pow():
# modular exponentiation
assert isinstance(Mod(Pow(2, 2, evaluate=False), 3), Integer)
assert Mod(Pow(4, 13, evaluate=False), 497) == Mod(Pow(4, 13), 497)
assert Mod(Pow(2, 10000000000, evaluate=False), 3) == 1
assert Mod(Pow(32131231232, 9**10**6, evaluate=False),10**12) == \
pow(32131231232,9**10**6,10**12)
assert Mod(Pow(33284959323, 123**999, evaluate=False),11**13) == \
pow(33284959323,123**999,11**13)
assert Mod(Pow(78789849597, 333**555, evaluate=False),12**9) == \
pow(78789849597,333**555,12**9)
# modular nested exponentiation
expr = Pow(2, 2, evaluate=False)
expr = Pow(2, expr, evaluate=False)
assert Mod(expr, 3**10) == 16
expr = Pow(2, expr, evaluate=False)
assert Mod(expr, 3**10) == 6487
expr = Pow(2, expr, evaluate=False)
assert Mod(expr, 3**10) == 32191
expr = Pow(2, expr, evaluate=False)
assert Mod(expr, 3**10) == 18016
expr = Pow(2, expr, evaluate=False)
assert Mod(expr, 3**10) == 5137
expr = Pow(2, 2, evaluate=False)
expr = Pow(expr, 2, evaluate=False)
assert Mod(expr, 3**10) == 16
expr = Pow(expr, 2, evaluate=False)
assert Mod(expr, 3**10) == 256
expr = Pow(expr, 2, evaluate=False)
assert Mod(expr, 3**10) == 6487
expr = Pow(expr, 2, evaluate=False)
assert Mod(expr, 3**10) == 38281
expr = Pow(expr, 2, evaluate=False)
assert Mod(expr, 3**10) == 15928
expr = Pow(2, 2, evaluate=False)
expr = Pow(expr, expr, evaluate=False)
assert Mod(expr, 3**10) == 256
expr = Pow(expr, expr, evaluate=False)
assert Mod(expr, 3**10) == 9229
expr = Pow(expr, expr, evaluate=False)
assert Mod(expr, 3**10) == 25708
expr = Pow(expr, expr, evaluate=False)
assert Mod(expr, 3**10) == 26608
expr = Pow(expr, expr, evaluate=False)
# XXX This used to fail in a nondeterministic way because of overflow
# error.
assert Mod(expr, 3**10) == 1966
def test_Mod_is_integer():
p = Symbol('p', integer=True)
q1 = Symbol('q1', integer=True)
q2 = Symbol('q2', integer=True, nonzero=True)
assert Mod(x, y).is_integer is None
assert Mod(p, q1).is_integer is None
assert Mod(x, q2).is_integer is None
assert Mod(p, q2).is_integer
def test_Mod_is_nonposneg():
n = Symbol('n', integer=True)
k = Symbol('k', integer=True, positive=True)
assert (n%3).is_nonnegative
assert Mod(n, -3).is_nonpositive
assert Mod(n, k).is_nonnegative
assert Mod(n, -k).is_nonpositive
assert Mod(k, n).is_nonnegative is None
def test_issue_6001():
A = Symbol("A", commutative=False)
eq = A + A**2
# it doesn't matter whether it's True or False; they should
# just all be the same
assert (
eq.is_commutative ==
(eq + 1).is_commutative ==
(A + 1).is_commutative)
B = Symbol("B", commutative=False)
# Although commutative terms could cancel we return True
# meaning "there are non-commutative symbols; aftersubstitution
# that definition can change, e.g. (A*B).subs(B,A**-1) -> 1
assert (sqrt(2)*A).is_commutative is False
assert (sqrt(2)*A*B).is_commutative is False
def test_polar():
from sympy import polar_lift
p = Symbol('p', polar=True)
x = Symbol('x')
assert p.is_polar
assert x.is_polar is None
assert S.One.is_polar is None
assert (p**x).is_polar is True
assert (x**p).is_polar is None
assert ((2*p)**x).is_polar is True
assert (2*p).is_polar is True
assert (-2*p).is_polar is not True
assert (polar_lift(-2)*p).is_polar is True
q = Symbol('q', polar=True)
assert (p*q)**2 == p**2 * q**2
assert (2*q)**2 == 4 * q**2
assert ((p*q)**x).expand() == p**x * q**x
def test_issue_6040():
a, b = Pow(1, 2, evaluate=False), S.One
assert a != b
assert b != a
assert not (a == b)
assert not (b == a)
def test_issue_6082():
# Comparison is symmetric
assert Basic.compare(Max(x, 1), Max(x, 2)) == \
- Basic.compare(Max(x, 2), Max(x, 1))
# Equal expressions compare equal
assert Basic.compare(Max(x, 1), Max(x, 1)) == 0
# Basic subtypes (such as Max) compare different than standard types
assert Basic.compare(Max(1, x), frozenset((1, x))) != 0
def test_issue_6077():
assert x**2.0/x == x**1.0
assert x/x**2.0 == x**-1.0
assert x*x**2.0 == x**3.0
assert x**1.5*x**2.5 == x**4.0
assert 2**(2.0*x)/2**x == 2**(1.0*x)
assert 2**x/2**(2.0*x) == 2**(-1.0*x)
assert 2**x*2**(2.0*x) == 2**(3.0*x)
assert 2**(1.5*x)*2**(2.5*x) == 2**(4.0*x)
def test_mul_flatten_oo():
p = symbols('p', positive=True)
n, m = symbols('n,m', negative=True)
x_im = symbols('x_im', imaginary=True)
assert n*oo is -oo
assert n*m*oo is oo
assert p*oo is oo
assert x_im*oo != I*oo # i could be +/- 3*I -> +/-oo
def test_add_flatten():
# see https://github.com/sympy/sympy/issues/2633#issuecomment-29545524
a = oo + I*oo
b = oo - I*oo
assert a + b is nan
assert a - b is nan
# FIXME: This evaluates as:
# >>> 1/a
# 0*(oo + oo*I)
# which should not simplify to 0. Should be fixed in Pow.eval
#assert (1/a).simplify() == (1/b).simplify() == 0
a = Pow(2, 3, evaluate=False)
assert a + a == 16
def test_issue_5160_6087_6089_6090():
# issue 6087
assert ((-2*x*y**y)**3.2).n(2) == (2**3.2*(-x*y**y)**3.2).n(2)
# issue 6089
A, B, C = symbols('A,B,C', commutative=False)
assert (2.*B*C)**3 == 8.0*(B*C)**3
assert (-2.*B*C)**3 == -8.0*(B*C)**3
assert (-2*B*C)**2 == 4*(B*C)**2
# issue 5160
assert sqrt(-1.0*x) == 1.0*sqrt(-x)
assert sqrt(1.0*x) == 1.0*sqrt(x)
# issue 6090
assert (-2*x*y*A*B)**2 == 4*x**2*y**2*(A*B)**2
def test_float_int_round():
assert int(float(sqrt(10))) == int(sqrt(10))
assert int(pi**1000) % 10 == 2
assert int(Float('1.123456789012345678901234567890e20', '')) == \
int(112345678901234567890)
assert int(Float('1.123456789012345678901234567890e25', '')) == \
int(11234567890123456789012345)
# decimal forces float so it's not an exact integer ending in 000000
assert int(Float('1.123456789012345678901234567890e35', '')) == \
112345678901234567890123456789000192
assert int(Float('123456789012345678901234567890e5', '')) == \
12345678901234567890123456789000000
assert Integer(Float('1.123456789012345678901234567890e20', '')) == \
112345678901234567890
assert Integer(Float('1.123456789012345678901234567890e25', '')) == \
11234567890123456789012345
# decimal forces float so it's not an exact integer ending in 000000
assert Integer(Float('1.123456789012345678901234567890e35', '')) == \
112345678901234567890123456789000192
assert Integer(Float('123456789012345678901234567890e5', '')) == \
12345678901234567890123456789000000
assert same_and_same_prec(Float('123000e-2',''), Float('1230.00', ''))
assert same_and_same_prec(Float('123000e2',''), Float('12300000', ''))
assert int(1 + Rational('.9999999999999999999999999')) == 1
assert int(pi/1e20) == 0
assert int(1 + pi/1e20) == 1
assert int(Add(1.2, -2, evaluate=False)) == int(1.2 - 2)
assert int(Add(1.2, +2, evaluate=False)) == int(1.2 + 2)
assert int(Add(1 + Float('.99999999999999999', ''), evaluate=False)) == 1
raises(TypeError, lambda: float(x))
raises(TypeError, lambda: float(sqrt(-1)))
assert int(12345678901234567890 + cos(1)**2 + sin(1)**2) == \
12345678901234567891
def test_issue_6611a():
assert Mul.flatten([3**Rational(1, 3),
Pow(-Rational(1, 9), Rational(2, 3), evaluate=False)]) == \
([Rational(1, 3), (-1)**Rational(2, 3)], [], None)
def test_denest_add_mul():
# when working with evaluated expressions make sure they denest
eq = x + 1
eq = Add(eq, 2, evaluate=False)
eq = Add(eq, 2, evaluate=False)
assert Add(*eq.args) == x + 5
eq = x*2
eq = Mul(eq, 2, evaluate=False)
eq = Mul(eq, 2, evaluate=False)
assert Mul(*eq.args) == 8*x
# but don't let them denest unecessarily
eq = Mul(-2, x - 2, evaluate=False)
assert 2*eq == Mul(-4, x - 2, evaluate=False)
assert -eq == Mul(2, x - 2, evaluate=False)
def test_mul_coeff():
# It is important that all Numbers be removed from the seq;
# This can be tricky when powers combine to produce those numbers
p = exp(I*pi/3)
assert p**2*x*p*y*p*x*p**2 == x**2*y
def test_mul_zero_detection():
nz = Dummy(real=True, zero=False)
r = Dummy(extended_real=True)
c = Dummy(real=False, complex=True)
c2 = Dummy(real=False, complex=True)
i = Dummy(imaginary=True)
e = nz*r*c
assert e.is_imaginary is None
assert e.is_extended_real is None
e = nz*c
assert e.is_imaginary is None
assert e.is_extended_real is False
e = nz*i*c
assert e.is_imaginary is False
assert e.is_extended_real is None
# check for more than one complex; it is important to use
# uniquely named Symbols to ensure that two factors appear
# e.g. if the symbols have the same name they just become
# a single factor, a power.
e = nz*i*c*c2
assert e.is_imaginary is None
assert e.is_extended_real is None
# _eval_is_extended_real and _eval_is_zero both employ trapping of the
# zero value so args should be tested in both directions and
# TO AVOID GETTING THE CACHED RESULT, Dummy MUST BE USED
# real is unknown
def test(z, b, e):
if z.is_zero and b.is_finite:
assert e.is_extended_real and e.is_zero
else:
assert e.is_extended_real is None
if b.is_finite:
if z.is_zero:
assert e.is_zero
else:
assert e.is_zero is None
elif b.is_finite is False:
if z.is_zero is None:
assert e.is_zero is None
else:
assert e.is_zero is False
for iz, ib in cartes(*[[True, False, None]]*2):
z = Dummy('z', nonzero=iz)
b = Dummy('f', finite=ib)
e = Mul(z, b, evaluate=False)
test(z, b, e)
z = Dummy('nz', nonzero=iz)
b = Dummy('f', finite=ib)
e = Mul(b, z, evaluate=False)
test(z, b, e)
# real is True
def test(z, b, e):
if z.is_zero and not b.is_finite:
assert e.is_extended_real is None
else:
assert e.is_extended_real is True
for iz, ib in cartes(*[[True, False, None]]*2):
z = Dummy('z', nonzero=iz, extended_real=True)
b = Dummy('b', finite=ib, extended_real=True)
e = Mul(z, b, evaluate=False)
test(z, b, e)
z = Dummy('z', nonzero=iz, extended_real=True)
b = Dummy('b', finite=ib, extended_real=True)
e = Mul(b, z, evaluate=False)
test(z, b, e)
def test_Mul_with_zero_infinite():
zer = Dummy(zero=True)
inf = Dummy(finite=False)
e = Mul(zer, inf, evaluate=False)
assert e.is_extended_positive is None
assert e.is_hermitian is None
e = Mul(inf, zer, evaluate=False)
assert e.is_extended_positive is None
assert e.is_hermitian is None
def test_Mul_does_not_cancel_infinities():
a, b = symbols('a b')
assert ((zoo + 3*a)/(3*a + zoo)) is nan
assert ((b - oo)/(b - oo)) is nan
# issue 13904
expr = (1/(a+b) + 1/(a-b))/(1/(a+b) - 1/(a-b))
assert expr.subs(b, a) is nan
def test_Mul_does_not_distribute_infinity():
a, b = symbols('a b')
assert ((1 + I)*oo).is_Mul
assert ((a + b)*(-oo)).is_Mul
assert ((a + 1)*zoo).is_Mul
assert ((1 + I)*oo).is_finite is False
z = (1 + I)*oo
assert ((1 - I)*z).expand() is oo
def test_issue_8247_8354():
from sympy import tan
z = sqrt(1 + sqrt(3)) + sqrt(3 + 3*sqrt(3)) - sqrt(10 + 6*sqrt(3))
assert z.is_positive is False # it's 0
z = S('''-2**(1/3)*(3*sqrt(93) + 29)**2 - 4*(3*sqrt(93) + 29)**(4/3) +
12*sqrt(93)*(3*sqrt(93) + 29)**(1/3) + 116*(3*sqrt(93) + 29)**(1/3) +
174*2**(1/3)*sqrt(93) + 1678*2**(1/3)''')
assert z.is_positive is False # it's 0
z = 2*(-3*tan(19*pi/90) + sqrt(3))*cos(11*pi/90)*cos(19*pi/90) - \
sqrt(3)*(-3 + 4*cos(19*pi/90)**2)
assert z.is_positive is not True # it's zero and it shouldn't hang
z = S('''9*(3*sqrt(93) + 29)**(2/3)*((3*sqrt(93) +
29)**(1/3)*(-2**(2/3)*(3*sqrt(93) + 29)**(1/3) - 2) - 2*2**(1/3))**3 +
72*(3*sqrt(93) + 29)**(2/3)*(81*sqrt(93) + 783) + (162*sqrt(93) +
1566)*((3*sqrt(93) + 29)**(1/3)*(-2**(2/3)*(3*sqrt(93) + 29)**(1/3) -
2) - 2*2**(1/3))**2''')
assert z.is_positive is False # it's 0 (and a single _mexpand isn't enough)
def test_Add_is_zero():
x, y = symbols('x y', zero=True)
assert (x + y).is_zero
# Issue 15873
e = -2*I + (1 + I)**2
assert e.is_zero is None
def test_issue_14392():
assert (sin(zoo)**2).as_real_imag() == (nan, nan)
def test_divmod():
assert divmod(x, y) == (x//y, x % y)
assert divmod(x, 3) == (x//3, x % 3)
assert divmod(3, x) == (3//x, 3 % x)
def test__neg__():
assert -(x*y) == -x*y
assert -(-x*y) == x*y
assert -(1.*x) == -1.*x
assert -(-1.*x) == 1.*x
assert -(2.*x) == -2.*x
assert -(-2.*x) == 2.*x
with distribute(False):
eq = -(x + y)
assert eq.is_Mul and eq.args == (-1, x + y)
def test_issue_18507():
assert Mul(zoo, zoo, 0) is nan
|
f836c72b3298f3dcf4c435b3c33742d51ac22b2f047d10ba246f2a1c6ef38dee | """Tests that the IPython printing module is properly loaded. """
from sympy.interactive.session import init_ipython_session
from sympy.external import import_module
from sympy.testing.pytest import raises
# run_cell was added in IPython 0.11
ipython = import_module("IPython", min_module_version="0.11")
# disable tests if ipython is not present
if not ipython:
disabled = True
def test_ipythonprinting():
# Initialize and setup IPython session
app = init_ipython_session()
app.run_cell("ip = get_ipython()")
app.run_cell("inst = ip.instance()")
app.run_cell("format = inst.display_formatter.format")
app.run_cell("from sympy import Symbol")
# Printing without printing extension
app.run_cell("a = format(Symbol('pi'))")
app.run_cell("a2 = format(Symbol('pi')**2)")
# Deal with API change starting at IPython 1.0
if int(ipython.__version__.split(".")[0]) < 1:
assert app.user_ns['a']['text/plain'] == "pi"
assert app.user_ns['a2']['text/plain'] == "pi**2"
else:
assert app.user_ns['a'][0]['text/plain'] == "pi"
assert app.user_ns['a2'][0]['text/plain'] == "pi**2"
# Load printing extension
app.run_cell("from sympy import init_printing")
app.run_cell("init_printing()")
# Printing with printing extension
app.run_cell("a = format(Symbol('pi'))")
app.run_cell("a2 = format(Symbol('pi')**2)")
# Deal with API change starting at IPython 1.0
if int(ipython.__version__.split(".")[0]) < 1:
assert app.user_ns['a']['text/plain'] in ('\N{GREEK SMALL LETTER PI}', 'pi')
assert app.user_ns['a2']['text/plain'] in (' 2\n\N{GREEK SMALL LETTER PI} ', ' 2\npi ')
else:
assert app.user_ns['a'][0]['text/plain'] in ('\N{GREEK SMALL LETTER PI}', 'pi')
assert app.user_ns['a2'][0]['text/plain'] in (' 2\n\N{GREEK SMALL LETTER PI} ', ' 2\npi ')
def test_print_builtin_option():
# Initialize and setup IPython session
app = init_ipython_session()
app.run_cell("ip = get_ipython()")
app.run_cell("inst = ip.instance()")
app.run_cell("format = inst.display_formatter.format")
app.run_cell("from sympy import Symbol")
app.run_cell("from sympy import init_printing")
app.run_cell("a = format({Symbol('pi'): 3.14, Symbol('n_i'): 3})")
# Deal with API change starting at IPython 1.0
if int(ipython.__version__.split(".")[0]) < 1:
text = app.user_ns['a']['text/plain']
raises(KeyError, lambda: app.user_ns['a']['text/latex'])
else:
text = app.user_ns['a'][0]['text/plain']
raises(KeyError, lambda: app.user_ns['a'][0]['text/latex'])
# Note : Unicode of Python2 is equivalent to str in Python3. In Python 3 we have one
# text type: str which holds Unicode data and two byte types bytes and bytearray.
# XXX: How can we make this ignore the terminal width? This test fails if
# the terminal is too narrow.
assert text in ("{pi: 3.14, n_i: 3}",
'{n\N{LATIN SUBSCRIPT SMALL LETTER I}: 3, \N{GREEK SMALL LETTER PI}: 3.14}',
"{n_i: 3, pi: 3.14}",
'{\N{GREEK SMALL LETTER PI}: 3.14, n\N{LATIN SUBSCRIPT SMALL LETTER I}: 3}')
# If we enable the default printing, then the dictionary's should render
# as a LaTeX version of the whole dict: ${\pi: 3.14, n_i: 3}$
app.run_cell("inst.display_formatter.formatters['text/latex'].enabled = True")
app.run_cell("init_printing(use_latex=True)")
app.run_cell("a = format({Symbol('pi'): 3.14, Symbol('n_i'): 3})")
# Deal with API change starting at IPython 1.0
if int(ipython.__version__.split(".")[0]) < 1:
text = app.user_ns['a']['text/plain']
latex = app.user_ns['a']['text/latex']
else:
text = app.user_ns['a'][0]['text/plain']
latex = app.user_ns['a'][0]['text/latex']
assert text in ("{pi: 3.14, n_i: 3}",
'{n\N{LATIN SUBSCRIPT SMALL LETTER I}: 3, \N{GREEK SMALL LETTER PI}: 3.14}',
"{n_i: 3, pi: 3.14}",
'{\N{GREEK SMALL LETTER PI}: 3.14, n\N{LATIN SUBSCRIPT SMALL LETTER I}: 3}')
assert latex == r'$\displaystyle \left\{ n_{i} : 3, \ \pi : 3.14\right\}$'
app.run_cell("inst.display_formatter.formatters['text/latex'].enabled = True")
app.run_cell("init_printing(use_latex=True, print_builtin=False)")
app.run_cell("a = format({Symbol('pi'): 3.14, Symbol('n_i'): 3})")
# Deal with API change starting at IPython 1.0
if int(ipython.__version__.split(".")[0]) < 1:
text = app.user_ns['a']['text/plain']
raises(KeyError, lambda: app.user_ns['a']['text/latex'])
else:
text = app.user_ns['a'][0]['text/plain']
raises(KeyError, lambda: app.user_ns['a'][0]['text/latex'])
# Note : In Python 3 we have one text type: str which holds Unicode data
# and two byte types bytes and bytearray.
# Python 3.3.3 + IPython 0.13.2 gives: '{n_i: 3, pi: 3.14}'
# Python 3.3.3 + IPython 1.1.0 gives: '{n_i: 3, pi: 3.14}'
assert text in ("{pi: 3.14, n_i: 3}", "{n_i: 3, pi: 3.14}")
def test_builtin_containers():
# Initialize and setup IPython session
app = init_ipython_session()
app.run_cell("ip = get_ipython()")
app.run_cell("inst = ip.instance()")
app.run_cell("format = inst.display_formatter.format")
app.run_cell("inst.display_formatter.formatters['text/latex'].enabled = True")
app.run_cell("from sympy import init_printing, Matrix")
app.run_cell('init_printing(use_latex=True, use_unicode=False)')
# Make sure containers that shouldn't pretty print don't.
app.run_cell('a = format((True, False))')
app.run_cell('import sys')
app.run_cell('b = format(sys.flags)')
app.run_cell('c = format((Matrix([1, 2]),))')
# Deal with API change starting at IPython 1.0
if int(ipython.__version__.split(".")[0]) < 1:
assert app.user_ns['a']['text/plain'] == '(True, False)'
assert 'text/latex' not in app.user_ns['a']
assert app.user_ns['b']['text/plain'][:10] == 'sys.flags('
assert 'text/latex' not in app.user_ns['b']
assert app.user_ns['c']['text/plain'] == \
"""\
[1] \n\
([ ],)
[2] \
"""
assert app.user_ns['c']['text/latex'] == '$\\displaystyle \\left( \\left[\\begin{matrix}1\\\\2\\end{matrix}\\right]\\right)$'
else:
assert app.user_ns['a'][0]['text/plain'] == '(True, False)'
assert 'text/latex' not in app.user_ns['a'][0]
assert app.user_ns['b'][0]['text/plain'][:10] == 'sys.flags('
assert 'text/latex' not in app.user_ns['b'][0]
assert app.user_ns['c'][0]['text/plain'] == \
"""\
[1] \n\
([ ],)
[2] \
"""
assert app.user_ns['c'][0]['text/latex'] == '$\\displaystyle \\left( \\left[\\begin{matrix}1\\\\2\\end{matrix}\\right]\\right)$'
def test_matplotlib_bad_latex():
# Initialize and setup IPython session
app = init_ipython_session()
app.run_cell("import IPython")
app.run_cell("ip = get_ipython()")
app.run_cell("inst = ip.instance()")
app.run_cell("format = inst.display_formatter.format")
app.run_cell("from sympy import init_printing, Matrix")
app.run_cell("init_printing(use_latex='matplotlib')")
# The png formatter is not enabled by default in this context
app.run_cell("inst.display_formatter.formatters['image/png'].enabled = True")
# Make sure no warnings are raised by IPython
app.run_cell("import warnings")
# IPython.core.formatters.FormatterWarning was introduced in IPython 2.0
if int(ipython.__version__.split(".")[0]) < 2:
app.run_cell("warnings.simplefilter('error')")
else:
app.run_cell("warnings.simplefilter('error', IPython.core.formatters.FormatterWarning)")
# This should not raise an exception
app.run_cell("a = format(Matrix([1, 2, 3]))")
# issue 9799
app.run_cell("from sympy import Piecewise, Symbol, Eq")
app.run_cell("x = Symbol('x'); pw = format(Piecewise((1, Eq(x, 0)), (0, True)))")
|
2bada75e30c1fdd68af7d4570825a20e7b6c868a49235fbac61b74e104dec907 | """Implementation of :class:`Domain` class. """
from __future__ import print_function, division
from typing import Any, Optional, Type
from sympy.core import Basic, sympify
from sympy.core.compatibility import HAS_GMPY, is_sequence
from sympy.core.decorators import deprecated
from sympy.polys.domains.domainelement import DomainElement
from sympy.polys.orderings import lex
from sympy.polys.polyerrors import UnificationFailed, CoercionFailed, DomainError
from sympy.polys.polyutils import _unify_gens, _not_a_coeff
from sympy.utilities import default_sort_key, public
@public
class Domain(object):
"""Represents an abstract domain. """
dtype = None # type: Optional[Type]
zero = None # type: Optional[Any]
one = None # type: Optional[Any]
is_Ring = False
is_Field = False
has_assoc_Ring = False
has_assoc_Field = False
is_FiniteField = is_FF = False
is_IntegerRing = is_ZZ = False
is_RationalField = is_QQ = False
is_RealField = is_RR = False
is_ComplexField = is_CC = False
is_AlgebraicField = is_Algebraic = False
is_PolynomialRing = is_Poly = False
is_FractionField = is_Frac = False
is_SymbolicDomain = is_EX = False
is_Exact = True
is_Numerical = False
is_Simple = False
is_Composite = False
is_PID = False
has_CharacteristicZero = False
rep = None # type: Optional[str]
alias = None # type: Optional[str]
@property # type: ignore
@deprecated(useinstead="is_Field", issue=12723, deprecated_since_version="1.1")
def has_Field(self):
return self.is_Field
@property # type: ignore
@deprecated(useinstead="is_Ring", issue=12723, deprecated_since_version="1.1")
def has_Ring(self):
return self.is_Ring
def __init__(self):
raise NotImplementedError
def __str__(self):
return self.rep
def __repr__(self):
return str(self)
def __hash__(self):
return hash((self.__class__.__name__, self.dtype))
def new(self, *args):
return self.dtype(*args)
@property
def tp(self):
return self.dtype
def __call__(self, *args):
"""Construct an element of ``self`` domain from ``args``. """
return self.new(*args)
def normal(self, *args):
return self.dtype(*args)
def convert_from(self, element, base):
"""Convert ``element`` to ``self.dtype`` given the base domain. """
if base.alias is not None:
method = "from_" + base.alias
else:
method = "from_" + base.__class__.__name__
_convert = getattr(self, method)
if _convert is not None:
result = _convert(element, base)
if result is not None:
return result
raise CoercionFailed("can't convert %s of type %s from %s to %s" % (element, type(element), base, self))
def convert(self, element, base=None):
"""Convert ``element`` to ``self.dtype``. """
if _not_a_coeff(element):
raise CoercionFailed('%s is not in any domain' % element)
if base is not None:
return self.convert_from(element, base)
if self.of_type(element):
return element
from sympy.polys.domains import PythonIntegerRing, GMPYIntegerRing, GMPYRationalField, RealField, ComplexField
if isinstance(element, int):
return self.convert_from(element, PythonIntegerRing())
if HAS_GMPY:
integers = GMPYIntegerRing()
if isinstance(element, integers.tp):
return self.convert_from(element, integers)
rationals = GMPYRationalField()
if isinstance(element, rationals.tp):
return self.convert_from(element, rationals)
if isinstance(element, float):
parent = RealField(tol=False)
return self.convert_from(parent(element), parent)
if isinstance(element, complex):
parent = ComplexField(tol=False)
return self.convert_from(parent(element), parent)
if isinstance(element, DomainElement):
return self.convert_from(element, element.parent())
# TODO: implement this in from_ methods
if self.is_Numerical and getattr(element, 'is_ground', False):
return self.convert(element.LC())
if isinstance(element, Basic):
try:
return self.from_sympy(element)
except (TypeError, ValueError):
pass
else: # TODO: remove this branch
if not is_sequence(element):
try:
element = sympify(element, strict=True)
if isinstance(element, Basic):
return self.from_sympy(element)
except (TypeError, ValueError):
pass
raise CoercionFailed("can't convert %s of type %s to %s" % (element, type(element), self))
def of_type(self, element):
"""Check if ``a`` is of type ``dtype``. """
return isinstance(element, self.tp) # XXX: this isn't correct, e.g. PolyElement
def __contains__(self, a):
"""Check if ``a`` belongs to this domain. """
try:
if _not_a_coeff(a):
raise CoercionFailed
self.convert(a) # this might raise, too
except CoercionFailed:
return False
return True
def to_sympy(self, a):
"""Convert ``a`` to a SymPy object. """
raise NotImplementedError
def from_sympy(self, a):
"""Convert a SymPy object to ``dtype``. """
raise NotImplementedError
def from_FF_python(K1, a, K0):
"""Convert ``ModularInteger(int)`` to ``dtype``. """
return None
def from_ZZ_python(K1, a, K0):
"""Convert a Python ``int`` object to ``dtype``. """
return None
def from_QQ_python(K1, a, K0):
"""Convert a Python ``Fraction`` object to ``dtype``. """
return None
def from_FF_gmpy(K1, a, K0):
"""Convert ``ModularInteger(mpz)`` to ``dtype``. """
return None
def from_ZZ_gmpy(K1, a, K0):
"""Convert a GMPY ``mpz`` object to ``dtype``. """
return None
def from_QQ_gmpy(K1, a, K0):
"""Convert a GMPY ``mpq`` object to ``dtype``. """
return None
def from_RealField(K1, a, K0):
"""Convert a real element object to ``dtype``. """
return None
def from_ComplexField(K1, a, K0):
"""Convert a complex element to ``dtype``. """
return None
def from_AlgebraicField(K1, a, K0):
"""Convert an algebraic number to ``dtype``. """
return None
def from_PolynomialRing(K1, a, K0):
"""Convert a polynomial to ``dtype``. """
if a.is_ground:
return K1.convert(a.LC, K0.dom)
def from_FractionField(K1, a, K0):
"""Convert a rational function to ``dtype``. """
return None
def from_ExpressionDomain(K1, a, K0):
"""Convert a ``EX`` object to ``dtype``. """
return K1.from_sympy(a.ex)
def from_GlobalPolynomialRing(K1, a, K0):
"""Convert a polynomial to ``dtype``. """
if a.degree() <= 0:
return K1.convert(a.LC(), K0.dom)
def from_GeneralizedPolynomialRing(K1, a, K0):
return K1.from_FractionField(a, K0)
def unify_with_symbols(K0, K1, symbols):
if (K0.is_Composite and (set(K0.symbols) & set(symbols))) or (K1.is_Composite and (set(K1.symbols) & set(symbols))):
raise UnificationFailed("can't unify %s with %s, given %s generators" % (K0, K1, tuple(symbols)))
return K0.unify(K1)
def unify(K0, K1, symbols=None):
"""
Construct a minimal domain that contains elements of ``K0`` and ``K1``.
Known domains (from smallest to largest):
- ``GF(p)``
- ``ZZ``
- ``QQ``
- ``RR(prec, tol)``
- ``CC(prec, tol)``
- ``ALG(a, b, c)``
- ``K[x, y, z]``
- ``K(x, y, z)``
- ``EX``
"""
if symbols is not None:
return K0.unify_with_symbols(K1, symbols)
if K0 == K1:
return K0
if K0.is_EX:
return K0
if K1.is_EX:
return K1
if K0.is_Composite or K1.is_Composite:
K0_ground = K0.dom if K0.is_Composite else K0
K1_ground = K1.dom if K1.is_Composite else K1
K0_symbols = K0.symbols if K0.is_Composite else ()
K1_symbols = K1.symbols if K1.is_Composite else ()
domain = K0_ground.unify(K1_ground)
symbols = _unify_gens(K0_symbols, K1_symbols)
order = K0.order if K0.is_Composite else K1.order
if ((K0.is_FractionField and K1.is_PolynomialRing or
K1.is_FractionField and K0.is_PolynomialRing) and
(not K0_ground.is_Field or not K1_ground.is_Field) and domain.is_Field):
domain = domain.get_ring()
if K0.is_Composite and (not K1.is_Composite or K0.is_FractionField or K1.is_PolynomialRing):
cls = K0.__class__
else:
cls = K1.__class__
from sympy.polys.domains.old_polynomialring import GlobalPolynomialRing
if cls == GlobalPolynomialRing:
return cls(domain, symbols)
return cls(domain, symbols, order)
def mkinexact(cls, K0, K1):
prec = max(K0.precision, K1.precision)
tol = max(K0.tolerance, K1.tolerance)
return cls(prec=prec, tol=tol)
if K0.is_ComplexField and K1.is_ComplexField:
return mkinexact(K0.__class__, K0, K1)
if K0.is_ComplexField and K1.is_RealField:
return mkinexact(K0.__class__, K0, K1)
if K0.is_RealField and K1.is_ComplexField:
return mkinexact(K1.__class__, K1, K0)
if K0.is_RealField and K1.is_RealField:
return mkinexact(K0.__class__, K0, K1)
if K0.is_ComplexField or K0.is_RealField:
return K0
if K1.is_ComplexField or K1.is_RealField:
return K1
if K0.is_AlgebraicField and K1.is_AlgebraicField:
return K0.__class__(K0.dom.unify(K1.dom), *_unify_gens(K0.orig_ext, K1.orig_ext))
elif K0.is_AlgebraicField:
return K0
elif K1.is_AlgebraicField:
return K1
if K0.is_RationalField:
return K0
if K1.is_RationalField:
return K1
if K0.is_IntegerRing:
return K0
if K1.is_IntegerRing:
return K1
if K0.is_FiniteField and K1.is_FiniteField:
return K0.__class__(max(K0.mod, K1.mod, key=default_sort_key))
from sympy.polys.domains import EX
return EX
def __eq__(self, other):
"""Returns ``True`` if two domains are equivalent. """
return isinstance(other, Domain) and self.dtype == other.dtype
def __ne__(self, other):
"""Returns ``False`` if two domains are equivalent. """
return not self == other
def map(self, seq):
"""Rersively apply ``self`` to all elements of ``seq``. """
result = []
for elt in seq:
if isinstance(elt, list):
result.append(self.map(elt))
else:
result.append(self(elt))
return result
def get_ring(self):
"""Returns a ring associated with ``self``. """
raise DomainError('there is no ring associated with %s' % self)
def get_field(self):
"""Returns a field associated with ``self``. """
raise DomainError('there is no field associated with %s' % self)
def get_exact(self):
"""Returns an exact domain associated with ``self``. """
return self
def __getitem__(self, symbols):
"""The mathematical way to make a polynomial ring. """
if hasattr(symbols, '__iter__'):
return self.poly_ring(*symbols)
else:
return self.poly_ring(symbols)
def poly_ring(self, *symbols, **kwargs):
"""Returns a polynomial ring, i.e. `K[X]`. """
from sympy.polys.domains.polynomialring import PolynomialRing
return PolynomialRing(self, symbols, kwargs.get("order", lex))
def frac_field(self, *symbols, **kwargs):
"""Returns a fraction field, i.e. `K(X)`. """
from sympy.polys.domains.fractionfield import FractionField
return FractionField(self, symbols, kwargs.get("order", lex))
def old_poly_ring(self, *symbols, **kwargs):
"""Returns a polynomial ring, i.e. `K[X]`. """
from sympy.polys.domains.old_polynomialring import PolynomialRing
return PolynomialRing(self, *symbols, **kwargs)
def old_frac_field(self, *symbols, **kwargs):
"""Returns a fraction field, i.e. `K(X)`. """
from sympy.polys.domains.old_fractionfield import FractionField
return FractionField(self, *symbols, **kwargs)
def algebraic_field(self, *extension):
r"""Returns an algebraic field, i.e. `K(\alpha, \ldots)`. """
raise DomainError("can't create algebraic field over %s" % self)
def inject(self, *symbols):
"""Inject generators into this domain. """
raise NotImplementedError
def is_zero(self, a):
"""Returns True if ``a`` is zero. """
return not a
def is_one(self, a):
"""Returns True if ``a`` is one. """
return a == self.one
def is_positive(self, a):
"""Returns True if ``a`` is positive. """
return a > 0
def is_negative(self, a):
"""Returns True if ``a`` is negative. """
return a < 0
def is_nonpositive(self, a):
"""Returns True if ``a`` is non-positive. """
return a <= 0
def is_nonnegative(self, a):
"""Returns True if ``a`` is non-negative. """
return a >= 0
def abs(self, a):
"""Absolute value of ``a``, implies ``__abs__``. """
return abs(a)
def neg(self, a):
"""Returns ``a`` negated, implies ``__neg__``. """
return -a
def pos(self, a):
"""Returns ``a`` positive, implies ``__pos__``. """
return +a
def add(self, a, b):
"""Sum of ``a`` and ``b``, implies ``__add__``. """
return a + b
def sub(self, a, b):
"""Difference of ``a`` and ``b``, implies ``__sub__``. """
return a - b
def mul(self, a, b):
"""Product of ``a`` and ``b``, implies ``__mul__``. """
return a * b
def pow(self, a, b):
"""Raise ``a`` to power ``b``, implies ``__pow__``. """
return a ** b
def exquo(self, a, b):
"""Exact quotient of ``a`` and ``b``, implies something. """
raise NotImplementedError
def quo(self, a, b):
"""Quotient of ``a`` and ``b``, implies something. """
raise NotImplementedError
def rem(self, a, b):
"""Remainder of ``a`` and ``b``, implies ``__mod__``. """
raise NotImplementedError
def div(self, a, b):
"""Division of ``a`` and ``b``, implies something. """
raise NotImplementedError
def invert(self, a, b):
"""Returns inversion of ``a mod b``, implies something. """
raise NotImplementedError
def revert(self, a):
"""Returns ``a**(-1)`` if possible. """
raise NotImplementedError
def numer(self, a):
"""Returns numerator of ``a``. """
raise NotImplementedError
def denom(self, a):
"""Returns denominator of ``a``. """
raise NotImplementedError
def half_gcdex(self, a, b):
"""Half extended GCD of ``a`` and ``b``. """
s, t, h = self.gcdex(a, b)
return s, h
def gcdex(self, a, b):
"""Extended GCD of ``a`` and ``b``. """
raise NotImplementedError
def cofactors(self, a, b):
"""Returns GCD and cofactors of ``a`` and ``b``. """
gcd = self.gcd(a, b)
cfa = self.quo(a, gcd)
cfb = self.quo(b, gcd)
return gcd, cfa, cfb
def gcd(self, a, b):
"""Returns GCD of ``a`` and ``b``. """
raise NotImplementedError
def lcm(self, a, b):
"""Returns LCM of ``a`` and ``b``. """
raise NotImplementedError
def log(self, a, b):
"""Returns b-base logarithm of ``a``. """
raise NotImplementedError
def sqrt(self, a):
"""Returns square root of ``a``. """
raise NotImplementedError
def evalf(self, a, prec=None, **options):
"""Returns numerical approximation of ``a``. """
return self.to_sympy(a).evalf(prec, **options)
n = evalf
def real(self, a):
return a
def imag(self, a):
return self.zero
def almosteq(self, a, b, tolerance=None):
"""Check if ``a`` and ``b`` are almost equal. """
return a == b
def characteristic(self):
"""Return the characteristic of this domain. """
raise NotImplementedError('characteristic()')
__all__ = ['Domain']
|
8a324fd073d6ff87fbbfb1643c5eb4d8173d376d22ecb63eccef7b54ea114896 | """Tools for polynomial factorization routines in characteristic zero. """
from sympy.polys.rings import ring, xring
from sympy.polys.domains import FF, ZZ, QQ, RR, EX
from sympy.polys import polyconfig as config
from sympy.polys.polyerrors import DomainError
from sympy.polys.polyclasses import ANP
from sympy.polys.specialpolys import f_polys, w_polys
from sympy import nextprime, sin, sqrt, I
from sympy.testing.pytest import raises, XFAIL
f_0, f_1, f_2, f_3, f_4, f_5, f_6 = f_polys()
w_1, w_2 = w_polys()
def test_dup_trial_division():
R, x = ring("x", ZZ)
assert R.dup_trial_division(x**5 + 8*x**4 + 25*x**3 + 38*x**2 + 28*x + 8, (x + 1, x + 2)) == [(x + 1, 2), (x + 2, 3)]
def test_dmp_trial_division():
R, x, y = ring("x,y", ZZ)
assert R.dmp_trial_division(x**5 + 8*x**4 + 25*x**3 + 38*x**2 + 28*x + 8, (x + 1, x + 2)) == [(x + 1, 2), (x + 2, 3)]
def test_dup_zz_mignotte_bound():
R, x = ring("x", ZZ)
assert R.dup_zz_mignotte_bound(2*x**2 + 3*x + 4) == 6
assert R.dup_zz_mignotte_bound(x**3 + 14*x**2 + 56*x + 64) == 152
def test_dmp_zz_mignotte_bound():
R, x, y = ring("x,y", ZZ)
assert R.dmp_zz_mignotte_bound(2*x**2 + 3*x + 4) == 32
def test_dup_zz_hensel_step():
R, x = ring("x", ZZ)
f = x**4 - 1
g = x**3 + 2*x**2 - x - 2
h = x - 2
s = -2
t = 2*x**2 - 2*x - 1
G, H, S, T = R.dup_zz_hensel_step(5, f, g, h, s, t)
assert G == x**3 + 7*x**2 - x - 7
assert H == x - 7
assert S == 8
assert T == -8*x**2 - 12*x - 1
def test_dup_zz_hensel_lift():
R, x = ring("x", ZZ)
f = x**4 - 1
F = [x - 1, x - 2, x + 2, x + 1]
assert R.dup_zz_hensel_lift(ZZ(5), f, F, 4) == \
[x - 1, x - 182, x + 182, x + 1]
def test_dup_zz_irreducible_p():
R, x = ring("x", ZZ)
assert R.dup_zz_irreducible_p(3*x**4 + 2*x**3 + 6*x**2 + 8*x + 7) is None
assert R.dup_zz_irreducible_p(3*x**4 + 2*x**3 + 6*x**2 + 8*x + 4) is None
assert R.dup_zz_irreducible_p(3*x**4 + 2*x**3 + 6*x**2 + 8*x + 10) is True
assert R.dup_zz_irreducible_p(3*x**4 + 2*x**3 + 6*x**2 + 8*x + 14) is True
def test_dup_cyclotomic_p():
R, x = ring("x", ZZ)
assert R.dup_cyclotomic_p(x - 1) is True
assert R.dup_cyclotomic_p(x + 1) is True
assert R.dup_cyclotomic_p(x**2 + x + 1) is True
assert R.dup_cyclotomic_p(x**2 + 1) is True
assert R.dup_cyclotomic_p(x**4 + x**3 + x**2 + x + 1) is True
assert R.dup_cyclotomic_p(x**2 - x + 1) is True
assert R.dup_cyclotomic_p(x**6 + x**5 + x**4 + x**3 + x**2 + x + 1) is True
assert R.dup_cyclotomic_p(x**4 + 1) is True
assert R.dup_cyclotomic_p(x**6 + x**3 + 1) is True
assert R.dup_cyclotomic_p(0) is False
assert R.dup_cyclotomic_p(1) is False
assert R.dup_cyclotomic_p(x) is False
assert R.dup_cyclotomic_p(x + 2) is False
assert R.dup_cyclotomic_p(3*x + 1) is False
assert R.dup_cyclotomic_p(x**2 - 1) is False
f = x**16 + x**14 - x**10 + x**8 - x**6 + x**2 + 1
assert R.dup_cyclotomic_p(f) is False
g = x**16 + x**14 - x**10 - x**8 - x**6 + x**2 + 1
assert R.dup_cyclotomic_p(g) is True
R, x = ring("x", QQ)
assert R.dup_cyclotomic_p(x**2 + x + 1) is True
assert R.dup_cyclotomic_p(QQ(1,2)*x**2 + x + 1) is False
R, x = ring("x", ZZ["y"])
assert R.dup_cyclotomic_p(x**2 + x + 1) is False
def test_dup_zz_cyclotomic_poly():
R, x = ring("x", ZZ)
assert R.dup_zz_cyclotomic_poly(1) == x - 1
assert R.dup_zz_cyclotomic_poly(2) == x + 1
assert R.dup_zz_cyclotomic_poly(3) == x**2 + x + 1
assert R.dup_zz_cyclotomic_poly(4) == x**2 + 1
assert R.dup_zz_cyclotomic_poly(5) == x**4 + x**3 + x**2 + x + 1
assert R.dup_zz_cyclotomic_poly(6) == x**2 - x + 1
assert R.dup_zz_cyclotomic_poly(7) == x**6 + x**5 + x**4 + x**3 + x**2 + x + 1
assert R.dup_zz_cyclotomic_poly(8) == x**4 + 1
assert R.dup_zz_cyclotomic_poly(9) == x**6 + x**3 + 1
def test_dup_zz_cyclotomic_factor():
R, x = ring("x", ZZ)
assert R.dup_zz_cyclotomic_factor(0) is None
assert R.dup_zz_cyclotomic_factor(1) is None
assert R.dup_zz_cyclotomic_factor(2*x**10 - 1) is None
assert R.dup_zz_cyclotomic_factor(x**10 - 3) is None
assert R.dup_zz_cyclotomic_factor(x**10 + x**5 - 1) is None
assert R.dup_zz_cyclotomic_factor(x + 1) == [x + 1]
assert R.dup_zz_cyclotomic_factor(x - 1) == [x - 1]
assert R.dup_zz_cyclotomic_factor(x**2 + 1) == [x**2 + 1]
assert R.dup_zz_cyclotomic_factor(x**2 - 1) == [x - 1, x + 1]
assert R.dup_zz_cyclotomic_factor(x**27 + 1) == \
[x + 1, x**2 - x + 1, x**6 - x**3 + 1, x**18 - x**9 + 1]
assert R.dup_zz_cyclotomic_factor(x**27 - 1) == \
[x - 1, x**2 + x + 1, x**6 + x**3 + 1, x**18 + x**9 + 1]
def test_dup_zz_factor():
R, x = ring("x", ZZ)
assert R.dup_zz_factor(0) == (0, [])
assert R.dup_zz_factor(7) == (7, [])
assert R.dup_zz_factor(-7) == (-7, [])
assert R.dup_zz_factor_sqf(0) == (0, [])
assert R.dup_zz_factor_sqf(7) == (7, [])
assert R.dup_zz_factor_sqf(-7) == (-7, [])
assert R.dup_zz_factor(2*x + 4) == (2, [(x + 2, 1)])
assert R.dup_zz_factor_sqf(2*x + 4) == (2, [x + 2])
f = x**4 + x + 1
for i in range(0, 20):
assert R.dup_zz_factor(f) == (1, [(f, 1)])
assert R.dup_zz_factor(x**2 + 2*x + 2) == \
(1, [(x**2 + 2*x + 2, 1)])
assert R.dup_zz_factor(18*x**2 + 12*x + 2) == \
(2, [(3*x + 1, 2)])
assert R.dup_zz_factor(-9*x**2 + 1) == \
(-1, [(3*x - 1, 1),
(3*x + 1, 1)])
assert R.dup_zz_factor_sqf(-9*x**2 + 1) == \
(-1, [3*x - 1,
3*x + 1])
assert R.dup_zz_factor(x**3 - 6*x**2 + 11*x - 6) == \
(1, [(x - 3, 1),
(x - 2, 1),
(x - 1, 1)])
assert R.dup_zz_factor_sqf(x**3 - 6*x**2 + 11*x - 6) == \
(1, [x - 3,
x - 2,
x - 1])
assert R.dup_zz_factor(3*x**3 + 10*x**2 + 13*x + 10) == \
(1, [(x + 2, 1),
(3*x**2 + 4*x + 5, 1)])
assert R.dup_zz_factor_sqf(3*x**3 + 10*x**2 + 13*x + 10) == \
(1, [x + 2,
3*x**2 + 4*x + 5])
assert R.dup_zz_factor(-x**6 + x**2) == \
(-1, [(x - 1, 1),
(x + 1, 1),
(x, 2),
(x**2 + 1, 1)])
f = 1080*x**8 + 5184*x**7 + 2099*x**6 + 744*x**5 + 2736*x**4 - 648*x**3 + 129*x**2 - 324
assert R.dup_zz_factor(f) == \
(1, [(5*x**4 + 24*x**3 + 9*x**2 + 12, 1),
(216*x**4 + 31*x**2 - 27, 1)])
f = -29802322387695312500000000000000000000*x**25 \
+ 2980232238769531250000000000000000*x**20 \
+ 1743435859680175781250000000000*x**15 \
+ 114142894744873046875000000*x**10 \
- 210106372833251953125*x**5 \
+ 95367431640625
assert R.dup_zz_factor(f) == \
(-95367431640625, [(5*x - 1, 1),
(100*x**2 + 10*x - 1, 2),
(625*x**4 + 125*x**3 + 25*x**2 + 5*x + 1, 1),
(10000*x**4 - 3000*x**3 + 400*x**2 - 20*x + 1, 2),
(10000*x**4 + 2000*x**3 + 400*x**2 + 30*x + 1, 2)])
f = x**10 - 1
config.setup('USE_CYCLOTOMIC_FACTOR', True)
F_0 = R.dup_zz_factor(f)
config.setup('USE_CYCLOTOMIC_FACTOR', False)
F_1 = R.dup_zz_factor(f)
assert F_0 == F_1 == \
(1, [(x - 1, 1),
(x + 1, 1),
(x**4 - x**3 + x**2 - x + 1, 1),
(x**4 + x**3 + x**2 + x + 1, 1)])
config.setup('USE_CYCLOTOMIC_FACTOR')
f = x**10 + 1
config.setup('USE_CYCLOTOMIC_FACTOR', True)
F_0 = R.dup_zz_factor(f)
config.setup('USE_CYCLOTOMIC_FACTOR', False)
F_1 = R.dup_zz_factor(f)
assert F_0 == F_1 == \
(1, [(x**2 + 1, 1),
(x**8 - x**6 + x**4 - x**2 + 1, 1)])
config.setup('USE_CYCLOTOMIC_FACTOR')
def test_dmp_zz_wang():
R, x,y,z = ring("x,y,z", ZZ)
UV, _x = ring("x", ZZ)
p = ZZ(nextprime(R.dmp_zz_mignotte_bound(w_1)))
assert p == 6291469
t_1, k_1, e_1 = y, 1, ZZ(-14)
t_2, k_2, e_2 = z, 2, ZZ(3)
t_3, k_3, e_3 = y + z, 2, ZZ(-11)
t_4, k_4, e_4 = y - z, 1, ZZ(-17)
T = [t_1, t_2, t_3, t_4]
K = [k_1, k_2, k_3, k_4]
E = [e_1, e_2, e_3, e_4]
T = zip([ t.drop(x) for t in T ], K)
A = [ZZ(-14), ZZ(3)]
S = R.dmp_eval_tail(w_1, A)
cs, s = UV.dup_primitive(S)
assert cs == 1 and s == S == \
1036728*_x**6 + 915552*_x**5 + 55748*_x**4 + 105621*_x**3 - 17304*_x**2 - 26841*_x - 644
assert R.dmp_zz_wang_non_divisors(E, cs, ZZ(4)) == [7, 3, 11, 17]
assert UV.dup_sqf_p(s) and UV.dup_degree(s) == R.dmp_degree(w_1)
_, H = UV.dup_zz_factor_sqf(s)
h_1 = 44*_x**2 + 42*_x + 1
h_2 = 126*_x**2 - 9*_x + 28
h_3 = 187*_x**2 - 23
assert H == [h_1, h_2, h_3]
LC = [ lc.drop(x) for lc in [-4*y - 4*z, -y*z**2, y**2 - z**2] ]
assert R.dmp_zz_wang_lead_coeffs(w_1, T, cs, E, H, A) == (w_1, H, LC)
factors = R.dmp_zz_wang_hensel_lifting(w_1, H, LC, A, p)
assert R.dmp_expand(factors) == w_1
@XFAIL
def test_dmp_zz_wang_fail():
R, x,y,z = ring("x,y,z", ZZ)
UV, _x = ring("x", ZZ)
p = ZZ(nextprime(R.dmp_zz_mignotte_bound(w_1)))
assert p == 6291469
H_1 = [44*x**2 + 42*x + 1, 126*x**2 - 9*x + 28, 187*x**2 - 23]
H_2 = [-4*x**2*y - 12*x**2 - 3*x*y + 1, -9*x**2*y - 9*x - 2*y, x**2*y**2 - 9*x**2 + y - 9]
H_3 = [-4*x**2*y - 12*x**2 - 3*x*y + 1, -9*x**2*y - 9*x - 2*y, x**2*y**2 - 9*x**2 + y - 9]
c_1 = -70686*x**5 - 5863*x**4 - 17826*x**3 + 2009*x**2 + 5031*x + 74
c_2 = 9*x**5*y**4 + 12*x**5*y**3 - 45*x**5*y**2 - 108*x**5*y - 324*x**5 + 18*x**4*y**3 - 216*x**4*y**2 - 810*x**4*y + 2*x**3*y**4 + 9*x**3*y**3 - 252*x**3*y**2 - 288*x**3*y - 945*x**3 - 30*x**2*y**2 - 414*x**2*y + 2*x*y**3 - 54*x*y**2 - 3*x*y + 81*x + 12*y
c_3 = -36*x**4*y**2 - 108*x**4*y - 27*x**3*y**2 - 36*x**3*y - 108*x**3 - 8*x**2*y**2 - 42*x**2*y - 6*x*y**2 + 9*x + 2*y
assert R.dmp_zz_diophantine(H_1, c_1, [], 5, p) == [-3*x, -2, 1]
assert R.dmp_zz_diophantine(H_2, c_2, [ZZ(-14)], 5, p) == [-x*y, -3*x, -6]
assert R.dmp_zz_diophantine(H_3, c_3, [ZZ(-14)], 5, p) == [0, 0, -1]
def test_issue_6355():
# This tests a bug in the Wang algorithm that occurred only with a very
# specific set of random numbers.
random_sequence = [-1, -1, 0, 0, 0, 0, -1, -1, 0, -1, 3, -1, 3, 3, 3, 3, -1, 3]
R, x, y, z = ring("x,y,z", ZZ)
f = 2*x**2 + y*z - y - z**2 + z
assert R.dmp_zz_wang(f, seed=random_sequence) == [f]
def test_dmp_zz_factor():
R, x = ring("x", ZZ)
assert R.dmp_zz_factor(0) == (0, [])
assert R.dmp_zz_factor(7) == (7, [])
assert R.dmp_zz_factor(-7) == (-7, [])
assert R.dmp_zz_factor(x**2 - 9) == (1, [(x - 3, 1), (x + 3, 1)])
R, x, y = ring("x,y", ZZ)
assert R.dmp_zz_factor(0) == (0, [])
assert R.dmp_zz_factor(7) == (7, [])
assert R.dmp_zz_factor(-7) == (-7, [])
assert R.dmp_zz_factor(x) == (1, [(x, 1)])
assert R.dmp_zz_factor(4*x) == (4, [(x, 1)])
assert R.dmp_zz_factor(4*x + 2) == (2, [(2*x + 1, 1)])
assert R.dmp_zz_factor(x*y + 1) == (1, [(x*y + 1, 1)])
assert R.dmp_zz_factor(y**2 + 1) == (1, [(y**2 + 1, 1)])
assert R.dmp_zz_factor(y**2 - 1) == (1, [(y - 1, 1), (y + 1, 1)])
assert R.dmp_zz_factor(x**2*y**2 + 6*x**2*y + 9*x**2 - 1) == (1, [(x*y + 3*x - 1, 1), (x*y + 3*x + 1, 1)])
assert R.dmp_zz_factor(x**2*y**2 - 9) == (1, [(x*y - 3, 1), (x*y + 3, 1)])
R, x, y, z = ring("x,y,z", ZZ)
assert R.dmp_zz_factor(x**2*y**2*z**2 - 9) == \
(1, [(x*y*z - 3, 1),
(x*y*z + 3, 1)])
R, x, y, z, u = ring("x,y,z,u", ZZ)
assert R.dmp_zz_factor(x**2*y**2*z**2*u**2 - 9) == \
(1, [(x*y*z*u - 3, 1),
(x*y*z*u + 3, 1)])
R, x, y, z = ring("x,y,z", ZZ)
assert R.dmp_zz_factor(f_1) == \
(1, [(x + y*z + 20, 1),
(x*y + z + 10, 1),
(x*z + y + 30, 1)])
assert R.dmp_zz_factor(f_2) == \
(1, [(x**2*y**2 + x**2*z**2 + y + 90, 1),
(x**3*y + x**3*z + z - 11, 1)])
assert R.dmp_zz_factor(f_3) == \
(1, [(x**2*y**2 + x*z**4 + x + z, 1),
(x**3 + x*y*z + y**2 + y*z**3, 1)])
assert R.dmp_zz_factor(f_4) == \
(-1, [(x*y**3 + z**2, 1),
(x**2*z + y**4*z**2 + 5, 1),
(x**3*y - z**2 - 3, 1),
(x**3*y**4 + z**2, 1)])
assert R.dmp_zz_factor(f_5) == \
(-1, [(x + y - z, 3)])
R, x, y, z, t = ring("x,y,z,t", ZZ)
assert R.dmp_zz_factor(f_6) == \
(1, [(47*x*y + z**3*t**2 - t**2, 1),
(45*x**3 - 9*y**3 - y**2 + 3*z**3 + 2*z*t, 1)])
R, x, y, z = ring("x,y,z", ZZ)
assert R.dmp_zz_factor(w_1) == \
(1, [(x**2*y**2 - x**2*z**2 + y - z**2, 1),
(x**2*y*z**2 + 3*x*z + 2*y, 1),
(4*x**2*y + 4*x**2*z + x*y*z - 1, 1)])
R, x, y = ring("x,y", ZZ)
f = -12*x**16*y + 240*x**12*y**3 - 768*x**10*y**4 + 1080*x**8*y**5 - 768*x**6*y**6 + 240*x**4*y**7 - 12*y**9
assert R.dmp_zz_factor(f) == \
(-12, [(y, 1),
(x**2 - y, 6),
(x**4 + 6*x**2*y + y**2, 1)])
def test_dup_ext_factor():
R, x = ring("x", QQ.algebraic_field(I))
def anp(element):
return ANP(element, [QQ(1), QQ(0), QQ(1)], QQ)
assert R.dup_ext_factor(0) == (anp([]), [])
f = anp([QQ(1)])*x + anp([QQ(1)])
assert R.dup_ext_factor(f) == (anp([QQ(1)]), [(f, 1)])
g = anp([QQ(2)])*x + anp([QQ(2)])
assert R.dup_ext_factor(g) == (anp([QQ(2)]), [(f, 1)])
f = anp([QQ(7)])*x**4 + anp([QQ(1, 1)])
g = anp([QQ(1)])*x**4 + anp([QQ(1, 7)])
assert R.dup_ext_factor(f) == (anp([QQ(7)]), [(g, 1)])
f = anp([QQ(1)])*x**4 + anp([QQ(1)])
assert R.dup_ext_factor(f) == \
(anp([QQ(1, 1)]), [(anp([QQ(1)])*x**2 + anp([QQ(-1), QQ(0)]), 1),
(anp([QQ(1)])*x**2 + anp([QQ( 1), QQ(0)]), 1)])
f = anp([QQ(4, 1)])*x**2 + anp([QQ(9, 1)])
assert R.dup_ext_factor(f) == \
(anp([QQ(4, 1)]), [(anp([QQ(1, 1)])*x + anp([-QQ(3, 2), QQ(0, 1)]), 1),
(anp([QQ(1, 1)])*x + anp([ QQ(3, 2), QQ(0, 1)]), 1)])
f = anp([QQ(4, 1)])*x**4 + anp([QQ(8, 1)])*x**3 + anp([QQ(77, 1)])*x**2 + anp([QQ(18, 1)])*x + anp([QQ(153, 1)])
assert R.dup_ext_factor(f) == \
(anp([QQ(4, 1)]), [(anp([QQ(1, 1)])*x + anp([-QQ(4, 1), QQ(1, 1)]), 1),
(anp([QQ(1, 1)])*x + anp([-QQ(3, 2), QQ(0, 1)]), 1),
(anp([QQ(1, 1)])*x + anp([ QQ(3, 2), QQ(0, 1)]), 1),
(anp([QQ(1, 1)])*x + anp([ QQ(4, 1), QQ(1, 1)]), 1)])
R, x = ring("x", QQ.algebraic_field(sqrt(2)))
def anp(element):
return ANP(element, [QQ(1), QQ(0), QQ(-2)], QQ)
f = anp([QQ(1)])*x**4 + anp([QQ(1, 1)])
assert R.dup_ext_factor(f) == \
(anp([QQ(1)]), [(anp([QQ(1)])*x**2 + anp([QQ(-1), QQ(0)])*x + anp([QQ(1)]), 1),
(anp([QQ(1)])*x**2 + anp([QQ( 1), QQ(0)])*x + anp([QQ(1)]), 1)])
f = anp([QQ(1, 1)])*x**2 + anp([QQ(2), QQ(0)])*x + anp([QQ(2, 1)])
assert R.dup_ext_factor(f) == \
(anp([QQ(1, 1)]), [(anp([1])*x + anp([1, 0]), 2)])
assert R.dup_ext_factor(f**3) == \
(anp([QQ(1, 1)]), [(anp([1])*x + anp([1, 0]), 6)])
f *= anp([QQ(2, 1)])
assert R.dup_ext_factor(f) == \
(anp([QQ(2, 1)]), [(anp([1])*x + anp([1, 0]), 2)])
assert R.dup_ext_factor(f**3) == \
(anp([QQ(8, 1)]), [(anp([1])*x + anp([1, 0]), 6)])
def test_dmp_ext_factor():
R, x,y = ring("x,y", QQ.algebraic_field(sqrt(2)))
def anp(x):
return ANP(x, [QQ(1), QQ(0), QQ(-2)], QQ)
assert R.dmp_ext_factor(0) == (anp([]), [])
f = anp([QQ(1)])*x + anp([QQ(1)])
assert R.dmp_ext_factor(f) == (anp([QQ(1)]), [(f, 1)])
g = anp([QQ(2)])*x + anp([QQ(2)])
assert R.dmp_ext_factor(g) == (anp([QQ(2)]), [(f, 1)])
f = anp([QQ(1)])*x**2 + anp([QQ(-2)])*y**2
assert R.dmp_ext_factor(f) == \
(anp([QQ(1)]), [(anp([QQ(1)])*x + anp([QQ(-1), QQ(0)])*y, 1),
(anp([QQ(1)])*x + anp([QQ( 1), QQ(0)])*y, 1)])
f = anp([QQ(2)])*x**2 + anp([QQ(-4)])*y**2
assert R.dmp_ext_factor(f) == \
(anp([QQ(2)]), [(anp([QQ(1)])*x + anp([QQ(-1), QQ(0)])*y, 1),
(anp([QQ(1)])*x + anp([QQ( 1), QQ(0)])*y, 1)])
def test_dup_factor_list():
R, x = ring("x", ZZ)
assert R.dup_factor_list(0) == (0, [])
assert R.dup_factor_list(7) == (7, [])
R, x = ring("x", QQ)
assert R.dup_factor_list(0) == (0, [])
assert R.dup_factor_list(QQ(1, 7)) == (QQ(1, 7), [])
R, x = ring("x", ZZ['t'])
assert R.dup_factor_list(0) == (0, [])
assert R.dup_factor_list(7) == (7, [])
R, x = ring("x", QQ['t'])
assert R.dup_factor_list(0) == (0, [])
assert R.dup_factor_list(QQ(1, 7)) == (QQ(1, 7), [])
R, x = ring("x", ZZ)
assert R.dup_factor_list_include(0) == [(0, 1)]
assert R.dup_factor_list_include(7) == [(7, 1)]
assert R.dup_factor_list(x**2 + 2*x + 1) == (1, [(x + 1, 2)])
assert R.dup_factor_list_include(x**2 + 2*x + 1) == [(x + 1, 2)]
# issue 8037
assert R.dup_factor_list(6*x**2 - 5*x - 6) == (1, [(2*x - 3, 1), (3*x + 2, 1)])
R, x = ring("x", QQ)
assert R.dup_factor_list(QQ(1,2)*x**2 + x + QQ(1,2)) == (QQ(1, 2), [(x + 1, 2)])
R, x = ring("x", FF(2))
assert R.dup_factor_list(x**2 + 1) == (1, [(x + 1, 2)])
R, x = ring("x", RR)
assert R.dup_factor_list(1.0*x**2 + 2.0*x + 1.0) == (1.0, [(1.0*x + 1.0, 2)])
assert R.dup_factor_list(2.0*x**2 + 4.0*x + 2.0) == (2.0, [(1.0*x + 1.0, 2)])
f = 6.7225336055071*x**2 - 10.6463972754741*x - 0.33469524022264
coeff, factors = R.dup_factor_list(f)
assert coeff == RR(10.6463972754741)
assert len(factors) == 1
assert factors[0][0].max_norm() == RR(1.0)
assert factors[0][1] == 1
Rt, t = ring("t", ZZ)
R, x = ring("x", Rt)
f = 4*t*x**2 + 4*t**2*x
assert R.dup_factor_list(f) == \
(4*t, [(x, 1),
(x + t, 1)])
Rt, t = ring("t", QQ)
R, x = ring("x", Rt)
f = QQ(1, 2)*t*x**2 + QQ(1, 2)*t**2*x
assert R.dup_factor_list(f) == \
(QQ(1, 2)*t, [(x, 1),
(x + t, 1)])
R, x = ring("x", QQ.algebraic_field(I))
def anp(element):
return ANP(element, [QQ(1), QQ(0), QQ(1)], QQ)
f = anp([QQ(1, 1)])*x**4 + anp([QQ(2, 1)])*x**2
assert R.dup_factor_list(f) == \
(anp([QQ(1, 1)]), [(anp([QQ(1, 1)])*x, 2),
(anp([QQ(1, 1)])*x**2 + anp([])*x + anp([QQ(2, 1)]), 1)])
R, x = ring("x", EX)
raises(DomainError, lambda: R.dup_factor_list(EX(sin(1))))
def test_dmp_factor_list():
R, x, y = ring("x,y", ZZ)
assert R.dmp_factor_list(0) == (ZZ(0), [])
assert R.dmp_factor_list(7) == (7, [])
R, x, y = ring("x,y", QQ)
assert R.dmp_factor_list(0) == (QQ(0), [])
assert R.dmp_factor_list(QQ(1, 7)) == (QQ(1, 7), [])
Rt, t = ring("t", ZZ)
R, x, y = ring("x,y", Rt)
assert R.dmp_factor_list(0) == (0, [])
assert R.dmp_factor_list(7) == (ZZ(7), [])
Rt, t = ring("t", QQ)
R, x, y = ring("x,y", Rt)
assert R.dmp_factor_list(0) == (0, [])
assert R.dmp_factor_list(QQ(1, 7)) == (QQ(1, 7), [])
R, x, y = ring("x,y", ZZ)
assert R.dmp_factor_list_include(0) == [(0, 1)]
assert R.dmp_factor_list_include(7) == [(7, 1)]
R, X = xring("x:200", ZZ)
f, g = X[0]**2 + 2*X[0] + 1, X[0] + 1
assert R.dmp_factor_list(f) == (1, [(g, 2)])
f, g = X[-1]**2 + 2*X[-1] + 1, X[-1] + 1
assert R.dmp_factor_list(f) == (1, [(g, 2)])
R, x = ring("x", ZZ)
assert R.dmp_factor_list(x**2 + 2*x + 1) == (1, [(x + 1, 2)])
R, x = ring("x", QQ)
assert R.dmp_factor_list(QQ(1,2)*x**2 + x + QQ(1,2)) == (QQ(1,2), [(x + 1, 2)])
R, x, y = ring("x,y", ZZ)
assert R.dmp_factor_list(x**2 + 2*x + 1) == (1, [(x + 1, 2)])
R, x, y = ring("x,y", QQ)
assert R.dmp_factor_list(QQ(1,2)*x**2 + x + QQ(1,2)) == (QQ(1,2), [(x + 1, 2)])
R, x, y = ring("x,y", ZZ)
f = 4*x**2*y + 4*x*y**2
assert R.dmp_factor_list(f) == \
(4, [(y, 1),
(x, 1),
(x + y, 1)])
assert R.dmp_factor_list_include(f) == \
[(4*y, 1),
(x, 1),
(x + y, 1)]
R, x, y = ring("x,y", QQ)
f = QQ(1,2)*x**2*y + QQ(1,2)*x*y**2
assert R.dmp_factor_list(f) == \
(QQ(1,2), [(y, 1),
(x, 1),
(x + y, 1)])
R, x, y = ring("x,y", RR)
f = 2.0*x**2 - 8.0*y**2
assert R.dmp_factor_list(f) == \
(RR(8.0), [(0.5*x - y, 1),
(0.5*x + y, 1)])
f = 6.7225336055071*x**2*y**2 - 10.6463972754741*x*y - 0.33469524022264
coeff, factors = R.dmp_factor_list(f)
assert coeff == RR(10.6463972754741)
assert len(factors) == 1
assert factors[0][0].max_norm() == RR(1.0)
assert factors[0][1] == 1
Rt, t = ring("t", ZZ)
R, x, y = ring("x,y", Rt)
f = 4*t*x**2 + 4*t**2*x
assert R.dmp_factor_list(f) == \
(4*t, [(x, 1),
(x + t, 1)])
Rt, t = ring("t", QQ)
R, x, y = ring("x,y", Rt)
f = QQ(1, 2)*t*x**2 + QQ(1, 2)*t**2*x
assert R.dmp_factor_list(f) == \
(QQ(1, 2)*t, [(x, 1),
(x + t, 1)])
R, x, y = ring("x,y", FF(2))
raises(NotImplementedError, lambda: R.dmp_factor_list(x**2 + y**2))
R, x, y = ring("x,y", EX)
raises(DomainError, lambda: R.dmp_factor_list(EX(sin(1))))
def test_dup_irreducible_p():
R, x = ring("x", ZZ)
assert R.dup_irreducible_p(x**2 + x + 1) is True
assert R.dup_irreducible_p(x**2 + 2*x + 1) is False
def test_dmp_irreducible_p():
R, x, y = ring("x,y", ZZ)
assert R.dmp_irreducible_p(x**2 + x + 1) is True
assert R.dmp_irreducible_p(x**2 + 2*x + 1) is False
|
d9814e1a866b230bd1a74de0f9fbf561f1ede60a1da3f3182bbfc59cf626dcdc | """Tests for the implementation of RootOf class and related tools. """
from sympy.polys.polytools import Poly
from sympy.polys.rootoftools import (rootof, RootOf, CRootOf, RootSum,
_pure_key_dict as D)
from sympy.polys.polyerrors import (
MultivariatePolynomialError,
GeneratorsNeeded,
PolynomialError,
)
from sympy import (
S, sqrt, I, Rational, Float, Lambda, log, exp, tan, Function, Eq,
solve, legendre_poly, Integral
)
from sympy.testing.pytest import raises, slow
from sympy.core.expr import unchanged
from sympy.abc import a, b, x, y, z, r
def test_CRootOf___new__():
assert rootof(x, 0) == 0
assert rootof(x, -1) == 0
assert rootof(x, S.Zero) == 0
assert rootof(x - 1, 0) == 1
assert rootof(x - 1, -1) == 1
assert rootof(x + 1, 0) == -1
assert rootof(x + 1, -1) == -1
assert rootof(x**2 + 2*x + 3, 0) == -1 - I*sqrt(2)
assert rootof(x**2 + 2*x + 3, 1) == -1 + I*sqrt(2)
assert rootof(x**2 + 2*x + 3, -1) == -1 + I*sqrt(2)
assert rootof(x**2 + 2*x + 3, -2) == -1 - I*sqrt(2)
r = rootof(x**2 + 2*x + 3, 0, radicals=False)
assert isinstance(r, RootOf) is True
r = rootof(x**2 + 2*x + 3, 1, radicals=False)
assert isinstance(r, RootOf) is True
r = rootof(x**2 + 2*x + 3, -1, radicals=False)
assert isinstance(r, RootOf) is True
r = rootof(x**2 + 2*x + 3, -2, radicals=False)
assert isinstance(r, RootOf) is True
assert rootof((x - 1)*(x + 1), 0, radicals=False) == -1
assert rootof((x - 1)*(x + 1), 1, radicals=False) == 1
assert rootof((x - 1)*(x + 1), -1, radicals=False) == 1
assert rootof((x - 1)*(x + 1), -2, radicals=False) == -1
assert rootof((x - 1)*(x + 1), 0, radicals=True) == -1
assert rootof((x - 1)*(x + 1), 1, radicals=True) == 1
assert rootof((x - 1)*(x + 1), -1, radicals=True) == 1
assert rootof((x - 1)*(x + 1), -2, radicals=True) == -1
assert rootof((x - 1)*(x**3 + x + 3), 0) == rootof(x**3 + x + 3, 0)
assert rootof((x - 1)*(x**3 + x + 3), 1) == 1
assert rootof((x - 1)*(x**3 + x + 3), 2) == rootof(x**3 + x + 3, 1)
assert rootof((x - 1)*(x**3 + x + 3), 3) == rootof(x**3 + x + 3, 2)
assert rootof((x - 1)*(x**3 + x + 3), -1) == rootof(x**3 + x + 3, 2)
assert rootof((x - 1)*(x**3 + x + 3), -2) == rootof(x**3 + x + 3, 1)
assert rootof((x - 1)*(x**3 + x + 3), -3) == 1
assert rootof((x - 1)*(x**3 + x + 3), -4) == rootof(x**3 + x + 3, 0)
assert rootof(x**4 + 3*x**3, 0) == -3
assert rootof(x**4 + 3*x**3, 1) == 0
assert rootof(x**4 + 3*x**3, 2) == 0
assert rootof(x**4 + 3*x**3, 3) == 0
raises(GeneratorsNeeded, lambda: rootof(0, 0))
raises(GeneratorsNeeded, lambda: rootof(1, 0))
raises(PolynomialError, lambda: rootof(Poly(0, x), 0))
raises(PolynomialError, lambda: rootof(Poly(1, x), 0))
raises(PolynomialError, lambda: rootof(x - y, 0))
# issue 8617
raises(PolynomialError, lambda: rootof(exp(x), 0))
raises(NotImplementedError, lambda: rootof(x**3 - x + sqrt(2), 0))
raises(NotImplementedError, lambda: rootof(x**3 - x + I, 0))
raises(IndexError, lambda: rootof(x**2 - 1, -4))
raises(IndexError, lambda: rootof(x**2 - 1, -3))
raises(IndexError, lambda: rootof(x**2 - 1, 2))
raises(IndexError, lambda: rootof(x**2 - 1, 3))
raises(ValueError, lambda: rootof(x**2 - 1, x))
assert rootof(Poly(x - y, x), 0) == y
assert rootof(Poly(x**2 - y, x), 0) == -sqrt(y)
assert rootof(Poly(x**2 - y, x), 1) == sqrt(y)
assert rootof(Poly(x**3 - y, x), 0) == y**Rational(1, 3)
assert rootof(y*x**3 + y*x + 2*y, x, 0) == -1
raises(NotImplementedError, lambda: rootof(x**3 + x + 2*y, x, 0))
assert rootof(x**3 + x + 1, 0).is_commutative is True
def test_CRootOf_attributes():
r = rootof(x**3 + x + 3, 0)
assert r.is_number
assert r.free_symbols == set()
# if the following assertion fails then multivariate polynomials
# are apparently supported and the RootOf.free_symbols routine
# should be changed to return whatever symbols would not be
# the PurePoly dummy symbol
raises(NotImplementedError, lambda: rootof(Poly(x**3 + y*x + 1, x), 0))
def test_CRootOf___eq__():
assert (rootof(x**3 + x + 3, 0) == rootof(x**3 + x + 3, 0)) is True
assert (rootof(x**3 + x + 3, 0) == rootof(x**3 + x + 3, 1)) is False
assert (rootof(x**3 + x + 3, 1) == rootof(x**3 + x + 3, 1)) is True
assert (rootof(x**3 + x + 3, 1) == rootof(x**3 + x + 3, 2)) is False
assert (rootof(x**3 + x + 3, 2) == rootof(x**3 + x + 3, 2)) is True
assert (rootof(x**3 + x + 3, 0) == rootof(y**3 + y + 3, 0)) is True
assert (rootof(x**3 + x + 3, 0) == rootof(y**3 + y + 3, 1)) is False
assert (rootof(x**3 + x + 3, 1) == rootof(y**3 + y + 3, 1)) is True
assert (rootof(x**3 + x + 3, 1) == rootof(y**3 + y + 3, 2)) is False
assert (rootof(x**3 + x + 3, 2) == rootof(y**3 + y + 3, 2)) is True
def test_CRootOf___eval_Eq__():
f = Function('f')
eq = x**3 + x + 3
r = rootof(eq, 2)
r1 = rootof(eq, 1)
assert Eq(r, r1) is S.false
assert Eq(r, r) is S.true
assert unchanged(Eq, r, x)
assert Eq(r, 0) is S.false
assert Eq(r, S.Infinity) is S.false
assert Eq(r, I) is S.false
assert unchanged(Eq, r, f(0))
sol = solve(eq)
for s in sol:
if s.is_real:
assert Eq(r, s) is S.false
r = rootof(eq, 0)
for s in sol:
if s.is_real:
assert Eq(r, s) is S.true
eq = x**3 + x + 1
sol = solve(eq)
assert [Eq(rootof(eq, i), j) for i in range(3) for j in sol] == [
False, False, True, False, True, False, True, False, False]
assert Eq(rootof(eq, 0), 1 + S.ImaginaryUnit) == False
def test_CRootOf_is_real():
assert rootof(x**3 + x + 3, 0).is_real is True
assert rootof(x**3 + x + 3, 1).is_real is False
assert rootof(x**3 + x + 3, 2).is_real is False
def test_CRootOf_is_complex():
assert rootof(x**3 + x + 3, 0).is_complex is True
def test_CRootOf_subs():
assert rootof(x**3 + x + 1, 0).subs(x, y) == rootof(y**3 + y + 1, 0)
def test_CRootOf_diff():
assert rootof(x**3 + x + 1, 0).diff(x) == 0
assert rootof(x**3 + x + 1, 0).diff(y) == 0
@slow
def test_CRootOf_evalf():
real = rootof(x**3 + x + 3, 0).evalf(n=20)
assert real.epsilon_eq(Float("-1.2134116627622296341"))
re, im = rootof(x**3 + x + 3, 1).evalf(n=20).as_real_imag()
assert re.epsilon_eq( Float("0.60670583138111481707"))
assert im.epsilon_eq(-Float("1.45061224918844152650"))
re, im = rootof(x**3 + x + 3, 2).evalf(n=20).as_real_imag()
assert re.epsilon_eq(Float("0.60670583138111481707"))
assert im.epsilon_eq(Float("1.45061224918844152650"))
p = legendre_poly(4, x, polys=True)
roots = [str(r.n(17)) for r in p.real_roots()]
# magnitudes are given by
# sqrt(3/S(7) - 2*sqrt(6/S(5))/7)
# and
# sqrt(3/S(7) + 2*sqrt(6/S(5))/7)
assert roots == [
"-0.86113631159405258",
"-0.33998104358485626",
"0.33998104358485626",
"0.86113631159405258",
]
re = rootof(x**5 - 5*x + 12, 0).evalf(n=20)
assert re.epsilon_eq(Float("-1.84208596619025438271"))
re, im = rootof(x**5 - 5*x + 12, 1).evalf(n=20).as_real_imag()
assert re.epsilon_eq(Float("-0.351854240827371999559"))
assert im.epsilon_eq(Float("-1.709561043370328882010"))
re, im = rootof(x**5 - 5*x + 12, 2).evalf(n=20).as_real_imag()
assert re.epsilon_eq(Float("-0.351854240827371999559"))
assert im.epsilon_eq(Float("+1.709561043370328882010"))
re, im = rootof(x**5 - 5*x + 12, 3).evalf(n=20).as_real_imag()
assert re.epsilon_eq(Float("+1.272897223922499190910"))
assert im.epsilon_eq(Float("-0.719798681483861386681"))
re, im = rootof(x**5 - 5*x + 12, 4).evalf(n=20).as_real_imag()
assert re.epsilon_eq(Float("+1.272897223922499190910"))
assert im.epsilon_eq(Float("+0.719798681483861386681"))
# issue 6393
assert str(rootof(x**5 + 2*x**4 + x**3 - 68719476736, 0).n(3)) == '147.'
eq = (531441*x**11 + 3857868*x**10 + 13730229*x**9 + 32597882*x**8 +
55077472*x**7 + 60452000*x**6 + 32172064*x**5 - 4383808*x**4 -
11942912*x**3 - 1506304*x**2 + 1453312*x + 512)
a, b = rootof(eq, 1).n(2).as_real_imag()
c, d = rootof(eq, 2).n(2).as_real_imag()
assert a == c
assert b < d
assert b == -d
# issue 6451
r = rootof(legendre_poly(64, x), 7)
assert r.n(2) == r.n(100).n(2)
# issue 9019
r0 = rootof(x**2 + 1, 0, radicals=False)
r1 = rootof(x**2 + 1, 1, radicals=False)
assert r0.n(4) == -1.0*I
assert r1.n(4) == 1.0*I
# make sure verification is used in case a max/min traps the "root"
assert str(rootof(4*x**5 + 16*x**3 + 12*x**2 + 7, 0).n(3)) == '-0.976'
# watch out for UnboundLocalError
c = CRootOf(90720*x**6 - 4032*x**4 + 84*x**2 - 1, 0)
assert c._eval_evalf(2) # doesn't fail
# watch out for imaginary parts that don't want to evaluate
assert str(RootOf(x**16 + 32*x**14 + 508*x**12 + 5440*x**10 +
39510*x**8 + 204320*x**6 + 755548*x**4 + 1434496*x**2 +
877969, 10).n(2)) == '-3.4*I'
assert abs(RootOf(x**4 + 10*x**2 + 1, 0).n(2)) < 0.4
# check reset and args
r = [RootOf(x**3 + x + 3, i) for i in range(3)]
r[0]._reset()
for ri in r:
i = ri._get_interval()
ri.n(2)
assert i != ri._get_interval()
ri._reset()
assert i == ri._get_interval()
assert i == i.func(*i.args)
def test_CRootOf_evalf_caching_bug():
r = rootof(x**5 - 5*x + 12, 1)
r.n()
a = r._get_interval()
r = rootof(x**5 - 5*x + 12, 1)
r.n()
b = r._get_interval()
assert a == b
def test_CRootOf_real_roots():
assert Poly(x**5 + x + 1).real_roots() == [rootof(x**3 - x**2 + 1, 0)]
assert Poly(x**5 + x + 1).real_roots(radicals=False) == [rootof(
x**3 - x**2 + 1, 0)]
def test_CRootOf_all_roots():
assert Poly(x**5 + x + 1).all_roots() == [
rootof(x**3 - x**2 + 1, 0),
Rational(-1, 2) - sqrt(3)*I/2,
Rational(-1, 2) + sqrt(3)*I/2,
rootof(x**3 - x**2 + 1, 1),
rootof(x**3 - x**2 + 1, 2),
]
assert Poly(x**5 + x + 1).all_roots(radicals=False) == [
rootof(x**3 - x**2 + 1, 0),
rootof(x**2 + x + 1, 0, radicals=False),
rootof(x**2 + x + 1, 1, radicals=False),
rootof(x**3 - x**2 + 1, 1),
rootof(x**3 - x**2 + 1, 2),
]
def test_CRootOf_eval_rational():
p = legendre_poly(4, x, polys=True)
roots = [r.eval_rational(n=18) for r in p.real_roots()]
for root in roots:
assert isinstance(root, Rational)
roots = [str(root.n(17)) for root in roots]
assert roots == [
"-0.86113631159405258",
"-0.33998104358485626",
"0.33998104358485626",
"0.86113631159405258",
]
def test_RootSum___new__():
f = x**3 + x + 3
g = Lambda(r, log(r*x))
s = RootSum(f, g)
assert isinstance(s, RootSum) is True
assert RootSum(f**2, g) == 2*RootSum(f, g)
assert RootSum((x - 7)*f**3, g) == log(7*x) + 3*RootSum(f, g)
# issue 5571
assert hash(RootSum((x - 7)*f**3, g)) == hash(log(7*x) + 3*RootSum(f, g))
raises(MultivariatePolynomialError, lambda: RootSum(x**3 + x + y))
raises(ValueError, lambda: RootSum(x**2 + 3, lambda x: x))
assert RootSum(f, exp) == RootSum(f, Lambda(x, exp(x)))
assert RootSum(f, log) == RootSum(f, Lambda(x, log(x)))
assert isinstance(RootSum(f, auto=False), RootSum) is True
assert RootSum(f) == 0
assert RootSum(f, Lambda(x, x)) == 0
assert RootSum(f, Lambda(x, x**2)) == -2
assert RootSum(f, Lambda(x, 1)) == 3
assert RootSum(f, Lambda(x, 2)) == 6
assert RootSum(f, auto=False).is_commutative is True
assert RootSum(f, Lambda(x, 1/(x + x**2))) == Rational(11, 3)
assert RootSum(f, Lambda(x, y/(x + x**2))) == Rational(11, 3)*y
assert RootSum(x**2 - 1, Lambda(x, 3*x**2), x) == 6
assert RootSum(x**2 - y, Lambda(x, 3*x**2), x) == 6*y
assert RootSum(x**2 - 1, Lambda(x, z*x**2), x) == 2*z
assert RootSum(x**2 - y, Lambda(x, z*x**2), x) == 2*z*y
assert RootSum(
x**2 - 1, Lambda(x, exp(x)), quadratic=True) == exp(-1) + exp(1)
assert RootSum(x**3 + a*x + a**3, tan, x) == \
RootSum(x**3 + x + 1, Lambda(x, tan(a*x)))
assert RootSum(a**3*x**3 + a*x + 1, tan, x) == \
RootSum(x**3 + x + 1, Lambda(x, tan(x/a)))
def test_RootSum_free_symbols():
assert RootSum(x**3 + x + 3, Lambda(r, exp(r))).free_symbols == set()
assert RootSum(x**3 + x + 3, Lambda(r, exp(a*r))).free_symbols == {a}
assert RootSum(
x**3 + x + y, Lambda(r, exp(a*r)), x).free_symbols == {a, y}
def test_RootSum___eq__():
f = Lambda(x, exp(x))
assert (RootSum(x**3 + x + 1, f) == RootSum(x**3 + x + 1, f)) is True
assert (RootSum(x**3 + x + 1, f) == RootSum(y**3 + y + 1, f)) is True
assert (RootSum(x**3 + x + 1, f) == RootSum(x**3 + x + 2, f)) is False
assert (RootSum(x**3 + x + 1, f) == RootSum(y**3 + y + 2, f)) is False
def test_RootSum_doit():
rs = RootSum(x**2 + 1, exp)
assert isinstance(rs, RootSum) is True
assert rs.doit() == exp(-I) + exp(I)
rs = RootSum(x**2 + a, exp, x)
assert isinstance(rs, RootSum) is True
assert rs.doit() == exp(-sqrt(-a)) + exp(sqrt(-a))
def test_RootSum_evalf():
rs = RootSum(x**2 + 1, exp)
assert rs.evalf(n=20, chop=True).epsilon_eq(Float("1.0806046117362794348"))
assert rs.evalf(n=15, chop=True).epsilon_eq(Float("1.08060461173628"))
rs = RootSum(x**2 + a, exp, x)
assert rs.evalf() == rs
def test_RootSum_diff():
f = x**3 + x + 3
g = Lambda(r, exp(r*x))
h = Lambda(r, r*exp(r*x))
assert RootSum(f, g).diff(x) == RootSum(f, h)
def test_RootSum_subs():
f = x**3 + x + 3
g = Lambda(r, exp(r*x))
F = y**3 + y + 3
G = Lambda(r, exp(r*y))
assert RootSum(f, g).subs(y, 1) == RootSum(f, g)
assert RootSum(f, g).subs(x, y) == RootSum(F, G)
def test_RootSum_rational():
assert RootSum(
z**5 - z + 1, Lambda(z, z/(x - z))) == (4*x - 5)/(x**5 - x + 1)
f = 161*z**3 + 115*z**2 + 19*z + 1
g = Lambda(z, z*log(
-3381*z**4/4 - 3381*z**3/4 - 625*z**2/2 - z*Rational(125, 2) - 5 + exp(x)))
assert RootSum(f, g).diff(x) == -(
(5*exp(2*x) - 6*exp(x) + 4)*exp(x)/(exp(3*x) - exp(2*x) + 1))/7
def test_RootSum_independent():
f = (x**3 - a)**2*(x**4 - b)**3
g = Lambda(x, 5*tan(x) + 7)
h = Lambda(x, tan(x))
r0 = RootSum(x**3 - a, h, x)
r1 = RootSum(x**4 - b, h, x)
assert RootSum(f, g, x).as_ordered_terms() == [10*r0, 15*r1, 126]
def test_issue_7876():
l1 = Poly(x**6 - x + 1, x).all_roots()
l2 = [rootof(x**6 - x + 1, i) for i in range(6)]
assert frozenset(l1) == frozenset(l2)
def test_issue_8316():
f = Poly(7*x**8 - 9)
assert len(f.all_roots()) == 8
f = Poly(7*x**8 - 10)
assert len(f.all_roots()) == 8
def test__imag_count():
from sympy.polys.rootoftools import _imag_count_of_factor
def imag_count(p):
return sum([_imag_count_of_factor(f)*m for f, m in
p.factor_list()[1]])
assert imag_count(Poly(x**6 + 10*x**2 + 1)) == 2
assert imag_count(Poly(x**2)) == 0
assert imag_count(Poly([1]*3 + [-1], x)) == 0
assert imag_count(Poly(x**3 + 1)) == 0
assert imag_count(Poly(x**2 + 1)) == 2
assert imag_count(Poly(x**2 - 1)) == 0
assert imag_count(Poly(x**4 - 1)) == 2
assert imag_count(Poly(x**4 + 1)) == 0
assert imag_count(Poly([1, 2, 3], x)) == 0
assert imag_count(Poly(x**3 + x + 1)) == 0
assert imag_count(Poly(x**4 + x + 1)) == 0
def q(r1, r2, p):
return Poly(((x - r1)*(x - r2)).subs(x, x**p), x)
assert imag_count(q(-1, -2, 2)) == 4
assert imag_count(q(-1, 2, 2)) == 2
assert imag_count(q(1, 2, 2)) == 0
assert imag_count(q(1, 2, 4)) == 4
assert imag_count(q(-1, 2, 4)) == 2
assert imag_count(q(-1, -2, 4)) == 0
def test_RootOf_is_imaginary():
r = RootOf(x**4 + 4*x**2 + 1, 1)
i = r._get_interval()
assert r.is_imaginary and i.ax*i.bx <= 0
def test_is_disjoint():
eq = x**3 + 5*x + 1
ir = rootof(eq, 0)._get_interval()
ii = rootof(eq, 1)._get_interval()
assert ir.is_disjoint(ii)
assert ii.is_disjoint(ir)
def test_pure_key_dict():
p = D()
assert (x in p) is False
assert (1 in p) is False
p[x] = 1
assert x in p
assert y in p
assert p[y] == 1
raises(KeyError, lambda: p[1])
def dont(k):
p[k] = 2
raises(ValueError, lambda: dont(1))
@slow
def test_eval_approx_relative():
CRootOf.clear_cache()
t = [CRootOf(x**3 + 10*x + 1, i) for i in range(3)]
assert [i.eval_rational(1e-1) for i in t] == [
Rational(-21, 220), Rational(15, 256) - I*Rational(805, 256),
Rational(15, 256) + I*Rational(805, 256)]
t[0]._reset()
assert [i.eval_rational(1e-1, 1e-4) for i in t] == [
Rational(-21, 220), Rational(3275, 65536) - I*Rational(414645, 131072),
Rational(3275, 65536) + I*Rational(414645, 131072)]
assert S(t[0]._get_interval().dx) < 1e-1
assert S(t[1]._get_interval().dx) < 1e-1
assert S(t[1]._get_interval().dy) < 1e-4
assert S(t[2]._get_interval().dx) < 1e-1
assert S(t[2]._get_interval().dy) < 1e-4
t[0]._reset()
assert [i.eval_rational(1e-4, 1e-4) for i in t] == [
Rational(-2001, 20020), Rational(6545, 131072) - I*Rational(414645, 131072),
Rational(6545, 131072) + I*Rational(414645, 131072)]
assert S(t[0]._get_interval().dx) < 1e-4
assert S(t[1]._get_interval().dx) < 1e-4
assert S(t[1]._get_interval().dy) < 1e-4
assert S(t[2]._get_interval().dx) < 1e-4
assert S(t[2]._get_interval().dy) < 1e-4
# in the following, the actual relative precision is
# less than tested, but it should never be greater
t[0]._reset()
assert [i.eval_rational(n=2) for i in t] == [
Rational(-202201, 2024022), Rational(104755, 2097152) - I*Rational(6634255, 2097152),
Rational(104755, 2097152) + I*Rational(6634255, 2097152)]
assert abs(S(t[0]._get_interval().dx)/t[0]) < 1e-2
assert abs(S(t[1]._get_interval().dx)/t[1]).n() < 1e-2
assert abs(S(t[1]._get_interval().dy)/t[1]).n() < 1e-2
assert abs(S(t[2]._get_interval().dx)/t[2]).n() < 1e-2
assert abs(S(t[2]._get_interval().dy)/t[2]).n() < 1e-2
t[0]._reset()
assert [i.eval_rational(n=3) for i in t] == [
Rational(-202201, 2024022), Rational(1676045, 33554432) - I*Rational(106148135, 33554432),
Rational(1676045, 33554432) + I*Rational(106148135, 33554432)]
assert abs(S(t[0]._get_interval().dx)/t[0]) < 1e-3
assert abs(S(t[1]._get_interval().dx)/t[1]).n() < 1e-3
assert abs(S(t[1]._get_interval().dy)/t[1]).n() < 1e-3
assert abs(S(t[2]._get_interval().dx)/t[2]).n() < 1e-3
assert abs(S(t[2]._get_interval().dy)/t[2]).n() < 1e-3
t[0]._reset()
a = [i.eval_approx(2) for i in t]
assert [str(i) for i in a] == [
'-0.10', '0.05 - 3.2*I', '0.05 + 3.2*I']
assert all(abs(((a[i] - t[i])/t[i]).n()) < 1e-2 for i in range(len(a)))
def test_issue_15920():
r = rootof(x**5 - x + 1, 0)
p = Integral(x, (x, 1, y))
assert unchanged(Eq, r, p)
def test_issue_19113():
eq = y**3 - y + 1
# generator is a canonical x in RootOf
assert str(Poly(eq).real_roots()) == '[CRootOf(x**3 - x + 1, 0)]'
assert str(Poly(eq.subs(y, tan(y))).real_roots()
) == '[CRootOf(x**3 - x + 1, 0)]'
assert str(Poly(eq.subs(y, tan(x))).real_roots()
) == '[CRootOf(x**3 - x + 1, 0)]'
|
b0225fe40a6e5b3b7176d44d8c1d44f1287880baff45fbe0934a8867e8343d5c | """Tests for user-friendly public interface to polynomial functions. """
from sympy.polys.polytools import (
Poly, PurePoly, poly,
parallel_poly_from_expr,
degree, degree_list,
total_degree,
LC, LM, LT,
pdiv, prem, pquo, pexquo,
div, rem, quo, exquo,
half_gcdex, gcdex, invert,
subresultants,
resultant, discriminant,
terms_gcd, cofactors,
gcd, gcd_list,
lcm, lcm_list,
trunc,
monic, content, primitive,
compose, decompose,
sturm,
gff_list, gff,
sqf_norm, sqf_part, sqf_list, sqf,
factor_list, factor,
intervals, refine_root, count_roots,
real_roots, nroots, ground_roots,
nth_power_roots_poly,
cancel, reduced, groebner,
GroebnerBasis, is_zero_dimensional,
_torational_factor_list,
to_rational_coeffs)
from sympy.polys.polyerrors import (
MultivariatePolynomialError,
ExactQuotientFailed,
PolificationFailed,
ComputationFailed,
UnificationFailed,
RefinementFailed,
GeneratorsNeeded,
GeneratorsError,
PolynomialError,
CoercionFailed,
DomainError,
OptionError,
FlagError)
from sympy.polys.polyclasses import DMP
from sympy.polys.fields import field
from sympy.polys.domains import FF, ZZ, QQ, RR, EX
from sympy.polys.domains.realfield import RealField
from sympy.polys.orderings import lex, grlex, grevlex
from sympy import (
S, Integer, Rational, Float, Mul, Symbol, sqrt, Piecewise, Derivative,
exp, sin, tanh, expand, oo, I, pi, re, im, rootof, Eq, Tuple, Expr, diff)
from sympy.core.basic import _aresame
from sympy.core.compatibility import iterable
from sympy.core.mul import _keep_coeff
from sympy.testing.pytest import raises, warns_deprecated_sympy
from sympy.abc import a, b, c, d, p, q, t, w, x, y, z
from sympy import MatrixSymbol, Matrix
def _epsilon_eq(a, b):
for u, v in zip(a, b):
if abs(u - v) > 1e-10:
return False
return True
def _strict_eq(a, b):
if type(a) == type(b):
if iterable(a):
if len(a) == len(b):
return all(_strict_eq(c, d) for c, d in zip(a, b))
else:
return False
else:
return isinstance(a, Poly) and a.eq(b, strict=True)
else:
return False
def test_Poly_mixed_operations():
p = Poly(x, x)
with warns_deprecated_sympy():
p * exp(x)
with warns_deprecated_sympy():
p + exp(x)
with warns_deprecated_sympy():
p - exp(x)
def test_Poly_from_dict():
K = FF(3)
assert Poly.from_dict(
{0: 1, 1: 2}, gens=x, domain=K).rep == DMP([K(2), K(1)], K)
assert Poly.from_dict(
{0: 1, 1: 5}, gens=x, domain=K).rep == DMP([K(2), K(1)], K)
assert Poly.from_dict(
{(0,): 1, (1,): 2}, gens=x, domain=K).rep == DMP([K(2), K(1)], K)
assert Poly.from_dict(
{(0,): 1, (1,): 5}, gens=x, domain=K).rep == DMP([K(2), K(1)], K)
assert Poly.from_dict({(0, 0): 1, (1, 1): 2}, gens=(
x, y), domain=K).rep == DMP([[K(2), K(0)], [K(1)]], K)
assert Poly.from_dict({0: 1, 1: 2}, gens=x).rep == DMP([ZZ(2), ZZ(1)], ZZ)
assert Poly.from_dict(
{0: 1, 1: 2}, gens=x, field=True).rep == DMP([QQ(2), QQ(1)], QQ)
assert Poly.from_dict(
{0: 1, 1: 2}, gens=x, domain=ZZ).rep == DMP([ZZ(2), ZZ(1)], ZZ)
assert Poly.from_dict(
{0: 1, 1: 2}, gens=x, domain=QQ).rep == DMP([QQ(2), QQ(1)], QQ)
assert Poly.from_dict(
{(0,): 1, (1,): 2}, gens=x).rep == DMP([ZZ(2), ZZ(1)], ZZ)
assert Poly.from_dict(
{(0,): 1, (1,): 2}, gens=x, field=True).rep == DMP([QQ(2), QQ(1)], QQ)
assert Poly.from_dict(
{(0,): 1, (1,): 2}, gens=x, domain=ZZ).rep == DMP([ZZ(2), ZZ(1)], ZZ)
assert Poly.from_dict(
{(0,): 1, (1,): 2}, gens=x, domain=QQ).rep == DMP([QQ(2), QQ(1)], QQ)
assert Poly.from_dict({(1,): sin(y)}, gens=x, composite=False) == \
Poly(sin(y)*x, x, domain='EX')
assert Poly.from_dict({(1,): y}, gens=x, composite=False) == \
Poly(y*x, x, domain='EX')
assert Poly.from_dict({(1, 1): 1}, gens=(x, y), composite=False) == \
Poly(x*y, x, y, domain='ZZ')
assert Poly.from_dict({(1, 0): y}, gens=(x, z), composite=False) == \
Poly(y*x, x, z, domain='EX')
def test_Poly_from_list():
K = FF(3)
assert Poly.from_list([2, 1], gens=x, domain=K).rep == DMP([K(2), K(1)], K)
assert Poly.from_list([5, 1], gens=x, domain=K).rep == DMP([K(2), K(1)], K)
assert Poly.from_list([2, 1], gens=x).rep == DMP([ZZ(2), ZZ(1)], ZZ)
assert Poly.from_list([2, 1], gens=x, field=True).rep == DMP([QQ(2), QQ(1)], QQ)
assert Poly.from_list([2, 1], gens=x, domain=ZZ).rep == DMP([ZZ(2), ZZ(1)], ZZ)
assert Poly.from_list([2, 1], gens=x, domain=QQ).rep == DMP([QQ(2), QQ(1)], QQ)
assert Poly.from_list([0, 1.0], gens=x).rep == DMP([RR(1.0)], RR)
assert Poly.from_list([1.0, 0], gens=x).rep == DMP([RR(1.0), RR(0.0)], RR)
raises(MultivariatePolynomialError, lambda: Poly.from_list([[]], gens=(x, y)))
def test_Poly_from_poly():
f = Poly(x + 7, x, domain=ZZ)
g = Poly(x + 2, x, modulus=3)
h = Poly(x + y, x, y, domain=ZZ)
K = FF(3)
assert Poly.from_poly(f) == f
assert Poly.from_poly(f, domain=K).rep == DMP([K(1), K(1)], K)
assert Poly.from_poly(f, domain=ZZ).rep == DMP([1, 7], ZZ)
assert Poly.from_poly(f, domain=QQ).rep == DMP([1, 7], QQ)
assert Poly.from_poly(f, gens=x) == f
assert Poly.from_poly(f, gens=x, domain=K).rep == DMP([K(1), K(1)], K)
assert Poly.from_poly(f, gens=x, domain=ZZ).rep == DMP([1, 7], ZZ)
assert Poly.from_poly(f, gens=x, domain=QQ).rep == DMP([1, 7], QQ)
assert Poly.from_poly(f, gens=y) == Poly(x + 7, y, domain='ZZ[x]')
raises(CoercionFailed, lambda: Poly.from_poly(f, gens=y, domain=K))
raises(CoercionFailed, lambda: Poly.from_poly(f, gens=y, domain=ZZ))
raises(CoercionFailed, lambda: Poly.from_poly(f, gens=y, domain=QQ))
assert Poly.from_poly(f, gens=(x, y)) == Poly(x + 7, x, y, domain='ZZ')
assert Poly.from_poly(
f, gens=(x, y), domain=ZZ) == Poly(x + 7, x, y, domain='ZZ')
assert Poly.from_poly(
f, gens=(x, y), domain=QQ) == Poly(x + 7, x, y, domain='QQ')
assert Poly.from_poly(
f, gens=(x, y), modulus=3) == Poly(x + 7, x, y, domain='FF(3)')
K = FF(2)
assert Poly.from_poly(g) == g
assert Poly.from_poly(g, domain=ZZ).rep == DMP([1, -1], ZZ)
raises(CoercionFailed, lambda: Poly.from_poly(g, domain=QQ))
assert Poly.from_poly(g, domain=K).rep == DMP([K(1), K(0)], K)
assert Poly.from_poly(g, gens=x) == g
assert Poly.from_poly(g, gens=x, domain=ZZ).rep == DMP([1, -1], ZZ)
raises(CoercionFailed, lambda: Poly.from_poly(g, gens=x, domain=QQ))
assert Poly.from_poly(g, gens=x, domain=K).rep == DMP([K(1), K(0)], K)
K = FF(3)
assert Poly.from_poly(h) == h
assert Poly.from_poly(
h, domain=ZZ).rep == DMP([[ZZ(1)], [ZZ(1), ZZ(0)]], ZZ)
assert Poly.from_poly(
h, domain=QQ).rep == DMP([[QQ(1)], [QQ(1), QQ(0)]], QQ)
assert Poly.from_poly(h, domain=K).rep == DMP([[K(1)], [K(1), K(0)]], K)
assert Poly.from_poly(h, gens=x) == Poly(x + y, x, domain=ZZ[y])
raises(CoercionFailed, lambda: Poly.from_poly(h, gens=x, domain=ZZ))
assert Poly.from_poly(
h, gens=x, domain=ZZ[y]) == Poly(x + y, x, domain=ZZ[y])
raises(CoercionFailed, lambda: Poly.from_poly(h, gens=x, domain=QQ))
assert Poly.from_poly(
h, gens=x, domain=QQ[y]) == Poly(x + y, x, domain=QQ[y])
raises(CoercionFailed, lambda: Poly.from_poly(h, gens=x, modulus=3))
assert Poly.from_poly(h, gens=y) == Poly(x + y, y, domain=ZZ[x])
raises(CoercionFailed, lambda: Poly.from_poly(h, gens=y, domain=ZZ))
assert Poly.from_poly(
h, gens=y, domain=ZZ[x]) == Poly(x + y, y, domain=ZZ[x])
raises(CoercionFailed, lambda: Poly.from_poly(h, gens=y, domain=QQ))
assert Poly.from_poly(
h, gens=y, domain=QQ[x]) == Poly(x + y, y, domain=QQ[x])
raises(CoercionFailed, lambda: Poly.from_poly(h, gens=y, modulus=3))
assert Poly.from_poly(h, gens=(x, y)) == h
assert Poly.from_poly(
h, gens=(x, y), domain=ZZ).rep == DMP([[ZZ(1)], [ZZ(1), ZZ(0)]], ZZ)
assert Poly.from_poly(
h, gens=(x, y), domain=QQ).rep == DMP([[QQ(1)], [QQ(1), QQ(0)]], QQ)
assert Poly.from_poly(
h, gens=(x, y), domain=K).rep == DMP([[K(1)], [K(1), K(0)]], K)
assert Poly.from_poly(
h, gens=(y, x)).rep == DMP([[ZZ(1)], [ZZ(1), ZZ(0)]], ZZ)
assert Poly.from_poly(
h, gens=(y, x), domain=ZZ).rep == DMP([[ZZ(1)], [ZZ(1), ZZ(0)]], ZZ)
assert Poly.from_poly(
h, gens=(y, x), domain=QQ).rep == DMP([[QQ(1)], [QQ(1), QQ(0)]], QQ)
assert Poly.from_poly(
h, gens=(y, x), domain=K).rep == DMP([[K(1)], [K(1), K(0)]], K)
assert Poly.from_poly(
h, gens=(x, y), field=True).rep == DMP([[QQ(1)], [QQ(1), QQ(0)]], QQ)
assert Poly.from_poly(
h, gens=(x, y), field=True).rep == DMP([[QQ(1)], [QQ(1), QQ(0)]], QQ)
def test_Poly_from_expr():
raises(GeneratorsNeeded, lambda: Poly.from_expr(S.Zero))
raises(GeneratorsNeeded, lambda: Poly.from_expr(S(7)))
F3 = FF(3)
assert Poly.from_expr(x + 5, domain=F3).rep == DMP([F3(1), F3(2)], F3)
assert Poly.from_expr(y + 5, domain=F3).rep == DMP([F3(1), F3(2)], F3)
assert Poly.from_expr(x + 5, x, domain=F3).rep == DMP([F3(1), F3(2)], F3)
assert Poly.from_expr(y + 5, y, domain=F3).rep == DMP([F3(1), F3(2)], F3)
assert Poly.from_expr(x + y, domain=F3).rep == DMP([[F3(1)], [F3(1), F3(0)]], F3)
assert Poly.from_expr(x + y, x, y, domain=F3).rep == DMP([[F3(1)], [F3(1), F3(0)]], F3)
assert Poly.from_expr(x + 5).rep == DMP([1, 5], ZZ)
assert Poly.from_expr(y + 5).rep == DMP([1, 5], ZZ)
assert Poly.from_expr(x + 5, x).rep == DMP([1, 5], ZZ)
assert Poly.from_expr(y + 5, y).rep == DMP([1, 5], ZZ)
assert Poly.from_expr(x + 5, domain=ZZ).rep == DMP([1, 5], ZZ)
assert Poly.from_expr(y + 5, domain=ZZ).rep == DMP([1, 5], ZZ)
assert Poly.from_expr(x + 5, x, domain=ZZ).rep == DMP([1, 5], ZZ)
assert Poly.from_expr(y + 5, y, domain=ZZ).rep == DMP([1, 5], ZZ)
assert Poly.from_expr(x + 5, x, y, domain=ZZ).rep == DMP([[1], [5]], ZZ)
assert Poly.from_expr(y + 5, x, y, domain=ZZ).rep == DMP([[1, 5]], ZZ)
def test_Poly__new__():
raises(GeneratorsError, lambda: Poly(x + 1, x, x))
raises(GeneratorsError, lambda: Poly(x + y, x, y, domain=ZZ[x]))
raises(GeneratorsError, lambda: Poly(x + y, x, y, domain=ZZ[y]))
raises(OptionError, lambda: Poly(x, x, symmetric=True))
raises(OptionError, lambda: Poly(x + 2, x, modulus=3, domain=QQ))
raises(OptionError, lambda: Poly(x + 2, x, domain=ZZ, gaussian=True))
raises(OptionError, lambda: Poly(x + 2, x, modulus=3, gaussian=True))
raises(OptionError, lambda: Poly(x + 2, x, domain=ZZ, extension=[sqrt(3)]))
raises(OptionError, lambda: Poly(x + 2, x, modulus=3, extension=[sqrt(3)]))
raises(OptionError, lambda: Poly(x + 2, x, domain=ZZ, extension=True))
raises(OptionError, lambda: Poly(x + 2, x, modulus=3, extension=True))
raises(OptionError, lambda: Poly(x + 2, x, domain=ZZ, greedy=True))
raises(OptionError, lambda: Poly(x + 2, x, domain=QQ, field=True))
raises(OptionError, lambda: Poly(x + 2, x, domain=ZZ, greedy=False))
raises(OptionError, lambda: Poly(x + 2, x, domain=QQ, field=False))
raises(NotImplementedError, lambda: Poly(x + 1, x, modulus=3, order='grlex'))
raises(NotImplementedError, lambda: Poly(x + 1, x, order='grlex'))
raises(GeneratorsNeeded, lambda: Poly({1: 2, 0: 1}))
raises(GeneratorsNeeded, lambda: Poly([2, 1]))
raises(GeneratorsNeeded, lambda: Poly((2, 1)))
raises(GeneratorsNeeded, lambda: Poly(1))
f = a*x**2 + b*x + c
assert Poly({2: a, 1: b, 0: c}, x) == f
assert Poly(iter([a, b, c]), x) == f
assert Poly([a, b, c], x) == f
assert Poly((a, b, c), x) == f
f = Poly({}, x, y, z)
assert f.gens == (x, y, z) and f.as_expr() == 0
assert Poly(Poly(a*x + b*y, x, y), x) == Poly(a*x + b*y, x)
assert Poly(3*x**2 + 2*x + 1, domain='ZZ').all_coeffs() == [3, 2, 1]
assert Poly(3*x**2 + 2*x + 1, domain='QQ').all_coeffs() == [3, 2, 1]
assert Poly(3*x**2 + 2*x + 1, domain='RR').all_coeffs() == [3.0, 2.0, 1.0]
raises(CoercionFailed, lambda: Poly(3*x**2/5 + x*Rational(2, 5) + 1, domain='ZZ'))
assert Poly(
3*x**2/5 + x*Rational(2, 5) + 1, domain='QQ').all_coeffs() == [Rational(3, 5), Rational(2, 5), 1]
assert _epsilon_eq(
Poly(3*x**2/5 + x*Rational(2, 5) + 1, domain='RR').all_coeffs(), [0.6, 0.4, 1.0])
assert Poly(3.0*x**2 + 2.0*x + 1, domain='ZZ').all_coeffs() == [3, 2, 1]
assert Poly(3.0*x**2 + 2.0*x + 1, domain='QQ').all_coeffs() == [3, 2, 1]
assert Poly(
3.0*x**2 + 2.0*x + 1, domain='RR').all_coeffs() == [3.0, 2.0, 1.0]
raises(CoercionFailed, lambda: Poly(3.1*x**2 + 2.1*x + 1, domain='ZZ'))
assert Poly(3.1*x**2 + 2.1*x + 1, domain='QQ').all_coeffs() == [Rational(31, 10), Rational(21, 10), 1]
assert Poly(3.1*x**2 + 2.1*x + 1, domain='RR').all_coeffs() == [3.1, 2.1, 1.0]
assert Poly({(2, 1): 1, (1, 2): 2, (1, 1): 3}, x, y) == \
Poly(x**2*y + 2*x*y**2 + 3*x*y, x, y)
assert Poly(x**2 + 1, extension=I).get_domain() == QQ.algebraic_field(I)
f = 3*x**5 - x**4 + x**3 - x** 2 + 65538
assert Poly(f, x, modulus=65537, symmetric=True) == \
Poly(3*x**5 - x**4 + x**3 - x** 2 + 1, x, modulus=65537,
symmetric=True)
assert Poly(f, x, modulus=65537, symmetric=False) == \
Poly(3*x**5 + 65536*x**4 + x**3 + 65536*x** 2 + 1, x,
modulus=65537, symmetric=False)
assert isinstance(Poly(x**2 + x + 1.0).get_domain(), RealField)
def test_Poly__args():
assert Poly(x**2 + 1).args == (x**2 + 1, x)
def test_Poly__gens():
assert Poly((x - p)*(x - q), x).gens == (x,)
assert Poly((x - p)*(x - q), p).gens == (p,)
assert Poly((x - p)*(x - q), q).gens == (q,)
assert Poly((x - p)*(x - q), x, p).gens == (x, p)
assert Poly((x - p)*(x - q), x, q).gens == (x, q)
assert Poly((x - p)*(x - q), x, p, q).gens == (x, p, q)
assert Poly((x - p)*(x - q), p, x, q).gens == (p, x, q)
assert Poly((x - p)*(x - q), p, q, x).gens == (p, q, x)
assert Poly((x - p)*(x - q)).gens == (x, p, q)
assert Poly((x - p)*(x - q), sort='x > p > q').gens == (x, p, q)
assert Poly((x - p)*(x - q), sort='p > x > q').gens == (p, x, q)
assert Poly((x - p)*(x - q), sort='p > q > x').gens == (p, q, x)
assert Poly((x - p)*(x - q), x, p, q, sort='p > q > x').gens == (x, p, q)
assert Poly((x - p)*(x - q), wrt='x').gens == (x, p, q)
assert Poly((x - p)*(x - q), wrt='p').gens == (p, x, q)
assert Poly((x - p)*(x - q), wrt='q').gens == (q, x, p)
assert Poly((x - p)*(x - q), wrt=x).gens == (x, p, q)
assert Poly((x - p)*(x - q), wrt=p).gens == (p, x, q)
assert Poly((x - p)*(x - q), wrt=q).gens == (q, x, p)
assert Poly((x - p)*(x - q), x, p, q, wrt='p').gens == (x, p, q)
assert Poly((x - p)*(x - q), wrt='p', sort='q > x').gens == (p, q, x)
assert Poly((x - p)*(x - q), wrt='q', sort='p > x').gens == (q, p, x)
def test_Poly_zero():
assert Poly(x).zero == Poly(0, x, domain=ZZ)
assert Poly(x/2).zero == Poly(0, x, domain=QQ)
def test_Poly_one():
assert Poly(x).one == Poly(1, x, domain=ZZ)
assert Poly(x/2).one == Poly(1, x, domain=QQ)
def test_Poly__unify():
raises(UnificationFailed, lambda: Poly(x)._unify(y))
F3 = FF(3)
F5 = FF(5)
assert Poly(x, x, modulus=3)._unify(Poly(y, y, modulus=3))[2:] == (
DMP([[F3(1)], []], F3), DMP([[F3(1), F3(0)]], F3))
assert Poly(x, x, modulus=3)._unify(Poly(y, y, modulus=5))[2:] == (
DMP([[F5(1)], []], F5), DMP([[F5(1), F5(0)]], F5))
assert Poly(y, x, y)._unify(Poly(x, x, modulus=3))[2:] == (DMP([[F3(1), F3(0)]], F3), DMP([[F3(1)], []], F3))
assert Poly(x, x, modulus=3)._unify(Poly(y, x, y))[2:] == (DMP([[F3(1)], []], F3), DMP([[F3(1), F3(0)]], F3))
assert Poly(x + 1, x)._unify(Poly(x + 2, x))[2:] == (DMP([1, 1], ZZ), DMP([1, 2], ZZ))
assert Poly(x + 1, x, domain='QQ')._unify(Poly(x + 2, x))[2:] == (DMP([1, 1], QQ), DMP([1, 2], QQ))
assert Poly(x + 1, x)._unify(Poly(x + 2, x, domain='QQ'))[2:] == (DMP([1, 1], QQ), DMP([1, 2], QQ))
assert Poly(x + 1, x)._unify(Poly(x + 2, x, y))[2:] == (DMP([[1], [1]], ZZ), DMP([[1], [2]], ZZ))
assert Poly(x + 1, x, domain='QQ')._unify(Poly(x + 2, x, y))[2:] == (DMP([[1], [1]], QQ), DMP([[1], [2]], QQ))
assert Poly(x + 1, x)._unify(Poly(x + 2, x, y, domain='QQ'))[2:] == (DMP([[1], [1]], QQ), DMP([[1], [2]], QQ))
assert Poly(x + 1, x, y)._unify(Poly(x + 2, x))[2:] == (DMP([[1], [1]], ZZ), DMP([[1], [2]], ZZ))
assert Poly(x + 1, x, y, domain='QQ')._unify(Poly(x + 2, x))[2:] == (DMP([[1], [1]], QQ), DMP([[1], [2]], QQ))
assert Poly(x + 1, x, y)._unify(Poly(x + 2, x, domain='QQ'))[2:] == (DMP([[1], [1]], QQ), DMP([[1], [2]], QQ))
assert Poly(x + 1, x, y)._unify(Poly(x + 2, x, y))[2:] == (DMP([[1], [1]], ZZ), DMP([[1], [2]], ZZ))
assert Poly(x + 1, x, y, domain='QQ')._unify(Poly(x + 2, x, y))[2:] == (DMP([[1], [1]], QQ), DMP([[1], [2]], QQ))
assert Poly(x + 1, x, y)._unify(Poly(x + 2, x, y, domain='QQ'))[2:] == (DMP([[1], [1]], QQ), DMP([[1], [2]], QQ))
assert Poly(x + 1, x)._unify(Poly(x + 2, y, x))[2:] == (DMP([[1, 1]], ZZ), DMP([[1, 2]], ZZ))
assert Poly(x + 1, x, domain='QQ')._unify(Poly(x + 2, y, x))[2:] == (DMP([[1, 1]], QQ), DMP([[1, 2]], QQ))
assert Poly(x + 1, x)._unify(Poly(x + 2, y, x, domain='QQ'))[2:] == (DMP([[1, 1]], QQ), DMP([[1, 2]], QQ))
assert Poly(x + 1, y, x)._unify(Poly(x + 2, x))[2:] == (DMP([[1, 1]], ZZ), DMP([[1, 2]], ZZ))
assert Poly(x + 1, y, x, domain='QQ')._unify(Poly(x + 2, x))[2:] == (DMP([[1, 1]], QQ), DMP([[1, 2]], QQ))
assert Poly(x + 1, y, x)._unify(Poly(x + 2, x, domain='QQ'))[2:] == (DMP([[1, 1]], QQ), DMP([[1, 2]], QQ))
assert Poly(x + 1, x, y)._unify(Poly(x + 2, y, x))[2:] == (DMP([[1], [1]], ZZ), DMP([[1], [2]], ZZ))
assert Poly(x + 1, x, y, domain='QQ')._unify(Poly(x + 2, y, x))[2:] == (DMP([[1], [1]], QQ), DMP([[1], [2]], QQ))
assert Poly(x + 1, x, y)._unify(Poly(x + 2, y, x, domain='QQ'))[2:] == (DMP([[1], [1]], QQ), DMP([[1], [2]], QQ))
assert Poly(x + 1, y, x)._unify(Poly(x + 2, x, y))[2:] == (DMP([[1, 1]], ZZ), DMP([[1, 2]], ZZ))
assert Poly(x + 1, y, x, domain='QQ')._unify(Poly(x + 2, x, y))[2:] == (DMP([[1, 1]], QQ), DMP([[1, 2]], QQ))
assert Poly(x + 1, y, x)._unify(Poly(x + 2, x, y, domain='QQ'))[2:] == (DMP([[1, 1]], QQ), DMP([[1, 2]], QQ))
F, A, B = field("a,b", ZZ)
assert Poly(a*x, x, domain='ZZ[a]')._unify(Poly(a*b*x, x, domain='ZZ(a,b)'))[2:] == \
(DMP([A, F(0)], F.to_domain()), DMP([A*B, F(0)], F.to_domain()))
assert Poly(a*x, x, domain='ZZ(a)')._unify(Poly(a*b*x, x, domain='ZZ(a,b)'))[2:] == \
(DMP([A, F(0)], F.to_domain()), DMP([A*B, F(0)], F.to_domain()))
raises(CoercionFailed, lambda: Poly(Poly(x**2 + x**2*z, y, field=True), domain='ZZ(x)'))
f = Poly(t**2 + t/3 + x, t, domain='QQ(x)')
g = Poly(t**2 + t/3 + x, t, domain='QQ[x]')
assert f._unify(g)[2:] == (f.rep, f.rep)
def test_Poly_free_symbols():
assert Poly(x**2 + 1).free_symbols == {x}
assert Poly(x**2 + y*z).free_symbols == {x, y, z}
assert Poly(x**2 + y*z, x).free_symbols == {x, y, z}
assert Poly(x**2 + sin(y*z)).free_symbols == {x, y, z}
assert Poly(x**2 + sin(y*z), x).free_symbols == {x, y, z}
assert Poly(x**2 + sin(y*z), x, domain=EX).free_symbols == {x, y, z}
assert Poly(1 + x + x**2, x, y, z).free_symbols == {x}
assert Poly(x + sin(y), z).free_symbols == {x, y}
def test_PurePoly_free_symbols():
assert PurePoly(x**2 + 1).free_symbols == set([])
assert PurePoly(x**2 + y*z).free_symbols == set([])
assert PurePoly(x**2 + y*z, x).free_symbols == {y, z}
assert PurePoly(x**2 + sin(y*z)).free_symbols == set([])
assert PurePoly(x**2 + sin(y*z), x).free_symbols == {y, z}
assert PurePoly(x**2 + sin(y*z), x, domain=EX).free_symbols == {y, z}
def test_Poly__eq__():
assert (Poly(x, x) == Poly(x, x)) is True
assert (Poly(x, x, domain=QQ) == Poly(x, x)) is False
assert (Poly(x, x) == Poly(x, x, domain=QQ)) is False
assert (Poly(x, x, domain=ZZ[a]) == Poly(x, x)) is False
assert (Poly(x, x) == Poly(x, x, domain=ZZ[a])) is False
assert (Poly(x*y, x, y) == Poly(x, x)) is False
assert (Poly(x, x, y) == Poly(x, x)) is False
assert (Poly(x, x) == Poly(x, x, y)) is False
assert (Poly(x**2 + 1, x) == Poly(y**2 + 1, y)) is False
assert (Poly(y**2 + 1, y) == Poly(x**2 + 1, x)) is False
f = Poly(x, x, domain=ZZ)
g = Poly(x, x, domain=QQ)
assert f.eq(g) is False
assert f.ne(g) is True
assert f.eq(g, strict=True) is False
assert f.ne(g, strict=True) is True
t0 = Symbol('t0')
f = Poly((t0/2 + x**2)*t**2 - x**2*t, t, domain='QQ[x,t0]')
g = Poly((t0/2 + x**2)*t**2 - x**2*t, t, domain='ZZ(x,t0)')
assert (f == g) is False
def test_PurePoly__eq__():
assert (PurePoly(x, x) == PurePoly(x, x)) is True
assert (PurePoly(x, x, domain=QQ) == PurePoly(x, x)) is True
assert (PurePoly(x, x) == PurePoly(x, x, domain=QQ)) is True
assert (PurePoly(x, x, domain=ZZ[a]) == PurePoly(x, x)) is True
assert (PurePoly(x, x) == PurePoly(x, x, domain=ZZ[a])) is True
assert (PurePoly(x*y, x, y) == PurePoly(x, x)) is False
assert (PurePoly(x, x, y) == PurePoly(x, x)) is False
assert (PurePoly(x, x) == PurePoly(x, x, y)) is False
assert (PurePoly(x**2 + 1, x) == PurePoly(y**2 + 1, y)) is True
assert (PurePoly(y**2 + 1, y) == PurePoly(x**2 + 1, x)) is True
f = PurePoly(x, x, domain=ZZ)
g = PurePoly(x, x, domain=QQ)
assert f.eq(g) is True
assert f.ne(g) is False
assert f.eq(g, strict=True) is False
assert f.ne(g, strict=True) is True
f = PurePoly(x, x, domain=ZZ)
g = PurePoly(y, y, domain=QQ)
assert f.eq(g) is True
assert f.ne(g) is False
assert f.eq(g, strict=True) is False
assert f.ne(g, strict=True) is True
def test_PurePoly_Poly():
assert isinstance(PurePoly(Poly(x**2 + 1)), PurePoly) is True
assert isinstance(Poly(PurePoly(x**2 + 1)), Poly) is True
def test_Poly_get_domain():
assert Poly(2*x).get_domain() == ZZ
assert Poly(2*x, domain='ZZ').get_domain() == ZZ
assert Poly(2*x, domain='QQ').get_domain() == QQ
assert Poly(x/2).get_domain() == QQ
raises(CoercionFailed, lambda: Poly(x/2, domain='ZZ'))
assert Poly(x/2, domain='QQ').get_domain() == QQ
assert isinstance(Poly(0.2*x).get_domain(), RealField)
def test_Poly_set_domain():
assert Poly(2*x + 1).set_domain(ZZ) == Poly(2*x + 1)
assert Poly(2*x + 1).set_domain('ZZ') == Poly(2*x + 1)
assert Poly(2*x + 1).set_domain(QQ) == Poly(2*x + 1, domain='QQ')
assert Poly(2*x + 1).set_domain('QQ') == Poly(2*x + 1, domain='QQ')
assert Poly(Rational(2, 10)*x + Rational(1, 10)).set_domain('RR') == Poly(0.2*x + 0.1)
assert Poly(0.2*x + 0.1).set_domain('QQ') == Poly(Rational(2, 10)*x + Rational(1, 10))
raises(CoercionFailed, lambda: Poly(x/2 + 1).set_domain(ZZ))
raises(CoercionFailed, lambda: Poly(x + 1, modulus=2).set_domain(QQ))
raises(GeneratorsError, lambda: Poly(x*y, x, y).set_domain(ZZ[y]))
def test_Poly_get_modulus():
assert Poly(x**2 + 1, modulus=2).get_modulus() == 2
raises(PolynomialError, lambda: Poly(x**2 + 1).get_modulus())
def test_Poly_set_modulus():
assert Poly(
x**2 + 1, modulus=2).set_modulus(7) == Poly(x**2 + 1, modulus=7)
assert Poly(
x**2 + 5, modulus=7).set_modulus(2) == Poly(x**2 + 1, modulus=2)
assert Poly(x**2 + 1).set_modulus(2) == Poly(x**2 + 1, modulus=2)
raises(CoercionFailed, lambda: Poly(x/2 + 1).set_modulus(2))
def test_Poly_add_ground():
assert Poly(x + 1).add_ground(2) == Poly(x + 3)
def test_Poly_sub_ground():
assert Poly(x + 1).sub_ground(2) == Poly(x - 1)
def test_Poly_mul_ground():
assert Poly(x + 1).mul_ground(2) == Poly(2*x + 2)
def test_Poly_quo_ground():
assert Poly(2*x + 4).quo_ground(2) == Poly(x + 2)
assert Poly(2*x + 3).quo_ground(2) == Poly(x + 1)
def test_Poly_exquo_ground():
assert Poly(2*x + 4).exquo_ground(2) == Poly(x + 2)
raises(ExactQuotientFailed, lambda: Poly(2*x + 3).exquo_ground(2))
def test_Poly_abs():
assert Poly(-x + 1, x).abs() == abs(Poly(-x + 1, x)) == Poly(x + 1, x)
def test_Poly_neg():
assert Poly(-x + 1, x).neg() == -Poly(-x + 1, x) == Poly(x - 1, x)
def test_Poly_add():
assert Poly(0, x).add(Poly(0, x)) == Poly(0, x)
assert Poly(0, x) + Poly(0, x) == Poly(0, x)
assert Poly(1, x).add(Poly(0, x)) == Poly(1, x)
assert Poly(1, x, y) + Poly(0, x) == Poly(1, x, y)
assert Poly(0, x).add(Poly(1, x, y)) == Poly(1, x, y)
assert Poly(0, x, y) + Poly(1, x, y) == Poly(1, x, y)
assert Poly(1, x) + x == Poly(x + 1, x)
with warns_deprecated_sympy():
Poly(1, x) + sin(x)
assert Poly(x, x) + 1 == Poly(x + 1, x)
assert 1 + Poly(x, x) == Poly(x + 1, x)
def test_Poly_sub():
assert Poly(0, x).sub(Poly(0, x)) == Poly(0, x)
assert Poly(0, x) - Poly(0, x) == Poly(0, x)
assert Poly(1, x).sub(Poly(0, x)) == Poly(1, x)
assert Poly(1, x, y) - Poly(0, x) == Poly(1, x, y)
assert Poly(0, x).sub(Poly(1, x, y)) == Poly(-1, x, y)
assert Poly(0, x, y) - Poly(1, x, y) == Poly(-1, x, y)
assert Poly(1, x) - x == Poly(1 - x, x)
with warns_deprecated_sympy():
Poly(1, x) - sin(x)
assert Poly(x, x) - 1 == Poly(x - 1, x)
assert 1 - Poly(x, x) == Poly(1 - x, x)
def test_Poly_mul():
assert Poly(0, x).mul(Poly(0, x)) == Poly(0, x)
assert Poly(0, x) * Poly(0, x) == Poly(0, x)
assert Poly(2, x).mul(Poly(4, x)) == Poly(8, x)
assert Poly(2, x, y) * Poly(4, x) == Poly(8, x, y)
assert Poly(4, x).mul(Poly(2, x, y)) == Poly(8, x, y)
assert Poly(4, x, y) * Poly(2, x, y) == Poly(8, x, y)
assert Poly(1, x) * x == Poly(x, x)
with warns_deprecated_sympy():
Poly(1, x) * sin(x)
assert Poly(x, x) * 2 == Poly(2*x, x)
assert 2 * Poly(x, x) == Poly(2*x, x)
def test_issue_13079():
assert Poly(x)*x == Poly(x**2, x, domain='ZZ')
assert x*Poly(x) == Poly(x**2, x, domain='ZZ')
assert -2*Poly(x) == Poly(-2*x, x, domain='ZZ')
assert S(-2)*Poly(x) == Poly(-2*x, x, domain='ZZ')
assert Poly(x)*S(-2) == Poly(-2*x, x, domain='ZZ')
def test_Poly_sqr():
assert Poly(x*y, x, y).sqr() == Poly(x**2*y**2, x, y)
def test_Poly_pow():
assert Poly(x, x).pow(10) == Poly(x**10, x)
assert Poly(x, x).pow(Integer(10)) == Poly(x**10, x)
assert Poly(2*y, x, y).pow(4) == Poly(16*y**4, x, y)
assert Poly(2*y, x, y).pow(Integer(4)) == Poly(16*y**4, x, y)
assert Poly(7*x*y, x, y)**3 == Poly(343*x**3*y**3, x, y)
raises(TypeError, lambda: Poly(x*y + 1, x, y)**(-1))
raises(TypeError, lambda: Poly(x*y + 1, x, y)**x)
def test_Poly_divmod():
f, g = Poly(x**2), Poly(x)
q, r = g, Poly(0, x)
assert divmod(f, g) == (q, r)
assert f // g == q
assert f % g == r
assert divmod(f, x) == (q, r)
assert f // x == q
assert f % x == r
q, r = Poly(0, x), Poly(2, x)
assert divmod(2, g) == (q, r)
assert 2 // g == q
assert 2 % g == r
assert Poly(x)/Poly(x) == 1
assert Poly(x**2)/Poly(x) == x
assert Poly(x)/Poly(x**2) == 1/x
def test_Poly_eq_ne():
assert (Poly(x + y, x, y) == Poly(x + y, x, y)) is True
assert (Poly(x + y, x) == Poly(x + y, x, y)) is False
assert (Poly(x + y, x, y) == Poly(x + y, x)) is False
assert (Poly(x + y, x) == Poly(x + y, x)) is True
assert (Poly(x + y, y) == Poly(x + y, y)) is True
assert (Poly(x + y, x, y) == x + y) is True
assert (Poly(x + y, x) == x + y) is True
assert (Poly(x + y, x, y) == x + y) is True
assert (Poly(x + y, x) == x + y) is True
assert (Poly(x + y, y) == x + y) is True
assert (Poly(x + y, x, y) != Poly(x + y, x, y)) is False
assert (Poly(x + y, x) != Poly(x + y, x, y)) is True
assert (Poly(x + y, x, y) != Poly(x + y, x)) is True
assert (Poly(x + y, x) != Poly(x + y, x)) is False
assert (Poly(x + y, y) != Poly(x + y, y)) is False
assert (Poly(x + y, x, y) != x + y) is False
assert (Poly(x + y, x) != x + y) is False
assert (Poly(x + y, x, y) != x + y) is False
assert (Poly(x + y, x) != x + y) is False
assert (Poly(x + y, y) != x + y) is False
assert (Poly(x, x) == sin(x)) is False
assert (Poly(x, x) != sin(x)) is True
def test_Poly_nonzero():
assert not bool(Poly(0, x)) is True
assert not bool(Poly(1, x)) is False
def test_Poly_properties():
assert Poly(0, x).is_zero is True
assert Poly(1, x).is_zero is False
assert Poly(1, x).is_one is True
assert Poly(2, x).is_one is False
assert Poly(x - 1, x).is_sqf is True
assert Poly((x - 1)**2, x).is_sqf is False
assert Poly(x - 1, x).is_monic is True
assert Poly(2*x - 1, x).is_monic is False
assert Poly(3*x + 2, x).is_primitive is True
assert Poly(4*x + 2, x).is_primitive is False
assert Poly(1, x).is_ground is True
assert Poly(x, x).is_ground is False
assert Poly(x + y + z + 1).is_linear is True
assert Poly(x*y*z + 1).is_linear is False
assert Poly(x*y + z + 1).is_quadratic is True
assert Poly(x*y*z + 1).is_quadratic is False
assert Poly(x*y).is_monomial is True
assert Poly(x*y + 1).is_monomial is False
assert Poly(x**2 + x*y).is_homogeneous is True
assert Poly(x**3 + x*y).is_homogeneous is False
assert Poly(x).is_univariate is True
assert Poly(x*y).is_univariate is False
assert Poly(x*y).is_multivariate is True
assert Poly(x).is_multivariate is False
assert Poly(
x**16 + x**14 - x**10 + x**8 - x**6 + x**2 + 1).is_cyclotomic is False
assert Poly(
x**16 + x**14 - x**10 - x**8 - x**6 + x**2 + 1).is_cyclotomic is True
def test_Poly_is_irreducible():
assert Poly(x**2 + x + 1).is_irreducible is True
assert Poly(x**2 + 2*x + 1).is_irreducible is False
assert Poly(7*x + 3, modulus=11).is_irreducible is True
assert Poly(7*x**2 + 3*x + 1, modulus=11).is_irreducible is False
def test_Poly_subs():
assert Poly(x + 1).subs(x, 0) == 1
assert Poly(x + 1).subs(x, x) == Poly(x + 1)
assert Poly(x + 1).subs(x, y) == Poly(y + 1)
assert Poly(x*y, x).subs(y, x) == x**2
assert Poly(x*y, x).subs(x, y) == y**2
def test_Poly_replace():
assert Poly(x + 1).replace(x) == Poly(x + 1)
assert Poly(x + 1).replace(y) == Poly(y + 1)
raises(PolynomialError, lambda: Poly(x + y).replace(z))
assert Poly(x + 1).replace(x, x) == Poly(x + 1)
assert Poly(x + 1).replace(x, y) == Poly(y + 1)
assert Poly(x + y).replace(x, x) == Poly(x + y)
assert Poly(x + y).replace(x, z) == Poly(z + y, z, y)
assert Poly(x + y).replace(y, y) == Poly(x + y)
assert Poly(x + y).replace(y, z) == Poly(x + z, x, z)
assert Poly(x + y).replace(z, t) == Poly(x + y)
raises(PolynomialError, lambda: Poly(x + y).replace(x, y))
assert Poly(x + y, x).replace(x, z) == Poly(z + y, z)
assert Poly(x + y, y).replace(y, z) == Poly(x + z, z)
raises(PolynomialError, lambda: Poly(x + y, x).replace(x, y))
raises(PolynomialError, lambda: Poly(x + y, y).replace(y, x))
def test_Poly_reorder():
raises(PolynomialError, lambda: Poly(x + y).reorder(x, z))
assert Poly(x + y, x, y).reorder(x, y) == Poly(x + y, x, y)
assert Poly(x + y, x, y).reorder(y, x) == Poly(x + y, y, x)
assert Poly(x + y, y, x).reorder(x, y) == Poly(x + y, x, y)
assert Poly(x + y, y, x).reorder(y, x) == Poly(x + y, y, x)
assert Poly(x + y, x, y).reorder(wrt=x) == Poly(x + y, x, y)
assert Poly(x + y, x, y).reorder(wrt=y) == Poly(x + y, y, x)
def test_Poly_ltrim():
f = Poly(y**2 + y*z**2, x, y, z).ltrim(y)
assert f.as_expr() == y**2 + y*z**2 and f.gens == (y, z)
assert Poly(x*y - x, z, x, y).ltrim(1) == Poly(x*y - x, x, y)
raises(PolynomialError, lambda: Poly(x*y**2 + y**2, x, y).ltrim(y))
raises(PolynomialError, lambda: Poly(x*y - x, x, y).ltrim(-1))
def test_Poly_has_only_gens():
assert Poly(x*y + 1, x, y, z).has_only_gens(x, y) is True
assert Poly(x*y + z, x, y, z).has_only_gens(x, y) is False
raises(GeneratorsError, lambda: Poly(x*y**2 + y**2, x, y).has_only_gens(t))
def test_Poly_to_ring():
assert Poly(2*x + 1, domain='ZZ').to_ring() == Poly(2*x + 1, domain='ZZ')
assert Poly(2*x + 1, domain='QQ').to_ring() == Poly(2*x + 1, domain='ZZ')
raises(CoercionFailed, lambda: Poly(x/2 + 1).to_ring())
raises(DomainError, lambda: Poly(2*x + 1, modulus=3).to_ring())
def test_Poly_to_field():
assert Poly(2*x + 1, domain='ZZ').to_field() == Poly(2*x + 1, domain='QQ')
assert Poly(2*x + 1, domain='QQ').to_field() == Poly(2*x + 1, domain='QQ')
assert Poly(x/2 + 1, domain='QQ').to_field() == Poly(x/2 + 1, domain='QQ')
assert Poly(2*x + 1, modulus=3).to_field() == Poly(2*x + 1, modulus=3)
assert Poly(2.0*x + 1.0).to_field() == Poly(2.0*x + 1.0)
def test_Poly_to_exact():
assert Poly(2*x).to_exact() == Poly(2*x)
assert Poly(x/2).to_exact() == Poly(x/2)
assert Poly(0.1*x).to_exact() == Poly(x/10)
def test_Poly_retract():
f = Poly(x**2 + 1, x, domain=QQ[y])
assert f.retract() == Poly(x**2 + 1, x, domain='ZZ')
assert f.retract(field=True) == Poly(x**2 + 1, x, domain='QQ')
assert Poly(0, x, y).retract() == Poly(0, x, y)
def test_Poly_slice():
f = Poly(x**3 + 2*x**2 + 3*x + 4)
assert f.slice(0, 0) == Poly(0, x)
assert f.slice(0, 1) == Poly(4, x)
assert f.slice(0, 2) == Poly(3*x + 4, x)
assert f.slice(0, 3) == Poly(2*x**2 + 3*x + 4, x)
assert f.slice(0, 4) == Poly(x**3 + 2*x**2 + 3*x + 4, x)
assert f.slice(x, 0, 0) == Poly(0, x)
assert f.slice(x, 0, 1) == Poly(4, x)
assert f.slice(x, 0, 2) == Poly(3*x + 4, x)
assert f.slice(x, 0, 3) == Poly(2*x**2 + 3*x + 4, x)
assert f.slice(x, 0, 4) == Poly(x**3 + 2*x**2 + 3*x + 4, x)
def test_Poly_coeffs():
assert Poly(0, x).coeffs() == [0]
assert Poly(1, x).coeffs() == [1]
assert Poly(2*x + 1, x).coeffs() == [2, 1]
assert Poly(7*x**2 + 2*x + 1, x).coeffs() == [7, 2, 1]
assert Poly(7*x**4 + 2*x + 1, x).coeffs() == [7, 2, 1]
assert Poly(x*y**7 + 2*x**2*y**3).coeffs('lex') == [2, 1]
assert Poly(x*y**7 + 2*x**2*y**3).coeffs('grlex') == [1, 2]
def test_Poly_monoms():
assert Poly(0, x).monoms() == [(0,)]
assert Poly(1, x).monoms() == [(0,)]
assert Poly(2*x + 1, x).monoms() == [(1,), (0,)]
assert Poly(7*x**2 + 2*x + 1, x).monoms() == [(2,), (1,), (0,)]
assert Poly(7*x**4 + 2*x + 1, x).monoms() == [(4,), (1,), (0,)]
assert Poly(x*y**7 + 2*x**2*y**3).monoms('lex') == [(2, 3), (1, 7)]
assert Poly(x*y**7 + 2*x**2*y**3).monoms('grlex') == [(1, 7), (2, 3)]
def test_Poly_terms():
assert Poly(0, x).terms() == [((0,), 0)]
assert Poly(1, x).terms() == [((0,), 1)]
assert Poly(2*x + 1, x).terms() == [((1,), 2), ((0,), 1)]
assert Poly(7*x**2 + 2*x + 1, x).terms() == [((2,), 7), ((1,), 2), ((0,), 1)]
assert Poly(7*x**4 + 2*x + 1, x).terms() == [((4,), 7), ((1,), 2), ((0,), 1)]
assert Poly(
x*y**7 + 2*x**2*y**3).terms('lex') == [((2, 3), 2), ((1, 7), 1)]
assert Poly(
x*y**7 + 2*x**2*y**3).terms('grlex') == [((1, 7), 1), ((2, 3), 2)]
def test_Poly_all_coeffs():
assert Poly(0, x).all_coeffs() == [0]
assert Poly(1, x).all_coeffs() == [1]
assert Poly(2*x + 1, x).all_coeffs() == [2, 1]
assert Poly(7*x**2 + 2*x + 1, x).all_coeffs() == [7, 2, 1]
assert Poly(7*x**4 + 2*x + 1, x).all_coeffs() == [7, 0, 0, 2, 1]
def test_Poly_all_monoms():
assert Poly(0, x).all_monoms() == [(0,)]
assert Poly(1, x).all_monoms() == [(0,)]
assert Poly(2*x + 1, x).all_monoms() == [(1,), (0,)]
assert Poly(7*x**2 + 2*x + 1, x).all_monoms() == [(2,), (1,), (0,)]
assert Poly(7*x**4 + 2*x + 1, x).all_monoms() == [(4,), (3,), (2,), (1,), (0,)]
def test_Poly_all_terms():
assert Poly(0, x).all_terms() == [((0,), 0)]
assert Poly(1, x).all_terms() == [((0,), 1)]
assert Poly(2*x + 1, x).all_terms() == [((1,), 2), ((0,), 1)]
assert Poly(7*x**2 + 2*x + 1, x).all_terms() == \
[((2,), 7), ((1,), 2), ((0,), 1)]
assert Poly(7*x**4 + 2*x + 1, x).all_terms() == \
[((4,), 7), ((3,), 0), ((2,), 0), ((1,), 2), ((0,), 1)]
def test_Poly_termwise():
f = Poly(x**2 + 20*x + 400)
g = Poly(x**2 + 2*x + 4)
def func(monom, coeff):
(k,) = monom
return coeff//10**(2 - k)
assert f.termwise(func) == g
def func(monom, coeff):
(k,) = monom
return (k,), coeff//10**(2 - k)
assert f.termwise(func) == g
def test_Poly_length():
assert Poly(0, x).length() == 0
assert Poly(1, x).length() == 1
assert Poly(x, x).length() == 1
assert Poly(x + 1, x).length() == 2
assert Poly(x**2 + 1, x).length() == 2
assert Poly(x**2 + x + 1, x).length() == 3
def test_Poly_as_dict():
assert Poly(0, x).as_dict() == {}
assert Poly(0, x, y, z).as_dict() == {}
assert Poly(1, x).as_dict() == {(0,): 1}
assert Poly(1, x, y, z).as_dict() == {(0, 0, 0): 1}
assert Poly(x**2 + 3, x).as_dict() == {(2,): 1, (0,): 3}
assert Poly(x**2 + 3, x, y, z).as_dict() == {(2, 0, 0): 1, (0, 0, 0): 3}
assert Poly(3*x**2*y*z**3 + 4*x*y + 5*x*z).as_dict() == {(2, 1, 3): 3,
(1, 1, 0): 4, (1, 0, 1): 5}
def test_Poly_as_expr():
assert Poly(0, x).as_expr() == 0
assert Poly(0, x, y, z).as_expr() == 0
assert Poly(1, x).as_expr() == 1
assert Poly(1, x, y, z).as_expr() == 1
assert Poly(x**2 + 3, x).as_expr() == x**2 + 3
assert Poly(x**2 + 3, x, y, z).as_expr() == x**2 + 3
assert Poly(
3*x**2*y*z**3 + 4*x*y + 5*x*z).as_expr() == 3*x**2*y*z**3 + 4*x*y + 5*x*z
f = Poly(x**2 + 2*x*y**2 - y, x, y)
assert f.as_expr() == -y + x**2 + 2*x*y**2
assert f.as_expr({x: 5}) == 25 - y + 10*y**2
assert f.as_expr({y: 6}) == -6 + 72*x + x**2
assert f.as_expr({x: 5, y: 6}) == 379
assert f.as_expr(5, 6) == 379
raises(GeneratorsError, lambda: f.as_expr({z: 7}))
def test_Poly_lift():
assert Poly(x**4 - I*x + 17*I, x, gaussian=True).lift() == \
Poly(x**16 + 2*x**10 + 578*x**8 + x**4 - 578*x**2 + 83521,
x, domain='QQ')
def test_Poly_deflate():
assert Poly(0, x).deflate() == ((1,), Poly(0, x))
assert Poly(1, x).deflate() == ((1,), Poly(1, x))
assert Poly(x, x).deflate() == ((1,), Poly(x, x))
assert Poly(x**2, x).deflate() == ((2,), Poly(x, x))
assert Poly(x**17, x).deflate() == ((17,), Poly(x, x))
assert Poly(
x**2*y*z**11 + x**4*z**11).deflate() == ((2, 1, 11), Poly(x*y*z + x**2*z))
def test_Poly_inject():
f = Poly(x**2*y + x*y**3 + x*y + 1, x)
assert f.inject() == Poly(x**2*y + x*y**3 + x*y + 1, x, y)
assert f.inject(front=True) == Poly(y**3*x + y*x**2 + y*x + 1, y, x)
def test_Poly_eject():
f = Poly(x**2*y + x*y**3 + x*y + 1, x, y)
assert f.eject(x) == Poly(x*y**3 + (x**2 + x)*y + 1, y, domain='ZZ[x]')
assert f.eject(y) == Poly(y*x**2 + (y**3 + y)*x + 1, x, domain='ZZ[y]')
ex = x + y + z + t + w
g = Poly(ex, x, y, z, t, w)
assert g.eject(x) == Poly(ex, y, z, t, w, domain='ZZ[x]')
assert g.eject(x, y) == Poly(ex, z, t, w, domain='ZZ[x, y]')
assert g.eject(x, y, z) == Poly(ex, t, w, domain='ZZ[x, y, z]')
assert g.eject(w) == Poly(ex, x, y, z, t, domain='ZZ[w]')
assert g.eject(t, w) == Poly(ex, x, y, z, domain='ZZ[t, w]')
assert g.eject(z, t, w) == Poly(ex, x, y, domain='ZZ[z, t, w]')
raises(DomainError, lambda: Poly(x*y, x, y, domain=ZZ[z]).eject(y))
raises(NotImplementedError, lambda: Poly(x*y, x, y, z).eject(y))
def test_Poly_exclude():
assert Poly(x, x, y).exclude() == Poly(x, x)
assert Poly(x*y, x, y).exclude() == Poly(x*y, x, y)
assert Poly(1, x, y).exclude() == Poly(1, x, y)
def test_Poly__gen_to_level():
assert Poly(1, x, y)._gen_to_level(-2) == 0
assert Poly(1, x, y)._gen_to_level(-1) == 1
assert Poly(1, x, y)._gen_to_level( 0) == 0
assert Poly(1, x, y)._gen_to_level( 1) == 1
raises(PolynomialError, lambda: Poly(1, x, y)._gen_to_level(-3))
raises(PolynomialError, lambda: Poly(1, x, y)._gen_to_level( 2))
assert Poly(1, x, y)._gen_to_level(x) == 0
assert Poly(1, x, y)._gen_to_level(y) == 1
assert Poly(1, x, y)._gen_to_level('x') == 0
assert Poly(1, x, y)._gen_to_level('y') == 1
raises(PolynomialError, lambda: Poly(1, x, y)._gen_to_level(z))
raises(PolynomialError, lambda: Poly(1, x, y)._gen_to_level('z'))
def test_Poly_degree():
assert Poly(0, x).degree() is -oo
assert Poly(1, x).degree() == 0
assert Poly(x, x).degree() == 1
assert Poly(0, x).degree(gen=0) is -oo
assert Poly(1, x).degree(gen=0) == 0
assert Poly(x, x).degree(gen=0) == 1
assert Poly(0, x).degree(gen=x) is -oo
assert Poly(1, x).degree(gen=x) == 0
assert Poly(x, x).degree(gen=x) == 1
assert Poly(0, x).degree(gen='x') is -oo
assert Poly(1, x).degree(gen='x') == 0
assert Poly(x, x).degree(gen='x') == 1
raises(PolynomialError, lambda: Poly(1, x).degree(gen=1))
raises(PolynomialError, lambda: Poly(1, x).degree(gen=y))
raises(PolynomialError, lambda: Poly(1, x).degree(gen='y'))
assert Poly(1, x, y).degree() == 0
assert Poly(2*y, x, y).degree() == 0
assert Poly(x*y, x, y).degree() == 1
assert Poly(1, x, y).degree(gen=x) == 0
assert Poly(2*y, x, y).degree(gen=x) == 0
assert Poly(x*y, x, y).degree(gen=x) == 1
assert Poly(1, x, y).degree(gen=y) == 0
assert Poly(2*y, x, y).degree(gen=y) == 1
assert Poly(x*y, x, y).degree(gen=y) == 1
assert degree(0, x) is -oo
assert degree(1, x) == 0
assert degree(x, x) == 1
assert degree(x*y**2, x) == 1
assert degree(x*y**2, y) == 2
assert degree(x*y**2, z) == 0
assert degree(pi) == 1
raises(TypeError, lambda: degree(y**2 + x**3))
raises(TypeError, lambda: degree(y**2 + x**3, 1))
raises(PolynomialError, lambda: degree(x, 1.1))
raises(PolynomialError, lambda: degree(x**2/(x**3 + 1), x))
assert degree(Poly(0,x),z) is -oo
assert degree(Poly(1,x),z) == 0
assert degree(Poly(x**2+y**3,y)) == 3
assert degree(Poly(y**2 + x**3, y, x), 1) == 3
assert degree(Poly(y**2 + x**3, x), z) == 0
assert degree(Poly(y**2 + x**3 + z**4, x), z) == 4
def test_Poly_degree_list():
assert Poly(0, x).degree_list() == (-oo,)
assert Poly(0, x, y).degree_list() == (-oo, -oo)
assert Poly(0, x, y, z).degree_list() == (-oo, -oo, -oo)
assert Poly(1, x).degree_list() == (0,)
assert Poly(1, x, y).degree_list() == (0, 0)
assert Poly(1, x, y, z).degree_list() == (0, 0, 0)
assert Poly(x**2*y + x**3*z**2 + 1).degree_list() == (3, 1, 2)
assert degree_list(1, x) == (0,)
assert degree_list(x, x) == (1,)
assert degree_list(x*y**2) == (1, 2)
raises(ComputationFailed, lambda: degree_list(1))
def test_Poly_total_degree():
assert Poly(x**2*y + x**3*z**2 + 1).total_degree() == 5
assert Poly(x**2 + z**3).total_degree() == 3
assert Poly(x*y*z + z**4).total_degree() == 4
assert Poly(x**3 + x + 1).total_degree() == 3
assert total_degree(x*y + z**3) == 3
assert total_degree(x*y + z**3, x, y) == 2
assert total_degree(1) == 0
assert total_degree(Poly(y**2 + x**3 + z**4)) == 4
assert total_degree(Poly(y**2 + x**3 + z**4, x)) == 3
assert total_degree(Poly(y**2 + x**3 + z**4, x), z) == 4
assert total_degree(Poly(x**9 + x*z*y + x**3*z**2 + z**7,x), z) == 7
def test_Poly_homogenize():
assert Poly(x**2+y).homogenize(z) == Poly(x**2+y*z)
assert Poly(x+y).homogenize(z) == Poly(x+y, x, y, z)
assert Poly(x+y**2).homogenize(y) == Poly(x*y+y**2)
def test_Poly_homogeneous_order():
assert Poly(0, x, y).homogeneous_order() is -oo
assert Poly(1, x, y).homogeneous_order() == 0
assert Poly(x, x, y).homogeneous_order() == 1
assert Poly(x*y, x, y).homogeneous_order() == 2
assert Poly(x + 1, x, y).homogeneous_order() is None
assert Poly(x*y + x, x, y).homogeneous_order() is None
assert Poly(x**5 + 2*x**3*y**2 + 9*x*y**4).homogeneous_order() == 5
assert Poly(x**5 + 2*x**3*y**3 + 9*x*y**4).homogeneous_order() is None
def test_Poly_LC():
assert Poly(0, x).LC() == 0
assert Poly(1, x).LC() == 1
assert Poly(2*x**2 + x, x).LC() == 2
assert Poly(x*y**7 + 2*x**2*y**3).LC('lex') == 2
assert Poly(x*y**7 + 2*x**2*y**3).LC('grlex') == 1
assert LC(x*y**7 + 2*x**2*y**3, order='lex') == 2
assert LC(x*y**7 + 2*x**2*y**3, order='grlex') == 1
def test_Poly_TC():
assert Poly(0, x).TC() == 0
assert Poly(1, x).TC() == 1
assert Poly(2*x**2 + x, x).TC() == 0
def test_Poly_EC():
assert Poly(0, x).EC() == 0
assert Poly(1, x).EC() == 1
assert Poly(2*x**2 + x, x).EC() == 1
assert Poly(x*y**7 + 2*x**2*y**3).EC('lex') == 1
assert Poly(x*y**7 + 2*x**2*y**3).EC('grlex') == 2
def test_Poly_coeff():
assert Poly(0, x).coeff_monomial(1) == 0
assert Poly(0, x).coeff_monomial(x) == 0
assert Poly(1, x).coeff_monomial(1) == 1
assert Poly(1, x).coeff_monomial(x) == 0
assert Poly(x**8, x).coeff_monomial(1) == 0
assert Poly(x**8, x).coeff_monomial(x**7) == 0
assert Poly(x**8, x).coeff_monomial(x**8) == 1
assert Poly(x**8, x).coeff_monomial(x**9) == 0
assert Poly(3*x*y**2 + 1, x, y).coeff_monomial(1) == 1
assert Poly(3*x*y**2 + 1, x, y).coeff_monomial(x*y**2) == 3
p = Poly(24*x*y*exp(8) + 23*x, x, y)
assert p.coeff_monomial(x) == 23
assert p.coeff_monomial(y) == 0
assert p.coeff_monomial(x*y) == 24*exp(8)
assert p.as_expr().coeff(x) == 24*y*exp(8) + 23
raises(NotImplementedError, lambda: p.coeff(x))
raises(ValueError, lambda: Poly(x + 1).coeff_monomial(0))
raises(ValueError, lambda: Poly(x + 1).coeff_monomial(3*x))
raises(ValueError, lambda: Poly(x + 1).coeff_monomial(3*x*y))
def test_Poly_nth():
assert Poly(0, x).nth(0) == 0
assert Poly(0, x).nth(1) == 0
assert Poly(1, x).nth(0) == 1
assert Poly(1, x).nth(1) == 0
assert Poly(x**8, x).nth(0) == 0
assert Poly(x**8, x).nth(7) == 0
assert Poly(x**8, x).nth(8) == 1
assert Poly(x**8, x).nth(9) == 0
assert Poly(3*x*y**2 + 1, x, y).nth(0, 0) == 1
assert Poly(3*x*y**2 + 1, x, y).nth(1, 2) == 3
raises(ValueError, lambda: Poly(x*y + 1, x, y).nth(1))
def test_Poly_LM():
assert Poly(0, x).LM() == (0,)
assert Poly(1, x).LM() == (0,)
assert Poly(2*x**2 + x, x).LM() == (2,)
assert Poly(x*y**7 + 2*x**2*y**3).LM('lex') == (2, 3)
assert Poly(x*y**7 + 2*x**2*y**3).LM('grlex') == (1, 7)
assert LM(x*y**7 + 2*x**2*y**3, order='lex') == x**2*y**3
assert LM(x*y**7 + 2*x**2*y**3, order='grlex') == x*y**7
def test_Poly_LM_custom_order():
f = Poly(x**2*y**3*z + x**2*y*z**3 + x*y*z + 1)
rev_lex = lambda monom: tuple(reversed(monom))
assert f.LM(order='lex') == (2, 3, 1)
assert f.LM(order=rev_lex) == (2, 1, 3)
def test_Poly_EM():
assert Poly(0, x).EM() == (0,)
assert Poly(1, x).EM() == (0,)
assert Poly(2*x**2 + x, x).EM() == (1,)
assert Poly(x*y**7 + 2*x**2*y**3).EM('lex') == (1, 7)
assert Poly(x*y**7 + 2*x**2*y**3).EM('grlex') == (2, 3)
def test_Poly_LT():
assert Poly(0, x).LT() == ((0,), 0)
assert Poly(1, x).LT() == ((0,), 1)
assert Poly(2*x**2 + x, x).LT() == ((2,), 2)
assert Poly(x*y**7 + 2*x**2*y**3).LT('lex') == ((2, 3), 2)
assert Poly(x*y**7 + 2*x**2*y**3).LT('grlex') == ((1, 7), 1)
assert LT(x*y**7 + 2*x**2*y**3, order='lex') == 2*x**2*y**3
assert LT(x*y**7 + 2*x**2*y**3, order='grlex') == x*y**7
def test_Poly_ET():
assert Poly(0, x).ET() == ((0,), 0)
assert Poly(1, x).ET() == ((0,), 1)
assert Poly(2*x**2 + x, x).ET() == ((1,), 1)
assert Poly(x*y**7 + 2*x**2*y**3).ET('lex') == ((1, 7), 1)
assert Poly(x*y**7 + 2*x**2*y**3).ET('grlex') == ((2, 3), 2)
def test_Poly_max_norm():
assert Poly(-1, x).max_norm() == 1
assert Poly( 0, x).max_norm() == 0
assert Poly( 1, x).max_norm() == 1
def test_Poly_l1_norm():
assert Poly(-1, x).l1_norm() == 1
assert Poly( 0, x).l1_norm() == 0
assert Poly( 1, x).l1_norm() == 1
def test_Poly_clear_denoms():
coeff, poly = Poly(x + 2, x).clear_denoms()
assert coeff == 1 and poly == Poly(
x + 2, x, domain='ZZ') and poly.get_domain() == ZZ
coeff, poly = Poly(x/2 + 1, x).clear_denoms()
assert coeff == 2 and poly == Poly(
x + 2, x, domain='QQ') and poly.get_domain() == QQ
coeff, poly = Poly(x/2 + 1, x).clear_denoms(convert=True)
assert coeff == 2 and poly == Poly(
x + 2, x, domain='ZZ') and poly.get_domain() == ZZ
coeff, poly = Poly(x/y + 1, x).clear_denoms(convert=True)
assert coeff == y and poly == Poly(
x + y, x, domain='ZZ[y]') and poly.get_domain() == ZZ[y]
coeff, poly = Poly(x/3 + sqrt(2), x, domain='EX').clear_denoms()
assert coeff == 3 and poly == Poly(
x + 3*sqrt(2), x, domain='EX') and poly.get_domain() == EX
coeff, poly = Poly(
x/3 + sqrt(2), x, domain='EX').clear_denoms(convert=True)
assert coeff == 3 and poly == Poly(
x + 3*sqrt(2), x, domain='EX') and poly.get_domain() == EX
def test_Poly_rat_clear_denoms():
f = Poly(x**2/y + 1, x)
g = Poly(x**3 + y, x)
assert f.rat_clear_denoms(g) == \
(Poly(x**2 + y, x), Poly(y*x**3 + y**2, x))
f = f.set_domain(EX)
g = g.set_domain(EX)
assert f.rat_clear_denoms(g) == (f, g)
def test_Poly_integrate():
assert Poly(x + 1).integrate() == Poly(x**2/2 + x)
assert Poly(x + 1).integrate(x) == Poly(x**2/2 + x)
assert Poly(x + 1).integrate((x, 1)) == Poly(x**2/2 + x)
assert Poly(x*y + 1).integrate(x) == Poly(x**2*y/2 + x)
assert Poly(x*y + 1).integrate(y) == Poly(x*y**2/2 + y)
assert Poly(x*y + 1).integrate(x, x) == Poly(x**3*y/6 + x**2/2)
assert Poly(x*y + 1).integrate(y, y) == Poly(x*y**3/6 + y**2/2)
assert Poly(x*y + 1).integrate((x, 2)) == Poly(x**3*y/6 + x**2/2)
assert Poly(x*y + 1).integrate((y, 2)) == Poly(x*y**3/6 + y**2/2)
assert Poly(x*y + 1).integrate(x, y) == Poly(x**2*y**2/4 + x*y)
assert Poly(x*y + 1).integrate(y, x) == Poly(x**2*y**2/4 + x*y)
def test_Poly_diff():
assert Poly(x**2 + x).diff() == Poly(2*x + 1)
assert Poly(x**2 + x).diff(x) == Poly(2*x + 1)
assert Poly(x**2 + x).diff((x, 1)) == Poly(2*x + 1)
assert Poly(x**2*y**2 + x*y).diff(x) == Poly(2*x*y**2 + y)
assert Poly(x**2*y**2 + x*y).diff(y) == Poly(2*x**2*y + x)
assert Poly(x**2*y**2 + x*y).diff(x, x) == Poly(2*y**2, x, y)
assert Poly(x**2*y**2 + x*y).diff(y, y) == Poly(2*x**2, x, y)
assert Poly(x**2*y**2 + x*y).diff((x, 2)) == Poly(2*y**2, x, y)
assert Poly(x**2*y**2 + x*y).diff((y, 2)) == Poly(2*x**2, x, y)
assert Poly(x**2*y**2 + x*y).diff(x, y) == Poly(4*x*y + 1)
assert Poly(x**2*y**2 + x*y).diff(y, x) == Poly(4*x*y + 1)
def test_issue_9585():
assert diff(Poly(x**2 + x)) == Poly(2*x + 1)
assert diff(Poly(x**2 + x), x, evaluate=False) == \
Derivative(Poly(x**2 + x), x)
assert Derivative(Poly(x**2 + x), x).doit() == Poly(2*x + 1)
def test_Poly_eval():
assert Poly(0, x).eval(7) == 0
assert Poly(1, x).eval(7) == 1
assert Poly(x, x).eval(7) == 7
assert Poly(0, x).eval(0, 7) == 0
assert Poly(1, x).eval(0, 7) == 1
assert Poly(x, x).eval(0, 7) == 7
assert Poly(0, x).eval(x, 7) == 0
assert Poly(1, x).eval(x, 7) == 1
assert Poly(x, x).eval(x, 7) == 7
assert Poly(0, x).eval('x', 7) == 0
assert Poly(1, x).eval('x', 7) == 1
assert Poly(x, x).eval('x', 7) == 7
raises(PolynomialError, lambda: Poly(1, x).eval(1, 7))
raises(PolynomialError, lambda: Poly(1, x).eval(y, 7))
raises(PolynomialError, lambda: Poly(1, x).eval('y', 7))
assert Poly(123, x, y).eval(7) == Poly(123, y)
assert Poly(2*y, x, y).eval(7) == Poly(2*y, y)
assert Poly(x*y, x, y).eval(7) == Poly(7*y, y)
assert Poly(123, x, y).eval(x, 7) == Poly(123, y)
assert Poly(2*y, x, y).eval(x, 7) == Poly(2*y, y)
assert Poly(x*y, x, y).eval(x, 7) == Poly(7*y, y)
assert Poly(123, x, y).eval(y, 7) == Poly(123, x)
assert Poly(2*y, x, y).eval(y, 7) == Poly(14, x)
assert Poly(x*y, x, y).eval(y, 7) == Poly(7*x, x)
assert Poly(x*y + y, x, y).eval({x: 7}) == Poly(8*y, y)
assert Poly(x*y + y, x, y).eval({y: 7}) == Poly(7*x + 7, x)
assert Poly(x*y + y, x, y).eval({x: 6, y: 7}) == 49
assert Poly(x*y + y, x, y).eval({x: 7, y: 6}) == 48
assert Poly(x*y + y, x, y).eval((6, 7)) == 49
assert Poly(x*y + y, x, y).eval([6, 7]) == 49
assert Poly(x + 1, domain='ZZ').eval(S.Half) == Rational(3, 2)
assert Poly(x + 1, domain='ZZ').eval(sqrt(2)) == sqrt(2) + 1
raises(ValueError, lambda: Poly(x*y + y, x, y).eval((6, 7, 8)))
raises(DomainError, lambda: Poly(x + 1, domain='ZZ').eval(S.Half, auto=False))
# issue 6344
alpha = Symbol('alpha')
result = (2*alpha*z - 2*alpha + z**2 + 3)/(z**2 - 2*z + 1)
f = Poly(x**2 + (alpha - 1)*x - alpha + 1, x, domain='ZZ[alpha]')
assert f.eval((z + 1)/(z - 1)) == result
g = Poly(x**2 + (alpha - 1)*x - alpha + 1, x, y, domain='ZZ[alpha]')
assert g.eval((z + 1)/(z - 1)) == Poly(result, y, domain='ZZ(alpha,z)')
def test_Poly___call__():
f = Poly(2*x*y + 3*x + y + 2*z)
assert f(2) == Poly(5*y + 2*z + 6)
assert f(2, 5) == Poly(2*z + 31)
assert f(2, 5, 7) == 45
def test_parallel_poly_from_expr():
assert parallel_poly_from_expr(
[x - 1, x**2 - 1], x)[0] == [Poly(x - 1, x), Poly(x**2 - 1, x)]
assert parallel_poly_from_expr(
[Poly(x - 1, x), x**2 - 1], x)[0] == [Poly(x - 1, x), Poly(x**2 - 1, x)]
assert parallel_poly_from_expr(
[x - 1, Poly(x**2 - 1, x)], x)[0] == [Poly(x - 1, x), Poly(x**2 - 1, x)]
assert parallel_poly_from_expr([Poly(
x - 1, x), Poly(x**2 - 1, x)], x)[0] == [Poly(x - 1, x), Poly(x**2 - 1, x)]
assert parallel_poly_from_expr(
[x - 1, x**2 - 1], x, y)[0] == [Poly(x - 1, x, y), Poly(x**2 - 1, x, y)]
assert parallel_poly_from_expr([Poly(
x - 1, x), x**2 - 1], x, y)[0] == [Poly(x - 1, x, y), Poly(x**2 - 1, x, y)]
assert parallel_poly_from_expr([x - 1, Poly(
x**2 - 1, x)], x, y)[0] == [Poly(x - 1, x, y), Poly(x**2 - 1, x, y)]
assert parallel_poly_from_expr([Poly(x - 1, x), Poly(
x**2 - 1, x)], x, y)[0] == [Poly(x - 1, x, y), Poly(x**2 - 1, x, y)]
assert parallel_poly_from_expr(
[x - 1, x**2 - 1])[0] == [Poly(x - 1, x), Poly(x**2 - 1, x)]
assert parallel_poly_from_expr(
[Poly(x - 1, x), x**2 - 1])[0] == [Poly(x - 1, x), Poly(x**2 - 1, x)]
assert parallel_poly_from_expr(
[x - 1, Poly(x**2 - 1, x)])[0] == [Poly(x - 1, x), Poly(x**2 - 1, x)]
assert parallel_poly_from_expr(
[Poly(x - 1, x), Poly(x**2 - 1, x)])[0] == [Poly(x - 1, x), Poly(x**2 - 1, x)]
assert parallel_poly_from_expr(
[1, x**2 - 1])[0] == [Poly(1, x), Poly(x**2 - 1, x)]
assert parallel_poly_from_expr(
[1, x**2 - 1])[0] == [Poly(1, x), Poly(x**2 - 1, x)]
assert parallel_poly_from_expr(
[1, Poly(x**2 - 1, x)])[0] == [Poly(1, x), Poly(x**2 - 1, x)]
assert parallel_poly_from_expr(
[1, Poly(x**2 - 1, x)])[0] == [Poly(1, x), Poly(x**2 - 1, x)]
assert parallel_poly_from_expr(
[x**2 - 1, 1])[0] == [Poly(x**2 - 1, x), Poly(1, x)]
assert parallel_poly_from_expr(
[x**2 - 1, 1])[0] == [Poly(x**2 - 1, x), Poly(1, x)]
assert parallel_poly_from_expr(
[Poly(x**2 - 1, x), 1])[0] == [Poly(x**2 - 1, x), Poly(1, x)]
assert parallel_poly_from_expr(
[Poly(x**2 - 1, x), 1])[0] == [Poly(x**2 - 1, x), Poly(1, x)]
assert parallel_poly_from_expr([Poly(x, x, y), Poly(y, x, y)], x, y, order='lex')[0] == \
[Poly(x, x, y, domain='ZZ'), Poly(y, x, y, domain='ZZ')]
raises(PolificationFailed, lambda: parallel_poly_from_expr([0, 1]))
def test_pdiv():
f, g = x**2 - y**2, x - y
q, r = x + y, 0
F, G, Q, R = [ Poly(h, x, y) for h in (f, g, q, r) ]
assert F.pdiv(G) == (Q, R)
assert F.prem(G) == R
assert F.pquo(G) == Q
assert F.pexquo(G) == Q
assert pdiv(f, g) == (q, r)
assert prem(f, g) == r
assert pquo(f, g) == q
assert pexquo(f, g) == q
assert pdiv(f, g, x, y) == (q, r)
assert prem(f, g, x, y) == r
assert pquo(f, g, x, y) == q
assert pexquo(f, g, x, y) == q
assert pdiv(f, g, (x, y)) == (q, r)
assert prem(f, g, (x, y)) == r
assert pquo(f, g, (x, y)) == q
assert pexquo(f, g, (x, y)) == q
assert pdiv(F, G) == (Q, R)
assert prem(F, G) == R
assert pquo(F, G) == Q
assert pexquo(F, G) == Q
assert pdiv(f, g, polys=True) == (Q, R)
assert prem(f, g, polys=True) == R
assert pquo(f, g, polys=True) == Q
assert pexquo(f, g, polys=True) == Q
assert pdiv(F, G, polys=False) == (q, r)
assert prem(F, G, polys=False) == r
assert pquo(F, G, polys=False) == q
assert pexquo(F, G, polys=False) == q
raises(ComputationFailed, lambda: pdiv(4, 2))
raises(ComputationFailed, lambda: prem(4, 2))
raises(ComputationFailed, lambda: pquo(4, 2))
raises(ComputationFailed, lambda: pexquo(4, 2))
def test_div():
f, g = x**2 - y**2, x - y
q, r = x + y, 0
F, G, Q, R = [ Poly(h, x, y) for h in (f, g, q, r) ]
assert F.div(G) == (Q, R)
assert F.rem(G) == R
assert F.quo(G) == Q
assert F.exquo(G) == Q
assert div(f, g) == (q, r)
assert rem(f, g) == r
assert quo(f, g) == q
assert exquo(f, g) == q
assert div(f, g, x, y) == (q, r)
assert rem(f, g, x, y) == r
assert quo(f, g, x, y) == q
assert exquo(f, g, x, y) == q
assert div(f, g, (x, y)) == (q, r)
assert rem(f, g, (x, y)) == r
assert quo(f, g, (x, y)) == q
assert exquo(f, g, (x, y)) == q
assert div(F, G) == (Q, R)
assert rem(F, G) == R
assert quo(F, G) == Q
assert exquo(F, G) == Q
assert div(f, g, polys=True) == (Q, R)
assert rem(f, g, polys=True) == R
assert quo(f, g, polys=True) == Q
assert exquo(f, g, polys=True) == Q
assert div(F, G, polys=False) == (q, r)
assert rem(F, G, polys=False) == r
assert quo(F, G, polys=False) == q
assert exquo(F, G, polys=False) == q
raises(ComputationFailed, lambda: div(4, 2))
raises(ComputationFailed, lambda: rem(4, 2))
raises(ComputationFailed, lambda: quo(4, 2))
raises(ComputationFailed, lambda: exquo(4, 2))
f, g = x**2 + 1, 2*x - 4
qz, rz = 0, x**2 + 1
qq, rq = x/2 + 1, 5
assert div(f, g) == (qq, rq)
assert div(f, g, auto=True) == (qq, rq)
assert div(f, g, auto=False) == (qz, rz)
assert div(f, g, domain=ZZ) == (qz, rz)
assert div(f, g, domain=QQ) == (qq, rq)
assert div(f, g, domain=ZZ, auto=True) == (qq, rq)
assert div(f, g, domain=ZZ, auto=False) == (qz, rz)
assert div(f, g, domain=QQ, auto=True) == (qq, rq)
assert div(f, g, domain=QQ, auto=False) == (qq, rq)
assert rem(f, g) == rq
assert rem(f, g, auto=True) == rq
assert rem(f, g, auto=False) == rz
assert rem(f, g, domain=ZZ) == rz
assert rem(f, g, domain=QQ) == rq
assert rem(f, g, domain=ZZ, auto=True) == rq
assert rem(f, g, domain=ZZ, auto=False) == rz
assert rem(f, g, domain=QQ, auto=True) == rq
assert rem(f, g, domain=QQ, auto=False) == rq
assert quo(f, g) == qq
assert quo(f, g, auto=True) == qq
assert quo(f, g, auto=False) == qz
assert quo(f, g, domain=ZZ) == qz
assert quo(f, g, domain=QQ) == qq
assert quo(f, g, domain=ZZ, auto=True) == qq
assert quo(f, g, domain=ZZ, auto=False) == qz
assert quo(f, g, domain=QQ, auto=True) == qq
assert quo(f, g, domain=QQ, auto=False) == qq
f, g, q = x**2, 2*x, x/2
assert exquo(f, g) == q
assert exquo(f, g, auto=True) == q
raises(ExactQuotientFailed, lambda: exquo(f, g, auto=False))
raises(ExactQuotientFailed, lambda: exquo(f, g, domain=ZZ))
assert exquo(f, g, domain=QQ) == q
assert exquo(f, g, domain=ZZ, auto=True) == q
raises(ExactQuotientFailed, lambda: exquo(f, g, domain=ZZ, auto=False))
assert exquo(f, g, domain=QQ, auto=True) == q
assert exquo(f, g, domain=QQ, auto=False) == q
f, g = Poly(x**2), Poly(x)
q, r = f.div(g)
assert q.get_domain().is_ZZ and r.get_domain().is_ZZ
r = f.rem(g)
assert r.get_domain().is_ZZ
q = f.quo(g)
assert q.get_domain().is_ZZ
q = f.exquo(g)
assert q.get_domain().is_ZZ
f, g = Poly(x+y, x), Poly(2*x+y, x)
q, r = f.div(g)
assert q.get_domain().is_Frac and r.get_domain().is_Frac
def test_issue_7864():
q, r = div(a, .408248290463863*a)
assert abs(q - 2.44948974278318) < 1e-14
assert r == 0
def test_gcdex():
f, g = 2*x, x**2 - 16
s, t, h = x/32, Rational(-1, 16), 1
F, G, S, T, H = [ Poly(u, x, domain='QQ') for u in (f, g, s, t, h) ]
assert F.half_gcdex(G) == (S, H)
assert F.gcdex(G) == (S, T, H)
assert F.invert(G) == S
assert half_gcdex(f, g) == (s, h)
assert gcdex(f, g) == (s, t, h)
assert invert(f, g) == s
assert half_gcdex(f, g, x) == (s, h)
assert gcdex(f, g, x) == (s, t, h)
assert invert(f, g, x) == s
assert half_gcdex(f, g, (x,)) == (s, h)
assert gcdex(f, g, (x,)) == (s, t, h)
assert invert(f, g, (x,)) == s
assert half_gcdex(F, G) == (S, H)
assert gcdex(F, G) == (S, T, H)
assert invert(F, G) == S
assert half_gcdex(f, g, polys=True) == (S, H)
assert gcdex(f, g, polys=True) == (S, T, H)
assert invert(f, g, polys=True) == S
assert half_gcdex(F, G, polys=False) == (s, h)
assert gcdex(F, G, polys=False) == (s, t, h)
assert invert(F, G, polys=False) == s
assert half_gcdex(100, 2004) == (-20, 4)
assert gcdex(100, 2004) == (-20, 1, 4)
assert invert(3, 7) == 5
raises(DomainError, lambda: half_gcdex(x + 1, 2*x + 1, auto=False))
raises(DomainError, lambda: gcdex(x + 1, 2*x + 1, auto=False))
raises(DomainError, lambda: invert(x + 1, 2*x + 1, auto=False))
def test_revert():
f = Poly(1 - x**2/2 + x**4/24 - x**6/720)
g = Poly(61*x**6/720 + 5*x**4/24 + x**2/2 + 1)
assert f.revert(8) == g
def test_subresultants():
f, g, h = x**2 - 2*x + 1, x**2 - 1, 2*x - 2
F, G, H = Poly(f), Poly(g), Poly(h)
assert F.subresultants(G) == [F, G, H]
assert subresultants(f, g) == [f, g, h]
assert subresultants(f, g, x) == [f, g, h]
assert subresultants(f, g, (x,)) == [f, g, h]
assert subresultants(F, G) == [F, G, H]
assert subresultants(f, g, polys=True) == [F, G, H]
assert subresultants(F, G, polys=False) == [f, g, h]
raises(ComputationFailed, lambda: subresultants(4, 2))
def test_resultant():
f, g, h = x**2 - 2*x + 1, x**2 - 1, 0
F, G = Poly(f), Poly(g)
assert F.resultant(G) == h
assert resultant(f, g) == h
assert resultant(f, g, x) == h
assert resultant(f, g, (x,)) == h
assert resultant(F, G) == h
assert resultant(f, g, polys=True) == h
assert resultant(F, G, polys=False) == h
assert resultant(f, g, includePRS=True) == (h, [f, g, 2*x - 2])
f, g, h = x - a, x - b, a - b
F, G, H = Poly(f), Poly(g), Poly(h)
assert F.resultant(G) == H
assert resultant(f, g) == h
assert resultant(f, g, x) == h
assert resultant(f, g, (x,)) == h
assert resultant(F, G) == H
assert resultant(f, g, polys=True) == H
assert resultant(F, G, polys=False) == h
raises(ComputationFailed, lambda: resultant(4, 2))
def test_discriminant():
f, g = x**3 + 3*x**2 + 9*x - 13, -11664
F = Poly(f)
assert F.discriminant() == g
assert discriminant(f) == g
assert discriminant(f, x) == g
assert discriminant(f, (x,)) == g
assert discriminant(F) == g
assert discriminant(f, polys=True) == g
assert discriminant(F, polys=False) == g
f, g = a*x**2 + b*x + c, b**2 - 4*a*c
F, G = Poly(f), Poly(g)
assert F.discriminant() == G
assert discriminant(f) == g
assert discriminant(f, x, a, b, c) == g
assert discriminant(f, (x, a, b, c)) == g
assert discriminant(F) == G
assert discriminant(f, polys=True) == G
assert discriminant(F, polys=False) == g
raises(ComputationFailed, lambda: discriminant(4))
def test_dispersion():
# We test only the API here. For more mathematical
# tests see the dedicated test file.
fp = poly((x + 1)*(x + 2), x)
assert sorted(fp.dispersionset()) == [0, 1]
assert fp.dispersion() == 1
fp = poly(x**4 - 3*x**2 + 1, x)
gp = fp.shift(-3)
assert sorted(fp.dispersionset(gp)) == [2, 3, 4]
assert fp.dispersion(gp) == 4
def test_gcd_list():
F = [x**3 - 1, x**2 - 1, x**2 - 3*x + 2]
assert gcd_list(F) == x - 1
assert gcd_list(F, polys=True) == Poly(x - 1)
assert gcd_list([]) == 0
assert gcd_list([1, 2]) == 1
assert gcd_list([4, 6, 8]) == 2
assert gcd_list([x*(y + 42) - x*y - x*42]) == 0
gcd = gcd_list([], x)
assert gcd.is_Number and gcd is S.Zero
gcd = gcd_list([], x, polys=True)
assert gcd.is_Poly and gcd.is_zero
raises(ComputationFailed, lambda: gcd_list([], polys=True))
def test_lcm_list():
F = [x**3 - 1, x**2 - 1, x**2 - 3*x + 2]
assert lcm_list(F) == x**5 - x**4 - 2*x**3 - x**2 + x + 2
assert lcm_list(F, polys=True) == Poly(x**5 - x**4 - 2*x**3 - x**2 + x + 2)
assert lcm_list([]) == 1
assert lcm_list([1, 2]) == 2
assert lcm_list([4, 6, 8]) == 24
assert lcm_list([x*(y + 42) - x*y - x*42]) == 0
lcm = lcm_list([], x)
assert lcm.is_Number and lcm is S.One
lcm = lcm_list([], x, polys=True)
assert lcm.is_Poly and lcm.is_one
raises(ComputationFailed, lambda: lcm_list([], polys=True))
def test_gcd():
f, g = x**3 - 1, x**2 - 1
s, t = x**2 + x + 1, x + 1
h, r = x - 1, x**4 + x**3 - x - 1
F, G, S, T, H, R = [ Poly(u) for u in (f, g, s, t, h, r) ]
assert F.cofactors(G) == (H, S, T)
assert F.gcd(G) == H
assert F.lcm(G) == R
assert cofactors(f, g) == (h, s, t)
assert gcd(f, g) == h
assert lcm(f, g) == r
assert cofactors(f, g, x) == (h, s, t)
assert gcd(f, g, x) == h
assert lcm(f, g, x) == r
assert cofactors(f, g, (x,)) == (h, s, t)
assert gcd(f, g, (x,)) == h
assert lcm(f, g, (x,)) == r
assert cofactors(F, G) == (H, S, T)
assert gcd(F, G) == H
assert lcm(F, G) == R
assert cofactors(f, g, polys=True) == (H, S, T)
assert gcd(f, g, polys=True) == H
assert lcm(f, g, polys=True) == R
assert cofactors(F, G, polys=False) == (h, s, t)
assert gcd(F, G, polys=False) == h
assert lcm(F, G, polys=False) == r
f, g = 1.0*x**2 - 1.0, 1.0*x - 1.0
h, s, t = g, 1.0*x + 1.0, 1.0
assert cofactors(f, g) == (h, s, t)
assert gcd(f, g) == h
assert lcm(f, g) == f
f, g = 1.0*x**2 - 1.0, 1.0*x - 1.0
h, s, t = g, 1.0*x + 1.0, 1.0
assert cofactors(f, g) == (h, s, t)
assert gcd(f, g) == h
assert lcm(f, g) == f
assert cofactors(8, 6) == (2, 4, 3)
assert gcd(8, 6) == 2
assert lcm(8, 6) == 24
f, g = x**2 - 3*x - 4, x**3 - 4*x**2 + x - 4
l = x**4 - 3*x**3 - 3*x**2 - 3*x - 4
h, s, t = x - 4, x + 1, x**2 + 1
assert cofactors(f, g, modulus=11) == (h, s, t)
assert gcd(f, g, modulus=11) == h
assert lcm(f, g, modulus=11) == l
f, g = x**2 + 8*x + 7, x**3 + 7*x**2 + x + 7
l = x**4 + 8*x**3 + 8*x**2 + 8*x + 7
h, s, t = x + 7, x + 1, x**2 + 1
assert cofactors(f, g, modulus=11, symmetric=False) == (h, s, t)
assert gcd(f, g, modulus=11, symmetric=False) == h
assert lcm(f, g, modulus=11, symmetric=False) == l
raises(TypeError, lambda: gcd(x))
raises(TypeError, lambda: lcm(x))
def test_gcd_numbers_vs_polys():
assert isinstance(gcd(3, 9), Integer)
assert isinstance(gcd(3*x, 9), Integer)
assert gcd(3, 9) == 3
assert gcd(3*x, 9) == 3
assert isinstance(gcd(Rational(3, 2), Rational(9, 4)), Rational)
assert isinstance(gcd(Rational(3, 2)*x, Rational(9, 4)), Rational)
assert gcd(Rational(3, 2), Rational(9, 4)) == Rational(3, 4)
assert gcd(Rational(3, 2)*x, Rational(9, 4)) == 1
assert isinstance(gcd(3.0, 9.0), Float)
assert isinstance(gcd(3.0*x, 9.0), Float)
assert gcd(3.0, 9.0) == 1.0
assert gcd(3.0*x, 9.0) == 1.0
def test_terms_gcd():
assert terms_gcd(1) == 1
assert terms_gcd(1, x) == 1
assert terms_gcd(x - 1) == x - 1
assert terms_gcd(-x - 1) == -x - 1
assert terms_gcd(2*x + 3) == 2*x + 3
assert terms_gcd(6*x + 4) == Mul(2, 3*x + 2, evaluate=False)
assert terms_gcd(x**3*y + x*y**3) == x*y*(x**2 + y**2)
assert terms_gcd(2*x**3*y + 2*x*y**3) == 2*x*y*(x**2 + y**2)
assert terms_gcd(x**3*y/2 + x*y**3/2) == x*y/2*(x**2 + y**2)
assert terms_gcd(x**3*y + 2*x*y**3) == x*y*(x**2 + 2*y**2)
assert terms_gcd(2*x**3*y + 4*x*y**3) == 2*x*y*(x**2 + 2*y**2)
assert terms_gcd(2*x**3*y/3 + 4*x*y**3/5) == x*y*Rational(2, 15)*(5*x**2 + 6*y**2)
assert terms_gcd(2.0*x**3*y + 4.1*x*y**3) == x*y*(2.0*x**2 + 4.1*y**2)
assert _aresame(terms_gcd(2.0*x + 3), 2.0*x + 3)
assert terms_gcd((3 + 3*x)*(x + x*y), expand=False) == \
(3*x + 3)*(x*y + x)
assert terms_gcd((3 + 3*x)*(x + x*sin(3 + 3*y)), expand=False, deep=True) == \
3*x*(x + 1)*(sin(Mul(3, y + 1, evaluate=False)) + 1)
assert terms_gcd(sin(x + x*y), deep=True) == \
sin(x*(y + 1))
eq = Eq(2*x, 2*y + 2*z*y)
assert terms_gcd(eq) == Eq(2*x, 2*y*(z + 1))
assert terms_gcd(eq, deep=True) == Eq(2*x, 2*y*(z + 1))
raises(TypeError, lambda: terms_gcd(x < 2))
def test_trunc():
f, g = x**5 + 2*x**4 + 3*x**3 + 4*x**2 + 5*x + 6, x**5 - x**4 + x**2 - x
F, G = Poly(f), Poly(g)
assert F.trunc(3) == G
assert trunc(f, 3) == g
assert trunc(f, 3, x) == g
assert trunc(f, 3, (x,)) == g
assert trunc(F, 3) == G
assert trunc(f, 3, polys=True) == G
assert trunc(F, 3, polys=False) == g
f, g = 6*x**5 + 5*x**4 + 4*x**3 + 3*x**2 + 2*x + 1, -x**4 + x**3 - x + 1
F, G = Poly(f), Poly(g)
assert F.trunc(3) == G
assert trunc(f, 3) == g
assert trunc(f, 3, x) == g
assert trunc(f, 3, (x,)) == g
assert trunc(F, 3) == G
assert trunc(f, 3, polys=True) == G
assert trunc(F, 3, polys=False) == g
f = Poly(x**2 + 2*x + 3, modulus=5)
assert f.trunc(2) == Poly(x**2 + 1, modulus=5)
def test_monic():
f, g = 2*x - 1, x - S.Half
F, G = Poly(f, domain='QQ'), Poly(g)
assert F.monic() == G
assert monic(f) == g
assert monic(f, x) == g
assert monic(f, (x,)) == g
assert monic(F) == G
assert monic(f, polys=True) == G
assert monic(F, polys=False) == g
raises(ComputationFailed, lambda: monic(4))
assert monic(2*x**2 + 6*x + 4, auto=False) == x**2 + 3*x + 2
raises(ExactQuotientFailed, lambda: monic(2*x + 6*x + 1, auto=False))
assert monic(2.0*x**2 + 6.0*x + 4.0) == 1.0*x**2 + 3.0*x + 2.0
assert monic(2*x**2 + 3*x + 4, modulus=5) == x**2 - x + 2
def test_content():
f, F = 4*x + 2, Poly(4*x + 2)
assert F.content() == 2
assert content(f) == 2
raises(ComputationFailed, lambda: content(4))
f = Poly(2*x, modulus=3)
assert f.content() == 1
def test_primitive():
f, g = 4*x + 2, 2*x + 1
F, G = Poly(f), Poly(g)
assert F.primitive() == (2, G)
assert primitive(f) == (2, g)
assert primitive(f, x) == (2, g)
assert primitive(f, (x,)) == (2, g)
assert primitive(F) == (2, G)
assert primitive(f, polys=True) == (2, G)
assert primitive(F, polys=False) == (2, g)
raises(ComputationFailed, lambda: primitive(4))
f = Poly(2*x, modulus=3)
g = Poly(2.0*x, domain=RR)
assert f.primitive() == (1, f)
assert g.primitive() == (1.0, g)
assert primitive(S('-3*x/4 + y + 11/8')) == \
S('(1/8, -6*x + 8*y + 11)')
def test_compose():
f = x**12 + 20*x**10 + 150*x**8 + 500*x**6 + 625*x**4 - 2*x**3 - 10*x + 9
g = x**4 - 2*x + 9
h = x**3 + 5*x
F, G, H = map(Poly, (f, g, h))
assert G.compose(H) == F
assert compose(g, h) == f
assert compose(g, h, x) == f
assert compose(g, h, (x,)) == f
assert compose(G, H) == F
assert compose(g, h, polys=True) == F
assert compose(G, H, polys=False) == f
assert F.decompose() == [G, H]
assert decompose(f) == [g, h]
assert decompose(f, x) == [g, h]
assert decompose(f, (x,)) == [g, h]
assert decompose(F) == [G, H]
assert decompose(f, polys=True) == [G, H]
assert decompose(F, polys=False) == [g, h]
raises(ComputationFailed, lambda: compose(4, 2))
raises(ComputationFailed, lambda: decompose(4))
assert compose(x**2 - y**2, x - y, x, y) == x**2 - 2*x*y
assert compose(x**2 - y**2, x - y, y, x) == -y**2 + 2*x*y
def test_shift():
assert Poly(x**2 - 2*x + 1, x).shift(2) == Poly(x**2 + 2*x + 1, x)
def test_transform():
# Also test that 3-way unification is done correctly
assert Poly(x**2 - 2*x + 1, x).transform(Poly(x + 1), Poly(x - 1)) == \
Poly(4, x) == \
cancel((x - 1)**2*(x**2 - 2*x + 1).subs(x, (x + 1)/(x - 1)))
assert Poly(x**2 - x/2 + 1, x).transform(Poly(x + 1), Poly(x - 1)) == \
Poly(3*x**2/2 + Rational(5, 2), x) == \
cancel((x - 1)**2*(x**2 - x/2 + 1).subs(x, (x + 1)/(x - 1)))
assert Poly(x**2 - 2*x + 1, x).transform(Poly(x + S.Half), Poly(x - 1)) == \
Poly(Rational(9, 4), x) == \
cancel((x - 1)**2*(x**2 - 2*x + 1).subs(x, (x + S.Half)/(x - 1)))
assert Poly(x**2 - 2*x + 1, x).transform(Poly(x + 1), Poly(x - S.Half)) == \
Poly(Rational(9, 4), x) == \
cancel((x - S.Half)**2*(x**2 - 2*x + 1).subs(x, (x + 1)/(x - S.Half)))
# Unify ZZ, QQ, and RR
assert Poly(x**2 - 2*x + 1, x).transform(Poly(x + 1.0), Poly(x - S.Half)) == \
Poly(Rational(9, 4), x, domain='RR') == \
cancel((x - S.Half)**2*(x**2 - 2*x + 1).subs(x, (x + 1.0)/(x - S.Half)))
raises(ValueError, lambda: Poly(x*y).transform(Poly(x + 1), Poly(x - 1)))
raises(ValueError, lambda: Poly(x).transform(Poly(y + 1), Poly(x - 1)))
raises(ValueError, lambda: Poly(x).transform(Poly(x + 1), Poly(y - 1)))
raises(ValueError, lambda: Poly(x).transform(Poly(x*y + 1), Poly(x - 1)))
raises(ValueError, lambda: Poly(x).transform(Poly(x + 1), Poly(x*y - 1)))
def test_sturm():
f, F = x, Poly(x, domain='QQ')
g, G = 1, Poly(1, x, domain='QQ')
assert F.sturm() == [F, G]
assert sturm(f) == [f, g]
assert sturm(f, x) == [f, g]
assert sturm(f, (x,)) == [f, g]
assert sturm(F) == [F, G]
assert sturm(f, polys=True) == [F, G]
assert sturm(F, polys=False) == [f, g]
raises(ComputationFailed, lambda: sturm(4))
raises(DomainError, lambda: sturm(f, auto=False))
f = Poly(S(1024)/(15625*pi**8)*x**5
- S(4096)/(625*pi**8)*x**4
+ S(32)/(15625*pi**4)*x**3
- S(128)/(625*pi**4)*x**2
+ Rational(1, 62500)*x
- Rational(1, 625), x, domain='ZZ(pi)')
assert sturm(f) == \
[Poly(x**3 - 100*x**2 + pi**4/64*x - 25*pi**4/16, x, domain='ZZ(pi)'),
Poly(3*x**2 - 200*x + pi**4/64, x, domain='ZZ(pi)'),
Poly((Rational(20000, 9) - pi**4/96)*x + 25*pi**4/18, x, domain='ZZ(pi)'),
Poly((-3686400000000*pi**4 - 11520000*pi**8 - 9*pi**12)/(26214400000000 - 245760000*pi**4 + 576*pi**8), x, domain='ZZ(pi)')]
def test_gff():
f = x**5 + 2*x**4 - x**3 - 2*x**2
assert Poly(f).gff_list() == [(Poly(x), 1), (Poly(x + 2), 4)]
assert gff_list(f) == [(x, 1), (x + 2, 4)]
raises(NotImplementedError, lambda: gff(f))
f = x*(x - 1)**3*(x - 2)**2*(x - 4)**2*(x - 5)
assert Poly(f).gff_list() == [(
Poly(x**2 - 5*x + 4), 1), (Poly(x**2 - 5*x + 4), 2), (Poly(x), 3)]
assert gff_list(f) == [(x**2 - 5*x + 4, 1), (x**2 - 5*x + 4, 2), (x, 3)]
raises(NotImplementedError, lambda: gff(f))
def test_norm():
a, b = sqrt(2), sqrt(3)
f = Poly(a*x + b*y, x, y, extension=(a, b))
assert f.norm() == Poly(4*x**4 - 12*x**2*y**2 + 9*y**4, x, y, domain='QQ')
def test_sqf_norm():
assert sqf_norm(x**2 - 2, extension=sqrt(3)) == \
(1, x**2 - 2*sqrt(3)*x + 1, x**4 - 10*x**2 + 1)
assert sqf_norm(x**2 - 3, extension=sqrt(2)) == \
(1, x**2 - 2*sqrt(2)*x - 1, x**4 - 10*x**2 + 1)
assert Poly(x**2 - 2, extension=sqrt(3)).sqf_norm() == \
(1, Poly(x**2 - 2*sqrt(3)*x + 1, x, extension=sqrt(3)),
Poly(x**4 - 10*x**2 + 1, x, domain='QQ'))
assert Poly(x**2 - 3, extension=sqrt(2)).sqf_norm() == \
(1, Poly(x**2 - 2*sqrt(2)*x - 1, x, extension=sqrt(2)),
Poly(x**4 - 10*x**2 + 1, x, domain='QQ'))
def test_sqf():
f = x**5 - x**3 - x**2 + 1
g = x**3 + 2*x**2 + 2*x + 1
h = x - 1
p = x**4 + x**3 - x - 1
F, G, H, P = map(Poly, (f, g, h, p))
assert F.sqf_part() == P
assert sqf_part(f) == p
assert sqf_part(f, x) == p
assert sqf_part(f, (x,)) == p
assert sqf_part(F) == P
assert sqf_part(f, polys=True) == P
assert sqf_part(F, polys=False) == p
assert F.sqf_list() == (1, [(G, 1), (H, 2)])
assert sqf_list(f) == (1, [(g, 1), (h, 2)])
assert sqf_list(f, x) == (1, [(g, 1), (h, 2)])
assert sqf_list(f, (x,)) == (1, [(g, 1), (h, 2)])
assert sqf_list(F) == (1, [(G, 1), (H, 2)])
assert sqf_list(f, polys=True) == (1, [(G, 1), (H, 2)])
assert sqf_list(F, polys=False) == (1, [(g, 1), (h, 2)])
assert F.sqf_list_include() == [(G, 1), (H, 2)]
raises(ComputationFailed, lambda: sqf_part(4))
assert sqf(1) == 1
assert sqf_list(1) == (1, [])
assert sqf((2*x**2 + 2)**7) == 128*(x**2 + 1)**7
assert sqf(f) == g*h**2
assert sqf(f, x) == g*h**2
assert sqf(f, (x,)) == g*h**2
d = x**2 + y**2
assert sqf(f/d) == (g*h**2)/d
assert sqf(f/d, x) == (g*h**2)/d
assert sqf(f/d, (x,)) == (g*h**2)/d
assert sqf(x - 1) == x - 1
assert sqf(-x - 1) == -x - 1
assert sqf(x - 1) == x - 1
assert sqf(6*x - 10) == Mul(2, 3*x - 5, evaluate=False)
assert sqf((6*x - 10)/(3*x - 6)) == Rational(2, 3)*((3*x - 5)/(x - 2))
assert sqf(Poly(x**2 - 2*x + 1)) == (x - 1)**2
f = 3 + x - x*(1 + x) + x**2
assert sqf(f) == 3
f = (x**2 + 2*x + 1)**20000000000
assert sqf(f) == (x + 1)**40000000000
assert sqf_list(f) == (1, [(x + 1, 40000000000)])
def test_factor():
f = x**5 - x**3 - x**2 + 1
u = x + 1
v = x - 1
w = x**2 + x + 1
F, U, V, W = map(Poly, (f, u, v, w))
assert F.factor_list() == (1, [(U, 1), (V, 2), (W, 1)])
assert factor_list(f) == (1, [(u, 1), (v, 2), (w, 1)])
assert factor_list(f, x) == (1, [(u, 1), (v, 2), (w, 1)])
assert factor_list(f, (x,)) == (1, [(u, 1), (v, 2), (w, 1)])
assert factor_list(F) == (1, [(U, 1), (V, 2), (W, 1)])
assert factor_list(f, polys=True) == (1, [(U, 1), (V, 2), (W, 1)])
assert factor_list(F, polys=False) == (1, [(u, 1), (v, 2), (w, 1)])
assert F.factor_list_include() == [(U, 1), (V, 2), (W, 1)]
assert factor_list(1) == (1, [])
assert factor_list(6) == (6, [])
assert factor_list(sqrt(3), x) == (sqrt(3), [])
assert factor_list((-1)**x, x) == (1, [(-1, x)])
assert factor_list((2*x)**y, x) == (1, [(2, y), (x, y)])
assert factor_list(sqrt(x*y), x) == (1, [(x*y, S.Half)])
assert factor(6) == 6 and factor(6).is_Integer
assert factor_list(3*x) == (3, [(x, 1)])
assert factor_list(3*x**2) == (3, [(x, 2)])
assert factor(3*x) == 3*x
assert factor(3*x**2) == 3*x**2
assert factor((2*x**2 + 2)**7) == 128*(x**2 + 1)**7
assert factor(f) == u*v**2*w
assert factor(f, x) == u*v**2*w
assert factor(f, (x,)) == u*v**2*w
g, p, q, r = x**2 - y**2, x - y, x + y, x**2 + 1
assert factor(f/g) == (u*v**2*w)/(p*q)
assert factor(f/g, x) == (u*v**2*w)/(p*q)
assert factor(f/g, (x,)) == (u*v**2*w)/(p*q)
p = Symbol('p', positive=True)
i = Symbol('i', integer=True)
r = Symbol('r', real=True)
assert factor(sqrt(x*y)).is_Pow is True
assert factor(sqrt(3*x**2 - 3)) == sqrt(3)*sqrt((x - 1)*(x + 1))
assert factor(sqrt(3*x**2 + 3)) == sqrt(3)*sqrt(x**2 + 1)
assert factor((y*x**2 - y)**i) == y**i*(x - 1)**i*(x + 1)**i
assert factor((y*x**2 + y)**i) == y**i*(x**2 + 1)**i
assert factor((y*x**2 - y)**t) == (y*(x - 1)*(x + 1))**t
assert factor((y*x**2 + y)**t) == (y*(x**2 + 1))**t
f = sqrt(expand((r**2 + 1)*(p + 1)*(p - 1)*(p - 2)**3))
g = sqrt((p - 2)**3*(p - 1))*sqrt(p + 1)*sqrt(r**2 + 1)
assert factor(f) == g
assert factor(g) == g
g = (x - 1)**5*(r**2 + 1)
f = sqrt(expand(g))
assert factor(f) == sqrt(g)
f = Poly(sin(1)*x + 1, x, domain=EX)
assert f.factor_list() == (1, [(f, 1)])
f = x**4 + 1
assert factor(f) == f
assert factor(f, extension=I) == (x**2 - I)*(x**2 + I)
assert factor(f, gaussian=True) == (x**2 - I)*(x**2 + I)
assert factor(
f, extension=sqrt(2)) == (x**2 + sqrt(2)*x + 1)*(x**2 - sqrt(2)*x + 1)
f = x**2 + 2*sqrt(2)*x + 2
assert factor(f, extension=sqrt(2)) == (x + sqrt(2))**2
assert factor(f**3, extension=sqrt(2)) == (x + sqrt(2))**6
assert factor(x**2 - 2*y**2, extension=sqrt(2)) == \
(x + sqrt(2)*y)*(x - sqrt(2)*y)
assert factor(2*x**2 - 4*y**2, extension=sqrt(2)) == \
2*((x + sqrt(2)*y)*(x - sqrt(2)*y))
assert factor(x - 1) == x - 1
assert factor(-x - 1) == -x - 1
assert factor(x - 1) == x - 1
assert factor(6*x - 10) == Mul(2, 3*x - 5, evaluate=False)
assert factor(x**11 + x + 1, modulus=65537, symmetric=True) == \
(x**2 + x + 1)*(x**9 - x**8 + x**6 - x**5 + x**3 - x** 2 + 1)
assert factor(x**11 + x + 1, modulus=65537, symmetric=False) == \
(x**2 + x + 1)*(x**9 + 65536*x**8 + x**6 + 65536*x**5 +
x**3 + 65536*x** 2 + 1)
f = x/pi + x*sin(x)/pi
g = y/(pi**2 + 2*pi + 1) + y*sin(x)/(pi**2 + 2*pi + 1)
assert factor(f) == x*(sin(x) + 1)/pi
assert factor(g) == y*(sin(x) + 1)/(pi + 1)**2
assert factor(Eq(
x**2 + 2*x + 1, x**3 + 1)) == Eq((x + 1)**2, (x + 1)*(x**2 - x + 1))
f = (x**2 - 1)/(x**2 + 4*x + 4)
assert factor(f) == (x + 1)*(x - 1)/(x + 2)**2
assert factor(f, x) == (x + 1)*(x - 1)/(x + 2)**2
f = 3 + x - x*(1 + x) + x**2
assert factor(f) == 3
assert factor(f, x) == 3
assert factor(1/(x**2 + 2*x + 1/x) - 1) == -((1 - x + 2*x**2 +
x**3)/(1 + 2*x**2 + x**3))
assert factor(f, expand=False) == f
raises(PolynomialError, lambda: factor(f, x, expand=False))
raises(FlagError, lambda: factor(x**2 - 1, polys=True))
assert factor([x, Eq(x**2 - y**2, Tuple(x**2 - z**2, 1/x + 1/y))]) == \
[x, Eq((x - y)*(x + y), Tuple((x - z)*(x + z), (x + y)/x/y))]
assert not isinstance(
Poly(x**3 + x + 1).factor_list()[1][0][0], PurePoly) is True
assert isinstance(
PurePoly(x**3 + x + 1).factor_list()[1][0][0], PurePoly) is True
assert factor(sqrt(-x)) == sqrt(-x)
# issue 5917
e = (-2*x*(-x + 1)*(x - 1)*(-x*(-x + 1)*(x - 1) - x*(x - 1)**2)*(x**2*(x -
1) - x*(x - 1) - x) - (-2*x**2*(x - 1)**2 - x*(-x + 1)*(-x*(-x + 1) +
x*(x - 1)))*(x**2*(x - 1)**4 - x*(-x*(-x + 1)*(x - 1) - x*(x - 1)**2)))
assert factor(e) == 0
# deep option
assert factor(sin(x**2 + x) + x, deep=True) == sin(x*(x + 1)) + x
assert factor(sin(x**2 + x)*x, deep=True) == sin(x*(x + 1))*x
assert factor(sqrt(x**2)) == sqrt(x**2)
# issue 13149
assert factor(expand((0.5*x+1)*(0.5*y+1))) == Mul(1.0, 0.5*x + 1.0,
0.5*y + 1.0, evaluate = False)
assert factor(expand((0.5*x+0.5)**2)) == 0.25*(1.0*x + 1.0)**2
eq = x**2*y**2 + 11*x**2*y + 30*x**2 + 7*x*y**2 + 77*x*y + 210*x + 12*y**2 + 132*y + 360
assert factor(eq, x) == (x + 3)*(x + 4)*(y**2 + 11*y + 30)
assert factor(eq, x, deep=True) == (x + 3)*(x + 4)*(y**2 + 11*y + 30)
assert factor(eq, y, deep=True) == (y + 5)*(y + 6)*(x**2 + 7*x + 12)
# fraction option
f = 5*x + 3*exp(2 - 7*x)
assert factor(f, deep=True) == factor(f, deep=True, fraction=True)
assert factor(f, deep=True, fraction=False) == 5*x + 3*exp(2)*exp(-7*x)
def test_factor_large():
f = (x**2 + 4*x + 4)**10000000*(x**2 + 1)*(x**2 + 2*x + 1)**1234567
g = ((x**2 + 2*x + 1)**3000*y**2 + (x**2 + 2*x + 1)**3000*2*y + (
x**2 + 2*x + 1)**3000)
assert factor(f) == (x + 2)**20000000*(x**2 + 1)*(x + 1)**2469134
assert factor(g) == (x + 1)**6000*(y + 1)**2
assert factor_list(
f) == (1, [(x + 1, 2469134), (x + 2, 20000000), (x**2 + 1, 1)])
assert factor_list(g) == (1, [(y + 1, 2), (x + 1, 6000)])
f = (x**2 - y**2)**200000*(x**7 + 1)
g = (x**2 + y**2)**200000*(x**7 + 1)
assert factor(f) == \
(x + 1)*(x - y)**200000*(x + y)**200000*(x**6 - x**5 +
x**4 - x**3 + x**2 - x + 1)
assert factor(g, gaussian=True) == \
(x + 1)*(x - I*y)**200000*(x + I*y)**200000*(x**6 - x**5 +
x**4 - x**3 + x**2 - x + 1)
assert factor_list(f) == \
(1, [(x + 1, 1), (x - y, 200000), (x + y, 200000), (x**6 -
x**5 + x**4 - x**3 + x**2 - x + 1, 1)])
assert factor_list(g, gaussian=True) == \
(1, [(x + 1, 1), (x - I*y, 200000), (x + I*y, 200000), (
x**6 - x**5 + x**4 - x**3 + x**2 - x + 1, 1)])
def test_factor_noeval():
assert factor(6*x - 10) == Mul(2, 3*x - 5, evaluate=False)
assert factor((6*x - 10)/(3*x - 6)) == Mul(Rational(2, 3), 3*x - 5, 1/(x - 2))
def test_intervals():
assert intervals(0) == []
assert intervals(1) == []
assert intervals(x, sqf=True) == [(0, 0)]
assert intervals(x) == [((0, 0), 1)]
assert intervals(x**128) == [((0, 0), 128)]
assert intervals([x**2, x**4]) == [((0, 0), {0: 2, 1: 4})]
f = Poly((x*Rational(2, 5) - Rational(17, 3))*(4*x + Rational(1, 257)))
assert f.intervals(sqf=True) == [(-1, 0), (14, 15)]
assert f.intervals() == [((-1, 0), 1), ((14, 15), 1)]
assert f.intervals(fast=True, sqf=True) == [(-1, 0), (14, 15)]
assert f.intervals(fast=True) == [((-1, 0), 1), ((14, 15), 1)]
assert f.intervals(eps=Rational(1, 10)) == f.intervals(eps=0.1) == \
[((Rational(-1, 258), 0), 1), ((Rational(85, 6), Rational(85, 6)), 1)]
assert f.intervals(eps=Rational(1, 100)) == f.intervals(eps=0.01) == \
[((Rational(-1, 258), 0), 1), ((Rational(85, 6), Rational(85, 6)), 1)]
assert f.intervals(eps=Rational(1, 1000)) == f.intervals(eps=0.001) == \
[((Rational(-1, 1002), 0), 1), ((Rational(85, 6), Rational(85, 6)), 1)]
assert f.intervals(eps=Rational(1, 10000)) == f.intervals(eps=0.0001) == \
[((Rational(-1, 1028), Rational(-1, 1028)), 1), ((Rational(85, 6), Rational(85, 6)), 1)]
f = (x*Rational(2, 5) - Rational(17, 3))*(4*x + Rational(1, 257))
assert intervals(f, sqf=True) == [(-1, 0), (14, 15)]
assert intervals(f) == [((-1, 0), 1), ((14, 15), 1)]
assert intervals(f, eps=Rational(1, 10)) == intervals(f, eps=0.1) == \
[((Rational(-1, 258), 0), 1), ((Rational(85, 6), Rational(85, 6)), 1)]
assert intervals(f, eps=Rational(1, 100)) == intervals(f, eps=0.01) == \
[((Rational(-1, 258), 0), 1), ((Rational(85, 6), Rational(85, 6)), 1)]
assert intervals(f, eps=Rational(1, 1000)) == intervals(f, eps=0.001) == \
[((Rational(-1, 1002), 0), 1), ((Rational(85, 6), Rational(85, 6)), 1)]
assert intervals(f, eps=Rational(1, 10000)) == intervals(f, eps=0.0001) == \
[((Rational(-1, 1028), Rational(-1, 1028)), 1), ((Rational(85, 6), Rational(85, 6)), 1)]
f = Poly((x**2 - 2)*(x**2 - 3)**7*(x + 1)*(7*x + 3)**3)
assert f.intervals() == \
[((-2, Rational(-3, 2)), 7), ((Rational(-3, 2), -1), 1),
((-1, -1), 1), ((-1, 0), 3),
((1, Rational(3, 2)), 1), ((Rational(3, 2), 2), 7)]
assert intervals([x**5 - 200, x**5 - 201]) == \
[((Rational(75, 26), Rational(101, 35)), {0: 1}), ((Rational(309, 107), Rational(26, 9)), {1: 1})]
assert intervals([x**5 - 200, x**5 - 201], fast=True) == \
[((Rational(75, 26), Rational(101, 35)), {0: 1}), ((Rational(309, 107), Rational(26, 9)), {1: 1})]
assert intervals([x**2 - 200, x**2 - 201]) == \
[((Rational(-71, 5), Rational(-85, 6)), {1: 1}), ((Rational(-85, 6), -14), {0: 1}),
((14, Rational(85, 6)), {0: 1}), ((Rational(85, 6), Rational(71, 5)), {1: 1})]
assert intervals([x + 1, x + 2, x - 1, x + 1, 1, x - 1, x - 1, (x - 2)**2]) == \
[((-2, -2), {1: 1}), ((-1, -1), {0: 1, 3: 1}), ((1, 1), {2:
1, 5: 1, 6: 1}), ((2, 2), {7: 2})]
f, g, h = x**2 - 2, x**4 - 4*x**2 + 4, x - 1
assert intervals(f, inf=Rational(7, 4), sqf=True) == []
assert intervals(f, inf=Rational(7, 5), sqf=True) == [(Rational(7, 5), Rational(3, 2))]
assert intervals(f, sup=Rational(7, 4), sqf=True) == [(-2, -1), (1, Rational(3, 2))]
assert intervals(f, sup=Rational(7, 5), sqf=True) == [(-2, -1)]
assert intervals(g, inf=Rational(7, 4)) == []
assert intervals(g, inf=Rational(7, 5)) == [((Rational(7, 5), Rational(3, 2)), 2)]
assert intervals(g, sup=Rational(7, 4)) == [((-2, -1), 2), ((1, Rational(3, 2)), 2)]
assert intervals(g, sup=Rational(7, 5)) == [((-2, -1), 2)]
assert intervals([g, h], inf=Rational(7, 4)) == []
assert intervals([g, h], inf=Rational(7, 5)) == [((Rational(7, 5), Rational(3, 2)), {0: 2})]
assert intervals([g, h], sup=S(
7)/4) == [((-2, -1), {0: 2}), ((1, 1), {1: 1}), ((1, Rational(3, 2)), {0: 2})]
assert intervals(
[g, h], sup=Rational(7, 5)) == [((-2, -1), {0: 2}), ((1, 1), {1: 1})]
assert intervals([x + 2, x**2 - 2]) == \
[((-2, -2), {0: 1}), ((-2, -1), {1: 1}), ((1, 2), {1: 1})]
assert intervals([x + 2, x**2 - 2], strict=True) == \
[((-2, -2), {0: 1}), ((Rational(-3, 2), -1), {1: 1}), ((1, 2), {1: 1})]
f = 7*z**4 - 19*z**3 + 20*z**2 + 17*z + 20
assert intervals(f) == []
real_part, complex_part = intervals(f, all=True, sqf=True)
assert real_part == []
assert all(re(a) < re(r) < re(b) and im(
a) < im(r) < im(b) for (a, b), r in zip(complex_part, nroots(f)))
assert complex_part == [(Rational(-40, 7) - I*Rational(40, 7), 0),
(Rational(-40, 7), I*Rational(40, 7)),
(I*Rational(-40, 7), Rational(40, 7)),
(0, Rational(40, 7) + I*Rational(40, 7))]
real_part, complex_part = intervals(f, all=True, sqf=True, eps=Rational(1, 10))
assert real_part == []
assert all(re(a) < re(r) < re(b) and im(
a) < im(r) < im(b) for (a, b), r in zip(complex_part, nroots(f)))
raises(ValueError, lambda: intervals(x**2 - 2, eps=10**-100000))
raises(ValueError, lambda: Poly(x**2 - 2).intervals(eps=10**-100000))
raises(
ValueError, lambda: intervals([x**2 - 2, x**2 - 3], eps=10**-100000))
def test_refine_root():
f = Poly(x**2 - 2)
assert f.refine_root(1, 2, steps=0) == (1, 2)
assert f.refine_root(-2, -1, steps=0) == (-2, -1)
assert f.refine_root(1, 2, steps=None) == (1, Rational(3, 2))
assert f.refine_root(-2, -1, steps=None) == (Rational(-3, 2), -1)
assert f.refine_root(1, 2, steps=1) == (1, Rational(3, 2))
assert f.refine_root(-2, -1, steps=1) == (Rational(-3, 2), -1)
assert f.refine_root(1, 2, steps=1, fast=True) == (1, Rational(3, 2))
assert f.refine_root(-2, -1, steps=1, fast=True) == (Rational(-3, 2), -1)
assert f.refine_root(1, 2, eps=Rational(1, 100)) == (Rational(24, 17), Rational(17, 12))
assert f.refine_root(1, 2, eps=1e-2) == (Rational(24, 17), Rational(17, 12))
raises(PolynomialError, lambda: (f**2).refine_root(1, 2, check_sqf=True))
raises(RefinementFailed, lambda: (f**2).refine_root(1, 2))
raises(RefinementFailed, lambda: (f**2).refine_root(2, 3))
f = x**2 - 2
assert refine_root(f, 1, 2, steps=1) == (1, Rational(3, 2))
assert refine_root(f, -2, -1, steps=1) == (Rational(-3, 2), -1)
assert refine_root(f, 1, 2, steps=1, fast=True) == (1, Rational(3, 2))
assert refine_root(f, -2, -1, steps=1, fast=True) == (Rational(-3, 2), -1)
assert refine_root(f, 1, 2, eps=Rational(1, 100)) == (Rational(24, 17), Rational(17, 12))
assert refine_root(f, 1, 2, eps=1e-2) == (Rational(24, 17), Rational(17, 12))
raises(PolynomialError, lambda: refine_root(1, 7, 8, eps=Rational(1, 100)))
raises(ValueError, lambda: Poly(f).refine_root(1, 2, eps=10**-100000))
raises(ValueError, lambda: refine_root(f, 1, 2, eps=10**-100000))
def test_count_roots():
assert count_roots(x**2 - 2) == 2
assert count_roots(x**2 - 2, inf=-oo) == 2
assert count_roots(x**2 - 2, sup=+oo) == 2
assert count_roots(x**2 - 2, inf=-oo, sup=+oo) == 2
assert count_roots(x**2 - 2, inf=-2) == 2
assert count_roots(x**2 - 2, inf=-1) == 1
assert count_roots(x**2 - 2, sup=1) == 1
assert count_roots(x**2 - 2, sup=2) == 2
assert count_roots(x**2 - 2, inf=-1, sup=1) == 0
assert count_roots(x**2 - 2, inf=-2, sup=2) == 2
assert count_roots(x**2 - 2, inf=-1, sup=1) == 0
assert count_roots(x**2 - 2, inf=-2, sup=2) == 2
assert count_roots(x**2 + 2) == 0
assert count_roots(x**2 + 2, inf=-2*I) == 2
assert count_roots(x**2 + 2, sup=+2*I) == 2
assert count_roots(x**2 + 2, inf=-2*I, sup=+2*I) == 2
assert count_roots(x**2 + 2, inf=0) == 0
assert count_roots(x**2 + 2, sup=0) == 0
assert count_roots(x**2 + 2, inf=-I) == 1
assert count_roots(x**2 + 2, sup=+I) == 1
assert count_roots(x**2 + 2, inf=+I/2, sup=+I) == 0
assert count_roots(x**2 + 2, inf=-I, sup=-I/2) == 0
raises(PolynomialError, lambda: count_roots(1))
def test_Poly_root():
f = Poly(2*x**3 - 7*x**2 + 4*x + 4)
assert f.root(0) == Rational(-1, 2)
assert f.root(1) == 2
assert f.root(2) == 2
raises(IndexError, lambda: f.root(3))
assert Poly(x**5 + x + 1).root(0) == rootof(x**3 - x**2 + 1, 0)
def test_real_roots():
assert real_roots(x) == [0]
assert real_roots(x, multiple=False) == [(0, 1)]
assert real_roots(x**3) == [0, 0, 0]
assert real_roots(x**3, multiple=False) == [(0, 3)]
assert real_roots(x*(x**3 + x + 3)) == [rootof(x**3 + x + 3, 0), 0]
assert real_roots(x*(x**3 + x + 3), multiple=False) == [(rootof(
x**3 + x + 3, 0), 1), (0, 1)]
assert real_roots(
x**3*(x**3 + x + 3)) == [rootof(x**3 + x + 3, 0), 0, 0, 0]
assert real_roots(x**3*(x**3 + x + 3), multiple=False) == [(rootof(
x**3 + x + 3, 0), 1), (0, 3)]
f = 2*x**3 - 7*x**2 + 4*x + 4
g = x**3 + x + 1
assert Poly(f).real_roots() == [Rational(-1, 2), 2, 2]
assert Poly(g).real_roots() == [rootof(g, 0)]
def test_all_roots():
f = 2*x**3 - 7*x**2 + 4*x + 4
g = x**3 + x + 1
assert Poly(f).all_roots() == [Rational(-1, 2), 2, 2]
assert Poly(g).all_roots() == [rootof(g, 0), rootof(g, 1), rootof(g, 2)]
def test_nroots():
assert Poly(0, x).nroots() == []
assert Poly(1, x).nroots() == []
assert Poly(x**2 - 1, x).nroots() == [-1.0, 1.0]
assert Poly(x**2 + 1, x).nroots() == [-1.0*I, 1.0*I]
roots = Poly(x**2 - 1, x).nroots()
assert roots == [-1.0, 1.0]
roots = Poly(x**2 + 1, x).nroots()
assert roots == [-1.0*I, 1.0*I]
roots = Poly(x**2/3 - Rational(1, 3), x).nroots()
assert roots == [-1.0, 1.0]
roots = Poly(x**2/3 + Rational(1, 3), x).nroots()
assert roots == [-1.0*I, 1.0*I]
assert Poly(x**2 + 2*I, x).nroots() == [-1.0 + 1.0*I, 1.0 - 1.0*I]
assert Poly(
x**2 + 2*I, x, extension=I).nroots() == [-1.0 + 1.0*I, 1.0 - 1.0*I]
assert Poly(0.2*x + 0.1).nroots() == [-0.5]
roots = nroots(x**5 + x + 1, n=5)
eps = Float("1e-5")
assert re(roots[0]).epsilon_eq(-0.75487, eps) is S.true
assert im(roots[0]) == 0.0
assert re(roots[1]) == -0.5
assert im(roots[1]).epsilon_eq(-0.86602, eps) is S.true
assert re(roots[2]) == -0.5
assert im(roots[2]).epsilon_eq(+0.86602, eps) is S.true
assert re(roots[3]).epsilon_eq(+0.87743, eps) is S.true
assert im(roots[3]).epsilon_eq(-0.74486, eps) is S.true
assert re(roots[4]).epsilon_eq(+0.87743, eps) is S.true
assert im(roots[4]).epsilon_eq(+0.74486, eps) is S.true
eps = Float("1e-6")
assert re(roots[0]).epsilon_eq(-0.75487, eps) is S.false
assert im(roots[0]) == 0.0
assert re(roots[1]) == -0.5
assert im(roots[1]).epsilon_eq(-0.86602, eps) is S.false
assert re(roots[2]) == -0.5
assert im(roots[2]).epsilon_eq(+0.86602, eps) is S.false
assert re(roots[3]).epsilon_eq(+0.87743, eps) is S.false
assert im(roots[3]).epsilon_eq(-0.74486, eps) is S.false
assert re(roots[4]).epsilon_eq(+0.87743, eps) is S.false
assert im(roots[4]).epsilon_eq(+0.74486, eps) is S.false
raises(DomainError, lambda: Poly(x + y, x).nroots())
raises(MultivariatePolynomialError, lambda: Poly(x + y).nroots())
assert nroots(x**2 - 1) == [-1.0, 1.0]
roots = nroots(x**2 - 1)
assert roots == [-1.0, 1.0]
assert nroots(x + I) == [-1.0*I]
assert nroots(x + 2*I) == [-2.0*I]
raises(PolynomialError, lambda: nroots(0))
# issue 8296
f = Poly(x**4 - 1)
assert f.nroots(2) == [w.n(2) for w in f.all_roots()]
assert str(Poly(x**16 + 32*x**14 + 508*x**12 + 5440*x**10 +
39510*x**8 + 204320*x**6 + 755548*x**4 + 1434496*x**2 +
877969).nroots(2)) == ('[-1.7 - 1.9*I, -1.7 + 1.9*I, -1.7 '
'- 2.5*I, -1.7 + 2.5*I, -1.0*I, 1.0*I, -1.7*I, 1.7*I, -2.8*I, '
'2.8*I, -3.4*I, 3.4*I, 1.7 - 1.9*I, 1.7 + 1.9*I, 1.7 - 2.5*I, '
'1.7 + 2.5*I]')
def test_ground_roots():
f = x**6 - 4*x**4 + 4*x**3 - x**2
assert Poly(f).ground_roots() == {S.One: 2, S.Zero: 2}
assert ground_roots(f) == {S.One: 2, S.Zero: 2}
def test_nth_power_roots_poly():
f = x**4 - x**2 + 1
f_2 = (x**2 - x + 1)**2
f_3 = (x**2 + 1)**2
f_4 = (x**2 + x + 1)**2
f_12 = (x - 1)**4
assert nth_power_roots_poly(f, 1) == f
raises(ValueError, lambda: nth_power_roots_poly(f, 0))
raises(ValueError, lambda: nth_power_roots_poly(f, x))
assert factor(nth_power_roots_poly(f, 2)) == f_2
assert factor(nth_power_roots_poly(f, 3)) == f_3
assert factor(nth_power_roots_poly(f, 4)) == f_4
assert factor(nth_power_roots_poly(f, 12)) == f_12
raises(MultivariatePolynomialError, lambda: nth_power_roots_poly(
x + y, 2, x, y))
def test_torational_factor_list():
p = expand(((x**2-1)*(x-2)).subs({x:x*(1 + sqrt(2))}))
assert _torational_factor_list(p, x) == (-2, [
(-x*(1 + sqrt(2))/2 + 1, 1),
(-x*(1 + sqrt(2)) - 1, 1),
(-x*(1 + sqrt(2)) + 1, 1)])
p = expand(((x**2-1)*(x-2)).subs({x:x*(1 + 2**Rational(1, 4))}))
assert _torational_factor_list(p, x) is None
def test_cancel():
assert cancel(0) == 0
assert cancel(7) == 7
assert cancel(x) == x
assert cancel(oo) is oo
assert cancel((2, 3)) == (1, 2, 3)
assert cancel((1, 0), x) == (1, 1, 0)
assert cancel((0, 1), x) == (1, 0, 1)
f, g, p, q = 4*x**2 - 4, 2*x - 2, 2*x + 2, 1
F, G, P, Q = [ Poly(u, x) for u in (f, g, p, q) ]
assert F.cancel(G) == (1, P, Q)
assert cancel((f, g)) == (1, p, q)
assert cancel((f, g), x) == (1, p, q)
assert cancel((f, g), (x,)) == (1, p, q)
assert cancel((F, G)) == (1, P, Q)
assert cancel((f, g), polys=True) == (1, P, Q)
assert cancel((F, G), polys=False) == (1, p, q)
f = (x**2 - 2)/(x + sqrt(2))
assert cancel(f) == f
assert cancel(f, greedy=False) == x - sqrt(2)
f = (x**2 - 2)/(x - sqrt(2))
assert cancel(f) == f
assert cancel(f, greedy=False) == x + sqrt(2)
assert cancel((x**2/4 - 1, x/2 - 1)) == (S.Half, x + 2, 1)
assert cancel((x**2 - y)/(x - y)) == 1/(x - y)*(x**2 - y)
assert cancel((x**2 - y**2)/(x - y), x) == x + y
assert cancel((x**2 - y**2)/(x - y), y) == x + y
assert cancel((x**2 - y**2)/(x - y)) == x + y
assert cancel((x**3 - 1)/(x**2 - 1)) == (x**2 + x + 1)/(x + 1)
assert cancel((x**3/2 - S.Half)/(x**2 - 1)) == (x**2 + x + 1)/(2*x + 2)
assert cancel((exp(2*x) + 2*exp(x) + 1)/(exp(x) + 1)) == exp(x) + 1
f = Poly(x**2 - a**2, x)
g = Poly(x - a, x)
F = Poly(x + a, x, domain='ZZ[a]')
G = Poly(1, x, domain='ZZ[a]')
assert cancel((f, g)) == (1, F, G)
f = x**3 + (sqrt(2) - 2)*x**2 - (2*sqrt(2) + 3)*x - 3*sqrt(2)
g = x**2 - 2
assert cancel((f, g), extension=True) == (1, x**2 - 2*x - 3, x - sqrt(2))
f = Poly(-2*x + 3, x)
g = Poly(-x**9 + x**8 + x**6 - x**5 + 2*x**2 - 3*x + 1, x)
assert cancel((f, g)) == (1, -f, -g)
f = Poly(y, y, domain='ZZ(x)')
g = Poly(1, y, domain='ZZ[x]')
assert f.cancel(
g) == (1, Poly(y, y, domain='ZZ(x)'), Poly(1, y, domain='ZZ(x)'))
assert f.cancel(g, include=True) == (
Poly(y, y, domain='ZZ(x)'), Poly(1, y, domain='ZZ(x)'))
f = Poly(5*x*y + x, y, domain='ZZ(x)')
g = Poly(2*x**2*y, y, domain='ZZ(x)')
assert f.cancel(g, include=True) == (
Poly(5*y + 1, y, domain='ZZ(x)'), Poly(2*x*y, y, domain='ZZ(x)'))
f = -(-2*x - 4*y + 0.005*(z - y)**2)/((z - y)*(-z + y + 2))
assert cancel(f).is_Mul == True
P = tanh(x - 3.0)
Q = tanh(x + 3.0)
f = ((-2*P**2 + 2)*(-P**2 + 1)*Q**2/2 + (-2*P**2 + 2)*(-2*Q**2 + 2)*P*Q - (-2*P**2 + 2)*P**2*Q**2 + (-2*Q**2 + 2)*(-Q**2 + 1)*P**2/2 - (-2*Q**2 + 2)*P**2*Q**2)/(2*sqrt(P**2*Q**2 + 0.0001)) \
+ (-(-2*P**2 + 2)*P*Q**2/2 - (-2*Q**2 + 2)*P**2*Q/2)*((-2*P**2 + 2)*P*Q**2/2 + (-2*Q**2 + 2)*P**2*Q/2)/(2*(P**2*Q**2 + 0.0001)**Rational(3, 2))
assert cancel(f).is_Mul == True
# issue 7022
A = Symbol('A', commutative=False)
p1 = Piecewise((A*(x**2 - 1)/(x + 1), x > 1), ((x + 2)/(x**2 + 2*x), True))
p2 = Piecewise((A*(x - 1), x > 1), (1/x, True))
assert cancel(p1) == p2
assert cancel(2*p1) == 2*p2
assert cancel(1 + p1) == 1 + p2
assert cancel((x**2 - 1)/(x + 1)*p1) == (x - 1)*p2
assert cancel((x**2 - 1)/(x + 1) + p1) == (x - 1) + p2
p3 = Piecewise(((x**2 - 1)/(x + 1), x > 1), ((x + 2)/(x**2 + 2*x), True))
p4 = Piecewise(((x - 1), x > 1), (1/x, True))
assert cancel(p3) == p4
assert cancel(2*p3) == 2*p4
assert cancel(1 + p3) == 1 + p4
assert cancel((x**2 - 1)/(x + 1)*p3) == (x - 1)*p4
assert cancel((x**2 - 1)/(x + 1) + p3) == (x - 1) + p4
# issue 9363
M = MatrixSymbol('M', 5, 5)
assert cancel(M[0,0] + 7) == M[0,0] + 7
expr = sin(M[1, 4] + M[2, 1] * 5 * M[4, 0]) - 5 * M[1, 2] / z
assert cancel(expr) == (z*sin(M[1, 4] + M[2, 1] * 5 * M[4, 0]) - 5 * M[1, 2]) / z
def test_reduced():
f = 2*x**4 + y**2 - x**2 + y**3
G = [x**3 - x, y**3 - y]
Q = [2*x, 1]
r = x**2 + y**2 + y
assert reduced(f, G) == (Q, r)
assert reduced(f, G, x, y) == (Q, r)
H = groebner(G)
assert H.reduce(f) == (Q, r)
Q = [Poly(2*x, x, y), Poly(1, x, y)]
r = Poly(x**2 + y**2 + y, x, y)
assert _strict_eq(reduced(f, G, polys=True), (Q, r))
assert _strict_eq(reduced(f, G, x, y, polys=True), (Q, r))
H = groebner(G, polys=True)
assert _strict_eq(H.reduce(f), (Q, r))
f = 2*x**3 + y**3 + 3*y
G = groebner([x**2 + y**2 - 1, x*y - 2])
Q = [x**2 - x*y**3/2 + x*y/2 + y**6/4 - y**4/2 + y**2/4, -y**5/4 + y**3/2 + y*Rational(3, 4)]
r = 0
assert reduced(f, G) == (Q, r)
assert G.reduce(f) == (Q, r)
assert reduced(f, G, auto=False)[1] != 0
assert G.reduce(f, auto=False)[1] != 0
assert G.contains(f) is True
assert G.contains(f + 1) is False
assert reduced(1, [1], x) == ([1], 0)
raises(ComputationFailed, lambda: reduced(1, [1]))
def test_groebner():
assert groebner([], x, y, z) == []
assert groebner([x**2 + 1, y**4*x + x**3], x, y, order='lex') == [1 + x**2, -1 + y**4]
assert groebner([x**2 + 1, y**4*x + x**3, x*y*z**3], x, y, z, order='grevlex') == [-1 + y**4, z**3, 1 + x**2]
assert groebner([x**2 + 1, y**4*x + x**3], x, y, order='lex', polys=True) == \
[Poly(1 + x**2, x, y), Poly(-1 + y**4, x, y)]
assert groebner([x**2 + 1, y**4*x + x**3, x*y*z**3], x, y, z, order='grevlex', polys=True) == \
[Poly(-1 + y**4, x, y, z), Poly(z**3, x, y, z), Poly(1 + x**2, x, y, z)]
assert groebner([x**3 - 1, x**2 - 1]) == [x - 1]
assert groebner([Eq(x**3, 1), Eq(x**2, 1)]) == [x - 1]
F = [3*x**2 + y*z - 5*x - 1, 2*x + 3*x*y + y**2, x - 3*y + x*z - 2*z**2]
f = z**9 - x**2*y**3 - 3*x*y**2*z + 11*y*z**2 + x**2*z**2 - 5
G = groebner(F, x, y, z, modulus=7, symmetric=False)
assert G == [1 + x + y + 3*z + 2*z**2 + 2*z**3 + 6*z**4 + z**5,
1 + 3*y + y**2 + 6*z**2 + 3*z**3 + 3*z**4 + 3*z**5 + 4*z**6,
1 + 4*y + 4*z + y*z + 4*z**3 + z**4 + z**6,
6 + 6*z + z**2 + 4*z**3 + 3*z**4 + 6*z**5 + 3*z**6 + z**7]
Q, r = reduced(f, G, x, y, z, modulus=7, symmetric=False, polys=True)
assert sum([ q*g for q, g in zip(Q, G.polys)], r) == Poly(f, modulus=7)
F = [x*y - 2*y, 2*y**2 - x**2]
assert groebner(F, x, y, order='grevlex') == \
[y**3 - 2*y, x**2 - 2*y**2, x*y - 2*y]
assert groebner(F, y, x, order='grevlex') == \
[x**3 - 2*x**2, -x**2 + 2*y**2, x*y - 2*y]
assert groebner(F, order='grevlex', field=True) == \
[y**3 - 2*y, x**2 - 2*y**2, x*y - 2*y]
assert groebner([1], x) == [1]
assert groebner([x**2 + 2.0*y], x, y) == [1.0*x**2 + 2.0*y]
raises(ComputationFailed, lambda: groebner([1]))
assert groebner([x**2 - 1, x**3 + 1], method='buchberger') == [x + 1]
assert groebner([x**2 - 1, x**3 + 1], method='f5b') == [x + 1]
raises(ValueError, lambda: groebner([x, y], method='unknown'))
def test_fglm():
F = [a + b + c + d, a*b + a*d + b*c + b*d, a*b*c + a*b*d + a*c*d + b*c*d, a*b*c*d - 1]
G = groebner(F, a, b, c, d, order=grlex)
B = [
4*a + 3*d**9 - 4*d**5 - 3*d,
4*b + 4*c - 3*d**9 + 4*d**5 + 7*d,
4*c**2 + 3*d**10 - 4*d**6 - 3*d**2,
4*c*d**4 + 4*c - d**9 + 4*d**5 + 5*d,
d**12 - d**8 - d**4 + 1,
]
assert groebner(F, a, b, c, d, order=lex) == B
assert G.fglm(lex) == B
F = [9*x**8 + 36*x**7 - 32*x**6 - 252*x**5 - 78*x**4 + 468*x**3 + 288*x**2 - 108*x + 9,
-72*t*x**7 - 252*t*x**6 + 192*t*x**5 + 1260*t*x**4 + 312*t*x**3 - 404*t*x**2 - 576*t*x + \
108*t - 72*x**7 - 256*x**6 + 192*x**5 + 1280*x**4 + 312*x**3 - 576*x + 96]
G = groebner(F, t, x, order=grlex)
B = [
203577793572507451707*t + 627982239411707112*x**7 - 666924143779443762*x**6 - \
10874593056632447619*x**5 + 5119998792707079562*x**4 + 72917161949456066376*x**3 + \
20362663855832380362*x**2 - 142079311455258371571*x + 183756699868981873194,
9*x**8 + 36*x**7 - 32*x**6 - 252*x**5 - 78*x**4 + 468*x**3 + 288*x**2 - 108*x + 9,
]
assert groebner(F, t, x, order=lex) == B
assert G.fglm(lex) == B
F = [x**2 - x - 3*y + 1, -2*x + y**2 + y - 1]
G = groebner(F, x, y, order=lex)
B = [
x**2 - x - 3*y + 1,
y**2 - 2*x + y - 1,
]
assert groebner(F, x, y, order=grlex) == B
assert G.fglm(grlex) == B
def test_is_zero_dimensional():
assert is_zero_dimensional([x, y], x, y) is True
assert is_zero_dimensional([x**3 + y**2], x, y) is False
assert is_zero_dimensional([x, y, z], x, y, z) is True
assert is_zero_dimensional([x, y, z], x, y, z, t) is False
F = [x*y - z, y*z - x, x*y - y]
assert is_zero_dimensional(F, x, y, z) is True
F = [x**2 - 2*x*z + 5, x*y**2 + y*z**3, 3*y**2 - 8*z**2]
assert is_zero_dimensional(F, x, y, z) is True
def test_GroebnerBasis():
F = [x*y - 2*y, 2*y**2 - x**2]
G = groebner(F, x, y, order='grevlex')
H = [y**3 - 2*y, x**2 - 2*y**2, x*y - 2*y]
P = [ Poly(h, x, y) for h in H ]
assert groebner(F + [0], x, y, order='grevlex') == G
assert isinstance(G, GroebnerBasis) is True
assert len(G) == 3
assert G[0] == H[0] and not G[0].is_Poly
assert G[1] == H[1] and not G[1].is_Poly
assert G[2] == H[2] and not G[2].is_Poly
assert G[1:] == H[1:] and not any(g.is_Poly for g in G[1:])
assert G[:2] == H[:2] and not any(g.is_Poly for g in G[1:])
assert G.exprs == H
assert G.polys == P
assert G.gens == (x, y)
assert G.domain == ZZ
assert G.order == grevlex
assert G == H
assert G == tuple(H)
assert G == P
assert G == tuple(P)
assert G != []
G = groebner(F, x, y, order='grevlex', polys=True)
assert G[0] == P[0] and G[0].is_Poly
assert G[1] == P[1] and G[1].is_Poly
assert G[2] == P[2] and G[2].is_Poly
assert G[1:] == P[1:] and all(g.is_Poly for g in G[1:])
assert G[:2] == P[:2] and all(g.is_Poly for g in G[1:])
def test_poly():
assert poly(x) == Poly(x, x)
assert poly(y) == Poly(y, y)
assert poly(x + y) == Poly(x + y, x, y)
assert poly(x + sin(x)) == Poly(x + sin(x), x, sin(x))
assert poly(x + y, wrt=y) == Poly(x + y, y, x)
assert poly(x + sin(x), wrt=sin(x)) == Poly(x + sin(x), sin(x), x)
assert poly(x*y + 2*x*z**2 + 17) == Poly(x*y + 2*x*z**2 + 17, x, y, z)
assert poly(2*(y + z)**2 - 1) == Poly(2*y**2 + 4*y*z + 2*z**2 - 1, y, z)
assert poly(
x*(y + z)**2 - 1) == Poly(x*y**2 + 2*x*y*z + x*z**2 - 1, x, y, z)
assert poly(2*x*(
y + z)**2 - 1) == Poly(2*x*y**2 + 4*x*y*z + 2*x*z**2 - 1, x, y, z)
assert poly(2*(
y + z)**2 - x - 1) == Poly(2*y**2 + 4*y*z + 2*z**2 - x - 1, x, y, z)
assert poly(x*(
y + z)**2 - x - 1) == Poly(x*y**2 + 2*x*y*z + x*z**2 - x - 1, x, y, z)
assert poly(2*x*(y + z)**2 - x - 1) == Poly(2*x*y**2 + 4*x*y*z + 2*
x*z**2 - x - 1, x, y, z)
assert poly(x*y + (x + y)**2 + (x + z)**2) == \
Poly(2*x*z + 3*x*y + y**2 + z**2 + 2*x**2, x, y, z)
assert poly(x*y*(x + y)*(x + z)**2) == \
Poly(x**3*y**2 + x*y**2*z**2 + y*x**2*z**2 + 2*z*x**2*
y**2 + 2*y*z*x**3 + y*x**4, x, y, z)
assert poly(Poly(x + y + z, y, x, z)) == Poly(x + y + z, y, x, z)
assert poly((x + y)**2, x) == Poly(x**2 + 2*x*y + y**2, x, domain=ZZ[y])
assert poly((x + y)**2, y) == Poly(x**2 + 2*x*y + y**2, y, domain=ZZ[x])
assert poly(1, x) == Poly(1, x)
raises(GeneratorsNeeded, lambda: poly(1))
# issue 6184
assert poly(x + y, x, y) == Poly(x + y, x, y)
assert poly(x + y, y, x) == Poly(x + y, y, x)
def test_keep_coeff():
u = Mul(2, x + 1, evaluate=False)
assert _keep_coeff(S.One, x) == x
assert _keep_coeff(S.NegativeOne, x) == -x
assert _keep_coeff(S(1.0), x) == 1.0*x
assert _keep_coeff(S(-1.0), x) == -1.0*x
assert _keep_coeff(S.One, 2*x) == 2*x
assert _keep_coeff(S(2), x/2) == x
assert _keep_coeff(S(2), sin(x)) == 2*sin(x)
assert _keep_coeff(S(2), x + 1) == u
assert _keep_coeff(x, 1/x) == 1
assert _keep_coeff(x + 1, S(2)) == u
def test_poly_matching_consistency():
# Test for this issue:
# https://github.com/sympy/sympy/issues/5514
assert I * Poly(x, x) == Poly(I*x, x)
assert Poly(x, x) * I == Poly(I*x, x)
def test_issue_5786():
assert expand(factor(expand(
(x - I*y)*(z - I*t)), extension=[I])) == -I*t*x - t*y + x*z - I*y*z
def test_noncommutative():
class foo(Expr):
is_commutative=False
e = x/(x + x*y)
c = 1/( 1 + y)
assert cancel(foo(e)) == foo(c)
assert cancel(e + foo(e)) == c + foo(c)
assert cancel(e*foo(c)) == c*foo(c)
def test_to_rational_coeffs():
assert to_rational_coeffs(
Poly(x**3 + y*x**2 + sqrt(y), x, domain='EX')) is None
def test_factor_terms():
# issue 7067
assert factor_list(x*(x + y)) == (1, [(x, 1), (x + y, 1)])
assert sqf_list(x*(x + y)) == (1, [(x**2 + x*y, 1)])
def test_as_list():
# issue 14496
assert Poly(x**3 + 2, x, domain='ZZ').as_list() == [1, 0, 0, 2]
assert Poly(x**2 + y + 1, x, y, domain='ZZ').as_list() == [[1], [], [1, 1]]
assert Poly(x**2 + y + 1, x, y, z, domain='ZZ').as_list() == \
[[[1]], [[]], [[1], [1]]]
def test_issue_11198():
assert factor_list(sqrt(2)*x) == (sqrt(2), [(x, 1)])
assert factor_list(sqrt(2)*sin(x), sin(x)) == (sqrt(2), [(sin(x), 1)])
def test_Poly_precision():
# Make sure Poly doesn't lose precision
p = Poly(pi.evalf(100)*x)
assert p.as_expr() == pi.evalf(100)*x
def test_issue_12400():
# Correction of check for negative exponents
assert poly(1/(1+sqrt(2)), x) == \
Poly(1/(1+sqrt(2)), x , domain='EX')
def test_issue_14364():
assert gcd(S(6)*(1 + sqrt(3))/5, S(3)*(1 + sqrt(3))/10) == Rational(3, 10) * (1 + sqrt(3))
assert gcd(sqrt(5)*Rational(4, 7), sqrt(5)*Rational(2, 3)) == sqrt(5)*Rational(2, 21)
assert lcm(Rational(2, 3)*sqrt(3), Rational(5, 6)*sqrt(3)) == S(10)*sqrt(3)/3
assert lcm(3*sqrt(3), 4/sqrt(3)) == 12*sqrt(3)
assert lcm(S(5)*(1 + 2**Rational(1, 3))/6, S(3)*(1 + 2**Rational(1, 3))/8) == Rational(15, 2) * (1 + 2**Rational(1, 3))
assert gcd(Rational(2, 3)*sqrt(3), Rational(5, 6)/sqrt(3)) == sqrt(3)/18
assert gcd(S(4)*sqrt(13)/7, S(3)*sqrt(13)/14) == sqrt(13)/14
# gcd_list and lcm_list
assert gcd([S(2)*sqrt(47)/7, S(6)*sqrt(47)/5, S(8)*sqrt(47)/5]) == sqrt(47)*Rational(2, 35)
assert gcd([S(6)*(1 + sqrt(7))/5, S(2)*(1 + sqrt(7))/7, S(4)*(1 + sqrt(7))/13]) == (1 + sqrt(7))*Rational(2, 455)
assert lcm((Rational(7, 2)/sqrt(15), Rational(5, 6)/sqrt(15), Rational(5, 8)/sqrt(15))) == Rational(35, 2)/sqrt(15)
assert lcm([S(5)*(2 + 2**Rational(5, 7))/6, S(7)*(2 + 2**Rational(5, 7))/2, S(13)*(2 + 2**Rational(5, 7))/4]) == Rational(455, 2) * (2 + 2**Rational(5, 7))
def test_issue_15669():
x = Symbol("x", positive=True)
expr = (16*x**3/(-x**2 + sqrt(8*x**2 + (x**2 - 2)**2) + 2)**2 -
2*2**Rational(4, 5)*x*(-x**2 + sqrt(8*x**2 + (x**2 - 2)**2) + 2)**Rational(3, 5) + 10*x)
assert factor(expr, deep=True) == x*(x**2 + 2)
def test_issue_17988():
x = Symbol('x')
p = poly(x - 1)
M = Matrix([[poly(x + 1), poly(x + 1)]])
assert p * M == M * p == Matrix([[poly(x**2 - 1), poly(x**2 - 1)]])
def test_issue_18205():
assert cancel((2 + I)*(3 - I)) == 7 + I
assert cancel((2 + I)*(2 - I)) == 5
def test_issue_8695():
p = (x**2 + 1) * (x - 1)**2 * (x - 2)**3 * (x - 3)**3
result = (1, [(x**2 + 1, 1), (x - 1, 2), (x**2 - 5*x + 6, 3)])
assert sqf_list(p) == result
def test_issue_19113():
eq = sin(x)**3 - sin(x) + 1
raises(PolynomialError, lambda: refine_root(eq, 1, 2, 1e-2))
raises(PolynomialError, lambda: count_roots(eq, -1, 1))
raises(PolynomialError, lambda: real_roots(eq))
raises(PolynomialError, lambda: nroots(eq))
raises(PolynomialError, lambda: ground_roots(eq))
raises(PolynomialError, lambda: nth_power_roots_poly(eq, 2))
|
87622951808cff9de02cf3ed3574131092c019446b00fc0c68275c5bcaad55ab | """Tests for useful utilities for higher level polynomial classes. """
from sympy import (S, Integer, sin, cos, sqrt, symbols, pi,
Eq, Integral, exp, Mul)
from sympy.testing.pytest import raises
from sympy.polys.polyutils import (
_nsort,
_sort_gens,
_unify_gens,
_analyze_gens,
_sort_factors,
parallel_dict_from_expr,
dict_from_expr,
)
from sympy.polys.polyerrors import PolynomialError
from sympy.polys.domains import ZZ
x, y, z, p, q, r, s, t, u, v, w = symbols('x,y,z,p,q,r,s,t,u,v,w')
A, B = symbols('A,B', commutative=False)
def test__nsort():
# issue 6137
r = S('''[3/2 + sqrt(-14/3 - 2*(-415/216 + 13*I/12)**(1/3) - 4/sqrt(-7/3 +
61/(18*(-415/216 + 13*I/12)**(1/3)) + 2*(-415/216 + 13*I/12)**(1/3)) -
61/(18*(-415/216 + 13*I/12)**(1/3)))/2 - sqrt(-7/3 + 61/(18*(-415/216
+ 13*I/12)**(1/3)) + 2*(-415/216 + 13*I/12)**(1/3))/2, 3/2 - sqrt(-7/3
+ 61/(18*(-415/216 + 13*I/12)**(1/3)) + 2*(-415/216 +
13*I/12)**(1/3))/2 - sqrt(-14/3 - 2*(-415/216 + 13*I/12)**(1/3) -
4/sqrt(-7/3 + 61/(18*(-415/216 + 13*I/12)**(1/3)) + 2*(-415/216 +
13*I/12)**(1/3)) - 61/(18*(-415/216 + 13*I/12)**(1/3)))/2, 3/2 +
sqrt(-14/3 - 2*(-415/216 + 13*I/12)**(1/3) + 4/sqrt(-7/3 +
61/(18*(-415/216 + 13*I/12)**(1/3)) + 2*(-415/216 + 13*I/12)**(1/3)) -
61/(18*(-415/216 + 13*I/12)**(1/3)))/2 + sqrt(-7/3 + 61/(18*(-415/216
+ 13*I/12)**(1/3)) + 2*(-415/216 + 13*I/12)**(1/3))/2, 3/2 + sqrt(-7/3
+ 61/(18*(-415/216 + 13*I/12)**(1/3)) + 2*(-415/216 +
13*I/12)**(1/3))/2 - sqrt(-14/3 - 2*(-415/216 + 13*I/12)**(1/3) +
4/sqrt(-7/3 + 61/(18*(-415/216 + 13*I/12)**(1/3)) + 2*(-415/216 +
13*I/12)**(1/3)) - 61/(18*(-415/216 + 13*I/12)**(1/3)))/2]''')
ans = [r[1], r[0], r[-1], r[-2]]
assert _nsort(r) == ans
assert len(_nsort(r, separated=True)[0]) == 0
b, c, a = exp(-1000), exp(-999), exp(-1001)
assert _nsort((b, c, a)) == [a, b, c]
# issue 12560
a = cos(1)**2 + sin(1)**2 - 1
assert _nsort([a]) == [a]
def test__sort_gens():
assert _sort_gens([]) == ()
assert _sort_gens([x]) == (x,)
assert _sort_gens([p]) == (p,)
assert _sort_gens([q]) == (q,)
assert _sort_gens([x, p]) == (x, p)
assert _sort_gens([p, x]) == (x, p)
assert _sort_gens([q, p]) == (p, q)
assert _sort_gens([q, p, x]) == (x, p, q)
assert _sort_gens([x, p, q], wrt=x) == (x, p, q)
assert _sort_gens([x, p, q], wrt=p) == (p, x, q)
assert _sort_gens([x, p, q], wrt=q) == (q, x, p)
assert _sort_gens([x, p, q], wrt='x') == (x, p, q)
assert _sort_gens([x, p, q], wrt='p') == (p, x, q)
assert _sort_gens([x, p, q], wrt='q') == (q, x, p)
assert _sort_gens([x, p, q], wrt='x,q') == (x, q, p)
assert _sort_gens([x, p, q], wrt='q,x') == (q, x, p)
assert _sort_gens([x, p, q], wrt='p,q') == (p, q, x)
assert _sort_gens([x, p, q], wrt='q,p') == (q, p, x)
assert _sort_gens([x, p, q], wrt='x, q') == (x, q, p)
assert _sort_gens([x, p, q], wrt='q, x') == (q, x, p)
assert _sort_gens([x, p, q], wrt='p, q') == (p, q, x)
assert _sort_gens([x, p, q], wrt='q, p') == (q, p, x)
assert _sort_gens([x, p, q], wrt=[x, 'q']) == (x, q, p)
assert _sort_gens([x, p, q], wrt=[q, 'x']) == (q, x, p)
assert _sort_gens([x, p, q], wrt=[p, 'q']) == (p, q, x)
assert _sort_gens([x, p, q], wrt=[q, 'p']) == (q, p, x)
assert _sort_gens([x, p, q], wrt=['x', 'q']) == (x, q, p)
assert _sort_gens([x, p, q], wrt=['q', 'x']) == (q, x, p)
assert _sort_gens([x, p, q], wrt=['p', 'q']) == (p, q, x)
assert _sort_gens([x, p, q], wrt=['q', 'p']) == (q, p, x)
assert _sort_gens([x, p, q], sort='x > p > q') == (x, p, q)
assert _sort_gens([x, p, q], sort='p > x > q') == (p, x, q)
assert _sort_gens([x, p, q], sort='p > q > x') == (p, q, x)
assert _sort_gens([x, p, q], wrt='x', sort='q > p') == (x, q, p)
assert _sort_gens([x, p, q], wrt='p', sort='q > x') == (p, q, x)
assert _sort_gens([x, p, q], wrt='q', sort='p > x') == (q, p, x)
X = symbols('x0,x1,x2,x10,x11,x12,x20,x21,x22')
assert _sort_gens(X) == X
def test__unify_gens():
assert _unify_gens([], []) == ()
assert _unify_gens([x], [x]) == (x,)
assert _unify_gens([y], [y]) == (y,)
assert _unify_gens([x, y], [x]) == (x, y)
assert _unify_gens([x], [x, y]) == (x, y)
assert _unify_gens([x, y], [x, y]) == (x, y)
assert _unify_gens([y, x], [y, x]) == (y, x)
assert _unify_gens([x], [y]) == (x, y)
assert _unify_gens([y], [x]) == (y, x)
assert _unify_gens([x], [y, x]) == (y, x)
assert _unify_gens([y, x], [x]) == (y, x)
assert _unify_gens([x, y, z], [x, y, z]) == (x, y, z)
assert _unify_gens([z, y, x], [x, y, z]) == (z, y, x)
assert _unify_gens([x, y, z], [z, y, x]) == (x, y, z)
assert _unify_gens([z, y, x], [z, y, x]) == (z, y, x)
assert _unify_gens([x, y, z], [t, x, p, q, z]) == (t, x, y, p, q, z)
def test__analyze_gens():
assert _analyze_gens((x, y, z)) == (x, y, z)
assert _analyze_gens([x, y, z]) == (x, y, z)
assert _analyze_gens(([x, y, z],)) == (x, y, z)
assert _analyze_gens(((x, y, z),)) == (x, y, z)
def test__sort_factors():
assert _sort_factors([], multiple=True) == []
assert _sort_factors([], multiple=False) == []
F = [[1, 2, 3], [1, 2], [1]]
G = [[1], [1, 2], [1, 2, 3]]
assert _sort_factors(F, multiple=False) == G
F = [[1, 2], [1, 2, 3], [1, 2], [1]]
G = [[1], [1, 2], [1, 2], [1, 2, 3]]
assert _sort_factors(F, multiple=False) == G
F = [[2, 2], [1, 2, 3], [1, 2], [1]]
G = [[1], [1, 2], [2, 2], [1, 2, 3]]
assert _sort_factors(F, multiple=False) == G
F = [([1, 2, 3], 1), ([1, 2], 1), ([1], 1)]
G = [([1], 1), ([1, 2], 1), ([1, 2, 3], 1)]
assert _sort_factors(F, multiple=True) == G
F = [([1, 2], 1), ([1, 2, 3], 1), ([1, 2], 1), ([1], 1)]
G = [([1], 1), ([1, 2], 1), ([1, 2], 1), ([1, 2, 3], 1)]
assert _sort_factors(F, multiple=True) == G
F = [([2, 2], 1), ([1, 2, 3], 1), ([1, 2], 1), ([1], 1)]
G = [([1], 1), ([1, 2], 1), ([2, 2], 1), ([1, 2, 3], 1)]
assert _sort_factors(F, multiple=True) == G
F = [([2, 2], 1), ([1, 2, 3], 1), ([1, 2], 2), ([1], 1)]
G = [([1], 1), ([2, 2], 1), ([1, 2], 2), ([1, 2, 3], 1)]
assert _sort_factors(F, multiple=True) == G
def test__dict_from_expr_if_gens():
assert dict_from_expr(
Integer(17), gens=(x,)) == ({(0,): Integer(17)}, (x,))
assert dict_from_expr(
Integer(17), gens=(x, y)) == ({(0, 0): Integer(17)}, (x, y))
assert dict_from_expr(
Integer(17), gens=(x, y, z)) == ({(0, 0, 0): Integer(17)}, (x, y, z))
assert dict_from_expr(
Integer(-17), gens=(x,)) == ({(0,): Integer(-17)}, (x,))
assert dict_from_expr(
Integer(-17), gens=(x, y)) == ({(0, 0): Integer(-17)}, (x, y))
assert dict_from_expr(Integer(
-17), gens=(x, y, z)) == ({(0, 0, 0): Integer(-17)}, (x, y, z))
assert dict_from_expr(
Integer(17)*x, gens=(x,)) == ({(1,): Integer(17)}, (x,))
assert dict_from_expr(
Integer(17)*x, gens=(x, y)) == ({(1, 0): Integer(17)}, (x, y))
assert dict_from_expr(Integer(
17)*x, gens=(x, y, z)) == ({(1, 0, 0): Integer(17)}, (x, y, z))
assert dict_from_expr(
Integer(17)*x**7, gens=(x,)) == ({(7,): Integer(17)}, (x,))
assert dict_from_expr(
Integer(17)*x**7*y, gens=(x, y)) == ({(7, 1): Integer(17)}, (x, y))
assert dict_from_expr(Integer(17)*x**7*y*z**12, gens=(
x, y, z)) == ({(7, 1, 12): Integer(17)}, (x, y, z))
assert dict_from_expr(x + 2*y + 3*z, gens=(x,)) == \
({(1,): Integer(1), (0,): 2*y + 3*z}, (x,))
assert dict_from_expr(x + 2*y + 3*z, gens=(x, y)) == \
({(1, 0): Integer(1), (0, 1): Integer(2), (0, 0): 3*z}, (x, y))
assert dict_from_expr(x + 2*y + 3*z, gens=(x, y, z)) == \
({(1, 0, 0): Integer(
1), (0, 1, 0): Integer(2), (0, 0, 1): Integer(3)}, (x, y, z))
assert dict_from_expr(x*y + 2*x*z + 3*y*z, gens=(x,)) == \
({(1,): y + 2*z, (0,): 3*y*z}, (x,))
assert dict_from_expr(x*y + 2*x*z + 3*y*z, gens=(x, y)) == \
({(1, 1): Integer(1), (1, 0): 2*z, (0, 1): 3*z}, (x, y))
assert dict_from_expr(x*y + 2*x*z + 3*y*z, gens=(x, y, z)) == \
({(1, 1, 0): Integer(
1), (1, 0, 1): Integer(2), (0, 1, 1): Integer(3)}, (x, y, z))
assert dict_from_expr(2**y*x, gens=(x,)) == ({(1,): 2**y}, (x,))
assert dict_from_expr(Integral(x, (x, 1, 2)) + x) == (
{(0, 1): 1, (1, 0): 1}, (x, Integral(x, (x, 1, 2))))
raises(PolynomialError, lambda: dict_from_expr(2**y*x, gens=(x, y)))
def test__dict_from_expr_no_gens():
assert dict_from_expr(Integer(17)) == ({(): Integer(17)}, ())
assert dict_from_expr(x) == ({(1,): Integer(1)}, (x,))
assert dict_from_expr(y) == ({(1,): Integer(1)}, (y,))
assert dict_from_expr(x*y) == ({(1, 1): Integer(1)}, (x, y))
assert dict_from_expr(
x + y) == ({(1, 0): Integer(1), (0, 1): Integer(1)}, (x, y))
assert dict_from_expr(sqrt(2)) == ({(1,): Integer(1)}, (sqrt(2),))
assert dict_from_expr(sqrt(2), greedy=False) == ({(): sqrt(2)}, ())
assert dict_from_expr(x*y, domain=ZZ[x]) == ({(1,): x}, (y,))
assert dict_from_expr(x*y, domain=ZZ[y]) == ({(1,): y}, (x,))
assert dict_from_expr(3*sqrt(
2)*pi*x*y, extension=None) == ({(1, 1, 1, 1): 3}, (x, y, pi, sqrt(2)))
assert dict_from_expr(3*sqrt(
2)*pi*x*y, extension=True) == ({(1, 1, 1): 3*sqrt(2)}, (x, y, pi))
assert dict_from_expr(3*sqrt(
2)*pi*x*y, extension=True) == ({(1, 1, 1): 3*sqrt(2)}, (x, y, pi))
f = cos(x)*sin(x) + cos(x)*sin(y) + cos(y)*sin(x) + cos(y)*sin(y)
assert dict_from_expr(f) == ({(0, 1, 0, 1): 1, (0, 1, 1, 0): 1,
(1, 0, 0, 1): 1, (1, 0, 1, 0): 1}, (cos(x), cos(y), sin(x), sin(y)))
def test__parallel_dict_from_expr_if_gens():
assert parallel_dict_from_expr([x + 2*y + 3*z, Integer(7)], gens=(x,)) == \
([{(1,): Integer(1), (0,): 2*y + 3*z}, {(0,): Integer(7)}], (x,))
def test__parallel_dict_from_expr_no_gens():
assert parallel_dict_from_expr([x*y, Integer(3)]) == \
([{(1, 1): Integer(1)}, {(0, 0): Integer(3)}], (x, y))
assert parallel_dict_from_expr([x*y, 2*z, Integer(3)]) == \
([{(1, 1, 0): Integer(
1)}, {(0, 0, 1): Integer(2)}, {(0, 0, 0): Integer(3)}], (x, y, z))
assert parallel_dict_from_expr((Mul(x, x**2, evaluate=False),)) == \
([{(3,): 1}], (x,))
def test_parallel_dict_from_expr():
assert parallel_dict_from_expr([Eq(x, 1), Eq(
x**2, 2)]) == ([{(0,): -Integer(1), (1,): Integer(1)},
{(0,): -Integer(2), (2,): Integer(1)}], (x,))
raises(PolynomialError, lambda: parallel_dict_from_expr([A*B - B*A]))
def test_dict_from_expr():
assert dict_from_expr(Eq(x, 1)) == \
({(0,): -Integer(1), (1,): Integer(1)}, (x,))
raises(PolynomialError, lambda: dict_from_expr(A*B - B*A))
raises(PolynomialError, lambda: dict_from_expr(S.true))
|
a64a4ed3176d7f84e8b2813f456ee532e7099a20dd446f940d9ae4ba453a2ab3 | """Tests for algorithms for computing symbolic roots of polynomials. """
from sympy import (S, symbols, Symbol, Wild, Rational, sqrt,
powsimp, sin, cos, pi, I, Interval, re, im, exp, ZZ, Piecewise,
acos, root, conjugate)
from sympy.polys import Poly, cyclotomic_poly, intervals, nroots, rootof
from sympy.polys.polyroots import (root_factors, roots_linear,
roots_quadratic, roots_cubic, roots_quartic, roots_cyclotomic,
roots_binomial, preprocess_roots, roots)
from sympy.polys.orthopolys import legendre_poly
from sympy.polys.polyerrors import PolynomialError
from sympy.polys.polyutils import _nsort
from sympy.utilities.iterables import cartes
from sympy.testing.pytest import raises, slow
from sympy.testing.randtest import verify_numerically
import mpmath
a, b, c, d, e, q, t, x, y, z = symbols('a,b,c,d,e,q,t,x,y,z')
def _check(roots):
# this is the desired invariant for roots returned
# by all_roots. It is trivially true for linear
# polynomials.
nreal = sum([1 if i.is_real else 0 for i in roots])
assert list(sorted(roots[:nreal])) == list(roots[:nreal])
for ix in range(nreal, len(roots), 2):
if not (
roots[ix + 1] == roots[ix] or
roots[ix + 1] == conjugate(roots[ix])):
return False
return True
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]
_check(Poly(2*x**2 + 4*x + 3, x).all_roots())
f = x**2 + (2*a*e + 2*c*e)/(a - c)*x + (d - b + a*e**2 - c*e**2)/(a - c)
assert roots_quadratic(Poly(f, x)) == \
[-e*(a + c)/(a - c) - sqrt((a*b + c*d - a*d - b*c + 4*a*c*e**2))/(a - c),
-e*(a + c)/(a - c) + sqrt((a*b + c*d - a*d - b*c + 4*a*c*e**2))/(a - c)]
# check for simplification
f = Poly(y*x**2 - 2*x - 2*y, x)
assert roots_quadratic(f) == \
[-sqrt(2*y**2 + 1)/y + 1/y, sqrt(2*y**2 + 1)/y + 1/y]
f = Poly(x**2 + (-y**2 - 2)*x + y**2 + 1, x)
assert roots_quadratic(f) == \
[1,y**2 + 1]
f = Poly(sqrt(2)*x**2 - 1, x)
r = roots_quadratic(f)
assert r == _nsort(r)
# issue 8255
f = Poly(-24*x**2 - 180*x + 264)
assert [w.n(2) for w in f.all_roots(radicals=True)] == \
[w.n(2) for w in f.all_roots(radicals=False)]
for _a, _b, _c in cartes((-2, 2), (-2, 2), (0, -1)):
f = Poly(_a*x**2 + _b*x + _c)
roots = roots_quadratic(f)
assert roots == _nsort(roots)
def test_issue_7724():
eq = Poly(x**4*I + x**2 + I, x)
assert roots(eq) == {
sqrt(I/2 + sqrt(5)*I/2): 1,
sqrt(-sqrt(5)*I/2 + I/2): 1,
-sqrt(I/2 + sqrt(5)*I/2): 1,
-sqrt(-sqrt(5)*I/2 + I/2): 1}
def test_issue_8438():
p = Poly([1, y, -2, -3], x).as_expr()
roots = roots_cubic(Poly(p, x), x)
z = Rational(-3, 2) - I*Rational(7, 2) # this will fail in code given in commit msg
post = [r.subs(y, z) for r in roots]
assert set(post) == \
set(roots_cubic(Poly(p.subs(y, z), x)))
# /!\ if p is not made an expression, this is *very* slow
assert all(p.subs({y: z, x: i}).n(2, chop=True) == 0 for i in post)
def test_issue_8285():
roots = (Poly(4*x**8 - 1, x)*Poly(x**2 + 1)).all_roots()
assert _check(roots)
f = Poly(x**4 + 5*x**2 + 6, x)
ro = [rootof(f, i) for i in range(4)]
roots = Poly(x**4 + 5*x**2 + 6, x).all_roots()
assert roots == ro
assert _check(roots)
# more than 2 complex roots from which to identify the
# imaginary ones
roots = Poly(2*x**8 - 1).all_roots()
assert _check(roots)
assert len(Poly(2*x**10 - 1).all_roots()) == 10 # doesn't fail
def test_issue_8289():
roots = (Poly(x**2 + 2)*Poly(x**4 + 2)).all_roots()
assert _check(roots)
roots = Poly(x**6 + 3*x**3 + 2, x).all_roots()
assert _check(roots)
roots = Poly(x**6 - x + 1).all_roots()
assert _check(roots)
# all imaginary roots with multiplicity of 2
roots = Poly(x**4 + 4*x**2 + 4, x).all_roots()
assert _check(roots)
def test_issue_14291():
assert Poly(((x - 1)**2 + 1)*((x - 1)**2 + 2)*(x - 1)
).all_roots() == [1, 1 - I, 1 + I, 1 - sqrt(2)*I, 1 + sqrt(2)*I]
p = x**4 + 10*x**2 + 1
ans = [rootof(p, i) for i in range(4)]
assert Poly(p).all_roots() == ans
_check(ans)
def test_issue_13340():
eq = Poly(y**3 + exp(x)*y + x, y, domain='EX')
roots_d = roots(eq)
assert len(roots_d) == 3
def test_issue_14522():
eq = Poly(x**4 + x**3*(16 + 32*I) + x**2*(-285 + 386*I) + x*(-2824 - 448*I) - 2058 - 6053*I, x)
roots_eq = roots(eq)
assert all(eq(r) == 0 for r in roots_eq)
def test_issue_15076():
sol = roots_quartic(Poly(t**4 - 6*t**2 + t/x - 3, t))
assert sol[0].has(x)
def test_issue_16589():
eq = Poly(x**4 - 8*sqrt(2)*x**3 + 4*x**3 - 64*sqrt(2)*x**2 + 1024*x, x)
roots_eq = roots(eq)
assert 0 in roots_eq
def test_roots_cubic():
assert roots_cubic(Poly(2*x**3, x)) == [0, 0, 0]
assert roots_cubic(Poly(x**3 - 3*x**2 + 3*x - 1, x)) == [1, 1, 1]
assert roots_cubic(Poly(x**3 + 1, x)) == \
[-1, S.Half - I*sqrt(3)/2, S.Half + I*sqrt(3)/2]
assert roots_cubic(Poly(2*x**3 - 3*x**2 - 3*x - 1, x))[0] == \
S.Half + 3**Rational(1, 3)/2 + 3**Rational(2, 3)/2
eq = -x**3 + 2*x**2 + 3*x - 2
assert roots(eq, trig=True, multiple=True) == \
roots_cubic(Poly(eq, x), trig=True) == [
Rational(2, 3) + 2*sqrt(13)*cos(acos(8*sqrt(13)/169)/3)/3,
-2*sqrt(13)*sin(-acos(8*sqrt(13)/169)/3 + pi/6)/3 + Rational(2, 3),
-2*sqrt(13)*cos(-acos(8*sqrt(13)/169)/3 + pi/3)/3 + Rational(2, 3),
]
def test_roots_quartic():
assert roots_quartic(Poly(x**4, x)) == [0, 0, 0, 0]
assert roots_quartic(Poly(x**4 + x**3, x)) in [
[-1, 0, 0, 0],
[0, -1, 0, 0],
[0, 0, -1, 0],
[0, 0, 0, -1]
]
assert roots_quartic(Poly(x**4 - x**3, x)) in [
[1, 0, 0, 0],
[0, 1, 0, 0],
[0, 0, 1, 0],
[0, 0, 0, 1]
]
lhs = roots_quartic(Poly(x**4 + x, x))
rhs = [S.Half + I*sqrt(3)/2, S.Half - I*sqrt(3)/2, S.Zero, -S.One]
assert sorted(lhs, key=hash) == sorted(rhs, key=hash)
# test of all branches of roots quartic
for i, (a, b, c, d) in enumerate([(1, 2, 3, 0),
(3, -7, -9, 9),
(1, 2, 3, 4),
(1, 2, 3, 4),
(-7, -3, 3, -6),
(-3, 5, -6, -4),
(6, -5, -10, -3)]):
if i == 2:
c = -a*(a**2/S(8) - b/S(2))
elif i == 3:
d = a*(a*(a**2*Rational(3, 256) - b/S(16)) + c/S(4))
eq = x**4 + a*x**3 + b*x**2 + c*x + d
ans = roots_quartic(Poly(eq, x))
assert all(eq.subs(x, ai).n(chop=True) == 0 for ai in ans)
# not all symbolic quartics are unresolvable
eq = Poly(q*x + q/4 + x**4 + x**3 + 2*x**2 - Rational(1, 3), x)
sol = roots_quartic(eq)
assert all(verify_numerically(eq.subs(x, i), 0) for i in sol)
z = symbols('z', negative=True)
eq = x**4 + 2*x**3 + 3*x**2 + x*(z + 11) + 5
zans = roots_quartic(Poly(eq, x))
assert all([verify_numerically(eq.subs(((x, i), (z, -1))), 0) for i in zans])
# but some are (see also issue 4989)
# it's ok if the solution is not Piecewise, but the tests below should pass
eq = Poly(y*x**4 + x**3 - x + z, x)
ans = roots_quartic(eq)
assert all(type(i) == Piecewise for i in ans)
reps = (
dict(y=Rational(-1, 3), z=Rational(-1, 4)), # 4 real
dict(y=Rational(-1, 3), z=Rational(-1, 2)), # 2 real
dict(y=Rational(-1, 3), z=-2)) # 0 real
for rep in reps:
sol = roots_quartic(Poly(eq.subs(rep), x))
assert all([verify_numerically(w.subs(rep) - s, 0) for w, s in zip(ans, sol)])
def test_roots_cyclotomic():
assert roots_cyclotomic(cyclotomic_poly(1, x, polys=True)) == [1]
assert roots_cyclotomic(cyclotomic_poly(2, x, polys=True)) == [-1]
assert roots_cyclotomic(cyclotomic_poly(
3, x, polys=True)) == [Rational(-1, 2) - I*sqrt(3)/2, Rational(-1, 2) + I*sqrt(3)/2]
assert roots_cyclotomic(cyclotomic_poly(4, x, polys=True)) == [-I, I]
assert roots_cyclotomic(cyclotomic_poly(
6, x, polys=True)) == [S.Half - I*sqrt(3)/2, S.Half + I*sqrt(3)/2]
assert roots_cyclotomic(cyclotomic_poly(7, x, polys=True)) == [
-cos(pi/7) - I*sin(pi/7),
-cos(pi/7) + I*sin(pi/7),
-cos(pi*Rational(3, 7)) - I*sin(pi*Rational(3, 7)),
-cos(pi*Rational(3, 7)) + I*sin(pi*Rational(3, 7)),
cos(pi*Rational(2, 7)) - I*sin(pi*Rational(2, 7)),
cos(pi*Rational(2, 7)) + I*sin(pi*Rational(2, 7)),
]
assert roots_cyclotomic(cyclotomic_poly(8, x, polys=True)) == [
-sqrt(2)/2 - I*sqrt(2)/2,
-sqrt(2)/2 + I*sqrt(2)/2,
sqrt(2)/2 - I*sqrt(2)/2,
sqrt(2)/2 + I*sqrt(2)/2,
]
assert roots_cyclotomic(cyclotomic_poly(12, x, polys=True)) == [
-sqrt(3)/2 - I/2,
-sqrt(3)/2 + I/2,
sqrt(3)/2 - I/2,
sqrt(3)/2 + I/2,
]
assert roots_cyclotomic(
cyclotomic_poly(1, x, polys=True), factor=True) == [1]
assert roots_cyclotomic(
cyclotomic_poly(2, x, polys=True), factor=True) == [-1]
assert roots_cyclotomic(cyclotomic_poly(3, x, polys=True), factor=True) == \
[-root(-1, 3), -1 + root(-1, 3)]
assert roots_cyclotomic(cyclotomic_poly(4, x, polys=True), factor=True) == \
[-I, I]
assert roots_cyclotomic(cyclotomic_poly(5, x, polys=True), factor=True) == \
[-root(-1, 5), -root(-1, 5)**3, root(-1, 5)**2, -1 - root(-1, 5)**2 + root(-1, 5) + root(-1, 5)**3]
assert roots_cyclotomic(cyclotomic_poly(6, x, polys=True), factor=True) == \
[1 - root(-1, 3), root(-1, 3)]
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 - A*I, -A + A*I, A - A*I, A + A*I]
_check(roots_binomial(Poly(x**8 - 2)))
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 powsimp(r0[0]) == powsimp(r1[0])
assert powsimp(r0[1]) == powsimp(r1[1])
for a, b, s, n in cartes((1, 2), (1, 2), (-1, 1), (2, 3, 4, 5)):
if a == b and a != 1: # a == b == 1 is sufficient
continue
p = Poly(a*x**n + s*b)
ans = roots_binomial(p)
assert ans == _nsort(ans)
# issue 8813
assert roots(Poly(2*x**3 - 16*y**3, x)) == {
2*y*(Rational(-1, 2) - sqrt(3)*I/2): 1,
2*y: 1,
2*y*(Rational(-1, 2) + sqrt(3)*I/2): 1}
def test_roots_preprocessing():
f = a*y*x**2 + y - b
coeff, poly = preprocess_roots(Poly(f, x))
assert coeff == 1
assert poly == Poly(a*y*x**2 + y - b, x)
f = c**3*x**3 + c**2*x**2 + c*x + a
coeff, poly = preprocess_roots(Poly(f, x))
assert coeff == 1/c
assert poly == Poly(x**3 + x**2 + x + a, x)
f = c**3*x**3 + c**2*x**2 + a
coeff, poly = preprocess_roots(Poly(f, x))
assert coeff == 1/c
assert poly == Poly(x**3 + x**2 + a, x)
f = c**3*x**3 + c*x + a
coeff, poly = preprocess_roots(Poly(f, x))
assert coeff == 1/c
assert poly == Poly(x**3 + x + a, x)
f = c**3*x**3 + a
coeff, poly = preprocess_roots(Poly(f, x))
assert coeff == 1/c
assert poly == Poly(x**3 + a, x)
E, F, J, L = symbols("E,F,J,L")
f = -21601054687500000000*E**8*J**8/L**16 + \
508232812500000000*F*x*E**7*J**7/L**14 - \
4269543750000000*E**6*F**2*J**6*x**2/L**12 + \
16194716250000*E**5*F**3*J**5*x**3/L**10 - \
27633173750*E**4*F**4*J**4*x**4/L**8 + \
14840215*E**3*F**5*J**3*x**5/L**6 + \
54794*E**2*F**6*J**2*x**6/(5*L**4) - \
1153*E*J*F**7*x**7/(80*L**2) + \
633*F**8*x**8/160000
coeff, poly = preprocess_roots(Poly(f, x))
assert coeff == 20*E*J/(F*L**2)
assert poly == 633*x**8 - 115300*x**7 + 4383520*x**6 + 296804300*x**5 - 27633173750*x**4 + \
809735812500*x**3 - 10673859375000*x**2 + 63529101562500*x - 135006591796875
f = Poly(-y**2 + x**2*exp(x), y, domain=ZZ[x, exp(x)])
g = Poly(-y**2 + exp(x), y, domain=ZZ[exp(x)])
assert preprocess_roots(f) == (x, g)
def test_roots0():
assert roots(1, x) == {}
assert roots(x, x) == {S.Zero: 1}
assert roots(x**9, x) == {S.Zero: 9}
assert roots(((x - 2)*(x + 3)*(x - 4)).expand(), x) == {-S(3): 1, S(2): 1, S(4): 1}
assert roots(2*x + 1, x) == {Rational(-1, 2): 1}
assert roots((2*x + 1)**2, x) == {Rational(-1, 2): 2}
assert roots((2*x + 1)**5, x) == {Rational(-1, 2): 5}
assert roots((2*x + 1)**10, x) == {Rational(-1, 2): 10}
assert roots(x**4 - 1, x) == {I: 1, S.One: 1, -S.One: 1, -I: 1}
assert roots((x**4 - 1)**2, x) == {I: 2, S.One: 2, -S.One: 2, -I: 2}
assert roots(((2*x - 3)**2).expand(), x) == {Rational( 3, 2): 2}
assert roots(((2*x + 3)**2).expand(), x) == {Rational(-3, 2): 2}
assert roots(((2*x - 3)**3).expand(), x) == {Rational( 3, 2): 3}
assert roots(((2*x + 3)**3).expand(), x) == {Rational(-3, 2): 3}
assert roots(((2*x - 3)**5).expand(), x) == {Rational( 3, 2): 5}
assert roots(((2*x + 3)**5).expand(), x) == {Rational(-3, 2): 5}
assert roots(((a*x - b)**5).expand(), x) == { b/a: 5}
assert roots(((a*x + b)**5).expand(), x) == {-b/a: 5}
assert roots(x**2 + (-a - 1)*x + a, x) == {a: 1, S.One: 1}
assert roots(x**4 - 2*x**2 + 1, x) == {S.One: 2, S.NegativeOne: 2}
assert roots(x**6 - 4*x**4 + 4*x**3 - x**2, x) == \
{S.One: 2, -1 - sqrt(2): 1, S.Zero: 2, -1 + sqrt(2): 1}
assert roots(x**8 - 1, x) == {
sqrt(2)/2 + I*sqrt(2)/2: 1,
sqrt(2)/2 - I*sqrt(2)/2: 1,
-sqrt(2)/2 + I*sqrt(2)/2: 1,
-sqrt(2)/2 - I*sqrt(2)/2: 1,
S.One: 1, -S.One: 1, I: 1, -I: 1
}
f = -2016*x**2 - 5616*x**3 - 2056*x**4 + 3324*x**5 + 2176*x**6 - \
224*x**7 - 384*x**8 - 64*x**9
assert roots(f) == {S.Zero: 2, -S(2): 2, S(2): 1, Rational(-7, 2): 1,
Rational(-3, 2): 1, Rational(-1, 2): 1, Rational(3, 2): 1}
assert roots((a + b + c)*x - (a + b + c + d), x) == {(a + b + c + d)/(a + b + c): 1}
assert roots(x**3 + x**2 - x + 1, x, cubics=False) == {}
assert roots(((x - 2)*(
x + 3)*(x - 4)).expand(), x, cubics=False) == {-S(3): 1, S(2): 1, S(4): 1}
assert roots(((x - 2)*(x + 3)*(x - 4)*(x - 5)).expand(), x, cubics=False) == \
{-S(3): 1, S(2): 1, S(4): 1, S(5): 1}
assert roots(x**3 + 2*x**2 + 4*x + 8, x) == {-S(2): 1, -2*I: 1, 2*I: 1}
assert roots(x**3 + 2*x**2 + 4*x + 8, x, cubics=True) == \
{-2*I: 1, 2*I: 1, -S(2): 1}
assert roots((x**2 - x)*(x**3 + 2*x**2 + 4*x + 8), x ) == \
{S.One: 1, S.Zero: 1, -S(2): 1, -2*I: 1, 2*I: 1}
r1_2, r1_3 = S.Half, Rational(1, 3)
x0 = (3*sqrt(33) + 19)**r1_3
x1 = 4/x0/3
x2 = x0/3
x3 = sqrt(3)*I/2
x4 = x3 - r1_2
x5 = -x3 - r1_2
assert roots(x**3 + x**2 - x + 1, x, cubics=True) == {
-x1 - x2 - r1_3: 1,
-x1/x4 - x2*x4 - r1_3: 1,
-x1/x5 - x2*x5 - r1_3: 1,
}
f = (x**2 + 2*x + 3).subs(x, 2*x**2 + 3*x).subs(x, 5*x - 4)
r13_20, r1_20 = [ Rational(*r)
for r in ((13, 20), (1, 20)) ]
s2 = sqrt(2)
assert roots(f, x) == {
r13_20 + r1_20*sqrt(1 - 8*I*s2): 1,
r13_20 - r1_20*sqrt(1 - 8*I*s2): 1,
r13_20 + r1_20*sqrt(1 + 8*I*s2): 1,
r13_20 - r1_20*sqrt(1 + 8*I*s2): 1,
}
f = x**4 + x**3 + x**2 + x + 1
r1_4, r1_8, r5_8 = [ Rational(*r) for r in ((1, 4), (1, 8), (5, 8)) ]
assert roots(f, x) == {
-r1_4 + r1_4*5**r1_2 + I*(r5_8 + r1_8*5**r1_2)**r1_2: 1,
-r1_4 + r1_4*5**r1_2 - I*(r5_8 + r1_8*5**r1_2)**r1_2: 1,
-r1_4 - r1_4*5**r1_2 + I*(r5_8 - r1_8*5**r1_2)**r1_2: 1,
-r1_4 - r1_4*5**r1_2 - I*(r5_8 - r1_8*5**r1_2)**r1_2: 1,
}
f = z**3 + (-2 - y)*z**2 + (1 + 2*y - 2*x**2)*z - y + 2*x**2
assert roots(f, z) == {
S.One: 1,
S.Half + S.Half*y + S.Half*sqrt(1 - 2*y + y**2 + 8*x**2): 1,
S.Half + S.Half*y - S.Half*sqrt(1 - 2*y + y**2 + 8*x**2): 1,
}
assert roots(a*b*c*x**3 + 2*x**2 + 4*x + 8, x, cubics=False) == {}
assert roots(a*b*c*x**3 + 2*x**2 + 4*x + 8, x, cubics=True) != {}
assert roots(x**4 - 1, x, filter='Z') == {S.One: 1, -S.One: 1}
assert roots(x**4 - 1, x, filter='I') == {I: 1, -I: 1}
assert roots((x - 1)*(x + 1), x) == {S.One: 1, -S.One: 1}
assert roots(
(x - 1)*(x + 1), x, predicate=lambda r: r.is_positive) == {S.One: 1}
assert roots(x**4 - 1, x, filter='Z', multiple=True) == [-S.One, S.One]
assert roots(x**4 - 1, x, filter='I', multiple=True) == [I, -I]
ar, br = symbols('a, b', real=True)
p = x**2*(ar-br)**2 + 2*x*(br-ar) + 1
assert roots(p, x, filter='R') == {1/(ar - br): 2}
assert roots(x**3, x, multiple=True) == [S.Zero, S.Zero, S.Zero]
assert roots(1234, x, multiple=True) == []
f = x**6 - x**5 + x**4 - x**3 + x**2 - x + 1
assert roots(f) == {
-I*sin(pi/7) + cos(pi/7): 1,
-I*sin(pi*Rational(2, 7)) - cos(pi*Rational(2, 7)): 1,
-I*sin(pi*Rational(3, 7)) + cos(pi*Rational(3, 7)): 1,
I*sin(pi/7) + cos(pi/7): 1,
I*sin(pi*Rational(2, 7)) - cos(pi*Rational(2, 7)): 1,
I*sin(pi*Rational(3, 7)) + cos(pi*Rational(3, 7)): 1,
}
g = ((x**2 + 1)*f**2).expand()
assert roots(g) == {
-I*sin(pi/7) + cos(pi/7): 2,
-I*sin(pi*Rational(2, 7)) - cos(pi*Rational(2, 7)): 2,
-I*sin(pi*Rational(3, 7)) + cos(pi*Rational(3, 7)): 2,
I*sin(pi/7) + cos(pi/7): 2,
I*sin(pi*Rational(2, 7)) - cos(pi*Rational(2, 7)): 2,
I*sin(pi*Rational(3, 7)) + cos(pi*Rational(3, 7)): 2,
-I: 1, I: 1,
}
r = roots(x**3 + 40*x + 64)
real_root = [rx for rx in r if rx.is_real][0]
cr = 108 + 6*sqrt(1074)
assert real_root == -2*root(cr, 3)/3 + 20/root(cr, 3)
eq = Poly((7 + 5*sqrt(2))*x**3 + (-6 - 4*sqrt(2))*x**2 + (-sqrt(2) - 1)*x + 2, x, domain='EX')
assert roots(eq) == {-1 + sqrt(2): 1, -2 + 2*sqrt(2): 1, -sqrt(2) + 1: 1}
eq = Poly(41*x**5 + 29*sqrt(2)*x**5 - 153*x**4 - 108*sqrt(2)*x**4 +
175*x**3 + 125*sqrt(2)*x**3 - 45*x**2 - 30*sqrt(2)*x**2 - 26*sqrt(2)*x -
26*x + 24, x, domain='EX')
assert roots(eq) == {-sqrt(2) + 1: 1, -2 + 2*sqrt(2): 1, -1 + sqrt(2): 1,
-4 + 4*sqrt(2): 1, -3 + 3*sqrt(2): 1}
eq = Poly(x**3 - 2*x**2 + 6*sqrt(2)*x**2 - 8*sqrt(2)*x + 23*x - 14 +
14*sqrt(2), x, domain='EX')
assert roots(eq) == {-2*sqrt(2) + 2: 1, -2*sqrt(2) + 1: 1, -2*sqrt(2) - 1: 1}
assert roots(Poly((x + sqrt(2))**3 - 7, x, domain='EX')) == \
{-sqrt(2) - root(7, 3)/2 - sqrt(3)*root(7, 3)*I/2: 1,
-sqrt(2) - root(7, 3)/2 + sqrt(3)*root(7, 3)*I/2: 1,
-sqrt(2) + root(7, 3): 1}
def test_roots_slow():
"""Just test that calculating these roots does not hang. """
a, b, c, d, x = symbols("a,b,c,d,x")
f1 = x**2*c + (a/b) + x*c*d - a
f2 = x**2*(a + b*(c - d)*a) + x*a*b*c/(b*d - d) + (a*d - c/d)
assert list(roots(f1, x).values()) == [1, 1]
assert list(roots(f2, x).values()) == [1, 1]
(zz, yy, xx, zy, zx, yx, k) = symbols("zz,yy,xx,zy,zx,yx,k")
e1 = (zz - k)*(yy - k)*(xx - k) + zy*yx*zx + zx - zy - yx
e2 = (zz - k)*yx*yx + zx*(yy - k)*zx + zy*zy*(xx - k)
assert list(roots(e1 - e2, k).values()) == [1, 1, 1]
f = x**3 + 2*x**2 + 8
R = list(roots(f).keys())
assert not any(i for i in [f.subs(x, ri).n(chop=True) for ri in R])
def test_roots_inexact():
R1 = roots(x**2 + x + 1, x, multiple=True)
R2 = roots(x**2 + x + 1.0, x, multiple=True)
for r1, r2 in zip(R1, R2):
assert abs(r1 - r2) < 1e-12
f = x**4 + 3.0*sqrt(2.0)*x**3 - (78.0 + 24.0*sqrt(3.0))*x**2 \
+ 144.0*(2*sqrt(3.0) + 9.0)
R1 = roots(f, multiple=True)
R2 = (-12.7530479110482, -3.85012393732929,
4.89897948556636, 7.46155167569183)
for r1, r2 in zip(R1, R2):
assert abs(r1 - r2) < 1e-10
def test_roots_preprocessed():
E, F, J, L = symbols("E,F,J,L")
f = -21601054687500000000*E**8*J**8/L**16 + \
508232812500000000*F*x*E**7*J**7/L**14 - \
4269543750000000*E**6*F**2*J**6*x**2/L**12 + \
16194716250000*E**5*F**3*J**5*x**3/L**10 - \
27633173750*E**4*F**4*J**4*x**4/L**8 + \
14840215*E**3*F**5*J**3*x**5/L**6 + \
54794*E**2*F**6*J**2*x**6/(5*L**4) - \
1153*E*J*F**7*x**7/(80*L**2) + \
633*F**8*x**8/160000
assert roots(f, x) == {}
R1 = roots(f.evalf(), x, multiple=True)
R2 = [-1304.88375606366, 97.1168816800648, 186.946430171876, 245.526792947065,
503.441004174773, 791.549343830097, 1273.16678129348, 1850.10650616851]
w = Wild('w')
p = w*E*J/(F*L**2)
assert len(R1) == len(R2)
for r1, r2 in zip(R1, R2):
match = r1.match(p)
assert match is not None and abs(match[w] - r2) < 1e-10
def test_roots_mixed():
f = -1936 - 5056*x - 7592*x**2 + 2704*x**3 - 49*x**4
_re, _im = intervals(f, all=True)
_nroots = nroots(f)
_sroots = roots(f, multiple=True)
_re = [ Interval(a, b) for (a, b), _ in _re ]
_im = [ Interval(re(a), re(b))*Interval(im(a), im(b)) for (a, b),
_ in _im ]
_intervals = _re + _im
_sroots = [ r.evalf() for r in _sroots ]
_nroots = sorted(_nroots, key=lambda x: x.sort_key())
_sroots = sorted(_sroots, key=lambda x: x.sort_key())
for _roots in (_nroots, _sroots):
for i, r in zip(_intervals, _roots):
if r.is_real:
assert r in i
else:
assert (re(r), im(r)) in i
def test_root_factors():
assert root_factors(Poly(1, x)) == [Poly(1, x)]
assert root_factors(Poly(x, x)) == [Poly(x, x)]
assert root_factors(x**2 - 1, x) == [x + 1, x - 1]
assert root_factors(x**2 - y, x) == [x - sqrt(y), x + sqrt(y)]
assert root_factors((x**4 - 1)**2) == \
[x + 1, x + 1, x - 1, x - 1, x - I, x - I, x + I, x + I]
assert root_factors(Poly(x**4 - 1, x), filter='Z') == \
[Poly(x + 1, x), Poly(x - 1, x), Poly(x**2 + 1, x)]
assert root_factors(8*x**2 + 12*x**4 + 6*x**6 + x**8, x, filter='Q') == \
[x, x, x**6 + 6*x**4 + 12*x**2 + 8]
@slow
def test_nroots1():
n = 64
p = legendre_poly(n, x, polys=True)
raises(mpmath.mp.NoConvergence, lambda: p.nroots(n=3, maxsteps=5))
roots = p.nroots(n=3)
# The order of roots matters. They are ordered from smallest to the
# largest.
assert [str(r) for r in roots] == \
['-0.999', '-0.996', '-0.991', '-0.983', '-0.973', '-0.961',
'-0.946', '-0.930', '-0.911', '-0.889', '-0.866', '-0.841',
'-0.813', '-0.784', '-0.753', '-0.720', '-0.685', '-0.649',
'-0.611', '-0.572', '-0.531', '-0.489', '-0.446', '-0.402',
'-0.357', '-0.311', '-0.265', '-0.217', '-0.170', '-0.121',
'-0.0730', '-0.0243', '0.0243', '0.0730', '0.121', '0.170',
'0.217', '0.265', '0.311', '0.357', '0.402', '0.446', '0.489',
'0.531', '0.572', '0.611', '0.649', '0.685', '0.720', '0.753',
'0.784', '0.813', '0.841', '0.866', '0.889', '0.911', '0.930',
'0.946', '0.961', '0.973', '0.983', '0.991', '0.996', '0.999']
def test_nroots2():
p = Poly(x**5 + 3*x + 1, x)
roots = p.nroots(n=3)
# The order of roots matters. The roots are ordered by their real
# components (if they agree, then by their imaginary components),
# with real roots appearing first.
assert [str(r) for r in roots] == \
['-0.332', '-0.839 - 0.944*I', '-0.839 + 0.944*I',
'1.01 - 0.937*I', '1.01 + 0.937*I']
roots = p.nroots(n=5)
assert [str(r) for r in roots] == \
['-0.33199', '-0.83907 - 0.94385*I', '-0.83907 + 0.94385*I',
'1.0051 - 0.93726*I', '1.0051 + 0.93726*I']
def test_roots_composite():
assert len(roots(Poly(y**3 + y**2*sqrt(x) + y + x, y, composite=True))) == 3
def test_issue_19113():
eq = cos(x)**3 - cos(x) + 1
raises(PolynomialError, lambda: roots(eq))
|
83e29a3f59aa8d3f2a559e0d18498606e1321cb2bbdfbfa751c07d3d1936c45b | from sympy.core.function import Derivative
from sympy.vector.vector import Vector
from sympy.vector.coordsysrect import CoordSys3D
from sympy.simplify import simplify
from sympy.core.symbol import symbols
from sympy.core import S
from sympy import sin, cos
from sympy.vector.vector import Dot
from sympy.vector.operators import curl, divergence, gradient, Gradient, Divergence, Cross
from sympy.vector.deloperator import Del
from sympy.vector.functions import (is_conservative, is_solenoidal,
scalar_potential, directional_derivative,
laplacian, scalar_potential_difference)
from sympy.testing.pytest import raises
C = CoordSys3D('C')
i, j, k = C.base_vectors()
x, y, z = C.base_scalars()
delop = Del()
a, b, c, q = symbols('a b c q')
def test_del_operator():
# Tests for curl
assert delop ^ Vector.zero == Vector.zero
assert ((delop ^ Vector.zero).doit() == Vector.zero ==
curl(Vector.zero))
assert delop.cross(Vector.zero) == delop ^ Vector.zero
assert (delop ^ i).doit() == Vector.zero
assert delop.cross(2*y**2*j, doit=True) == Vector.zero
assert delop.cross(2*y**2*j) == delop ^ 2*y**2*j
v = x*y*z * (i + j + k)
assert ((delop ^ v).doit() ==
(-x*y + x*z)*i + (x*y - y*z)*j + (-x*z + y*z)*k ==
curl(v))
assert delop ^ v == delop.cross(v)
assert (delop.cross(2*x**2*j) ==
(Derivative(0, C.y) - Derivative(2*C.x**2, C.z))*C.i +
(-Derivative(0, C.x) + Derivative(0, C.z))*C.j +
(-Derivative(0, C.y) + Derivative(2*C.x**2, C.x))*C.k)
assert (delop.cross(2*x**2*j, doit=True) == 4*x*k ==
curl(2*x**2*j))
#Tests for divergence
assert delop & Vector.zero is S.Zero == divergence(Vector.zero)
assert (delop & Vector.zero).doit() is S.Zero
assert delop.dot(Vector.zero) == delop & Vector.zero
assert (delop & i).doit() is S.Zero
assert (delop & x**2*i).doit() == 2*x == divergence(x**2*i)
assert (delop.dot(v, doit=True) == x*y + y*z + z*x ==
divergence(v))
assert delop & v == delop.dot(v)
assert delop.dot(1/(x*y*z) * (i + j + k), doit=True) == \
- 1 / (x*y*z**2) - 1 / (x*y**2*z) - 1 / (x**2*y*z)
v = x*i + y*j + z*k
assert (delop & v == Derivative(C.x, C.x) +
Derivative(C.y, C.y) + Derivative(C.z, C.z))
assert delop.dot(v, doit=True) == 3 == divergence(v)
assert delop & v == delop.dot(v)
assert simplify((delop & v).doit()) == 3
#Tests for gradient
assert (delop.gradient(0, doit=True) == Vector.zero ==
gradient(0))
assert delop.gradient(0) == delop(0)
assert (delop(S.Zero)).doit() == Vector.zero
assert (delop(x) == (Derivative(C.x, C.x))*C.i +
(Derivative(C.x, C.y))*C.j + (Derivative(C.x, C.z))*C.k)
assert (delop(x)).doit() == i == gradient(x)
assert (delop(x*y*z) ==
(Derivative(C.x*C.y*C.z, C.x))*C.i +
(Derivative(C.x*C.y*C.z, C.y))*C.j +
(Derivative(C.x*C.y*C.z, C.z))*C.k)
assert (delop.gradient(x*y*z, doit=True) ==
y*z*i + z*x*j + x*y*k ==
gradient(x*y*z))
assert delop(x*y*z) == delop.gradient(x*y*z)
assert (delop(2*x**2)).doit() == 4*x*i
assert ((delop(a*sin(y) / x)).doit() ==
-a*sin(y)/x**2 * i + a*cos(y)/x * j)
#Tests for directional derivative
assert (Vector.zero & delop)(a) is S.Zero
assert ((Vector.zero & delop)(a)).doit() is S.Zero
assert ((v & delop)(Vector.zero)).doit() == Vector.zero
assert ((v & delop)(S.Zero)).doit() is S.Zero
assert ((i & delop)(x)).doit() == 1
assert ((j & delop)(y)).doit() == 1
assert ((k & delop)(z)).doit() == 1
assert ((i & delop)(x*y*z)).doit() == y*z
assert ((v & delop)(x)).doit() == x
assert ((v & delop)(x*y*z)).doit() == 3*x*y*z
assert (v & delop)(x + y + z) == C.x + C.y + C.z
assert ((v & delop)(x + y + z)).doit() == x + y + z
assert ((v & delop)(v)).doit() == v
assert ((i & delop)(v)).doit() == i
assert ((j & delop)(v)).doit() == j
assert ((k & delop)(v)).doit() == k
assert ((v & delop)(Vector.zero)).doit() == Vector.zero
# Tests for laplacian on scalar fields
assert laplacian(x*y*z) is S.Zero
assert laplacian(x**2) == S(2)
assert laplacian(x**2*y**2*z**2) == \
2*y**2*z**2 + 2*x**2*z**2 + 2*x**2*y**2
A = CoordSys3D('A', transformation="spherical", variable_names=["r", "theta", "phi"])
B = CoordSys3D('B', transformation='cylindrical', variable_names=["r", "theta", "z"])
assert laplacian(A.r + A.theta + A.phi) == 2/A.r + cos(A.theta)/(A.r**2*sin(A.theta))
assert laplacian(B.r + B.theta + B.z) == 1/B.r
# Tests for laplacian on vector fields
assert laplacian(x*y*z*(i + j + k)) == Vector.zero
assert laplacian(x*y**2*z*(i + j + k)) == \
2*x*z*i + 2*x*z*j + 2*x*z*k
def test_product_rules():
"""
Tests the six product rules defined with respect to the Del
operator
References
==========
.. [1] https://en.wikipedia.org/wiki/Del
"""
#Define the scalar and vector functions
f = 2*x*y*z
g = x*y + y*z + z*x
u = x**2*i + 4*j - y**2*z*k
v = 4*i + x*y*z*k
# First product rule
lhs = delop(f * g, doit=True)
rhs = (f * delop(g) + g * delop(f)).doit()
assert simplify(lhs) == simplify(rhs)
# Second product rule
lhs = delop(u & v).doit()
rhs = ((u ^ (delop ^ v)) + (v ^ (delop ^ u)) + \
((u & delop)(v)) + ((v & delop)(u))).doit()
assert simplify(lhs) == simplify(rhs)
# Third product rule
lhs = (delop & (f*v)).doit()
rhs = ((f * (delop & v)) + (v & (delop(f)))).doit()
assert simplify(lhs) == simplify(rhs)
# Fourth product rule
lhs = (delop & (u ^ v)).doit()
rhs = ((v & (delop ^ u)) - (u & (delop ^ v))).doit()
assert simplify(lhs) == simplify(rhs)
# Fifth product rule
lhs = (delop ^ (f * v)).doit()
rhs = (((delop(f)) ^ v) + (f * (delop ^ v))).doit()
assert simplify(lhs) == simplify(rhs)
# Sixth product rule
lhs = (delop ^ (u ^ v)).doit()
rhs = ((u * (delop & v) - v * (delop & u) +
(v & delop)(u) - (u & delop)(v))).doit()
assert simplify(lhs) == simplify(rhs)
P = C.orient_new_axis('P', q, C.k) # type: ignore
scalar_field = 2*x**2*y*z
grad_field = gradient(scalar_field)
vector_field = y**2*i + 3*x*j + 5*y*z*k
curl_field = curl(vector_field)
def test_conservative():
assert is_conservative(Vector.zero) is True
assert is_conservative(i) is True
assert is_conservative(2 * i + 3 * j + 4 * k) is True
assert (is_conservative(y*z*i + x*z*j + x*y*k) is
True)
assert is_conservative(x * j) is False
assert is_conservative(grad_field) is True
assert is_conservative(curl_field) is False
assert (is_conservative(4*x*y*z*i + 2*x**2*z*j) is
False)
assert is_conservative(z*P.i + P.x*k) is True
def test_solenoidal():
assert is_solenoidal(Vector.zero) is True
assert is_solenoidal(i) is True
assert is_solenoidal(2 * i + 3 * j + 4 * k) is True
assert (is_solenoidal(y*z*i + x*z*j + x*y*k) is
True)
assert is_solenoidal(y * j) is False
assert is_solenoidal(grad_field) is False
assert is_solenoidal(curl_field) is True
assert is_solenoidal((-2*y + 3)*k) is True
assert is_solenoidal(cos(q)*i + sin(q)*j + cos(q)*P.k) is True
assert is_solenoidal(z*P.i + P.x*k) is True
def test_directional_derivative():
assert directional_derivative(C.x*C.y*C.z, 3*C.i + 4*C.j + C.k) == C.x*C.y + 4*C.x*C.z + 3*C.y*C.z
assert directional_derivative(5*C.x**2*C.z, 3*C.i + 4*C.j + C.k) == 5*C.x**2 + 30*C.x*C.z
assert directional_derivative(5*C.x**2*C.z, 4*C.j) is S.Zero
D = CoordSys3D("D", "spherical", variable_names=["r", "theta", "phi"],
vector_names=["e_r", "e_theta", "e_phi"])
r, theta, phi = D.base_scalars()
e_r, e_theta, e_phi = D.base_vectors()
assert directional_derivative(r**2*e_r, e_r) == 2*r*e_r
assert directional_derivative(5*r**2*phi, 3*e_r + 4*e_theta + e_phi) == 5*r**2 + 30*r*phi
def test_scalar_potential():
assert scalar_potential(Vector.zero, C) == 0
assert scalar_potential(i, C) == x
assert scalar_potential(j, C) == y
assert scalar_potential(k, C) == z
assert scalar_potential(y*z*i + x*z*j + x*y*k, C) == x*y*z
assert scalar_potential(grad_field, C) == scalar_field
assert scalar_potential(z*P.i + P.x*k, C) == x*z*cos(q) + y*z*sin(q)
assert scalar_potential(z*P.i + P.x*k, P) == P.x*P.z
raises(ValueError, lambda: scalar_potential(x*j, C))
def test_scalar_potential_difference():
point1 = C.origin.locate_new('P1', 1*i + 2*j + 3*k)
point2 = C.origin.locate_new('P2', 4*i + 5*j + 6*k)
genericpointC = C.origin.locate_new('RP', x*i + y*j + z*k)
genericpointP = P.origin.locate_new('PP', P.x*P.i + P.y*P.j + P.z*P.k)
assert scalar_potential_difference(S.Zero, C, point1, point2) == 0
assert (scalar_potential_difference(scalar_field, C, C.origin,
genericpointC) ==
scalar_field)
assert (scalar_potential_difference(grad_field, C, C.origin,
genericpointC) ==
scalar_field)
assert scalar_potential_difference(grad_field, C, point1, point2) == 948
assert (scalar_potential_difference(y*z*i + x*z*j +
x*y*k, C, point1,
genericpointC) ==
x*y*z - 6)
potential_diff_P = (2*P.z*(P.x*sin(q) + P.y*cos(q))*
(P.x*cos(q) - P.y*sin(q))**2)
assert (scalar_potential_difference(grad_field, P, P.origin,
genericpointP).simplify() ==
potential_diff_P.simplify())
def test_differential_operators_curvilinear_system():
A = CoordSys3D('A', transformation="spherical", variable_names=["r", "theta", "phi"])
B = CoordSys3D('B', transformation='cylindrical', variable_names=["r", "theta", "z"])
# Test for spherical coordinate system and gradient
assert gradient(3*A.r + 4*A.theta) == 3*A.i + 4/A.r*A.j
assert gradient(3*A.r*A.phi + 4*A.theta) == 3*A.phi*A.i + 4/A.r*A.j + (3/sin(A.theta))*A.k
assert gradient(0*A.r + 0*A.theta+0*A.phi) == Vector.zero
assert gradient(A.r*A.theta*A.phi) == A.theta*A.phi*A.i + A.phi*A.j + (A.theta/sin(A.theta))*A.k
# Test for spherical coordinate system and divergence
assert divergence(A.r * A.i + A.theta * A.j + A.phi * A.k) == \
(sin(A.theta)*A.r + cos(A.theta)*A.r*A.theta)/(sin(A.theta)*A.r**2) + 3 + 1/(sin(A.theta)*A.r)
assert divergence(3*A.r*A.phi*A.i + A.theta*A.j + A.r*A.theta*A.phi*A.k) == \
(sin(A.theta)*A.r + cos(A.theta)*A.r*A.theta)/(sin(A.theta)*A.r**2) + 9*A.phi + A.theta/sin(A.theta)
assert divergence(Vector.zero) == 0
assert divergence(0*A.i + 0*A.j + 0*A.k) == 0
# Test for spherical coordinate system and curl
assert curl(A.r*A.i + A.theta*A.j + A.phi*A.k) == \
(cos(A.theta)*A.phi/(sin(A.theta)*A.r))*A.i + (-A.phi/A.r)*A.j + A.theta/A.r*A.k
assert curl(A.r*A.j + A.phi*A.k) == (cos(A.theta)*A.phi/(sin(A.theta)*A.r))*A.i + (-A.phi/A.r)*A.j + 2*A.k
# Test for cylindrical coordinate system and gradient
assert gradient(0*B.r + 0*B.theta+0*B.z) == Vector.zero
assert gradient(B.r*B.theta*B.z) == B.theta*B.z*B.i + B.z*B.j + B.r*B.theta*B.k
assert gradient(3*B.r) == 3*B.i
assert gradient(2*B.theta) == 2/B.r * B.j
assert gradient(4*B.z) == 4*B.k
# Test for cylindrical coordinate system and divergence
assert divergence(B.r*B.i + B.theta*B.j + B.z*B.k) == 3 + 1/B.r
assert divergence(B.r*B.j + B.z*B.k) == 1
# Test for cylindrical coordinate system and curl
assert curl(B.r*B.j + B.z*B.k) == 2*B.k
assert curl(3*B.i + 2/B.r*B.j + 4*B.k) == Vector.zero
def test_mixed_coordinates():
# gradient
a = CoordSys3D('a')
b = CoordSys3D('b')
c = CoordSys3D('c')
assert gradient(a.x*b.y) == b.y*a.i + a.x*b.j
assert gradient(3*cos(q)*a.x*b.x+a.y*(a.x+(cos(q)+b.x))) ==\
(a.y + 3*b.x*cos(q))*a.i + (a.x + b.x + cos(q))*a.j + (3*a.x*cos(q) + a.y)*b.i
# Some tests need further work:
# assert gradient(a.x*(cos(a.x+b.x))) == (cos(a.x + b.x))*a.i + a.x*Gradient(cos(a.x + b.x))
# assert gradient(cos(a.x + b.x)*cos(a.x + b.z)) == Gradient(cos(a.x + b.x)*cos(a.x + b.z))
assert gradient(a.x**b.y) == Gradient(a.x**b.y)
# assert gradient(cos(a.x+b.y)*a.z) == None
assert gradient(cos(a.x*b.y)) == Gradient(cos(a.x*b.y))
assert gradient(3*cos(q)*a.x*b.x*a.z*a.y+ b.y*b.z + cos(a.x+a.y)*b.z) == \
(3*a.y*a.z*b.x*cos(q) - b.z*sin(a.x + a.y))*a.i + \
(3*a.x*a.z*b.x*cos(q) - b.z*sin(a.x + a.y))*a.j + (3*a.x*a.y*b.x*cos(q))*a.k + \
(3*a.x*a.y*a.z*cos(q))*b.i + b.z*b.j + (b.y + cos(a.x + a.y))*b.k
# divergence
assert divergence(a.i*a.x+a.j*a.y+a.z*a.k + b.i*b.x+b.j*b.y+b.z*b.k + c.i*c.x+c.j*c.y+c.z*c.k) == S(9)
# assert divergence(3*a.i*a.x*cos(a.x+b.z) + a.j*b.x*c.z) == None
assert divergence(3*a.i*a.x*a.z + b.j*b.x*c.z + 3*a.j*a.z*a.y) == \
6*a.z + b.x*Dot(b.j, c.k)
assert divergence(3*cos(q)*a.x*b.x*b.i*c.x) == \
3*a.x*b.x*cos(q)*Dot(b.i, c.i) + 3*a.x*c.x*cos(q) + 3*b.x*c.x*cos(q)*Dot(b.i, a.i)
assert divergence(a.x*b.x*c.x*Cross(a.x*a.i, a.y*b.j)) ==\
a.x*b.x*c.x*Divergence(Cross(a.x*a.i, a.y*b.j)) + \
b.x*c.x*Dot(Cross(a.x*a.i, a.y*b.j), a.i) + \
a.x*c.x*Dot(Cross(a.x*a.i, a.y*b.j), b.i) + \
a.x*b.x*Dot(Cross(a.x*a.i, a.y*b.j), c.i)
assert divergence(a.x*b.x*c.x*(a.x*a.i + b.x*b.i)) == \
4*a.x*b.x*c.x +\
a.x**2*c.x*Dot(a.i, b.i) +\
a.x**2*b.x*Dot(a.i, c.i) +\
b.x**2*c.x*Dot(b.i, a.i) +\
a.x*b.x**2*Dot(b.i, c.i)
|
54b14ae2441cf11f9e5fad0287ac743bdb2d3c079ef35c5c5c95e0c55d19c694 | # -*- coding: utf-8 -*-
from sympy import Integral, latex, Function
from sympy import pretty as xpretty
from sympy.vector import CoordSys3D, Vector, express
from sympy.abc import a, b, c
from sympy.core.compatibility import u_decode as u
from sympy.testing.pytest import XFAIL
def pretty(expr):
"""ASCII pretty-printing"""
return xpretty(expr, use_unicode=False, wrap_line=False)
def upretty(expr):
"""Unicode pretty-printing"""
return xpretty(expr, use_unicode=True, wrap_line=False)
# Initialize the basic and tedious vector/dyadic expressions
# needed for testing.
# Some of the pretty forms shown denote how the expressions just
# above them should look with pretty printing.
N = CoordSys3D('N')
C = N.orient_new_axis('C', a, N.k) # type: ignore
v = []
d = []
v.append(Vector.zero)
v.append(N.i) # type: ignore
v.append(-N.i) # type: ignore
v.append(N.i + N.j) # type: ignore
v.append(a*N.i) # type: ignore
v.append(a*N.i - b*N.j) # type: ignore
v.append((a**2 + N.x)*N.i + N.k) # type: ignore
v.append((a**2 + b)*N.i + 3*(C.y - c)*N.k) # type: ignore
f = Function('f')
v.append(N.j - (Integral(f(b)) - C.x**2)*N.k) # type: ignore
upretty_v_8 = u(
"""\
⎛ 2 ⌠ ⎞ \n\
j_N + ⎜x_C - ⎮ f(b) db⎟ k_N\n\
⎝ ⌡ ⎠ \
""")
pretty_v_8 = u(
"""\
j_N + / / \\\n\
| 2 | |\n\
|x_C - | f(b) db|\n\
| | |\n\
\\ / / \
""")
v.append(N.i + C.k) # type: ignore
v.append(express(N.i, C)) # type: ignore
v.append((a**2 + b)*N.i + (Integral(f(b)))*N.k) # type: ignore
upretty_v_11 = u(
"""\
⎛ 2 ⎞ ⎛⌠ ⎞ \n\
⎝a + b⎠ i_N + ⎜⎮ f(b) db⎟ k_N\n\
⎝⌡ ⎠ \
""")
pretty_v_11 = u(
"""\
/ 2 \\ + / / \\\n\
\\a + b/ i_N| | |\n\
| | f(b) db|\n\
| | |\n\
\\/ / \
""")
for x in v:
d.append(x | N.k) # type: ignore
s = 3*N.x**2*C.y # type: ignore
upretty_s = u(
"""\
2\n\
3⋅y_C⋅x_N \
""")
pretty_s = u(
"""\
2\n\
3*y_C*x_N \
""")
# This is the pretty form for ((a**2 + b)*N.i + 3*(C.y - c)*N.k) | N.k
upretty_d_7 = u(
"""\
⎛ 2 ⎞ \n\
⎝a + b⎠ (i_N|k_N) + (3⋅y_C - 3⋅c) (k_N|k_N)\
""")
pretty_d_7 = u(
"""\
/ 2 \\ (i_N|k_N) + (3*y_C - 3*c) (k_N|k_N)\n\
\\a + b/ \
""")
def test_str_printing():
assert str(v[0]) == '0'
assert str(v[1]) == 'N.i'
assert str(v[2]) == '(-1)*N.i'
assert str(v[3]) == 'N.i + N.j'
assert str(v[8]) == 'N.j + (C.x**2 - Integral(f(b), b))*N.k'
assert str(v[9]) == 'C.k + N.i'
assert str(s) == '3*C.y*N.x**2'
assert str(d[0]) == '0'
assert str(d[1]) == '(N.i|N.k)'
assert str(d[4]) == 'a*(N.i|N.k)'
assert str(d[5]) == 'a*(N.i|N.k) + (-b)*(N.j|N.k)'
assert str(d[8]) == ('(N.j|N.k) + (C.x**2 - ' +
'Integral(f(b), b))*(N.k|N.k)')
@XFAIL
def test_pretty_printing_ascii():
assert pretty(v[0]) == '0'
assert pretty(v[1]) == 'i_N'
assert pretty(v[5]) == '(a) i_N + (-b) j_N'
assert pretty(v[8]) == pretty_v_8
assert pretty(v[2]) == '(-1) i_N'
assert pretty(v[11]) == pretty_v_11
assert pretty(s) == pretty_s
assert pretty(d[0]) == '(0|0)'
assert pretty(d[5]) == '(a) (i_N|k_N) + (-b) (j_N|k_N)'
assert pretty(d[7]) == pretty_d_7
assert pretty(d[10]) == '(cos(a)) (i_C|k_N) + (-sin(a)) (j_C|k_N)'
def test_pretty_print_unicode_v():
assert upretty(v[0]) == '0'
assert upretty(v[1]) == 'i_N'
assert upretty(v[5]) == '(a) i_N + (-b) j_N'
# Make sure the printing works in other objects
assert upretty(v[5].args) == '((a) i_N, (-b) j_N)'
assert upretty(v[8]) == upretty_v_8
assert upretty(v[2]) == '(-1) i_N'
assert upretty(v[11]) == upretty_v_11
assert upretty(s) == upretty_s
assert upretty(d[0]) == '(0|0)'
assert upretty(d[5]) == '(a) (i_N|k_N) + (-b) (j_N|k_N)'
assert upretty(d[7]) == upretty_d_7
assert upretty(d[10]) == '(cos(a)) (i_C|k_N) + (-sin(a)) (j_C|k_N)'
def test_latex_printing():
assert latex(v[0]) == '\\mathbf{\\hat{0}}'
assert latex(v[1]) == '\\mathbf{\\hat{i}_{N}}'
assert latex(v[2]) == '- \\mathbf{\\hat{i}_{N}}'
assert latex(v[5]) == ('(a)\\mathbf{\\hat{i}_{N}} + ' +
'(- b)\\mathbf{\\hat{j}_{N}}')
assert latex(v[6]) == ('(\\mathbf{{x}_{N}} + a^{2})\\mathbf{\\hat{i}_' +
'{N}} + \\mathbf{\\hat{k}_{N}}')
assert latex(v[8]) == ('\\mathbf{\\hat{j}_{N}} + (\\mathbf{{x}_' +
'{C}}^{2} - \\int f{\\left(b \\right)}\\,' +
' db)\\mathbf{\\hat{k}_{N}}')
assert latex(s) == '3 \\mathbf{{y}_{C}} \\mathbf{{x}_{N}}^{2}'
assert latex(d[0]) == '(\\mathbf{\\hat{0}}|\\mathbf{\\hat{0}})'
assert latex(d[4]) == ('(a)(\\mathbf{\\hat{i}_{N}}{|}\\mathbf' +
'{\\hat{k}_{N}})')
assert latex(d[9]) == ('(\\mathbf{\\hat{k}_{C}}{|}\\mathbf{\\' +
'hat{k}_{N}}) + (\\mathbf{\\hat{i}_{N}}{|' +
'}\\mathbf{\\hat{k}_{N}})')
assert latex(d[11]) == ('(a^{2} + b)(\\mathbf{\\hat{i}_{N}}{|}\\' +
'mathbf{\\hat{k}_{N}}) + (\\int f{\\left(' +
'b \\right)}\\, db)(\\mathbf{\\hat{k}_{N}' +
'}{|}\\mathbf{\\hat{k}_{N}})')
def test_custom_names():
A = CoordSys3D('A', vector_names=['x', 'y', 'z'],
variable_names=['i', 'j', 'k'])
assert A.i.__str__() == 'A.i'
assert A.x.__str__() == 'A.x'
assert A.i._pretty_form == 'i_A'
assert A.x._pretty_form == 'x_A'
assert A.i._latex_form == r'\mathbf{{i}_{A}}'
assert A.x._latex_form == r"\mathbf{\hat{x}_{A}}"
|
c75fd3bb7271cf9518ec7e984f6fcaad5e8c37a1ccea56ed80259bf8f1575b8c | from sympy import (Eq, Rational, Float, S, Symbol, cos, oo, pi, simplify,
sin, sqrt, symbols, acos)
from sympy.functions.elementary.trigonometric import tan
from sympy.geometry import (Circle, GeometryError, Line, Point, Ray,
Segment, Triangle, intersection, Point3D, Line3D, Ray3D, Segment3D,
Point2D, Line2D)
from sympy.geometry.line import Undecidable
from sympy.geometry.polygon import _asa as asa
from sympy.utilities.iterables import cartes
from sympy.testing.pytest import raises, warns
x = Symbol('x', real=True)
y = Symbol('y', real=True)
z = Symbol('z', real=True)
k = Symbol('k', real=True)
x1 = Symbol('x1', real=True)
y1 = Symbol('y1', real=True)
t = Symbol('t', real=True)
a, b = symbols('a,b', real=True)
m = symbols('m', real=True)
def test_object_from_equation():
from sympy.abc import x, y, a, b
assert Line(3*x + y + 18) == Line2D(Point2D(0, -18), Point2D(1, -21))
assert Line(3*x + 5 * y + 1) == Line2D(Point2D(0, Rational(-1, 5)), Point2D(1, Rational(-4, 5)))
assert Line(3*a + b + 18, x='a', y='b') == Line2D(Point2D(0, -18), Point2D(1, -21))
assert Line(3*x + y) == Line2D(Point2D(0, 0), Point2D(1, -3))
assert Line(x + y) == Line2D(Point2D(0, 0), Point2D(1, -1))
assert Line(Eq(3*a + b, -18), x='a', y=b) == Line2D(Point2D(0, -18), Point2D(1, -21))
raises(ValueError, lambda: Line(x))
raises(ValueError, lambda: Line(y))
raises(ValueError, lambda: Line(x/y))
raises(ValueError, lambda: Line(a/b, x='a', y='b'))
raises(ValueError, lambda: Line(y/x))
raises(ValueError, lambda: Line(b/a, x='a', y='b'))
raises(ValueError, lambda: Line((x + 1)**2 + y))
def feq(a, b):
"""Test if two floating point values are 'equal'."""
t_float = Float("1.0E-10")
return -t_float < a - b < t_float
def test_angle_between():
a = Point(1, 2, 3, 4)
b = a.orthogonal_direction
o = a.origin
assert feq(Line.angle_between(Line(Point(0, 0), Point(1, 1)),
Line(Point(0, 0), Point(5, 0))).evalf(), pi.evalf() / 4)
assert Line(a, o).angle_between(Line(b, o)) == pi / 2
assert Line3D.angle_between(Line3D(Point3D(0, 0, 0), Point3D(1, 1, 1)),
Line3D(Point3D(0, 0, 0), Point3D(5, 0, 0))) == acos(sqrt(3) / 3)
def test_closing_angle():
a = Ray((0, 0), angle=0)
b = Ray((1, 2), angle=pi/2)
assert a.closing_angle(b) == -pi/2
assert b.closing_angle(a) == pi/2
assert a.closing_angle(a) == 0
def test_smallest_angle():
a = Line(Point(1, 1), Point(1, 2))
b = Line(Point(1, 1),Point(2, 3))
assert a.smallest_angle_between(b) == acos(2*sqrt(5)/5)
def test_svg():
a = Line(Point(1, 1),Point(1, 2))
assert a._svg() == '<path fill-rule="evenodd" fill="#66cc99" stroke="#555555" stroke-width="2.0" opacity="0.6" d="M 1.00000000000000,1.00000000000000 L 1.00000000000000,2.00000000000000" marker-start="url(#markerReverseArrow)" marker-end="url(#markerArrow)"/>'
a = Segment(Point(1, 0),Point(1, 1))
assert a._svg() == '<path fill-rule="evenodd" fill="#66cc99" stroke="#555555" stroke-width="2.0" opacity="0.6" d="M 1.00000000000000,0 L 1.00000000000000,1.00000000000000" />'
a = Ray(Point(2, 3), Point(3, 5))
assert a._svg() == '<path fill-rule="evenodd" fill="#66cc99" stroke="#555555" stroke-width="2.0" opacity="0.6" d="M 2.00000000000000,3.00000000000000 L 3.00000000000000,5.00000000000000" marker-start="url(#markerCircle)" marker-end="url(#markerArrow)"/>'
def test_arbitrary_point():
l1 = Line3D(Point3D(0, 0, 0), Point3D(1, 1, 1))
l2 = Line(Point(x1, x1), Point(y1, y1))
assert l2.arbitrary_point() in l2
assert Ray((1, 1), angle=pi / 4).arbitrary_point() == \
Point(t + 1, t + 1)
assert Segment((1, 1), (2, 3)).arbitrary_point() == Point(1 + t, 1 + 2 * t)
assert l1.perpendicular_segment(l1.arbitrary_point()) == l1.arbitrary_point()
assert Ray3D((1, 1, 1), direction_ratio=[1, 2, 3]).arbitrary_point() == \
Point3D(t + 1, 2 * t + 1, 3 * t + 1)
assert Segment3D(Point3D(0, 0, 0), Point3D(1, 1, 1)).midpoint == \
Point3D(S.Half, S.Half, S.Half)
assert Segment3D(Point3D(x1, x1, x1), Point3D(y1, y1, y1)).length == sqrt(3) * sqrt((x1 - y1) ** 2)
assert Segment3D((1, 1, 1), (2, 3, 4)).arbitrary_point() == \
Point3D(t + 1, 2 * t + 1, 3 * t + 1)
raises(ValueError, (lambda: Line((x, 1), (2, 3)).arbitrary_point(x)))
def test_are_concurrent_2d():
l1 = Line(Point(0, 0), Point(1, 1))
l2 = Line(Point(x1, x1), Point(x1, 1 + x1))
assert Line.are_concurrent(l1) is False
assert Line.are_concurrent(l1, l2)
assert Line.are_concurrent(l1, l1, l1, l2)
assert Line.are_concurrent(l1, l2, Line(Point(5, x1), Point(Rational(-3, 5), x1)))
assert Line.are_concurrent(l1, Line(Point(0, 0), Point(-x1, x1)), l2) is False
def test_are_concurrent_3d():
p1 = Point3D(0, 0, 0)
l1 = Line(p1, Point3D(1, 1, 1))
parallel_1 = Line3D(Point3D(0, 0, 0), Point3D(1, 0, 0))
parallel_2 = Line3D(Point3D(0, 1, 0), Point3D(1, 1, 0))
assert Line3D.are_concurrent(l1) is False
assert Line3D.are_concurrent(l1, Line(Point3D(x1, x1, x1), Point3D(y1, y1, y1))) is False
assert Line3D.are_concurrent(l1, Line3D(p1, Point3D(x1, x1, x1)),
Line(Point3D(x1, x1, x1), Point3D(x1, 1 + x1, 1))) is True
assert Line3D.are_concurrent(parallel_1, parallel_2) is False
def test_arguments():
"""Functions accepting `Point` objects in `geometry`
should also accept tuples, lists, and generators and
automatically convert them to points."""
from sympy import subsets
singles2d = ((1, 2), [1, 3], Point(1, 5))
doubles2d = subsets(singles2d, 2)
l2d = Line(Point2D(1, 2), Point2D(2, 3))
singles3d = ((1, 2, 3), [1, 2, 4], Point(1, 2, 6))
doubles3d = subsets(singles3d, 2)
l3d = Line(Point3D(1, 2, 3), Point3D(1, 1, 2))
singles4d = ((1, 2, 3, 4), [1, 2, 3, 5], Point(1, 2, 3, 7))
doubles4d = subsets(singles4d, 2)
l4d = Line(Point(1, 2, 3, 4), Point(2, 2, 2, 2))
# test 2D
test_single = ['contains', 'distance', 'equals', 'parallel_line', 'perpendicular_line', 'perpendicular_segment',
'projection', 'intersection']
for p in doubles2d:
Line2D(*p)
for func in test_single:
for p in singles2d:
getattr(l2d, func)(p)
# test 3D
for p in doubles3d:
Line3D(*p)
for func in test_single:
for p in singles3d:
getattr(l3d, func)(p)
# test 4D
for p in doubles4d:
Line(*p)
for func in test_single:
for p in singles4d:
getattr(l4d, func)(p)
def test_basic_properties_2d():
p1 = Point(0, 0)
p2 = Point(1, 1)
p10 = Point(2000, 2000)
p_r3 = Ray(p1, p2).random_point()
p_r4 = Ray(p2, p1).random_point()
l1 = Line(p1, p2)
l3 = Line(Point(x1, x1), Point(x1, 1 + x1))
l4 = Line(p1, Point(1, 0))
r1 = Ray(p1, Point(0, 1))
r2 = Ray(Point(0, 1), p1)
s1 = Segment(p1, p10)
p_s1 = s1.random_point()
assert Line((1, 1), slope=1) == Line((1, 1), (2, 2))
assert Line((1, 1), slope=oo) == Line((1, 1), (1, 2))
assert Line((1, 1), slope=oo).bounds == (1, 1, 1, 2)
assert Line((1, 1), slope=-oo) == Line((1, 1), (1, 2))
assert Line(p1, p2).scale(2, 1) == Line(p1, Point(2, 1))
assert Line(p1, p2) == Line(p1, p2)
assert Line(p1, p2) != Line(p2, p1)
assert l1 != Line(Point(x1, x1), Point(y1, y1))
assert l1 != l3
assert Line(p1, p10) != Line(p10, p1)
assert Line(p1, p10) != p1
assert p1 in l1 # is p1 on the line l1?
assert p1 not in l3
assert s1 in Line(p1, p10)
assert Ray(Point(0, 0), Point(0, 1)) in Ray(Point(0, 0), Point(0, 2))
assert Ray(Point(0, 0), Point(0, 2)) in Ray(Point(0, 0), Point(0, 1))
assert Ray(Point(0, 0), Point(0, 2)).xdirection == S.Zero
assert Ray(Point(0, 0), Point(1, 2)).xdirection == S.Infinity
assert Ray(Point(0, 0), Point(-1, 2)).xdirection == S.NegativeInfinity
assert Ray(Point(0, 0), Point(2, 0)).ydirection == S.Zero
assert Ray(Point(0, 0), Point(2, 2)).ydirection == S.Infinity
assert Ray(Point(0, 0), Point(2, -2)).ydirection == S.NegativeInfinity
assert (r1 in s1) is False
assert Segment(p1, p2) in s1
assert Ray(Point(x1, x1), Point(x1, 1 + x1)) != Ray(p1, Point(-1, 5))
assert Segment(p1, p2).midpoint == Point(S.Half, S.Half)
assert Segment(p1, Point(-x1, x1)).length == sqrt(2 * (x1 ** 2))
assert l1.slope == 1
assert l3.slope is oo
assert l4.slope == 0
assert Line(p1, Point(0, 1)).slope is oo
assert Line(r1.source, r1.random_point()).slope == r1.slope
assert Line(r2.source, r2.random_point()).slope == r2.slope
assert Segment(Point(0, -1), Segment(p1, Point(0, 1)).random_point()).slope == Segment(p1, Point(0, 1)).slope
assert l4.coefficients == (0, 1, 0)
assert Line((-x, x), (-x + 1, x - 1)).coefficients == (1, 1, 0)
assert Line(p1, Point(0, 1)).coefficients == (1, 0, 0)
# issue 7963
r = Ray((0, 0), angle=x)
assert r.subs(x, 3 * pi / 4) == Ray((0, 0), (-1, 1))
assert r.subs(x, 5 * pi / 4) == Ray((0, 0), (-1, -1))
assert r.subs(x, -pi / 4) == Ray((0, 0), (1, -1))
assert r.subs(x, pi / 2) == Ray((0, 0), (0, 1))
assert r.subs(x, -pi / 2) == Ray((0, 0), (0, -1))
for ind in range(0, 5):
assert l3.random_point() in l3
assert p_r3.x >= p1.x and p_r3.y >= p1.y
assert p_r4.x <= p2.x and p_r4.y <= p2.y
assert p1.x <= p_s1.x <= p10.x and p1.y <= p_s1.y <= p10.y
assert hash(s1) != hash(Segment(p10, p1))
assert s1.plot_interval() == [t, 0, 1]
assert Line(p1, p10).plot_interval() == [t, -5, 5]
assert Ray((0, 0), angle=pi / 4).plot_interval() == [t, 0, 10]
def test_basic_properties_3d():
p1 = Point3D(0, 0, 0)
p2 = Point3D(1, 1, 1)
p3 = Point3D(x1, x1, x1)
p5 = Point3D(x1, 1 + x1, 1)
l1 = Line3D(p1, p2)
l3 = Line3D(p3, p5)
r1 = Ray3D(p1, Point3D(-1, 5, 0))
r3 = Ray3D(p1, p2)
s1 = Segment3D(p1, p2)
assert Line3D((1, 1, 1), direction_ratio=[2, 3, 4]) == Line3D(Point3D(1, 1, 1), Point3D(3, 4, 5))
assert Line3D((1, 1, 1), direction_ratio=[1, 5, 7]) == Line3D(Point3D(1, 1, 1), Point3D(2, 6, 8))
assert Line3D((1, 1, 1), direction_ratio=[1, 2, 3]) == Line3D(Point3D(1, 1, 1), Point3D(2, 3, 4))
assert Line3D(Point3D(0, 0, 0), Point3D(1, 0, 0)).direction_cosine == [1, 0, 0]
assert Line3D(Line3D(p1, Point3D(0, 1, 0))) == Line3D(p1, Point3D(0, 1, 0))
assert Ray3D(Line3D(Point3D(0, 0, 0), Point3D(1, 0, 0))) == Ray3D(p1, Point3D(1, 0, 0))
assert Line3D(p1, p2) != Line3D(p2, p1)
assert l1 != l3
assert l1 != Line3D(p3, Point3D(y1, y1, y1))
assert r3 != r1
assert Ray3D(Point3D(0, 0, 0), Point3D(1, 1, 1)) in Ray3D(Point3D(0, 0, 0), Point3D(2, 2, 2))
assert Ray3D(Point3D(0, 0, 0), Point3D(2, 2, 2)) in Ray3D(Point3D(0, 0, 0), Point3D(1, 1, 1))
assert Ray3D(Point3D(0, 0, 0), Point3D(2, 2, 2)).xdirection == S.Infinity
assert Ray3D(Point3D(0, 0, 0), Point3D(2, 2, 2)).ydirection == S.Infinity
assert Ray3D(Point3D(0, 0, 0), Point3D(2, 2, 2)).zdirection == S.Infinity
assert Ray3D(Point3D(0, 0, 0), Point3D(-2, 2, 2)).xdirection == S.NegativeInfinity
assert Ray3D(Point3D(0, 0, 0), Point3D(2, -2, 2)).ydirection == S.NegativeInfinity
assert Ray3D(Point3D(0, 0, 0), Point3D(2, 2, -2)).zdirection == S.NegativeInfinity
assert Ray3D(Point3D(0, 0, 0), Point3D(0, 2, 2)).xdirection == S.Zero
assert Ray3D(Point3D(0, 0, 0), Point3D(2, 0, 2)).ydirection == S.Zero
assert Ray3D(Point3D(0, 0, 0), Point3D(2, 2, 0)).zdirection == S.Zero
assert p1 in l1
assert p1 not in l3
assert l1.direction_ratio == [1, 1, 1]
assert s1.midpoint == Point3D(S.Half, S.Half, S.Half)
# Test zdirection
assert Ray3D(p1, Point3D(0, 0, -1)).zdirection is S.NegativeInfinity
def test_contains():
p1 = Point(0, 0)
r = Ray(p1, Point(4, 4))
r1 = Ray3D(p1, Point3D(0, 0, -1))
r2 = Ray3D(p1, Point3D(0, 1, 0))
r3 = Ray3D(p1, Point3D(0, 0, 1))
l = Line(Point(0, 1), Point(3, 4))
# Segment contains
assert Point(0, (a + b) / 2) in Segment((0, a), (0, b))
assert Point((a + b) / 2, 0) in Segment((a, 0), (b, 0))
assert Point3D(0, 1, 0) in Segment3D((0, 1, 0), (0, 1, 0))
assert Point3D(1, 0, 0) in Segment3D((1, 0, 0), (1, 0, 0))
assert Segment3D(Point3D(0, 0, 0), Point3D(1, 0, 0)).contains([]) is True
assert Segment3D(Point3D(0, 0, 0), Point3D(1, 0, 0)).contains(
Segment3D(Point3D(2, 2, 2), Point3D(3, 2, 2))) is False
# Line contains
assert l.contains(Point(0, 1)) is True
assert l.contains((0, 1)) is True
assert l.contains((0, 0)) is False
# Ray contains
assert r.contains(p1) is True
assert r.contains((1, 1)) is True
assert r.contains((1, 3)) is False
assert r.contains(Segment((1, 1), (2, 2))) is True
assert r.contains(Segment((1, 2), (2, 5))) is False
assert r.contains(Ray((2, 2), (3, 3))) is True
assert r.contains(Ray((2, 2), (3, 5))) is False
assert r1.contains(Segment3D(p1, Point3D(0, 0, -10))) is True
assert r1.contains(Segment3D(Point3D(1, 1, 1), Point3D(2, 2, 2))) is False
assert r2.contains(Point3D(0, 0, 0)) is True
assert r3.contains(Point3D(0, 0, 0)) is True
assert Ray3D(Point3D(1, 1, 1), Point3D(1, 0, 0)).contains([]) is False
assert Line3D((0, 0, 0), (x, y, z)).contains((2 * x, 2 * y, 2 * z))
with warns(UserWarning):
assert Line3D(p1, Point3D(0, 1, 0)).contains(Point(1.0, 1.0)) is False
with warns(UserWarning):
assert r3.contains(Point(1.0, 1.0)) is False
def test_contains_nonreal_symbols():
u, v, w, z = symbols('u, v, w, z')
l = Segment(Point(u, w), Point(v, z))
p = Point(u*Rational(2, 3) + v/3, w*Rational(2, 3) + z/3)
assert l.contains(p)
def test_distance_2d():
p1 = Point(0, 0)
p2 = Point(1, 1)
half = S.Half
s1 = Segment(Point(0, 0), Point(1, 1))
s2 = Segment(Point(half, half), Point(1, 0))
r = Ray(p1, p2)
assert s1.distance(Point(0, 0)) == 0
assert s1.distance((0, 0)) == 0
assert s2.distance(Point(0, 0)) == 2 ** half / 2
assert s2.distance(Point(Rational(3) / 2, Rational(3) / 2)) == 2 ** half
assert Line(p1, p2).distance(Point(-1, 1)) == sqrt(2)
assert Line(p1, p2).distance(Point(1, -1)) == sqrt(2)
assert Line(p1, p2).distance(Point(2, 2)) == 0
assert Line(p1, p2).distance((-1, 1)) == sqrt(2)
assert Line((0, 0), (0, 1)).distance(p1) == 0
assert Line((0, 0), (0, 1)).distance(p2) == 1
assert Line((0, 0), (1, 0)).distance(p1) == 0
assert Line((0, 0), (1, 0)).distance(p2) == 1
assert r.distance(Point(-1, -1)) == sqrt(2)
assert r.distance(Point(1, 1)) == 0
assert r.distance(Point(-1, 1)) == sqrt(2)
assert Ray((1, 1), (2, 2)).distance(Point(1.5, 3)) == 3 * sqrt(2) / 4
assert r.distance((1, 1)) == 0
def test_dimension_normalization():
with warns(UserWarning):
assert Ray((1, 1), (2, 1, 2)) == Ray((1, 1, 0), (2, 1, 2))
def test_distance_3d():
p1, p2 = Point3D(0, 0, 0), Point3D(1, 1, 1)
p3 = Point3D(Rational(3) / 2, Rational(3) / 2, Rational(3) / 2)
s1 = Segment3D(Point3D(0, 0, 0), Point3D(1, 1, 1))
s2 = Segment3D(Point3D(S.Half, S.Half, S.Half), Point3D(1, 0, 1))
r = Ray3D(p1, p2)
assert s1.distance(p1) == 0
assert s2.distance(p1) == sqrt(3) / 2
assert s2.distance(p3) == 2 * sqrt(6) / 3
assert s1.distance((0, 0, 0)) == 0
assert s2.distance((0, 0, 0)) == sqrt(3) / 2
assert s1.distance(p1) == 0
assert s2.distance(p1) == sqrt(3) / 2
assert s2.distance(p3) == 2 * sqrt(6) / 3
assert s1.distance((0, 0, 0)) == 0
assert s2.distance((0, 0, 0)) == sqrt(3) / 2
# Line to point
assert Line3D(p1, p2).distance(Point3D(-1, 1, 1)) == 2 * sqrt(6) / 3
assert Line3D(p1, p2).distance(Point3D(1, -1, 1)) == 2 * sqrt(6) / 3
assert Line3D(p1, p2).distance(Point3D(2, 2, 2)) == 0
assert Line3D(p1, p2).distance((2, 2, 2)) == 0
assert Line3D(p1, p2).distance((1, -1, 1)) == 2 * sqrt(6) / 3
assert Line3D((0, 0, 0), (0, 1, 0)).distance(p1) == 0
assert Line3D((0, 0, 0), (0, 1, 0)).distance(p2) == sqrt(2)
assert Line3D((0, 0, 0), (1, 0, 0)).distance(p1) == 0
assert Line3D((0, 0, 0), (1, 0, 0)).distance(p2) == sqrt(2)
# Ray to point
assert r.distance(Point3D(-1, -1, -1)) == sqrt(3)
assert r.distance(Point3D(1, 1, 1)) == 0
assert r.distance((-1, -1, -1)) == sqrt(3)
assert r.distance((1, 1, 1)) == 0
assert Ray3D((0, 0, 0), (1, 1, 2)).distance((-1, -1, 2)) == 4 * sqrt(3) / 3
assert Ray3D((1, 1, 1), (2, 2, 2)).distance(Point3D(1.5, -3, -1)) == Rational(9) / 2
assert Ray3D((1, 1, 1), (2, 2, 2)).distance(Point3D(1.5, 3, 1)) == sqrt(78) / 6
def test_equals():
p1 = Point(0, 0)
p2 = Point(1, 1)
l1 = Line(p1, p2)
l2 = Line((0, 5), slope=m)
l3 = Line(Point(x1, x1), Point(x1, 1 + x1))
assert l1.perpendicular_line(p1.args).equals(Line(Point(0, 0), Point(1, -1)))
assert l1.perpendicular_line(p1).equals(Line(Point(0, 0), Point(1, -1)))
assert Line(Point(x1, x1), Point(y1, y1)).parallel_line(Point(-x1, x1)). \
equals(Line(Point(-x1, x1), Point(-y1, 2 * x1 - y1)))
assert l3.parallel_line(p1.args).equals(Line(Point(0, 0), Point(0, -1)))
assert l3.parallel_line(p1).equals(Line(Point(0, 0), Point(0, -1)))
assert (l2.distance(Point(2, 3)) - 2 * abs(m + 1) / sqrt(m ** 2 + 1)).equals(0)
assert Line3D(p1, Point3D(0, 1, 0)).equals(Point(1.0, 1.0)) is False
assert Line3D(Point3D(0, 0, 0), Point3D(1, 0, 0)).equals(Line3D(Point3D(-5, 0, 0), Point3D(-1, 0, 0))) is True
assert Line3D(Point3D(0, 0, 0), Point3D(1, 0, 0)).equals(Line3D(p1, Point3D(0, 1, 0))) is False
assert Ray3D(p1, Point3D(0, 0, -1)).equals(Point(1.0, 1.0)) is False
assert Ray3D(p1, Point3D(0, 0, -1)).equals(Ray3D(p1, Point3D(0, 0, -1))) is True
assert Line3D((0, 0), (t, t)).perpendicular_line(Point(0, 1, 0)).equals(
Line3D(Point3D(0, 1, 0), Point3D(S.Half, S.Half, 0)))
assert Line3D((0, 0), (t, t)).perpendicular_segment(Point(0, 1, 0)).equals(Segment3D((0, 1), (S.Half, S.Half)))
assert Line3D(p1, Point3D(0, 1, 0)).equals(Point(1.0, 1.0)) is False
def test_equation():
p1 = Point(0, 0)
p2 = Point(1, 1)
l1 = Line(p1, p2)
l3 = Line(Point(x1, x1), Point(x1, 1 + x1))
assert simplify(l1.equation()) in (x - y, y - x)
assert simplify(l3.equation()) in (x - x1, x1 - x)
assert simplify(l1.equation()) in (x - y, y - x)
assert simplify(l3.equation()) in (x - x1, x1 - x)
assert Line(p1, Point(1, 0)).equation(x=x, y=y) == y
assert Line(p1, Point(0, 1)).equation() == x
assert Line(Point(2, 0), Point(2, 1)).equation() == x - 2
assert Line(p2, Point(2, 1)).equation() == y - 1
assert Line3D(Point(x1, x1, x1), Point(y1, y1, y1)
).equation() == (-x + y, -x + z)
assert Line3D(Point(1, 2, 3), Point(2, 3, 4)
).equation() == (-x + y - 1, -x + z - 2)
assert Line3D(Point(1, 2, 3), Point(1, 3, 4)
).equation() == (x - 1, -y + z - 1)
assert Line3D(Point(1, 2, 3), Point(2, 2, 4)
).equation() == (y - 2, -x + z - 2)
assert Line3D(Point(1, 2, 3), Point(2, 3, 3)
).equation() == (-x + y - 1, z - 3)
assert Line3D(Point(1, 2, 3), Point(1, 2, 4)
).equation() == (x - 1, y - 2)
assert Line3D(Point(1, 2, 3), Point(1, 3, 3)
).equation() == (x - 1, z - 3)
assert Line3D(Point(1, 2, 3), Point(2, 2, 3)
).equation() == (y - 2, z - 3)
def test_intersection_2d():
p1 = Point(0, 0)
p2 = Point(1, 1)
p3 = Point(x1, x1)
p4 = Point(y1, y1)
l1 = Line(p1, p2)
l3 = Line(Point(0, 0), Point(3, 4))
r1 = Ray(Point(1, 1), Point(2, 2))
r2 = Ray(Point(0, 0), Point(3, 4))
r4 = Ray(p1, p2)
r6 = Ray(Point(0, 1), Point(1, 2))
r7 = Ray(Point(0.5, 0.5), Point(1, 1))
s1 = Segment(p1, p2)
s2 = Segment(Point(0.25, 0.25), Point(0.5, 0.5))
s3 = Segment(Point(0, 0), Point(3, 4))
assert intersection(l1, p1) == [p1]
assert intersection(l1, Point(x1, 1 + x1)) == []
assert intersection(l1, Line(p3, p4)) in [[l1], [Line(p3, p4)]]
assert intersection(l1, l1.parallel_line(Point(x1, 1 + x1))) == []
assert intersection(l3, l3) == [l3]
assert intersection(l3, r2) == [r2]
assert intersection(l3, s3) == [s3]
assert intersection(s3, l3) == [s3]
assert intersection(Segment(Point(-10, 10), Point(10, 10)), Segment(Point(-5, -5), Point(-5, 5))) == []
assert intersection(r2, l3) == [r2]
assert intersection(r1, Ray(Point(2, 2), Point(0, 0))) == [Segment(Point(1, 1), Point(2, 2))]
assert intersection(r1, Ray(Point(1, 1), Point(-1, -1))) == [Point(1, 1)]
assert intersection(r1, Segment(Point(0, 0), Point(2, 2))) == [Segment(Point(1, 1), Point(2, 2))]
assert r4.intersection(s2) == [s2]
assert r4.intersection(Segment(Point(2, 3), Point(3, 4))) == []
assert r4.intersection(Segment(Point(-1, -1), Point(0.5, 0.5))) == [Segment(p1, Point(0.5, 0.5))]
assert r4.intersection(Ray(p2, p1)) == [s1]
assert Ray(p2, p1).intersection(r6) == []
assert r4.intersection(r7) == r7.intersection(r4) == [r7]
assert Ray3D((0, 0), (3, 0)).intersection(Ray3D((1, 0), (3, 0))) == [Ray3D((1, 0), (3, 0))]
assert Ray3D((1, 0), (3, 0)).intersection(Ray3D((0, 0), (3, 0))) == [Ray3D((1, 0), (3, 0))]
assert Ray(Point(0, 0), Point(0, 4)).intersection(Ray(Point(0, 1), Point(0, -1))) == \
[Segment(Point(0, 0), Point(0, 1))]
assert Segment3D((0, 0), (3, 0)).intersection(
Segment3D((1, 0), (2, 0))) == [Segment3D((1, 0), (2, 0))]
assert Segment3D((1, 0), (2, 0)).intersection(
Segment3D((0, 0), (3, 0))) == [Segment3D((1, 0), (2, 0))]
assert Segment3D((0, 0), (3, 0)).intersection(
Segment3D((3, 0), (4, 0))) == [Point3D((3, 0))]
assert Segment3D((0, 0), (3, 0)).intersection(
Segment3D((2, 0), (5, 0))) == [Segment3D((2, 0), (3, 0))]
assert Segment3D((0, 0), (3, 0)).intersection(
Segment3D((-2, 0), (1, 0))) == [Segment3D((0, 0), (1, 0))]
assert Segment3D((0, 0), (3, 0)).intersection(
Segment3D((-2, 0), (0, 0))) == [Point3D(0, 0)]
assert s1.intersection(Segment(Point(1, 1), Point(2, 2))) == [Point(1, 1)]
assert s1.intersection(Segment(Point(0.5, 0.5), Point(1.5, 1.5))) == [Segment(Point(0.5, 0.5), p2)]
assert s1.intersection(Segment(Point(4, 4), Point(5, 5))) == []
assert s1.intersection(Segment(Point(-1, -1), p1)) == [p1]
assert s1.intersection(Segment(Point(-1, -1), Point(0.5, 0.5))) == [Segment(p1, Point(0.5, 0.5))]
assert s1.intersection(Line(Point(1, 0), Point(2, 1))) == []
assert s1.intersection(s2) == [s2]
assert s2.intersection(s1) == [s2]
assert asa(120, 8, 52) == \
Triangle(
Point(0, 0),
Point(8, 0),
Point(-4 * cos(19 * pi / 90) / sin(2 * pi / 45),
4 * sqrt(3) * cos(19 * pi / 90) / sin(2 * pi / 45)))
assert Line((0, 0), (1, 1)).intersection(Ray((1, 0), (1, 2))) == [Point(1, 1)]
assert Line((0, 0), (1, 1)).intersection(Segment((1, 0), (1, 2))) == [Point(1, 1)]
assert Ray((0, 0), (1, 1)).intersection(Ray((1, 0), (1, 2))) == [Point(1, 1)]
assert Ray((0, 0), (1, 1)).intersection(Segment((1, 0), (1, 2))) == [Point(1, 1)]
assert Ray((0, 0), (10, 10)).contains(Segment((1, 1), (2, 2))) is True
assert Segment((1, 1), (2, 2)) in Line((0, 0), (10, 10))
assert s1.intersection(Ray((1, 1), (4, 4))) == [Point(1, 1)]
# This test is disabled because it hangs after rref changes which simplify
# intermediate results and return a different representation from when the
# test was written.
# # 16628 - this should be fast
# p0 = Point2D(Rational(249, 5), Rational(497999, 10000))
# p1 = Point2D((-58977084786*sqrt(405639795226) + 2030690077184193 +
# 20112207807*sqrt(630547164901) + 99600*sqrt(255775022850776494562626))
# /(2000*sqrt(255775022850776494562626) + 1991998000*sqrt(405639795226)
# + 1991998000*sqrt(630547164901) + 1622561172902000),
# (-498000*sqrt(255775022850776494562626) - 995999*sqrt(630547164901) +
# 90004251917891999 +
# 496005510002*sqrt(405639795226))/(10000*sqrt(255775022850776494562626)
# + 9959990000*sqrt(405639795226) + 9959990000*sqrt(630547164901) +
# 8112805864510000))
# p2 = Point2D(Rational(497, 10), Rational(-497, 10))
# p3 = Point2D(Rational(-497, 10), Rational(-497, 10))
# l = Line(p0, p1)
# s = Segment(p2, p3)
# n = (-52673223862*sqrt(405639795226) - 15764156209307469 -
# 9803028531*sqrt(630547164901) +
# 33200*sqrt(255775022850776494562626))
# d = sqrt(405639795226) + 315274080450 + 498000*sqrt(
# 630547164901) + sqrt(255775022850776494562626)
# assert intersection(l, s) == [
# Point2D(n/d*Rational(3, 2000), Rational(-497, 10))]
def test_line_intersection():
# see also test_issue_11238 in test_matrices.py
x0 = tan(pi*Rational(13, 45))
x1 = sqrt(3)
x2 = x0**2
x, y = [8*x0/(x0 + x1), (24*x0 - 8*x1*x2)/(x2 - 3)]
assert Line(Point(0, 0), Point(1, -sqrt(3))).contains(Point(x, y)) is True
def test_intersection_3d():
p1 = Point3D(0, 0, 0)
p2 = Point3D(1, 1, 1)
l1 = Line3D(p1, p2)
l2 = Line3D(Point3D(0, 0, 0), Point3D(3, 4, 0))
r1 = Ray3D(Point3D(1, 1, 1), Point3D(2, 2, 2))
r2 = Ray3D(Point3D(0, 0, 0), Point3D(3, 4, 0))
s1 = Segment3D(Point3D(0, 0, 0), Point3D(3, 4, 0))
assert intersection(l1, p1) == [p1]
assert intersection(l1, Point3D(x1, 1 + x1, 1)) == []
assert intersection(l1, l1.parallel_line(p1)) == [Line3D(Point3D(0, 0, 0), Point3D(1, 1, 1))]
assert intersection(l2, r2) == [r2]
assert intersection(l2, s1) == [s1]
assert intersection(r2, l2) == [r2]
assert intersection(r1, Ray3D(Point3D(1, 1, 1), Point3D(-1, -1, -1))) == [Point3D(1, 1, 1)]
assert intersection(r1, Segment3D(Point3D(0, 0, 0), Point3D(2, 2, 2))) == [
Segment3D(Point3D(1, 1, 1), Point3D(2, 2, 2))]
assert intersection(Ray3D(Point3D(1, 0, 0), Point3D(-1, 0, 0)), Ray3D(Point3D(0, 1, 0), Point3D(0, -1, 0))) \
== [Point3D(0, 0, 0)]
assert intersection(r1, Ray3D(Point3D(2, 2, 2), Point3D(0, 0, 0))) == \
[Segment3D(Point3D(1, 1, 1), Point3D(2, 2, 2))]
assert intersection(s1, r2) == [s1]
assert Line3D(Point3D(4, 0, 1), Point3D(0, 4, 1)).intersection(Line3D(Point3D(0, 0, 1), Point3D(4, 4, 1))) == \
[Point3D(2, 2, 1)]
assert Line3D((0, 1, 2), (0, 2, 3)).intersection(Line3D((0, 1, 2), (0, 1, 1))) == [Point3D(0, 1, 2)]
assert Line3D((0, 0), (t, t)).intersection(Line3D((0, 1), (t, t))) == \
[Point3D(t, t)]
assert Ray3D(Point3D(0, 0, 0), Point3D(0, 4, 0)).intersection(Ray3D(Point3D(0, 1, 1), Point3D(0, -1, 1))) == []
def test_is_parallel():
p1 = Point3D(0, 0, 0)
p2 = Point3D(1, 1, 1)
p3 = Point3D(x1, x1, x1)
l2 = Line(Point(x1, x1), Point(y1, y1))
l2_1 = Line(Point(x1, x1), Point(x1, 1 + x1))
assert Line.is_parallel(Line(Point(0, 0), Point(1, 1)), l2)
assert Line.is_parallel(l2, Line(Point(x1, x1), Point(x1, 1 + x1))) is False
assert Line.is_parallel(l2, l2.parallel_line(Point(-x1, x1)))
assert Line.is_parallel(l2_1, l2_1.parallel_line(Point(0, 0)))
assert Line3D(p1, p2).is_parallel(Line3D(p1, p2)) # same as in 2D
assert Line3D(Point3D(4, 0, 1), Point3D(0, 4, 1)).is_parallel(Line3D(Point3D(0, 0, 1), Point3D(4, 4, 1))) is False
assert Line3D(p1, p2).parallel_line(p3) == Line3D(Point3D(x1, x1, x1),
Point3D(x1 + 1, x1 + 1, x1 + 1))
assert Line3D(p1, p2).parallel_line(p3.args) == \
Line3D(Point3D(x1, x1, x1), Point3D(x1 + 1, x1 + 1, x1 + 1))
assert Line3D(Point3D(4, 0, 1), Point3D(0, 4, 1)).is_parallel(Line3D(Point3D(0, 0, 1), Point3D(4, 4, 1))) is False
def test_is_perpendicular():
p1 = Point(0, 0)
p2 = Point(1, 1)
l1 = Line(p1, p2)
l2 = Line(Point(x1, x1), Point(y1, y1))
l1_1 = Line(p1, Point(-x1, x1))
# 2D
assert Line.is_perpendicular(l1, l1_1)
assert Line.is_perpendicular(l1, l2) is False
p = l1.random_point()
assert l1.perpendicular_segment(p) == p
# 3D
assert Line3D.is_perpendicular(Line3D(Point3D(0, 0, 0), Point3D(1, 0, 0)),
Line3D(Point3D(0, 0, 0), Point3D(0, 1, 0))) is True
assert Line3D.is_perpendicular(Line3D(Point3D(0, 0, 0), Point3D(1, 0, 0)),
Line3D(Point3D(0, 1, 0), Point3D(1, 1, 0))) is False
assert Line3D.is_perpendicular(Line3D(Point3D(0, 0, 0), Point3D(1, 1, 1)),
Line3D(Point3D(x1, x1, x1), Point3D(y1, y1, y1))) is False
def test_is_similar():
p1 = Point(2000, 2000)
p2 = p1.scale(2, 2)
r1 = Ray3D(Point3D(1, 1, 1), Point3D(1, 0, 0))
r2 = Ray(Point(0, 0), Point(0, 1))
s1 = Segment(Point(0, 0), p1)
assert s1.is_similar(Segment(p1, p2))
assert s1.is_similar(r2) is False
assert r1.is_similar(Line3D(Point3D(1, 1, 1), Point3D(1, 0, 0))) is True
assert r1.is_similar(Line3D(Point3D(0, 0, 0), Point3D(0, 1, 0))) is False
def test_length():
s2 = Segment3D(Point3D(x1, x1, x1), Point3D(y1, y1, y1))
assert Line(Point(0, 0), Point(1, 1)).length is oo
assert s2.length == sqrt(3) * sqrt((x1 - y1) ** 2)
assert Line3D(Point3D(0, 0, 0), Point3D(1, 1, 1)).length is oo
def test_projection():
p1 = Point(0, 0)
p2 = Point3D(0, 0, 0)
p3 = Point(-x1, x1)
l1 = Line(p1, Point(1, 1))
l2 = Line3D(Point3D(0, 0, 0), Point3D(1, 0, 0))
l3 = Line3D(p2, Point3D(1, 1, 1))
r1 = Ray(Point(1, 1), Point(2, 2))
assert Line(Point(x1, x1), Point(y1, y1)).projection(Point(y1, y1)) == Point(y1, y1)
assert Line(Point(x1, x1), Point(x1, 1 + x1)).projection(Point(1, 1)) == Point(x1, 1)
assert Segment(Point(-2, 2), Point(0, 4)).projection(r1) == Segment(Point(-1, 3), Point(0, 4))
assert Segment(Point(0, 4), Point(-2, 2)).projection(r1) == Segment(Point(0, 4), Point(-1, 3))
assert l1.projection(p3) == p1
assert l1.projection(Ray(p1, Point(-1, 5))) == Ray(Point(0, 0), Point(2, 2))
assert l1.projection(Ray(p1, Point(-1, 1))) == p1
assert r1.projection(Ray(Point(1, 1), Point(-1, -1))) == Point(1, 1)
assert r1.projection(Ray(Point(0, 4), Point(-1, -5))) == Segment(Point(1, 1), Point(2, 2))
assert r1.projection(Segment(Point(-1, 5), Point(-5, -10))) == Segment(Point(1, 1), Point(2, 2))
assert r1.projection(Ray(Point(1, 1), Point(-1, -1))) == Point(1, 1)
assert r1.projection(Ray(Point(0, 4), Point(-1, -5))) == Segment(Point(1, 1), Point(2, 2))
assert r1.projection(Segment(Point(-1, 5), Point(-5, -10))) == Segment(Point(1, 1), Point(2, 2))
assert l3.projection(Ray3D(p2, Point3D(-1, 5, 0))) == Ray3D(Point3D(0, 0, 0), Point3D(Rational(4, 3), Rational(4, 3), Rational(4, 3)))
assert l3.projection(Ray3D(p2, Point3D(-1, 1, 1))) == Ray3D(Point3D(0, 0, 0), Point3D(Rational(1, 3), Rational(1, 3), Rational(1, 3)))
assert l2.projection(Point3D(5, 5, 0)) == Point3D(5, 0)
assert l2.projection(Line3D(Point3D(0, 1, 0), Point3D(1, 1, 0))).equals(l2)
def test_perpendicular_bisector():
s1 = Segment(Point(0, 0), Point(1, 1))
aline = Line(Point(S.Half, S.Half), Point(Rational(3, 2), Rational(-1, 2)))
on_line = Segment(Point(S.Half, S.Half), Point(Rational(3, 2), Rational(-1, 2))).midpoint
assert s1.perpendicular_bisector().equals(aline)
assert s1.perpendicular_bisector(on_line).equals(Segment(s1.midpoint, on_line))
assert s1.perpendicular_bisector(on_line + (1, 0)).equals(aline)
def test_raises():
d, e = symbols('a,b', real=True)
s = Segment((d, 0), (e, 0))
raises(TypeError, lambda: Line((1, 1), 1))
raises(ValueError, lambda: Line(Point(0, 0), Point(0, 0)))
raises(Undecidable, lambda: Point(2 * d, 0) in s)
raises(ValueError, lambda: Ray3D(Point(1.0, 1.0)))
raises(ValueError, lambda: Line3D(Point3D(0, 0, 0), Point3D(0, 0, 0)))
raises(TypeError, lambda: Line3D((1, 1), 1))
raises(ValueError, lambda: Line3D(Point3D(0, 0, 0)))
raises(TypeError, lambda: Ray((1, 1), 1))
raises(GeometryError, lambda: Line(Point(0, 0), Point(1, 0))
.projection(Circle(Point(0, 0), 1)))
def test_ray_generation():
assert Ray((1, 1), angle=pi / 4) == Ray((1, 1), (2, 2))
assert Ray((1, 1), angle=pi / 2) == Ray((1, 1), (1, 2))
assert Ray((1, 1), angle=-pi / 2) == Ray((1, 1), (1, 0))
assert Ray((1, 1), angle=-3 * pi / 2) == Ray((1, 1), (1, 2))
assert Ray((1, 1), angle=5 * pi / 2) == Ray((1, 1), (1, 2))
assert Ray((1, 1), angle=5.0 * pi / 2) == Ray((1, 1), (1, 2))
assert Ray((1, 1), angle=pi) == Ray((1, 1), (0, 1))
assert Ray((1, 1), angle=3.0 * pi) == Ray((1, 1), (0, 1))
assert Ray((1, 1), angle=4.0 * pi) == Ray((1, 1), (2, 1))
assert Ray((1, 1), angle=0) == Ray((1, 1), (2, 1))
assert Ray((1, 1), angle=4.05 * pi) == Ray(Point(1, 1),
Point(2, -sqrt(5) * sqrt(2 * sqrt(5) + 10) / 4 - sqrt(
2 * sqrt(5) + 10) / 4 + 2 + sqrt(5)))
assert Ray((1, 1), angle=4.02 * pi) == Ray(Point(1, 1),
Point(2, 1 + tan(4.02 * pi)))
assert Ray((1, 1), angle=5) == Ray((1, 1), (2, 1 + tan(5)))
assert Ray3D((1, 1, 1), direction_ratio=[4, 4, 4]) == Ray3D(Point3D(1, 1, 1), Point3D(5, 5, 5))
assert Ray3D((1, 1, 1), direction_ratio=[1, 2, 3]) == Ray3D(Point3D(1, 1, 1), Point3D(2, 3, 4))
assert Ray3D((1, 1, 1), direction_ratio=[1, 1, 1]) == Ray3D(Point3D(1, 1, 1), Point3D(2, 2, 2))
def test_symbolic_intersect():
# Issue 7814.
circle = Circle(Point(x, 0), y)
line = Line(Point(k, z), slope=0)
assert line.intersection(circle) == [Point(x + sqrt((y - z) * (y + z)), z), Point(x - sqrt((y - z) * (y + z)), z)]
def test_issue_2941():
def _check():
for f, g in cartes(*[(Line, Ray, Segment)] * 2):
l1 = f(a, b)
l2 = g(c, d)
assert l1.intersection(l2) == l2.intersection(l1)
# intersect at end point
c, d = (-2, -2), (-2, 0)
a, b = (0, 0), (1, 1)
_check()
# midline intersection
c, d = (-2, -3), (-2, 0)
_check()
def test_parameter_value():
t = Symbol('t')
p1, p2 = Point(0, 1), Point(5, 6)
l = Line(p1, p2)
assert l.parameter_value((5, 6), t) == {t: 1}
raises(ValueError, lambda: l.parameter_value((0, 0), t))
def test_bisectors():
r1 = Line3D(Point3D(0, 0, 0), Point3D(1, 0, 0))
r2 = Line3D(Point3D(0, 0, 0), Point3D(0, 1, 0))
bisections = r1.bisectors(r2)
assert bisections == [Line3D(Point3D(0, 0, 0), Point3D(1, 1, 0)),
Line3D(Point3D(0, 0, 0), Point3D(1, -1, 0))]
ans = [Line3D(Point3D(0, 0, 0), Point3D(1, 0, 1)),
Line3D(Point3D(0, 0, 0), Point3D(-1, 0, 1))]
l1 = (0, 0, 0), (0, 0, 1)
l2 = (0, 0), (1, 0)
for a, b in cartes((Line, Segment, Ray), repeat=2):
assert a(*l1).bisectors(b(*l2)) == ans
def test_issue_8615():
a = Line3D(Point3D(6, 5, 0), Point3D(6, -6, 0))
b = Line3D(Point3D(6, -1, 19/10), Point3D(6, -1, 0))
assert a.intersection(b) == [Point3D(6, -1, 0)]
|
30facbd66d4f58fd48004b1c81d5b0085b7cbf4689cf63628a525cddaed17b51 | from sympy import Symbol, sqrt, Derivative, S, Function, exp
from sympy.geometry import Point, Point2D, Line, Polygon, Segment, convex_hull,\
intersection, centroid, Point3D, Line3D
from sympy.geometry.util import idiff, closest_points, farthest_points, _ordered_points, are_coplanar
from sympy.solvers.solvers import solve
from sympy.testing.pytest import raises
def test_idiff():
x = Symbol('x', real=True)
y = Symbol('y', real=True)
t = Symbol('t', real=True)
f = Function('f')
g = Function('g')
# the use of idiff in ellipse also provides coverage
circ = x**2 + y**2 - 4
ans = -3*x*(x**2 + y**2)/y**5
assert ans == idiff(circ, y, x, 3).simplify()
assert ans == idiff(circ, [y], x, 3).simplify()
assert idiff(circ, y, x, 3).simplify() == ans
explicit = 12*x/sqrt(-x**2 + 4)**5
assert ans.subs(y, solve(circ, y)[0]).equals(explicit)
assert True in [sol.diff(x, 3).equals(explicit) for sol in solve(circ, y)]
assert idiff(x + t + y, [y, t], x) == -Derivative(t, x) - 1
assert idiff(f(x) * exp(f(x)) - x * exp(x), f(x), x) == (x + 1) * exp(x - f(x))/(f(x) + 1)
assert idiff(f(x) - y * exp(x), [f(x), y], x) == (y + Derivative(y, x)) * exp(x)
assert idiff(f(x) - y * exp(x), [y, f(x)], x) == -y + exp(-x) * Derivative(f(x), x)
assert idiff(f(x) - g(x), [f(x), g(x)], x) == Derivative(g(x), x)
def test_intersection():
assert intersection(Point(0, 0)) == []
raises(TypeError, lambda: intersection(Point(0, 0), 3))
assert intersection(
Segment((0, 0), (2, 0)),
Segment((-1, 0), (1, 0)),
Line((0, 0), (0, 1)), pairwise=True) == [
Point(0, 0), Segment((0, 0), (1, 0))]
assert intersection(
Line((0, 0), (0, 1)),
Segment((0, 0), (2, 0)),
Segment((-1, 0), (1, 0)), pairwise=True) == [
Point(0, 0), Segment((0, 0), (1, 0))]
assert intersection(
Line((0, 0), (0, 1)),
Segment((0, 0), (2, 0)),
Segment((-1, 0), (1, 0)),
Line((0, 0), slope=1), pairwise=True) == [
Point(0, 0), Segment((0, 0), (1, 0))]
def test_convex_hull():
raises(TypeError, lambda: convex_hull(Point(0, 0), 3))
points = [(1, -1), (1, -2), (3, -1), (-5, -2), (15, -4)]
assert convex_hull(*points, **dict(polygon=False)) == (
[Point2D(-5, -2), Point2D(1, -1), Point2D(3, -1), Point2D(15, -4)],
[Point2D(-5, -2), Point2D(15, -4)])
def test_centroid():
p = Polygon((0, 0), (10, 0), (10, 10))
q = p.translate(0, 20)
assert centroid(p, q) == Point(20, 40)/3
p = Segment((0, 0), (2, 0))
q = Segment((0, 0), (2, 2))
assert centroid(p, q) == Point(1, -sqrt(2) + 2)
assert centroid(Point(0, 0), Point(2, 0)) == Point(2, 0)/2
assert centroid(Point(0, 0), Point(0, 0), Point(2, 0)) == Point(2, 0)/3
def test_farthest_points_closest_points():
from random import randint
from sympy.utilities.iterables import subsets
for how in (min, max):
if how is min:
func = closest_points
else:
func = farthest_points
raises(ValueError, lambda: func(Point2D(0, 0), Point2D(0, 0)))
# 3rd pt dx is close and pt is closer to 1st pt
p1 = [Point2D(0, 0), Point2D(3, 0), Point2D(1, 1)]
# 3rd pt dx is close and pt is closer to 2nd pt
p2 = [Point2D(0, 0), Point2D(3, 0), Point2D(2, 1)]
# 3rd pt dx is close and but pt is not closer
p3 = [Point2D(0, 0), Point2D(3, 0), Point2D(1, 10)]
# 3rd pt dx is not closer and it's closer to 2nd pt
p4 = [Point2D(0, 0), Point2D(3, 0), Point2D(4, 0)]
# 3rd pt dx is not closer and it's closer to 1st pt
p5 = [Point2D(0, 0), Point2D(3, 0), Point2D(-1, 0)]
# duplicate point doesn't affect outcome
dup = [Point2D(0, 0), Point2D(3, 0), Point2D(3, 0), Point2D(-1, 0)]
# symbolic
x = Symbol('x', positive=True)
s = [Point2D(a) for a in ((x, 1), (x + 3, 2), (x + 2, 2))]
for points in (p1, p2, p3, p4, p5, s, dup):
d = how(i.distance(j) for i, j in subsets(points, 2))
ans = a, b = list(func(*points))[0]
a.distance(b) == d
assert ans == _ordered_points(ans)
# if the following ever fails, the above tests were not sufficient
# and the logical error in the routine should be fixed
points = set()
while len(points) != 7:
points.add(Point2D(randint(1, 100), randint(1, 100)))
points = list(points)
d = how(i.distance(j) for i, j in subsets(points, 2))
ans = a, b = list(func(*points))[0]
a.distance(b) == d
assert ans == _ordered_points(ans)
# equidistant points
a, b, c = (
Point2D(0, 0), Point2D(1, 0), Point2D(S.Half, sqrt(3)/2))
ans = {_ordered_points((i, j))
for i, j in subsets((a, b, c), 2)}
assert closest_points(b, c, a) == ans
assert farthest_points(b, c, a) == ans
# unique to farthest
points = [(1, 1), (1, 2), (3, 1), (-5, 2), (15, 4)]
assert farthest_points(*points) == {
(Point2D(-5, 2), Point2D(15, 4))}
points = [(1, -1), (1, -2), (3, -1), (-5, -2), (15, -4)]
assert farthest_points(*points) == {
(Point2D(-5, -2), Point2D(15, -4))}
assert farthest_points((1, 1), (0, 0)) == {
(Point2D(0, 0), Point2D(1, 1))}
raises(ValueError, lambda: farthest_points((1, 1)))
def test_are_coplanar():
a = Line3D(Point3D(5, 0, 0), Point3D(1, -1, 1))
b = Line3D(Point3D(0, -2, 0), Point3D(3, 1, 1))
c = Line3D(Point3D(0, -1, 0), Point3D(5, -1, 9))
d = Line(Point2D(0, 3), Point2D(1, 5))
assert are_coplanar(a, b, c) == False
assert are_coplanar(a, d) == False
|
8afacf36aed2aac966eb5f9e43688dd7c2a722f2ff146265b4f934c631239060 | from __future__ import unicode_literals, print_function
from sympy.external import import_module
import os
cin = import_module('clang.cindex', import_kwargs = {'fromlist': ['cindex']})
"""
This module contains all the necessary Classes and Function used to Parse C and
C++ code into SymPy expression
The module serves as a backend for SymPyExpression to parse C code
It is also dependent on Clang's AST and Sympy's Codegen AST.
The module only supports the features currently supported by the Clang and
codegen AST which will be updated as the development of codegen AST and this
module progresses.
You might find unexpected bugs and exceptions while using the module, feel free
to report them to the SymPy Issue Tracker
Features Supported
==================
- Variable Declarations (integers and reals)
- Assignment (using integer & floating literal and function calls)
- Function Definitions nad Declaration
- Function Calls
- Compound statements, Return statements
Notes
=====
The module is dependent on an external dependency which needs to be installed
to use the features of this module.
Clang: The C and C++ compiler which is used to extract an AST from the provided
C source code.
Refrences
=========
.. [1] https://github.com/sympy/sympy/issues
.. [2] https://clang.llvm.org/docs/
.. [3] https://clang.llvm.org/docs/IntroductionToTheClangAST.html
"""
if cin:
from sympy.codegen.ast import (Variable, Integer, Float,
FunctionPrototype, FunctionDefinition, FunctionCall,
none, Return, Assignment, intc, int8, int16, int64,
uint8, uint16, uint32, uint64, float32, float64, float80,
aug_assign, bool_)
from sympy.codegen.cnodes import (PreDecrement, PostDecrement,
PreIncrement, PostIncrement)
from sympy.core import Add, Mod, Mul, Pow, Rel
from sympy.logic.boolalg import And, as_Boolean, Not, Or
from sympy import Symbol, sympify, true, false
import sys
import tempfile
class BaseParser(object):
"""Base Class for the C parser"""
def __init__(self):
"""Initializes the Base parser creating a Clang AST index"""
self.index = cin.Index.create()
def diagnostics(self, out):
"""Diagostics function for the Clang AST"""
for diag in self.tu.diagnostics:
print('%s %s (line %s, col %s) %s' % (
{
4: 'FATAL',
3: 'ERROR',
2: 'WARNING',
1: 'NOTE',
0: 'IGNORED',
}[diag.severity],
diag.location.file,
diag.location.line,
diag.location.column,
diag.spelling
), file=out)
class CCodeConverter(BaseParser):
"""The Code Convereter for Clang AST
The converter object takes the C source code or file as input and
converts them to SymPy Expressions.
"""
def __init__(self):
"""Initializes the code converter"""
super(CCodeConverter, self).__init__()
self._py_nodes = []
self._data_types = {
"void": {
cin.TypeKind.VOID: none
},
"bool": {
cin.TypeKind.BOOL: bool_
},
"int": {
cin.TypeKind.SCHAR: int8,
cin.TypeKind.SHORT: int16,
cin.TypeKind.INT: intc,
cin.TypeKind.LONG: int64,
cin.TypeKind.UCHAR: uint8,
cin.TypeKind.USHORT: uint16,
cin.TypeKind.UINT: uint32,
cin.TypeKind.ULONG: uint64
},
"float": {
cin.TypeKind.FLOAT: float32,
cin.TypeKind.DOUBLE: float64,
cin.TypeKind.LONGDOUBLE: float80
}
}
def parse(self, filenames, flags):
"""Function to parse a file with C source code
It takes the filename as an attribute and creates a Clang AST
Translation Unit parsing the file.
Then the transformation function is called on the transaltion unit,
whose reults are collected into a list which is returned by the
function.
Parameters
==========
filenames : string
Path to the C file to be parsed
flags: list
Arguments to be passed to Clang while parsing the C code
Returns
=======
py_nodes: list
A list of sympy AST nodes
"""
filename = os.path.abspath(filenames)
self.tu = self.index.parse(
filename,
args=flags,
options=cin.TranslationUnit.PARSE_DETAILED_PROCESSING_RECORD
)
for child in self.tu.cursor.get_children():
if child.kind == cin.CursorKind.VAR_DECL:
self._py_nodes.append(self.transform(child))
elif (child.kind == cin.CursorKind.FUNCTION_DECL):
self._py_nodes.append(self.transform(child))
else:
pass
return self._py_nodes
def parse_str(self, source, flags):
"""Function to parse a string with C source code
It takes the source code as an attribute, stores it in a temporary
file and creates a Clang AST Translation Unit parsing the file.
Then the transformation function is called on the transaltion unit,
whose reults are collected into a list which is returned by the
function.
Parameters
==========
source : string
Path to the C file to be parsed
flags: list
Arguments to be passed to Clang while parsing the C code
Returns
=======
py_nodes: list
A list of sympy AST nodes
"""
file = tempfile.NamedTemporaryFile(mode = 'w+', suffix = '.cpp')
file.write(source)
file.seek(0)
self.tu = self.index.parse(
file.name,
args=flags,
options=cin.TranslationUnit.PARSE_DETAILED_PROCESSING_RECORD
)
file.close()
for child in self.tu.cursor.get_children():
if child.kind == cin.CursorKind.VAR_DECL:
self._py_nodes.append(self.transform(child))
elif (child.kind == cin.CursorKind.FUNCTION_DECL):
self._py_nodes.append(self.transform(child))
else:
pass
return self._py_nodes
def transform(self, node):
"""Transformation Function for Clang AST nodes
It determines the kind of node and calls the respective
transformation function for that node.
Raises
======
NotImplementedError : if the transformation for the provided node
is not implemented
"""
try:
handler = getattr(self, 'transform_%s' % node.kind.name.lower())
except AttributeError:
print(
"Ignoring node of type %s (%s)" % (
node.kind,
' '.join(
t.spelling for t in node.get_tokens())
),
file=sys.stderr
)
handler = None
if handler:
result = handler(node)
return result
def transform_var_decl(self, node):
"""Transformation Function for Variable Declaration
Used to create nodes for variable declarations and assignments with
values or function call for the respective nodes in the clang AST
Returns
=======
A variable node as Declaration, with the initial value if given
Raises
======
NotImplementedError : if called for data types not currently
implemented
Notes
=====
The function currently supports following data types:
Boolean:
bool, _Bool
Integer:
8-bit: signed char and unsigned char
16-bit: short, short int, signed short,
signed short int, unsigned short, unsigned short int
32-bit: int, signed int, unsigned int
64-bit: long, long int, signed long,
signed long int, unsigned long, unsigned long int
Floating point:
Single Precision: float
Double Precision: double
Extended Precision: long double
"""
if node.type.kind in self._data_types["int"]:
type = self._data_types["int"][node.type.kind]
elif node.type.kind in self._data_types["float"]:
type = self._data_types["float"][node.type.kind]
elif node.type.kind in self._data_types["bool"]:
type = self._data_types["bool"][node.type.kind]
else:
raise NotImplementedError("Only bool, int "
"and float are supported")
try:
children = node.get_children()
child = next(children)
#ignoring namespace and type details for the variable
while child.kind == cin.CursorKind.NAMESPACE_REF:
child = next(children)
while child.kind == cin.CursorKind.TYPE_REF:
child = next(children)
val = self.transform(child)
supported_rhs = [
cin.CursorKind.INTEGER_LITERAL,
cin.CursorKind.FLOATING_LITERAL,
cin.CursorKind.UNEXPOSED_EXPR,
cin.CursorKind.BINARY_OPERATOR,
cin.CursorKind.PAREN_EXPR,
cin.CursorKind.UNARY_OPERATOR,
cin.CursorKind.CXX_BOOL_LITERAL_EXPR
]
if child.kind in supported_rhs:
if isinstance(val, str):
value = Symbol(val)
elif isinstance(val, bool):
if node.type.kind in self._data_types["int"]:
value = Integer(0) if val == False else Integer(1)
elif node.type.kind in self._data_types["float"]:
value = Float(0.0) if val == False else Float(1.0)
elif node.type.kind in self._data_types["bool"]:
value = sympify(val)
elif isinstance(val, (Integer, int, Float, float)):
if node.type.kind in self._data_types["int"]:
value = Integer(val)
elif node.type.kind in self._data_types["float"]:
value = Float(val)
elif node.type.kind in self._data_types["bool"]:
value = sympify(bool(val))
else:
value = val
return Variable(
node.spelling
).as_Declaration(
type = type,
value = value
)
elif child.kind == cin.CursorKind.CALL_EXPR:
return Variable(
node.spelling
).as_Declaration(
value = val
)
else:
raise NotImplementedError("Given "
"variable declaration \"{}\" "
"is not possible to parse yet!"
.format(" ".join(
t.spelling for t in node.get_tokens()
)
))
except StopIteration:
return Variable(
node.spelling
).as_Declaration(
type = type
)
def transform_function_decl(self, node):
"""Transformation Function For Function Declaration
Used to create nodes for function declarations and definitions for
the respective nodes in the clang AST
Returns
=======
function : Codegen AST node
- FunctionPrototype node if function body is not present
- FunctionDefinition node if the function body is present
"""
if node.result_type.kind in self._data_types["int"]:
ret_type = self._data_types["int"][node.result_type.kind]
elif node.result_type.kind in self._data_types["float"]:
ret_type = self._data_types["float"][node.result_type.kind]
elif node.result_type.kind in self._data_types["bool"]:
ret_type = self._data_types["bool"][node.result_type.kind]
elif node.result_type.kind in self._data_types["void"]:
ret_type = self._data_types["void"][node.result_type.kind]
else:
raise NotImplementedError("Only void, bool, int "
"and float are supported")
body = []
param = []
try:
children = node.get_children()
child = next(children)
# If the node has any children, the first children will be the
# return type and namespace for the function declaration. These
# nodes can be ignored.
while child.kind == cin.CursorKind.NAMESPACE_REF:
child = next(children)
while child.kind == cin.CursorKind.TYPE_REF:
child = next(children)
# Subsequent nodes will be the parameters for the function.
try:
while True:
decl = self.transform(child)
if (child.kind == cin.CursorKind.PARM_DECL):
param.append(decl)
elif (child.kind == cin.CursorKind.COMPOUND_STMT):
for val in decl:
body.append(val)
else:
body.append(decl)
child = next(children)
except StopIteration:
pass
except StopIteration:
pass
if body == []:
function = FunctionPrototype(
return_type = ret_type,
name = node.spelling,
parameters = param
)
else:
function = FunctionDefinition(
return_type = ret_type,
name = node.spelling,
parameters = param,
body = body
)
return function
def transform_parm_decl(self, node):
"""Transformation function for Parameter Declaration
Used to create parameter nodes for the required functions for the
respective nodes in the clang AST
Returns
=======
param : Codegen AST Node
Variable node with the value nad type of the variable
Raises
======
ValueError if multiple children encountered in the parameter node
"""
if node.type.kind in self._data_types["int"]:
type = self._data_types["int"][node.type.kind]
elif node.type.kind in self._data_types["float"]:
type = self._data_types["float"][node.type.kind]
elif node.type.kind in self._data_types["bool"]:
type = self._data_types["bool"][node.type.kind]
else:
raise NotImplementedError("Only bool, int "
"and float are supported")
try:
children = node.get_children()
child = next(children)
# Any namespace nodes can be ignored
while child.kind in [cin.CursorKind.NAMESPACE_REF,
cin.CursorKind.TYPE_REF,
cin.CursorKind.TEMPLATE_REF]:
child = next(children)
# If there is a child, it is the default value of the parameter.
lit = self.transform(child)
if node.type.kind in self._data_types["int"]:
val = Integer(lit)
elif node.type.kind in self._data_types["float"]:
val = Float(lit)
elif node.type.kind in self._data_types["bool"]:
val = sympify(bool(lit))
else:
raise NotImplementedError("Only bool, int "
"and float are supported")
param = Variable(
node.spelling
).as_Declaration(
type = type,
value = val
)
except StopIteration:
param = Variable(
node.spelling
).as_Declaration(
type = type
)
try:
self.transform(next(children))
raise ValueError("Can't handle multiple children on parameter")
except StopIteration:
pass
return param
def transform_integer_literal(self, node):
"""Transformation function for integer literal
Used to get the value and type of the given integer literal.
Returns
=======
val : list
List with two arguments type and Value
type contains the type of the integer
value contains the value stored in the variable
Notes
=====
Only Base Integer type supported for now
"""
try:
value = next(node.get_tokens()).spelling
except StopIteration:
# No tokens
value = node.literal
return int(value)
def transform_floating_literal(self, node):
"""Transformation function for floating literal
Used to get the value and type of the given floating literal.
Returns
=======
val : list
List with two arguments type and Value
type contains the type of float
value contains the value stored in the variable
Notes
=====
Only Base Float type supported for now
"""
try:
value = next(node.get_tokens()).spelling
except (StopIteration, ValueError):
# No tokens
value = node.literal
return float(value)
def transform_string_literal(self, node):
#TODO: No string type in AST
#type =
#try:
# value = next(node.get_tokens()).spelling
#except (StopIteration, ValueError):
# No tokens
# value = node.literal
#val = [type, value]
#return val
pass
def transform_character_literal(self, node):
"""Transformation function for character literal
Used to get the value of the given character literal.
Returns
=======
val : int
val contains the ascii value of the character literal
Notes
=====
Only for cases where character is assigned to a integer value,
since character literal is not in sympy AST
"""
try:
value = next(node.get_tokens()).spelling
except (StopIteration, ValueError):
# No tokens
value = node.literal
return ord(str(value[1]))
def transform_cxx_bool_literal_expr(self, node):
"""Transformation function for boolean literal
Used to get the value of the given boolean literal.
Returns
=======
value : bool
value contains the boolean value of the variable
"""
try:
value = next(node.get_tokens()).spelling
except (StopIteration, ValueError):
value = node.literal
return True if value == 'true' else False
def transform_unexposed_decl(self,node):
"""Transformation function for unexposed declarations"""
pass
def transform_unexposed_expr(self, node):
"""Transformation function for unexposed expression
Unexposed expressions are used to wrap float, double literals and
expressions
Returns
=======
expr : Codegen AST Node
the result from the wrapped expression
None : NoneType
No childs are found for the node
Raises
======
ValueError if the expression contains multiple children
"""
# Ignore unexposed nodes; pass whatever is the first
# (and should be only) child unaltered.
try:
children = node.get_children()
expr = self.transform(next(children))
except StopIteration:
return None
try:
next(children)
raise ValueError("Unexposed expression has > 1 children.")
except StopIteration:
pass
return expr
def transform_decl_ref_expr(self, node):
"""Returns the name of the declaration reference"""
return node.spelling
def transform_call_expr(self, node):
"""Transformation function for a call expression
Used to create function call nodes for the function calls present
in the C code
Returns
=======
FunctionCall : Codegen AST Node
FunctionCall node with parameters if any parameters are present
"""
param = []
children = node.get_children()
child = next(children)
while child.kind == cin.CursorKind.NAMESPACE_REF:
child = next(children)
while child.kind == cin.CursorKind.TYPE_REF:
child = next(children)
first_child = self.transform(child)
try:
for child in children:
arg = self.transform(child)
if (child.kind == cin.CursorKind.INTEGER_LITERAL):
param.append(Integer(arg))
elif (child.kind == cin.CursorKind.FLOATING_LITERAL):
param.append(Float(arg))
else:
param.append(arg)
return FunctionCall(first_child, param)
except StopIteration:
return FunctionCall(first_child)
def transform_return_stmt(self, node):
"""Returns the Return Node for a return statement"""
return Return(next(node.get_children()).spelling)
def transform_compound_stmt(self, node):
"""Transformation function for compond statemets
Returns
=======
expr : list
list of Nodes for the expressions present in the statement
None : NoneType
if the compound statement is empty
"""
try:
expr = []
children = node.get_children()
for child in children:
expr.append(self.transform(child))
except StopIteration:
return None
return expr
def transform_decl_stmt(self, node):
"""Transformation function for declaration statements
These statements are used to wrap different kinds of declararions
like variable or function declaration
The function calls the transformer function for the child of the
given node
Returns
=======
statement : Codegen AST Node
contains the node returned by the children node for the type of
declaration
Raises
======
ValueError if multiple children present
"""
try:
children = node.get_children()
statement = self.transform(next(children))
except StopIteration:
pass
try:
self.transform(next(children))
raise ValueError("Don't know how to handle multiple statements")
except StopIteration:
pass
return statement
def transform_paren_expr(self, node):
"""Transformation function for Parenthesized expressions
Returns the result from its children nodes
"""
return self.transform(next(node.get_children()))
def transform_compound_assignment_operator(self, node):
"""Transformation function for handling shorthand operators
Returns
=======
augmented_assignment_expression: Codegen AST node
shorthand assignment expression represented as Codegen AST
Raises
======
NotImplementedError
If the shorthand operator for bitwise operators
(~=, ^=, &=, |=, <<=, >>=) is encountered
"""
return self.transform_binary_operator(node)
def transform_unary_operator(self, node):
"""Transformation function for handling unary operators
Returns
=======
unary_expression: Codegen AST node
simplified unary expression represented as Codegen AST
Raises
======
NotImplementedError
If dereferencing operator(*), address operator(&) or
bitwise NOT operator(~) is encountered
"""
# supported operators list
operators_list = ['+', '-', '++', '--', '!']
tokens = [token for token in node.get_tokens()]
# it can be either pre increment/decrement or any other operator from the list
if tokens[0].spelling in operators_list:
child = self.transform(next(node.get_children()))
# (decl_ref) e.g.; int a = ++b; or simply ++b;
if isinstance(child, str):
if tokens[0].spelling == '+':
return Symbol(child)
if tokens[0].spelling == '-':
return Mul(Symbol(child), -1)
if tokens[0].spelling == '++':
return PreIncrement(Symbol(child))
if tokens[0].spelling == '--':
return PreDecrement(Symbol(child))
if tokens[0].spelling == '!':
return Not(Symbol(child))
# e.g.; int a = -1; or int b = -(1 + 2);
else:
if tokens[0].spelling == '+':
return child
if tokens[0].spelling == '-':
return Mul(child, -1)
if tokens[0].spelling == '!':
return Not(sympify(bool(child)))
# it can be either post increment/decrement
# since variable name is obtained in token[0].spelling
elif tokens[1].spelling in ['++', '--']:
child = self.transform(next(node.get_children()))
if tokens[1].spelling == '++':
return PostIncrement(Symbol(child))
if tokens[1].spelling == '--':
return PostDecrement(Symbol(child))
else:
raise NotImplementedError("Dereferencing operator, "
"Address operator and bitwise NOT operator "
"have not been implemented yet!")
def transform_binary_operator(self, node):
"""Transformation function for handling binary operators
Returns
=======
binary_expression: Codegen AST node
simplified binary expression represented as Codegen AST
Raises
======
NotImplementedError
If a bitwise operator or
unary operator(which is a child of any binary
operator in Clang AST) is encountered
"""
# get all the tokens of assignment
# and store it in the tokens list
tokens = [token for token in node.get_tokens()]
# supported operators list
operators_list = ['+', '-', '*', '/', '%','=',
'>', '>=', '<', '<=', '==', '!=', '&&', '||', '+=', '-=',
'*=', '/=', '%=']
# this stack will contain variable content
# and type of variable in the rhs
combined_variables_stack = []
# this stack will contain operators
# to be processed in the rhs
operators_stack = []
# iterate through every token
for token in tokens:
# token is either '(', ')' or
# any of the supported operators from the operator list
if token.kind == cin.TokenKind.PUNCTUATION:
# push '(' to the operators stack
if token.spelling == '(':
operators_stack.append('(')
elif token.spelling == ')':
# keep adding the expression to the
# combined variables stack unless
# '(' is found
while (operators_stack
and operators_stack[-1] != '('):
if len(combined_variables_stack) < 2:
raise NotImplementedError(
"Unary operators as a part of "
"binary operators is not "
"supported yet!")
rhs = combined_variables_stack.pop()
lhs = combined_variables_stack.pop()
operator = operators_stack.pop()
combined_variables_stack.append(
self.perform_operation(
lhs, rhs, operator))
# pop '('
operators_stack.pop()
# token is an operator (supported)
elif token.spelling in operators_list:
while (operators_stack
and self.priority_of(token.spelling)
<= self.priority_of(
operators_stack[-1])):
if len(combined_variables_stack) < 2:
raise NotImplementedError(
"Unary operators as a part of "
"binary operators is not "
"supported yet!")
rhs = combined_variables_stack.pop()
lhs = combined_variables_stack.pop()
operator = operators_stack.pop()
combined_variables_stack.append(
self.perform_operation(
lhs, rhs, operator))
# push current operator
operators_stack.append(token.spelling)
# token is a bitwise operator
elif token.spelling in ['&', '|', '^', '<<', '>>']:
raise NotImplementedError(
"Bitwise operator has not been "
"implemented yet!")
# token is a shorthand bitwise operator
elif token.spelling in ['&=', '|=', '^=', '<<=',
'>>=']:
raise NotImplementedError(
"Shorthand bitwise operator has not been "
"implemented yet!")
else:
raise NotImplementedError(
"Given token {} is not implemented yet!"
.format(token.spelling))
# token is an identifier(variable)
elif token.kind == cin.TokenKind.IDENTIFIER:
combined_variables_stack.append(
[token.spelling, 'identifier'])
# token is a literal
elif token.kind == cin.TokenKind.LITERAL:
combined_variables_stack.append(
[token.spelling, 'literal'])
# token is a keyword, either true or false
elif (token.kind == cin.TokenKind.KEYWORD
and token.spelling in ['true', 'false']):
combined_variables_stack.append(
[token.spelling, 'boolean'])
else:
raise NotImplementedError(
"Given token {} is not implemented yet!"
.format(token.spelling))
# process remaining operators
while operators_stack:
if len(combined_variables_stack) < 2:
raise NotImplementedError(
"Unary operators as a part of "
"binary operators is not "
"supported yet!")
rhs = combined_variables_stack.pop()
lhs = combined_variables_stack.pop()
operator = operators_stack.pop()
combined_variables_stack.append(
self.perform_operation(lhs, rhs, operator))
return combined_variables_stack[-1][0]
def priority_of(self, op):
"""To get the priority of given operator"""
if op in ['=', '+=', '-=', '*=', '/=', '%=']:
return 1
if op in ['&&', '||']:
return 2
if op in ['<', '<=', '>', '>=', '==', '!=']:
return 3
if op in ['+', '-']:
return 4
if op in ['*', '/', '%']:
return 5
return 0
def perform_operation(self, lhs, rhs, op):
"""Performs operation supported by the sympy core
Returns
=======
combined_variable: list
contains variable content and type of variable
"""
lhs_value = self.get_expr_for_operand(lhs)
rhs_value = self.get_expr_for_operand(rhs)
if op == '+':
return [Add(lhs_value, rhs_value), 'expr']
if op == '-':
return [Add(lhs_value, -rhs_value), 'expr']
if op == '*':
return [Mul(lhs_value, rhs_value), 'expr']
if op == '/':
return [Mul(lhs_value, Pow(rhs_value, Integer(-1))), 'expr']
if op == '%':
return [Mod(lhs_value, rhs_value), 'expr']
if op in ['<', '<=', '>', '>=', '==', '!=']:
return [Rel(lhs_value, rhs_value, op), 'expr']
if op == '&&':
return [And(as_Boolean(lhs_value), as_Boolean(rhs_value)), 'expr']
if op == '||':
return [Or(as_Boolean(lhs_value), as_Boolean(rhs_value)), 'expr']
if op == '=':
return [Assignment(Variable(lhs_value), rhs_value), 'expr']
if op in ['+=', '-=', '*=', '/=', '%=']:
return [aug_assign(Variable(lhs_value), op[0], rhs_value), 'expr']
def get_expr_for_operand(self, combined_variable):
"""Gives out SymPy Codegen AST node
AST node returned is corresponding to
combined variable passed.Combined variable contains
variable content and type of variable
"""
if combined_variable[1] == 'identifier':
return Symbol(combined_variable[0])
if combined_variable[1] == 'literal':
if '.' in combined_variable[0]:
return Float(float(combined_variable[0]))
else:
return Integer(int(combined_variable[0]))
if combined_variable[1] == 'expr':
return combined_variable[0]
if combined_variable[1] == 'boolean':
return true if combined_variable[0] == 'true' else false
else:
class CCodeConverter(): # type: ignore
def __init__(self, *args, **kwargs):
raise ImportError("Module not Installed")
def parse_c(source):
"""Function for converting a C source code
The function reads the source code present in the given file and parses it
to give out SymPy Expressions
Returns
=======
src : list
List of Python expression strings
"""
converter = CCodeConverter()
if os.path.exists(source):
src = converter.parse(source, flags = [])
else:
src = converter.parse_str(source, flags = [])
return src
|
9a455d6996360e50906ba7865eed66c9e3aa5a00ca8e0c9bd2e209365a51e0f4 | from sympy.parsing.sym_expr import SymPyExpression
from sympy.testing.pytest import raises
from sympy.external import import_module
lfortran = import_module('lfortran')
cin = import_module('clang.cindex', import_kwargs = {'fromlist': ['cindex']})
if lfortran and cin:
from sympy.codegen.ast import (Variable, IntBaseType, FloatBaseType, String,
Declaration, FloatType)
from sympy.core import Integer, Float
from sympy import Symbol
expr1 = SymPyExpression()
src = """\
integer :: a, b, c, d
real :: p, q, r, s
"""
def test_c_parse():
src1 = """\
int a, b = 4;
float c, d = 2.4;
"""
expr1.convert_to_expr(src1, 'c')
ls = expr1.return_expr()
assert ls[0] == Declaration(
Variable(
Symbol('a'),
type=IntBaseType(String('intc'))
)
)
assert ls[1] == Declaration(
Variable(
Symbol('b'),
type=IntBaseType(String('intc')),
value=Integer(4)
)
)
assert ls[2] == Declaration(
Variable(
Symbol('c'),
type=FloatType(
String('float32'),
nbits=Integer(32),
nmant=Integer(23),
nexp=Integer(8)
)
)
)
assert ls[3] == Declaration(
Variable(
Symbol('d'),
type=FloatType(
String('float32'),
nbits=Integer(32),
nmant=Integer(23),
nexp=Integer(8)
),
value=Float('2.3999999999999999', precision=53)
)
)
def test_fortran_parse():
expr = SymPyExpression(src, 'f')
ls = expr.return_expr()
assert ls[0] == Declaration(
Variable(
Symbol('a'),
type=IntBaseType(String('integer')),
value=Integer(0)
)
)
assert ls[1] == Declaration(
Variable(
Symbol('b'),
type=IntBaseType(String('integer')),
value=Integer(0)
)
)
assert ls[2] == Declaration(
Variable(
Symbol('c'),
type=IntBaseType(String('integer')),
value=Integer(0)
)
)
assert ls[3] == Declaration(
Variable(
Symbol('d'),
type=IntBaseType(String('integer')),
value=Integer(0)
)
)
assert ls[4] == Declaration(
Variable(
Symbol('p'),
type=FloatBaseType(String('real')),
value=Float('0.0', precision=53)
)
)
assert ls[5] == Declaration(
Variable(
Symbol('q'),
type=FloatBaseType(String('real')),
value=Float('0.0', precision=53)
)
)
assert ls[6] == Declaration(
Variable(
Symbol('r'),
type=FloatBaseType(String('real')),
value=Float('0.0', precision=53)
)
)
assert ls[7] == Declaration(
Variable(
Symbol('s'),
type=FloatBaseType(String('real')),
value=Float('0.0', precision=53)
)
)
def test_convert_py():
src1 = (
src +
"""\
a = b + c
s = p * q / r
"""
)
expr1.convert_to_expr(src1, 'f')
exp_py = expr1.convert_to_python()
assert exp_py == [
'a = 0',
'b = 0',
'c = 0',
'd = 0',
'p = 0.0',
'q = 0.0',
'r = 0.0',
's = 0.0',
'a = b + c',
's = p*q/r'
]
def test_convert_fort():
src1 = (
src +
"""\
a = b + c
s = p * q / r
"""
)
expr1.convert_to_expr(src1, 'f')
exp_fort = expr1.convert_to_fortran()
assert exp_fort == [
' integer*4 a',
' integer*4 b',
' integer*4 c',
' integer*4 d',
' real*8 p',
' real*8 q',
' real*8 r',
' real*8 s',
' a = b + c',
' s = p*q/r'
]
def test_convert_c():
src1 = (
src +
"""\
a = b + c
s = p * q / r
"""
)
expr1.convert_to_expr(src1, 'f')
exp_c = expr1.convert_to_c()
assert exp_c == [
'int a = 0',
'int b = 0',
'int c = 0',
'int d = 0',
'double p = 0.0',
'double q = 0.0',
'double r = 0.0',
'double s = 0.0',
'a = b + c;',
's = p*q/r;'
]
def test_exceptions():
src = 'int a;'
raises(ValueError, lambda: SymPyExpression(src))
raises(ValueError, lambda: SymPyExpression(mode = 'c'))
raises(NotImplementedError, lambda: SymPyExpression(src, mode = 'd'))
elif not lfortran and not cin:
def test_raise():
raises(ImportError, lambda: SymPyExpression('int a;', 'c'))
raises(ImportError, lambda: SymPyExpression('integer :: a', 'f'))
|
5025f28c6369ac6d4c869e94ae132aac1a3037cab5b5f2c7339c0b67eb378bf6 | from sympy.testing.pytest import raises, XFAIL
from sympy.external import import_module
from sympy import (
Symbol, Mul, Add, Eq, Abs, sin, asin, cos, Pow,
csc, sec, Limit, oo, Derivative, Integral, factorial,
sqrt, root, StrictLessThan, LessThan, StrictGreaterThan,
GreaterThan, Sum, Product, E, log, tan, Function, binomial
)
from sympy.abc import x, y, z, a, b, c, t, k, n
antlr4 = import_module("antlr4")
# disable tests if antlr4-python*-runtime is not present
if not antlr4:
disabled = True
theta = Symbol('theta')
f = Function('f')
# shorthand definitions
def _Add(a, b):
return Add(a, b, evaluate=False)
def _Mul(a, b):
return Mul(a, b, evaluate=False)
def _Pow(a, b):
return Pow(a, b, evaluate=False)
def _Abs(a):
return Abs(a, evaluate=False)
def _factorial(a):
return factorial(a, evaluate=False)
def _log(a, b):
return log(a, b, evaluate=False)
def _binomial(n, k):
return binomial(n, k, evaluate=False)
def test_import():
from sympy.parsing.latex._build_latex_antlr import (
build_parser,
check_antlr_version,
dir_latex_antlr
)
# XXX: It would be better to come up with a test for these...
del build_parser, check_antlr_version, dir_latex_antlr
# These LaTeX strings should parse to the corresponding SymPy expression
GOOD_PAIRS = [
("0", 0),
("1", 1),
("-3.14", _Mul(-1, 3.14)),
("(-7.13)(1.5)", _Mul(_Mul(-1, 7.13), 1.5)),
("x", x),
("2x", 2*x),
("x^2", x**2),
("x^{3 + 1}", x**_Add(3, 1)),
("-c", -c),
("a \\cdot b", a * b),
("a / b", a / b),
("a \\div b", a / b),
("a + b", a + b),
("a + b - a", _Add(a+b, -a)),
("a^2 + b^2 = c^2", Eq(a**2 + b**2, c**2)),
("\\sin \\theta", sin(theta)),
("\\sin(\\theta)", sin(theta)),
("\\sin^{-1} a", asin(a)),
("\\sin a \\cos b", _Mul(sin(a), cos(b))),
("\\sin \\cos \\theta", sin(cos(theta))),
("\\sin(\\cos \\theta)", sin(cos(theta))),
("\\frac{a}{b}", a / b),
("\\frac{a + b}{c}", _Mul(a + b, _Pow(c, -1))),
("\\frac{7}{3}", _Mul(7, _Pow(3, -1))),
("(\\csc x)(\\sec y)", csc(x)*sec(y)),
("\\lim_{x \\to 3} a", Limit(a, x, 3)),
("\\lim_{x \\rightarrow 3} a", Limit(a, x, 3)),
("\\lim_{x \\Rightarrow 3} a", Limit(a, x, 3)),
("\\lim_{x \\longrightarrow 3} a", Limit(a, x, 3)),
("\\lim_{x \\Longrightarrow 3} a", Limit(a, x, 3)),
("\\lim_{x \\to 3^{+}} a", Limit(a, x, 3, dir='+')),
("\\lim_{x \\to 3^{-}} a", Limit(a, x, 3, dir='-')),
("\\infty", oo),
("\\lim_{x \\to \\infty} \\frac{1}{x}",
Limit(_Mul(1, _Pow(x, -1)), x, oo)),
("\\frac{d}{dx} x", Derivative(x, x)),
("\\frac{d}{dt} x", Derivative(x, t)),
("f(x)", f(x)),
("f(x, y)", f(x, y)),
("f(x, y, z)", f(x, y, z)),
("\\frac{d f(x)}{dx}", Derivative(f(x), x)),
("\\frac{d\\theta(x)}{dx}", Derivative(Function('theta')(x), x)),
("|x|", _Abs(x)),
("||x||", _Abs(Abs(x))),
("|x||y|", _Abs(x)*_Abs(y)),
("||x||y||", _Abs(_Abs(x)*_Abs(y))),
("\\pi^{|xy|}", Symbol('pi')**_Abs(x*y)),
("\\int x dx", Integral(x, x)),
("\\int x d\\theta", Integral(x, theta)),
("\\int (x^2 - y)dx", Integral(x**2 - y, x)),
("\\int x + a dx", Integral(_Add(x, a), x)),
("\\int da", Integral(1, a)),
("\\int_0^7 dx", Integral(1, (x, 0, 7))),
("\\int_a^b x dx", Integral(x, (x, a, b))),
("\\int^b_a x dx", Integral(x, (x, a, b))),
("\\int_{a}^b x dx", Integral(x, (x, a, b))),
("\\int^{b}_a x dx", Integral(x, (x, a, b))),
("\\int_{a}^{b} x dx", Integral(x, (x, a, b))),
("\\int^{b}_{a} x dx", Integral(x, (x, a, b))),
("\\int_{f(a)}^{f(b)} f(z) dz", Integral(f(z), (z, f(a), f(b)))),
("\\int (x+a)", Integral(_Add(x, a), x)),
("\\int a + b + c dx", Integral(_Add(_Add(a, b), c), x)),
("\\int \\frac{dz}{z}", Integral(Pow(z, -1), z)),
("\\int \\frac{3 dz}{z}", Integral(3*Pow(z, -1), z)),
("\\int \\frac{1}{x} dx", Integral(Pow(x, -1), x)),
("\\int \\frac{1}{a} + \\frac{1}{b} dx",
Integral(_Add(_Pow(a, -1), Pow(b, -1)), x)),
("\\int \\frac{3 \\cdot d\\theta}{\\theta}",
Integral(3*_Pow(theta, -1), theta)),
("\\int \\frac{1}{x} + 1 dx", Integral(_Add(_Pow(x, -1), 1), x)),
("x_0", Symbol('x_{0}')),
("x_{1}", Symbol('x_{1}')),
("x_a", Symbol('x_{a}')),
("x_{b}", Symbol('x_{b}')),
("h_\\theta", Symbol('h_{theta}')),
("h_{\\theta}", Symbol('h_{theta}')),
("h_{\\theta}(x_0, x_1)",
Function('h_{theta}')(Symbol('x_{0}'), Symbol('x_{1}'))),
("x!", _factorial(x)),
("100!", _factorial(100)),
("\\theta!", _factorial(theta)),
("(x + 1)!", _factorial(_Add(x, 1))),
("(x!)!", _factorial(_factorial(x))),
("x!!!", _factorial(_factorial(_factorial(x)))),
("5!7!", _Mul(_factorial(5), _factorial(7))),
("\\sqrt{x}", sqrt(x)),
("\\sqrt{x + b}", sqrt(_Add(x, b))),
("\\sqrt[3]{\\sin x}", root(sin(x), 3)),
("\\sqrt[y]{\\sin x}", root(sin(x), y)),
("\\sqrt[\\theta]{\\sin x}", root(sin(x), theta)),
("x < y", StrictLessThan(x, y)),
("x \\leq y", LessThan(x, y)),
("x > y", StrictGreaterThan(x, y)),
("x \\geq y", GreaterThan(x, y)),
("\\mathit{x}", Symbol('x')),
("\\mathit{test}", Symbol('test')),
("\\mathit{TEST}", Symbol('TEST')),
("\\mathit{HELLO world}", Symbol('HELLO world')),
("\\sum_{k = 1}^{3} c", Sum(c, (k, 1, 3))),
("\\sum_{k = 1}^3 c", Sum(c, (k, 1, 3))),
("\\sum^{3}_{k = 1} c", Sum(c, (k, 1, 3))),
("\\sum^3_{k = 1} c", Sum(c, (k, 1, 3))),
("\\sum_{k = 1}^{10} k^2", Sum(k**2, (k, 1, 10))),
("\\sum_{n = 0}^{\\infty} \\frac{1}{n!}",
Sum(_Pow(_factorial(n), -1), (n, 0, oo))),
("\\prod_{a = b}^{c} x", Product(x, (a, b, c))),
("\\prod_{a = b}^c x", Product(x, (a, b, c))),
("\\prod^{c}_{a = b} x", Product(x, (a, b, c))),
("\\prod^c_{a = b} x", Product(x, (a, b, c))),
("\\ln x", _log(x, E)),
("\\ln xy", _log(x*y, E)),
("\\log x", _log(x, 10)),
("\\log xy", _log(x*y, 10)),
("\\log_{2} x", _log(x, 2)),
("\\log_{a} x", _log(x, a)),
("\\log_{11} x", _log(x, 11)),
("\\log_{a^2} x", _log(x, _Pow(a, 2))),
("[x]", x),
("[a + b]", _Add(a, b)),
("\\frac{d}{dx} [ \\tan x ]", Derivative(tan(x), x)),
("\\binom{n}{k}", _binomial(n, k)),
("\\tbinom{n}{k}", _binomial(n, k)),
("\\dbinom{n}{k}", _binomial(n, k)),
("\\binom{n}{0}", _binomial(n, 0))
]
def test_parseable():
from sympy.parsing.latex import parse_latex
for latex_str, sympy_expr in GOOD_PAIRS:
assert parse_latex(latex_str) == sympy_expr
# At time of migration from latex2sympy, should work but doesn't
FAILING_PAIRS = [
("\\log_2 x", _log(x, 2)),
("\\log_a x", _log(x, a)),
]
def test_failing_parseable():
from sympy.parsing.latex import parse_latex
for latex_str, sympy_expr in FAILING_PAIRS:
with raises(Exception):
assert parse_latex(latex_str) == sympy_expr
# These bad LaTeX strings should raise a LaTeXParsingError when parsed
BAD_STRINGS = [
"(",
")",
"\\frac{d}{dx}",
"(\\frac{d}{dx})"
"\\sqrt{}",
"\\sqrt",
"{",
"}",
"\\mathit{x + y}",
"\\mathit{21}",
"\\frac{2}{}",
"\\frac{}{2}",
"\\int",
"!",
"!0",
"_",
"^",
"|",
"||x|",
"()",
"((((((((((((((((()))))))))))))))))",
"-",
"\\frac{d}{dx} + \\frac{d}{dt}",
"f(x,,y)",
"f(x,y,",
"\\sin^x",
"\\cos^2",
"@",
"#",
"$",
"%",
"&",
"*",
"\\",
"~",
"\\frac{(2 + x}{1 - x)}"
]
def test_not_parseable():
from sympy.parsing.latex import parse_latex, LaTeXParsingError
for latex_str in BAD_STRINGS:
with raises(LaTeXParsingError):
parse_latex(latex_str)
# At time of migration from latex2sympy, should fail but doesn't
FAILING_BAD_STRINGS = [
"\\cos 1 \\cos",
"f(,",
"f()",
"a \\div \\div b",
"a \\cdot \\cdot b",
"a // b",
"a +",
"1.1.1",
"1 +",
"a / b /",
]
@XFAIL
def test_failing_not_parseable():
from sympy.parsing.latex import parse_latex, LaTeXParsingError
for latex_str in FAILING_BAD_STRINGS:
with raises(LaTeXParsingError):
parse_latex(latex_str)
|
98264a4af8066ed92eda33a846fd2df91de081bd66e0b371d4d950926fd15b19 | from sympy.parsing.sym_expr import SymPyExpression
from sympy.testing.pytest import raises
from sympy.external import import_module
cin = import_module('clang.cindex', import_kwargs = {'fromlist': ['cindex']})
if cin:
from sympy.codegen.ast import (Variable, String, Return,
FunctionDefinition, Integer, Float, Declaration, CodeBlock,
FunctionPrototype, FunctionCall, NoneToken, Assignment, Type,
IntBaseType, SignedIntType, UnsignedIntType, FloatType,
AddAugmentedAssignment, SubAugmentedAssignment,
MulAugmentedAssignment, DivAugmentedAssignment,
ModAugmentedAssignment)
from sympy.codegen.cnodes import (PreDecrement, PostDecrement,
PreIncrement, PostIncrement)
from sympy.core import (Add, Mul, Mod, Pow, Rational,
StrictLessThan, LessThan, StrictGreaterThan, GreaterThan,
Equality, Unequality)
from sympy.logic.boolalg import And, Not, Or
from sympy import Symbol, true, false
import os
def test_variable():
c_src1 = (
'int a;' + '\n' +
'int b;' + '\n'
)
c_src2 = (
'float a;' + '\n'
+ 'float b;' + '\n'
)
c_src3 = (
'int a;' + '\n' +
'float b;' + '\n' +
'int c;'
)
c_src4 = (
'int x = 1, y = 6.78;' + '\n' +
'float p = 2, q = 9.67;'
)
res1 = SymPyExpression(c_src1, 'c').return_expr()
res2 = SymPyExpression(c_src2, 'c').return_expr()
res3 = SymPyExpression(c_src3, 'c').return_expr()
res4 = SymPyExpression(c_src4, 'c').return_expr()
assert res1[0] == Declaration(
Variable(
Symbol('a'),
type=IntBaseType(String('intc'))
)
)
assert res1[1] == Declaration(
Variable(
Symbol('b'),
type=IntBaseType(String('intc'))
)
)
assert res2[0] == Declaration(
Variable(
Symbol('a'),
type=FloatType(
String('float32'),
nbits=Integer(32),
nmant=Integer(23),
nexp=Integer(8)
)
)
)
assert res2[1] == Declaration(
Variable(
Symbol('b'),
type=FloatType(
String('float32'),
nbits=Integer(32),
nmant=Integer(23),
nexp=Integer(8)
)
)
)
assert res3[0] == Declaration(
Variable(
Symbol('a'),
type=IntBaseType(String('intc'))
)
)
assert res3[1] == Declaration(
Variable(
Symbol('b'),
type=FloatType(
String('float32'),
nbits=Integer(32),
nmant=Integer(23),
nexp=Integer(8)
)
)
)
assert res3[2] == Declaration(
Variable(
Symbol('c'),
type=IntBaseType(String('intc'))
)
)
assert res4[0] == Declaration(
Variable(
Symbol('x'),
type=IntBaseType(String('intc')),
value=Integer(1)
)
)
assert res4[1] == Declaration(
Variable(
Symbol('y'),
type=IntBaseType(String('intc')),
value=Integer(6)
)
)
assert res4[2] == Declaration(
Variable(
Symbol('p'),
type=FloatType(
String('float32'),
nbits=Integer(32),
nmant=Integer(23),
nexp=Integer(8)
),
value=Float('2.0', precision=53)
)
)
assert res4[3] == Declaration(
Variable(
Symbol('q'),
type=FloatType(
String('float32'),
nbits=Integer(32),
nmant=Integer(23),
nexp=Integer(8)
),
value=Float('9.67', precision=53)
)
)
def test_int():
c_src1 = 'int a = 1;'
c_src2 = (
'int a = 1;' + '\n' +
'int b = 2;' + '\n'
)
c_src3 = 'int a = 2.345, b = 5.67;'
c_src4 = 'int p = 6, q = 23.45;'
c_src5 = "int x = '0', y = 'a';"
c_src6 = "int r = true, s = false;"
# cin.TypeKind.UCHAR
c_src_type1 = (
"signed char a = 1, b = 5.1;"
)
# cin.TypeKind.SHORT
c_src_type2 = (
"short a = 1, b = 5.1;"
"signed short c = 1, d = 5.1;"
"short int e = 1, f = 5.1;"
"signed short int g = 1, h = 5.1;"
)
# cin.TypeKind.INT
c_src_type3 = (
"signed int a = 1, b = 5.1;"
"int c = 1, d = 5.1;"
)
# cin.TypeKind.LONG
c_src_type4 = (
"long a = 1, b = 5.1;"
"long int c = 1, d = 5.1;"
)
# cin.TypeKind.UCHAR
c_src_type5 = "unsigned char a = 1, b = 5.1;"
# cin.TypeKind.USHORT
c_src_type6 = (
"unsigned short a = 1, b = 5.1;"
"unsigned short int c = 1, d = 5.1;"
)
# cin.TypeKind.UINT
c_src_type7 = "unsigned int a = 1, b = 5.1;"
# cin.TypeKind.ULONG
c_src_type8 = (
"unsigned long a = 1, b = 5.1;"
"unsigned long int c = 1, d = 5.1;"
)
res1 = SymPyExpression(c_src1, 'c').return_expr()
res2 = SymPyExpression(c_src2, 'c').return_expr()
res3 = SymPyExpression(c_src3, 'c').return_expr()
res4 = SymPyExpression(c_src4, 'c').return_expr()
res5 = SymPyExpression(c_src5, 'c').return_expr()
res6 = SymPyExpression(c_src6, 'c').return_expr()
res_type1 = SymPyExpression(c_src_type1, 'c').return_expr()
res_type2 = SymPyExpression(c_src_type2, 'c').return_expr()
res_type3 = SymPyExpression(c_src_type3, 'c').return_expr()
res_type4 = SymPyExpression(c_src_type4, 'c').return_expr()
res_type5 = SymPyExpression(c_src_type5, 'c').return_expr()
res_type6 = SymPyExpression(c_src_type6, 'c').return_expr()
res_type7 = SymPyExpression(c_src_type7, 'c').return_expr()
res_type8 = SymPyExpression(c_src_type8, 'c').return_expr()
assert res1[0] == Declaration(
Variable(
Symbol('a'),
type=IntBaseType(String('intc')),
value=Integer(1)
)
)
assert res2[0] == Declaration(
Variable(
Symbol('a'),
type=IntBaseType(String('intc')),
value=Integer(1)
)
)
assert res2[1] == Declaration(
Variable(
Symbol('b'),
type=IntBaseType(String('intc')),
value=Integer(2)
)
)
assert res3[0] == Declaration(
Variable(
Symbol('a'),
type=IntBaseType(String('intc')),
value=Integer(2)
)
)
assert res3[1] == Declaration(
Variable(
Symbol('b'),
type=IntBaseType(String('intc')),
value=Integer(5)
)
)
assert res4[0] == Declaration(
Variable(
Symbol('p'),
type=IntBaseType(String('intc')),
value=Integer(6)
)
)
assert res4[1] == Declaration(
Variable(
Symbol('q'),
type=IntBaseType(String('intc')),
value=Integer(23)
)
)
assert res5[0] == Declaration(
Variable(
Symbol('x'),
type=IntBaseType(String('intc')),
value=Integer(48)
)
)
assert res5[1] == Declaration(
Variable(
Symbol('y'),
type=IntBaseType(String('intc')),
value=Integer(97)
)
)
assert res6[0] == Declaration(
Variable(
Symbol('r'),
type=IntBaseType(String('intc')),
value=Integer(1)
)
)
assert res6[1] == Declaration(
Variable(
Symbol('s'),
type=IntBaseType(String('intc')),
value=Integer(0)
)
)
assert res_type1[0] == Declaration(
Variable(
Symbol('a'),
type=SignedIntType(
String('int8'),
nbits=Integer(8)
),
value=Integer(1)
)
)
assert res_type1[1] == Declaration(
Variable(
Symbol('b'),
type=SignedIntType(
String('int8'),
nbits=Integer(8)
),
value=Integer(5)
)
)
assert res_type2[0] == Declaration(
Variable(
Symbol('a'),
type=SignedIntType(
String('int16'),
nbits=Integer(16)
),
value=Integer(1)
)
)
assert res_type2[1] == Declaration(
Variable(
Symbol('b'),
type=SignedIntType(
String('int16'),
nbits=Integer(16)
),
value=Integer(5)
)
)
assert res_type2[2] == Declaration(
Variable(Symbol('c'),
type=SignedIntType(
String('int16'),
nbits=Integer(16)
),
value=Integer(1)
)
)
assert res_type2[3] == Declaration(
Variable(
Symbol('d'),
type=SignedIntType(
String('int16'),
nbits=Integer(16)
),
value=Integer(5)
)
)
assert res_type2[4] == Declaration(
Variable(
Symbol('e'),
type=SignedIntType(
String('int16'),
nbits=Integer(16)
),
value=Integer(1)
)
)
assert res_type2[5] == Declaration(
Variable(
Symbol('f'),
type=SignedIntType(
String('int16'),
nbits=Integer(16)
),
value=Integer(5)
)
)
assert res_type2[6] == Declaration(
Variable(
Symbol('g'),
type=SignedIntType(
String('int16'),
nbits=Integer(16)
),
value=Integer(1)
)
)
assert res_type2[7] == Declaration(
Variable(
Symbol('h'),
type=SignedIntType(
String('int16'),
nbits=Integer(16)
),
value=Integer(5)
)
)
assert res_type3[0] == Declaration(
Variable(
Symbol('a'),
type=IntBaseType(String('intc')),
value=Integer(1)
)
)
assert res_type3[1] == Declaration(
Variable(
Symbol('b'),
type=IntBaseType(String('intc')),
value=Integer(5)
)
)
assert res_type3[2] == Declaration(
Variable(
Symbol('c'),
type=IntBaseType(String('intc')),
value=Integer(1)
)
)
assert res_type3[3] == Declaration(
Variable(
Symbol('d'),
type=IntBaseType(String('intc')),
value=Integer(5)
)
)
assert res_type4[0] == Declaration(
Variable(
Symbol('a'),
type=SignedIntType(
String('int64'),
nbits=Integer(64)
),
value=Integer(1)
)
)
assert res_type4[1] == Declaration(
Variable(
Symbol('b'),
type=SignedIntType(
String('int64'),
nbits=Integer(64)
),
value=Integer(5)
)
)
assert res_type4[2] == Declaration(
Variable(
Symbol('c'),
type=SignedIntType(
String('int64'),
nbits=Integer(64)
),
value=Integer(1)
)
)
assert res_type4[3] == Declaration(
Variable(
Symbol('d'),
type=SignedIntType(
String('int64'),
nbits=Integer(64)
),
value=Integer(5)
)
)
assert res_type5[0] == Declaration(
Variable(
Symbol('a'),
type=UnsignedIntType(
String('uint8'),
nbits=Integer(8)
),
value=Integer(1)
)
)
assert res_type5[1] == Declaration(
Variable(
Symbol('b'),
type=UnsignedIntType(
String('uint8'),
nbits=Integer(8)
),
value=Integer(5)
)
)
assert res_type6[0] == Declaration(
Variable(
Symbol('a'),
type=UnsignedIntType(
String('uint16'),
nbits=Integer(16)
),
value=Integer(1)
)
)
assert res_type6[1] == Declaration(
Variable(
Symbol('b'),
type=UnsignedIntType(
String('uint16'),
nbits=Integer(16)
),
value=Integer(5)
)
)
assert res_type6[2] == Declaration(
Variable(
Symbol('c'),
type=UnsignedIntType(
String('uint16'),
nbits=Integer(16)
),
value=Integer(1)
)
)
assert res_type6[3] == Declaration(
Variable(
Symbol('d'),
type=UnsignedIntType(
String('uint16'),
nbits=Integer(16)
),
value=Integer(5)
)
)
assert res_type7[0] == Declaration(
Variable(
Symbol('a'),
type=UnsignedIntType(
String('uint32'),
nbits=Integer(32)
),
value=Integer(1)
)
)
assert res_type7[1] == Declaration(
Variable(
Symbol('b'),
type=UnsignedIntType(
String('uint32'),
nbits=Integer(32)
),
value=Integer(5)
)
)
assert res_type8[0] == Declaration(
Variable(
Symbol('a'),
type=UnsignedIntType(
String('uint64'),
nbits=Integer(64)
),
value=Integer(1)
)
)
assert res_type8[1] == Declaration(
Variable(
Symbol('b'),
type=UnsignedIntType(
String('uint64'),
nbits=Integer(64)
),
value=Integer(5)
)
)
assert res_type8[2] == Declaration(
Variable(
Symbol('c'),
type=UnsignedIntType(
String('uint64'),
nbits=Integer(64)
),
value=Integer(1)
)
)
assert res_type8[3] == Declaration(
Variable(
Symbol('d'),
type=UnsignedIntType(
String('uint64'),
nbits=Integer(64)
),
value=Integer(5)
)
)
def test_float():
c_src1 = 'float a = 1.0;'
c_src2 = (
'float a = 1.25;' + '\n' +
'float b = 2.39;' + '\n'
)
c_src3 = 'float x = 1, y = 2;'
c_src4 = 'float p = 5, e = 7.89;'
c_src5 = 'float r = true, s = false;'
# cin.TypeKind.FLOAT
c_src_type1 = 'float x = 1, y = 2.5;'
# cin.TypeKind.DOUBLE
c_src_type2 = 'double x = 1, y = 2.5;'
# cin.TypeKind.LONGDOUBLE
c_src_type3 = 'long double x = 1, y = 2.5;'
res1 = SymPyExpression(c_src1, 'c').return_expr()
res2 = SymPyExpression(c_src2, 'c').return_expr()
res3 = SymPyExpression(c_src3, 'c').return_expr()
res4 = SymPyExpression(c_src4, 'c').return_expr()
res5 = SymPyExpression(c_src5, 'c').return_expr()
res_type1 = SymPyExpression(c_src_type1, 'c').return_expr()
res_type2 = SymPyExpression(c_src_type2, 'c').return_expr()
res_type3 = SymPyExpression(c_src_type3, 'c').return_expr()
assert res1[0] == Declaration(
Variable(
Symbol('a'),
type=FloatType(
String('float32'),
nbits=Integer(32),
nmant=Integer(23),
nexp=Integer(8)
),
value=Float('1.0', precision=53)
)
)
assert res2[0] == Declaration(
Variable(
Symbol('a'),
type=FloatType(
String('float32'),
nbits=Integer(32),
nmant=Integer(23),
nexp=Integer(8)
),
value=Float('1.25', precision=53)
)
)
assert res2[1] == Declaration(
Variable(
Symbol('b'),
type=FloatType(
String('float32'),
nbits=Integer(32),
nmant=Integer(23),
nexp=Integer(8)
),
value=Float('2.3900000000000001', precision=53)
)
)
assert res3[0] == Declaration(
Variable(
Symbol('x'),
type=FloatType(
String('float32'),
nbits=Integer(32),
nmant=Integer(23),
nexp=Integer(8)
),
value=Float('1.0', precision=53)
)
)
assert res3[1] == Declaration(
Variable(
Symbol('y'),
type=FloatType(
String('float32'),
nbits=Integer(32),
nmant=Integer(23),
nexp=Integer(8)
),
value=Float('2.0', precision=53)
)
)
assert res4[0] == Declaration(
Variable(
Symbol('p'),
type=FloatType(
String('float32'),
nbits=Integer(32),
nmant=Integer(23),
nexp=Integer(8)
),
value=Float('5.0', precision=53)
)
)
assert res4[1] == Declaration(
Variable(
Symbol('e'),
type=FloatType(
String('float32'),
nbits=Integer(32),
nmant=Integer(23),
nexp=Integer(8)
),
value=Float('7.89', precision=53)
)
)
assert res5[0] == Declaration(
Variable(
Symbol('r'),
type=FloatType(
String('float32'),
nbits=Integer(32),
nmant=Integer(23),
nexp=Integer(8)
),
value=Float('1.0', precision=53)
)
)
assert res5[1] == Declaration(
Variable(
Symbol('s'),
type=FloatType(
String('float32'),
nbits=Integer(32),
nmant=Integer(23),
nexp=Integer(8)
),
value=Float('0.0', precision=53)
)
)
assert res_type1[0] == Declaration(
Variable(
Symbol('x'),
type=FloatType(
String('float32'),
nbits=Integer(32),
nmant=Integer(23),
nexp=Integer(8)
),
value=Float('1.0', precision=53)
)
)
assert res_type1[1] == Declaration(
Variable(
Symbol('y'),
type=FloatType(
String('float32'),
nbits=Integer(32),
nmant=Integer(23),
nexp=Integer(8)
),
value=Float('2.5', precision=53)
)
)
assert res_type2[0] == Declaration(
Variable(
Symbol('x'),
type=FloatType(
String('float64'),
nbits=Integer(64),
nmant=Integer(52),
nexp=Integer(11)
),
value=Float('1.0', precision=53)
)
)
assert res_type2[1] == Declaration(
Variable(
Symbol('y'),
type=FloatType(
String('float64'),
nbits=Integer(64),
nmant=Integer(52),
nexp=Integer(11)
),
value=Float('2.5', precision=53)
)
)
assert res_type3[0] == Declaration(
Variable(
Symbol('x'),
type=FloatType(
String('float80'),
nbits=Integer(80),
nmant=Integer(63),
nexp=Integer(15)
),
value=Float('1.0', precision=53)
)
)
assert res_type3[1] == Declaration(
Variable(
Symbol('y'),
type=FloatType(
String('float80'),
nbits=Integer(80),
nmant=Integer(63),
nexp=Integer(15)
),
value=Float('2.5', precision=53)
)
)
def test_bool():
c_src1 = (
'bool a = true, b = false;'
)
c_src2 = (
'bool a = 1, b = 0;'
)
c_src3 = (
'bool a = 10, b = 20;'
)
c_src4 = (
'bool a = 19.1, b = 9.0, c = 0.0;'
)
res1 = SymPyExpression(c_src1, 'c').return_expr()
res2 = SymPyExpression(c_src2, 'c').return_expr()
res3 = SymPyExpression(c_src3, 'c').return_expr()
res4 = SymPyExpression(c_src4, 'c').return_expr()
assert res1[0] == Declaration(
Variable(Symbol('a'),
type=Type(String('bool')),
value=true
)
)
assert res1[1] == Declaration(
Variable(Symbol('b'),
type=Type(String('bool')),
value=false
)
)
assert res2[0] == Declaration(
Variable(Symbol('a'),
type=Type(String('bool')),
value=true)
)
assert res2[1] == Declaration(
Variable(Symbol('b'),
type=Type(String('bool')),
value=false
)
)
assert res3[0] == Declaration(
Variable(Symbol('a'),
type=Type(String('bool')),
value=true
)
)
assert res3[1] == Declaration(
Variable(Symbol('b'),
type=Type(String('bool')),
value=true
)
)
assert res4[0] == Declaration(
Variable(Symbol('a'),
type=Type(String('bool')),
value=true)
)
assert res4[1] == Declaration(
Variable(Symbol('b'),
type=Type(String('bool')),
value=true
)
)
assert res4[2] == Declaration(
Variable(Symbol('c'),
type=Type(String('bool')),
value=false
)
)
def test_function():
c_src1 = (
'void fun1()' + '\n' +
'{' + '\n' +
'int a;' + '\n' +
'}'
)
c_src2 = (
'int fun2()' + '\n' +
'{'+ '\n' +
'int a;' + '\n' +
'return a;' + '\n' +
'}'
)
c_src3 = (
'float fun3()' + '\n' +
'{' + '\n' +
'float b;' + '\n' +
'return b;' + '\n' +
'}'
)
c_src4 = (
'float fun4()' + '\n' +
'{}'
)
res1 = SymPyExpression(c_src1, 'c').return_expr()
res2 = SymPyExpression(c_src2, 'c').return_expr()
res3 = SymPyExpression(c_src3, 'c').return_expr()
res4 = SymPyExpression(c_src4, 'c').return_expr()
assert res1[0] == FunctionDefinition(
NoneToken(),
name=String('fun1'),
parameters=(),
body=CodeBlock(
Declaration(
Variable(
Symbol('a'),
type=IntBaseType(String('intc'))
)
)
)
)
assert res2[0] == FunctionDefinition(
IntBaseType(String('intc')),
name=String('fun2'),
parameters=(),
body=CodeBlock(
Declaration(
Variable(
Symbol('a'),
type=IntBaseType(String('intc'))
)
),
Return('a')
)
)
assert res3[0] == FunctionDefinition(
FloatType(
String('float32'),
nbits=Integer(32),
nmant=Integer(23),
nexp=Integer(8)
),
name=String('fun3'),
parameters=(),
body=CodeBlock(
Declaration(
Variable(
Symbol('b'),
type=FloatType(
String('float32'),
nbits=Integer(32),
nmant=Integer(23),
nexp=Integer(8)
)
)
),
Return('b')
)
)
assert res4[0] == FunctionPrototype(
FloatType(
String('float32'),
nbits=Integer(32),
nmant=Integer(23),
nexp=Integer(8)
),
name=String('fun4'),
parameters=()
)
def test_parameters():
c_src1 = (
'void fun1( int a)' + '\n' +
'{' + '\n' +
'int i;' + '\n' +
'}'
)
c_src2 = (
'int fun2(float x, float y)' + '\n' +
'{'+ '\n' +
'int a;' + '\n' +
'return a;' + '\n' +
'}'
)
c_src3 = (
'float fun3(int p, float q, int r)' + '\n' +
'{' + '\n' +
'float b;' + '\n' +
'return b;' + '\n' +
'}'
)
res1 = SymPyExpression(c_src1, 'c').return_expr()
res2 = SymPyExpression(c_src2, 'c').return_expr()
res3 = SymPyExpression(c_src3, 'c').return_expr()
assert res1[0] == FunctionDefinition(
NoneToken(),
name=String('fun1'),
parameters=(
Variable(
Symbol('a'),
type=IntBaseType(String('intc'))
),
),
body=CodeBlock(
Declaration(
Variable(
Symbol('i'),
type=IntBaseType(String('intc'))
)
)
)
)
assert res2[0] == FunctionDefinition(
IntBaseType(String('intc')),
name=String('fun2'),
parameters=(
Variable(
Symbol('x'),
type=FloatType(
String('float32'),
nbits=Integer(32),
nmant=Integer(23),
nexp=Integer(8)
)
),
Variable(
Symbol('y'),
type=FloatType(
String('float32'),
nbits=Integer(32),
nmant=Integer(23),
nexp=Integer(8)
)
)
),
body=CodeBlock(
Declaration(
Variable(
Symbol('a'),
type=IntBaseType(String('intc'))
)
),
Return('a')
)
)
assert res3[0] == FunctionDefinition(
FloatType(
String('float32'),
nbits=Integer(32),
nmant=Integer(23),
nexp=Integer(8)
),
name=String('fun3'),
parameters=(
Variable(
Symbol('p'),
type=IntBaseType(String('intc'))
),
Variable(
Symbol('q'),
type=FloatType(
String('float32'),
nbits=Integer(32),
nmant=Integer(23),
nexp=Integer(8)
)
),
Variable(
Symbol('r'),
type=IntBaseType(String('intc'))
)
),
body=CodeBlock(
Declaration(
Variable(
Symbol('b'),
type=FloatType(
String('float32'),
nbits=Integer(32),
nmant=Integer(23),
nexp=Integer(8)
)
)
),
Return('b')
)
)
def test_function_call():
c_src1 = (
'int fun1(int x)' + '\n' +
'{' + '\n' +
'return x;' + '\n' +
'}' + '\n' +
'void caller()' + '\n' +
'{' + '\n' +
'int x = fun1(2);' + '\n' +
'}'
)
c_src2 = (
'int fun2(int a, int b, int c)' + '\n' +
'{' + '\n' +
'return a;' + '\n' +
'}' + '\n' +
'void caller()' + '\n' +
'{' + '\n' +
'int y = fun2(2, 3, 4);' + '\n' +
'}'
)
c_src3 = (
'int fun3(int a, int b, int c)' + '\n' +
'{' + '\n' +
'return b;' + '\n' +
'}' + '\n' +
'void caller()' + '\n' +
'{' + '\n' +
'int p;' + '\n' +
'int q;' + '\n' +
'int r;' + '\n' +
'int z = fun3(p, q, r);' + '\n' +
'}'
)
c_src4 = (
'int fun4(float a, float b, int c)' + '\n' +
'{' + '\n' +
'return c;' + '\n' +
'}' + '\n' +
'void caller()' + '\n' +
'{' + '\n' +
'float x;' + '\n' +
'float y;' + '\n' +
'int z;' + '\n' +
'int i = fun4(x, y, z)' + '\n' +
'}'
)
c_src5 = (
'int fun()' + '\n' +
'{' + '\n' +
'return 1;' + '\n' +
'}' + '\n' +
'void caller()' + '\n' +
'{' + '\n' +
'int a = fun()' + '\n' +
'}'
)
res1 = SymPyExpression(c_src1, 'c').return_expr()
res2 = SymPyExpression(c_src2, 'c').return_expr()
res3 = SymPyExpression(c_src3, 'c').return_expr()
res4 = SymPyExpression(c_src4, 'c').return_expr()
res5 = SymPyExpression(c_src5, 'c').return_expr()
assert res1[0] == FunctionDefinition(
IntBaseType(String('intc')),
name=String('fun1'),
parameters=(Variable(Symbol('x'),
type=IntBaseType(String('intc'))
),
),
body=CodeBlock(
Return('x')
)
)
assert res1[1] == FunctionDefinition(
NoneToken(),
name=String('caller'),
parameters=(),
body=CodeBlock(
Declaration(
Variable(Symbol('x'),
value=FunctionCall(String('fun1'),
function_args=(
Integer(2),
)
)
)
)
)
)
assert res2[0] == FunctionDefinition(
IntBaseType(String('intc')),
name=String('fun2'),
parameters=(Variable(Symbol('a'),
type=IntBaseType(String('intc'))
),
Variable(Symbol('b'),
type=IntBaseType(String('intc'))
),
Variable(Symbol('c'),
type=IntBaseType(String('intc'))
)
),
body=CodeBlock(
Return('a')
)
)
assert res2[1] == FunctionDefinition(
NoneToken(),
name=String('caller'),
parameters=(),
body=CodeBlock(
Declaration(
Variable(Symbol('y'),
value=FunctionCall(
String('fun2'),
function_args=(
Integer(2),
Integer(3),
Integer(4)
)
)
)
)
)
)
assert res3[0] == FunctionDefinition(
IntBaseType(String('intc')),
name=String('fun3'),
parameters=(
Variable(Symbol('a'),
type=IntBaseType(String('intc'))
),
Variable(Symbol('b'),
type=IntBaseType(String('intc'))
),
Variable(Symbol('c'),
type=IntBaseType(String('intc'))
)
),
body=CodeBlock(
Return('b')
)
)
assert res3[1] == FunctionDefinition(
NoneToken(),
name=String('caller'),
parameters=(),
body=CodeBlock(
Declaration(
Variable(Symbol('p'),
type=IntBaseType(String('intc'))
)
),
Declaration(
Variable(Symbol('q'),
type=IntBaseType(String('intc'))
)
),
Declaration(
Variable(Symbol('r'),
type=IntBaseType(String('intc'))
)
),
Declaration(
Variable(Symbol('z'),
value=FunctionCall(
String('fun3'),
function_args=(
Symbol('p'),
Symbol('q'),
Symbol('r')
)
)
)
)
)
)
assert res4[0] == FunctionDefinition(
IntBaseType(String('intc')),
name=String('fun4'),
parameters=(Variable(Symbol('a'),
type=FloatType(
String('float32'),
nbits=Integer(32),
nmant=Integer(23),
nexp=Integer(8)
)
),
Variable(Symbol('b'),
type=FloatType(
String('float32'),
nbits=Integer(32),
nmant=Integer(23),
nexp=Integer(8)
)
),
Variable(Symbol('c'),
type=IntBaseType(String('intc'))
)
),
body=CodeBlock(
Return('c')
)
)
assert res4[1] == FunctionDefinition(
NoneToken(),
name=String('caller'),
parameters=(),
body=CodeBlock(
Declaration(
Variable(Symbol('x'),
type=FloatType(
String('float32'),
nbits=Integer(32),
nmant=Integer(23),
nexp=Integer(8)
)
)
),
Declaration(
Variable(Symbol('y'),
type=FloatType(
String('float32'),
nbits=Integer(32),
nmant=Integer(23),
nexp=Integer(8)
)
)
),
Declaration(
Variable(Symbol('z'),
type=IntBaseType(String('intc'))
)
),
Declaration(
Variable(Symbol('i'),
value=FunctionCall(String('fun4'),
function_args=(
Symbol('x'),
Symbol('y'),
Symbol('z')
)
)
)
)
)
)
assert res5[0] == FunctionDefinition(
IntBaseType(String('intc')),
name=String('fun'),
parameters=(),
body=CodeBlock(
Return('')
)
)
assert res5[1] == FunctionDefinition(
NoneToken(),
name=String('caller'),
parameters=(),
body=CodeBlock(
Declaration(
Variable(Symbol('a'),
value=FunctionCall(String('fun'),
function_args=()
)
)
)
)
)
def test_parse():
c_src1 = (
'int a;' + '\n' +
'int b;' + '\n'
)
c_src2 = (
'void fun1()' + '\n' +
'{' + '\n' +
'int a;' + '\n' +
'}'
)
f1 = open('..a.h', 'w')
f2 = open('..b.h', 'w')
f1.write(c_src1)
f2. write(c_src2)
f1.close()
f2.close()
res1 = SymPyExpression('..a.h', 'c').return_expr()
res2 = SymPyExpression('..b.h', 'c').return_expr()
os.remove('..a.h')
os.remove('..b.h')
assert res1[0] == Declaration(
Variable(
Symbol('a'),
type=IntBaseType(String('intc'))
)
)
assert res1[1] == Declaration(
Variable(
Symbol('b'),
type=IntBaseType(String('intc'))
)
)
assert res2[0] == FunctionDefinition(
NoneToken(),
name=String('fun1'),
parameters=(),
body=CodeBlock(
Declaration(
Variable(
Symbol('a'),
type=IntBaseType(String('intc'))
)
)
)
)
def test_binary_operators():
c_src1 = (
'void func()'+
'{' + '\n' +
'int a;' + '\n' +
'a = 1;' + '\n' +
'}'
)
c_src2 = (
'void func()'+
'{' + '\n' +
'int a = 0;' + '\n' +
'a = a + 1;' + '\n' +
'a = 3*a - 10;' + '\n' +
'}'
)
c_src3 = (
'void func()'+
'{' + '\n' +
'int a = 10;' + '\n' +
'a = 1 + a - 3 * 6;' + '\n' +
'}'
)
c_src4 = (
'void func()'+
'{' + '\n' +
'int a;' + '\n' +
'int b;' + '\n' +
'a = 100;' + '\n' +
'b = a*a + a*a + a + 19*a + 1 + 24;' + '\n' +
'}'
)
c_src5 = (
'void func()'+
'{' + '\n' +
'int a;' + '\n' +
'int b;' + '\n' +
'int c;' + '\n' +
'int d;' + '\n' +
'a = 1;' + '\n' +
'b = 2;' + '\n' +
'c = b;' + '\n' +
'd = ((a+b)*(a+c))*((c-d)*(a+c));' + '\n' +
'}'
)
c_src6 = (
'void func()'+
'{' + '\n' +
'int a;' + '\n' +
'int b;' + '\n' +
'int c;' + '\n' +
'int d;' + '\n' +
'a = 1;' + '\n' +
'b = 2;' + '\n' +
'c = 3;' + '\n' +
'd = (a*a*a*a + 3*b*b + b + b + c*d);' + '\n' +
'}'
)
c_src7 = (
'void func()'+
'{' + '\n' +
'float a;' + '\n' +
'a = 1.01;' + '\n' +
'}'
)
c_src8 = (
'void func()'+
'{' + '\n' +
'float a;' + '\n' +
'a = 10.0 + 2.5;' + '\n' +
'}'
)
c_src9 = (
'void func()'+
'{' + '\n' +
'float a;' + '\n' +
'a = 10.0 / 2.5;' + '\n' +
'}'
)
c_src10 = (
'void func()'+
'{' + '\n' +
'int a;' + '\n' +
'a = 100 / 4;' + '\n' +
'}'
)
c_src11 = (
'void func()'+
'{' + '\n' +
'int a;' + '\n' +
'a = 20 - 100 / 4 * 5 + 10;' + '\n' +
'}'
)
c_src12 = (
'void func()'+
'{' + '\n' +
'int a;' + '\n' +
'a = (20 - 100) / 4 * (5 + 10);' + '\n' +
'}'
)
c_src13 = (
'void func()'+
'{' + '\n' +
'int a;' + '\n' +
'int b;' + '\n' +
'float c;' + '\n' +
'c = b/a;' + '\n' +
'}'
)
c_src14 = (
'void func()'+
'{' + '\n' +
'int a = 2;' + '\n' +
'int d = 5;' + '\n' +
'int n = 10;' + '\n' +
'int s;' + '\n' +
's = (a/2)*(2*a + (n-1)*d);' + '\n' +
'}'
)
c_src15 = (
'void func()'+
'{' + '\n' +
'int a;' + '\n' +
'a = 1 % 2;' + '\n' +
'}'
)
c_src16 = (
'void func()'+
'{' + '\n' +
'int a = 2;' + '\n' +
'int b;' + '\n' +
'b = a % 3;' + '\n' +
'}'
)
c_src17 = (
'void func()'+
'{' + '\n' +
'int a = 100;' + '\n' +
'int b = 3;' + '\n' +
'int c;' + '\n' +
'c = a % b;' + '\n' +
'}'
)
c_src18 = (
'void func()'+
'{' + '\n' +
'int a = 100;' + '\n' +
'int b = 3;' + '\n' +
'int mod = 1000000007;' + '\n' +
'int c;' + '\n' +
'c = (a + b * (100/a)) % mod;' + '\n' +
'}'
)
c_src19 = (
'void func()'+
'{' + '\n' +
'int a = 100;' + '\n' +
'int b = 3;' + '\n' +
'int mod = 1000000007;' + '\n' +
'int c;' + '\n' +
'c = ((a % mod + b % mod) % mod *(' \
'a % mod - b % mod) % mod) % mod;' + '\n' +
'}'
)
c_src20 = (
'void func()'+
'{' + '\n' +
'bool a' + '\n' +
'bool b;' + '\n' +
'a = 1 == 2;' + '\n' +
'b = 1 != 2;' + '\n' +
'}'
)
c_src21 = (
'void func()'+
'{' + '\n' +
'bool a;' + '\n' +
'bool b;' + '\n' +
'bool c;' + '\n' +
'bool d;' + '\n' +
'a = 1 == 2;' + '\n' +
'b = 1 <= 2;' + '\n' +
'c = 1 > 2;' + '\n' +
'd = 1 >= 2;' + '\n' +
'}'
)
c_src22 = (
'void func()'+
'{' + '\n' +
'int a = 1;' + '\n' +
'int b = 2;' + '\n' +
'bool c1;' + '\n' +
'bool c2;' + '\n' +
'bool c3;' + '\n' +
'bool c4;' + '\n' +
'bool c5;' + '\n' +
'bool c6;' + '\n' +
'bool c7;' + '\n' +
'bool c8;' + '\n' +
'c1 = a == 1;' + '\n' +
'c2 = b == 2;' + '\n' +
'c3 = 1 != a;' + '\n' +
'c4 = 1 != b;' + '\n' +
'c5 = a < 0;' + '\n' +
'c6 = b <= 10;' + '\n' +
'c7 = a > 0;' + '\n' +
'c8 = b >= 11;' + '\n' +
'}'
)
c_src23 = (
'void func()'+
'{' + '\n' +
'int a = 3;' + '\n' +
'int b = 4;' + '\n' +
'bool c1;' + '\n' +
'bool c2;' + '\n' +
'bool c3;' + '\n' +
'bool c4;' + '\n' +
'bool c5;' + '\n' +
'bool c6;' + '\n' +
'c1 = a == b;' + '\n' +
'c2 = a != b;' + '\n' +
'c3 = a < b;' + '\n' +
'c4 = a <= b;' + '\n' +
'c5 = a > b;' + '\n' +
'c6 = a >= b;' + '\n' +
'}'
)
c_src24 = (
'void func()'+
'{' + '\n' +
'float a = 1.25'
'float b = 2.5;' + '\n' +
'bool c1;' + '\n' +
'bool c2;' + '\n' +
'bool c3;' + '\n' +
'bool c4;' + '\n' +
'c1 = a == 1.25;' + '\n' +
'c2 = b == 2.54;' + '\n' +
'c3 = 1.2 != a;' + '\n' +
'c4 = 1.5 != b;' + '\n' +
'}'
)
c_src25 = (
'void func()'+
'{' + '\n' +
'float a = 1.25' + '\n' +
'float b = 2.5;' + '\n' +
'bool c1;' + '\n' +
'bool c2;' + '\n' +
'bool c3;' + '\n' +
'bool c4;' + '\n' +
'bool c5;' + '\n' +
'bool c6;' + '\n' +
'c1 = a == b;' + '\n' +
'c2 = a != b;' + '\n' +
'c3 = a < b;' + '\n' +
'c4 = a <= b;' + '\n' +
'c5 = a > b;' + '\n' +
'c6 = a >= b;' + '\n' +
'}'
)
c_src26 = (
'void func()'+
'{' + '\n' +
'bool c1;' + '\n' +
'bool c2;' + '\n' +
'bool c3;' + '\n' +
'bool c4;' + '\n' +
'bool c5;' + '\n' +
'bool c6;' + '\n' +
'c1 = true == true;' + '\n' +
'c2 = true == false;' + '\n' +
'c3 = false == false;' + '\n' +
'c4 = true != true;' + '\n' +
'c5 = true != false;' + '\n' +
'c6 = false != false;' + '\n' +
'}'
)
c_src27 = (
'void func()'+
'{' + '\n' +
'bool c1;' + '\n' +
'bool c2;' + '\n' +
'bool c3;' + '\n' +
'bool c4;' + '\n' +
'bool c5;' + '\n' +
'bool c6;' + '\n' +
'c1 = true && true;' + '\n' +
'c2 = true && false;' + '\n' +
'c3 = false && false;' + '\n' +
'c4 = true || true;' + '\n' +
'c5 = true || false;' + '\n' +
'c6 = false || false;' + '\n' +
'}'
)
c_src28 = (
'void func()'+
'{' + '\n' +
'bool a;' + '\n' +
'bool c1;' + '\n' +
'bool c2;' + '\n' +
'bool c3;' + '\n' +
'bool c4;' + '\n' +
'c1 = a && true;' + '\n' +
'c2 = false && a;' + '\n' +
'c3 = true || a;' + '\n' +
'c4 = a || false;' + '\n' +
'}'
)
c_src29 = (
'void func()'+
'{' + '\n' +
'int a;' + '\n' +
'bool c1;' + '\n' +
'bool c2;' + '\n' +
'bool c3;' + '\n' +
'bool c4;' + '\n' +
'c1 = a && 1;' + '\n' +
'c2 = a && 0;' + '\n' +
'c3 = a || 1;' + '\n' +
'c4 = 0 || a;' + '\n' +
'}'
)
c_src30 = (
'void func()'+
'{' + '\n' +
'int a;' + '\n' +
'int b;' + '\n' +
'bool c;'+ '\n' +
'bool d;'+ '\n' +
'bool c1;' + '\n' +
'bool c2;' + '\n' +
'bool c3;' + '\n' +
'bool c4;' + '\n' +
'bool c5;' + '\n' +
'bool c6;' + '\n' +
'c1 = a && b;' + '\n' +
'c2 = a && c;' + '\n' +
'c3 = c && d;' + '\n' +
'c4 = a || b;' + '\n' +
'c5 = a || c;' + '\n' +
'c6 = c || d;' + '\n' +
'}'
)
c_src_raise1 = (
'void func()'+
'{' + '\n' +
'int a;' + '\n' +
'a = -1;' + '\n' +
'}'
)
c_src_raise2 = (
'void func()'+
'{' + '\n' +
'int a;' + '\n' +
'a = -+1;' + '\n' +
'}'
)
c_src_raise3 = (
'void func()'+
'{' + '\n' +
'int a;' + '\n' +
'a = 2*-2;' + '\n' +
'}'
)
c_src_raise4 = (
'void func()'+
'{' + '\n' +
'int a;' + '\n' +
'a = (int)2.0;' + '\n' +
'}'
)
c_src_raise5 = (
'void func()'+
'{' + '\n' +
'int a=100;' + '\n' +
'a = (a==100)?(1):(0);' + '\n' +
'}'
)
res1 = SymPyExpression(c_src1, 'c').return_expr()
res2 = SymPyExpression(c_src2, 'c').return_expr()
res3 = SymPyExpression(c_src3, 'c').return_expr()
res4 = SymPyExpression(c_src4, 'c').return_expr()
res5 = SymPyExpression(c_src5, 'c').return_expr()
res6 = SymPyExpression(c_src6, 'c').return_expr()
res7 = SymPyExpression(c_src7, 'c').return_expr()
res8 = SymPyExpression(c_src8, 'c').return_expr()
res9 = SymPyExpression(c_src9, 'c').return_expr()
res10 = SymPyExpression(c_src10, 'c').return_expr()
res11 = SymPyExpression(c_src11, 'c').return_expr()
res12 = SymPyExpression(c_src12, 'c').return_expr()
res13 = SymPyExpression(c_src13, 'c').return_expr()
res14 = SymPyExpression(c_src14, 'c').return_expr()
res15 = SymPyExpression(c_src15, 'c').return_expr()
res16 = SymPyExpression(c_src16, 'c').return_expr()
res17 = SymPyExpression(c_src17, 'c').return_expr()
res18 = SymPyExpression(c_src18, 'c').return_expr()
res19 = SymPyExpression(c_src19, 'c').return_expr()
res20 = SymPyExpression(c_src20, 'c').return_expr()
res21 = SymPyExpression(c_src21, 'c').return_expr()
res22 = SymPyExpression(c_src22, 'c').return_expr()
res23 = SymPyExpression(c_src23, 'c').return_expr()
res24 = SymPyExpression(c_src24, 'c').return_expr()
res25 = SymPyExpression(c_src25, 'c').return_expr()
res26 = SymPyExpression(c_src26, 'c').return_expr()
res27 = SymPyExpression(c_src27, 'c').return_expr()
res28 = SymPyExpression(c_src28, 'c').return_expr()
res29 = SymPyExpression(c_src29, 'c').return_expr()
res30 = SymPyExpression(c_src30, 'c').return_expr()
assert res1[0] == FunctionDefinition(
NoneToken(),
name=String('func'),
parameters=(),
body=CodeBlock(
Declaration(
Variable(Symbol('a'),
type=IntBaseType(String('intc'))
)
),
Assignment(Variable(Symbol('a')), Integer(1))
)
)
assert res2[0] == FunctionDefinition(
NoneToken(),
name=String('func'),
parameters=(),
body=CodeBlock(
Declaration(
Variable(Symbol('a'),
type=IntBaseType(String('intc')),
value=Integer(0))),
Assignment(
Variable(Symbol('a')),
Add(Symbol('a'),
Integer(1))
),
Assignment(Variable(Symbol('a')),
Add(
Mul(
Integer(3),
Symbol('a')),
Integer(-10)
)
)
)
)
assert res3[0] == FunctionDefinition(
NoneToken(),
name=String('func'),
parameters=(),
body=CodeBlock(
Declaration(
Variable(Symbol('a'),
type=IntBaseType(String('intc')),
value=Integer(10)
)
),
Assignment(
Variable(Symbol('a')),
Add(
Symbol('a'),
Integer(-17)
)
)
)
)
assert res4[0] == FunctionDefinition(
NoneToken(),
name=String('func'),
parameters=(),
body=CodeBlock(
Declaration(
Variable(Symbol('a'),
type=IntBaseType(String('intc'))
)
),
Declaration(
Variable(Symbol('b'),
type=IntBaseType(String('intc'))
)
),
Assignment(
Variable(Symbol('a')),
Integer(100)),
Assignment(
Variable(Symbol('b')),
Add(
Mul(
Integer(2),
Pow(
Symbol('a'),
Integer(2))
),
Mul(
Integer(20),
Symbol('a')),
Integer(25)
)
)
)
)
assert res5[0] == FunctionDefinition(
NoneToken(),
name=String('func'),
parameters=(),
body=CodeBlock(
Declaration(
Variable(Symbol('a'),
type=IntBaseType(String('intc'))
)
),
Declaration(
Variable(Symbol('b'),
type=IntBaseType(String('intc'))
)
),
Declaration(
Variable(Symbol('c'),
type=IntBaseType(String('intc'))
)
),
Declaration(
Variable(Symbol('d'),
type=IntBaseType(String('intc'))
)
),
Assignment(
Variable(Symbol('a')),
Integer(1)),
Assignment(
Variable(Symbol('b')),
Integer(2)
),
Assignment(
Variable(Symbol('c')),
Symbol('b')),
Assignment(
Variable(Symbol('d')),
Mul(
Add(
Symbol('a'),
Symbol('b')),
Pow(
Add(
Symbol('a'),
Symbol('c')
),
Integer(2)
),
Add(
Symbol('c'),
Mul(
Integer(-1),
Symbol('d')
)
)
)
)
)
)
assert res6[0] == FunctionDefinition(
NoneToken(),
name=String('func'),
parameters=(),
body=CodeBlock(
Declaration(
Variable(Symbol('a'),
type=IntBaseType(String('intc'))
)
),
Declaration(
Variable(Symbol('b'),
type=IntBaseType(String('intc'))
)
),
Declaration(
Variable(Symbol('c'),
type=IntBaseType(String('intc'))
)
),
Declaration(
Variable(Symbol('d'),
type=IntBaseType(String('intc'))
)
),
Assignment(
Variable(Symbol('a')),
Integer(1)
),
Assignment(
Variable(Symbol('b')),
Integer(2)
),
Assignment(
Variable(Symbol('c')),
Integer(3)
),
Assignment(
Variable(Symbol('d')),
Add(
Pow(
Symbol('a'),
Integer(4)
),
Mul(
Integer(3),
Pow(
Symbol('b'),
Integer(2)
)
),
Mul(
Integer(2),
Symbol('b')
),
Mul(
Symbol('c'),
Symbol('d')
)
)
)
)
)
assert res7[0] == FunctionDefinition(
NoneToken(),
name=String('func'),
parameters=(),
body=CodeBlock(
Declaration(
Variable(Symbol('a'),
type=FloatType(
String('float32'),
nbits=Integer(32),
nmant=Integer(23),
nexp=Integer(8)
)
)
),
Assignment(
Variable(Symbol('a')),
Float('1.01', precision=53)
)
)
)
assert res8[0] == FunctionDefinition(
NoneToken(),
name=String('func'),
parameters=(),
body=CodeBlock(
Declaration(
Variable(Symbol('a'),
type=FloatType(
String('float32'),
nbits=Integer(32),
nmant=Integer(23),
nexp=Integer(8)
)
)
),
Assignment(
Variable(Symbol('a')),
Float('12.5', precision=53)
)
)
)
assert res9[0] == FunctionDefinition(
NoneToken(),
name=String('func'),
parameters=(),
body=CodeBlock(
Declaration(
Variable(Symbol('a'),
type=FloatType(
String('float32'),
nbits=Integer(32),
nmant=Integer(23),
nexp=Integer(8)
)
)
),
Assignment(
Variable(Symbol('a')),
Float('4.0', precision=53)
)
)
)
assert res10[0] == FunctionDefinition(
NoneToken(),
name=String('func'),
parameters=(),
body=CodeBlock(
Declaration(
Variable(Symbol('a'),
type=IntBaseType(String('intc'))
)
),
Assignment(
Variable(Symbol('a')),
Integer(25)
)
)
)
assert res11[0] == FunctionDefinition(
NoneToken(),
name=String('func'),
parameters=(),
body=CodeBlock(
Declaration(
Variable(Symbol('a'),
type=IntBaseType(String('intc'))
)
),
Assignment(
Variable(Symbol('a')),
Integer(-95)
)
)
)
assert res12[0] == FunctionDefinition(
NoneToken(),
name=String('func'),
parameters=(),
body=CodeBlock(
Declaration(
Variable(Symbol('a'),
type=IntBaseType(String('intc'))
)
),
Assignment(
Variable(Symbol('a')),
Integer(-300)
)
)
)
assert res13[0] == FunctionDefinition(
NoneToken(),
name=String('func'),
parameters=(),
body=CodeBlock(
Declaration(
Variable(Symbol('a'),
type=IntBaseType(String('intc'))
)
),
Declaration(
Variable(Symbol('b'),
type=IntBaseType(String('intc'))
)
),
Declaration(
Variable(Symbol('c'),
type=FloatType(
String('float32'),
nbits=Integer(32),
nmant=Integer(23),
nexp=Integer(8)
)
)
),
Assignment(
Variable(Symbol('c')),
Mul(
Pow(
Symbol('a'),
Integer(-1)
),
Symbol('b')
)
)
)
)
assert res14[0] == FunctionDefinition(
NoneToken(),
name=String('func'),
parameters=(),
body=CodeBlock(
Declaration(
Variable(Symbol('a'),
type=IntBaseType(String('intc')),
value=Integer(2)
)
),
Declaration(
Variable(Symbol('d'),
type=IntBaseType(String('intc')),
value=Integer(5)
)
),
Declaration(
Variable(Symbol('n'),
type=IntBaseType(String('intc')),
value=Integer(10)
)
),
Declaration(
Variable(Symbol('s'),
type=IntBaseType(String('intc'))
)
),
Assignment(
Variable(Symbol('s')),
Mul(
Rational(1, 2),
Symbol('a'),
Add(
Mul(
Integer(2),
Symbol('a')
),
Mul(
Symbol('d'),
Add(
Symbol('n'),
Integer(-1)
)
)
)
)
)
)
)
assert res15[0] == FunctionDefinition(
NoneToken(),
name=String('func'),
parameters=(),
body=CodeBlock(
Declaration(
Variable(Symbol('a'),
type=IntBaseType(String('intc'))
)
),
Assignment(
Variable(Symbol('a')),
Integer(1)
)
)
)
assert res16[0] == FunctionDefinition(
NoneToken(),
name=String('func'),
parameters=(),
body=CodeBlock(
Declaration(
Variable(Symbol('a'),
type=IntBaseType(String('intc')),
value=Integer(2)
)
),
Declaration(
Variable(Symbol('b'),
type=IntBaseType(String('intc'))
)
),
Assignment(
Variable(Symbol('b')),
Mod(
Symbol('a'),
Integer(3)
)
)
)
)
assert res17[0] == FunctionDefinition(
NoneToken(),
name=String('func'),
parameters=(),
body=CodeBlock(
Declaration(
Variable(Symbol('a'),
type=IntBaseType(String('intc')),
value=Integer(100)
)
),
Declaration(
Variable(Symbol('b'),
type=IntBaseType(String('intc')),
value=Integer(3)
)
),
Declaration(
Variable(Symbol('c'),
type=IntBaseType(String('intc'))
)
),
Assignment(
Variable(Symbol('c')),
Mod(
Symbol('a'),
Symbol('b')
)
)
)
)
assert res18[0] == FunctionDefinition(
NoneToken(),
name=String('func'),
parameters=(),
body=CodeBlock(
Declaration(
Variable(Symbol('a'),
type=IntBaseType(String('intc')),
value=Integer(100)
)
),
Declaration(
Variable(Symbol('b'),
type=IntBaseType(String('intc')),
value=Integer(3)
)
),
Declaration(
Variable(Symbol('mod'),
type=IntBaseType(String('intc')),
value=Integer(1000000007)
)
),
Declaration(
Variable(Symbol('c'),
type=IntBaseType(String('intc'))
)
),
Assignment(
Variable(Symbol('c')),
Mod(
Add(
Symbol('a'),
Mul(
Integer(100),
Pow(
Symbol('a'),
Integer(-1)
),
Symbol('b')
)
),
Symbol('mod')
)
)
)
)
assert res19[0] == FunctionDefinition(
NoneToken(),
name=String('func'),
parameters=(),
body=CodeBlock(
Declaration(
Variable(Symbol('a'),
type=IntBaseType(String('intc')),
value=Integer(100)
)
),
Declaration(
Variable(Symbol('b'),
type=IntBaseType(String('intc')),
value=Integer(3)
)
),
Declaration(
Variable(Symbol('mod'),
type=IntBaseType(String('intc')),
value=Integer(1000000007)
)
),
Declaration(
Variable(Symbol('c'),
type=IntBaseType(String('intc'))
)
),
Assignment(
Variable(Symbol('c')),
Mod(
Mul(
Add(
Symbol('a'),
Mul(Integer(-1),
Symbol('b')
)
),
Add(
Symbol('a'),
Symbol('b')
)
),
Symbol('mod')
)
)
)
)
assert res20[0] == FunctionDefinition(
NoneToken(),
name=String('func'),
parameters=(),
body=CodeBlock(
Declaration(
Variable(Symbol('a'),
type=Type(String('bool'))
)
),
Declaration(
Variable(Symbol('b'),
type=Type(String('bool'))
)
),
Assignment(
Variable(Symbol('a')),
false
),
Assignment(
Variable(Symbol('b')),
true
)
)
)
assert res21[0] == FunctionDefinition(
NoneToken(),
name=String('func'),
parameters=(),
body=CodeBlock(
Declaration(
Variable(Symbol('a'),
type=Type(String('bool'))
)
),
Declaration(
Variable(Symbol('b'),
type=Type(String('bool'))
)
),
Declaration(
Variable(Symbol('c'),
type=Type(String('bool'))
)
),
Declaration(
Variable(Symbol('d'),
type=Type(String('bool'))
)
),
Assignment(
Variable(Symbol('a')),
false
),
Assignment(
Variable(Symbol('b')),
true
),
Assignment(
Variable(Symbol('c')),
false
),
Assignment(
Variable(Symbol('d')),
false
)
)
)
assert res22[0] == FunctionDefinition(
NoneToken(),
name=String('func'),
parameters=(),
body=CodeBlock(
Declaration(
Variable(Symbol('a'),
type=IntBaseType(String('intc')),
value=Integer(1)
)
),
Declaration(
Variable(Symbol('b'),
type=IntBaseType(String('intc')),
value=Integer(2)
)
),
Declaration(
Variable(Symbol('c1'),
type=Type(String('bool'))
)
),
Declaration(
Variable(Symbol('c2'),
type=Type(String('bool'))
)
),
Declaration(
Variable(Symbol('c3'),
type=Type(String('bool'))
)
),
Declaration(
Variable(Symbol('c4'),
type=Type(String('bool'))
)
),
Declaration(
Variable(Symbol('c5'),
type=Type(String('bool'))
)
),
Declaration(
Variable(Symbol('c6'),
type=Type(String('bool'))
)
),
Declaration(
Variable(Symbol('c7'),
type=Type(String('bool'))
)
),
Declaration(
Variable(Symbol('c8'),
type=Type(String('bool'))
)
),
Assignment(
Variable(Symbol('c1')),
Equality(
Symbol('a'),
Integer(1)
)
),
Assignment(
Variable(Symbol('c2')),
Equality(
Symbol('b'),
Integer(2)
)
),
Assignment(
Variable(Symbol('c3')),
Unequality(
Integer(1),
Symbol('a')
)
),
Assignment(
Variable(Symbol('c4')),
Unequality(
Integer(1),
Symbol('b')
)
),
Assignment(
Variable(Symbol('c5')),
StrictLessThan(
Symbol('a'),
Integer(0)
)
),
Assignment(
Variable(Symbol('c6')),
LessThan(
Symbol('b'),
Integer(10)
)
),
Assignment(
Variable(Symbol('c7')),
StrictGreaterThan(
Symbol('a'),
Integer(0)
)
),
Assignment(
Variable(Symbol('c8')),
GreaterThan(
Symbol('b'),
Integer(11)
)
)
)
)
assert res23[0] == FunctionDefinition(
NoneToken(),
name=String('func'),
parameters=(),
body=CodeBlock(
Declaration(
Variable(Symbol('a'),
type=IntBaseType(String('intc')),
value=Integer(3)
)
),
Declaration(
Variable(Symbol('b'),
type=IntBaseType(String('intc')),
value=Integer(4)
)
),
Declaration(
Variable(Symbol('c1'),
type=Type(String('bool'))
)
),
Declaration(
Variable(Symbol('c2'),
type=Type(String('bool'))
)
),
Declaration(
Variable(Symbol('c3'),
type=Type(String('bool'))
)
),
Declaration(
Variable(Symbol('c4'),
type=Type(String('bool'))
)
),
Declaration(
Variable(Symbol('c5'),
type=Type(String('bool'))
)
),
Declaration(
Variable(Symbol('c6'),
type=Type(String('bool'))
)
),
Assignment(
Variable(Symbol('c1')),
Equality(
Symbol('a'),
Symbol('b')
)
),
Assignment(
Variable(Symbol('c2')),
Unequality(
Symbol('a'),
Symbol('b')
)
),
Assignment(
Variable(Symbol('c3')),
StrictLessThan(
Symbol('a'),
Symbol('b')
)
),
Assignment(
Variable(Symbol('c4')),
LessThan(
Symbol('a'),
Symbol('b')
)
),
Assignment(
Variable(Symbol('c5')),
StrictGreaterThan(
Symbol('a'),
Symbol('b')
)
),
Assignment(
Variable(Symbol('c6')),
GreaterThan(
Symbol('a'),
Symbol('b')
)
)
)
)
assert res24[0] == FunctionDefinition(
NoneToken(),
name=String('func'),
parameters=(),
body=CodeBlock(
Declaration(
Variable(Symbol('a'),
type=FloatType(
String('float32'),
nbits=Integer(32),
nmant=Integer(23),
nexp=Integer(8)
)
)
),
Declaration(
Variable(Symbol('c1'),
type=Type(String('bool'))
)
),
Declaration(
Variable(Symbol('c2'),
type=Type(String('bool'))
)
),
Declaration(
Variable(Symbol('c3'),
type=Type(String('bool'))
)
),
Declaration(
Variable(Symbol('c4'),
type=Type(String('bool'))
)
),
Assignment(
Variable(Symbol('c1')),
Equality(
Symbol('a'),
Float('1.25', precision=53)
)
),
Assignment(
Variable(Symbol('c3')),
Unequality(
Float('1.2', precision=53),
Symbol('a')
)
)
)
)
assert res25[0] == FunctionDefinition(
NoneToken(),
name=String('func'),
parameters=(),
body=CodeBlock(
Declaration(
Variable(Symbol('a'),
type=FloatType(
String('float32'),
nbits=Integer(32),
nmant=Integer(23),
nexp=Integer(8)
),
value=Float('1.25', precision=53)
)
),
Declaration(
Variable(Symbol('b'),
type=FloatType(
String('float32'),
nbits=Integer(32),
nmant=Integer(23),
nexp=Integer(8)
),
value=Float('2.5', precision=53)
)
),
Declaration(
Variable(Symbol('c1'),
type=Type(String('bool'))
)
),
Declaration(
Variable(Symbol('c2'),
type=Type(String('bool')
)
)
),
Declaration(
Variable(Symbol('c3'),
type=Type(String('bool'))
)
),
Declaration(
Variable(Symbol('c4'),
type=Type(String('bool'))
)
),
Declaration(
Variable(Symbol('c5'),
type=Type(String('bool'))
)
),
Declaration(
Variable(Symbol('c6'),
type=Type(String('bool'))
)
),
Assignment(
Variable(Symbol('c1')),
Equality(
Symbol('a'),
Symbol('b')
)
),
Assignment(
Variable(Symbol('c2')),
Unequality(
Symbol('a'),
Symbol('b')
)
),
Assignment(
Variable(Symbol('c3')),
StrictLessThan(
Symbol('a'),
Symbol('b')
)
),
Assignment(
Variable(Symbol('c4')),
LessThan(
Symbol('a'),
Symbol('b')
)
),
Assignment(
Variable(Symbol('c5')),
StrictGreaterThan(
Symbol('a'),
Symbol('b')
)
),
Assignment(
Variable(Symbol('c6')),
GreaterThan(
Symbol('a'),
Symbol('b')
)
)
)
)
assert res26[0] == FunctionDefinition(
NoneToken(),
name=String('func'),
parameters=(), body=CodeBlock(
Declaration(
Variable(Symbol('c1'),
type=Type(String('bool'))
)
),
Declaration(
Variable(Symbol('c2'),
type=Type(String('bool'))
)
),
Declaration(
Variable(Symbol('c3'),
type=Type(String('bool'))
)
),
Declaration(
Variable(Symbol('c4'),
type=Type(String('bool'))
)
),
Declaration(
Variable(Symbol('c5'),
type=Type(String('bool'))
)
),
Declaration(
Variable(Symbol('c6'),
type=Type(String('bool'))
)
),
Assignment(
Variable(Symbol('c1')),
true
),
Assignment(
Variable(Symbol('c2')),
false
),
Assignment(
Variable(Symbol('c3')),
true
),
Assignment(
Variable(Symbol('c4')),
false
),
Assignment(
Variable(Symbol('c5')),
true
),
Assignment(
Variable(Symbol('c6')),
false
)
)
)
assert res27[0] == FunctionDefinition(
NoneToken(),
name=String('func'),
parameters=(),
body=CodeBlock(
Declaration(
Variable(Symbol('c1'),
type=Type(String('bool'))
)
),
Declaration(
Variable(Symbol('c2'),
type=Type(String('bool'))
)
),
Declaration(
Variable(Symbol('c3'),
type=Type(String('bool'))
)
),
Declaration(
Variable(Symbol('c4'),
type=Type(String('bool'))
)
),
Declaration(
Variable(Symbol('c5'),
type=Type(String('bool'))
)
),
Declaration(
Variable(Symbol('c6'),
type=Type(String('bool'))
)
),
Assignment(
Variable(Symbol('c1')),
true
),
Assignment(
Variable(Symbol('c2')),
false
),
Assignment(
Variable(Symbol('c3')),
false
),
Assignment(
Variable(Symbol('c4')),
true
),
Assignment(
Variable(Symbol('c5')),
true
),
Assignment(
Variable(Symbol('c6')),
false)
)
)
assert res28[0] == FunctionDefinition(
NoneToken(),
name=String('func'),
parameters=(),
body=CodeBlock(
Declaration(
Variable(Symbol('a'),
type=Type(String('bool'))
)
),
Declaration(
Variable(Symbol('c1'),
type=Type(String('bool'))
)
),
Declaration(
Variable(Symbol('c2'),
type=Type(String('bool'))
)
),
Declaration(
Variable(Symbol('c3'),
type=Type(String('bool'))
)
),
Declaration(
Variable(Symbol('c4'),
type=Type(String('bool'))
)
),
Assignment(
Variable(Symbol('c1')),
Symbol('a')
),
Assignment(
Variable(Symbol('c2')),
false
),
Assignment(
Variable(Symbol('c3')),
true
),
Assignment(
Variable(Symbol('c4')),
Symbol('a')
)
)
)
assert res29[0] == FunctionDefinition(
NoneToken(),
name=String('func'),
parameters=(),
body=CodeBlock(
Declaration(
Variable(Symbol('a'),
type=IntBaseType(String('intc'))
)
),
Declaration(
Variable(Symbol('c1'),
type=Type(String('bool'))
)
),
Declaration(
Variable(Symbol('c2'),
type=Type(String('bool'))
)
),
Declaration(
Variable(Symbol('c3'),
type=Type(String('bool'))
)
),
Declaration(
Variable(Symbol('c4'),
type=Type(String('bool'))
)
),
Assignment(
Variable(Symbol('c1')),
Symbol('a')
),
Assignment(
Variable(Symbol('c2')),
false
),
Assignment(
Variable(Symbol('c3')),
true
),
Assignment(
Variable(Symbol('c4')),
Symbol('a')
)
)
)
assert res30[0] == FunctionDefinition(
NoneToken(),
name=String('func'),
parameters=(),
body=CodeBlock(
Declaration(
Variable(Symbol('a'),
type=IntBaseType(String('intc'))
)
),
Declaration(
Variable(Symbol('b'),
type=IntBaseType(String('intc'))
)
),
Declaration(
Variable(Symbol('c'),
type=Type(String('bool'))
)
),
Declaration(
Variable(Symbol('d'),
type=Type(String('bool'))
)
),
Declaration(
Variable(Symbol('c1'),
type=Type(String('bool'))
)
),
Declaration(
Variable(Symbol('c2'),
type=Type(String('bool'))
)
),
Declaration(
Variable(Symbol('c3'),
type=Type(String('bool'))
)
),
Declaration(
Variable(Symbol('c4'),
type=Type(String('bool'))
)
),
Declaration(
Variable(Symbol('c5'),
type=Type(String('bool'))
)
),
Declaration(
Variable(Symbol('c6'),
type=Type(String('bool'))
)
),
Assignment(
Variable(Symbol('c1')),
And(
Symbol('a'),
Symbol('b')
)
),
Assignment(
Variable(Symbol('c2')),
And(
Symbol('a'),
Symbol('c')
)
),
Assignment(
Variable(Symbol('c3')),
And(
Symbol('c'),
Symbol('d')
)
),
Assignment(
Variable(Symbol('c4')),
Or(
Symbol('a'),
Symbol('b')
)
),
Assignment(
Variable(Symbol('c5')),
Or(
Symbol('a'),
Symbol('c')
)
),
Assignment(
Variable(Symbol('c6')),
Or(
Symbol('c'),
Symbol('d')
)
)
)
)
raises(NotImplementedError, lambda: SymPyExpression(c_src_raise1, 'c'))
raises(NotImplementedError, lambda: SymPyExpression(c_src_raise2, 'c'))
raises(NotImplementedError, lambda: SymPyExpression(c_src_raise3, 'c'))
raises(NotImplementedError, lambda: SymPyExpression(c_src_raise4, 'c'))
raises(NotImplementedError, lambda: SymPyExpression(c_src_raise5, 'c'))
def test_var_decl():
c_src1 = (
'int b = 100;' + '\n' +
'int a = b;' + '\n'
)
c_src2 = (
'int a = 1;' + '\n' +
'int b = a + 1;' + '\n'
)
c_src3 = (
'float a = 10.0 + 2.5;' + '\n' +
'float b = a * 20.0;' + '\n'
)
c_src4 = (
'int a = 1 + 100 - 3 * 6;' + '\n'
)
c_src5 = (
'int a = (((1 + 100) * 12) - 3) * (6 - 10);' + '\n'
)
c_src6 = (
'int b = 2;' + '\n' +
'int c = 3;' + '\n' +
'int a = b + c * 4;' + '\n'
)
c_src7 = (
'int b = 1;' + '\n' +
'int c = b + 2;' + '\n' +
'int a = 10 * b * b * c;' + '\n'
)
c_src8 = (
'void func()'+
'{' + '\n' +
'int a = 1;' + '\n' +
'int b = 2;' + '\n' +
'int temp = a;' + '\n' +
'a = b;' + '\n' +
'b = temp;' + '\n' +
'}'
)
c_src9 = (
'int a = 1;' + '\n' +
'int b = 2;' + '\n' +
'int c = a;' + '\n' +
'int d = a + b + c;' + '\n' +
'int e = a*a*a + 3*a*a*b + 3*a*b*b + b*b*b;' + '\n'
'int f = (a + b + c) * (a + b - c);' + '\n' +
'int g = (a + b + c + d)*(a + b + c + d)*(a * (b - c));'
+ '\n'
)
c_src10 = (
'float a = 10.0;' + '\n' +
'float b = 2.5;' + '\n' +
'float c = a*a + 2*a*b + b*b;' + '\n'
)
c_src11 = (
'float a = 10.0 / 2.5;' + '\n'
)
c_src12 = (
'int a = 100 / 4;' + '\n'
)
c_src13 = (
'int a = 20 - 100 / 4 * 5 + 10;' + '\n'
)
c_src14 = (
'int a = (20 - 100) / 4 * (5 + 10);' + '\n'
)
c_src15 = (
'int a = 4;' + '\n' +
'int b = 2;' + '\n' +
'float c = b/a;' + '\n'
)
c_src16 = (
'int a = 2;' + '\n' +
'int d = 5;' + '\n' +
'int n = 10;' + '\n' +
'int s = (a/2)*(2*a + (n-1)*d);' + '\n'
)
c_src17 = (
'int a = 1 % 2;' + '\n'
)
c_src18 = (
'int a = 2;' + '\n' +
'int b = a % 3;' + '\n'
)
c_src19 = (
'int a = 100;' + '\n' +
'int b = 3;' + '\n' +
'int c = a % b;' + '\n'
)
c_src20 = (
'int a = 100;' + '\n' +
'int b = 3;' + '\n' +
'int mod = 1000000007;' + '\n' +
'int c = (a + b * (100/a)) % mod;' + '\n'
)
c_src21 = (
'int a = 100;' + '\n' +
'int b = 3;' + '\n' +
'int mod = 1000000007;' + '\n' +
'int c = ((a % mod + b % mod) % mod *(' \
'a % mod - b % mod) % mod) % mod;' + '\n'
)
c_src22 = (
'bool a = 1 == 2, b = 1 != 2;'
)
c_src23 = (
'bool a = 1 < 2, b = 1 <= 2, c = 1 > 2, d = 1 >= 2;'
)
c_src24 = (
'int a = 1, b = 2;' + '\n' +
'bool c1 = a == 1;' + '\n' +
'bool c2 = b == 2;' + '\n' +
'bool c3 = 1 != a;' + '\n' +
'bool c4 = 1 != b;' + '\n' +
'bool c5 = a < 0;' + '\n' +
'bool c6 = b <= 10;' + '\n' +
'bool c7 = a > 0;' + '\n' +
'bool c8 = b >= 11;'
)
c_src25 = (
'int a = 3, b = 4;' + '\n' +
'bool c1 = a == b;' + '\n' +
'bool c2 = a != b;' + '\n' +
'bool c3 = a < b;' + '\n' +
'bool c4 = a <= b;' + '\n' +
'bool c5 = a > b;' + '\n' +
'bool c6 = a >= b;'
)
c_src26 = (
'float a = 1.25, b = 2.5;' + '\n' +
'bool c1 = a == 1.25;' + '\n' +
'bool c2 = b == 2.54;' + '\n' +
'bool c3 = 1.2 != a;' + '\n' +
'bool c4 = 1.5 != b;'
)
c_src27 = (
'float a = 1.25, b = 2.5;' + '\n' +
'bool c1 = a == b;' + '\n' +
'bool c2 = a != b;' + '\n' +
'bool c3 = a < b;' + '\n' +
'bool c4 = a <= b;' + '\n' +
'bool c5 = a > b;' + '\n' +
'bool c6 = a >= b;'
)
c_src28 = (
'bool c1 = true == true;' + '\n' +
'bool c2 = true == false;' + '\n' +
'bool c3 = false == false;' + '\n' +
'bool c4 = true != true;' + '\n' +
'bool c5 = true != false;' + '\n' +
'bool c6 = false != false;'
)
c_src29 = (
'bool c1 = true && true;' + '\n' +
'bool c2 = true && false;' + '\n' +
'bool c3 = false && false;' + '\n' +
'bool c4 = true || true;' + '\n' +
'bool c5 = true || false;' + '\n' +
'bool c6 = false || false;'
)
c_src30 = (
'bool a = false;' + '\n' +
'bool c1 = a && true;' + '\n' +
'bool c2 = false && a;' + '\n' +
'bool c3 = true || a;' + '\n' +
'bool c4 = a || false;'
)
c_src31 = (
'int a = 1;' + '\n' +
'bool c1 = a && 1;' + '\n' +
'bool c2 = a && 0;' + '\n' +
'bool c3 = a || 1;' + '\n' +
'bool c4 = 0 || a;'
)
c_src32 = (
'int a = 1, b = 0;' + '\n' +
'bool c = false, d = true;'+ '\n' +
'bool c1 = a && b;' + '\n' +
'bool c2 = a && c;' + '\n' +
'bool c3 = c && d;' + '\n' +
'bool c4 = a || b;' + '\n' +
'bool c5 = a || c;' + '\n' +
'bool c6 = c || d;'
)
c_src_raise1 = (
"char a = 'b';"
)
c_src_raise2 = (
'int a[] = {10, 20};'
)
res1 = SymPyExpression(c_src1, 'c').return_expr()
res2 = SymPyExpression(c_src2, 'c').return_expr()
res3 = SymPyExpression(c_src3, 'c').return_expr()
res4 = SymPyExpression(c_src4, 'c').return_expr()
res5 = SymPyExpression(c_src5, 'c').return_expr()
res6 = SymPyExpression(c_src6, 'c').return_expr()
res7 = SymPyExpression(c_src7, 'c').return_expr()
res8 = SymPyExpression(c_src8, 'c').return_expr()
res9 = SymPyExpression(c_src9, 'c').return_expr()
res10 = SymPyExpression(c_src10, 'c').return_expr()
res11 = SymPyExpression(c_src11, 'c').return_expr()
res12 = SymPyExpression(c_src12, 'c').return_expr()
res13 = SymPyExpression(c_src13, 'c').return_expr()
res14 = SymPyExpression(c_src14, 'c').return_expr()
res15 = SymPyExpression(c_src15, 'c').return_expr()
res16 = SymPyExpression(c_src16, 'c').return_expr()
res17 = SymPyExpression(c_src17, 'c').return_expr()
res18 = SymPyExpression(c_src18, 'c').return_expr()
res19 = SymPyExpression(c_src19, 'c').return_expr()
res20 = SymPyExpression(c_src20, 'c').return_expr()
res21 = SymPyExpression(c_src21, 'c').return_expr()
res22 = SymPyExpression(c_src22, 'c').return_expr()
res23 = SymPyExpression(c_src23, 'c').return_expr()
res24 = SymPyExpression(c_src24, 'c').return_expr()
res25 = SymPyExpression(c_src25, 'c').return_expr()
res26 = SymPyExpression(c_src26, 'c').return_expr()
res27 = SymPyExpression(c_src27, 'c').return_expr()
res28 = SymPyExpression(c_src28, 'c').return_expr()
res29 = SymPyExpression(c_src29, 'c').return_expr()
res30 = SymPyExpression(c_src30, 'c').return_expr()
res31 = SymPyExpression(c_src31, 'c').return_expr()
res32 = SymPyExpression(c_src32, 'c').return_expr()
assert res1[0] == Declaration(
Variable(Symbol('b'),
type=IntBaseType(String('intc')),
value=Integer(100)
)
)
assert res1[1] == Declaration(
Variable(Symbol('a'),
type=IntBaseType(String('intc')),
value=Symbol('b')
)
)
assert res2[0] == Declaration(
Variable(Symbol('a'),
type=IntBaseType(String('intc')),
value=Integer(1)
)
)
assert res2[1] == Declaration(Variable(Symbol('b'),
type=IntBaseType(String('intc')),
value=Add(
Symbol('a'),
Integer(1)
)
)
)
assert res3[0] == Declaration(
Variable(Symbol('a'),
type=FloatType(
String('float32'),
nbits=Integer(32),
nmant=Integer(23),
nexp=Integer(8)
),
value=Float('12.5', precision=53)
)
)
assert res3[1] == Declaration(
Variable(Symbol('b'),
type=FloatType(
String('float32'),
nbits=Integer(32),
nmant=Integer(23),
nexp=Integer(8)
),
value=Mul(
Float('20.0', precision=53),
Symbol('a')
)
)
)
assert res4[0] == Declaration(
Variable(Symbol('a'),
type=IntBaseType(String('intc')),
value=Integer(83)
)
)
assert res5[0] == Declaration(
Variable(Symbol('a'),
type=IntBaseType(String('intc')),
value=Integer(-4836)
)
)
assert res6[0] == Declaration(
Variable(Symbol('b'),
type=IntBaseType(String('intc')),
value=Integer(2)
)
)
assert res6[1] == Declaration(
Variable(Symbol('c'),
type=IntBaseType(String('intc')),
value=Integer(3)
)
)
assert res6[2] == Declaration(
Variable(Symbol('a'),
type=IntBaseType(String('intc')),
value=Add(
Symbol('b'),
Mul(
Integer(4),
Symbol('c')
)
)
)
)
assert res7[0] == Declaration(
Variable(Symbol('b'),
type=IntBaseType(String('intc')),
value=Integer(1)
)
)
assert res7[1] == Declaration(
Variable(Symbol('c'),
type=IntBaseType(String('intc')),
value=Add(
Symbol('b'),
Integer(2)
)
)
)
assert res7[2] == Declaration(
Variable(Symbol('a'),
type=IntBaseType(String('intc')),
value=Mul(
Integer(10),
Pow(
Symbol('b'),
Integer(2)
),
Symbol('c')
)
)
)
assert res8[0] == FunctionDefinition(
NoneToken(),
name=String('func'),
parameters=(),
body=CodeBlock(
Declaration(
Variable(Symbol('a'),
type=IntBaseType(String('intc')),
value=Integer(1)
)
),
Declaration(
Variable(Symbol('b'),
type=IntBaseType(String('intc')),
value=Integer(2)
)
),
Declaration(
Variable(Symbol('temp'),
type=IntBaseType(String('intc')),
value=Symbol('a')
)
),
Assignment(
Variable(Symbol('a')),
Symbol('b')
),
Assignment(
Variable(Symbol('b')),
Symbol('temp')
)
)
)
assert res9[0] == Declaration(
Variable(Symbol('a'),
type=IntBaseType(String('intc')),
value=Integer(1)
)
)
assert res9[1] == Declaration(
Variable(Symbol('b'),
type=IntBaseType(String('intc')),
value=Integer(2)
)
)
assert res9[2] == Declaration(
Variable(Symbol('c'),
type=IntBaseType(String('intc')),
value=Symbol('a')
)
)
assert res9[3] == Declaration(
Variable(Symbol('d'),
type=IntBaseType(String('intc')),
value=Add(
Symbol('a'),
Symbol('b'),
Symbol('c')
)
)
)
assert res9[4] == Declaration(
Variable(Symbol('e'),
type=IntBaseType(String('intc')),
value=Add(
Pow(
Symbol('a'),
Integer(3)
),
Mul(
Integer(3),
Pow(
Symbol('a'),
Integer(2)
),
Symbol('b')
),
Mul(
Integer(3),
Symbol('a'),
Pow(
Symbol('b'),
Integer(2)
)
),
Pow(
Symbol('b'),
Integer(3)
)
)
)
)
assert res9[5] == Declaration(
Variable(Symbol('f'),
type=IntBaseType(String('intc')),
value=Mul(
Add(
Symbol('a'),
Symbol('b'),
Mul(
Integer(-1),
Symbol('c')
)
),
Add(
Symbol('a'),
Symbol('b'),
Symbol('c')
)
)
)
)
assert res9[6] == Declaration(
Variable(Symbol('g'),
type=IntBaseType(String('intc')),
value=Mul(
Symbol('a'),
Add(
Symbol('b'),
Mul(
Integer(-1),
Symbol('c')
)
),
Pow(
Add(
Symbol('a'),
Symbol('b'),
Symbol('c'),
Symbol('d')
),
Integer(2)
)
)
)
)
assert res10[0] == Declaration(
Variable(Symbol('a'),
type=FloatType(
String('float32'),
nbits=Integer(32),
nmant=Integer(23),
nexp=Integer(8)
),
value=Float('10.0', precision=53)
)
)
assert res10[1] == Declaration(
Variable(Symbol('b'),
type=FloatType(
String('float32'),
nbits=Integer(32),
nmant=Integer(23),
nexp=Integer(8)
),
value=Float('2.5', precision=53)
)
)
assert res10[2] == Declaration(
Variable(Symbol('c'),
type=FloatType(
String('float32'),
nbits=Integer(32),
nmant=Integer(23),
nexp=Integer(8)
),
value=Add(
Pow(
Symbol('a'),
Integer(2)
),
Mul(
Integer(2),
Symbol('a'),
Symbol('b')
),
Pow(
Symbol('b'),
Integer(2)
)
)
)
)
assert res11[0] == Declaration(
Variable(Symbol('a'),
type=FloatType(
String('float32'),
nbits=Integer(32),
nmant=Integer(23),
nexp=Integer(8)
),
value=Float('4.0', precision=53)
)
)
assert res12[0] == Declaration(
Variable(Symbol('a'),
type=IntBaseType(String('intc')),
value=Integer(25)
)
)
assert res13[0] == Declaration(
Variable(Symbol('a'),
type=IntBaseType(String('intc')),
value=Integer(-95)
)
)
assert res14[0] == Declaration(
Variable(Symbol('a'),
type=IntBaseType(String('intc')),
value=Integer(-300)
)
)
assert res15[0] == Declaration(
Variable(Symbol('a'),
type=IntBaseType(String('intc')),
value=Integer(4)
)
)
assert res15[1] == Declaration(
Variable(Symbol('b'),
type=IntBaseType(String('intc')),
value=Integer(2)
)
)
assert res15[2] == Declaration(
Variable(Symbol('c'),
type=FloatType(
String('float32'),
nbits=Integer(32),
nmant=Integer(23),
nexp=Integer(8)
),
value=Mul(
Pow(
Symbol('a'),
Integer(-1)
),
Symbol('b')
)
)
)
assert res16[0] == Declaration(
Variable(Symbol('a'),
type=IntBaseType(String('intc')),
value=Integer(2)
)
)
assert res16[1] == Declaration(
Variable(Symbol('d'),
type=IntBaseType(String('intc')),
value=Integer(5)
)
)
assert res16[2] == Declaration(
Variable(Symbol('n'),
type=IntBaseType(String('intc')),
value=Integer(10)
)
)
assert res16[3] == Declaration(
Variable(Symbol('s'),
type=IntBaseType(String('intc')),
value=Mul(
Rational(1, 2),
Symbol('a'),
Add(
Mul(
Integer(2),
Symbol('a')
),
Mul(
Symbol('d'),
Add(
Symbol('n'),
Integer(-1)
)
)
)
)
)
)
assert res17[0] == Declaration(
Variable(Symbol('a'),
type=IntBaseType(String('intc')),
value=Integer(1)
)
)
assert res18[0] == Declaration(
Variable(Symbol('a'),
type=IntBaseType(String('intc')),
value=Integer(2)
)
)
assert res18[1] == Declaration(
Variable(Symbol('b'),
type=IntBaseType(String('intc')),
value=Mod(
Symbol('a'),
Integer(3)
)
)
)
assert res19[0] == Declaration(
Variable(Symbol('a'),
type=IntBaseType(String('intc')),
value=Integer(100)
)
)
assert res19[1] == Declaration(
Variable(Symbol('b'),
type=IntBaseType(String('intc')),
value=Integer(3)
)
)
assert res19[2] == Declaration(
Variable(Symbol('c'),
type=IntBaseType(String('intc')),
value=Mod(
Symbol('a'),
Symbol('b')
)
)
)
assert res20[0] == Declaration(
Variable(Symbol('a'),
type=IntBaseType(String('intc')),
value=Integer(100)
)
)
assert res20[1] == Declaration(
Variable(Symbol('b'),
type=IntBaseType(String('intc')),
value=Integer(3)
)
)
assert res20[2] == Declaration(
Variable(Symbol('mod'),
type=IntBaseType(String('intc')),
value=Integer(1000000007)
)
)
assert res20[3] == Declaration(
Variable(Symbol('c'),
type=IntBaseType(String('intc')),
value=Mod(
Add(
Symbol('a'),
Mul(
Integer(100),
Pow(
Symbol('a'),
Integer(-1)
),
Symbol('b')
)
),
Symbol('mod')
)
)
)
assert res21[0] == Declaration(
Variable(Symbol('a'),
type=IntBaseType(String('intc')),
value=Integer(100)
)
)
assert res21[1] == Declaration(
Variable(Symbol('b'),
type=IntBaseType(String('intc')),
value=Integer(3)
)
)
assert res21[2] == Declaration(
Variable(Symbol('mod'),
type=IntBaseType(String('intc')),
value=Integer(1000000007)
)
)
assert res21[3] == Declaration(
Variable(Symbol('c'),
type=IntBaseType(String('intc')),
value=Mod(
Mul(
Add(
Symbol('a'),
Mul(
Integer(-1),
Symbol('b')
)
),
Add(
Symbol('a'),
Symbol('b')
)
),
Symbol('mod')
)
)
)
assert res22[0] == Declaration(
Variable(Symbol('a'),
type=Type(String('bool')),
value=false
)
)
assert res22[1] == Declaration(
Variable(Symbol('b'),
type=Type(String('bool')),
value=true
)
)
assert res23[0] == Declaration(
Variable(Symbol('a'),
type=Type(String('bool')),
value=true
)
)
assert res23[1] == Declaration(
Variable(Symbol('b'),
type=Type(String('bool')),
value=true
)
)
assert res23[2] == Declaration(
Variable(Symbol('c'),
type=Type(String('bool')),
value=false
)
)
assert res23[3] == Declaration(
Variable(Symbol('d'),
type=Type(String('bool')),
value=false
)
)
assert res24[0] == Declaration(
Variable(Symbol('a'),
type=IntBaseType(String('intc')),
value=Integer(1)
)
)
assert res24[1] == Declaration(
Variable(Symbol('b'),
type=IntBaseType(String('intc')),
value=Integer(2)
)
)
assert res24[2] == Declaration(
Variable(Symbol('c1'),
type=Type(String('bool')),
value=Equality(
Symbol('a'),
Integer(1)
)
)
)
assert res24[3] == Declaration(
Variable(Symbol('c2'),
type=Type(String('bool')),
value=Equality(
Symbol('b'),
Integer(2)
)
)
)
assert res24[4] == Declaration(
Variable(Symbol('c3'),
type=Type(String('bool')),
value=Unequality(
Integer(1),
Symbol('a')
)
)
)
assert res24[5] == Declaration(
Variable(Symbol('c4'),
type=Type(String('bool')),
value=Unequality(
Integer(1),
Symbol('b')
)
)
)
assert res24[6] == Declaration(
Variable(Symbol('c5'),
type=Type(String('bool')),
value=StrictLessThan(Symbol('a'),
Integer(0)
)
)
)
assert res24[7] == Declaration(
Variable(Symbol('c6'),
type=Type(String('bool')),
value=LessThan(
Symbol('b'),
Integer(10)
)
)
)
assert res24[8] == Declaration(
Variable(Symbol('c7'),
type=Type(String('bool')),
value=StrictGreaterThan(
Symbol('a'),
Integer(0)
)
)
)
assert res24[9] == Declaration(
Variable(Symbol('c8'),
type=Type(String('bool')),
value=GreaterThan(
Symbol('b'),
Integer(11)
)
)
)
assert res25[0] == Declaration(
Variable(Symbol('a'),
type=IntBaseType(String('intc')),
value=Integer(3)
)
)
assert res25[1] == Declaration(
Variable(Symbol('b'),
type=IntBaseType(String('intc')),
value=Integer(4)
)
)
assert res25[2] == Declaration(Variable(Symbol('c1'),
type=Type(String('bool')),
value=Equality(
Symbol('a'),
Symbol('b')
)
)
)
assert res25[3] == Declaration(
Variable(Symbol('c2'),
type=Type(String('bool')),
value=Unequality(
Symbol('a'),
Symbol('b')
)
)
)
assert res25[4] == Declaration(
Variable(Symbol('c3'),
type=Type(String('bool')),
value=StrictLessThan(
Symbol('a'),
Symbol('b')
)
)
)
assert res25[5] == Declaration(
Variable(Symbol('c4'),
type=Type(String('bool')),
value=LessThan(
Symbol('a'),
Symbol('b')
)
)
)
assert res25[6] == Declaration(
Variable(Symbol('c5'),
type=Type(String('bool')),
value=StrictGreaterThan(
Symbol('a'),
Symbol('b')
)
)
)
assert res25[7] == Declaration(
Variable(Symbol('c6'),
type=Type(String('bool')),
value=GreaterThan(
Symbol('a'),
Symbol('b')
)
)
)
assert res26[0] == Declaration(
Variable(Symbol('a'),
type=FloatType(
String('float32'),
nbits=Integer(32),
nmant=Integer(23),
nexp=Integer(8)
),
value=Float('1.25', precision=53)
)
)
assert res26[1] == Declaration(
Variable(Symbol('b'),
type=FloatType(
String('float32'),
nbits=Integer(32),
nmant=Integer(23),
nexp=Integer(8)
),
value=Float('2.5', precision=53)
)
)
assert res26[2] == Declaration(
Variable(Symbol('c1'),
type=Type(String('bool')),
value=Equality(
Symbol('a'),
Float('1.25', precision=53)
)
)
)
assert res26[3] == Declaration(
Variable(Symbol('c2'),
type=Type(String('bool')),
value=Equality(
Symbol('b'),
Float('2.54', precision=53)
)
)
)
assert res26[4] == Declaration(
Variable(Symbol('c3'),
type=Type(String('bool')),
value=Unequality(
Float('1.2', precision=53),
Symbol('a')
)
)
)
assert res26[5] == Declaration(
Variable(Symbol('c4'),
type=Type(String('bool')),
value=Unequality(
Float('1.5', precision=53),
Symbol('b')
)
)
)
assert res27[0] == Declaration(
Variable(Symbol('a'),
type=FloatType(
String('float32'),
nbits=Integer(32),
nmant=Integer(23),
nexp=Integer(8)
),
value=Float('1.25', precision=53)
)
)
assert res27[1] == Declaration(
Variable(Symbol('b'),
type=FloatType(
String('float32'),
nbits=Integer(32),
nmant=Integer(23),
nexp=Integer(8)
),
value=Float('2.5', precision=53)
)
)
assert res27[2] == Declaration(
Variable(Symbol('c1'),
type=Type(String('bool')),
value=Equality(
Symbol('a'),
Symbol('b')
)
)
)
assert res27[3] == Declaration(
Variable(Symbol('c2'),
type=Type(String('bool')),
value=Unequality(
Symbol('a'),
Symbol('b')
)
)
)
assert res27[4] == Declaration(
Variable(Symbol('c3'),
type=Type(String('bool')),
value=StrictLessThan(
Symbol('a'),
Symbol('b')
)
)
)
assert res27[5] == Declaration(
Variable(Symbol('c4'),
type=Type(String('bool')),
value=LessThan(
Symbol('a'),
Symbol('b')
)
)
)
assert res27[6] == Declaration(
Variable(Symbol('c5'),
type=Type(String('bool')),
value=StrictGreaterThan(
Symbol('a'),
Symbol('b')
)
)
)
assert res27[7] == Declaration(
Variable(Symbol('c6'),
type=Type(String('bool')),
value=GreaterThan(
Symbol('a'),
Symbol('b')
)
)
)
assert res28[0] == Declaration(
Variable(Symbol('c1'),
type=Type(String('bool')),
value=true
)
)
assert res28[1] == Declaration(
Variable(Symbol('c2'),
type=Type(String('bool')),
value=false
)
)
assert res28[2] == Declaration(
Variable(Symbol('c3'),
type=Type(String('bool')),
value=true
)
)
assert res28[3] == Declaration(
Variable(Symbol('c4'),
type=Type(String('bool')),
value=false
)
)
assert res28[4] == Declaration(
Variable(Symbol('c5'),
type=Type(String('bool')),
value=true
)
)
assert res28[5] == Declaration(
Variable(Symbol('c6'),
type=Type(String('bool')),
value=false
)
)
assert res29[0] == Declaration(
Variable(Symbol('c1'),
type=Type(String('bool')),
value=true
)
)
assert res29[1] == Declaration(
Variable(Symbol('c2'),
type=Type(String('bool')),
value=false
)
)
assert res29[2] == Declaration(
Variable(Symbol('c3'),
type=Type(String('bool')),
value=false
)
)
assert res29[3] == Declaration(
Variable(Symbol('c4'),
type=Type(String('bool')),
value=true
)
)
assert res29[4] == Declaration(
Variable(Symbol('c5'),
type=Type(String('bool')),
value=true
)
)
assert res29[5] == Declaration(
Variable(Symbol('c6'),
type=Type(String('bool')),
value=false
)
)
assert res30[0] == Declaration(
Variable(Symbol('a'),
type=Type(String('bool')),
value=false
)
)
assert res30[1] == Declaration(
Variable(Symbol('c1'),
type=Type(String('bool')),
value=Symbol('a')
)
)
assert res30[2] == Declaration(
Variable(Symbol('c2'),
type=Type(String('bool')),
value=false
)
)
assert res30[3] == Declaration(
Variable(Symbol('c3'),
type=Type(String('bool')),
value=true
)
)
assert res30[4] == Declaration(
Variable(Symbol('c4'),
type=Type(String('bool')),
value=Symbol('a')
)
)
assert res31[0] == Declaration(
Variable(Symbol('a'),
type=IntBaseType(String('intc')),
value=Integer(1)
)
)
assert res31[1] == Declaration(
Variable(Symbol('c1'),
type=Type(String('bool')),
value=Symbol('a')
)
)
assert res31[2] == Declaration(
Variable(Symbol('c2'),
type=Type(String('bool')),
value=false
)
)
assert res31[3] == Declaration(
Variable(Symbol('c3'),
type=Type(String('bool')),
value=true
)
)
assert res31[4] == Declaration(
Variable(Symbol('c4'),
type=Type(String('bool')),
value=Symbol('a')
)
)
assert res32[0] == Declaration(
Variable(Symbol('a'),
type=IntBaseType(String('intc')),
value=Integer(1)
)
)
assert res32[1] == Declaration(
Variable(Symbol('b'),
type=IntBaseType(String('intc')),
value=Integer(0)
)
)
assert res32[2] == Declaration(
Variable(Symbol('c'),
type=Type(String('bool')),
value=false
)
)
assert res32[3] == Declaration(
Variable(Symbol('d'),
type=Type(String('bool')),
value=true
)
)
assert res32[4] == Declaration(
Variable(Symbol('c1'),
type=Type(String('bool')),
value=And(
Symbol('a'),
Symbol('b')
)
)
)
assert res32[5] == Declaration(
Variable(Symbol('c2'),
type=Type(String('bool')),
value=And(
Symbol('a'),
Symbol('c')
)
)
)
assert res32[6] == Declaration(
Variable(Symbol('c3'),
type=Type(String('bool')),
value=And(
Symbol('c'),
Symbol('d')
)
)
)
assert res32[7] == Declaration(
Variable(Symbol('c4'),
type=Type(String('bool')),
value=Or(
Symbol('a'),
Symbol('b')
)
)
)
assert res32[8] == Declaration(
Variable(Symbol('c5'),
type=Type(String('bool')),
value=Or(
Symbol('a'),
Symbol('c')
)
)
)
assert res32[9] == Declaration(
Variable(Symbol('c6'),
type=Type(String('bool')),
value=Or(
Symbol('c'),
Symbol('d')
)
)
)
raises(NotImplementedError, lambda: SymPyExpression(c_src_raise1, 'c'))
raises(NotImplementedError, lambda: SymPyExpression(c_src_raise2, 'c'))
def test_paren_expr():
c_src1 = (
'int a = (1);'
'int b = (1 + 2 * 3);'
)
c_src2 = (
'int a = 1, b = 2, c = 3;'
'int d = (a);'
'int e = (a + 1);'
'int f = (a + b * c - d / e);'
)
res1 = SymPyExpression(c_src1, 'c').return_expr()
res2 = SymPyExpression(c_src2, 'c').return_expr()
assert res1[0] == Declaration(
Variable(Symbol('a'),
type=IntBaseType(String('intc')),
value=Integer(1)
)
)
assert res1[1] == Declaration(
Variable(Symbol('b'),
type=IntBaseType(String('intc')),
value=Integer(7)
)
)
assert res2[0] == Declaration(
Variable(Symbol('a'),
type=IntBaseType(String('intc')),
value=Integer(1)
)
)
assert res2[1] == Declaration(
Variable(Symbol('b'),
type=IntBaseType(String('intc')),
value=Integer(2)
)
)
assert res2[2] == Declaration(
Variable(Symbol('c'),
type=IntBaseType(String('intc')),
value=Integer(3)
)
)
assert res2[3] == Declaration(
Variable(Symbol('d'),
type=IntBaseType(String('intc')),
value=Symbol('a')
)
)
assert res2[4] == Declaration(
Variable(Symbol('e'),
type=IntBaseType(String('intc')),
value=Add(
Symbol('a'),
Integer(1)
)
)
)
assert res2[5] == Declaration(
Variable(Symbol('f'),
type=IntBaseType(String('intc')),
value=Add(
Symbol('a'),
Mul(
Symbol('b'),
Symbol('c')
),
Mul(
Integer(-1),
Symbol('d'),
Pow(
Symbol('e'),
Integer(-1)
)
)
)
)
)
def test_unary_operators():
c_src1 = (
'void func()'+
'{' + '\n' +
'int a = 10;' + '\n' +
'int b = 20;' + '\n' +
'++a;' + '\n' +
'--b;' + '\n' +
'a++;' + '\n' +
'b--;' + '\n' +
'}'
)
c_src2 = (
'void func()'+
'{' + '\n' +
'int a = 10;' + '\n' +
'int b = -100;' + '\n' +
'int c = +19;' + '\n' +
'int d = ++a;' + '\n' +
'int e = --b;' + '\n' +
'int f = a++;' + '\n' +
'int g = b--;' + '\n' +
'bool h = !false;' + '\n' +
'bool i = !d;' + '\n' +
'bool j = !0;' + '\n' +
'bool k = !10.0;' + '\n' +
'}'
)
c_src_raise1 = (
'void func()'+
'{' + '\n' +
'int a = 10;' + '\n' +
'int b = ~a;' + '\n' +
'}'
)
c_src_raise2 = (
'void func()'+
'{' + '\n' +
'int a = 10;' + '\n' +
'int b = *&a;' + '\n' +
'}'
)
res1 = SymPyExpression(c_src1, 'c').return_expr()
res2 = SymPyExpression(c_src2, 'c').return_expr()
assert res1[0] == FunctionDefinition(
NoneToken(),
name=String('func'),
parameters=(),
body=CodeBlock(
Declaration(
Variable(Symbol('a'),
type=IntBaseType(String('intc')),
value=Integer(10)
)
),
Declaration(
Variable(Symbol('b'),
type=IntBaseType(String('intc')),
value=Integer(20)
)
),
PreIncrement(Symbol('a')),
PreDecrement(Symbol('b')),
PostIncrement(Symbol('a')),
PostDecrement(Symbol('b'))
)
)
assert res2[0] == FunctionDefinition(
NoneToken(),
name=String('func'),
parameters=(),
body=CodeBlock(
Declaration(
Variable(Symbol('a'),
type=IntBaseType(String('intc')),
value=Integer(10)
)
),
Declaration(
Variable(Symbol('b'),
type=IntBaseType(String('intc')),
value=Integer(-100)
)
),
Declaration(
Variable(Symbol('c'),
type=IntBaseType(String('intc')),
value=Integer(19)
)
),
Declaration(
Variable(Symbol('d'),
type=IntBaseType(String('intc')),
value=PreIncrement(Symbol('a'))
)
),
Declaration(
Variable(Symbol('e'),
type=IntBaseType(String('intc')),
value=PreDecrement(Symbol('b'))
)
),
Declaration(
Variable(Symbol('f'),
type=IntBaseType(String('intc')),
value=PostIncrement(Symbol('a'))
)
),
Declaration(
Variable(Symbol('g'),
type=IntBaseType(String('intc')),
value=PostDecrement(Symbol('b'))
)
),
Declaration(
Variable(Symbol('h'),
type=Type(String('bool')),
value=true
)
),
Declaration(
Variable(Symbol('i'),
type=Type(String('bool')),
value=Not(Symbol('d'))
)
),
Declaration(
Variable(Symbol('j'),
type=Type(String('bool')),
value=true
)
),
Declaration(
Variable(Symbol('k'),
type=Type(String('bool')),
value=false
)
)
)
)
raises(NotImplementedError, lambda: SymPyExpression(c_src_raise1, 'c'))
raises(NotImplementedError, lambda: SymPyExpression(c_src_raise2, 'c'))
def test_compound_assignment_operator():
c_src = (
'void func()'+
'{' + '\n' +
'int a = 100;' + '\n' +
'a += 10;' + '\n' +
'a -= 10;' + '\n' +
'a *= 10;' + '\n' +
'a /= 10;' + '\n' +
'a %= 10;' + '\n' +
'}'
)
res = SymPyExpression(c_src, 'c').return_expr()
assert res[0] == FunctionDefinition(
NoneToken(),
name=String('func'),
parameters=(),
body=CodeBlock(
Declaration(
Variable(
Symbol('a'),
type=IntBaseType(String('intc')),
value=Integer(100)
)
),
AddAugmentedAssignment(
Variable(Symbol('a')),
Integer(10)
),
SubAugmentedAssignment(
Variable(Symbol('a')),
Integer(10)
),
MulAugmentedAssignment(
Variable(Symbol('a')),
Integer(10)
),
DivAugmentedAssignment(
Variable(Symbol('a')),
Integer(10)
),
ModAugmentedAssignment(
Variable(Symbol('a')),
Integer(10)
)
)
)
else:
def test_raise():
from sympy.parsing.c.c_parser import CCodeConverter
raises(ImportError, lambda: CCodeConverter())
raises(ImportError, lambda: SymPyExpression(' ', mode = 'c'))
|
00781e42e814a6ab09e1f77bf9210b40c39e3bbc6cda88ab46883727ec225047 | from sympy.parsing.mathematica import mathematica
from sympy import sympify
def test_mathematica():
d = {
'- 6x': '-6*x',
'Sin[x]^2': 'sin(x)**2',
'2(x-1)': '2*(x-1)',
'3y+8': '3*y+8',
'ArcSin[2x+9(4-x)^2]/x': 'asin(2*x+9*(4-x)**2)/x',
'x+y': 'x+y',
'355/113': '355/113',
'2.718281828': '2.718281828',
'Sin[12]': 'sin(12)',
'Exp[Log[4]]': 'exp(log(4))',
'(x+1)(x+3)': '(x+1)*(x+3)',
'Cos[ArcCos[3.6]]': 'cos(acos(3.6))',
'Cos[x]==Sin[y]': 'cos(x)==sin(y)',
'2*Sin[x+y]': '2*sin(x+y)',
'Sin[x]+Cos[y]': 'sin(x)+cos(y)',
'Sin[Cos[x]]': 'sin(cos(x))',
'2*Sqrt[x+y]': '2*sqrt(x+y)', # Test case from the issue 4259
'+Sqrt[2]': 'sqrt(2)',
'-Sqrt[2]': '-sqrt(2)',
'-1/Sqrt[2]': '-1/sqrt(2)',
'-(1/Sqrt[3])': '-(1/sqrt(3))',
'1/(2*Sqrt[5])': '1/(2*sqrt(5))',
'Mod[5,3]': 'Mod(5,3)',
'-Mod[5,3]': '-Mod(5,3)',
'(x+1)y': '(x+1)*y',
'x(y+1)': 'x*(y+1)',
'Sin[x]Cos[y]': 'sin(x)*cos(y)',
'Sin[x]**2Cos[y]**2': 'sin(x)**2*cos(y)**2',
'Cos[x]^2(1 - Cos[y]^2)': 'cos(x)**2*(1-cos(y)**2)',
'x y': 'x*y',
'2 x': '2*x',
'x 8': 'x*8',
'2 8': '2*8',
'1 2 3': '1*2*3',
' - 2 * Sqrt[ 2 3 * ( 1 + 5 ) ] ': '-2*sqrt(2*3*(1+5))',
'Log[2,4]': 'log(4,2)',
'Log[Log[2,4],4]': 'log(4,log(4,2))',
'Exp[Sqrt[2]^2Log[2, 8]]': 'exp(sqrt(2)**2*log(8,2))',
'ArcSin[Cos[0]]': 'asin(cos(0))',
'Log2[16]': 'log(16,2)',
'Max[1,-2,3,-4]': 'Max(1,-2,3,-4)',
'Min[1,-2,3]': 'Min(1,-2,3)',
'Exp[I Pi/2]': 'exp(I*pi/2)',
'ArcTan[x,y]': 'atan2(y,x)',
'Pochhammer[x,y]': 'rf(x,y)',
'ExpIntegralEi[x]': 'Ei(x)',
'SinIntegral[x]': 'Si(x)',
'CosIntegral[x]': 'Ci(x)',
'AiryAi[x]': 'airyai(x)',
'AiryAiPrime[5]': 'airyaiprime(5)',
'AiryBi[x]' :'airybi(x)',
'AiryBiPrime[7]' :'airybiprime(7)',
'LogIntegral[4]':' li(4)',
'PrimePi[7]': 'primepi(7)',
'Prime[5]': 'prime(5)',
'PrimeQ[5]': 'isprime(5)'
}
for e in d:
assert mathematica(e) == sympify(d[e])
|
ea942f2a9ec58cca9a0ffbc0b0910bf49b6754cd129b2cd134a1715227934bac | # Ported from latex2sympy by @augustt198
# https://github.com/augustt198/latex2sympy
# See license in LICENSE.txt
import sympy
from sympy.external import import_module
from sympy.printing.str import StrPrinter
from .errors import LaTeXParsingError
LaTeXParser = LaTeXLexer = MathErrorListener = None
try:
LaTeXParser = import_module('sympy.parsing.latex._antlr.latexparser',
import_kwargs={'fromlist': ['LaTeXParser']}).LaTeXParser
LaTeXLexer = import_module('sympy.parsing.latex._antlr.latexlexer',
import_kwargs={'fromlist': ['LaTeXLexer']}).LaTeXLexer
except Exception:
pass
ErrorListener = import_module('antlr4.error.ErrorListener',
warn_not_installed=True,
import_kwargs={'fromlist': ['ErrorListener']}
)
if ErrorListener:
class MathErrorListener(ErrorListener.ErrorListener): # type: ignore
def __init__(self, src):
super(ErrorListener.ErrorListener, self).__init__()
self.src = src
def syntaxError(self, recog, symbol, line, col, msg, e):
fmt = "%s\n%s\n%s"
marker = "~" * col + "^"
if msg.startswith("missing"):
err = fmt % (msg, self.src, marker)
elif msg.startswith("no viable"):
err = fmt % ("I expected something else here", self.src, marker)
elif msg.startswith("mismatched"):
names = LaTeXParser.literalNames
expected = [
names[i] for i in e.getExpectedTokens() if i < len(names)
]
if len(expected) < 10:
expected = " ".join(expected)
err = (fmt % ("I expected one of these: " + expected, self.src,
marker))
else:
err = (fmt % ("I expected something else here", self.src,
marker))
else:
err = fmt % ("I don't understand this", self.src, marker)
raise LaTeXParsingError(err)
def parse_latex(sympy):
antlr4 = import_module('antlr4', warn_not_installed=True)
if None in [antlr4, MathErrorListener]:
raise ImportError("LaTeX parsing requires the antlr4 python package,"
" provided by pip (antlr4-python2-runtime or"
" antlr4-python3-runtime) or"
" conda (antlr-python-runtime)")
matherror = MathErrorListener(sympy)
stream = antlr4.InputStream(sympy)
lex = LaTeXLexer(stream)
lex.removeErrorListeners()
lex.addErrorListener(matherror)
tokens = antlr4.CommonTokenStream(lex)
parser = LaTeXParser(tokens)
# remove default console error listener
parser.removeErrorListeners()
parser.addErrorListener(matherror)
relation = parser.math().relation()
expr = convert_relation(relation)
return expr
def convert_relation(rel):
if rel.expr():
return convert_expr(rel.expr())
lh = convert_relation(rel.relation(0))
rh = convert_relation(rel.relation(1))
if rel.LT():
return sympy.StrictLessThan(lh, rh)
elif rel.LTE():
return sympy.LessThan(lh, rh)
elif rel.GT():
return sympy.StrictGreaterThan(lh, rh)
elif rel.GTE():
return sympy.GreaterThan(lh, rh)
elif rel.EQUAL():
return sympy.Eq(lh, rh)
def convert_expr(expr):
return convert_add(expr.additive())
def convert_add(add):
if add.ADD():
lh = convert_add(add.additive(0))
rh = convert_add(add.additive(1))
return sympy.Add(lh, rh, evaluate=False)
elif add.SUB():
lh = convert_add(add.additive(0))
rh = convert_add(add.additive(1))
return sympy.Add(lh, -1 * rh, evaluate=False)
else:
return convert_mp(add.mp())
def convert_mp(mp):
if hasattr(mp, 'mp'):
mp_left = mp.mp(0)
mp_right = mp.mp(1)
else:
mp_left = mp.mp_nofunc(0)
mp_right = mp.mp_nofunc(1)
if mp.MUL() or mp.CMD_TIMES() or mp.CMD_CDOT():
lh = convert_mp(mp_left)
rh = convert_mp(mp_right)
return sympy.Mul(lh, rh, evaluate=False)
elif mp.DIV() or mp.CMD_DIV() or mp.COLON():
lh = convert_mp(mp_left)
rh = convert_mp(mp_right)
return sympy.Mul(lh, sympy.Pow(rh, -1, evaluate=False), evaluate=False)
else:
if hasattr(mp, 'unary'):
return convert_unary(mp.unary())
else:
return convert_unary(mp.unary_nofunc())
def convert_unary(unary):
if hasattr(unary, 'unary'):
nested_unary = unary.unary()
else:
nested_unary = unary.unary_nofunc()
if hasattr(unary, 'postfix_nofunc'):
first = unary.postfix()
tail = unary.postfix_nofunc()
postfix = [first] + tail
else:
postfix = unary.postfix()
if unary.ADD():
return convert_unary(nested_unary)
elif unary.SUB():
return sympy.Mul(-1, convert_unary(nested_unary), evaluate=False)
elif postfix:
return convert_postfix_list(postfix)
def convert_postfix_list(arr, i=0):
if i >= len(arr):
raise LaTeXParsingError("Index out of bounds")
res = convert_postfix(arr[i])
if isinstance(res, sympy.Expr):
if i == len(arr) - 1:
return res # nothing to multiply by
else:
if i > 0:
left = convert_postfix(arr[i - 1])
right = convert_postfix(arr[i + 1])
if isinstance(left, sympy.Expr) and isinstance(
right, sympy.Expr):
left_syms = convert_postfix(arr[i - 1]).atoms(sympy.Symbol)
right_syms = convert_postfix(arr[i + 1]).atoms(
sympy.Symbol)
# if the left and right sides contain no variables and the
# symbol in between is 'x', treat as multiplication.
if len(left_syms) == 0 and len(right_syms) == 0 and str(
res) == "x":
return convert_postfix_list(arr, i + 1)
# multiply by next
return sympy.Mul(
res, convert_postfix_list(arr, i + 1), evaluate=False)
else: # must be derivative
wrt = res[0]
if i == len(arr) - 1:
raise LaTeXParsingError("Expected expression for derivative")
else:
expr = convert_postfix_list(arr, i + 1)
return sympy.Derivative(expr, wrt)
def do_subs(expr, at):
if at.expr():
at_expr = convert_expr(at.expr())
syms = at_expr.atoms(sympy.Symbol)
if len(syms) == 0:
return expr
elif len(syms) > 0:
sym = next(iter(syms))
return expr.subs(sym, at_expr)
elif at.equality():
lh = convert_expr(at.equality().expr(0))
rh = convert_expr(at.equality().expr(1))
return expr.subs(lh, rh)
def convert_postfix(postfix):
if hasattr(postfix, 'exp'):
exp_nested = postfix.exp()
else:
exp_nested = postfix.exp_nofunc()
exp = convert_exp(exp_nested)
for op in postfix.postfix_op():
if op.BANG():
if isinstance(exp, list):
raise LaTeXParsingError("Cannot apply postfix to derivative")
exp = sympy.factorial(exp, evaluate=False)
elif op.eval_at():
ev = op.eval_at()
at_b = None
at_a = None
if ev.eval_at_sup():
at_b = do_subs(exp, ev.eval_at_sup())
if ev.eval_at_sub():
at_a = do_subs(exp, ev.eval_at_sub())
if at_b is not None and at_a is not None:
exp = sympy.Add(at_b, -1 * at_a, evaluate=False)
elif at_b is not None:
exp = at_b
elif at_a is not None:
exp = at_a
return exp
def convert_exp(exp):
if hasattr(exp, 'exp'):
exp_nested = exp.exp()
else:
exp_nested = exp.exp_nofunc()
if exp_nested:
base = convert_exp(exp_nested)
if isinstance(base, list):
raise LaTeXParsingError("Cannot raise derivative to power")
if exp.atom():
exponent = convert_atom(exp.atom())
elif exp.expr():
exponent = convert_expr(exp.expr())
return sympy.Pow(base, exponent, evaluate=False)
else:
if hasattr(exp, 'comp'):
return convert_comp(exp.comp())
else:
return convert_comp(exp.comp_nofunc())
def convert_comp(comp):
if comp.group():
return convert_expr(comp.group().expr())
elif comp.abs_group():
return sympy.Abs(convert_expr(comp.abs_group().expr()), evaluate=False)
elif comp.atom():
return convert_atom(comp.atom())
elif comp.frac():
return convert_frac(comp.frac())
elif comp.binom():
return convert_binom(comp.binom())
elif comp.func():
return convert_func(comp.func())
def convert_atom(atom):
if atom.LETTER():
subscriptName = ''
if atom.subexpr():
subscript = None
if atom.subexpr().expr(): # subscript is expr
subscript = convert_expr(atom.subexpr().expr())
else: # subscript is atom
subscript = convert_atom(atom.subexpr().atom())
subscriptName = '_{' + StrPrinter().doprint(subscript) + '}'
return sympy.Symbol(atom.LETTER().getText() + subscriptName)
elif atom.SYMBOL():
s = atom.SYMBOL().getText()[1:]
if s == "infty":
return sympy.oo
else:
if atom.subexpr():
subscript = None
if atom.subexpr().expr(): # subscript is expr
subscript = convert_expr(atom.subexpr().expr())
else: # subscript is atom
subscript = convert_atom(atom.subexpr().atom())
subscriptName = StrPrinter().doprint(subscript)
s += '_{' + subscriptName + '}'
return sympy.Symbol(s)
elif atom.NUMBER():
s = atom.NUMBER().getText().replace(",", "")
return sympy.Number(s)
elif atom.DIFFERENTIAL():
var = get_differential_var(atom.DIFFERENTIAL())
return sympy.Symbol('d' + var.name)
elif atom.mathit():
text = rule2text(atom.mathit().mathit_text())
return sympy.Symbol(text)
def rule2text(ctx):
stream = ctx.start.getInputStream()
# starting index of starting token
startIdx = ctx.start.start
# stopping index of stopping token
stopIdx = ctx.stop.stop
return stream.getText(startIdx, stopIdx)
def convert_frac(frac):
diff_op = False
partial_op = False
lower_itv = frac.lower.getSourceInterval()
lower_itv_len = lower_itv[1] - lower_itv[0] + 1
if (frac.lower.start == frac.lower.stop
and frac.lower.start.type == LaTeXLexer.DIFFERENTIAL):
wrt = get_differential_var_str(frac.lower.start.text)
diff_op = True
elif (lower_itv_len == 2 and frac.lower.start.type == LaTeXLexer.SYMBOL
and frac.lower.start.text == '\\partial'
and (frac.lower.stop.type == LaTeXLexer.LETTER
or frac.lower.stop.type == LaTeXLexer.SYMBOL)):
partial_op = True
wrt = frac.lower.stop.text
if frac.lower.stop.type == LaTeXLexer.SYMBOL:
wrt = wrt[1:]
if diff_op or partial_op:
wrt = sympy.Symbol(wrt)
if (diff_op and frac.upper.start == frac.upper.stop
and frac.upper.start.type == LaTeXLexer.LETTER
and frac.upper.start.text == 'd'):
return [wrt]
elif (partial_op and frac.upper.start == frac.upper.stop
and frac.upper.start.type == LaTeXLexer.SYMBOL
and frac.upper.start.text == '\\partial'):
return [wrt]
upper_text = rule2text(frac.upper)
expr_top = None
if diff_op and upper_text.startswith('d'):
expr_top = parse_latex(upper_text[1:])
elif partial_op and frac.upper.start.text == '\\partial':
expr_top = parse_latex(upper_text[len('\\partial'):])
if expr_top:
return sympy.Derivative(expr_top, wrt)
expr_top = convert_expr(frac.upper)
expr_bot = convert_expr(frac.lower)
return sympy.Mul(
expr_top, sympy.Pow(expr_bot, -1, evaluate=False), evaluate=False)
def convert_binom(binom):
expr_n = convert_expr(binom.n)
expr_k = convert_expr(binom.k)
return sympy.binomial(expr_n, expr_k, evaluate=False)
def convert_func(func):
if func.func_normal():
if func.L_PAREN(): # function called with parenthesis
arg = convert_func_arg(func.func_arg())
else:
arg = convert_func_arg(func.func_arg_noparens())
name = func.func_normal().start.text[1:]
# change arc<trig> -> a<trig>
if name in [
"arcsin", "arccos", "arctan", "arccsc", "arcsec", "arccot"
]:
name = "a" + name[3:]
expr = getattr(sympy.functions, name)(arg, evaluate=False)
if name in ["arsinh", "arcosh", "artanh"]:
name = "a" + name[2:]
expr = getattr(sympy.functions, name)(arg, evaluate=False)
if (name == "log" or name == "ln"):
if func.subexpr():
base = convert_expr(func.subexpr().expr())
elif name == "log":
base = 10
elif name == "ln":
base = sympy.E
expr = sympy.log(arg, base, evaluate=False)
func_pow = None
should_pow = True
if func.supexpr():
if func.supexpr().expr():
func_pow = convert_expr(func.supexpr().expr())
else:
func_pow = convert_atom(func.supexpr().atom())
if name in [
"sin", "cos", "tan", "csc", "sec", "cot", "sinh", "cosh",
"tanh"
]:
if func_pow == -1:
name = "a" + name
should_pow = False
expr = getattr(sympy.functions, name)(arg, evaluate=False)
if func_pow and should_pow:
expr = sympy.Pow(expr, func_pow, evaluate=False)
return expr
elif func.LETTER() or func.SYMBOL():
if func.LETTER():
fname = func.LETTER().getText()
elif func.SYMBOL():
fname = func.SYMBOL().getText()[1:]
fname = str(fname) # can't be unicode
if func.subexpr():
subscript = None
if func.subexpr().expr(): # subscript is expr
subscript = convert_expr(func.subexpr().expr())
else: # subscript is atom
subscript = convert_atom(func.subexpr().atom())
subscriptName = StrPrinter().doprint(subscript)
fname += '_{' + subscriptName + '}'
input_args = func.args()
output_args = []
while input_args.args(): # handle multiple arguments to function
output_args.append(convert_expr(input_args.expr()))
input_args = input_args.args()
output_args.append(convert_expr(input_args.expr()))
return sympy.Function(fname)(*output_args)
elif func.FUNC_INT():
return handle_integral(func)
elif func.FUNC_SQRT():
expr = convert_expr(func.base)
if func.root:
r = convert_expr(func.root)
return sympy.root(expr, r)
else:
return sympy.sqrt(expr)
elif func.FUNC_SUM():
return handle_sum_or_prod(func, "summation")
elif func.FUNC_PROD():
return handle_sum_or_prod(func, "product")
elif func.FUNC_LIM():
return handle_limit(func)
def convert_func_arg(arg):
if hasattr(arg, 'expr'):
return convert_expr(arg.expr())
else:
return convert_mp(arg.mp_nofunc())
def handle_integral(func):
if func.additive():
integrand = convert_add(func.additive())
elif func.frac():
integrand = convert_frac(func.frac())
else:
integrand = 1
int_var = None
if func.DIFFERENTIAL():
int_var = get_differential_var(func.DIFFERENTIAL())
else:
for sym in integrand.atoms(sympy.Symbol):
s = str(sym)
if len(s) > 1 and s[0] == 'd':
if s[1] == '\\':
int_var = sympy.Symbol(s[2:])
else:
int_var = sympy.Symbol(s[1:])
int_sym = sym
if int_var:
integrand = integrand.subs(int_sym, 1)
else:
# Assume dx by default
int_var = sympy.Symbol('x')
if func.subexpr():
if func.subexpr().atom():
lower = convert_atom(func.subexpr().atom())
else:
lower = convert_expr(func.subexpr().expr())
if func.supexpr().atom():
upper = convert_atom(func.supexpr().atom())
else:
upper = convert_expr(func.supexpr().expr())
return sympy.Integral(integrand, (int_var, lower, upper))
else:
return sympy.Integral(integrand, int_var)
def handle_sum_or_prod(func, name):
val = convert_mp(func.mp())
iter_var = convert_expr(func.subeq().equality().expr(0))
start = convert_expr(func.subeq().equality().expr(1))
if func.supexpr().expr(): # ^{expr}
end = convert_expr(func.supexpr().expr())
else: # ^atom
end = convert_atom(func.supexpr().atom())
if name == "summation":
return sympy.Sum(val, (iter_var, start, end))
elif name == "product":
return sympy.Product(val, (iter_var, start, end))
def handle_limit(func):
sub = func.limit_sub()
if sub.LETTER():
var = sympy.Symbol(sub.LETTER().getText())
elif sub.SYMBOL():
var = sympy.Symbol(sub.SYMBOL().getText()[1:])
else:
var = sympy.Symbol('x')
if sub.SUB():
direction = "-"
else:
direction = "+"
approaching = convert_expr(sub.expr())
content = convert_mp(func.mp())
return sympy.Limit(content, var, approaching, direction)
def get_differential_var(d):
text = get_differential_var_str(d.getText())
return sympy.Symbol(text)
def get_differential_var_str(text):
for i in range(1, len(text)):
c = text[i]
if not (c == " " or c == "\r" or c == "\n" or c == "\t"):
idx = i
break
text = text[idx:]
if text[0] == "\\":
text = text[1:]
return text
|
81ca46167835bcaead0ca832202bd1c4a753aaef6c8d130b8db4868aa96d4df3 |
# encoding: utf-8
# *** GENERATED BY `setup.py antlr`, DO NOT EDIT BY HAND ***
#
# Generated from ../LaTeX.g4, derived from latex2sympy
# latex2sympy is licensed under the MIT license
# https://github.com/augustt198/latex2sympy/blob/master/LICENSE.txt
#
# Generated with antlr4
# antlr4 is licensed under the BSD-3-Clause License
# https://github.com/antlr/antlr4/blob/master/LICENSE.txt
from __future__ import print_function
from antlr4 import *
from io import StringIO
import sys
def serializedATN():
with StringIO() as buf:
buf.write(u"\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\2")
buf.write(u">\u0205\b\1\4\2\t\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4")
buf.write(u"\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13\t\13\4\f\t\f\4\r")
buf.write(u"\t\r\4\16\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22\t\22")
buf.write(u"\4\23\t\23\4\24\t\24\4\25\t\25\4\26\t\26\4\27\t\27\4")
buf.write(u"\30\t\30\4\31\t\31\4\32\t\32\4\33\t\33\4\34\t\34\4\35")
buf.write(u"\t\35\4\36\t\36\4\37\t\37\4 \t \4!\t!\4\"\t\"\4#\t#\4")
buf.write(u"$\t$\4%\t%\4&\t&\4\'\t\'\4(\t(\4)\t)\4*\t*\4+\t+\4,\t")
buf.write(u",\4-\t-\4.\t.\4/\t/\4\60\t\60\4\61\t\61\4\62\t\62\4\63")
buf.write(u"\t\63\4\64\t\64\4\65\t\65\4\66\t\66\4\67\t\67\48\t8\4")
buf.write(u"9\t9\4:\t:\4;\t;\4<\t<\4=\t=\4>\t>\4?\t?\3\2\3\2\3\3")
buf.write(u"\6\3\u0083\n\3\r\3\16\3\u0084\3\3\3\3\3\4\3\4\3\5\3\5")
buf.write(u"\3\6\3\6\3\7\3\7\3\b\3\b\3\t\3\t\3\n\3\n\3\13\3\13\3")
buf.write(u"\f\3\f\3\r\3\r\3\16\3\16\3\17\3\17\3\17\3\17\3\17\3\20")
buf.write(u"\3\20\3\20\3\20\3\20\3\20\3\20\3\20\3\20\3\20\3\20\3")
buf.write(u"\20\3\20\3\20\3\20\3\20\3\20\3\20\3\20\3\20\3\20\3\20")
buf.write(u"\3\20\3\20\3\20\3\20\3\20\3\20\3\20\3\20\3\20\3\20\3")
buf.write(u"\20\3\20\3\20\3\20\3\20\3\20\3\20\3\20\3\20\3\20\3\20")
buf.write(u"\3\20\3\20\3\20\3\20\3\20\3\20\3\20\3\20\3\20\3\20\3")
buf.write(u"\20\3\20\5\20\u00db\n\20\3\21\3\21\3\21\3\21\3\21\3\22")
buf.write(u"\3\22\3\22\3\22\3\22\3\23\3\23\3\23\3\23\3\23\3\23\3")
buf.write(u"\24\3\24\3\24\3\24\3\24\3\25\3\25\3\25\3\25\3\26\3\26")
buf.write(u"\3\26\3\26\3\26\3\27\3\27\3\27\3\27\3\27\3\30\3\30\3")
buf.write(u"\30\3\30\3\30\3\31\3\31\3\31\3\31\3\31\3\32\3\32\3\32")
buf.write(u"\3\32\3\32\3\33\3\33\3\33\3\33\3\33\3\34\3\34\3\34\3")
buf.write(u"\34\3\34\3\34\3\34\3\34\3\35\3\35\3\35\3\35\3\35\3\35")
buf.write(u"\3\35\3\35\3\36\3\36\3\36\3\36\3\36\3\36\3\36\3\36\3")
buf.write(u"\37\3\37\3\37\3\37\3\37\3\37\3\37\3\37\3 \3 \3 \3 \3")
buf.write(u" \3 \3 \3 \3!\3!\3!\3!\3!\3!\3!\3!\3\"\3\"\3\"\3\"\3")
buf.write(u"\"\3\"\3#\3#\3#\3#\3#\3#\3$\3$\3$\3$\3$\3$\3%\3%\3%\3")
buf.write(u"%\3%\3%\3%\3%\3&\3&\3&\3&\3&\3&\3&\3&\3\'\3\'\3\'\3\'")
buf.write(u"\3\'\3\'\3\'\3\'\3(\3(\3(\3(\3(\3(\3)\3)\3)\3)\3)\3)")
buf.write(u"\3)\3*\3*\3*\3*\3*\3*\3+\3+\3+\3+\3+\3,\3,\3,\3,\3,\3")
buf.write(u",\3-\3-\3-\3-\3-\3-\3-\3.\3.\3.\3.\3.\3.\3.\3.\3/\3/")
buf.write(u"\3/\3/\3/\3/\3/\3/\3\60\3\60\3\60\3\60\3\60\3\60\3\60")
buf.write(u"\3\60\3\61\3\61\3\62\3\62\3\63\3\63\3\64\3\64\3\65\3")
buf.write(u"\65\7\65\u01b5\n\65\f\65\16\65\u01b8\13\65\3\65\3\65")
buf.write(u"\3\65\6\65\u01bd\n\65\r\65\16\65\u01be\5\65\u01c1\n\65")
buf.write(u"\3\66\3\66\3\67\3\67\38\68\u01c8\n8\r8\168\u01c9\38\3")
buf.write(u"8\38\38\38\78\u01d1\n8\f8\168\u01d4\138\38\78\u01d7\n")
buf.write(u"8\f8\168\u01da\138\38\38\38\38\38\78\u01e1\n8\f8\168")
buf.write(u"\u01e4\138\38\38\68\u01e8\n8\r8\168\u01e9\58\u01ec\n")
buf.write(u"8\39\39\3:\3:\3;\3;\3;\3;\3;\3<\3<\3=\3=\3=\3=\3=\3>")
buf.write(u"\3>\3?\3?\6?\u0202\n?\r?\16?\u0203\3\u01b6\2@\3\3\5\4")
buf.write(u"\7\5\t\6\13\7\r\b\17\t\21\n\23\13\25\f\27\r\31\16\33")
buf.write(u"\17\35\20\37\21!\22#\23%\24\'\25)\26+\27-\30/\31\61\32")
buf.write(u"\63\33\65\34\67\359\36;\37= ?!A\"C#E$G%I&K\'M(O)Q*S+")
buf.write(u"U,W-Y.[/]\60_\61a\62c\63e\64g\2i\65k\66m\2o\67q8s9u:")
buf.write(u"w;y<{=}>\3\2\5\5\2\13\f\17\17\"\"\4\2C\\c|\3\2\62;\2")
buf.write(u"\u0211\2\3\3\2\2\2\2\5\3\2\2\2\2\7\3\2\2\2\2\t\3\2\2")
buf.write(u"\2\2\13\3\2\2\2\2\r\3\2\2\2\2\17\3\2\2\2\2\21\3\2\2\2")
buf.write(u"\2\23\3\2\2\2\2\25\3\2\2\2\2\27\3\2\2\2\2\31\3\2\2\2")
buf.write(u"\2\33\3\2\2\2\2\35\3\2\2\2\2\37\3\2\2\2\2!\3\2\2\2\2")
buf.write(u"#\3\2\2\2\2%\3\2\2\2\2\'\3\2\2\2\2)\3\2\2\2\2+\3\2\2")
buf.write(u"\2\2-\3\2\2\2\2/\3\2\2\2\2\61\3\2\2\2\2\63\3\2\2\2\2")
buf.write(u"\65\3\2\2\2\2\67\3\2\2\2\29\3\2\2\2\2;\3\2\2\2\2=\3\2")
buf.write(u"\2\2\2?\3\2\2\2\2A\3\2\2\2\2C\3\2\2\2\2E\3\2\2\2\2G\3")
buf.write(u"\2\2\2\2I\3\2\2\2\2K\3\2\2\2\2M\3\2\2\2\2O\3\2\2\2\2")
buf.write(u"Q\3\2\2\2\2S\3\2\2\2\2U\3\2\2\2\2W\3\2\2\2\2Y\3\2\2\2")
buf.write(u"\2[\3\2\2\2\2]\3\2\2\2\2_\3\2\2\2\2a\3\2\2\2\2c\3\2\2")
buf.write(u"\2\2e\3\2\2\2\2i\3\2\2\2\2k\3\2\2\2\2o\3\2\2\2\2q\3\2")
buf.write(u"\2\2\2s\3\2\2\2\2u\3\2\2\2\2w\3\2\2\2\2y\3\2\2\2\2{\3")
buf.write(u"\2\2\2\2}\3\2\2\2\3\177\3\2\2\2\5\u0082\3\2\2\2\7\u0088")
buf.write(u"\3\2\2\2\t\u008a\3\2\2\2\13\u008c\3\2\2\2\r\u008e\3\2")
buf.write(u"\2\2\17\u0090\3\2\2\2\21\u0092\3\2\2\2\23\u0094\3\2\2")
buf.write(u"\2\25\u0096\3\2\2\2\27\u0098\3\2\2\2\31\u009a\3\2\2\2")
buf.write(u"\33\u009c\3\2\2\2\35\u009e\3\2\2\2\37\u00da\3\2\2\2!")
buf.write(u"\u00dc\3\2\2\2#\u00e1\3\2\2\2%\u00e6\3\2\2\2\'\u00ec")
buf.write(u"\3\2\2\2)\u00f1\3\2\2\2+\u00f5\3\2\2\2-\u00fa\3\2\2\2")
buf.write(u"/\u00ff\3\2\2\2\61\u0104\3\2\2\2\63\u0109\3\2\2\2\65")
buf.write(u"\u010e\3\2\2\2\67\u0113\3\2\2\29\u011b\3\2\2\2;\u0123")
buf.write(u"\3\2\2\2=\u012b\3\2\2\2?\u0133\3\2\2\2A\u013b\3\2\2\2")
buf.write(u"C\u0143\3\2\2\2E\u0149\3\2\2\2G\u014f\3\2\2\2I\u0155")
buf.write(u"\3\2\2\2K\u015d\3\2\2\2M\u0165\3\2\2\2O\u016d\3\2\2\2")
buf.write(u"Q\u0173\3\2\2\2S\u017a\3\2\2\2U\u0180\3\2\2\2W\u0185")
buf.write(u"\3\2\2\2Y\u018b\3\2\2\2[\u0192\3\2\2\2]\u019a\3\2\2\2")
buf.write(u"_\u01a2\3\2\2\2a\u01aa\3\2\2\2c\u01ac\3\2\2\2e\u01ae")
buf.write(u"\3\2\2\2g\u01b0\3\2\2\2i\u01b2\3\2\2\2k\u01c2\3\2\2\2")
buf.write(u"m\u01c4\3\2\2\2o\u01eb\3\2\2\2q\u01ed\3\2\2\2s\u01ef")
buf.write(u"\3\2\2\2u\u01f1\3\2\2\2w\u01f6\3\2\2\2y\u01f8\3\2\2\2")
buf.write(u"{\u01fd\3\2\2\2}\u01ff\3\2\2\2\177\u0080\7.\2\2\u0080")
buf.write(u"\4\3\2\2\2\u0081\u0083\t\2\2\2\u0082\u0081\3\2\2\2\u0083")
buf.write(u"\u0084\3\2\2\2\u0084\u0082\3\2\2\2\u0084\u0085\3\2\2")
buf.write(u"\2\u0085\u0086\3\2\2\2\u0086\u0087\b\3\2\2\u0087\6\3")
buf.write(u"\2\2\2\u0088\u0089\7-\2\2\u0089\b\3\2\2\2\u008a\u008b")
buf.write(u"\7/\2\2\u008b\n\3\2\2\2\u008c\u008d\7,\2\2\u008d\f\3")
buf.write(u"\2\2\2\u008e\u008f\7\61\2\2\u008f\16\3\2\2\2\u0090\u0091")
buf.write(u"\7*\2\2\u0091\20\3\2\2\2\u0092\u0093\7+\2\2\u0093\22")
buf.write(u"\3\2\2\2\u0094\u0095\7}\2\2\u0095\24\3\2\2\2\u0096\u0097")
buf.write(u"\7\177\2\2\u0097\26\3\2\2\2\u0098\u0099\7]\2\2\u0099")
buf.write(u"\30\3\2\2\2\u009a\u009b\7_\2\2\u009b\32\3\2\2\2\u009c")
buf.write(u"\u009d\7~\2\2\u009d\34\3\2\2\2\u009e\u009f\7^\2\2\u009f")
buf.write(u"\u00a0\7n\2\2\u00a0\u00a1\7k\2\2\u00a1\u00a2\7o\2\2\u00a2")
buf.write(u"\36\3\2\2\2\u00a3\u00a4\7^\2\2\u00a4\u00a5\7v\2\2\u00a5")
buf.write(u"\u00db\7q\2\2\u00a6\u00a7\7^\2\2\u00a7\u00a8\7t\2\2\u00a8")
buf.write(u"\u00a9\7k\2\2\u00a9\u00aa\7i\2\2\u00aa\u00ab\7j\2\2\u00ab")
buf.write(u"\u00ac\7v\2\2\u00ac\u00ad\7c\2\2\u00ad\u00ae\7t\2\2\u00ae")
buf.write(u"\u00af\7t\2\2\u00af\u00b0\7q\2\2\u00b0\u00db\7y\2\2\u00b1")
buf.write(u"\u00b2\7^\2\2\u00b2\u00b3\7T\2\2\u00b3\u00b4\7k\2\2\u00b4")
buf.write(u"\u00b5\7i\2\2\u00b5\u00b6\7j\2\2\u00b6\u00b7\7v\2\2\u00b7")
buf.write(u"\u00b8\7c\2\2\u00b8\u00b9\7t\2\2\u00b9\u00ba\7t\2\2\u00ba")
buf.write(u"\u00bb\7q\2\2\u00bb\u00db\7y\2\2\u00bc\u00bd\7^\2\2\u00bd")
buf.write(u"\u00be\7n\2\2\u00be\u00bf\7q\2\2\u00bf\u00c0\7p\2\2\u00c0")
buf.write(u"\u00c1\7i\2\2\u00c1\u00c2\7t\2\2\u00c2\u00c3\7k\2\2\u00c3")
buf.write(u"\u00c4\7i\2\2\u00c4\u00c5\7j\2\2\u00c5\u00c6\7v\2\2\u00c6")
buf.write(u"\u00c7\7c\2\2\u00c7\u00c8\7t\2\2\u00c8\u00c9\7t\2\2\u00c9")
buf.write(u"\u00ca\7q\2\2\u00ca\u00db\7y\2\2\u00cb\u00cc\7^\2\2\u00cc")
buf.write(u"\u00cd\7N\2\2\u00cd\u00ce\7q\2\2\u00ce\u00cf\7p\2\2\u00cf")
buf.write(u"\u00d0\7i\2\2\u00d0\u00d1\7t\2\2\u00d1\u00d2\7k\2\2\u00d2")
buf.write(u"\u00d3\7i\2\2\u00d3\u00d4\7j\2\2\u00d4\u00d5\7v\2\2\u00d5")
buf.write(u"\u00d6\7c\2\2\u00d6\u00d7\7t\2\2\u00d7\u00d8\7t\2\2\u00d8")
buf.write(u"\u00d9\7q\2\2\u00d9\u00db\7y\2\2\u00da\u00a3\3\2\2\2")
buf.write(u"\u00da\u00a6\3\2\2\2\u00da\u00b1\3\2\2\2\u00da\u00bc")
buf.write(u"\3\2\2\2\u00da\u00cb\3\2\2\2\u00db \3\2\2\2\u00dc\u00dd")
buf.write(u"\7^\2\2\u00dd\u00de\7k\2\2\u00de\u00df\7p\2\2\u00df\u00e0")
buf.write(u"\7v\2\2\u00e0\"\3\2\2\2\u00e1\u00e2\7^\2\2\u00e2\u00e3")
buf.write(u"\7u\2\2\u00e3\u00e4\7w\2\2\u00e4\u00e5\7o\2\2\u00e5$")
buf.write(u"\3\2\2\2\u00e6\u00e7\7^\2\2\u00e7\u00e8\7r\2\2\u00e8")
buf.write(u"\u00e9\7t\2\2\u00e9\u00ea\7q\2\2\u00ea\u00eb\7f\2\2\u00eb")
buf.write(u"&\3\2\2\2\u00ec\u00ed\7^\2\2\u00ed\u00ee\7n\2\2\u00ee")
buf.write(u"\u00ef\7q\2\2\u00ef\u00f0\7i\2\2\u00f0(\3\2\2\2\u00f1")
buf.write(u"\u00f2\7^\2\2\u00f2\u00f3\7n\2\2\u00f3\u00f4\7p\2\2\u00f4")
buf.write(u"*\3\2\2\2\u00f5\u00f6\7^\2\2\u00f6\u00f7\7u\2\2\u00f7")
buf.write(u"\u00f8\7k\2\2\u00f8\u00f9\7p\2\2\u00f9,\3\2\2\2\u00fa")
buf.write(u"\u00fb\7^\2\2\u00fb\u00fc\7e\2\2\u00fc\u00fd\7q\2\2\u00fd")
buf.write(u"\u00fe\7u\2\2\u00fe.\3\2\2\2\u00ff\u0100\7^\2\2\u0100")
buf.write(u"\u0101\7v\2\2\u0101\u0102\7c\2\2\u0102\u0103\7p\2\2\u0103")
buf.write(u"\60\3\2\2\2\u0104\u0105\7^\2\2\u0105\u0106\7e\2\2\u0106")
buf.write(u"\u0107\7u\2\2\u0107\u0108\7e\2\2\u0108\62\3\2\2\2\u0109")
buf.write(u"\u010a\7^\2\2\u010a\u010b\7u\2\2\u010b\u010c\7g\2\2\u010c")
buf.write(u"\u010d\7e\2\2\u010d\64\3\2\2\2\u010e\u010f\7^\2\2\u010f")
buf.write(u"\u0110\7e\2\2\u0110\u0111\7q\2\2\u0111\u0112\7v\2\2\u0112")
buf.write(u"\66\3\2\2\2\u0113\u0114\7^\2\2\u0114\u0115\7c\2\2\u0115")
buf.write(u"\u0116\7t\2\2\u0116\u0117\7e\2\2\u0117\u0118\7u\2\2\u0118")
buf.write(u"\u0119\7k\2\2\u0119\u011a\7p\2\2\u011a8\3\2\2\2\u011b")
buf.write(u"\u011c\7^\2\2\u011c\u011d\7c\2\2\u011d\u011e\7t\2\2\u011e")
buf.write(u"\u011f\7e\2\2\u011f\u0120\7e\2\2\u0120\u0121\7q\2\2\u0121")
buf.write(u"\u0122\7u\2\2\u0122:\3\2\2\2\u0123\u0124\7^\2\2\u0124")
buf.write(u"\u0125\7c\2\2\u0125\u0126\7t\2\2\u0126\u0127\7e\2\2\u0127")
buf.write(u"\u0128\7v\2\2\u0128\u0129\7c\2\2\u0129\u012a\7p\2\2\u012a")
buf.write(u"<\3\2\2\2\u012b\u012c\7^\2\2\u012c\u012d\7c\2\2\u012d")
buf.write(u"\u012e\7t\2\2\u012e\u012f\7e\2\2\u012f\u0130\7e\2\2\u0130")
buf.write(u"\u0131\7u\2\2\u0131\u0132\7e\2\2\u0132>\3\2\2\2\u0133")
buf.write(u"\u0134\7^\2\2\u0134\u0135\7c\2\2\u0135\u0136\7t\2\2\u0136")
buf.write(u"\u0137\7e\2\2\u0137\u0138\7u\2\2\u0138\u0139\7g\2\2\u0139")
buf.write(u"\u013a\7e\2\2\u013a@\3\2\2\2\u013b\u013c\7^\2\2\u013c")
buf.write(u"\u013d\7c\2\2\u013d\u013e\7t\2\2\u013e\u013f\7e\2\2\u013f")
buf.write(u"\u0140\7e\2\2\u0140\u0141\7q\2\2\u0141\u0142\7v\2\2\u0142")
buf.write(u"B\3\2\2\2\u0143\u0144\7^\2\2\u0144\u0145\7u\2\2\u0145")
buf.write(u"\u0146\7k\2\2\u0146\u0147\7p\2\2\u0147\u0148\7j\2\2\u0148")
buf.write(u"D\3\2\2\2\u0149\u014a\7^\2\2\u014a\u014b\7e\2\2\u014b")
buf.write(u"\u014c\7q\2\2\u014c\u014d\7u\2\2\u014d\u014e\7j\2\2\u014e")
buf.write(u"F\3\2\2\2\u014f\u0150\7^\2\2\u0150\u0151\7v\2\2\u0151")
buf.write(u"\u0152\7c\2\2\u0152\u0153\7p\2\2\u0153\u0154\7j\2\2\u0154")
buf.write(u"H\3\2\2\2\u0155\u0156\7^\2\2\u0156\u0157\7c\2\2\u0157")
buf.write(u"\u0158\7t\2\2\u0158\u0159\7u\2\2\u0159\u015a\7k\2\2\u015a")
buf.write(u"\u015b\7p\2\2\u015b\u015c\7j\2\2\u015cJ\3\2\2\2\u015d")
buf.write(u"\u015e\7^\2\2\u015e\u015f\7c\2\2\u015f\u0160\7t\2\2\u0160")
buf.write(u"\u0161\7e\2\2\u0161\u0162\7q\2\2\u0162\u0163\7u\2\2\u0163")
buf.write(u"\u0164\7j\2\2\u0164L\3\2\2\2\u0165\u0166\7^\2\2\u0166")
buf.write(u"\u0167\7c\2\2\u0167\u0168\7t\2\2\u0168\u0169\7v\2\2\u0169")
buf.write(u"\u016a\7c\2\2\u016a\u016b\7p\2\2\u016b\u016c\7j\2\2\u016c")
buf.write(u"N\3\2\2\2\u016d\u016e\7^\2\2\u016e\u016f\7u\2\2\u016f")
buf.write(u"\u0170\7s\2\2\u0170\u0171\7t\2\2\u0171\u0172\7v\2\2\u0172")
buf.write(u"P\3\2\2\2\u0173\u0174\7^\2\2\u0174\u0175\7v\2\2\u0175")
buf.write(u"\u0176\7k\2\2\u0176\u0177\7o\2\2\u0177\u0178\7g\2\2\u0178")
buf.write(u"\u0179\7u\2\2\u0179R\3\2\2\2\u017a\u017b\7^\2\2\u017b")
buf.write(u"\u017c\7e\2\2\u017c\u017d\7f\2\2\u017d\u017e\7q\2\2\u017e")
buf.write(u"\u017f\7v\2\2\u017fT\3\2\2\2\u0180\u0181\7^\2\2\u0181")
buf.write(u"\u0182\7f\2\2\u0182\u0183\7k\2\2\u0183\u0184\7x\2\2\u0184")
buf.write(u"V\3\2\2\2\u0185\u0186\7^\2\2\u0186\u0187\7h\2\2\u0187")
buf.write(u"\u0188\7t\2\2\u0188\u0189\7c\2\2\u0189\u018a\7e\2\2\u018a")
buf.write(u"X\3\2\2\2\u018b\u018c\7^\2\2\u018c\u018d\7d\2\2\u018d")
buf.write(u"\u018e\7k\2\2\u018e\u018f\7p\2\2\u018f\u0190\7q\2\2\u0190")
buf.write(u"\u0191\7o\2\2\u0191Z\3\2\2\2\u0192\u0193\7^\2\2\u0193")
buf.write(u"\u0194\7f\2\2\u0194\u0195\7d\2\2\u0195\u0196\7k\2\2\u0196")
buf.write(u"\u0197\7p\2\2\u0197\u0198\7q\2\2\u0198\u0199\7o\2\2\u0199")
buf.write(u"\\\3\2\2\2\u019a\u019b\7^\2\2\u019b\u019c\7v\2\2\u019c")
buf.write(u"\u019d\7d\2\2\u019d\u019e\7k\2\2\u019e\u019f\7p\2\2\u019f")
buf.write(u"\u01a0\7q\2\2\u01a0\u01a1\7o\2\2\u01a1^\3\2\2\2\u01a2")
buf.write(u"\u01a3\7^\2\2\u01a3\u01a4\7o\2\2\u01a4\u01a5\7c\2\2\u01a5")
buf.write(u"\u01a6\7v\2\2\u01a6\u01a7\7j\2\2\u01a7\u01a8\7k\2\2\u01a8")
buf.write(u"\u01a9\7v\2\2\u01a9`\3\2\2\2\u01aa\u01ab\7a\2\2\u01ab")
buf.write(u"b\3\2\2\2\u01ac\u01ad\7`\2\2\u01add\3\2\2\2\u01ae\u01af")
buf.write(u"\7<\2\2\u01aff\3\2\2\2\u01b0\u01b1\t\2\2\2\u01b1h\3\2")
buf.write(u"\2\2\u01b2\u01b6\7f\2\2\u01b3\u01b5\5g\64\2\u01b4\u01b3")
buf.write(u"\3\2\2\2\u01b5\u01b8\3\2\2\2\u01b6\u01b7\3\2\2\2\u01b6")
buf.write(u"\u01b4\3\2\2\2\u01b7\u01c0\3\2\2\2\u01b8\u01b6\3\2\2")
buf.write(u"\2\u01b9\u01c1\t\3\2\2\u01ba\u01bc\7^\2\2\u01bb\u01bd")
buf.write(u"\t\3\2\2\u01bc\u01bb\3\2\2\2\u01bd\u01be\3\2\2\2\u01be")
buf.write(u"\u01bc\3\2\2\2\u01be\u01bf\3\2\2\2\u01bf\u01c1\3\2\2")
buf.write(u"\2\u01c0\u01b9\3\2\2\2\u01c0\u01ba\3\2\2\2\u01c1j\3\2")
buf.write(u"\2\2\u01c2\u01c3\t\3\2\2\u01c3l\3\2\2\2\u01c4\u01c5\t")
buf.write(u"\4\2\2\u01c5n\3\2\2\2\u01c6\u01c8\5m\67\2\u01c7\u01c6")
buf.write(u"\3\2\2\2\u01c8\u01c9\3\2\2\2\u01c9\u01c7\3\2\2\2\u01c9")
buf.write(u"\u01ca\3\2\2\2\u01ca\u01d2\3\2\2\2\u01cb\u01cc\7.\2\2")
buf.write(u"\u01cc\u01cd\5m\67\2\u01cd\u01ce\5m\67\2\u01ce\u01cf")
buf.write(u"\5m\67\2\u01cf\u01d1\3\2\2\2\u01d0\u01cb\3\2\2\2\u01d1")
buf.write(u"\u01d4\3\2\2\2\u01d2\u01d0\3\2\2\2\u01d2\u01d3\3\2\2")
buf.write(u"\2\u01d3\u01ec\3\2\2\2\u01d4\u01d2\3\2\2\2\u01d5\u01d7")
buf.write(u"\5m\67\2\u01d6\u01d5\3\2\2\2\u01d7\u01da\3\2\2\2\u01d8")
buf.write(u"\u01d6\3\2\2\2\u01d8\u01d9\3\2\2\2\u01d9\u01e2\3\2\2")
buf.write(u"\2\u01da\u01d8\3\2\2\2\u01db\u01dc\7.\2\2\u01dc\u01dd")
buf.write(u"\5m\67\2\u01dd\u01de\5m\67\2\u01de\u01df\5m\67\2\u01df")
buf.write(u"\u01e1\3\2\2\2\u01e0\u01db\3\2\2\2\u01e1\u01e4\3\2\2")
buf.write(u"\2\u01e2\u01e0\3\2\2\2\u01e2\u01e3\3\2\2\2\u01e3\u01e5")
buf.write(u"\3\2\2\2\u01e4\u01e2\3\2\2\2\u01e5\u01e7\7\60\2\2\u01e6")
buf.write(u"\u01e8\5m\67\2\u01e7\u01e6\3\2\2\2\u01e8\u01e9\3\2\2")
buf.write(u"\2\u01e9\u01e7\3\2\2\2\u01e9\u01ea\3\2\2\2\u01ea\u01ec")
buf.write(u"\3\2\2\2\u01eb\u01c7\3\2\2\2\u01eb\u01d8\3\2\2\2\u01ec")
buf.write(u"p\3\2\2\2\u01ed\u01ee\7?\2\2\u01eer\3\2\2\2\u01ef\u01f0")
buf.write(u"\7>\2\2\u01f0t\3\2\2\2\u01f1\u01f2\7^\2\2\u01f2\u01f3")
buf.write(u"\7n\2\2\u01f3\u01f4\7g\2\2\u01f4\u01f5\7s\2\2\u01f5v")
buf.write(u"\3\2\2\2\u01f6\u01f7\7@\2\2\u01f7x\3\2\2\2\u01f8\u01f9")
buf.write(u"\7^\2\2\u01f9\u01fa\7i\2\2\u01fa\u01fb\7g\2\2\u01fb\u01fc")
buf.write(u"\7s\2\2\u01fcz\3\2\2\2\u01fd\u01fe\7#\2\2\u01fe|\3\2")
buf.write(u"\2\2\u01ff\u0201\7^\2\2\u0200\u0202\t\3\2\2\u0201\u0200")
buf.write(u"\3\2\2\2\u0202\u0203\3\2\2\2\u0203\u0201\3\2\2\2\u0203")
buf.write(u"\u0204\3\2\2\2\u0204~\3\2\2\2\17\2\u0084\u00da\u01b6")
buf.write(u"\u01be\u01c0\u01c9\u01d2\u01d8\u01e2\u01e9\u01eb\u0203")
buf.write(u"\3\b\2\2")
return buf.getvalue()
class LaTeXLexer(Lexer):
atn = ATNDeserializer().deserialize(serializedATN())
decisionsToDFA = [ DFA(ds, i) for i, ds in enumerate(atn.decisionToState) ]
T__0 = 1
WS = 2
ADD = 3
SUB = 4
MUL = 5
DIV = 6
L_PAREN = 7
R_PAREN = 8
L_BRACE = 9
R_BRACE = 10
L_BRACKET = 11
R_BRACKET = 12
BAR = 13
FUNC_LIM = 14
LIM_APPROACH_SYM = 15
FUNC_INT = 16
FUNC_SUM = 17
FUNC_PROD = 18
FUNC_LOG = 19
FUNC_LN = 20
FUNC_SIN = 21
FUNC_COS = 22
FUNC_TAN = 23
FUNC_CSC = 24
FUNC_SEC = 25
FUNC_COT = 26
FUNC_ARCSIN = 27
FUNC_ARCCOS = 28
FUNC_ARCTAN = 29
FUNC_ARCCSC = 30
FUNC_ARCSEC = 31
FUNC_ARCCOT = 32
FUNC_SINH = 33
FUNC_COSH = 34
FUNC_TANH = 35
FUNC_ARSINH = 36
FUNC_ARCOSH = 37
FUNC_ARTANH = 38
FUNC_SQRT = 39
CMD_TIMES = 40
CMD_CDOT = 41
CMD_DIV = 42
CMD_FRAC = 43
CMD_BINOM = 44
CMD_DBINOM = 45
CMD_TBINOM = 46
CMD_MATHIT = 47
UNDERSCORE = 48
CARET = 49
COLON = 50
DIFFERENTIAL = 51
LETTER = 52
NUMBER = 53
EQUAL = 54
LT = 55
LTE = 56
GT = 57
GTE = 58
BANG = 59
SYMBOL = 60
channelNames = [ u"DEFAULT_TOKEN_CHANNEL", u"HIDDEN" ]
modeNames = [ u"DEFAULT_MODE" ]
literalNames = [ u"<INVALID>",
u"','", u"'+'", u"'-'", u"'*'", u"'/'", u"'('", u"')'", u"'{'",
u"'}'", u"'['", u"']'", u"'|'", u"'\\lim'", u"'\\int'", u"'\\sum'",
u"'\\prod'", u"'\\log'", u"'\\ln'", u"'\\sin'", u"'\\cos'",
u"'\\tan'", u"'\\csc'", u"'\\sec'", u"'\\cot'", u"'\\arcsin'",
u"'\\arccos'", u"'\\arctan'", u"'\\arccsc'", u"'\\arcsec'",
u"'\\arccot'", u"'\\sinh'", u"'\\cosh'", u"'\\tanh'", u"'\\arsinh'",
u"'\\arcosh'", u"'\\artanh'", u"'\\sqrt'", u"'\\times'", u"'\\cdot'",
u"'\\div'", u"'\\frac'", u"'\\binom'", u"'\\dbinom'", u"'\\tbinom'",
u"'\\mathit'", u"'_'", u"'^'", u"':'", u"'='", u"'<'", u"'\\leq'",
u"'>'", u"'\\geq'", u"'!'" ]
symbolicNames = [ u"<INVALID>",
u"WS", u"ADD", u"SUB", u"MUL", u"DIV", u"L_PAREN", u"R_PAREN",
u"L_BRACE", u"R_BRACE", u"L_BRACKET", u"R_BRACKET", u"BAR",
u"FUNC_LIM", u"LIM_APPROACH_SYM", u"FUNC_INT", u"FUNC_SUM",
u"FUNC_PROD", u"FUNC_LOG", u"FUNC_LN", u"FUNC_SIN", u"FUNC_COS",
u"FUNC_TAN", u"FUNC_CSC", u"FUNC_SEC", u"FUNC_COT", u"FUNC_ARCSIN",
u"FUNC_ARCCOS", u"FUNC_ARCTAN", u"FUNC_ARCCSC", u"FUNC_ARCSEC",
u"FUNC_ARCCOT", u"FUNC_SINH", u"FUNC_COSH", u"FUNC_TANH", u"FUNC_ARSINH",
u"FUNC_ARCOSH", u"FUNC_ARTANH", u"FUNC_SQRT", u"CMD_TIMES",
u"CMD_CDOT", u"CMD_DIV", u"CMD_FRAC", u"CMD_BINOM", u"CMD_DBINOM",
u"CMD_TBINOM", u"CMD_MATHIT", u"UNDERSCORE", u"CARET", u"COLON",
u"DIFFERENTIAL", u"LETTER", u"NUMBER", u"EQUAL", u"LT", u"LTE",
u"GT", u"GTE", u"BANG", u"SYMBOL" ]
ruleNames = [ u"T__0", u"WS", u"ADD", u"SUB", u"MUL", u"DIV", u"L_PAREN",
u"R_PAREN", u"L_BRACE", u"R_BRACE", u"L_BRACKET", u"R_BRACKET",
u"BAR", u"FUNC_LIM", u"LIM_APPROACH_SYM", u"FUNC_INT",
u"FUNC_SUM", u"FUNC_PROD", u"FUNC_LOG", u"FUNC_LN", u"FUNC_SIN",
u"FUNC_COS", u"FUNC_TAN", u"FUNC_CSC", u"FUNC_SEC", u"FUNC_COT",
u"FUNC_ARCSIN", u"FUNC_ARCCOS", u"FUNC_ARCTAN", u"FUNC_ARCCSC",
u"FUNC_ARCSEC", u"FUNC_ARCCOT", u"FUNC_SINH", u"FUNC_COSH",
u"FUNC_TANH", u"FUNC_ARSINH", u"FUNC_ARCOSH", u"FUNC_ARTANH",
u"FUNC_SQRT", u"CMD_TIMES", u"CMD_CDOT", u"CMD_DIV", u"CMD_FRAC",
u"CMD_BINOM", u"CMD_DBINOM", u"CMD_TBINOM", u"CMD_MATHIT",
u"UNDERSCORE", u"CARET", u"COLON", u"WS_CHAR", u"DIFFERENTIAL",
u"LETTER", u"DIGIT", u"NUMBER", u"EQUAL", u"LT", u"LTE",
u"GT", u"GTE", u"BANG", u"SYMBOL" ]
grammarFileName = u"LaTeX.g4"
def __init__(self, input=None, output=sys.stdout):
super(LaTeXLexer, self).__init__(input, output=output)
self.checkVersion("4.7.1")
self._interp = LexerATNSimulator(self, self.atn, self.decisionsToDFA, PredictionContextCache())
self._actions = None
self._predicates = None
|
b68c6739a7901ac64662d9c1d3e7eb8b8e1439a9ec1823b7ce982cfec6fa9150 |
# encoding: utf-8
# *** GENERATED BY `setup.py antlr`, DO NOT EDIT BY HAND ***
#
# Generated from ../LaTeX.g4, derived from latex2sympy
# latex2sympy is licensed under the MIT license
# https://github.com/augustt198/latex2sympy/blob/master/LICENSE.txt
#
# Generated with antlr4
# antlr4 is licensed under the BSD-3-Clause License
# https://github.com/antlr/antlr4/blob/master/LICENSE.txt
from __future__ import print_function
from antlr4 import *
from io import StringIO
import sys
def serializedATN():
with StringIO() as buf:
buf.write(u"\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3")
buf.write(u">\u01ae\4\2\t\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t")
buf.write(u"\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13\t\13\4\f\t\f\4\r\t\r")
buf.write(u"\4\16\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22\t\22\4")
buf.write(u"\23\t\23\4\24\t\24\4\25\t\25\4\26\t\26\4\27\t\27\4\30")
buf.write(u"\t\30\4\31\t\31\4\32\t\32\4\33\t\33\4\34\t\34\4\35\t")
buf.write(u"\35\4\36\t\36\4\37\t\37\4 \t \4!\t!\4\"\t\"\4#\t#\4$")
buf.write(u"\t$\4%\t%\3\2\3\2\3\3\3\3\3\3\3\3\3\3\3\3\7\3S\n\3\f")
buf.write(u"\3\16\3V\13\3\3\4\3\4\3\4\3\4\3\5\3\5\3\6\3\6\3\6\3\6")
buf.write(u"\3\6\3\6\7\6d\n\6\f\6\16\6g\13\6\3\7\3\7\3\7\3\7\3\7")
buf.write(u"\3\7\7\7o\n\7\f\7\16\7r\13\7\3\b\3\b\3\b\3\b\3\b\3\b")
buf.write(u"\7\bz\n\b\f\b\16\b}\13\b\3\t\3\t\3\t\6\t\u0082\n\t\r")
buf.write(u"\t\16\t\u0083\5\t\u0086\n\t\3\n\3\n\3\n\3\n\7\n\u008c")
buf.write(u"\n\n\f\n\16\n\u008f\13\n\5\n\u0091\n\n\3\13\3\13\7\13")
buf.write(u"\u0095\n\13\f\13\16\13\u0098\13\13\3\f\3\f\7\f\u009c")
buf.write(u"\n\f\f\f\16\f\u009f\13\f\3\r\3\r\5\r\u00a3\n\r\3\16\3")
buf.write(u"\16\3\16\3\16\3\16\3\16\5\16\u00ab\n\16\3\17\3\17\3\17")
buf.write(u"\3\17\5\17\u00b1\n\17\3\17\3\17\3\20\3\20\3\20\3\20\5")
buf.write(u"\20\u00b9\n\20\3\20\3\20\3\21\3\21\3\21\3\21\3\21\3\21")
buf.write(u"\3\21\3\21\3\21\3\21\5\21\u00c7\n\21\3\21\5\21\u00ca")
buf.write(u"\n\21\7\21\u00cc\n\21\f\21\16\21\u00cf\13\21\3\22\3\22")
buf.write(u"\3\22\3\22\3\22\3\22\3\22\3\22\3\22\3\22\5\22\u00db\n")
buf.write(u"\22\3\22\5\22\u00de\n\22\7\22\u00e0\n\22\f\22\16\22\u00e3")
buf.write(u"\13\22\3\23\3\23\3\23\3\23\3\23\3\23\5\23\u00eb\n\23")
buf.write(u"\3\24\3\24\3\24\3\24\3\24\5\24\u00f2\n\24\3\25\3\25\3")
buf.write(u"\25\3\25\3\25\3\25\3\25\3\25\3\25\3\25\3\25\3\25\5\25")
buf.write(u"\u0100\n\25\3\26\3\26\3\26\3\26\3\27\3\27\5\27\u0108")
buf.write(u"\n\27\3\27\3\27\3\27\5\27\u010d\n\27\3\30\3\30\3\30\3")
buf.write(u"\30\3\30\3\31\7\31\u0115\n\31\f\31\16\31\u0118\13\31")
buf.write(u"\3\32\3\32\3\32\3\32\3\32\3\32\3\32\3\32\3\33\3\33\3")
buf.write(u"\33\3\33\3\33\3\33\3\33\3\33\3\34\3\34\3\35\3\35\5\35")
buf.write(u"\u012e\n\35\3\35\5\35\u0131\n\35\3\35\5\35\u0134\n\35")
buf.write(u"\3\35\5\35\u0137\n\35\5\35\u0139\n\35\3\35\3\35\3\35")
buf.write(u"\3\35\3\35\5\35\u0140\n\35\3\35\3\35\5\35\u0144\n\35")
buf.write(u"\3\35\3\35\3\35\3\35\3\35\3\35\3\35\3\35\3\35\3\35\3")
buf.write(u"\35\5\35\u0151\n\35\3\35\5\35\u0154\n\35\3\35\3\35\3")
buf.write(u"\35\5\35\u0159\n\35\3\35\3\35\3\35\3\35\3\35\5\35\u0160")
buf.write(u"\n\35\3\35\3\35\3\35\3\35\3\35\3\35\3\35\3\35\3\35\3")
buf.write(u"\35\3\35\5\35\u016d\n\35\3\35\3\35\3\35\3\35\3\35\3\35")
buf.write(u"\5\35\u0175\n\35\3\36\3\36\3\36\3\36\3\36\5\36\u017c")
buf.write(u"\n\36\3\37\3\37\3\37\3\37\3\37\3\37\3\37\3\37\3\37\5")
buf.write(u"\37\u0187\n\37\3\37\3\37\3 \3 \3 \3 \3 \5 \u0190\n \3")
buf.write(u"!\3!\3\"\3\"\3\"\3\"\3\"\3\"\5\"\u019a\n\"\3#\3#\3#\3")
buf.write(u"#\3#\3#\5#\u01a2\n#\3$\3$\3$\3$\3$\3%\3%\3%\3%\3%\3%")
buf.write(u"\2\b\4\n\f\16 \"&\2\4\6\b\n\f\16\20\22\24\26\30\32\34")
buf.write(u"\36 \"$&(*,.\60\62\64\668:<>@BDFH\2\t\3\28<\3\2\5\6\5")
buf.write(u"\2\7\b*,\64\64\4\2\66\66>>\3\2.\60\3\2\25(\3\2\23\24")
buf.write(u"\2\u01c6\2J\3\2\2\2\4L\3\2\2\2\6W\3\2\2\2\b[\3\2\2\2")
buf.write(u"\n]\3\2\2\2\fh\3\2\2\2\16s\3\2\2\2\20\u0085\3\2\2\2\22")
buf.write(u"\u0090\3\2\2\2\24\u0092\3\2\2\2\26\u0099\3\2\2\2\30\u00a2")
buf.write(u"\3\2\2\2\32\u00a4\3\2\2\2\34\u00ac\3\2\2\2\36\u00b4\3")
buf.write(u"\2\2\2 \u00bc\3\2\2\2\"\u00d0\3\2\2\2$\u00ea\3\2\2\2")
buf.write(u"&\u00f1\3\2\2\2(\u00ff\3\2\2\2*\u0101\3\2\2\2,\u010c")
buf.write(u"\3\2\2\2.\u010e\3\2\2\2\60\u0116\3\2\2\2\62\u0119\3\2")
buf.write(u"\2\2\64\u0121\3\2\2\2\66\u0129\3\2\2\28\u0174\3\2\2\2")
buf.write(u":\u017b\3\2\2\2<\u017d\3\2\2\2>\u018f\3\2\2\2@\u0191")
buf.write(u"\3\2\2\2B\u0193\3\2\2\2D\u019b\3\2\2\2F\u01a3\3\2\2\2")
buf.write(u"H\u01a8\3\2\2\2JK\5\4\3\2K\3\3\2\2\2LM\b\3\1\2MN\5\b")
buf.write(u"\5\2NT\3\2\2\2OP\f\4\2\2PQ\t\2\2\2QS\5\4\3\5RO\3\2\2")
buf.write(u"\2SV\3\2\2\2TR\3\2\2\2TU\3\2\2\2U\5\3\2\2\2VT\3\2\2\2")
buf.write(u"WX\5\b\5\2XY\78\2\2YZ\5\b\5\2Z\7\3\2\2\2[\\\5\n\6\2\\")
buf.write(u"\t\3\2\2\2]^\b\6\1\2^_\5\f\7\2_e\3\2\2\2`a\f\4\2\2ab")
buf.write(u"\t\3\2\2bd\5\n\6\5c`\3\2\2\2dg\3\2\2\2ec\3\2\2\2ef\3")
buf.write(u"\2\2\2f\13\3\2\2\2ge\3\2\2\2hi\b\7\1\2ij\5\20\t\2jp\3")
buf.write(u"\2\2\2kl\f\4\2\2lm\t\4\2\2mo\5\f\7\5nk\3\2\2\2or\3\2")
buf.write(u"\2\2pn\3\2\2\2pq\3\2\2\2q\r\3\2\2\2rp\3\2\2\2st\b\b\1")
buf.write(u"\2tu\5\22\n\2u{\3\2\2\2vw\f\4\2\2wx\t\4\2\2xz\5\16\b")
buf.write(u"\5yv\3\2\2\2z}\3\2\2\2{y\3\2\2\2{|\3\2\2\2|\17\3\2\2")
buf.write(u"\2}{\3\2\2\2~\177\t\3\2\2\177\u0086\5\20\t\2\u0080\u0082")
buf.write(u"\5\24\13\2\u0081\u0080\3\2\2\2\u0082\u0083\3\2\2\2\u0083")
buf.write(u"\u0081\3\2\2\2\u0083\u0084\3\2\2\2\u0084\u0086\3\2\2")
buf.write(u"\2\u0085~\3\2\2\2\u0085\u0081\3\2\2\2\u0086\21\3\2\2")
buf.write(u"\2\u0087\u0088\t\3\2\2\u0088\u0091\5\22\n\2\u0089\u008d")
buf.write(u"\5\24\13\2\u008a\u008c\5\26\f\2\u008b\u008a\3\2\2\2\u008c")
buf.write(u"\u008f\3\2\2\2\u008d\u008b\3\2\2\2\u008d\u008e\3\2\2")
buf.write(u"\2\u008e\u0091\3\2\2\2\u008f\u008d\3\2\2\2\u0090\u0087")
buf.write(u"\3\2\2\2\u0090\u0089\3\2\2\2\u0091\23\3\2\2\2\u0092\u0096")
buf.write(u"\5 \21\2\u0093\u0095\5\30\r\2\u0094\u0093\3\2\2\2\u0095")
buf.write(u"\u0098\3\2\2\2\u0096\u0094\3\2\2\2\u0096\u0097\3\2\2")
buf.write(u"\2\u0097\25\3\2\2\2\u0098\u0096\3\2\2\2\u0099\u009d\5")
buf.write(u"\"\22\2\u009a\u009c\5\30\r\2\u009b\u009a\3\2\2\2\u009c")
buf.write(u"\u009f\3\2\2\2\u009d\u009b\3\2\2\2\u009d\u009e\3\2\2")
buf.write(u"\2\u009e\27\3\2\2\2\u009f\u009d\3\2\2\2\u00a0\u00a3\7")
buf.write(u"=\2\2\u00a1\u00a3\5\32\16\2\u00a2\u00a0\3\2\2\2\u00a2")
buf.write(u"\u00a1\3\2\2\2\u00a3\31\3\2\2\2\u00a4\u00aa\7\17\2\2")
buf.write(u"\u00a5\u00ab\5\36\20\2\u00a6\u00ab\5\34\17\2\u00a7\u00a8")
buf.write(u"\5\36\20\2\u00a8\u00a9\5\34\17\2\u00a9\u00ab\3\2\2\2")
buf.write(u"\u00aa\u00a5\3\2\2\2\u00aa\u00a6\3\2\2\2\u00aa\u00a7")
buf.write(u"\3\2\2\2\u00ab\33\3\2\2\2\u00ac\u00ad\7\62\2\2\u00ad")
buf.write(u"\u00b0\7\13\2\2\u00ae\u00b1\5\b\5\2\u00af\u00b1\5\6\4")
buf.write(u"\2\u00b0\u00ae\3\2\2\2\u00b0\u00af\3\2\2\2\u00b1\u00b2")
buf.write(u"\3\2\2\2\u00b2\u00b3\7\f\2\2\u00b3\35\3\2\2\2\u00b4\u00b5")
buf.write(u"\7\63\2\2\u00b5\u00b8\7\13\2\2\u00b6\u00b9\5\b\5\2\u00b7")
buf.write(u"\u00b9\5\6\4\2\u00b8\u00b6\3\2\2\2\u00b8\u00b7\3\2\2")
buf.write(u"\2\u00b9\u00ba\3\2\2\2\u00ba\u00bb\7\f\2\2\u00bb\37\3")
buf.write(u"\2\2\2\u00bc\u00bd\b\21\1\2\u00bd\u00be\5$\23\2\u00be")
buf.write(u"\u00cd\3\2\2\2\u00bf\u00c0\f\4\2\2\u00c0\u00c6\7\63\2")
buf.write(u"\2\u00c1\u00c7\5,\27\2\u00c2\u00c3\7\13\2\2\u00c3\u00c4")
buf.write(u"\5\b\5\2\u00c4\u00c5\7\f\2\2\u00c5\u00c7\3\2\2\2\u00c6")
buf.write(u"\u00c1\3\2\2\2\u00c6\u00c2\3\2\2\2\u00c7\u00c9\3\2\2")
buf.write(u"\2\u00c8\u00ca\5B\"\2\u00c9\u00c8\3\2\2\2\u00c9\u00ca")
buf.write(u"\3\2\2\2\u00ca\u00cc\3\2\2\2\u00cb\u00bf\3\2\2\2\u00cc")
buf.write(u"\u00cf\3\2\2\2\u00cd\u00cb\3\2\2\2\u00cd\u00ce\3\2\2")
buf.write(u"\2\u00ce!\3\2\2\2\u00cf\u00cd\3\2\2\2\u00d0\u00d1\b\22")
buf.write(u"\1\2\u00d1\u00d2\5&\24\2\u00d2\u00e1\3\2\2\2\u00d3\u00d4")
buf.write(u"\f\4\2\2\u00d4\u00da\7\63\2\2\u00d5\u00db\5,\27\2\u00d6")
buf.write(u"\u00d7\7\13\2\2\u00d7\u00d8\5\b\5\2\u00d8\u00d9\7\f\2")
buf.write(u"\2\u00d9\u00db\3\2\2\2\u00da\u00d5\3\2\2\2\u00da\u00d6")
buf.write(u"\3\2\2\2\u00db\u00dd\3\2\2\2\u00dc\u00de\5B\"\2\u00dd")
buf.write(u"\u00dc\3\2\2\2\u00dd\u00de\3\2\2\2\u00de\u00e0\3\2\2")
buf.write(u"\2\u00df\u00d3\3\2\2\2\u00e0\u00e3\3\2\2\2\u00e1\u00df")
buf.write(u"\3\2\2\2\u00e1\u00e2\3\2\2\2\u00e2#\3\2\2\2\u00e3\u00e1")
buf.write(u"\3\2\2\2\u00e4\u00eb\5(\25\2\u00e5\u00eb\5*\26\2\u00e6")
buf.write(u"\u00eb\58\35\2\u00e7\u00eb\5,\27\2\u00e8\u00eb\5\62\32")
buf.write(u"\2\u00e9\u00eb\5\64\33\2\u00ea\u00e4\3\2\2\2\u00ea\u00e5")
buf.write(u"\3\2\2\2\u00ea\u00e6\3\2\2\2\u00ea\u00e7\3\2\2\2\u00ea")
buf.write(u"\u00e8\3\2\2\2\u00ea\u00e9\3\2\2\2\u00eb%\3\2\2\2\u00ec")
buf.write(u"\u00f2\5(\25\2\u00ed\u00f2\5*\26\2\u00ee\u00f2\5,\27")
buf.write(u"\2\u00ef\u00f2\5\62\32\2\u00f0\u00f2\5\64\33\2\u00f1")
buf.write(u"\u00ec\3\2\2\2\u00f1\u00ed\3\2\2\2\u00f1\u00ee\3\2\2")
buf.write(u"\2\u00f1\u00ef\3\2\2\2\u00f1\u00f0\3\2\2\2\u00f2\'\3")
buf.write(u"\2\2\2\u00f3\u00f4\7\t\2\2\u00f4\u00f5\5\b\5\2\u00f5")
buf.write(u"\u00f6\7\n\2\2\u00f6\u0100\3\2\2\2\u00f7\u00f8\7\r\2")
buf.write(u"\2\u00f8\u00f9\5\b\5\2\u00f9\u00fa\7\16\2\2\u00fa\u0100")
buf.write(u"\3\2\2\2\u00fb\u00fc\7\13\2\2\u00fc\u00fd\5\b\5\2\u00fd")
buf.write(u"\u00fe\7\f\2\2\u00fe\u0100\3\2\2\2\u00ff\u00f3\3\2\2")
buf.write(u"\2\u00ff\u00f7\3\2\2\2\u00ff\u00fb\3\2\2\2\u0100)\3\2")
buf.write(u"\2\2\u0101\u0102\7\17\2\2\u0102\u0103\5\b\5\2\u0103\u0104")
buf.write(u"\7\17\2\2\u0104+\3\2\2\2\u0105\u0107\t\5\2\2\u0106\u0108")
buf.write(u"\5B\"\2\u0107\u0106\3\2\2\2\u0107\u0108\3\2\2\2\u0108")
buf.write(u"\u010d\3\2\2\2\u0109\u010d\7\67\2\2\u010a\u010d\7\65")
buf.write(u"\2\2\u010b\u010d\5.\30\2\u010c\u0105\3\2\2\2\u010c\u0109")
buf.write(u"\3\2\2\2\u010c\u010a\3\2\2\2\u010c\u010b\3\2\2\2\u010d")
buf.write(u"-\3\2\2\2\u010e\u010f\7\61\2\2\u010f\u0110\7\13\2\2\u0110")
buf.write(u"\u0111\5\60\31\2\u0111\u0112\7\f\2\2\u0112/\3\2\2\2\u0113")
buf.write(u"\u0115\7\66\2\2\u0114\u0113\3\2\2\2\u0115\u0118\3\2\2")
buf.write(u"\2\u0116\u0114\3\2\2\2\u0116\u0117\3\2\2\2\u0117\61\3")
buf.write(u"\2\2\2\u0118\u0116\3\2\2\2\u0119\u011a\7-\2\2\u011a\u011b")
buf.write(u"\7\13\2\2\u011b\u011c\5\b\5\2\u011c\u011d\7\f\2\2\u011d")
buf.write(u"\u011e\7\13\2\2\u011e\u011f\5\b\5\2\u011f\u0120\7\f\2")
buf.write(u"\2\u0120\63\3\2\2\2\u0121\u0122\t\6\2\2\u0122\u0123\7")
buf.write(u"\13\2\2\u0123\u0124\5\b\5\2\u0124\u0125\7\f\2\2\u0125")
buf.write(u"\u0126\7\13\2\2\u0126\u0127\5\b\5\2\u0127\u0128\7\f\2")
buf.write(u"\2\u0128\65\3\2\2\2\u0129\u012a\t\7\2\2\u012a\67\3\2")
buf.write(u"\2\2\u012b\u0138\5\66\34\2\u012c\u012e\5B\"\2\u012d\u012c")
buf.write(u"\3\2\2\2\u012d\u012e\3\2\2\2\u012e\u0130\3\2\2\2\u012f")
buf.write(u"\u0131\5D#\2\u0130\u012f\3\2\2\2\u0130\u0131\3\2\2\2")
buf.write(u"\u0131\u0139\3\2\2\2\u0132\u0134\5D#\2\u0133\u0132\3")
buf.write(u"\2\2\2\u0133\u0134\3\2\2\2\u0134\u0136\3\2\2\2\u0135")
buf.write(u"\u0137\5B\"\2\u0136\u0135\3\2\2\2\u0136\u0137\3\2\2\2")
buf.write(u"\u0137\u0139\3\2\2\2\u0138\u012d\3\2\2\2\u0138\u0133")
buf.write(u"\3\2\2\2\u0139\u013f\3\2\2\2\u013a\u013b\7\t\2\2\u013b")
buf.write(u"\u013c\5> \2\u013c\u013d\7\n\2\2\u013d\u0140\3\2\2\2")
buf.write(u"\u013e\u0140\5@!\2\u013f\u013a\3\2\2\2\u013f\u013e\3")
buf.write(u"\2\2\2\u0140\u0175\3\2\2\2\u0141\u0143\t\5\2\2\u0142")
buf.write(u"\u0144\5B\"\2\u0143\u0142\3\2\2\2\u0143\u0144\3\2\2\2")
buf.write(u"\u0144\u0145\3\2\2\2\u0145\u0146\7\t\2\2\u0146\u0147")
buf.write(u"\5:\36\2\u0147\u0148\7\n\2\2\u0148\u0175\3\2\2\2\u0149")
buf.write(u"\u0150\7\22\2\2\u014a\u014b\5B\"\2\u014b\u014c\5D#\2")
buf.write(u"\u014c\u0151\3\2\2\2\u014d\u014e\5D#\2\u014e\u014f\5")
buf.write(u"B\"\2\u014f\u0151\3\2\2\2\u0150\u014a\3\2\2\2\u0150\u014d")
buf.write(u"\3\2\2\2\u0150\u0151\3\2\2\2\u0151\u0158\3\2\2\2\u0152")
buf.write(u"\u0154\5\n\6\2\u0153\u0152\3\2\2\2\u0153\u0154\3\2\2")
buf.write(u"\2\u0154\u0155\3\2\2\2\u0155\u0159\7\65\2\2\u0156\u0159")
buf.write(u"\5\62\32\2\u0157\u0159\5\n\6\2\u0158\u0153\3\2\2\2\u0158")
buf.write(u"\u0156\3\2\2\2\u0158\u0157\3\2\2\2\u0159\u0175\3\2\2")
buf.write(u"\2\u015a\u015f\7)\2\2\u015b\u015c\7\r\2\2\u015c\u015d")
buf.write(u"\5\b\5\2\u015d\u015e\7\16\2\2\u015e\u0160\3\2\2\2\u015f")
buf.write(u"\u015b\3\2\2\2\u015f\u0160\3\2\2\2\u0160\u0161\3\2\2")
buf.write(u"\2\u0161\u0162\7\13\2\2\u0162\u0163\5\b\5\2\u0163\u0164")
buf.write(u"\7\f\2\2\u0164\u0175\3\2\2\2\u0165\u016c\t\b\2\2\u0166")
buf.write(u"\u0167\5F$\2\u0167\u0168\5D#\2\u0168\u016d\3\2\2\2\u0169")
buf.write(u"\u016a\5D#\2\u016a\u016b\5F$\2\u016b\u016d\3\2\2\2\u016c")
buf.write(u"\u0166\3\2\2\2\u016c\u0169\3\2\2\2\u016d\u016e\3\2\2")
buf.write(u"\2\u016e\u016f\5\f\7\2\u016f\u0175\3\2\2\2\u0170\u0171")
buf.write(u"\7\20\2\2\u0171\u0172\5<\37\2\u0172\u0173\5\f\7\2\u0173")
buf.write(u"\u0175\3\2\2\2\u0174\u012b\3\2\2\2\u0174\u0141\3\2\2")
buf.write(u"\2\u0174\u0149\3\2\2\2\u0174\u015a\3\2\2\2\u0174\u0165")
buf.write(u"\3\2\2\2\u0174\u0170\3\2\2\2\u01759\3\2\2\2\u0176\u0177")
buf.write(u"\5\b\5\2\u0177\u0178\7\3\2\2\u0178\u0179\5:\36\2\u0179")
buf.write(u"\u017c\3\2\2\2\u017a\u017c\5\b\5\2\u017b\u0176\3\2\2")
buf.write(u"\2\u017b\u017a\3\2\2\2\u017c;\3\2\2\2\u017d\u017e\7\62")
buf.write(u"\2\2\u017e\u017f\7\13\2\2\u017f\u0180\t\5\2\2\u0180\u0181")
buf.write(u"\7\21\2\2\u0181\u0186\5\b\5\2\u0182\u0183\7\63\2\2\u0183")
buf.write(u"\u0184\7\13\2\2\u0184\u0185\t\3\2\2\u0185\u0187\7\f\2")
buf.write(u"\2\u0186\u0182\3\2\2\2\u0186\u0187\3\2\2\2\u0187\u0188")
buf.write(u"\3\2\2\2\u0188\u0189\7\f\2\2\u0189=\3\2\2\2\u018a\u0190")
buf.write(u"\5\b\5\2\u018b\u018c\5\b\5\2\u018c\u018d\7\3\2\2\u018d")
buf.write(u"\u018e\5> \2\u018e\u0190\3\2\2\2\u018f\u018a\3\2\2\2")
buf.write(u"\u018f\u018b\3\2\2\2\u0190?\3\2\2\2\u0191\u0192\5\16")
buf.write(u"\b\2\u0192A\3\2\2\2\u0193\u0199\7\62\2\2\u0194\u019a")
buf.write(u"\5,\27\2\u0195\u0196\7\13\2\2\u0196\u0197\5\b\5\2\u0197")
buf.write(u"\u0198\7\f\2\2\u0198\u019a\3\2\2\2\u0199\u0194\3\2\2")
buf.write(u"\2\u0199\u0195\3\2\2\2\u019aC\3\2\2\2\u019b\u01a1\7\63")
buf.write(u"\2\2\u019c\u01a2\5,\27\2\u019d\u019e\7\13\2\2\u019e\u019f")
buf.write(u"\5\b\5\2\u019f\u01a0\7\f\2\2\u01a0\u01a2\3\2\2\2\u01a1")
buf.write(u"\u019c\3\2\2\2\u01a1\u019d\3\2\2\2\u01a2E\3\2\2\2\u01a3")
buf.write(u"\u01a4\7\62\2\2\u01a4\u01a5\7\13\2\2\u01a5\u01a6\5\6")
buf.write(u"\4\2\u01a6\u01a7\7\f\2\2\u01a7G\3\2\2\2\u01a8\u01a9\7")
buf.write(u"\62\2\2\u01a9\u01aa\7\13\2\2\u01aa\u01ab\5\6\4\2\u01ab")
buf.write(u"\u01ac\7\f\2\2\u01acI\3\2\2\2.Tep{\u0083\u0085\u008d")
buf.write(u"\u0090\u0096\u009d\u00a2\u00aa\u00b0\u00b8\u00c6\u00c9")
buf.write(u"\u00cd\u00da\u00dd\u00e1\u00ea\u00f1\u00ff\u0107\u010c")
buf.write(u"\u0116\u012d\u0130\u0133\u0136\u0138\u013f\u0143\u0150")
buf.write(u"\u0153\u0158\u015f\u016c\u0174\u017b\u0186\u018f\u0199")
buf.write(u"\u01a1")
return buf.getvalue()
class LaTeXParser ( Parser ):
grammarFileName = "LaTeX.g4"
atn = ATNDeserializer().deserialize(serializedATN())
decisionsToDFA = [ DFA(ds, i) for i, ds in enumerate(atn.decisionToState) ]
sharedContextCache = PredictionContextCache()
literalNames = [ u"<INVALID>", u"','", u"<INVALID>", u"'+'", u"'-'",
u"'*'", u"'/'", u"'('", u"')'", u"'{'", u"'}'", u"'['",
u"']'", u"'|'", u"'\\lim'", u"<INVALID>", u"'\\int'",
u"'\\sum'", u"'\\prod'", u"'\\log'", u"'\\ln'", u"'\\sin'",
u"'\\cos'", u"'\\tan'", u"'\\csc'", u"'\\sec'", u"'\\cot'",
u"'\\arcsin'", u"'\\arccos'", u"'\\arctan'", u"'\\arccsc'",
u"'\\arcsec'", u"'\\arccot'", u"'\\sinh'", u"'\\cosh'",
u"'\\tanh'", u"'\\arsinh'", u"'\\arcosh'", u"'\\artanh'",
u"'\\sqrt'", u"'\\times'", u"'\\cdot'", u"'\\div'",
u"'\\frac'", u"'\\binom'", u"'\\dbinom'", u"'\\tbinom'",
u"'\\mathit'", u"'_'", u"'^'", u"':'", u"<INVALID>",
u"<INVALID>", u"<INVALID>", u"'='", u"'<'", u"'\\leq'",
u"'>'", u"'\\geq'", u"'!'" ]
symbolicNames = [ u"<INVALID>", u"<INVALID>", u"WS", u"ADD", u"SUB",
u"MUL", u"DIV", u"L_PAREN", u"R_PAREN", u"L_BRACE",
u"R_BRACE", u"L_BRACKET", u"R_BRACKET", u"BAR", u"FUNC_LIM",
u"LIM_APPROACH_SYM", u"FUNC_INT", u"FUNC_SUM", u"FUNC_PROD",
u"FUNC_LOG", u"FUNC_LN", u"FUNC_SIN", u"FUNC_COS",
u"FUNC_TAN", u"FUNC_CSC", u"FUNC_SEC", u"FUNC_COT",
u"FUNC_ARCSIN", u"FUNC_ARCCOS", u"FUNC_ARCTAN", u"FUNC_ARCCSC",
u"FUNC_ARCSEC", u"FUNC_ARCCOT", u"FUNC_SINH", u"FUNC_COSH",
u"FUNC_TANH", u"FUNC_ARSINH", u"FUNC_ARCOSH", u"FUNC_ARTANH",
u"FUNC_SQRT", u"CMD_TIMES", u"CMD_CDOT", u"CMD_DIV",
u"CMD_FRAC", u"CMD_BINOM", u"CMD_DBINOM", u"CMD_TBINOM",
u"CMD_MATHIT", u"UNDERSCORE", u"CARET", u"COLON",
u"DIFFERENTIAL", u"LETTER", u"NUMBER", u"EQUAL", u"LT",
u"LTE", u"GT", u"GTE", u"BANG", u"SYMBOL" ]
RULE_math = 0
RULE_relation = 1
RULE_equality = 2
RULE_expr = 3
RULE_additive = 4
RULE_mp = 5
RULE_mp_nofunc = 6
RULE_unary = 7
RULE_unary_nofunc = 8
RULE_postfix = 9
RULE_postfix_nofunc = 10
RULE_postfix_op = 11
RULE_eval_at = 12
RULE_eval_at_sub = 13
RULE_eval_at_sup = 14
RULE_exp = 15
RULE_exp_nofunc = 16
RULE_comp = 17
RULE_comp_nofunc = 18
RULE_group = 19
RULE_abs_group = 20
RULE_atom = 21
RULE_mathit = 22
RULE_mathit_text = 23
RULE_frac = 24
RULE_binom = 25
RULE_func_normal = 26
RULE_func = 27
RULE_args = 28
RULE_limit_sub = 29
RULE_func_arg = 30
RULE_func_arg_noparens = 31
RULE_subexpr = 32
RULE_supexpr = 33
RULE_subeq = 34
RULE_supeq = 35
ruleNames = [ u"math", u"relation", u"equality", u"expr", u"additive",
u"mp", u"mp_nofunc", u"unary", u"unary_nofunc", u"postfix",
u"postfix_nofunc", u"postfix_op", u"eval_at", u"eval_at_sub",
u"eval_at_sup", u"exp", u"exp_nofunc", u"comp", u"comp_nofunc",
u"group", u"abs_group", u"atom", u"mathit", u"mathit_text",
u"frac", u"binom", u"func_normal", u"func", u"args",
u"limit_sub", u"func_arg", u"func_arg_noparens", u"subexpr",
u"supexpr", u"subeq", u"supeq" ]
EOF = Token.EOF
T__0=1
WS=2
ADD=3
SUB=4
MUL=5
DIV=6
L_PAREN=7
R_PAREN=8
L_BRACE=9
R_BRACE=10
L_BRACKET=11
R_BRACKET=12
BAR=13
FUNC_LIM=14
LIM_APPROACH_SYM=15
FUNC_INT=16
FUNC_SUM=17
FUNC_PROD=18
FUNC_LOG=19
FUNC_LN=20
FUNC_SIN=21
FUNC_COS=22
FUNC_TAN=23
FUNC_CSC=24
FUNC_SEC=25
FUNC_COT=26
FUNC_ARCSIN=27
FUNC_ARCCOS=28
FUNC_ARCTAN=29
FUNC_ARCCSC=30
FUNC_ARCSEC=31
FUNC_ARCCOT=32
FUNC_SINH=33
FUNC_COSH=34
FUNC_TANH=35
FUNC_ARSINH=36
FUNC_ARCOSH=37
FUNC_ARTANH=38
FUNC_SQRT=39
CMD_TIMES=40
CMD_CDOT=41
CMD_DIV=42
CMD_FRAC=43
CMD_BINOM=44
CMD_DBINOM=45
CMD_TBINOM=46
CMD_MATHIT=47
UNDERSCORE=48
CARET=49
COLON=50
DIFFERENTIAL=51
LETTER=52
NUMBER=53
EQUAL=54
LT=55
LTE=56
GT=57
GTE=58
BANG=59
SYMBOL=60
def __init__(self, input, output=sys.stdout):
super(LaTeXParser, self).__init__(input, output=output)
self.checkVersion("4.7.1")
self._interp = ParserATNSimulator(self, self.atn, self.decisionsToDFA, self.sharedContextCache)
self._predicates = None
class MathContext(ParserRuleContext):
def __init__(self, parser, parent=None, invokingState=-1):
super(LaTeXParser.MathContext, self).__init__(parent, invokingState)
self.parser = parser
def relation(self):
return self.getTypedRuleContext(LaTeXParser.RelationContext,0)
def getRuleIndex(self):
return LaTeXParser.RULE_math
def math(self):
localctx = LaTeXParser.MathContext(self, self._ctx, self.state)
self.enterRule(localctx, 0, self.RULE_math)
try:
self.enterOuterAlt(localctx, 1)
self.state = 72
self.relation(0)
except RecognitionException as re:
localctx.exception = re
self._errHandler.reportError(self, re)
self._errHandler.recover(self, re)
finally:
self.exitRule()
return localctx
class RelationContext(ParserRuleContext):
def __init__(self, parser, parent=None, invokingState=-1):
super(LaTeXParser.RelationContext, self).__init__(parent, invokingState)
self.parser = parser
def expr(self):
return self.getTypedRuleContext(LaTeXParser.ExprContext,0)
def relation(self, i=None):
if i is None:
return self.getTypedRuleContexts(LaTeXParser.RelationContext)
else:
return self.getTypedRuleContext(LaTeXParser.RelationContext,i)
def EQUAL(self):
return self.getToken(LaTeXParser.EQUAL, 0)
def LT(self):
return self.getToken(LaTeXParser.LT, 0)
def LTE(self):
return self.getToken(LaTeXParser.LTE, 0)
def GT(self):
return self.getToken(LaTeXParser.GT, 0)
def GTE(self):
return self.getToken(LaTeXParser.GTE, 0)
def getRuleIndex(self):
return LaTeXParser.RULE_relation
def relation(self, _p=0):
_parentctx = self._ctx
_parentState = self.state
localctx = LaTeXParser.RelationContext(self, self._ctx, _parentState)
_prevctx = localctx
_startState = 2
self.enterRecursionRule(localctx, 2, self.RULE_relation, _p)
self._la = 0 # Token type
try:
self.enterOuterAlt(localctx, 1)
self.state = 75
self.expr()
self._ctx.stop = self._input.LT(-1)
self.state = 82
self._errHandler.sync(self)
_alt = self._interp.adaptivePredict(self._input,0,self._ctx)
while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
if _alt==1:
if self._parseListeners is not None:
self.triggerExitRuleEvent()
_prevctx = localctx
localctx = LaTeXParser.RelationContext(self, _parentctx, _parentState)
self.pushNewRecursionContext(localctx, _startState, self.RULE_relation)
self.state = 77
if not self.precpred(self._ctx, 2):
from antlr4.error.Errors import FailedPredicateException
raise FailedPredicateException(self, "self.precpred(self._ctx, 2)")
self.state = 78
_la = self._input.LA(1)
if not((((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << LaTeXParser.EQUAL) | (1 << LaTeXParser.LT) | (1 << LaTeXParser.LTE) | (1 << LaTeXParser.GT) | (1 << LaTeXParser.GTE))) != 0)):
self._errHandler.recoverInline(self)
else:
self._errHandler.reportMatch(self)
self.consume()
self.state = 79
self.relation(3)
self.state = 84
self._errHandler.sync(self)
_alt = self._interp.adaptivePredict(self._input,0,self._ctx)
except RecognitionException as re:
localctx.exception = re
self._errHandler.reportError(self, re)
self._errHandler.recover(self, re)
finally:
self.unrollRecursionContexts(_parentctx)
return localctx
class EqualityContext(ParserRuleContext):
def __init__(self, parser, parent=None, invokingState=-1):
super(LaTeXParser.EqualityContext, self).__init__(parent, invokingState)
self.parser = parser
def expr(self, i=None):
if i is None:
return self.getTypedRuleContexts(LaTeXParser.ExprContext)
else:
return self.getTypedRuleContext(LaTeXParser.ExprContext,i)
def EQUAL(self):
return self.getToken(LaTeXParser.EQUAL, 0)
def getRuleIndex(self):
return LaTeXParser.RULE_equality
def equality(self):
localctx = LaTeXParser.EqualityContext(self, self._ctx, self.state)
self.enterRule(localctx, 4, self.RULE_equality)
try:
self.enterOuterAlt(localctx, 1)
self.state = 85
self.expr()
self.state = 86
self.match(LaTeXParser.EQUAL)
self.state = 87
self.expr()
except RecognitionException as re:
localctx.exception = re
self._errHandler.reportError(self, re)
self._errHandler.recover(self, re)
finally:
self.exitRule()
return localctx
class ExprContext(ParserRuleContext):
def __init__(self, parser, parent=None, invokingState=-1):
super(LaTeXParser.ExprContext, self).__init__(parent, invokingState)
self.parser = parser
def additive(self):
return self.getTypedRuleContext(LaTeXParser.AdditiveContext,0)
def getRuleIndex(self):
return LaTeXParser.RULE_expr
def expr(self):
localctx = LaTeXParser.ExprContext(self, self._ctx, self.state)
self.enterRule(localctx, 6, self.RULE_expr)
try:
self.enterOuterAlt(localctx, 1)
self.state = 89
self.additive(0)
except RecognitionException as re:
localctx.exception = re
self._errHandler.reportError(self, re)
self._errHandler.recover(self, re)
finally:
self.exitRule()
return localctx
class AdditiveContext(ParserRuleContext):
def __init__(self, parser, parent=None, invokingState=-1):
super(LaTeXParser.AdditiveContext, self).__init__(parent, invokingState)
self.parser = parser
def mp(self):
return self.getTypedRuleContext(LaTeXParser.MpContext,0)
def additive(self, i=None):
if i is None:
return self.getTypedRuleContexts(LaTeXParser.AdditiveContext)
else:
return self.getTypedRuleContext(LaTeXParser.AdditiveContext,i)
def ADD(self):
return self.getToken(LaTeXParser.ADD, 0)
def SUB(self):
return self.getToken(LaTeXParser.SUB, 0)
def getRuleIndex(self):
return LaTeXParser.RULE_additive
def additive(self, _p=0):
_parentctx = self._ctx
_parentState = self.state
localctx = LaTeXParser.AdditiveContext(self, self._ctx, _parentState)
_prevctx = localctx
_startState = 8
self.enterRecursionRule(localctx, 8, self.RULE_additive, _p)
self._la = 0 # Token type
try:
self.enterOuterAlt(localctx, 1)
self.state = 92
self.mp(0)
self._ctx.stop = self._input.LT(-1)
self.state = 99
self._errHandler.sync(self)
_alt = self._interp.adaptivePredict(self._input,1,self._ctx)
while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
if _alt==1:
if self._parseListeners is not None:
self.triggerExitRuleEvent()
_prevctx = localctx
localctx = LaTeXParser.AdditiveContext(self, _parentctx, _parentState)
self.pushNewRecursionContext(localctx, _startState, self.RULE_additive)
self.state = 94
if not self.precpred(self._ctx, 2):
from antlr4.error.Errors import FailedPredicateException
raise FailedPredicateException(self, "self.precpred(self._ctx, 2)")
self.state = 95
_la = self._input.LA(1)
if not(_la==LaTeXParser.ADD or _la==LaTeXParser.SUB):
self._errHandler.recoverInline(self)
else:
self._errHandler.reportMatch(self)
self.consume()
self.state = 96
self.additive(3)
self.state = 101
self._errHandler.sync(self)
_alt = self._interp.adaptivePredict(self._input,1,self._ctx)
except RecognitionException as re:
localctx.exception = re
self._errHandler.reportError(self, re)
self._errHandler.recover(self, re)
finally:
self.unrollRecursionContexts(_parentctx)
return localctx
class MpContext(ParserRuleContext):
def __init__(self, parser, parent=None, invokingState=-1):
super(LaTeXParser.MpContext, self).__init__(parent, invokingState)
self.parser = parser
def unary(self):
return self.getTypedRuleContext(LaTeXParser.UnaryContext,0)
def mp(self, i=None):
if i is None:
return self.getTypedRuleContexts(LaTeXParser.MpContext)
else:
return self.getTypedRuleContext(LaTeXParser.MpContext,i)
def MUL(self):
return self.getToken(LaTeXParser.MUL, 0)
def CMD_TIMES(self):
return self.getToken(LaTeXParser.CMD_TIMES, 0)
def CMD_CDOT(self):
return self.getToken(LaTeXParser.CMD_CDOT, 0)
def DIV(self):
return self.getToken(LaTeXParser.DIV, 0)
def CMD_DIV(self):
return self.getToken(LaTeXParser.CMD_DIV, 0)
def COLON(self):
return self.getToken(LaTeXParser.COLON, 0)
def getRuleIndex(self):
return LaTeXParser.RULE_mp
def mp(self, _p=0):
_parentctx = self._ctx
_parentState = self.state
localctx = LaTeXParser.MpContext(self, self._ctx, _parentState)
_prevctx = localctx
_startState = 10
self.enterRecursionRule(localctx, 10, self.RULE_mp, _p)
self._la = 0 # Token type
try:
self.enterOuterAlt(localctx, 1)
self.state = 103
self.unary()
self._ctx.stop = self._input.LT(-1)
self.state = 110
self._errHandler.sync(self)
_alt = self._interp.adaptivePredict(self._input,2,self._ctx)
while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
if _alt==1:
if self._parseListeners is not None:
self.triggerExitRuleEvent()
_prevctx = localctx
localctx = LaTeXParser.MpContext(self, _parentctx, _parentState)
self.pushNewRecursionContext(localctx, _startState, self.RULE_mp)
self.state = 105
if not self.precpred(self._ctx, 2):
from antlr4.error.Errors import FailedPredicateException
raise FailedPredicateException(self, "self.precpred(self._ctx, 2)")
self.state = 106
_la = self._input.LA(1)
if not((((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << LaTeXParser.MUL) | (1 << LaTeXParser.DIV) | (1 << LaTeXParser.CMD_TIMES) | (1 << LaTeXParser.CMD_CDOT) | (1 << LaTeXParser.CMD_DIV) | (1 << LaTeXParser.COLON))) != 0)):
self._errHandler.recoverInline(self)
else:
self._errHandler.reportMatch(self)
self.consume()
self.state = 107
self.mp(3)
self.state = 112
self._errHandler.sync(self)
_alt = self._interp.adaptivePredict(self._input,2,self._ctx)
except RecognitionException as re:
localctx.exception = re
self._errHandler.reportError(self, re)
self._errHandler.recover(self, re)
finally:
self.unrollRecursionContexts(_parentctx)
return localctx
class Mp_nofuncContext(ParserRuleContext):
def __init__(self, parser, parent=None, invokingState=-1):
super(LaTeXParser.Mp_nofuncContext, self).__init__(parent, invokingState)
self.parser = parser
def unary_nofunc(self):
return self.getTypedRuleContext(LaTeXParser.Unary_nofuncContext,0)
def mp_nofunc(self, i=None):
if i is None:
return self.getTypedRuleContexts(LaTeXParser.Mp_nofuncContext)
else:
return self.getTypedRuleContext(LaTeXParser.Mp_nofuncContext,i)
def MUL(self):
return self.getToken(LaTeXParser.MUL, 0)
def CMD_TIMES(self):
return self.getToken(LaTeXParser.CMD_TIMES, 0)
def CMD_CDOT(self):
return self.getToken(LaTeXParser.CMD_CDOT, 0)
def DIV(self):
return self.getToken(LaTeXParser.DIV, 0)
def CMD_DIV(self):
return self.getToken(LaTeXParser.CMD_DIV, 0)
def COLON(self):
return self.getToken(LaTeXParser.COLON, 0)
def getRuleIndex(self):
return LaTeXParser.RULE_mp_nofunc
def mp_nofunc(self, _p=0):
_parentctx = self._ctx
_parentState = self.state
localctx = LaTeXParser.Mp_nofuncContext(self, self._ctx, _parentState)
_prevctx = localctx
_startState = 12
self.enterRecursionRule(localctx, 12, self.RULE_mp_nofunc, _p)
self._la = 0 # Token type
try:
self.enterOuterAlt(localctx, 1)
self.state = 114
self.unary_nofunc()
self._ctx.stop = self._input.LT(-1)
self.state = 121
self._errHandler.sync(self)
_alt = self._interp.adaptivePredict(self._input,3,self._ctx)
while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
if _alt==1:
if self._parseListeners is not None:
self.triggerExitRuleEvent()
_prevctx = localctx
localctx = LaTeXParser.Mp_nofuncContext(self, _parentctx, _parentState)
self.pushNewRecursionContext(localctx, _startState, self.RULE_mp_nofunc)
self.state = 116
if not self.precpred(self._ctx, 2):
from antlr4.error.Errors import FailedPredicateException
raise FailedPredicateException(self, "self.precpred(self._ctx, 2)")
self.state = 117
_la = self._input.LA(1)
if not((((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << LaTeXParser.MUL) | (1 << LaTeXParser.DIV) | (1 << LaTeXParser.CMD_TIMES) | (1 << LaTeXParser.CMD_CDOT) | (1 << LaTeXParser.CMD_DIV) | (1 << LaTeXParser.COLON))) != 0)):
self._errHandler.recoverInline(self)
else:
self._errHandler.reportMatch(self)
self.consume()
self.state = 118
self.mp_nofunc(3)
self.state = 123
self._errHandler.sync(self)
_alt = self._interp.adaptivePredict(self._input,3,self._ctx)
except RecognitionException as re:
localctx.exception = re
self._errHandler.reportError(self, re)
self._errHandler.recover(self, re)
finally:
self.unrollRecursionContexts(_parentctx)
return localctx
class UnaryContext(ParserRuleContext):
def __init__(self, parser, parent=None, invokingState=-1):
super(LaTeXParser.UnaryContext, self).__init__(parent, invokingState)
self.parser = parser
def unary(self):
return self.getTypedRuleContext(LaTeXParser.UnaryContext,0)
def ADD(self):
return self.getToken(LaTeXParser.ADD, 0)
def SUB(self):
return self.getToken(LaTeXParser.SUB, 0)
def postfix(self, i=None):
if i is None:
return self.getTypedRuleContexts(LaTeXParser.PostfixContext)
else:
return self.getTypedRuleContext(LaTeXParser.PostfixContext,i)
def getRuleIndex(self):
return LaTeXParser.RULE_unary
def unary(self):
localctx = LaTeXParser.UnaryContext(self, self._ctx, self.state)
self.enterRule(localctx, 14, self.RULE_unary)
self._la = 0 # Token type
try:
self.state = 131
self._errHandler.sync(self)
token = self._input.LA(1)
if token in [LaTeXParser.ADD, LaTeXParser.SUB]:
self.enterOuterAlt(localctx, 1)
self.state = 124
_la = self._input.LA(1)
if not(_la==LaTeXParser.ADD or _la==LaTeXParser.SUB):
self._errHandler.recoverInline(self)
else:
self._errHandler.reportMatch(self)
self.consume()
self.state = 125
self.unary()
pass
elif token in [LaTeXParser.L_PAREN, LaTeXParser.L_BRACE, LaTeXParser.L_BRACKET, LaTeXParser.BAR, LaTeXParser.FUNC_LIM, LaTeXParser.FUNC_INT, LaTeXParser.FUNC_SUM, LaTeXParser.FUNC_PROD, LaTeXParser.FUNC_LOG, LaTeXParser.FUNC_LN, LaTeXParser.FUNC_SIN, LaTeXParser.FUNC_COS, LaTeXParser.FUNC_TAN, LaTeXParser.FUNC_CSC, LaTeXParser.FUNC_SEC, LaTeXParser.FUNC_COT, LaTeXParser.FUNC_ARCSIN, LaTeXParser.FUNC_ARCCOS, LaTeXParser.FUNC_ARCTAN, LaTeXParser.FUNC_ARCCSC, LaTeXParser.FUNC_ARCSEC, LaTeXParser.FUNC_ARCCOT, LaTeXParser.FUNC_SINH, LaTeXParser.FUNC_COSH, LaTeXParser.FUNC_TANH, LaTeXParser.FUNC_ARSINH, LaTeXParser.FUNC_ARCOSH, LaTeXParser.FUNC_ARTANH, LaTeXParser.FUNC_SQRT, LaTeXParser.CMD_FRAC, LaTeXParser.CMD_BINOM, LaTeXParser.CMD_DBINOM, LaTeXParser.CMD_TBINOM, LaTeXParser.CMD_MATHIT, LaTeXParser.DIFFERENTIAL, LaTeXParser.LETTER, LaTeXParser.NUMBER, LaTeXParser.SYMBOL]:
self.enterOuterAlt(localctx, 2)
self.state = 127
self._errHandler.sync(self)
_alt = 1
while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
if _alt == 1:
self.state = 126
self.postfix()
else:
raise NoViableAltException(self)
self.state = 129
self._errHandler.sync(self)
_alt = self._interp.adaptivePredict(self._input,4,self._ctx)
pass
else:
raise NoViableAltException(self)
except RecognitionException as re:
localctx.exception = re
self._errHandler.reportError(self, re)
self._errHandler.recover(self, re)
finally:
self.exitRule()
return localctx
class Unary_nofuncContext(ParserRuleContext):
def __init__(self, parser, parent=None, invokingState=-1):
super(LaTeXParser.Unary_nofuncContext, self).__init__(parent, invokingState)
self.parser = parser
def unary_nofunc(self):
return self.getTypedRuleContext(LaTeXParser.Unary_nofuncContext,0)
def ADD(self):
return self.getToken(LaTeXParser.ADD, 0)
def SUB(self):
return self.getToken(LaTeXParser.SUB, 0)
def postfix(self):
return self.getTypedRuleContext(LaTeXParser.PostfixContext,0)
def postfix_nofunc(self, i=None):
if i is None:
return self.getTypedRuleContexts(LaTeXParser.Postfix_nofuncContext)
else:
return self.getTypedRuleContext(LaTeXParser.Postfix_nofuncContext,i)
def getRuleIndex(self):
return LaTeXParser.RULE_unary_nofunc
def unary_nofunc(self):
localctx = LaTeXParser.Unary_nofuncContext(self, self._ctx, self.state)
self.enterRule(localctx, 16, self.RULE_unary_nofunc)
self._la = 0 # Token type
try:
self.state = 142
self._errHandler.sync(self)
token = self._input.LA(1)
if token in [LaTeXParser.ADD, LaTeXParser.SUB]:
self.enterOuterAlt(localctx, 1)
self.state = 133
_la = self._input.LA(1)
if not(_la==LaTeXParser.ADD or _la==LaTeXParser.SUB):
self._errHandler.recoverInline(self)
else:
self._errHandler.reportMatch(self)
self.consume()
self.state = 134
self.unary_nofunc()
pass
elif token in [LaTeXParser.L_PAREN, LaTeXParser.L_BRACE, LaTeXParser.L_BRACKET, LaTeXParser.BAR, LaTeXParser.FUNC_LIM, LaTeXParser.FUNC_INT, LaTeXParser.FUNC_SUM, LaTeXParser.FUNC_PROD, LaTeXParser.FUNC_LOG, LaTeXParser.FUNC_LN, LaTeXParser.FUNC_SIN, LaTeXParser.FUNC_COS, LaTeXParser.FUNC_TAN, LaTeXParser.FUNC_CSC, LaTeXParser.FUNC_SEC, LaTeXParser.FUNC_COT, LaTeXParser.FUNC_ARCSIN, LaTeXParser.FUNC_ARCCOS, LaTeXParser.FUNC_ARCTAN, LaTeXParser.FUNC_ARCCSC, LaTeXParser.FUNC_ARCSEC, LaTeXParser.FUNC_ARCCOT, LaTeXParser.FUNC_SINH, LaTeXParser.FUNC_COSH, LaTeXParser.FUNC_TANH, LaTeXParser.FUNC_ARSINH, LaTeXParser.FUNC_ARCOSH, LaTeXParser.FUNC_ARTANH, LaTeXParser.FUNC_SQRT, LaTeXParser.CMD_FRAC, LaTeXParser.CMD_BINOM, LaTeXParser.CMD_DBINOM, LaTeXParser.CMD_TBINOM, LaTeXParser.CMD_MATHIT, LaTeXParser.DIFFERENTIAL, LaTeXParser.LETTER, LaTeXParser.NUMBER, LaTeXParser.SYMBOL]:
self.enterOuterAlt(localctx, 2)
self.state = 135
self.postfix()
self.state = 139
self._errHandler.sync(self)
_alt = self._interp.adaptivePredict(self._input,6,self._ctx)
while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
if _alt==1:
self.state = 136
self.postfix_nofunc()
self.state = 141
self._errHandler.sync(self)
_alt = self._interp.adaptivePredict(self._input,6,self._ctx)
pass
else:
raise NoViableAltException(self)
except RecognitionException as re:
localctx.exception = re
self._errHandler.reportError(self, re)
self._errHandler.recover(self, re)
finally:
self.exitRule()
return localctx
class PostfixContext(ParserRuleContext):
def __init__(self, parser, parent=None, invokingState=-1):
super(LaTeXParser.PostfixContext, self).__init__(parent, invokingState)
self.parser = parser
def exp(self):
return self.getTypedRuleContext(LaTeXParser.ExpContext,0)
def postfix_op(self, i=None):
if i is None:
return self.getTypedRuleContexts(LaTeXParser.Postfix_opContext)
else:
return self.getTypedRuleContext(LaTeXParser.Postfix_opContext,i)
def getRuleIndex(self):
return LaTeXParser.RULE_postfix
def postfix(self):
localctx = LaTeXParser.PostfixContext(self, self._ctx, self.state)
self.enterRule(localctx, 18, self.RULE_postfix)
try:
self.enterOuterAlt(localctx, 1)
self.state = 144
self.exp(0)
self.state = 148
self._errHandler.sync(self)
_alt = self._interp.adaptivePredict(self._input,8,self._ctx)
while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
if _alt==1:
self.state = 145
self.postfix_op()
self.state = 150
self._errHandler.sync(self)
_alt = self._interp.adaptivePredict(self._input,8,self._ctx)
except RecognitionException as re:
localctx.exception = re
self._errHandler.reportError(self, re)
self._errHandler.recover(self, re)
finally:
self.exitRule()
return localctx
class Postfix_nofuncContext(ParserRuleContext):
def __init__(self, parser, parent=None, invokingState=-1):
super(LaTeXParser.Postfix_nofuncContext, self).__init__(parent, invokingState)
self.parser = parser
def exp_nofunc(self):
return self.getTypedRuleContext(LaTeXParser.Exp_nofuncContext,0)
def postfix_op(self, i=None):
if i is None:
return self.getTypedRuleContexts(LaTeXParser.Postfix_opContext)
else:
return self.getTypedRuleContext(LaTeXParser.Postfix_opContext,i)
def getRuleIndex(self):
return LaTeXParser.RULE_postfix_nofunc
def postfix_nofunc(self):
localctx = LaTeXParser.Postfix_nofuncContext(self, self._ctx, self.state)
self.enterRule(localctx, 20, self.RULE_postfix_nofunc)
try:
self.enterOuterAlt(localctx, 1)
self.state = 151
self.exp_nofunc(0)
self.state = 155
self._errHandler.sync(self)
_alt = self._interp.adaptivePredict(self._input,9,self._ctx)
while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
if _alt==1:
self.state = 152
self.postfix_op()
self.state = 157
self._errHandler.sync(self)
_alt = self._interp.adaptivePredict(self._input,9,self._ctx)
except RecognitionException as re:
localctx.exception = re
self._errHandler.reportError(self, re)
self._errHandler.recover(self, re)
finally:
self.exitRule()
return localctx
class Postfix_opContext(ParserRuleContext):
def __init__(self, parser, parent=None, invokingState=-1):
super(LaTeXParser.Postfix_opContext, self).__init__(parent, invokingState)
self.parser = parser
def BANG(self):
return self.getToken(LaTeXParser.BANG, 0)
def eval_at(self):
return self.getTypedRuleContext(LaTeXParser.Eval_atContext,0)
def getRuleIndex(self):
return LaTeXParser.RULE_postfix_op
def postfix_op(self):
localctx = LaTeXParser.Postfix_opContext(self, self._ctx, self.state)
self.enterRule(localctx, 22, self.RULE_postfix_op)
try:
self.state = 160
self._errHandler.sync(self)
token = self._input.LA(1)
if token in [LaTeXParser.BANG]:
self.enterOuterAlt(localctx, 1)
self.state = 158
self.match(LaTeXParser.BANG)
pass
elif token in [LaTeXParser.BAR]:
self.enterOuterAlt(localctx, 2)
self.state = 159
self.eval_at()
pass
else:
raise NoViableAltException(self)
except RecognitionException as re:
localctx.exception = re
self._errHandler.reportError(self, re)
self._errHandler.recover(self, re)
finally:
self.exitRule()
return localctx
class Eval_atContext(ParserRuleContext):
def __init__(self, parser, parent=None, invokingState=-1):
super(LaTeXParser.Eval_atContext, self).__init__(parent, invokingState)
self.parser = parser
def BAR(self):
return self.getToken(LaTeXParser.BAR, 0)
def eval_at_sup(self):
return self.getTypedRuleContext(LaTeXParser.Eval_at_supContext,0)
def eval_at_sub(self):
return self.getTypedRuleContext(LaTeXParser.Eval_at_subContext,0)
def getRuleIndex(self):
return LaTeXParser.RULE_eval_at
def eval_at(self):
localctx = LaTeXParser.Eval_atContext(self, self._ctx, self.state)
self.enterRule(localctx, 24, self.RULE_eval_at)
try:
self.enterOuterAlt(localctx, 1)
self.state = 162
self.match(LaTeXParser.BAR)
self.state = 168
self._errHandler.sync(self)
la_ = self._interp.adaptivePredict(self._input,11,self._ctx)
if la_ == 1:
self.state = 163
self.eval_at_sup()
pass
elif la_ == 2:
self.state = 164
self.eval_at_sub()
pass
elif la_ == 3:
self.state = 165
self.eval_at_sup()
self.state = 166
self.eval_at_sub()
pass
except RecognitionException as re:
localctx.exception = re
self._errHandler.reportError(self, re)
self._errHandler.recover(self, re)
finally:
self.exitRule()
return localctx
class Eval_at_subContext(ParserRuleContext):
def __init__(self, parser, parent=None, invokingState=-1):
super(LaTeXParser.Eval_at_subContext, self).__init__(parent, invokingState)
self.parser = parser
def UNDERSCORE(self):
return self.getToken(LaTeXParser.UNDERSCORE, 0)
def L_BRACE(self):
return self.getToken(LaTeXParser.L_BRACE, 0)
def R_BRACE(self):
return self.getToken(LaTeXParser.R_BRACE, 0)
def expr(self):
return self.getTypedRuleContext(LaTeXParser.ExprContext,0)
def equality(self):
return self.getTypedRuleContext(LaTeXParser.EqualityContext,0)
def getRuleIndex(self):
return LaTeXParser.RULE_eval_at_sub
def eval_at_sub(self):
localctx = LaTeXParser.Eval_at_subContext(self, self._ctx, self.state)
self.enterRule(localctx, 26, self.RULE_eval_at_sub)
try:
self.enterOuterAlt(localctx, 1)
self.state = 170
self.match(LaTeXParser.UNDERSCORE)
self.state = 171
self.match(LaTeXParser.L_BRACE)
self.state = 174
self._errHandler.sync(self)
la_ = self._interp.adaptivePredict(self._input,12,self._ctx)
if la_ == 1:
self.state = 172
self.expr()
pass
elif la_ == 2:
self.state = 173
self.equality()
pass
self.state = 176
self.match(LaTeXParser.R_BRACE)
except RecognitionException as re:
localctx.exception = re
self._errHandler.reportError(self, re)
self._errHandler.recover(self, re)
finally:
self.exitRule()
return localctx
class Eval_at_supContext(ParserRuleContext):
def __init__(self, parser, parent=None, invokingState=-1):
super(LaTeXParser.Eval_at_supContext, self).__init__(parent, invokingState)
self.parser = parser
def CARET(self):
return self.getToken(LaTeXParser.CARET, 0)
def L_BRACE(self):
return self.getToken(LaTeXParser.L_BRACE, 0)
def R_BRACE(self):
return self.getToken(LaTeXParser.R_BRACE, 0)
def expr(self):
return self.getTypedRuleContext(LaTeXParser.ExprContext,0)
def equality(self):
return self.getTypedRuleContext(LaTeXParser.EqualityContext,0)
def getRuleIndex(self):
return LaTeXParser.RULE_eval_at_sup
def eval_at_sup(self):
localctx = LaTeXParser.Eval_at_supContext(self, self._ctx, self.state)
self.enterRule(localctx, 28, self.RULE_eval_at_sup)
try:
self.enterOuterAlt(localctx, 1)
self.state = 178
self.match(LaTeXParser.CARET)
self.state = 179
self.match(LaTeXParser.L_BRACE)
self.state = 182
self._errHandler.sync(self)
la_ = self._interp.adaptivePredict(self._input,13,self._ctx)
if la_ == 1:
self.state = 180
self.expr()
pass
elif la_ == 2:
self.state = 181
self.equality()
pass
self.state = 184
self.match(LaTeXParser.R_BRACE)
except RecognitionException as re:
localctx.exception = re
self._errHandler.reportError(self, re)
self._errHandler.recover(self, re)
finally:
self.exitRule()
return localctx
class ExpContext(ParserRuleContext):
def __init__(self, parser, parent=None, invokingState=-1):
super(LaTeXParser.ExpContext, self).__init__(parent, invokingState)
self.parser = parser
def comp(self):
return self.getTypedRuleContext(LaTeXParser.CompContext,0)
def exp(self):
return self.getTypedRuleContext(LaTeXParser.ExpContext,0)
def CARET(self):
return self.getToken(LaTeXParser.CARET, 0)
def atom(self):
return self.getTypedRuleContext(LaTeXParser.AtomContext,0)
def L_BRACE(self):
return self.getToken(LaTeXParser.L_BRACE, 0)
def expr(self):
return self.getTypedRuleContext(LaTeXParser.ExprContext,0)
def R_BRACE(self):
return self.getToken(LaTeXParser.R_BRACE, 0)
def subexpr(self):
return self.getTypedRuleContext(LaTeXParser.SubexprContext,0)
def getRuleIndex(self):
return LaTeXParser.RULE_exp
def exp(self, _p=0):
_parentctx = self._ctx
_parentState = self.state
localctx = LaTeXParser.ExpContext(self, self._ctx, _parentState)
_prevctx = localctx
_startState = 30
self.enterRecursionRule(localctx, 30, self.RULE_exp, _p)
try:
self.enterOuterAlt(localctx, 1)
self.state = 187
self.comp()
self._ctx.stop = self._input.LT(-1)
self.state = 203
self._errHandler.sync(self)
_alt = self._interp.adaptivePredict(self._input,16,self._ctx)
while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
if _alt==1:
if self._parseListeners is not None:
self.triggerExitRuleEvent()
_prevctx = localctx
localctx = LaTeXParser.ExpContext(self, _parentctx, _parentState)
self.pushNewRecursionContext(localctx, _startState, self.RULE_exp)
self.state = 189
if not self.precpred(self._ctx, 2):
from antlr4.error.Errors import FailedPredicateException
raise FailedPredicateException(self, "self.precpred(self._ctx, 2)")
self.state = 190
self.match(LaTeXParser.CARET)
self.state = 196
self._errHandler.sync(self)
token = self._input.LA(1)
if token in [LaTeXParser.CMD_MATHIT, LaTeXParser.DIFFERENTIAL, LaTeXParser.LETTER, LaTeXParser.NUMBER, LaTeXParser.SYMBOL]:
self.state = 191
self.atom()
pass
elif token in [LaTeXParser.L_BRACE]:
self.state = 192
self.match(LaTeXParser.L_BRACE)
self.state = 193
self.expr()
self.state = 194
self.match(LaTeXParser.R_BRACE)
pass
else:
raise NoViableAltException(self)
self.state = 199
self._errHandler.sync(self)
la_ = self._interp.adaptivePredict(self._input,15,self._ctx)
if la_ == 1:
self.state = 198
self.subexpr()
self.state = 205
self._errHandler.sync(self)
_alt = self._interp.adaptivePredict(self._input,16,self._ctx)
except RecognitionException as re:
localctx.exception = re
self._errHandler.reportError(self, re)
self._errHandler.recover(self, re)
finally:
self.unrollRecursionContexts(_parentctx)
return localctx
class Exp_nofuncContext(ParserRuleContext):
def __init__(self, parser, parent=None, invokingState=-1):
super(LaTeXParser.Exp_nofuncContext, self).__init__(parent, invokingState)
self.parser = parser
def comp_nofunc(self):
return self.getTypedRuleContext(LaTeXParser.Comp_nofuncContext,0)
def exp_nofunc(self):
return self.getTypedRuleContext(LaTeXParser.Exp_nofuncContext,0)
def CARET(self):
return self.getToken(LaTeXParser.CARET, 0)
def atom(self):
return self.getTypedRuleContext(LaTeXParser.AtomContext,0)
def L_BRACE(self):
return self.getToken(LaTeXParser.L_BRACE, 0)
def expr(self):
return self.getTypedRuleContext(LaTeXParser.ExprContext,0)
def R_BRACE(self):
return self.getToken(LaTeXParser.R_BRACE, 0)
def subexpr(self):
return self.getTypedRuleContext(LaTeXParser.SubexprContext,0)
def getRuleIndex(self):
return LaTeXParser.RULE_exp_nofunc
def exp_nofunc(self, _p=0):
_parentctx = self._ctx
_parentState = self.state
localctx = LaTeXParser.Exp_nofuncContext(self, self._ctx, _parentState)
_prevctx = localctx
_startState = 32
self.enterRecursionRule(localctx, 32, self.RULE_exp_nofunc, _p)
try:
self.enterOuterAlt(localctx, 1)
self.state = 207
self.comp_nofunc()
self._ctx.stop = self._input.LT(-1)
self.state = 223
self._errHandler.sync(self)
_alt = self._interp.adaptivePredict(self._input,19,self._ctx)
while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER:
if _alt==1:
if self._parseListeners is not None:
self.triggerExitRuleEvent()
_prevctx = localctx
localctx = LaTeXParser.Exp_nofuncContext(self, _parentctx, _parentState)
self.pushNewRecursionContext(localctx, _startState, self.RULE_exp_nofunc)
self.state = 209
if not self.precpred(self._ctx, 2):
from antlr4.error.Errors import FailedPredicateException
raise FailedPredicateException(self, "self.precpred(self._ctx, 2)")
self.state = 210
self.match(LaTeXParser.CARET)
self.state = 216
self._errHandler.sync(self)
token = self._input.LA(1)
if token in [LaTeXParser.CMD_MATHIT, LaTeXParser.DIFFERENTIAL, LaTeXParser.LETTER, LaTeXParser.NUMBER, LaTeXParser.SYMBOL]:
self.state = 211
self.atom()
pass
elif token in [LaTeXParser.L_BRACE]:
self.state = 212
self.match(LaTeXParser.L_BRACE)
self.state = 213
self.expr()
self.state = 214
self.match(LaTeXParser.R_BRACE)
pass
else:
raise NoViableAltException(self)
self.state = 219
self._errHandler.sync(self)
la_ = self._interp.adaptivePredict(self._input,18,self._ctx)
if la_ == 1:
self.state = 218
self.subexpr()
self.state = 225
self._errHandler.sync(self)
_alt = self._interp.adaptivePredict(self._input,19,self._ctx)
except RecognitionException as re:
localctx.exception = re
self._errHandler.reportError(self, re)
self._errHandler.recover(self, re)
finally:
self.unrollRecursionContexts(_parentctx)
return localctx
class CompContext(ParserRuleContext):
def __init__(self, parser, parent=None, invokingState=-1):
super(LaTeXParser.CompContext, self).__init__(parent, invokingState)
self.parser = parser
def group(self):
return self.getTypedRuleContext(LaTeXParser.GroupContext,0)
def abs_group(self):
return self.getTypedRuleContext(LaTeXParser.Abs_groupContext,0)
def func(self):
return self.getTypedRuleContext(LaTeXParser.FuncContext,0)
def atom(self):
return self.getTypedRuleContext(LaTeXParser.AtomContext,0)
def frac(self):
return self.getTypedRuleContext(LaTeXParser.FracContext,0)
def binom(self):
return self.getTypedRuleContext(LaTeXParser.BinomContext,0)
def getRuleIndex(self):
return LaTeXParser.RULE_comp
def comp(self):
localctx = LaTeXParser.CompContext(self, self._ctx, self.state)
self.enterRule(localctx, 34, self.RULE_comp)
try:
self.state = 232
self._errHandler.sync(self)
la_ = self._interp.adaptivePredict(self._input,20,self._ctx)
if la_ == 1:
self.enterOuterAlt(localctx, 1)
self.state = 226
self.group()
pass
elif la_ == 2:
self.enterOuterAlt(localctx, 2)
self.state = 227
self.abs_group()
pass
elif la_ == 3:
self.enterOuterAlt(localctx, 3)
self.state = 228
self.func()
pass
elif la_ == 4:
self.enterOuterAlt(localctx, 4)
self.state = 229
self.atom()
pass
elif la_ == 5:
self.enterOuterAlt(localctx, 5)
self.state = 230
self.frac()
pass
elif la_ == 6:
self.enterOuterAlt(localctx, 6)
self.state = 231
self.binom()
pass
except RecognitionException as re:
localctx.exception = re
self._errHandler.reportError(self, re)
self._errHandler.recover(self, re)
finally:
self.exitRule()
return localctx
class Comp_nofuncContext(ParserRuleContext):
def __init__(self, parser, parent=None, invokingState=-1):
super(LaTeXParser.Comp_nofuncContext, self).__init__(parent, invokingState)
self.parser = parser
def group(self):
return self.getTypedRuleContext(LaTeXParser.GroupContext,0)
def abs_group(self):
return self.getTypedRuleContext(LaTeXParser.Abs_groupContext,0)
def atom(self):
return self.getTypedRuleContext(LaTeXParser.AtomContext,0)
def frac(self):
return self.getTypedRuleContext(LaTeXParser.FracContext,0)
def binom(self):
return self.getTypedRuleContext(LaTeXParser.BinomContext,0)
def getRuleIndex(self):
return LaTeXParser.RULE_comp_nofunc
def comp_nofunc(self):
localctx = LaTeXParser.Comp_nofuncContext(self, self._ctx, self.state)
self.enterRule(localctx, 36, self.RULE_comp_nofunc)
try:
self.state = 239
self._errHandler.sync(self)
token = self._input.LA(1)
if token in [LaTeXParser.L_PAREN, LaTeXParser.L_BRACE, LaTeXParser.L_BRACKET]:
self.enterOuterAlt(localctx, 1)
self.state = 234
self.group()
pass
elif token in [LaTeXParser.BAR]:
self.enterOuterAlt(localctx, 2)
self.state = 235
self.abs_group()
pass
elif token in [LaTeXParser.CMD_MATHIT, LaTeXParser.DIFFERENTIAL, LaTeXParser.LETTER, LaTeXParser.NUMBER, LaTeXParser.SYMBOL]:
self.enterOuterAlt(localctx, 3)
self.state = 236
self.atom()
pass
elif token in [LaTeXParser.CMD_FRAC]:
self.enterOuterAlt(localctx, 4)
self.state = 237
self.frac()
pass
elif token in [LaTeXParser.CMD_BINOM, LaTeXParser.CMD_DBINOM, LaTeXParser.CMD_TBINOM]:
self.enterOuterAlt(localctx, 5)
self.state = 238
self.binom()
pass
else:
raise NoViableAltException(self)
except RecognitionException as re:
localctx.exception = re
self._errHandler.reportError(self, re)
self._errHandler.recover(self, re)
finally:
self.exitRule()
return localctx
class GroupContext(ParserRuleContext):
def __init__(self, parser, parent=None, invokingState=-1):
super(LaTeXParser.GroupContext, self).__init__(parent, invokingState)
self.parser = parser
def L_PAREN(self):
return self.getToken(LaTeXParser.L_PAREN, 0)
def expr(self):
return self.getTypedRuleContext(LaTeXParser.ExprContext,0)
def R_PAREN(self):
return self.getToken(LaTeXParser.R_PAREN, 0)
def L_BRACKET(self):
return self.getToken(LaTeXParser.L_BRACKET, 0)
def R_BRACKET(self):
return self.getToken(LaTeXParser.R_BRACKET, 0)
def L_BRACE(self):
return self.getToken(LaTeXParser.L_BRACE, 0)
def R_BRACE(self):
return self.getToken(LaTeXParser.R_BRACE, 0)
def getRuleIndex(self):
return LaTeXParser.RULE_group
def group(self):
localctx = LaTeXParser.GroupContext(self, self._ctx, self.state)
self.enterRule(localctx, 38, self.RULE_group)
try:
self.state = 253
self._errHandler.sync(self)
token = self._input.LA(1)
if token in [LaTeXParser.L_PAREN]:
self.enterOuterAlt(localctx, 1)
self.state = 241
self.match(LaTeXParser.L_PAREN)
self.state = 242
self.expr()
self.state = 243
self.match(LaTeXParser.R_PAREN)
pass
elif token in [LaTeXParser.L_BRACKET]:
self.enterOuterAlt(localctx, 2)
self.state = 245
self.match(LaTeXParser.L_BRACKET)
self.state = 246
self.expr()
self.state = 247
self.match(LaTeXParser.R_BRACKET)
pass
elif token in [LaTeXParser.L_BRACE]:
self.enterOuterAlt(localctx, 3)
self.state = 249
self.match(LaTeXParser.L_BRACE)
self.state = 250
self.expr()
self.state = 251
self.match(LaTeXParser.R_BRACE)
pass
else:
raise NoViableAltException(self)
except RecognitionException as re:
localctx.exception = re
self._errHandler.reportError(self, re)
self._errHandler.recover(self, re)
finally:
self.exitRule()
return localctx
class Abs_groupContext(ParserRuleContext):
def __init__(self, parser, parent=None, invokingState=-1):
super(LaTeXParser.Abs_groupContext, self).__init__(parent, invokingState)
self.parser = parser
def BAR(self, i=None):
if i is None:
return self.getTokens(LaTeXParser.BAR)
else:
return self.getToken(LaTeXParser.BAR, i)
def expr(self):
return self.getTypedRuleContext(LaTeXParser.ExprContext,0)
def getRuleIndex(self):
return LaTeXParser.RULE_abs_group
def abs_group(self):
localctx = LaTeXParser.Abs_groupContext(self, self._ctx, self.state)
self.enterRule(localctx, 40, self.RULE_abs_group)
try:
self.enterOuterAlt(localctx, 1)
self.state = 255
self.match(LaTeXParser.BAR)
self.state = 256
self.expr()
self.state = 257
self.match(LaTeXParser.BAR)
except RecognitionException as re:
localctx.exception = re
self._errHandler.reportError(self, re)
self._errHandler.recover(self, re)
finally:
self.exitRule()
return localctx
class AtomContext(ParserRuleContext):
def __init__(self, parser, parent=None, invokingState=-1):
super(LaTeXParser.AtomContext, self).__init__(parent, invokingState)
self.parser = parser
def LETTER(self):
return self.getToken(LaTeXParser.LETTER, 0)
def SYMBOL(self):
return self.getToken(LaTeXParser.SYMBOL, 0)
def subexpr(self):
return self.getTypedRuleContext(LaTeXParser.SubexprContext,0)
def NUMBER(self):
return self.getToken(LaTeXParser.NUMBER, 0)
def DIFFERENTIAL(self):
return self.getToken(LaTeXParser.DIFFERENTIAL, 0)
def mathit(self):
return self.getTypedRuleContext(LaTeXParser.MathitContext,0)
def getRuleIndex(self):
return LaTeXParser.RULE_atom
def atom(self):
localctx = LaTeXParser.AtomContext(self, self._ctx, self.state)
self.enterRule(localctx, 42, self.RULE_atom)
self._la = 0 # Token type
try:
self.state = 266
self._errHandler.sync(self)
token = self._input.LA(1)
if token in [LaTeXParser.LETTER, LaTeXParser.SYMBOL]:
self.enterOuterAlt(localctx, 1)
self.state = 259
_la = self._input.LA(1)
if not(_la==LaTeXParser.LETTER or _la==LaTeXParser.SYMBOL):
self._errHandler.recoverInline(self)
else:
self._errHandler.reportMatch(self)
self.consume()
self.state = 261
self._errHandler.sync(self)
la_ = self._interp.adaptivePredict(self._input,23,self._ctx)
if la_ == 1:
self.state = 260
self.subexpr()
pass
elif token in [LaTeXParser.NUMBER]:
self.enterOuterAlt(localctx, 2)
self.state = 263
self.match(LaTeXParser.NUMBER)
pass
elif token in [LaTeXParser.DIFFERENTIAL]:
self.enterOuterAlt(localctx, 3)
self.state = 264
self.match(LaTeXParser.DIFFERENTIAL)
pass
elif token in [LaTeXParser.CMD_MATHIT]:
self.enterOuterAlt(localctx, 4)
self.state = 265
self.mathit()
pass
else:
raise NoViableAltException(self)
except RecognitionException as re:
localctx.exception = re
self._errHandler.reportError(self, re)
self._errHandler.recover(self, re)
finally:
self.exitRule()
return localctx
class MathitContext(ParserRuleContext):
def __init__(self, parser, parent=None, invokingState=-1):
super(LaTeXParser.MathitContext, self).__init__(parent, invokingState)
self.parser = parser
def CMD_MATHIT(self):
return self.getToken(LaTeXParser.CMD_MATHIT, 0)
def L_BRACE(self):
return self.getToken(LaTeXParser.L_BRACE, 0)
def mathit_text(self):
return self.getTypedRuleContext(LaTeXParser.Mathit_textContext,0)
def R_BRACE(self):
return self.getToken(LaTeXParser.R_BRACE, 0)
def getRuleIndex(self):
return LaTeXParser.RULE_mathit
def mathit(self):
localctx = LaTeXParser.MathitContext(self, self._ctx, self.state)
self.enterRule(localctx, 44, self.RULE_mathit)
try:
self.enterOuterAlt(localctx, 1)
self.state = 268
self.match(LaTeXParser.CMD_MATHIT)
self.state = 269
self.match(LaTeXParser.L_BRACE)
self.state = 270
self.mathit_text()
self.state = 271
self.match(LaTeXParser.R_BRACE)
except RecognitionException as re:
localctx.exception = re
self._errHandler.reportError(self, re)
self._errHandler.recover(self, re)
finally:
self.exitRule()
return localctx
class Mathit_textContext(ParserRuleContext):
def __init__(self, parser, parent=None, invokingState=-1):
super(LaTeXParser.Mathit_textContext, self).__init__(parent, invokingState)
self.parser = parser
def LETTER(self, i=None):
if i is None:
return self.getTokens(LaTeXParser.LETTER)
else:
return self.getToken(LaTeXParser.LETTER, i)
def getRuleIndex(self):
return LaTeXParser.RULE_mathit_text
def mathit_text(self):
localctx = LaTeXParser.Mathit_textContext(self, self._ctx, self.state)
self.enterRule(localctx, 46, self.RULE_mathit_text)
self._la = 0 # Token type
try:
self.enterOuterAlt(localctx, 1)
self.state = 276
self._errHandler.sync(self)
_la = self._input.LA(1)
while _la==LaTeXParser.LETTER:
self.state = 273
self.match(LaTeXParser.LETTER)
self.state = 278
self._errHandler.sync(self)
_la = self._input.LA(1)
except RecognitionException as re:
localctx.exception = re
self._errHandler.reportError(self, re)
self._errHandler.recover(self, re)
finally:
self.exitRule()
return localctx
class FracContext(ParserRuleContext):
def __init__(self, parser, parent=None, invokingState=-1):
super(LaTeXParser.FracContext, self).__init__(parent, invokingState)
self.parser = parser
self.upper = None # ExprContext
self.lower = None # ExprContext
def CMD_FRAC(self):
return self.getToken(LaTeXParser.CMD_FRAC, 0)
def L_BRACE(self, i=None):
if i is None:
return self.getTokens(LaTeXParser.L_BRACE)
else:
return self.getToken(LaTeXParser.L_BRACE, i)
def R_BRACE(self, i=None):
if i is None:
return self.getTokens(LaTeXParser.R_BRACE)
else:
return self.getToken(LaTeXParser.R_BRACE, i)
def expr(self, i=None):
if i is None:
return self.getTypedRuleContexts(LaTeXParser.ExprContext)
else:
return self.getTypedRuleContext(LaTeXParser.ExprContext,i)
def getRuleIndex(self):
return LaTeXParser.RULE_frac
def frac(self):
localctx = LaTeXParser.FracContext(self, self._ctx, self.state)
self.enterRule(localctx, 48, self.RULE_frac)
try:
self.enterOuterAlt(localctx, 1)
self.state = 279
self.match(LaTeXParser.CMD_FRAC)
self.state = 280
self.match(LaTeXParser.L_BRACE)
self.state = 281
localctx.upper = self.expr()
self.state = 282
self.match(LaTeXParser.R_BRACE)
self.state = 283
self.match(LaTeXParser.L_BRACE)
self.state = 284
localctx.lower = self.expr()
self.state = 285
self.match(LaTeXParser.R_BRACE)
except RecognitionException as re:
localctx.exception = re
self._errHandler.reportError(self, re)
self._errHandler.recover(self, re)
finally:
self.exitRule()
return localctx
class BinomContext(ParserRuleContext):
def __init__(self, parser, parent=None, invokingState=-1):
super(LaTeXParser.BinomContext, self).__init__(parent, invokingState)
self.parser = parser
self.n = None # ExprContext
self.k = None # ExprContext
def L_BRACE(self, i=None):
if i is None:
return self.getTokens(LaTeXParser.L_BRACE)
else:
return self.getToken(LaTeXParser.L_BRACE, i)
def R_BRACE(self, i=None):
if i is None:
return self.getTokens(LaTeXParser.R_BRACE)
else:
return self.getToken(LaTeXParser.R_BRACE, i)
def CMD_BINOM(self):
return self.getToken(LaTeXParser.CMD_BINOM, 0)
def CMD_DBINOM(self):
return self.getToken(LaTeXParser.CMD_DBINOM, 0)
def CMD_TBINOM(self):
return self.getToken(LaTeXParser.CMD_TBINOM, 0)
def expr(self, i=None):
if i is None:
return self.getTypedRuleContexts(LaTeXParser.ExprContext)
else:
return self.getTypedRuleContext(LaTeXParser.ExprContext,i)
def getRuleIndex(self):
return LaTeXParser.RULE_binom
def binom(self):
localctx = LaTeXParser.BinomContext(self, self._ctx, self.state)
self.enterRule(localctx, 50, self.RULE_binom)
self._la = 0 # Token type
try:
self.enterOuterAlt(localctx, 1)
self.state = 287
_la = self._input.LA(1)
if not((((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << LaTeXParser.CMD_BINOM) | (1 << LaTeXParser.CMD_DBINOM) | (1 << LaTeXParser.CMD_TBINOM))) != 0)):
self._errHandler.recoverInline(self)
else:
self._errHandler.reportMatch(self)
self.consume()
self.state = 288
self.match(LaTeXParser.L_BRACE)
self.state = 289
localctx.n = self.expr()
self.state = 290
self.match(LaTeXParser.R_BRACE)
self.state = 291
self.match(LaTeXParser.L_BRACE)
self.state = 292
localctx.k = self.expr()
self.state = 293
self.match(LaTeXParser.R_BRACE)
except RecognitionException as re:
localctx.exception = re
self._errHandler.reportError(self, re)
self._errHandler.recover(self, re)
finally:
self.exitRule()
return localctx
class Func_normalContext(ParserRuleContext):
def __init__(self, parser, parent=None, invokingState=-1):
super(LaTeXParser.Func_normalContext, self).__init__(parent, invokingState)
self.parser = parser
def FUNC_LOG(self):
return self.getToken(LaTeXParser.FUNC_LOG, 0)
def FUNC_LN(self):
return self.getToken(LaTeXParser.FUNC_LN, 0)
def FUNC_SIN(self):
return self.getToken(LaTeXParser.FUNC_SIN, 0)
def FUNC_COS(self):
return self.getToken(LaTeXParser.FUNC_COS, 0)
def FUNC_TAN(self):
return self.getToken(LaTeXParser.FUNC_TAN, 0)
def FUNC_CSC(self):
return self.getToken(LaTeXParser.FUNC_CSC, 0)
def FUNC_SEC(self):
return self.getToken(LaTeXParser.FUNC_SEC, 0)
def FUNC_COT(self):
return self.getToken(LaTeXParser.FUNC_COT, 0)
def FUNC_ARCSIN(self):
return self.getToken(LaTeXParser.FUNC_ARCSIN, 0)
def FUNC_ARCCOS(self):
return self.getToken(LaTeXParser.FUNC_ARCCOS, 0)
def FUNC_ARCTAN(self):
return self.getToken(LaTeXParser.FUNC_ARCTAN, 0)
def FUNC_ARCCSC(self):
return self.getToken(LaTeXParser.FUNC_ARCCSC, 0)
def FUNC_ARCSEC(self):
return self.getToken(LaTeXParser.FUNC_ARCSEC, 0)
def FUNC_ARCCOT(self):
return self.getToken(LaTeXParser.FUNC_ARCCOT, 0)
def FUNC_SINH(self):
return self.getToken(LaTeXParser.FUNC_SINH, 0)
def FUNC_COSH(self):
return self.getToken(LaTeXParser.FUNC_COSH, 0)
def FUNC_TANH(self):
return self.getToken(LaTeXParser.FUNC_TANH, 0)
def FUNC_ARSINH(self):
return self.getToken(LaTeXParser.FUNC_ARSINH, 0)
def FUNC_ARCOSH(self):
return self.getToken(LaTeXParser.FUNC_ARCOSH, 0)
def FUNC_ARTANH(self):
return self.getToken(LaTeXParser.FUNC_ARTANH, 0)
def getRuleIndex(self):
return LaTeXParser.RULE_func_normal
def func_normal(self):
localctx = LaTeXParser.Func_normalContext(self, self._ctx, self.state)
self.enterRule(localctx, 52, self.RULE_func_normal)
self._la = 0 # Token type
try:
self.enterOuterAlt(localctx, 1)
self.state = 295
_la = self._input.LA(1)
if not((((_la) & ~0x3f) == 0 and ((1 << _la) & ((1 << LaTeXParser.FUNC_LOG) | (1 << LaTeXParser.FUNC_LN) | (1 << LaTeXParser.FUNC_SIN) | (1 << LaTeXParser.FUNC_COS) | (1 << LaTeXParser.FUNC_TAN) | (1 << LaTeXParser.FUNC_CSC) | (1 << LaTeXParser.FUNC_SEC) | (1 << LaTeXParser.FUNC_COT) | (1 << LaTeXParser.FUNC_ARCSIN) | (1 << LaTeXParser.FUNC_ARCCOS) | (1 << LaTeXParser.FUNC_ARCTAN) | (1 << LaTeXParser.FUNC_ARCCSC) | (1 << LaTeXParser.FUNC_ARCSEC) | (1 << LaTeXParser.FUNC_ARCCOT) | (1 << LaTeXParser.FUNC_SINH) | (1 << LaTeXParser.FUNC_COSH) | (1 << LaTeXParser.FUNC_TANH) | (1 << LaTeXParser.FUNC_ARSINH) | (1 << LaTeXParser.FUNC_ARCOSH) | (1 << LaTeXParser.FUNC_ARTANH))) != 0)):
self._errHandler.recoverInline(self)
else:
self._errHandler.reportMatch(self)
self.consume()
except RecognitionException as re:
localctx.exception = re
self._errHandler.reportError(self, re)
self._errHandler.recover(self, re)
finally:
self.exitRule()
return localctx
class FuncContext(ParserRuleContext):
def __init__(self, parser, parent=None, invokingState=-1):
super(LaTeXParser.FuncContext, self).__init__(parent, invokingState)
self.parser = parser
self.root = None # ExprContext
self.base = None # ExprContext
def func_normal(self):
return self.getTypedRuleContext(LaTeXParser.Func_normalContext,0)
def L_PAREN(self):
return self.getToken(LaTeXParser.L_PAREN, 0)
def func_arg(self):
return self.getTypedRuleContext(LaTeXParser.Func_argContext,0)
def R_PAREN(self):
return self.getToken(LaTeXParser.R_PAREN, 0)
def func_arg_noparens(self):
return self.getTypedRuleContext(LaTeXParser.Func_arg_noparensContext,0)
def subexpr(self):
return self.getTypedRuleContext(LaTeXParser.SubexprContext,0)
def supexpr(self):
return self.getTypedRuleContext(LaTeXParser.SupexprContext,0)
def args(self):
return self.getTypedRuleContext(LaTeXParser.ArgsContext,0)
def LETTER(self):
return self.getToken(LaTeXParser.LETTER, 0)
def SYMBOL(self):
return self.getToken(LaTeXParser.SYMBOL, 0)
def FUNC_INT(self):
return self.getToken(LaTeXParser.FUNC_INT, 0)
def DIFFERENTIAL(self):
return self.getToken(LaTeXParser.DIFFERENTIAL, 0)
def frac(self):
return self.getTypedRuleContext(LaTeXParser.FracContext,0)
def additive(self):
return self.getTypedRuleContext(LaTeXParser.AdditiveContext,0)
def FUNC_SQRT(self):
return self.getToken(LaTeXParser.FUNC_SQRT, 0)
def L_BRACE(self):
return self.getToken(LaTeXParser.L_BRACE, 0)
def R_BRACE(self):
return self.getToken(LaTeXParser.R_BRACE, 0)
def expr(self, i=None):
if i is None:
return self.getTypedRuleContexts(LaTeXParser.ExprContext)
else:
return self.getTypedRuleContext(LaTeXParser.ExprContext,i)
def L_BRACKET(self):
return self.getToken(LaTeXParser.L_BRACKET, 0)
def R_BRACKET(self):
return self.getToken(LaTeXParser.R_BRACKET, 0)
def mp(self):
return self.getTypedRuleContext(LaTeXParser.MpContext,0)
def FUNC_SUM(self):
return self.getToken(LaTeXParser.FUNC_SUM, 0)
def FUNC_PROD(self):
return self.getToken(LaTeXParser.FUNC_PROD, 0)
def subeq(self):
return self.getTypedRuleContext(LaTeXParser.SubeqContext,0)
def FUNC_LIM(self):
return self.getToken(LaTeXParser.FUNC_LIM, 0)
def limit_sub(self):
return self.getTypedRuleContext(LaTeXParser.Limit_subContext,0)
def getRuleIndex(self):
return LaTeXParser.RULE_func
def func(self):
localctx = LaTeXParser.FuncContext(self, self._ctx, self.state)
self.enterRule(localctx, 54, self.RULE_func)
self._la = 0 # Token type
try:
self.state = 370
self._errHandler.sync(self)
token = self._input.LA(1)
if token in [LaTeXParser.FUNC_LOG, LaTeXParser.FUNC_LN, LaTeXParser.FUNC_SIN, LaTeXParser.FUNC_COS, LaTeXParser.FUNC_TAN, LaTeXParser.FUNC_CSC, LaTeXParser.FUNC_SEC, LaTeXParser.FUNC_COT, LaTeXParser.FUNC_ARCSIN, LaTeXParser.FUNC_ARCCOS, LaTeXParser.FUNC_ARCTAN, LaTeXParser.FUNC_ARCCSC, LaTeXParser.FUNC_ARCSEC, LaTeXParser.FUNC_ARCCOT, LaTeXParser.FUNC_SINH, LaTeXParser.FUNC_COSH, LaTeXParser.FUNC_TANH, LaTeXParser.FUNC_ARSINH, LaTeXParser.FUNC_ARCOSH, LaTeXParser.FUNC_ARTANH]:
self.enterOuterAlt(localctx, 1)
self.state = 297
self.func_normal()
self.state = 310
self._errHandler.sync(self)
la_ = self._interp.adaptivePredict(self._input,30,self._ctx)
if la_ == 1:
self.state = 299
self._errHandler.sync(self)
_la = self._input.LA(1)
if _la==LaTeXParser.UNDERSCORE:
self.state = 298
self.subexpr()
self.state = 302
self._errHandler.sync(self)
_la = self._input.LA(1)
if _la==LaTeXParser.CARET:
self.state = 301
self.supexpr()
pass
elif la_ == 2:
self.state = 305
self._errHandler.sync(self)
_la = self._input.LA(1)
if _la==LaTeXParser.CARET:
self.state = 304
self.supexpr()
self.state = 308
self._errHandler.sync(self)
_la = self._input.LA(1)
if _la==LaTeXParser.UNDERSCORE:
self.state = 307
self.subexpr()
pass
self.state = 317
self._errHandler.sync(self)
la_ = self._interp.adaptivePredict(self._input,31,self._ctx)
if la_ == 1:
self.state = 312
self.match(LaTeXParser.L_PAREN)
self.state = 313
self.func_arg()
self.state = 314
self.match(LaTeXParser.R_PAREN)
pass
elif la_ == 2:
self.state = 316
self.func_arg_noparens()
pass
pass
elif token in [LaTeXParser.LETTER, LaTeXParser.SYMBOL]:
self.enterOuterAlt(localctx, 2)
self.state = 319
_la = self._input.LA(1)
if not(_la==LaTeXParser.LETTER or _la==LaTeXParser.SYMBOL):
self._errHandler.recoverInline(self)
else:
self._errHandler.reportMatch(self)
self.consume()
self.state = 321
self._errHandler.sync(self)
_la = self._input.LA(1)
if _la==LaTeXParser.UNDERSCORE:
self.state = 320
self.subexpr()
self.state = 323
self.match(LaTeXParser.L_PAREN)
self.state = 324
self.args()
self.state = 325
self.match(LaTeXParser.R_PAREN)
pass
elif token in [LaTeXParser.FUNC_INT]:
self.enterOuterAlt(localctx, 3)
self.state = 327
self.match(LaTeXParser.FUNC_INT)
self.state = 334
self._errHandler.sync(self)
token = self._input.LA(1)
if token in [LaTeXParser.UNDERSCORE]:
self.state = 328
self.subexpr()
self.state = 329
self.supexpr()
pass
elif token in [LaTeXParser.CARET]:
self.state = 331
self.supexpr()
self.state = 332
self.subexpr()
pass
elif token in [LaTeXParser.ADD, LaTeXParser.SUB, LaTeXParser.L_PAREN, LaTeXParser.L_BRACE, LaTeXParser.L_BRACKET, LaTeXParser.BAR, LaTeXParser.FUNC_LIM, LaTeXParser.FUNC_INT, LaTeXParser.FUNC_SUM, LaTeXParser.FUNC_PROD, LaTeXParser.FUNC_LOG, LaTeXParser.FUNC_LN, LaTeXParser.FUNC_SIN, LaTeXParser.FUNC_COS, LaTeXParser.FUNC_TAN, LaTeXParser.FUNC_CSC, LaTeXParser.FUNC_SEC, LaTeXParser.FUNC_COT, LaTeXParser.FUNC_ARCSIN, LaTeXParser.FUNC_ARCCOS, LaTeXParser.FUNC_ARCTAN, LaTeXParser.FUNC_ARCCSC, LaTeXParser.FUNC_ARCSEC, LaTeXParser.FUNC_ARCCOT, LaTeXParser.FUNC_SINH, LaTeXParser.FUNC_COSH, LaTeXParser.FUNC_TANH, LaTeXParser.FUNC_ARSINH, LaTeXParser.FUNC_ARCOSH, LaTeXParser.FUNC_ARTANH, LaTeXParser.FUNC_SQRT, LaTeXParser.CMD_FRAC, LaTeXParser.CMD_BINOM, LaTeXParser.CMD_DBINOM, LaTeXParser.CMD_TBINOM, LaTeXParser.CMD_MATHIT, LaTeXParser.DIFFERENTIAL, LaTeXParser.LETTER, LaTeXParser.NUMBER, LaTeXParser.SYMBOL]:
pass
else:
pass
self.state = 342
self._errHandler.sync(self)
la_ = self._interp.adaptivePredict(self._input,35,self._ctx)
if la_ == 1:
self.state = 337
self._errHandler.sync(self)
la_ = self._interp.adaptivePredict(self._input,34,self._ctx)
if la_ == 1:
self.state = 336
self.additive(0)
self.state = 339
self.match(LaTeXParser.DIFFERENTIAL)
pass
elif la_ == 2:
self.state = 340
self.frac()
pass
elif la_ == 3:
self.state = 341
self.additive(0)
pass
pass
elif token in [LaTeXParser.FUNC_SQRT]:
self.enterOuterAlt(localctx, 4)
self.state = 344
self.match(LaTeXParser.FUNC_SQRT)
self.state = 349
self._errHandler.sync(self)
_la = self._input.LA(1)
if _la==LaTeXParser.L_BRACKET:
self.state = 345
self.match(LaTeXParser.L_BRACKET)
self.state = 346
localctx.root = self.expr()
self.state = 347
self.match(LaTeXParser.R_BRACKET)
self.state = 351
self.match(LaTeXParser.L_BRACE)
self.state = 352
localctx.base = self.expr()
self.state = 353
self.match(LaTeXParser.R_BRACE)
pass
elif token in [LaTeXParser.FUNC_SUM, LaTeXParser.FUNC_PROD]:
self.enterOuterAlt(localctx, 5)
self.state = 355
_la = self._input.LA(1)
if not(_la==LaTeXParser.FUNC_SUM or _la==LaTeXParser.FUNC_PROD):
self._errHandler.recoverInline(self)
else:
self._errHandler.reportMatch(self)
self.consume()
self.state = 362
self._errHandler.sync(self)
token = self._input.LA(1)
if token in [LaTeXParser.UNDERSCORE]:
self.state = 356
self.subeq()
self.state = 357
self.supexpr()
pass
elif token in [LaTeXParser.CARET]:
self.state = 359
self.supexpr()
self.state = 360
self.subeq()
pass
else:
raise NoViableAltException(self)
self.state = 364
self.mp(0)
pass
elif token in [LaTeXParser.FUNC_LIM]:
self.enterOuterAlt(localctx, 6)
self.state = 366
self.match(LaTeXParser.FUNC_LIM)
self.state = 367
self.limit_sub()
self.state = 368
self.mp(0)
pass
else:
raise NoViableAltException(self)
except RecognitionException as re:
localctx.exception = re
self._errHandler.reportError(self, re)
self._errHandler.recover(self, re)
finally:
self.exitRule()
return localctx
class ArgsContext(ParserRuleContext):
def __init__(self, parser, parent=None, invokingState=-1):
super(LaTeXParser.ArgsContext, self).__init__(parent, invokingState)
self.parser = parser
def expr(self):
return self.getTypedRuleContext(LaTeXParser.ExprContext,0)
def args(self):
return self.getTypedRuleContext(LaTeXParser.ArgsContext,0)
def getRuleIndex(self):
return LaTeXParser.RULE_args
def args(self):
localctx = LaTeXParser.ArgsContext(self, self._ctx, self.state)
self.enterRule(localctx, 56, self.RULE_args)
try:
self.state = 377
self._errHandler.sync(self)
la_ = self._interp.adaptivePredict(self._input,39,self._ctx)
if la_ == 1:
self.enterOuterAlt(localctx, 1)
self.state = 372
self.expr()
self.state = 373
self.match(LaTeXParser.T__0)
self.state = 374
self.args()
pass
elif la_ == 2:
self.enterOuterAlt(localctx, 2)
self.state = 376
self.expr()
pass
except RecognitionException as re:
localctx.exception = re
self._errHandler.reportError(self, re)
self._errHandler.recover(self, re)
finally:
self.exitRule()
return localctx
class Limit_subContext(ParserRuleContext):
def __init__(self, parser, parent=None, invokingState=-1):
super(LaTeXParser.Limit_subContext, self).__init__(parent, invokingState)
self.parser = parser
def UNDERSCORE(self):
return self.getToken(LaTeXParser.UNDERSCORE, 0)
def L_BRACE(self, i=None):
if i is None:
return self.getTokens(LaTeXParser.L_BRACE)
else:
return self.getToken(LaTeXParser.L_BRACE, i)
def LIM_APPROACH_SYM(self):
return self.getToken(LaTeXParser.LIM_APPROACH_SYM, 0)
def expr(self):
return self.getTypedRuleContext(LaTeXParser.ExprContext,0)
def R_BRACE(self, i=None):
if i is None:
return self.getTokens(LaTeXParser.R_BRACE)
else:
return self.getToken(LaTeXParser.R_BRACE, i)
def LETTER(self):
return self.getToken(LaTeXParser.LETTER, 0)
def SYMBOL(self):
return self.getToken(LaTeXParser.SYMBOL, 0)
def CARET(self):
return self.getToken(LaTeXParser.CARET, 0)
def ADD(self):
return self.getToken(LaTeXParser.ADD, 0)
def SUB(self):
return self.getToken(LaTeXParser.SUB, 0)
def getRuleIndex(self):
return LaTeXParser.RULE_limit_sub
def limit_sub(self):
localctx = LaTeXParser.Limit_subContext(self, self._ctx, self.state)
self.enterRule(localctx, 58, self.RULE_limit_sub)
self._la = 0 # Token type
try:
self.enterOuterAlt(localctx, 1)
self.state = 379
self.match(LaTeXParser.UNDERSCORE)
self.state = 380
self.match(LaTeXParser.L_BRACE)
self.state = 381
_la = self._input.LA(1)
if not(_la==LaTeXParser.LETTER or _la==LaTeXParser.SYMBOL):
self._errHandler.recoverInline(self)
else:
self._errHandler.reportMatch(self)
self.consume()
self.state = 382
self.match(LaTeXParser.LIM_APPROACH_SYM)
self.state = 383
self.expr()
self.state = 388
self._errHandler.sync(self)
_la = self._input.LA(1)
if _la==LaTeXParser.CARET:
self.state = 384
self.match(LaTeXParser.CARET)
self.state = 385
self.match(LaTeXParser.L_BRACE)
self.state = 386
_la = self._input.LA(1)
if not(_la==LaTeXParser.ADD or _la==LaTeXParser.SUB):
self._errHandler.recoverInline(self)
else:
self._errHandler.reportMatch(self)
self.consume()
self.state = 387
self.match(LaTeXParser.R_BRACE)
self.state = 390
self.match(LaTeXParser.R_BRACE)
except RecognitionException as re:
localctx.exception = re
self._errHandler.reportError(self, re)
self._errHandler.recover(self, re)
finally:
self.exitRule()
return localctx
class Func_argContext(ParserRuleContext):
def __init__(self, parser, parent=None, invokingState=-1):
super(LaTeXParser.Func_argContext, self).__init__(parent, invokingState)
self.parser = parser
def expr(self):
return self.getTypedRuleContext(LaTeXParser.ExprContext,0)
def func_arg(self):
return self.getTypedRuleContext(LaTeXParser.Func_argContext,0)
def getRuleIndex(self):
return LaTeXParser.RULE_func_arg
def func_arg(self):
localctx = LaTeXParser.Func_argContext(self, self._ctx, self.state)
self.enterRule(localctx, 60, self.RULE_func_arg)
try:
self.state = 397
self._errHandler.sync(self)
la_ = self._interp.adaptivePredict(self._input,41,self._ctx)
if la_ == 1:
self.enterOuterAlt(localctx, 1)
self.state = 392
self.expr()
pass
elif la_ == 2:
self.enterOuterAlt(localctx, 2)
self.state = 393
self.expr()
self.state = 394
self.match(LaTeXParser.T__0)
self.state = 395
self.func_arg()
pass
except RecognitionException as re:
localctx.exception = re
self._errHandler.reportError(self, re)
self._errHandler.recover(self, re)
finally:
self.exitRule()
return localctx
class Func_arg_noparensContext(ParserRuleContext):
def __init__(self, parser, parent=None, invokingState=-1):
super(LaTeXParser.Func_arg_noparensContext, self).__init__(parent, invokingState)
self.parser = parser
def mp_nofunc(self):
return self.getTypedRuleContext(LaTeXParser.Mp_nofuncContext,0)
def getRuleIndex(self):
return LaTeXParser.RULE_func_arg_noparens
def func_arg_noparens(self):
localctx = LaTeXParser.Func_arg_noparensContext(self, self._ctx, self.state)
self.enterRule(localctx, 62, self.RULE_func_arg_noparens)
try:
self.enterOuterAlt(localctx, 1)
self.state = 399
self.mp_nofunc(0)
except RecognitionException as re:
localctx.exception = re
self._errHandler.reportError(self, re)
self._errHandler.recover(self, re)
finally:
self.exitRule()
return localctx
class SubexprContext(ParserRuleContext):
def __init__(self, parser, parent=None, invokingState=-1):
super(LaTeXParser.SubexprContext, self).__init__(parent, invokingState)
self.parser = parser
def UNDERSCORE(self):
return self.getToken(LaTeXParser.UNDERSCORE, 0)
def atom(self):
return self.getTypedRuleContext(LaTeXParser.AtomContext,0)
def L_BRACE(self):
return self.getToken(LaTeXParser.L_BRACE, 0)
def expr(self):
return self.getTypedRuleContext(LaTeXParser.ExprContext,0)
def R_BRACE(self):
return self.getToken(LaTeXParser.R_BRACE, 0)
def getRuleIndex(self):
return LaTeXParser.RULE_subexpr
def subexpr(self):
localctx = LaTeXParser.SubexprContext(self, self._ctx, self.state)
self.enterRule(localctx, 64, self.RULE_subexpr)
try:
self.enterOuterAlt(localctx, 1)
self.state = 401
self.match(LaTeXParser.UNDERSCORE)
self.state = 407
self._errHandler.sync(self)
token = self._input.LA(1)
if token in [LaTeXParser.CMD_MATHIT, LaTeXParser.DIFFERENTIAL, LaTeXParser.LETTER, LaTeXParser.NUMBER, LaTeXParser.SYMBOL]:
self.state = 402
self.atom()
pass
elif token in [LaTeXParser.L_BRACE]:
self.state = 403
self.match(LaTeXParser.L_BRACE)
self.state = 404
self.expr()
self.state = 405
self.match(LaTeXParser.R_BRACE)
pass
else:
raise NoViableAltException(self)
except RecognitionException as re:
localctx.exception = re
self._errHandler.reportError(self, re)
self._errHandler.recover(self, re)
finally:
self.exitRule()
return localctx
class SupexprContext(ParserRuleContext):
def __init__(self, parser, parent=None, invokingState=-1):
super(LaTeXParser.SupexprContext, self).__init__(parent, invokingState)
self.parser = parser
def CARET(self):
return self.getToken(LaTeXParser.CARET, 0)
def atom(self):
return self.getTypedRuleContext(LaTeXParser.AtomContext,0)
def L_BRACE(self):
return self.getToken(LaTeXParser.L_BRACE, 0)
def expr(self):
return self.getTypedRuleContext(LaTeXParser.ExprContext,0)
def R_BRACE(self):
return self.getToken(LaTeXParser.R_BRACE, 0)
def getRuleIndex(self):
return LaTeXParser.RULE_supexpr
def supexpr(self):
localctx = LaTeXParser.SupexprContext(self, self._ctx, self.state)
self.enterRule(localctx, 66, self.RULE_supexpr)
try:
self.enterOuterAlt(localctx, 1)
self.state = 409
self.match(LaTeXParser.CARET)
self.state = 415
self._errHandler.sync(self)
token = self._input.LA(1)
if token in [LaTeXParser.CMD_MATHIT, LaTeXParser.DIFFERENTIAL, LaTeXParser.LETTER, LaTeXParser.NUMBER, LaTeXParser.SYMBOL]:
self.state = 410
self.atom()
pass
elif token in [LaTeXParser.L_BRACE]:
self.state = 411
self.match(LaTeXParser.L_BRACE)
self.state = 412
self.expr()
self.state = 413
self.match(LaTeXParser.R_BRACE)
pass
else:
raise NoViableAltException(self)
except RecognitionException as re:
localctx.exception = re
self._errHandler.reportError(self, re)
self._errHandler.recover(self, re)
finally:
self.exitRule()
return localctx
class SubeqContext(ParserRuleContext):
def __init__(self, parser, parent=None, invokingState=-1):
super(LaTeXParser.SubeqContext, self).__init__(parent, invokingState)
self.parser = parser
def UNDERSCORE(self):
return self.getToken(LaTeXParser.UNDERSCORE, 0)
def L_BRACE(self):
return self.getToken(LaTeXParser.L_BRACE, 0)
def equality(self):
return self.getTypedRuleContext(LaTeXParser.EqualityContext,0)
def R_BRACE(self):
return self.getToken(LaTeXParser.R_BRACE, 0)
def getRuleIndex(self):
return LaTeXParser.RULE_subeq
def subeq(self):
localctx = LaTeXParser.SubeqContext(self, self._ctx, self.state)
self.enterRule(localctx, 68, self.RULE_subeq)
try:
self.enterOuterAlt(localctx, 1)
self.state = 417
self.match(LaTeXParser.UNDERSCORE)
self.state = 418
self.match(LaTeXParser.L_BRACE)
self.state = 419
self.equality()
self.state = 420
self.match(LaTeXParser.R_BRACE)
except RecognitionException as re:
localctx.exception = re
self._errHandler.reportError(self, re)
self._errHandler.recover(self, re)
finally:
self.exitRule()
return localctx
class SupeqContext(ParserRuleContext):
def __init__(self, parser, parent=None, invokingState=-1):
super(LaTeXParser.SupeqContext, self).__init__(parent, invokingState)
self.parser = parser
def UNDERSCORE(self):
return self.getToken(LaTeXParser.UNDERSCORE, 0)
def L_BRACE(self):
return self.getToken(LaTeXParser.L_BRACE, 0)
def equality(self):
return self.getTypedRuleContext(LaTeXParser.EqualityContext,0)
def R_BRACE(self):
return self.getToken(LaTeXParser.R_BRACE, 0)
def getRuleIndex(self):
return LaTeXParser.RULE_supeq
def supeq(self):
localctx = LaTeXParser.SupeqContext(self, self._ctx, self.state)
self.enterRule(localctx, 70, self.RULE_supeq)
try:
self.enterOuterAlt(localctx, 1)
self.state = 422
self.match(LaTeXParser.UNDERSCORE)
self.state = 423
self.match(LaTeXParser.L_BRACE)
self.state = 424
self.equality()
self.state = 425
self.match(LaTeXParser.R_BRACE)
except RecognitionException as re:
localctx.exception = re
self._errHandler.reportError(self, re)
self._errHandler.recover(self, re)
finally:
self.exitRule()
return localctx
def sempred(self, localctx, ruleIndex, predIndex):
if self._predicates == None:
self._predicates = dict()
self._predicates[1] = self.relation_sempred
self._predicates[4] = self.additive_sempred
self._predicates[5] = self.mp_sempred
self._predicates[6] = self.mp_nofunc_sempred
self._predicates[15] = self.exp_sempred
self._predicates[16] = self.exp_nofunc_sempred
pred = self._predicates.get(ruleIndex, None)
if pred is None:
raise Exception("No predicate with index:" + str(ruleIndex))
else:
return pred(localctx, predIndex)
def relation_sempred(self, localctx, predIndex):
if predIndex == 0:
return self.precpred(self._ctx, 2)
def additive_sempred(self, localctx, predIndex):
if predIndex == 1:
return self.precpred(self._ctx, 2)
def mp_sempred(self, localctx, predIndex):
if predIndex == 2:
return self.precpred(self._ctx, 2)
def mp_nofunc_sempred(self, localctx, predIndex):
if predIndex == 3:
return self.precpred(self._ctx, 2)
def exp_sempred(self, localctx, predIndex):
if predIndex == 4:
return self.precpred(self._ctx, 2)
def exp_nofunc_sempred(self, localctx, predIndex):
if predIndex == 5:
return self.precpred(self._ctx, 2)
|
a4b920a1985dd4bf3fac8fcc6b93a9132f70886a315b44a0228dab4878311b6a | """
This module can be used to solve 2D beam bending problems with
singularity functions in mechanics.
"""
from __future__ import print_function, division
from sympy.core import S, Symbol, diff, symbols
from sympy.solvers import linsolve
from sympy.printing import sstr
from sympy.functions import SingularityFunction, Piecewise, factorial
from sympy.core import sympify
from sympy.integrals import integrate
from sympy.series import limit
from sympy.plotting import plot, PlotGrid
from sympy.geometry.entity import GeometryEntity
from sympy.external import import_module
from sympy import lambdify, Add
from sympy.core.compatibility import iterable
from sympy.utilities.decorator import doctest_depends_on
numpy = import_module('numpy', import_kwargs={'fromlist':['arange']})
class Beam(object):
"""
A Beam is a structural element that is capable of withstanding load
primarily by resisting against bending. Beams are characterized by
their cross sectional profile(Second moment of area), their length
and their material.
.. note::
While solving a beam bending problem, a user should choose its
own sign convention and should stick to it. The results will
automatically follow the chosen sign convention.
Examples
========
There is a beam of length 4 meters. A constant distributed load of 6 N/m
is applied from half of the beam till the end. There are two simple supports
below the beam, one at the starting point and another at the ending point
of the beam. The deflection of the beam at the end is restricted.
Using the sign convention of downwards forces being positive.
>>> from sympy.physics.continuum_mechanics.beam import Beam
>>> from sympy import symbols, Piecewise
>>> E, I = symbols('E, I')
>>> R1, R2 = symbols('R1, R2')
>>> b = Beam(4, E, I)
>>> b.apply_load(R1, 0, -1)
>>> b.apply_load(6, 2, 0)
>>> b.apply_load(R2, 4, -1)
>>> b.bc_deflection = [(0, 0), (4, 0)]
>>> b.boundary_conditions
{'deflection': [(0, 0), (4, 0)], 'slope': []}
>>> b.load
R1*SingularityFunction(x, 0, -1) + R2*SingularityFunction(x, 4, -1) + 6*SingularityFunction(x, 2, 0)
>>> b.solve_for_reaction_loads(R1, R2)
>>> b.load
-3*SingularityFunction(x, 0, -1) + 6*SingularityFunction(x, 2, 0) - 9*SingularityFunction(x, 4, -1)
>>> b.shear_force()
-3*SingularityFunction(x, 0, 0) + 6*SingularityFunction(x, 2, 1) - 9*SingularityFunction(x, 4, 0)
>>> b.bending_moment()
-3*SingularityFunction(x, 0, 1) + 3*SingularityFunction(x, 2, 2) - 9*SingularityFunction(x, 4, 1)
>>> b.slope()
(-3*SingularityFunction(x, 0, 2)/2 + SingularityFunction(x, 2, 3) - 9*SingularityFunction(x, 4, 2)/2 + 7)/(E*I)
>>> b.deflection()
(7*x - SingularityFunction(x, 0, 3)/2 + SingularityFunction(x, 2, 4)/4 - 3*SingularityFunction(x, 4, 3)/2)/(E*I)
>>> b.deflection().rewrite(Piecewise)
(7*x - Piecewise((x**3, x > 0), (0, True))/2
- 3*Piecewise(((x - 4)**3, x - 4 > 0), (0, True))/2
+ Piecewise(((x - 2)**4, x - 2 > 0), (0, True))/4)/(E*I)
"""
def __init__(self, length, elastic_modulus, second_moment, area=Symbol('A'), variable=Symbol('x'), base_char='C'):
"""Initializes the class.
Parameters
==========
length : Sympifyable
A Symbol or value representing the Beam's length.
elastic_modulus : Sympifyable
A SymPy expression representing the Beam's Modulus of Elasticity.
It is a measure of the stiffness of the Beam material. It can
also be a continuous function of position along the beam.
second_moment : Sympifyable or Geometry object
Describes the cross-section of the beam via a SymPy expression
representing the Beam's second moment of area. It is a geometrical
property of an area which reflects how its points are distributed
with respect to its neutral axis. It can also be a continuous
function of position along the beam. Alternatively ``second_moment``
can be a shape object such as a ``Polygon`` from the geometry module
representing the shape of the cross-section of the beam. In such cases,
it is assumed that the x-axis of the shape object is aligned with the
bending axis of the beam. The second moment of area will be computed
from the shape object internally.
area : Symbol/float
Represents the cross-section area of beam
variable : Symbol, optional
A Symbol object that will be used as the variable along the beam
while representing the load, shear, moment, slope and deflection
curve. By default, it is set to ``Symbol('x')``.
base_char : String, optional
A String that will be used as base character to generate sequential
symbols for integration constants in cases where boundary conditions
are not sufficient to solve them.
"""
self.length = length
self.elastic_modulus = elastic_modulus
if isinstance(second_moment, GeometryEntity):
self.cross_section = second_moment
else:
self.cross_section = None
self.second_moment = second_moment
self.variable = variable
self._base_char = base_char
self._boundary_conditions = {'deflection': [], 'slope': []}
self._load = 0
self._area = area
self._applied_supports = []
self._support_as_loads = []
self._applied_loads = []
self._reaction_loads = {}
self._composite_type = None
self._hinge_position = None
def __str__(self):
shape_description = self._cross_section if self._cross_section else self._second_moment
str_sol = 'Beam({}, {}, {})'.format(sstr(self._length), sstr(self._elastic_modulus), sstr(shape_description))
return str_sol
@property
def reaction_loads(self):
""" Returns the reaction forces in a dictionary."""
return self._reaction_loads
@property
def length(self):
"""Length of the Beam."""
return self._length
@length.setter
def length(self, l):
self._length = sympify(l)
@property
def area(self):
"""Cross-sectional area of the Beam. """
return self._area
@area.setter
def area(self, a):
self._area = sympify(a)
@property
def variable(self):
"""
A symbol that can be used as a variable along the length of the beam
while representing load distribution, shear force curve, bending
moment, slope curve and the deflection curve. By default, it is set
to ``Symbol('x')``, but this property is mutable.
Examples
========
>>> from sympy.physics.continuum_mechanics.beam import Beam
>>> from sympy import symbols
>>> E, I, A = symbols('E, I, A')
>>> x, y, z = symbols('x, y, z')
>>> b = Beam(4, E, I)
>>> b.variable
x
>>> b.variable = y
>>> b.variable
y
>>> b = Beam(4, E, I, A, z)
>>> b.variable
z
"""
return self._variable
@variable.setter
def variable(self, v):
if isinstance(v, Symbol):
self._variable = v
else:
raise TypeError("""The variable should be a Symbol object.""")
@property
def elastic_modulus(self):
"""Young's Modulus of the Beam. """
return self._elastic_modulus
@elastic_modulus.setter
def elastic_modulus(self, e):
self._elastic_modulus = sympify(e)
@property
def second_moment(self):
"""Second moment of area of the Beam. """
return self._second_moment
@second_moment.setter
def second_moment(self, i):
self._cross_section = None
if isinstance(i, GeometryEntity):
raise ValueError("To update cross-section geometry use `cross_section` attribute")
else:
self._second_moment = sympify(i)
@property
def cross_section(self):
"""Cross-section of the beam"""
return self._cross_section
@cross_section.setter
def cross_section(self, s):
if s:
self._second_moment = s.second_moment_of_area()[0]
self._cross_section = s
@property
def boundary_conditions(self):
"""
Returns a dictionary of boundary conditions applied on the beam.
The dictionary has three keywords namely moment, slope and deflection.
The value of each keyword is a list of tuple, where each tuple
contains location and value of a boundary condition in the format
(location, value).
Examples
========
There is a beam of length 4 meters. The bending moment at 0 should be 4
and at 4 it should be 0. The slope of the beam should be 1 at 0. The
deflection should be 2 at 0.
>>> from sympy.physics.continuum_mechanics.beam import Beam
>>> from sympy import symbols
>>> E, I = symbols('E, I')
>>> b = Beam(4, E, I)
>>> b.bc_deflection = [(0, 2)]
>>> b.bc_slope = [(0, 1)]
>>> b.boundary_conditions
{'deflection': [(0, 2)], 'slope': [(0, 1)]}
Here the deflection of the beam should be ``2`` at ``0``.
Similarly, the slope of the beam should be ``1`` at ``0``.
"""
return self._boundary_conditions
@property
def bc_slope(self):
return self._boundary_conditions['slope']
@bc_slope.setter
def bc_slope(self, s_bcs):
self._boundary_conditions['slope'] = s_bcs
@property
def bc_deflection(self):
return self._boundary_conditions['deflection']
@bc_deflection.setter
def bc_deflection(self, d_bcs):
self._boundary_conditions['deflection'] = d_bcs
def join(self, beam, via="fixed"):
"""
This method joins two beams to make a new composite beam system.
Passed Beam class instance is attached to the right end of calling
object. This method can be used to form beams having Discontinuous
values of Elastic modulus or Second moment.
Parameters
==========
beam : Beam class object
The Beam object which would be connected to the right of calling
object.
via : String
States the way two Beam object would get connected
- For axially fixed Beams, via="fixed"
- For Beams connected via hinge, via="hinge"
Examples
========
There is a cantilever beam of length 4 meters. For first 2 meters
its moment of inertia is `1.5*I` and `I` for the other end.
A pointload of magnitude 4 N is applied from the top at its free end.
>>> from sympy.physics.continuum_mechanics.beam import Beam
>>> from sympy import symbols
>>> E, I = symbols('E, I')
>>> R1, R2 = symbols('R1, R2')
>>> b1 = Beam(2, E, 1.5*I)
>>> b2 = Beam(2, E, I)
>>> b = b1.join(b2, "fixed")
>>> b.apply_load(20, 4, -1)
>>> b.apply_load(R1, 0, -1)
>>> b.apply_load(R2, 0, -2)
>>> b.bc_slope = [(0, 0)]
>>> b.bc_deflection = [(0, 0)]
>>> b.solve_for_reaction_loads(R1, R2)
>>> b.load
80*SingularityFunction(x, 0, -2) - 20*SingularityFunction(x, 0, -1) + 20*SingularityFunction(x, 4, -1)
>>> b.slope()
(((80*SingularityFunction(x, 0, 1) - 10*SingularityFunction(x, 0, 2) + 10*SingularityFunction(x, 4, 2))/I - 120/I)/E + 80.0/(E*I))*SingularityFunction(x, 2, 0)
+ 0.666666666666667*(80*SingularityFunction(x, 0, 1) - 10*SingularityFunction(x, 0, 2) + 10*SingularityFunction(x, 4, 2))*SingularityFunction(x, 0, 0)/(E*I)
- 0.666666666666667*(80*SingularityFunction(x, 0, 1) - 10*SingularityFunction(x, 0, 2) + 10*SingularityFunction(x, 4, 2))*SingularityFunction(x, 2, 0)/(E*I)
"""
x = self.variable
E = self.elastic_modulus
new_length = self.length + beam.length
if self.second_moment != beam.second_moment:
new_second_moment = Piecewise((self.second_moment, x<=self.length),
(beam.second_moment, x<=new_length))
else:
new_second_moment = self.second_moment
if via == "fixed":
new_beam = Beam(new_length, E, new_second_moment, x)
new_beam._composite_type = "fixed"
return new_beam
if via == "hinge":
new_beam = Beam(new_length, E, new_second_moment, x)
new_beam._composite_type = "hinge"
new_beam._hinge_position = self.length
return new_beam
def apply_support(self, loc, type="fixed"):
"""
This method applies support to a particular beam object.
Parameters
==========
loc : Sympifyable
Location of point at which support is applied.
type : String
Determines type of Beam support applied. To apply support structure
with
- zero degree of freedom, type = "fixed"
- one degree of freedom, type = "pin"
- two degrees of freedom, type = "roller"
Examples
========
There is a beam of length 30 meters. A moment of magnitude 120 Nm is
applied in the clockwise direction at the end of the beam. A pointload
of magnitude 8 N is applied from the top of the beam at the starting
point. There are two simple supports below the beam. One at the end
and another one at a distance of 10 meters from the start. The
deflection is restricted at both the supports.
Using the sign convention of upward forces and clockwise moment
being positive.
>>> from sympy.physics.continuum_mechanics.beam import Beam
>>> from sympy import symbols
>>> E, I = symbols('E, I')
>>> b = Beam(30, E, I)
>>> b.apply_support(10, 'roller')
>>> b.apply_support(30, 'roller')
>>> b.apply_load(-8, 0, -1)
>>> b.apply_load(120, 30, -2)
>>> R_10, R_30 = symbols('R_10, R_30')
>>> b.solve_for_reaction_loads(R_10, R_30)
>>> b.load
-8*SingularityFunction(x, 0, -1) + 6*SingularityFunction(x, 10, -1)
+ 120*SingularityFunction(x, 30, -2) + 2*SingularityFunction(x, 30, -1)
>>> b.slope()
(-4*SingularityFunction(x, 0, 2) + 3*SingularityFunction(x, 10, 2)
+ 120*SingularityFunction(x, 30, 1) + SingularityFunction(x, 30, 2) + 4000/3)/(E*I)
"""
loc = sympify(loc)
self._applied_supports.append((loc, type))
if type == "pin" or type == "roller":
reaction_load = Symbol('R_'+str(loc))
self.apply_load(reaction_load, loc, -1)
self.bc_deflection.append((loc, 0))
else:
reaction_load = Symbol('R_'+str(loc))
reaction_moment = Symbol('M_'+str(loc))
self.apply_load(reaction_load, loc, -1)
self.apply_load(reaction_moment, loc, -2)
self.bc_deflection.append((loc, 0))
self.bc_slope.append((loc, 0))
self._support_as_loads.append((reaction_moment, loc, -2, None))
self._support_as_loads.append((reaction_load, loc, -1, None))
def apply_load(self, value, start, order, end=None):
"""
This method adds up the loads given to a particular beam object.
Parameters
==========
value : Sympifyable
The value inserted should have the units [Force/(Distance**(n+1)]
where n is the order of applied load.
Units for applied loads:
- For moments, unit = kN*m
- For point loads, unit = kN
- For constant distributed load, unit = kN/m
- For ramp loads, unit = kN/m/m
- For parabolic ramp loads, unit = kN/m/m/m
- ... so on.
start : Sympifyable
The starting point of the applied load. For point moments and
point forces this is the location of application.
order : Integer
The order of the applied load.
- For moments, order = -2
- For point loads, order =-1
- For constant distributed load, order = 0
- For ramp loads, order = 1
- For parabolic ramp loads, order = 2
- ... so on.
end : Sympifyable, optional
An optional argument that can be used if the load has an end point
within the length of the beam.
Examples
========
There is a beam of length 4 meters. A moment of magnitude 3 Nm is
applied in the clockwise direction at the starting point of the beam.
A point load of magnitude 4 N is applied from the top of the beam at
2 meters from the starting point and a parabolic ramp load of magnitude
2 N/m is applied below the beam starting from 2 meters to 3 meters
away from the starting point of the beam.
>>> from sympy.physics.continuum_mechanics.beam import Beam
>>> from sympy import symbols
>>> E, I = symbols('E, I')
>>> b = Beam(4, E, I)
>>> b.apply_load(-3, 0, -2)
>>> b.apply_load(4, 2, -1)
>>> b.apply_load(-2, 2, 2, end=3)
>>> b.load
-3*SingularityFunction(x, 0, -2) + 4*SingularityFunction(x, 2, -1) - 2*SingularityFunction(x, 2, 2) + 2*SingularityFunction(x, 3, 0) + 4*SingularityFunction(x, 3, 1) + 2*SingularityFunction(x, 3, 2)
"""
x = self.variable
value = sympify(value)
start = sympify(start)
order = sympify(order)
self._applied_loads.append((value, start, order, end))
self._load += value*SingularityFunction(x, start, order)
if end:
if order.is_negative:
msg = ("If 'end' is provided the 'order' of the load cannot "
"be negative, i.e. 'end' is only valid for distributed "
"loads.")
raise ValueError(msg)
# NOTE : A Taylor series can be used to define the summation of
# singularity functions that subtract from the load past the end
# point such that it evaluates to zero past 'end'.
f = value*x**order
for i in range(0, order + 1):
self._load -= (f.diff(x, i).subs(x, end - start) *
SingularityFunction(x, end, i)/factorial(i))
def remove_load(self, value, start, order, end=None):
"""
This method removes a particular load present on the beam object.
Returns a ValueError if the load passed as an argument is not
present on the beam.
Parameters
==========
value : Sympifyable
The magnitude of an applied load.
start : Sympifyable
The starting point of the applied load. For point moments and
point forces this is the location of application.
order : Integer
The order of the applied load.
- For moments, order= -2
- For point loads, order=-1
- For constant distributed load, order=0
- For ramp loads, order=1
- For parabolic ramp loads, order=2
- ... so on.
end : Sympifyable, optional
An optional argument that can be used if the load has an end point
within the length of the beam.
Examples
========
There is a beam of length 4 meters. A moment of magnitude 3 Nm is
applied in the clockwise direction at the starting point of the beam.
A pointload of magnitude 4 N is applied from the top of the beam at
2 meters from the starting point and a parabolic ramp load of magnitude
2 N/m is applied below the beam starting from 2 meters to 3 meters
away from the starting point of the beam.
>>> from sympy.physics.continuum_mechanics.beam import Beam
>>> from sympy import symbols
>>> E, I = symbols('E, I')
>>> b = Beam(4, E, I)
>>> b.apply_load(-3, 0, -2)
>>> b.apply_load(4, 2, -1)
>>> b.apply_load(-2, 2, 2, end=3)
>>> b.load
-3*SingularityFunction(x, 0, -2) + 4*SingularityFunction(x, 2, -1) - 2*SingularityFunction(x, 2, 2) + 2*SingularityFunction(x, 3, 0) + 4*SingularityFunction(x, 3, 1) + 2*SingularityFunction(x, 3, 2)
>>> b.remove_load(-2, 2, 2, end = 3)
>>> b.load
-3*SingularityFunction(x, 0, -2) + 4*SingularityFunction(x, 2, -1)
"""
x = self.variable
value = sympify(value)
start = sympify(start)
order = sympify(order)
if (value, start, order, end) in self._applied_loads:
self._load -= value*SingularityFunction(x, start, order)
self._applied_loads.remove((value, start, order, end))
else:
msg = "No such load distribution exists on the beam object."
raise ValueError(msg)
if end:
# TODO : This is essentially duplicate code wrt to apply_load,
# would be better to move it to one location and both methods use
# it.
if order.is_negative:
msg = ("If 'end' is provided the 'order' of the load cannot "
"be negative, i.e. 'end' is only valid for distributed "
"loads.")
raise ValueError(msg)
# NOTE : A Taylor series can be used to define the summation of
# singularity functions that subtract from the load past the end
# point such that it evaluates to zero past 'end'.
f = value*x**order
for i in range(0, order + 1):
self._load += (f.diff(x, i).subs(x, end - start) *
SingularityFunction(x, end, i)/factorial(i))
@property
def load(self):
"""
Returns a Singularity Function expression which represents
the load distribution curve of the Beam object.
Examples
========
There is a beam of length 4 meters. A moment of magnitude 3 Nm is
applied in the clockwise direction at the starting point of the beam.
A point load of magnitude 4 N is applied from the top of the beam at
2 meters from the starting point and a parabolic ramp load of magnitude
2 N/m is applied below the beam starting from 3 meters away from the
starting point of the beam.
>>> from sympy.physics.continuum_mechanics.beam import Beam
>>> from sympy import symbols
>>> E, I = symbols('E, I')
>>> b = Beam(4, E, I)
>>> b.apply_load(-3, 0, -2)
>>> b.apply_load(4, 2, -1)
>>> b.apply_load(-2, 3, 2)
>>> b.load
-3*SingularityFunction(x, 0, -2) + 4*SingularityFunction(x, 2, -1) - 2*SingularityFunction(x, 3, 2)
"""
return self._load
@property
def applied_loads(self):
"""
Returns a list of all loads applied on the beam object.
Each load in the list is a tuple of form (value, start, order, end).
Examples
========
There is a beam of length 4 meters. A moment of magnitude 3 Nm is
applied in the clockwise direction at the starting point of the beam.
A pointload of magnitude 4 N is applied from the top of the beam at
2 meters from the starting point. Another pointload of magnitude 5 N
is applied at same position.
>>> from sympy.physics.continuum_mechanics.beam import Beam
>>> from sympy import symbols
>>> E, I = symbols('E, I')
>>> b = Beam(4, E, I)
>>> b.apply_load(-3, 0, -2)
>>> b.apply_load(4, 2, -1)
>>> b.apply_load(5, 2, -1)
>>> b.load
-3*SingularityFunction(x, 0, -2) + 9*SingularityFunction(x, 2, -1)
>>> b.applied_loads
[(-3, 0, -2, None), (4, 2, -1, None), (5, 2, -1, None)]
"""
return self._applied_loads
def _solve_hinge_beams(self, *reactions):
"""Method to find integration constants and reactional variables in a
composite beam connected via hinge.
This method resolves the composite Beam into its sub-beams and then
equations of shear force, bending moment, slope and deflection are
evaluated for both of them separately. These equations are then solved
for unknown reactions and integration constants using the boundary
conditions applied on the Beam. Equal deflection of both sub-beams
at the hinge joint gives us another equation to solve the system.
Examples
========
A combined beam, with constant fkexural rigidity E*I, is formed by joining
a Beam of length 2*l to the right of another Beam of length l. The whole beam
is fixed at both of its both end. A point load of magnitude P is also applied
from the top at a distance of 2*l from starting point.
>>> from sympy.physics.continuum_mechanics.beam import Beam
>>> from sympy import symbols
>>> E, I = symbols('E, I')
>>> l=symbols('l', positive=True)
>>> b1=Beam(l ,E,I)
>>> b2=Beam(2*l ,E,I)
>>> b=b1.join(b2,"hinge")
>>> M1, A1, M2, A2, P = symbols('M1 A1 M2 A2 P')
>>> b.apply_load(A1,0,-1)
>>> b.apply_load(M1,0,-2)
>>> b.apply_load(P,2*l,-1)
>>> b.apply_load(A2,3*l,-1)
>>> b.apply_load(M2,3*l,-2)
>>> b.bc_slope=[(0,0), (3*l, 0)]
>>> b.bc_deflection=[(0,0), (3*l, 0)]
>>> b.solve_for_reaction_loads(M1, A1, M2, A2)
>>> b.reaction_loads
{A1: -5*P/18, A2: -13*P/18, M1: 5*P*l/18, M2: -4*P*l/9}
>>> b.slope()
(5*P*l*SingularityFunction(x, 0, 1)/18 - 5*P*SingularityFunction(x, 0, 2)/36 + 5*P*SingularityFunction(x, l, 2)/36)*SingularityFunction(x, 0, 0)/(E*I)
- (5*P*l*SingularityFunction(x, 0, 1)/18 - 5*P*SingularityFunction(x, 0, 2)/36 + 5*P*SingularityFunction(x, l, 2)/36)*SingularityFunction(x, l, 0)/(E*I)
+ (P*l**2/18 - 4*P*l*SingularityFunction(-l + x, 2*l, 1)/9 - 5*P*SingularityFunction(-l + x, 0, 2)/36 + P*SingularityFunction(-l + x, l, 2)/2
- 13*P*SingularityFunction(-l + x, 2*l, 2)/36)*SingularityFunction(x, l, 0)/(E*I)
>>> b.deflection()
(5*P*l*SingularityFunction(x, 0, 2)/36 - 5*P*SingularityFunction(x, 0, 3)/108 + 5*P*SingularityFunction(x, l, 3)/108)*SingularityFunction(x, 0, 0)/(E*I)
- (5*P*l*SingularityFunction(x, 0, 2)/36 - 5*P*SingularityFunction(x, 0, 3)/108 + 5*P*SingularityFunction(x, l, 3)/108)*SingularityFunction(x, l, 0)/(E*I)
+ (5*P*l**3/54 + P*l**2*(-l + x)/18 - 2*P*l*SingularityFunction(-l + x, 2*l, 2)/9 - 5*P*SingularityFunction(-l + x, 0, 3)/108 + P*SingularityFunction(-l + x, l, 3)/6
- 13*P*SingularityFunction(-l + x, 2*l, 3)/108)*SingularityFunction(x, l, 0)/(E*I)
"""
x = self.variable
l = self._hinge_position
E = self._elastic_modulus
I = self._second_moment
if isinstance(I, Piecewise):
I1 = I.args[0][0]
I2 = I.args[1][0]
else:
I1 = I2 = I
load_1 = 0 # Load equation on first segment of composite beam
load_2 = 0 # Load equation on second segment of composite beam
# Distributing load on both segments
for load in self.applied_loads:
if load[1] < l:
load_1 += load[0]*SingularityFunction(x, load[1], load[2])
if load[2] == 0:
load_1 -= load[0]*SingularityFunction(x, load[3], load[2])
elif load[2] > 0:
load_1 -= load[0]*SingularityFunction(x, load[3], load[2]) + load[0]*SingularityFunction(x, load[3], 0)
elif load[1] == l:
load_1 += load[0]*SingularityFunction(x, load[1], load[2])
load_2 += load[0]*SingularityFunction(x, load[1] - l, load[2])
elif load[1] > l:
load_2 += load[0]*SingularityFunction(x, load[1] - l, load[2])
if load[2] == 0:
load_2 -= load[0]*SingularityFunction(x, load[3] - l, load[2])
elif load[2] > 0:
load_2 -= load[0]*SingularityFunction(x, load[3] - l, load[2]) + load[0]*SingularityFunction(x, load[3] - l, 0)
h = Symbol('h') # Force due to hinge
load_1 += h*SingularityFunction(x, l, -1)
load_2 -= h*SingularityFunction(x, 0, -1)
eq = []
shear_1 = integrate(load_1, x)
shear_curve_1 = limit(shear_1, x, l)
eq.append(shear_curve_1)
bending_1 = integrate(shear_1, x)
moment_curve_1 = limit(bending_1, x, l)
eq.append(moment_curve_1)
shear_2 = integrate(load_2, x)
shear_curve_2 = limit(shear_2, x, self.length - l)
eq.append(shear_curve_2)
bending_2 = integrate(shear_2, x)
moment_curve_2 = limit(bending_2, x, self.length - l)
eq.append(moment_curve_2)
C1 = Symbol('C1')
C2 = Symbol('C2')
C3 = Symbol('C3')
C4 = Symbol('C4')
slope_1 = S.One/(E*I1)*(integrate(bending_1, x) + C1)
def_1 = S.One/(E*I1)*(integrate((E*I)*slope_1, x) + C1*x + C2)
slope_2 = S.One/(E*I2)*(integrate(integrate(integrate(load_2, x), x), x) + C3)
def_2 = S.One/(E*I2)*(integrate((E*I)*slope_2, x) + C4)
for position, value in self.bc_slope:
if position<l:
eq.append(slope_1.subs(x, position) - value)
else:
eq.append(slope_2.subs(x, position - l) - value)
for position, value in self.bc_deflection:
if position<l:
eq.append(def_1.subs(x, position) - value)
else:
eq.append(def_2.subs(x, position - l) - value)
eq.append(def_1.subs(x, l) - def_2.subs(x, 0)) # Deflection of both the segments at hinge would be equal
constants = list(linsolve(eq, C1, C2, C3, C4, h, *reactions))
reaction_values = list(constants[0])[5:]
self._reaction_loads = dict(zip(reactions, reaction_values))
self._load = self._load.subs(self._reaction_loads)
# Substituting constants and reactional load and moments with their corresponding values
slope_1 = slope_1.subs({C1: constants[0][0], h:constants[0][4]}).subs(self._reaction_loads)
def_1 = def_1.subs({C1: constants[0][0], C2: constants[0][1], h:constants[0][4]}).subs(self._reaction_loads)
slope_2 = slope_2.subs({x: x-l, C3: constants[0][2], h:constants[0][4]}).subs(self._reaction_loads)
def_2 = def_2.subs({x: x-l,C3: constants[0][2], C4: constants[0][3], h:constants[0][4]}).subs(self._reaction_loads)
self._hinge_beam_slope = slope_1*SingularityFunction(x, 0, 0) - slope_1*SingularityFunction(x, l, 0) + slope_2*SingularityFunction(x, l, 0)
self._hinge_beam_deflection = def_1*SingularityFunction(x, 0, 0) - def_1*SingularityFunction(x, l, 0) + def_2*SingularityFunction(x, l, 0)
def solve_for_reaction_loads(self, *reactions):
"""
Solves for the reaction forces.
Examples
========
There is a beam of length 30 meters. A moment of magnitude 120 Nm is
applied in the clockwise direction at the end of the beam. A pointload
of magnitude 8 N is applied from the top of the beam at the starting
point. There are two simple supports below the beam. One at the end
and another one at a distance of 10 meters from the start. The
deflection is restricted at both the supports.
Using the sign convention of upward forces and clockwise moment
being positive.
>>> from sympy.physics.continuum_mechanics.beam import Beam
>>> from sympy import symbols, linsolve, limit
>>> E, I = symbols('E, I')
>>> R1, R2 = symbols('R1, R2')
>>> b = Beam(30, E, I)
>>> b.apply_load(-8, 0, -1)
>>> b.apply_load(R1, 10, -1) # Reaction force at x = 10
>>> b.apply_load(R2, 30, -1) # Reaction force at x = 30
>>> b.apply_load(120, 30, -2)
>>> b.bc_deflection = [(10, 0), (30, 0)]
>>> b.load
R1*SingularityFunction(x, 10, -1) + R2*SingularityFunction(x, 30, -1)
- 8*SingularityFunction(x, 0, -1) + 120*SingularityFunction(x, 30, -2)
>>> b.solve_for_reaction_loads(R1, R2)
>>> b.reaction_loads
{R1: 6, R2: 2}
>>> b.load
-8*SingularityFunction(x, 0, -1) + 6*SingularityFunction(x, 10, -1)
+ 120*SingularityFunction(x, 30, -2) + 2*SingularityFunction(x, 30, -1)
"""
if self._composite_type == "hinge":
return self._solve_hinge_beams(*reactions)
x = self.variable
l = self.length
C3 = Symbol('C3')
C4 = Symbol('C4')
shear_curve = limit(self.shear_force(), x, l)
moment_curve = limit(self.bending_moment(), x, l)
slope_eqs = []
deflection_eqs = []
slope_curve = integrate(self.bending_moment(), x) + C3
for position, value in self._boundary_conditions['slope']:
eqs = slope_curve.subs(x, position) - value
slope_eqs.append(eqs)
deflection_curve = integrate(slope_curve, x) + C4
for position, value in self._boundary_conditions['deflection']:
eqs = deflection_curve.subs(x, position) - value
deflection_eqs.append(eqs)
solution = list((linsolve([shear_curve, moment_curve] + slope_eqs
+ deflection_eqs, (C3, C4) + reactions).args)[0])
solution = solution[2:]
self._reaction_loads = dict(zip(reactions, solution))
self._load = self._load.subs(self._reaction_loads)
def shear_force(self):
"""
Returns a Singularity Function expression which represents
the shear force curve of the Beam object.
Examples
========
There is a beam of length 30 meters. A moment of magnitude 120 Nm is
applied in the clockwise direction at the end of the beam. A pointload
of magnitude 8 N is applied from the top of the beam at the starting
point. There are two simple supports below the beam. One at the end
and another one at a distance of 10 meters from the start. The
deflection is restricted at both the supports.
Using the sign convention of upward forces and clockwise moment
being positive.
>>> from sympy.physics.continuum_mechanics.beam import Beam
>>> from sympy import symbols
>>> E, I = symbols('E, I')
>>> R1, R2 = symbols('R1, R2')
>>> b = Beam(30, E, I)
>>> b.apply_load(-8, 0, -1)
>>> b.apply_load(R1, 10, -1)
>>> b.apply_load(R2, 30, -1)
>>> b.apply_load(120, 30, -2)
>>> b.bc_deflection = [(10, 0), (30, 0)]
>>> b.solve_for_reaction_loads(R1, R2)
>>> b.shear_force()
-8*SingularityFunction(x, 0, 0) + 6*SingularityFunction(x, 10, 0) + 120*SingularityFunction(x, 30, -1) + 2*SingularityFunction(x, 30, 0)
"""
x = self.variable
return integrate(self.load, x)
def max_shear_force(self):
"""Returns maximum Shear force and its coordinate
in the Beam object."""
from sympy import solve, Mul, Interval
shear_curve = self.shear_force()
x = self.variable
terms = shear_curve.args
singularity = [] # Points at which shear function changes
for term in terms:
if isinstance(term, Mul):
term = term.args[-1] # SingularityFunction in the term
singularity.append(term.args[1])
singularity.sort()
singularity = list(set(singularity))
intervals = [] # List of Intervals with discrete value of shear force
shear_values = [] # List of values of shear force in each interval
for i, s in enumerate(singularity):
if s == 0:
continue
try:
shear_slope = Piecewise((float("nan"), x<=singularity[i-1]),(self._load.rewrite(Piecewise), x<s), (float("nan"), True))
points = solve(shear_slope, x)
val = []
for point in points:
val.append(shear_curve.subs(x, point))
points.extend([singularity[i-1], s])
val.extend([limit(shear_curve, x, singularity[i-1], '+'), limit(shear_curve, x, s, '-')])
val = list(map(abs, val))
max_shear = max(val)
shear_values.append(max_shear)
intervals.append(points[val.index(max_shear)])
# If shear force in a particular Interval has zero or constant
# slope, then above block gives NotImplementedError as
# solve can't represent Interval solutions.
except NotImplementedError:
initial_shear = limit(shear_curve, x, singularity[i-1], '+')
final_shear = limit(shear_curve, x, s, '-')
# If shear_curve has a constant slope(it is a line).
if shear_curve.subs(x, (singularity[i-1] + s)/2) == (initial_shear + final_shear)/2 and initial_shear != final_shear:
shear_values.extend([initial_shear, final_shear])
intervals.extend([singularity[i-1], s])
else: # shear_curve has same value in whole Interval
shear_values.append(final_shear)
intervals.append(Interval(singularity[i-1], s))
shear_values = list(map(abs, shear_values))
maximum_shear = max(shear_values)
point = intervals[shear_values.index(maximum_shear)]
return (point, maximum_shear)
def bending_moment(self):
"""
Returns a Singularity Function expression which represents
the bending moment curve of the Beam object.
Examples
========
There is a beam of length 30 meters. A moment of magnitude 120 Nm is
applied in the clockwise direction at the end of the beam. A pointload
of magnitude 8 N is applied from the top of the beam at the starting
point. There are two simple supports below the beam. One at the end
and another one at a distance of 10 meters from the start. The
deflection is restricted at both the supports.
Using the sign convention of upward forces and clockwise moment
being positive.
>>> from sympy.physics.continuum_mechanics.beam import Beam
>>> from sympy import symbols
>>> E, I = symbols('E, I')
>>> R1, R2 = symbols('R1, R2')
>>> b = Beam(30, E, I)
>>> b.apply_load(-8, 0, -1)
>>> b.apply_load(R1, 10, -1)
>>> b.apply_load(R2, 30, -1)
>>> b.apply_load(120, 30, -2)
>>> b.bc_deflection = [(10, 0), (30, 0)]
>>> b.solve_for_reaction_loads(R1, R2)
>>> b.bending_moment()
-8*SingularityFunction(x, 0, 1) + 6*SingularityFunction(x, 10, 1) + 120*SingularityFunction(x, 30, 0) + 2*SingularityFunction(x, 30, 1)
"""
x = self.variable
return integrate(self.shear_force(), x)
def max_bmoment(self):
"""Returns maximum Shear force and its coordinate
in the Beam object."""
from sympy import solve, Mul, Interval
bending_curve = self.bending_moment()
x = self.variable
terms = bending_curve.args
singularity = [] # Points at which bending moment changes
for term in terms:
if isinstance(term, Mul):
term = term.args[-1] # SingularityFunction in the term
singularity.append(term.args[1])
singularity.sort()
singularity = list(set(singularity))
intervals = [] # List of Intervals with discrete value of bending moment
moment_values = [] # List of values of bending moment in each interval
for i, s in enumerate(singularity):
if s == 0:
continue
try:
moment_slope = Piecewise((float("nan"), x<=singularity[i-1]),(self.shear_force().rewrite(Piecewise), x<s), (float("nan"), True))
points = solve(moment_slope, x)
val = []
for point in points:
val.append(bending_curve.subs(x, point))
points.extend([singularity[i-1], s])
val.extend([limit(bending_curve, x, singularity[i-1], '+'), limit(bending_curve, x, s, '-')])
val = list(map(abs, val))
max_moment = max(val)
moment_values.append(max_moment)
intervals.append(points[val.index(max_moment)])
# If bending moment in a particular Interval has zero or constant
# slope, then above block gives NotImplementedError as solve
# can't represent Interval solutions.
except NotImplementedError:
initial_moment = limit(bending_curve, x, singularity[i-1], '+')
final_moment = limit(bending_curve, x, s, '-')
# If bending_curve has a constant slope(it is a line).
if bending_curve.subs(x, (singularity[i-1] + s)/2) == (initial_moment + final_moment)/2 and initial_moment != final_moment:
moment_values.extend([initial_moment, final_moment])
intervals.extend([singularity[i-1], s])
else: # bending_curve has same value in whole Interval
moment_values.append(final_moment)
intervals.append(Interval(singularity[i-1], s))
moment_values = list(map(abs, moment_values))
maximum_moment = max(moment_values)
point = intervals[moment_values.index(maximum_moment)]
return (point, maximum_moment)
def point_cflexure(self):
"""
Returns a Set of point(s) with zero bending moment and
where bending moment curve of the beam object changes
its sign from negative to positive or vice versa.
Examples
========
There is is 10 meter long overhanging beam. There are
two simple supports below the beam. One at the start
and another one at a distance of 6 meters from the start.
Point loads of magnitude 10KN and 20KN are applied at
2 meters and 4 meters from start respectively. A Uniformly
distribute load of magnitude of magnitude 3KN/m is also
applied on top starting from 6 meters away from starting
point till end.
Using the sign convention of upward forces and clockwise moment
being positive.
>>> from sympy.physics.continuum_mechanics.beam import Beam
>>> from sympy import symbols
>>> E, I = symbols('E, I')
>>> b = Beam(10, E, I)
>>> b.apply_load(-4, 0, -1)
>>> b.apply_load(-46, 6, -1)
>>> b.apply_load(10, 2, -1)
>>> b.apply_load(20, 4, -1)
>>> b.apply_load(3, 6, 0)
>>> b.point_cflexure()
[10/3]
"""
from sympy import solve, Piecewise
# To restrict the range within length of the Beam
moment_curve = Piecewise((float("nan"), self.variable<=0),
(self.bending_moment(), self.variable<self.length),
(float("nan"), True))
points = solve(moment_curve.rewrite(Piecewise), self.variable,
domain=S.Reals)
return points
def slope(self):
"""
Returns a Singularity Function expression which represents
the slope the elastic curve of the Beam object.
Examples
========
There is a beam of length 30 meters. A moment of magnitude 120 Nm is
applied in the clockwise direction at the end of the beam. A pointload
of magnitude 8 N is applied from the top of the beam at the starting
point. There are two simple supports below the beam. One at the end
and another one at a distance of 10 meters from the start. The
deflection is restricted at both the supports.
Using the sign convention of upward forces and clockwise moment
being positive.
>>> from sympy.physics.continuum_mechanics.beam import Beam
>>> from sympy import symbols
>>> E, I = symbols('E, I')
>>> R1, R2 = symbols('R1, R2')
>>> b = Beam(30, E, I)
>>> b.apply_load(-8, 0, -1)
>>> b.apply_load(R1, 10, -1)
>>> b.apply_load(R2, 30, -1)
>>> b.apply_load(120, 30, -2)
>>> b.bc_deflection = [(10, 0), (30, 0)]
>>> b.solve_for_reaction_loads(R1, R2)
>>> b.slope()
(-4*SingularityFunction(x, 0, 2) + 3*SingularityFunction(x, 10, 2)
+ 120*SingularityFunction(x, 30, 1) + SingularityFunction(x, 30, 2) + 4000/3)/(E*I)
"""
x = self.variable
E = self.elastic_modulus
I = self.second_moment
if self._composite_type == "hinge":
return self._hinge_beam_slope
if not self._boundary_conditions['slope']:
return diff(self.deflection(), x)
if isinstance(I, Piecewise) and self._composite_type == "fixed":
args = I.args
slope = 0
prev_slope = 0
prev_end = 0
for i in range(len(args)):
if i != 0:
prev_end = args[i-1][1].args[1]
slope_value = S.One/E*integrate(self.bending_moment()/args[i][0], (x, prev_end, x))
if i != len(args) - 1:
slope += (prev_slope + slope_value)*SingularityFunction(x, prev_end, 0) - \
(prev_slope + slope_value)*SingularityFunction(x, args[i][1].args[1], 0)
else:
slope += (prev_slope + slope_value)*SingularityFunction(x, prev_end, 0)
prev_slope = slope_value.subs(x, args[i][1].args[1])
return slope
C3 = Symbol('C3')
slope_curve = integrate(S.One/(E*I)*self.bending_moment(), x) + C3
bc_eqs = []
for position, value in self._boundary_conditions['slope']:
eqs = slope_curve.subs(x, position) - value
bc_eqs.append(eqs)
constants = list(linsolve(bc_eqs, C3))
slope_curve = slope_curve.subs({C3: constants[0][0]})
return slope_curve
def deflection(self):
"""
Returns a Singularity Function expression which represents
the elastic curve or deflection of the Beam object.
Examples
========
There is a beam of length 30 meters. A moment of magnitude 120 Nm is
applied in the clockwise direction at the end of the beam. A pointload
of magnitude 8 N is applied from the top of the beam at the starting
point. There are two simple supports below the beam. One at the end
and another one at a distance of 10 meters from the start. The
deflection is restricted at both the supports.
Using the sign convention of upward forces and clockwise moment
being positive.
>>> from sympy.physics.continuum_mechanics.beam import Beam
>>> from sympy import symbols
>>> E, I = symbols('E, I')
>>> R1, R2 = symbols('R1, R2')
>>> b = Beam(30, E, I)
>>> b.apply_load(-8, 0, -1)
>>> b.apply_load(R1, 10, -1)
>>> b.apply_load(R2, 30, -1)
>>> b.apply_load(120, 30, -2)
>>> b.bc_deflection = [(10, 0), (30, 0)]
>>> b.solve_for_reaction_loads(R1, R2)
>>> b.deflection()
(4000*x/3 - 4*SingularityFunction(x, 0, 3)/3 + SingularityFunction(x, 10, 3)
+ 60*SingularityFunction(x, 30, 2) + SingularityFunction(x, 30, 3)/3 - 12000)/(E*I)
"""
x = self.variable
E = self.elastic_modulus
I = self.second_moment
if self._composite_type == "hinge":
return self._hinge_beam_deflection
if not self._boundary_conditions['deflection'] and not self._boundary_conditions['slope']:
if isinstance(I, Piecewise) and self._composite_type == "fixed":
args = I.args
prev_slope = 0
prev_def = 0
prev_end = 0
deflection = 0
for i in range(len(args)):
if i != 0:
prev_end = args[i-1][1].args[1]
slope_value = S.One/E*integrate(self.bending_moment()/args[i][0], (x, prev_end, x))
recent_segment_slope = prev_slope + slope_value
deflection_value = integrate(recent_segment_slope, (x, prev_end, x))
if i != len(args) - 1:
deflection += (prev_def + deflection_value)*SingularityFunction(x, prev_end, 0) \
- (prev_def + deflection_value)*SingularityFunction(x, args[i][1].args[1], 0)
else:
deflection += (prev_def + deflection_value)*SingularityFunction(x, prev_end, 0)
prev_slope = slope_value.subs(x, args[i][1].args[1])
prev_def = deflection_value.subs(x, args[i][1].args[1])
return deflection
base_char = self._base_char
constants = symbols(base_char + '3:5')
return S.One/(E*I)*integrate(integrate(self.bending_moment(), x), x) + constants[0]*x + constants[1]
elif not self._boundary_conditions['deflection']:
base_char = self._base_char
constant = symbols(base_char + '4')
return integrate(self.slope(), x) + constant
elif not self._boundary_conditions['slope'] and self._boundary_conditions['deflection']:
if isinstance(I, Piecewise) and self._composite_type == "fixed":
args = I.args
prev_slope = 0
prev_def = 0
prev_end = 0
deflection = 0
for i in range(len(args)):
if i != 0:
prev_end = args[i-1][1].args[1]
slope_value = S.One/E*integrate(self.bending_moment()/args[i][0], (x, prev_end, x))
recent_segment_slope = prev_slope + slope_value
deflection_value = integrate(recent_segment_slope, (x, prev_end, x))
if i != len(args) - 1:
deflection += (prev_def + deflection_value)*SingularityFunction(x, prev_end, 0) \
- (prev_def + deflection_value)*SingularityFunction(x, args[i][1].args[1], 0)
else:
deflection += (prev_def + deflection_value)*SingularityFunction(x, prev_end, 0)
prev_slope = slope_value.subs(x, args[i][1].args[1])
prev_def = deflection_value.subs(x, args[i][1].args[1])
return deflection
base_char = self._base_char
C3, C4 = symbols(base_char + '3:5') # Integration constants
slope_curve = integrate(self.bending_moment(), x) + C3
deflection_curve = integrate(slope_curve, x) + C4
bc_eqs = []
for position, value in self._boundary_conditions['deflection']:
eqs = deflection_curve.subs(x, position) - value
bc_eqs.append(eqs)
constants = list(linsolve(bc_eqs, (C3, C4)))
deflection_curve = deflection_curve.subs({C3: constants[0][0], C4: constants[0][1]})
return S.One/(E*I)*deflection_curve
if isinstance(I, Piecewise) and self._composite_type == "fixed":
args = I.args
prev_slope = 0
prev_def = 0
prev_end = 0
deflection = 0
for i in range(len(args)):
if i != 0:
prev_end = args[i-1][1].args[1]
slope_value = S.One/E*integrate(self.bending_moment()/args[i][0], (x, prev_end, x))
recent_segment_slope = prev_slope + slope_value
deflection_value = integrate(recent_segment_slope, (x, prev_end, x))
if i != len(args) - 1:
deflection += (prev_def + deflection_value)*SingularityFunction(x, prev_end, 0) \
- (prev_def + deflection_value)*SingularityFunction(x, args[i][1].args[1], 0)
else:
deflection += (prev_def + deflection_value)*SingularityFunction(x, prev_end, 0)
prev_slope = slope_value.subs(x, args[i][1].args[1])
prev_def = deflection_value.subs(x, args[i][1].args[1])
return deflection
C4 = Symbol('C4')
deflection_curve = integrate(self.slope(), x) + C4
bc_eqs = []
for position, value in self._boundary_conditions['deflection']:
eqs = deflection_curve.subs(x, position) - value
bc_eqs.append(eqs)
constants = list(linsolve(bc_eqs, C4))
deflection_curve = deflection_curve.subs({C4: constants[0][0]})
return deflection_curve
def max_deflection(self):
"""
Returns point of max deflection and its corresponding deflection value
in a Beam object.
"""
from sympy import solve, Piecewise
# To restrict the range within length of the Beam
slope_curve = Piecewise((float("nan"), self.variable<=0),
(self.slope(), self.variable<self.length),
(float("nan"), True))
points = solve(slope_curve.rewrite(Piecewise), self.variable,
domain=S.Reals)
deflection_curve = self.deflection()
deflections = [deflection_curve.subs(self.variable, x) for x in points]
deflections = list(map(abs, deflections))
if len(deflections) != 0:
max_def = max(deflections)
return (points[deflections.index(max_def)], max_def)
else:
return None
def shear_stress(self):
"""
Returns an expression representing the Shear Stress
curve of the Beam object.
"""
return self.shear_force()/self._area
def plot_shear_force(self, subs=None):
"""
Returns a plot for Shear force present in the Beam object.
Parameters
==========
subs : dictionary
Python dictionary containing Symbols as key and their
corresponding values.
Examples
========
There is a beam of length 8 meters. A constant distributed load of 10 KN/m
is applied from half of the beam till the end. There are two simple supports
below the beam, one at the starting point and another at the ending point
of the beam. A pointload of magnitude 5 KN is also applied from top of the
beam, at a distance of 4 meters from the starting point.
Take E = 200 GPa and I = 400*(10**-6) meter**4.
Using the sign convention of downwards forces being positive.
.. plot::
:context: close-figs
:format: doctest
:include-source: True
>>> from sympy.physics.continuum_mechanics.beam import Beam
>>> from sympy import symbols
>>> R1, R2 = symbols('R1, R2')
>>> b = Beam(8, 200*(10**9), 400*(10**-6))
>>> b.apply_load(5000, 2, -1)
>>> b.apply_load(R1, 0, -1)
>>> b.apply_load(R2, 8, -1)
>>> b.apply_load(10000, 4, 0, end=8)
>>> b.bc_deflection = [(0, 0), (8, 0)]
>>> b.solve_for_reaction_loads(R1, R2)
>>> b.plot_shear_force()
Plot object containing:
[0]: cartesian line: -13750*SingularityFunction(x, 0, 0) + 5000*SingularityFunction(x, 2, 0)
+ 10000*SingularityFunction(x, 4, 1) - 31250*SingularityFunction(x, 8, 0)
- 10000*SingularityFunction(x, 8, 1) for x over (0.0, 8.0)
"""
shear_force = self.shear_force()
if subs is None:
subs = {}
for sym in shear_force.atoms(Symbol):
if sym == self.variable:
continue
if sym not in subs:
raise ValueError('Value of %s was not passed.' %sym)
if self.length in subs:
length = subs[self.length]
else:
length = self.length
return plot(shear_force.subs(subs), (self.variable, 0, length), title='Shear Force',
xlabel=r'$\mathrm{x}$', ylabel=r'$\mathrm{V}$', line_color='g')
def plot_bending_moment(self, subs=None):
"""
Returns a plot for Bending moment present in the Beam object.
Parameters
==========
subs : dictionary
Python dictionary containing Symbols as key and their
corresponding values.
Examples
========
There is a beam of length 8 meters. A constant distributed load of 10 KN/m
is applied from half of the beam till the end. There are two simple supports
below the beam, one at the starting point and another at the ending point
of the beam. A pointload of magnitude 5 KN is also applied from top of the
beam, at a distance of 4 meters from the starting point.
Take E = 200 GPa and I = 400*(10**-6) meter**4.
Using the sign convention of downwards forces being positive.
.. plot::
:context: close-figs
:format: doctest
:include-source: True
>>> from sympy.physics.continuum_mechanics.beam import Beam
>>> from sympy import symbols
>>> R1, R2 = symbols('R1, R2')
>>> b = Beam(8, 200*(10**9), 400*(10**-6))
>>> b.apply_load(5000, 2, -1)
>>> b.apply_load(R1, 0, -1)
>>> b.apply_load(R2, 8, -1)
>>> b.apply_load(10000, 4, 0, end=8)
>>> b.bc_deflection = [(0, 0), (8, 0)]
>>> b.solve_for_reaction_loads(R1, R2)
>>> b.plot_bending_moment()
Plot object containing:
[0]: cartesian line: -13750*SingularityFunction(x, 0, 1) + 5000*SingularityFunction(x, 2, 1)
+ 5000*SingularityFunction(x, 4, 2) - 31250*SingularityFunction(x, 8, 1)
- 5000*SingularityFunction(x, 8, 2) for x over (0.0, 8.0)
"""
bending_moment = self.bending_moment()
if subs is None:
subs = {}
for sym in bending_moment.atoms(Symbol):
if sym == self.variable:
continue
if sym not in subs:
raise ValueError('Value of %s was not passed.' %sym)
if self.length in subs:
length = subs[self.length]
else:
length = self.length
return plot(bending_moment.subs(subs), (self.variable, 0, length), title='Bending Moment',
xlabel=r'$\mathrm{x}$', ylabel=r'$\mathrm{M}$', line_color='b')
def plot_slope(self, subs=None):
"""
Returns a plot for slope of deflection curve of the Beam object.
Parameters
==========
subs : dictionary
Python dictionary containing Symbols as key and their
corresponding values.
Examples
========
There is a beam of length 8 meters. A constant distributed load of 10 KN/m
is applied from half of the beam till the end. There are two simple supports
below the beam, one at the starting point and another at the ending point
of the beam. A pointload of magnitude 5 KN is also applied from top of the
beam, at a distance of 4 meters from the starting point.
Take E = 200 GPa and I = 400*(10**-6) meter**4.
Using the sign convention of downwards forces being positive.
.. plot::
:context: close-figs
:format: doctest
:include-source: True
>>> from sympy.physics.continuum_mechanics.beam import Beam
>>> from sympy import symbols
>>> R1, R2 = symbols('R1, R2')
>>> b = Beam(8, 200*(10**9), 400*(10**-6))
>>> b.apply_load(5000, 2, -1)
>>> b.apply_load(R1, 0, -1)
>>> b.apply_load(R2, 8, -1)
>>> b.apply_load(10000, 4, 0, end=8)
>>> b.bc_deflection = [(0, 0), (8, 0)]
>>> b.solve_for_reaction_loads(R1, R2)
>>> b.plot_slope()
Plot object containing:
[0]: cartesian line: -8.59375e-5*SingularityFunction(x, 0, 2) + 3.125e-5*SingularityFunction(x, 2, 2)
+ 2.08333333333333e-5*SingularityFunction(x, 4, 3) - 0.0001953125*SingularityFunction(x, 8, 2)
- 2.08333333333333e-5*SingularityFunction(x, 8, 3) + 0.00138541666666667 for x over (0.0, 8.0)
"""
slope = self.slope()
if subs is None:
subs = {}
for sym in slope.atoms(Symbol):
if sym == self.variable:
continue
if sym not in subs:
raise ValueError('Value of %s was not passed.' %sym)
if self.length in subs:
length = subs[self.length]
else:
length = self.length
return plot(slope.subs(subs), (self.variable, 0, length), title='Slope',
xlabel=r'$\mathrm{x}$', ylabel=r'$\theta$', line_color='m')
def plot_deflection(self, subs=None):
"""
Returns a plot for deflection curve of the Beam object.
Parameters
==========
subs : dictionary
Python dictionary containing Symbols as key and their
corresponding values.
Examples
========
There is a beam of length 8 meters. A constant distributed load of 10 KN/m
is applied from half of the beam till the end. There are two simple supports
below the beam, one at the starting point and another at the ending point
of the beam. A pointload of magnitude 5 KN is also applied from top of the
beam, at a distance of 4 meters from the starting point.
Take E = 200 GPa and I = 400*(10**-6) meter**4.
Using the sign convention of downwards forces being positive.
.. plot::
:context: close-figs
:format: doctest
:include-source: True
>>> from sympy.physics.continuum_mechanics.beam import Beam
>>> from sympy import symbols
>>> R1, R2 = symbols('R1, R2')
>>> b = Beam(8, 200*(10**9), 400*(10**-6))
>>> b.apply_load(5000, 2, -1)
>>> b.apply_load(R1, 0, -1)
>>> b.apply_load(R2, 8, -1)
>>> b.apply_load(10000, 4, 0, end=8)
>>> b.bc_deflection = [(0, 0), (8, 0)]
>>> b.solve_for_reaction_loads(R1, R2)
>>> b.plot_deflection()
Plot object containing:
[0]: cartesian line: 0.00138541666666667*x - 2.86458333333333e-5*SingularityFunction(x, 0, 3)
+ 1.04166666666667e-5*SingularityFunction(x, 2, 3) + 5.20833333333333e-6*SingularityFunction(x, 4, 4)
- 6.51041666666667e-5*SingularityFunction(x, 8, 3) - 5.20833333333333e-6*SingularityFunction(x, 8, 4)
for x over (0.0, 8.0)
"""
deflection = self.deflection()
if subs is None:
subs = {}
for sym in deflection.atoms(Symbol):
if sym == self.variable:
continue
if sym not in subs:
raise ValueError('Value of %s was not passed.' %sym)
if self.length in subs:
length = subs[self.length]
else:
length = self.length
return plot(deflection.subs(subs), (self.variable, 0, length),
title='Deflection', xlabel=r'$\mathrm{x}$', ylabel=r'$\delta$',
line_color='r')
def plot_loading_results(self, subs=None):
"""
Returns a subplot of Shear Force, Bending Moment,
Slope and Deflection of the Beam object.
Parameters
==========
subs : dictionary
Python dictionary containing Symbols as key and their
corresponding values.
Examples
========
There is a beam of length 8 meters. A constant distributed load of 10 KN/m
is applied from half of the beam till the end. There are two simple supports
below the beam, one at the starting point and another at the ending point
of the beam. A pointload of magnitude 5 KN is also applied from top of the
beam, at a distance of 4 meters from the starting point.
Take E = 200 GPa and I = 400*(10**-6) meter**4.
Using the sign convention of downwards forces being positive.
.. plot::
:context: close-figs
:format: doctest
:include-source: True
>>> from sympy.physics.continuum_mechanics.beam import Beam
>>> from sympy import symbols
>>> from sympy.plotting import PlotGrid
>>> R1, R2 = symbols('R1, R2')
>>> b = Beam(8, 200*(10**9), 400*(10**-6))
>>> b.apply_load(5000, 2, -1)
>>> b.apply_load(R1, 0, -1)
>>> b.apply_load(R2, 8, -1)
>>> b.apply_load(10000, 4, 0, end=8)
>>> b.bc_deflection = [(0, 0), (8, 0)]
>>> b.solve_for_reaction_loads(R1, R2)
>>> axes = b.plot_loading_results()
"""
length = self.length
variable = self.variable
if subs is None:
subs = {}
for sym in self.deflection().atoms(Symbol):
if sym == self.variable:
continue
if sym not in subs:
raise ValueError('Value of %s was not passed.' %sym)
if self.length in subs:
length = subs[self.length]
else:
length = self.length
ax1 = plot(self.shear_force().subs(subs), (variable, 0, length),
title="Shear Force", xlabel=r'$\mathrm{x}$', ylabel=r'$\mathrm{V}$',
line_color='g', show=False)
ax2 = plot(self.bending_moment().subs(subs), (variable, 0, length),
title="Bending Moment", xlabel=r'$\mathrm{x}$', ylabel=r'$\mathrm{M}$',
line_color='b', show=False)
ax3 = plot(self.slope().subs(subs), (variable, 0, length),
title="Slope", xlabel=r'$\mathrm{x}$', ylabel=r'$\theta$',
line_color='m', show=False)
ax4 = plot(self.deflection().subs(subs), (variable, 0, length),
title="Deflection", xlabel=r'$\mathrm{x}$', ylabel=r'$\delta$',
line_color='r', show=False)
return PlotGrid(4, 1, ax1, ax2, ax3, ax4)
@doctest_depends_on(modules=('numpy',))
def draw(self, pictorial=True):
"""
Returns a plot object representing the beam diagram of the beam.
.. note::
The user must be careful while entering load values.
The draw function assumes a sign convention which is used
for plotting loads.
Given a right handed coordinate system with XYZ coordinates,
the beam's length is assumed to be along the positive X axis.
The draw function recognizes positve loads(with n>-2) as loads
acting along negative Y direction and positve moments acting
along positive Z direction.
Parameters
==========
pictorial: Boolean (default=True)
Setting ``pictorial=True`` would simply create a pictorial (scaled) view
of the beam diagram not with the exact dimensions.
Although setting ``pictorial=False`` would create a beam diagram with
the exact dimensions on the plot
Examples
========
.. plot::
:context: close-figs
:format: doctest
:include-source: True
>>> from sympy.physics.continuum_mechanics.beam import Beam
>>> from sympy import symbols
>>> R1, R2 = symbols('R1, R2')
>>> E, I = symbols('E, I')
>>> b = Beam(50, 20, 30)
>>> b.apply_load(10, 2, -1)
>>> b.apply_load(R1, 10, -1)
>>> b.apply_load(R2, 30, -1)
>>> b.apply_load(90, 5, 0, 23)
>>> b.apply_load(10, 30, 1, 50)
>>> b.apply_support(50, "pin")
>>> b.apply_support(0, "fixed")
>>> b.apply_support(20, "roller")
>>> b.draw()
Plot object containing:
[0]: cartesian line: 25*SingularityFunction(x, 5, 0) - 25*SingularityFunction(x, 23, 0)
+ SingularityFunction(x, 30, 1) - 20*SingularityFunction(x, 50, 0)
- SingularityFunction(x, 50, 1) + 5 for x over (0.0, 50.0)
[1]: cartesian line: 5 for x over (0.0, 50.0)
"""
if not numpy:
raise ImportError("To use this function numpy module is required")
x = self.variable
# checking whether length is an expression in terms of any Symbol.
from sympy import Expr
if isinstance(self.length, Expr):
l = list(self.length.atoms(Symbol))
# assigning every Symbol a default value of 10
l = {i:10 for i in l}
length = self.length.subs(l)
else:
l = {}
length = self.length
height = length/10
rectangles = []
rectangles.append({'xy':(0, 0), 'width':length, 'height': height, 'facecolor':"brown"})
annotations, markers, load_eq,load_eq1, fill = self._draw_load(pictorial, length, l)
support_markers, support_rectangles = self._draw_supports(length, l)
rectangles += support_rectangles
markers += support_markers
sing_plot = plot(height + load_eq, height + load_eq1, (x, 0, length),
xlim=(-height, length + height), ylim=(-length, 1.25*length), annotations=annotations,
markers=markers, rectangles=rectangles, line_color='brown', fill=fill, axis=False, show=False)
return sing_plot
def _draw_load(self, pictorial, length, l):
loads = list(set(self.applied_loads) - set(self._support_as_loads))
height = length/10
x = self.variable
annotations = []
markers = []
load_args = []
scaled_load = 0
load_args1 = []
scaled_load1 = 0
load_eq = 0 # For positive valued higher order loads
load_eq1 = 0 # For negative valued higher order loads
fill = None
plus = 0 # For positive valued higher order loads
minus = 0 # For negative valued higher order loads
for load in loads:
# check if the position of load is in terms of the beam length.
if l:
pos = load[1].subs(l)
else:
pos = load[1]
# point loads
if load[2] == -1:
if isinstance(load[0], Symbol) or load[0].is_negative:
annotations.append({'s':'', 'xy':(pos, 0), 'xytext':(pos, height - 4*height), 'arrowprops':dict(width= 1.5, headlength=5, headwidth=5, facecolor='black')})
else:
annotations.append({'s':'', 'xy':(pos, height), 'xytext':(pos, height*4), 'arrowprops':dict(width= 1.5, headlength=4, headwidth=4, facecolor='black')})
# moment loads
elif load[2] == -2:
if load[0].is_negative:
markers.append({'args':[[pos], [height/2]], 'marker': r'$\circlearrowright$', 'markersize':15})
else:
markers.append({'args':[[pos], [height/2]], 'marker': r'$\circlearrowleft$', 'markersize':15})
# higher order loads
elif load[2] >= 0:
# `fill` will be assigned only when higher order loads are present
value, start, order, end = load
# Positive loads have their seperate equations
if(value>0):
plus = 1
# if pictorial is True we remake the load equation again with
# some constant magnitude values.
if pictorial:
value = 10**(1-order) if order > 0 else length/2
scaled_load += value*SingularityFunction(x, start, order)
if end:
f2 = 10**(1-order)*x**order if order > 0 else length/2*x**order
for i in range(0, order + 1):
scaled_load -= (f2.diff(x, i).subs(x, end - start)*
SingularityFunction(x, end, i)/factorial(i))
if pictorial:
if isinstance(scaled_load, Add):
load_args = scaled_load.args
else:
# when the load equation consists of only a single term
load_args = (scaled_load,)
load_eq = [i.subs(l) for i in load_args]
else:
if isinstance(self.load, Add):
load_args = self.load.args
else:
load_args = (self.load,)
load_eq = [i.subs(l) for i in load_args if list(i.atoms(SingularityFunction))[0].args[2] >= 0]
load_eq = Add(*load_eq)
# filling higher order loads with colour
expr = height + load_eq.rewrite(Piecewise)
y1 = lambdify(x, expr, 'numpy')
# For loads with negative value
else:
minus = 1
# if pictorial is True we remake the load equation again with
# some constant magnitude values.
if pictorial:
value = 10**(1-order) if order > 0 else length/2
scaled_load1 += value*SingularityFunction(x, start, order)
if end:
f2 = 10**(1-order)*x**order if order > 0 else length/2*x**order
for i in range(0, order + 1):
scaled_load1 -= (f2.diff(x, i).subs(x, end - start)*
SingularityFunction(x, end, i)/factorial(i))
if pictorial:
if isinstance(scaled_load1, Add):
load_args1 = scaled_load1.args
else:
# when the load equation consists of only a single term
load_args1 = (scaled_load1,)
load_eq1 = [i.subs(l) for i in load_args1]
else:
if isinstance(self.load, Add):
load_args1 = self.load.args1
else:
load_args1 = (self.load,)
load_eq1 = [i.subs(l) for i in load_args if list(i.atoms(SingularityFunction))[0].args[2] >= 0]
load_eq1 = -Add(*load_eq1)-height
# filling higher order loads with colour
expr = height + load_eq1.rewrite(Piecewise)
y1_ = lambdify(x, expr, 'numpy')
y = numpy.arange(0, float(length), 0.001)
y2 = float(height)
if(plus == 1 and minus == 1):
fill = {'x': y, 'y1': y1(y), 'y2': y1_(y), 'color':'darkkhaki'}
elif(plus == 1):
fill = {'x': y, 'y1': y1(y), 'y2': y2, 'color':'darkkhaki'}
else:
fill = {'x': y, 'y1': y1_(y), 'y2': y2 , 'color':'darkkhaki'}
return annotations, markers, load_eq, load_eq1, fill
def _draw_supports(self, length, l):
height = float(length/10)
support_markers = []
support_rectangles = []
for support in self._applied_supports:
if l:
pos = support[0].subs(l)
else:
pos = support[0]
if support[1] == "pin":
support_markers.append({'args':[pos, [0]], 'marker':6, 'markersize':13, 'color':"black"})
elif support[1] == "roller":
support_markers.append({'args':[pos, [-height/2.5]], 'marker':'o', 'markersize':11, 'color':"black"})
elif support[1] == "fixed":
if pos == 0:
support_rectangles.append({'xy':(0, -3*height), 'width':-length/20, 'height':6*height + height, 'fill':False, 'hatch':'/////'})
else:
support_rectangles.append({'xy':(length, -3*height), 'width':length/20, 'height': 6*height + height, 'fill':False, 'hatch':'/////'})
return support_markers, support_rectangles
class Beam3D(Beam):
"""
This class handles loads applied in any direction of a 3D space along
with unequal values of Second moment along different axes.
.. note::
While solving a beam bending problem, a user should choose its
own sign convention and should stick to it. The results will
automatically follow the chosen sign convention.
This class assumes that any kind of distributed load/moment is
applied through out the span of a beam.
Examples
========
There is a beam of l meters long. A constant distributed load of magnitude q
is applied along y-axis from start till the end of beam. A constant distributed
moment of magnitude m is also applied along z-axis from start till the end of beam.
Beam is fixed at both of its end. So, deflection of the beam at the both ends
is restricted.
>>> from sympy.physics.continuum_mechanics.beam import Beam3D
>>> from sympy import symbols, simplify, collect
>>> l, E, G, I, A = symbols('l, E, G, I, A')
>>> b = Beam3D(l, E, G, I, A)
>>> x, q, m = symbols('x, q, m')
>>> b.apply_load(q, 0, 0, dir="y")
>>> b.apply_moment_load(m, 0, -1, dir="z")
>>> b.shear_force()
[0, -q*x, 0]
>>> b.bending_moment()
[0, 0, -m*x + q*x**2/2]
>>> b.bc_slope = [(0, [0, 0, 0]), (l, [0, 0, 0])]
>>> b.bc_deflection = [(0, [0, 0, 0]), (l, [0, 0, 0])]
>>> b.solve_slope_deflection()
>>> b.slope()
[0, 0, x*(l*(-l*q + 3*l*(A*G*l**2*q - 2*A*G*l*m + 12*E*I*q)/(2*(A*G*l**2 + 12*E*I)) + 3*m)/6
+ q*x**2/6 + x*(-l*(A*G*l**2*q - 2*A*G*l*m + 12*E*I*q)/(2*(A*G*l**2 + 12*E*I)) - m)/2)/(E*I)]
>>> dx, dy, dz = b.deflection()
>>> dy = collect(simplify(dy), x)
>>> dx == dz == 0
True
>>> dy == (x*(12*A*E*G*I*l**3*q - 24*A*E*G*I*l**2*m + 144*E**2*I**2*l*q +
... x**3*(A**2*G**2*l**2*q + 12*A*E*G*I*q) +
... x**2*(-2*A**2*G**2*l**3*q - 24*A*E*G*I*l*q - 48*A*E*G*I*m) +
... x*(A**2*G**2*l**4*q + 72*A*E*G*I*l*m - 144*E**2*I**2*q)
... )/(24*A*E*G*I*(A*G*l**2 + 12*E*I)))
True
References
==========
.. [1] http://homes.civil.aau.dk/jc/FemteSemester/Beams3D.pdf
"""
def __init__(self, length, elastic_modulus, shear_modulus , second_moment, area, variable=Symbol('x')):
"""Initializes the class.
Parameters
==========
length : Sympifyable
A Symbol or value representing the Beam's length.
elastic_modulus : Sympifyable
A SymPy expression representing the Beam's Modulus of Elasticity.
It is a measure of the stiffness of the Beam material.
shear_modulus : Sympifyable
A SymPy expression representing the Beam's Modulus of rigidity.
It is a measure of rigidity of the Beam material.
second_moment : Sympifyable or list
A list of two elements having SymPy expression representing the
Beam's Second moment of area. First value represent Second moment
across y-axis and second across z-axis.
Single SymPy expression can be passed if both values are same
area : Sympifyable
A SymPy expression representing the Beam's cross-sectional area
in a plane prependicular to length of the Beam.
variable : Symbol, optional
A Symbol object that will be used as the variable along the beam
while representing the load, shear, moment, slope and deflection
curve. By default, it is set to ``Symbol('x')``.
"""
super(Beam3D, self).__init__(length, elastic_modulus, second_moment, variable)
self.shear_modulus = shear_modulus
self._area = area
self._load_vector = [0, 0, 0]
self._moment_load_vector = [0, 0, 0]
self._load_Singularity = [0, 0, 0]
self._slope = [0, 0, 0]
self._deflection = [0, 0, 0]
@property
def shear_modulus(self):
"""Young's Modulus of the Beam. """
return self._shear_modulus
@shear_modulus.setter
def shear_modulus(self, e):
self._shear_modulus = sympify(e)
@property
def second_moment(self):
"""Second moment of area of the Beam. """
return self._second_moment
@second_moment.setter
def second_moment(self, i):
if isinstance(i, list):
i = [sympify(x) for x in i]
self._second_moment = i
else:
self._second_moment = sympify(i)
@property
def area(self):
"""Cross-sectional area of the Beam. """
return self._area
@area.setter
def area(self, a):
self._area = sympify(a)
@property
def load_vector(self):
"""
Returns a three element list representing the load vector.
"""
return self._load_vector
@property
def moment_load_vector(self):
"""
Returns a three element list representing moment loads on Beam.
"""
return self._moment_load_vector
@property
def boundary_conditions(self):
"""
Returns a dictionary of boundary conditions applied on the beam.
The dictionary has two keywords namely slope and deflection.
The value of each keyword is a list of tuple, where each tuple
contains location and value of a boundary condition in the format
(location, value). Further each value is a list corresponding to
slope or deflection(s) values along three axes at that location.
Examples
========
There is a beam of length 4 meters. The slope at 0 should be 4 along
the x-axis and 0 along others. At the other end of beam, deflection
along all the three axes should be zero.
>>> from sympy.physics.continuum_mechanics.beam import Beam3D
>>> from sympy import symbols
>>> l, E, G, I, A, x = symbols('l, E, G, I, A, x')
>>> b = Beam3D(30, E, G, I, A, x)
>>> b.bc_slope = [(0, (4, 0, 0))]
>>> b.bc_deflection = [(4, [0, 0, 0])]
>>> b.boundary_conditions
{'deflection': [(4, [0, 0, 0])], 'slope': [(0, (4, 0, 0))]}
Here the deflection of the beam should be ``0`` along all the three axes at ``4``.
Similarly, the slope of the beam should be ``4`` along x-axis and ``0``
along y and z axis at ``0``.
"""
return self._boundary_conditions
def polar_moment(self):
"""
Returns the polar moment of area of the beam
about the X axis with respect to the centroid.
Examples
========
>>> from sympy.physics.continuum_mechanics.beam import Beam3D
>>> from sympy import symbols
>>> l, E, G, I, A = symbols('l, E, G, I, A')
>>> b = Beam3D(l, E, G, I, A)
>>> b.polar_moment()
2*I
>>> I1 = [9, 15]
>>> b = Beam3D(l, E, G, I1, A)
>>> b.polar_moment()
24
"""
if not iterable(self.second_moment):
return 2*self.second_moment
return sum(self.second_moment)
def apply_load(self, value, start, order, dir="y"):
"""
This method adds up the force load to a particular beam object.
Parameters
==========
value : Sympifyable
The magnitude of an applied load.
dir : String
Axis along which load is applied.
order : Integer
The order of the applied load.
- For point loads, order=-1
- For constant distributed load, order=0
- For ramp loads, order=1
- For parabolic ramp loads, order=2
- ... so on.
"""
x = self.variable
value = sympify(value)
start = sympify(start)
order = sympify(order)
if dir == "x":
if not order == -1:
self._load_vector[0] += value
self._load_Singularity[0] += value*SingularityFunction(x, start, order)
elif dir == "y":
if not order == -1:
self._load_vector[1] += value
self._load_Singularity[1] += value*SingularityFunction(x, start, order)
else:
if not order == -1:
self._load_vector[2] += value
self._load_Singularity[2] += value*SingularityFunction(x, start, order)
def apply_moment_load(self, value, start, order, dir="y"):
"""
This method adds up the moment loads to a particular beam object.
Parameters
==========
value : Sympifyable
The magnitude of an applied moment.
dir : String
Axis along which moment is applied.
order : Integer
The order of the applied load.
- For point moments, order=-2
- For constant distributed moment, order=-1
- For ramp moments, order=0
- For parabolic ramp moments, order=1
- ... so on.
"""
x = self.variable
value = sympify(value)
start = sympify(start)
order = sympify(order)
if dir == "x":
if not order == -2:
self._moment_load_vector[0] += value
self._load_Singularity[0] += value*SingularityFunction(x, start, order)
elif dir == "y":
if not order == -2:
self._moment_load_vector[1] += value
self._load_Singularity[0] += value*SingularityFunction(x, start, order)
else:
if not order == -2:
self._moment_load_vector[2] += value
self._load_Singularity[0] += value*SingularityFunction(x, start, order)
def apply_support(self, loc, type="fixed"):
if type == "pin" or type == "roller":
reaction_load = Symbol('R_'+str(loc))
self._reaction_loads[reaction_load] = reaction_load
self.bc_deflection.append((loc, [0, 0, 0]))
else:
reaction_load = Symbol('R_'+str(loc))
reaction_moment = Symbol('M_'+str(loc))
self._reaction_loads[reaction_load] = [reaction_load, reaction_moment]
self.bc_deflection.append((loc, [0, 0, 0]))
self.bc_slope.append((loc, [0, 0, 0]))
def solve_for_reaction_loads(self, *reaction):
"""
Solves for the reaction forces.
Examples
========
There is a beam of length 30 meters. It it supported by rollers at
of its end. A constant distributed load of magnitude 8 N is applied
from start till its end along y-axis. Another linear load having
slope equal to 9 is applied along z-axis.
>>> from sympy.physics.continuum_mechanics.beam import Beam3D
>>> from sympy import symbols
>>> l, E, G, I, A, x = symbols('l, E, G, I, A, x')
>>> b = Beam3D(30, E, G, I, A, x)
>>> b.apply_load(8, start=0, order=0, dir="y")
>>> b.apply_load(9*x, start=0, order=0, dir="z")
>>> b.bc_deflection = [(0, [0, 0, 0]), (30, [0, 0, 0])]
>>> R1, R2, R3, R4 = symbols('R1, R2, R3, R4')
>>> b.apply_load(R1, start=0, order=-1, dir="y")
>>> b.apply_load(R2, start=30, order=-1, dir="y")
>>> b.apply_load(R3, start=0, order=-1, dir="z")
>>> b.apply_load(R4, start=30, order=-1, dir="z")
>>> b.solve_for_reaction_loads(R1, R2, R3, R4)
>>> b.reaction_loads
{R1: -120, R2: -120, R3: -1350, R4: -2700}
"""
x = self.variable
l = self.length
q = self._load_Singularity
shear_curves = [integrate(load, x) for load in q]
moment_curves = [integrate(shear, x) for shear in shear_curves]
for i in range(3):
react = [r for r in reaction if (shear_curves[i].has(r) or moment_curves[i].has(r))]
if len(react) == 0:
continue
shear_curve = limit(shear_curves[i], x, l)
moment_curve = limit(moment_curves[i], x, l)
sol = list((linsolve([shear_curve, moment_curve], react).args)[0])
sol_dict = dict(zip(react, sol))
reaction_loads = self._reaction_loads
# Check if any of the evaluated rection exists in another direction
# and if it exists then it should have same value.
for key in sol_dict:
if key in reaction_loads and sol_dict[key] != reaction_loads[key]:
raise ValueError("Ambiguous solution for %s in different directions." % key)
self._reaction_loads.update(sol_dict)
def shear_force(self):
"""
Returns a list of three expressions which represents the shear force
curve of the Beam object along all three axes.
"""
x = self.variable
q = self._load_vector
return [integrate(-q[0], x), integrate(-q[1], x), integrate(-q[2], x)]
def axial_force(self):
"""
Returns expression of Axial shear force present inside the Beam object.
"""
return self.shear_force()[0]
def shear_stress(self):
"""
Returns a list of three expressions which represents the shear stress
curve of the Beam object along all three axes.
"""
return [self.shear_force()[0]/self._area, self.shear_force()[1]/self._area, self.shear_force()[2]/self._area]
def axial_stress(self):
"""
Returns expression of Axial stress present inside the Beam object.
"""
return self.axial_force()/self._area
def bending_moment(self):
"""
Returns a list of three expressions which represents the bending moment
curve of the Beam object along all three axes.
"""
x = self.variable
m = self._moment_load_vector
shear = self.shear_force()
return [integrate(-m[0], x), integrate(-m[1] + shear[2], x),
integrate(-m[2] - shear[1], x) ]
def torsional_moment(self):
"""
Returns expression of Torsional moment present inside the Beam object.
"""
return self.bending_moment()[0]
def solve_slope_deflection(self):
from sympy import dsolve, Function, Derivative, Eq
x = self.variable
l = self.length
E = self.elastic_modulus
G = self.shear_modulus
I = self.second_moment
if isinstance(I, list):
I_y, I_z = I[0], I[1]
else:
I_y = I_z = I
A = self._area
load = self._load_vector
moment = self._moment_load_vector
defl = Function('defl')
theta = Function('theta')
# Finding deflection along x-axis(and corresponding slope value by differentiating it)
# Equation used: Derivative(E*A*Derivative(def_x(x), x), x) + load_x = 0
eq = Derivative(E*A*Derivative(defl(x), x), x) + load[0]
def_x = dsolve(Eq(eq, 0), defl(x)).args[1]
# Solving constants originated from dsolve
C1 = Symbol('C1')
C2 = Symbol('C2')
constants = list((linsolve([def_x.subs(x, 0), def_x.subs(x, l)], C1, C2).args)[0])
def_x = def_x.subs({C1:constants[0], C2:constants[1]})
slope_x = def_x.diff(x)
self._deflection[0] = def_x
self._slope[0] = slope_x
# Finding deflection along y-axis and slope across z-axis. System of equation involved:
# 1: Derivative(E*I_z*Derivative(theta_z(x), x), x) + G*A*(Derivative(defl_y(x), x) - theta_z(x)) + moment_z = 0
# 2: Derivative(G*A*(Derivative(defl_y(x), x) - theta_z(x)), x) + load_y = 0
C_i = Symbol('C_i')
# Substitute value of `G*A*(Derivative(defl_y(x), x) - theta_z(x))` from (2) in (1)
eq1 = Derivative(E*I_z*Derivative(theta(x), x), x) + (integrate(-load[1], x) + C_i) + moment[2]
slope_z = dsolve(Eq(eq1, 0)).args[1]
# Solve for constants originated from using dsolve on eq1
constants = list((linsolve([slope_z.subs(x, 0), slope_z.subs(x, l)], C1, C2).args)[0])
slope_z = slope_z.subs({C1:constants[0], C2:constants[1]})
# Put value of slope obtained back in (2) to solve for `C_i` and find deflection across y-axis
eq2 = G*A*(Derivative(defl(x), x)) + load[1]*x - C_i - G*A*slope_z
def_y = dsolve(Eq(eq2, 0), defl(x)).args[1]
# Solve for constants originated from using dsolve on eq2
constants = list((linsolve([def_y.subs(x, 0), def_y.subs(x, l)], C1, C_i).args)[0])
self._deflection[1] = def_y.subs({C1:constants[0], C_i:constants[1]})
self._slope[2] = slope_z.subs(C_i, constants[1])
# Finding deflection along z-axis and slope across y-axis. System of equation involved:
# 1: Derivative(E*I_y*Derivative(theta_y(x), x), x) - G*A*(Derivative(defl_z(x), x) + theta_y(x)) + moment_y = 0
# 2: Derivative(G*A*(Derivative(defl_z(x), x) + theta_y(x)), x) + load_z = 0
# Substitute value of `G*A*(Derivative(defl_y(x), x) + theta_z(x))` from (2) in (1)
eq1 = Derivative(E*I_y*Derivative(theta(x), x), x) + (integrate(load[2], x) - C_i) + moment[1]
slope_y = dsolve(Eq(eq1, 0)).args[1]
# Solve for constants originated from using dsolve on eq1
constants = list((linsolve([slope_y.subs(x, 0), slope_y.subs(x, l)], C1, C2).args)[0])
slope_y = slope_y.subs({C1:constants[0], C2:constants[1]})
# Put value of slope obtained back in (2) to solve for `C_i` and find deflection across z-axis
eq2 = G*A*(Derivative(defl(x), x)) + load[2]*x - C_i + G*A*slope_y
def_z = dsolve(Eq(eq2,0)).args[1]
# Solve for constants originated from using dsolve on eq2
constants = list((linsolve([def_z.subs(x, 0), def_z.subs(x, l)], C1, C_i).args)[0])
self._deflection[2] = def_z.subs({C1:constants[0], C_i:constants[1]})
self._slope[1] = slope_y.subs(C_i, constants[1])
def slope(self):
"""
Returns a three element list representing slope of deflection curve
along all the three axes.
"""
return self._slope
def deflection(self):
"""
Returns a three element list representing deflection curve along all
the three axes.
"""
return self._deflection
|
1e439beb5fbf54ce404833b39e69f5fa56d90c2f9a2ee8374d53e936f45416d0 | from sympy import sqrt, exp, prod, Rational
from sympy.physics.quantum import Dagger, Commutator, qapply
from sympy.physics.quantum.boson import BosonOp
from sympy.physics.quantum.boson import (
BosonFockKet, BosonFockBra, BosonCoherentKet, BosonCoherentBra)
def test_bosonoperator():
a = BosonOp('a')
b = BosonOp('b')
assert isinstance(a, BosonOp)
assert isinstance(Dagger(a), BosonOp)
assert a.is_annihilation
assert not Dagger(a).is_annihilation
assert BosonOp("a") == BosonOp("a", True)
assert BosonOp("a") != BosonOp("c")
assert BosonOp("a", True) != BosonOp("a", False)
assert Commutator(a, Dagger(a)).doit() == 1
assert Commutator(a, Dagger(b)).doit() == a * Dagger(b) - Dagger(b) * a
assert Dagger(exp(a)) == exp(Dagger(a))
def test_boson_states():
a = BosonOp("a")
# Fock states
n = 3
assert (BosonFockBra(0) * BosonFockKet(1)).doit() == 0
assert (BosonFockBra(1) * BosonFockKet(1)).doit() == 1
assert qapply(BosonFockBra(n) * Dagger(a)**n * BosonFockKet(0)) \
== sqrt(prod(range(1, n+1)))
# Coherent states
alpha1, alpha2 = 1.2, 4.3
assert (BosonCoherentBra(alpha1) * BosonCoherentKet(alpha1)).doit() == 1
assert (BosonCoherentBra(alpha2) * BosonCoherentKet(alpha2)).doit() == 1
assert abs((BosonCoherentBra(alpha1) * BosonCoherentKet(alpha2)).doit() -
exp((alpha1 - alpha2) ** 2 * Rational(-1, 2))) < 1e-12
assert qapply(a * BosonCoherentKet(alpha1)) == \
alpha1 * BosonCoherentKet(alpha1)
|
68662da0bab7ec89c294281adc511799c028e35b7af7b97a15de1a1641360af1 | from sympy import I, symbols
from sympy.core.expr import unchanged
from sympy.matrices import Matrix, SparseMatrix
from sympy.physics.quantum.commutator import Commutator as Comm
from sympy.physics.quantum.tensorproduct import TensorProduct
from sympy.physics.quantum.tensorproduct import TensorProduct as TP
from sympy.physics.quantum.tensorproduct import tensor_product_simp
from sympy.physics.quantum.dagger import Dagger
from sympy.physics.quantum.qubit import Qubit, QubitBra
from sympy.physics.quantum.operator import OuterProduct
from sympy.physics.quantum.density import Density
from sympy.core.trace import Tr
A, B, C, D = symbols('A,B,C,D', commutative=False)
x = symbols('x')
mat1 = Matrix([[1, 2*I], [1 + I, 3]])
mat2 = Matrix([[2*I, 3], [4*I, 2]])
def test_sparse_matrices():
spm = SparseMatrix.diag(1, 0)
assert unchanged(TensorProduct, spm, spm)
def test_tensor_product_dagger():
assert Dagger(TensorProduct(I*A, B)) == \
-I*TensorProduct(Dagger(A), Dagger(B))
assert Dagger(TensorProduct(mat1, mat2)) == \
TensorProduct(Dagger(mat1), Dagger(mat2))
def test_tensor_product_abstract():
assert TP(x*A, 2*B) == x*2*TP(A, B)
assert TP(A, B) != TP(B, A)
assert TP(A, B).is_commutative is False
assert isinstance(TP(A, B), TP)
assert TP(A, B).subs(A, C) == TP(C, B)
def test_tensor_product_expand():
assert TP(A + B, B + C).expand(tensorproduct=True) == \
TP(A, B) + TP(A, C) + TP(B, B) + TP(B, C)
def test_tensor_product_commutator():
assert TP(Comm(A, B), C).doit().expand(tensorproduct=True) == \
TP(A*B, C) - TP(B*A, C)
assert Comm(TP(A, B), TP(B, C)).doit() == \
TP(A, B)*TP(B, C) - TP(B, C)*TP(A, B)
def test_tensor_product_simp():
assert tensor_product_simp(TP(A, B)*TP(B, C)) == TP(A*B, B*C)
# tests for Pow-expressions
assert tensor_product_simp(TP(A, B)**x) == TP(A**x, B**x)
assert tensor_product_simp(x*TP(A, B)**2) == x*TP(A**2,B**2)
assert tensor_product_simp(x*(TP(A, B)**2)*TP(C,D)) == x*TP(A**2*C,B**2*D)
assert tensor_product_simp(TP(A,B)-TP(C,D)**x) == TP(A,B)-TP(C**x,D**x)
def test_issue_5923():
# most of the issue regarding sympification of args has been handled
# and is tested internally by the use of args_cnc through the quantum
# module, but the following is a test from the issue that used to raise.
assert TensorProduct(1, Qubit('1')*Qubit('1').dual) == \
TensorProduct(1, OuterProduct(Qubit(1), QubitBra(1)))
def test_eval_trace():
# This test includes tests with dependencies between TensorProducts
#and density operators. Since, the test is more to test the behavior of
#TensorProducts it remains here
A, B, C, D, E, F = symbols('A B C D E F', commutative=False)
# Density with simple tensor products as args
t = TensorProduct(A, B)
d = Density([t, 1.0])
tr = Tr(d)
assert tr.doit() == 1.0*Tr(A*Dagger(A))*Tr(B*Dagger(B))
## partial trace with simple tensor products as args
t = TensorProduct(A, B, C)
d = Density([t, 1.0])
tr = Tr(d, [1])
assert tr.doit() == 1.0*A*Dagger(A)*Tr(B*Dagger(B))*C*Dagger(C)
tr = Tr(d, [0, 2])
assert tr.doit() == 1.0*Tr(A*Dagger(A))*B*Dagger(B)*Tr(C*Dagger(C))
# Density with multiple Tensorproducts as states
t2 = TensorProduct(A, B)
t3 = TensorProduct(C, D)
d = Density([t2, 0.5], [t3, 0.5])
t = Tr(d)
assert t.doit() == (0.5*Tr(A*Dagger(A))*Tr(B*Dagger(B)) +
0.5*Tr(C*Dagger(C))*Tr(D*Dagger(D)))
t = Tr(d, [0])
assert t.doit() == (0.5*Tr(A*Dagger(A))*B*Dagger(B) +
0.5*Tr(C*Dagger(C))*D*Dagger(D))
#Density with mixed states
d = Density([t2 + t3, 1.0])
t = Tr(d)
assert t.doit() == ( 1.0*Tr(A*Dagger(A))*Tr(B*Dagger(B)) +
1.0*Tr(A*Dagger(C))*Tr(B*Dagger(D)) +
1.0*Tr(C*Dagger(A))*Tr(D*Dagger(B)) +
1.0*Tr(C*Dagger(C))*Tr(D*Dagger(D)))
t = Tr(d, [1] )
assert t.doit() == ( 1.0*A*Dagger(A)*Tr(B*Dagger(B)) +
1.0*A*Dagger(C)*Tr(B*Dagger(D)) +
1.0*C*Dagger(A)*Tr(D*Dagger(B)) +
1.0*C*Dagger(C)*Tr(D*Dagger(D)))
|
4ba0d91a5be53e6e39f65609b2c9f6ae8315a433b51097799eaf179e5e48fe03 | from functools import wraps
from sympy import Matrix, eye, Integer, expand, Indexed, Sum
from sympy.combinatorics import Permutation
from sympy.core import S, Rational, Symbol, Basic, Add
from sympy.core.containers import Tuple
from sympy.core.symbol import symbols
from sympy.functions.elementary.miscellaneous import sqrt
from sympy.tensor.array import Array
from sympy.tensor.tensor import TensorIndexType, tensor_indices, TensorSymmetry, \
get_symmetric_group_sgs, TensorIndex, tensor_mul, TensAdd, \
riemann_cyclic_replace, riemann_cyclic, TensMul, tensor_heads, \
TensorManager, TensExpr, TensorHead, canon_bp, \
tensorhead, tensorsymmetry, TensorType, substitute_indices
from sympy.testing.pytest import raises, XFAIL, warns_deprecated_sympy, ignore_warnings
from sympy.utilities.exceptions import SymPyDeprecationWarning
from sympy.matrices import diag
def filter_warnings_decorator(f):
@wraps(f)
def wrapper():
with ignore_warnings(SymPyDeprecationWarning):
f()
return wrapper
def _is_equal(arg1, arg2):
if isinstance(arg1, TensExpr):
return arg1.equals(arg2)
elif isinstance(arg2, TensExpr):
return arg2.equals(arg1)
return arg1 == arg2
#################### Tests from tensor_can.py #######################
def test_canonicalize_no_slot_sym():
# A_d0 * B^d0; T_c = A^d0*B_d0
Lorentz = TensorIndexType('Lorentz', dummy_name='L')
a, b, d0, d1 = tensor_indices('a,b,d0,d1', Lorentz)
A, B = tensor_heads('A,B', [Lorentz], TensorSymmetry.no_symmetry(1))
t = A(-d0)*B(d0)
tc = t.canon_bp()
assert str(tc) == 'A(L_0)*B(-L_0)'
# A^a * B^b; T_c = T
t = A(a)*B(b)
tc = t.canon_bp()
assert tc == t
# B^b * A^a
t1 = B(b)*A(a)
tc = t1.canon_bp()
assert str(tc) == 'A(a)*B(b)'
# A symmetric
# A^{b}_{d0}*A^{d0, a}; T_c = A^{a d0}*A{b}_{d0}
A = TensorHead('A', [Lorentz]*2, TensorSymmetry.fully_symmetric(2))
t = A(b, -d0)*A(d0, a)
tc = t.canon_bp()
assert str(tc) == 'A(a, L_0)*A(b, -L_0)'
# A^{d1}_{d0}*B^d0*C_d1
# T_c = A^{d0 d1}*B_d0*C_d1
B, C = tensor_heads('B,C', [Lorentz], TensorSymmetry.no_symmetry(1))
t = A(d1, -d0)*B(d0)*C(-d1)
tc = t.canon_bp()
assert str(tc) == 'A(L_0, L_1)*B(-L_0)*C(-L_1)'
# A without symmetry
# A^{d1}_{d0}*B^d0*C_d1 ord=[d0,-d0,d1,-d1]; g = [2,1,0,3,4,5]
# T_c = A^{d0 d1}*B_d1*C_d0; can = [0,2,3,1,4,5]
A = TensorHead('A', [Lorentz]*2, TensorSymmetry.no_symmetry(2))
t = A(d1, -d0)*B(d0)*C(-d1)
tc = t.canon_bp()
assert str(tc) == 'A(L_0, L_1)*B(-L_1)*C(-L_0)'
# A, B without symmetry
# A^{d1}_{d0}*B_{d1}^{d0}
# T_c = A^{d0 d1}*B_{d0 d1}
B = TensorHead('B', [Lorentz]*2, TensorSymmetry.no_symmetry(2))
t = A(d1, -d0)*B(-d1, d0)
tc = t.canon_bp()
assert str(tc) == 'A(L_0, L_1)*B(-L_0, -L_1)'
# A_{d0}^{d1}*B_{d1}^{d0}
# T_c = A^{d0 d1}*B_{d1 d0}
t = A(-d0, d1)*B(-d1, d0)
tc = t.canon_bp()
assert str(tc) == 'A(L_0, L_1)*B(-L_1, -L_0)'
# A, B, C without symmetry
# A^{d1 d0}*B_{a d0}*C_{d1 b}
# T_c=A^{d0 d1}*B_{a d1}*C_{d0 b}
C = TensorHead('C', [Lorentz]*2, TensorSymmetry.no_symmetry(2))
t = A(d1, d0)*B(-a, -d0)*C(-d1, -b)
tc = t.canon_bp()
assert str(tc) == 'A(L_0, L_1)*B(-a, -L_1)*C(-L_0, -b)'
# A symmetric, B and C without symmetry
# A^{d1 d0}*B_{a d0}*C_{d1 b}
# T_c = A^{d0 d1}*B_{a d0}*C_{d1 b}
A = TensorHead('A', [Lorentz]*2, TensorSymmetry.fully_symmetric(2))
t = A(d1, d0)*B(-a, -d0)*C(-d1, -b)
tc = t.canon_bp()
assert str(tc) == 'A(L_0, L_1)*B(-a, -L_0)*C(-L_1, -b)'
# A and C symmetric, B without symmetry
# A^{d1 d0}*B_{a d0}*C_{d1 b} ord=[a,b,d0,-d0,d1,-d1]
# T_c = A^{d0 d1}*B_{a d0}*C_{b d1}
C = TensorHead('C', [Lorentz]*2, TensorSymmetry.fully_symmetric(2))
t = A(d1, d0)*B(-a, -d0)*C(-d1, -b)
tc = t.canon_bp()
assert str(tc) == 'A(L_0, L_1)*B(-a, -L_0)*C(-b, -L_1)'
def test_canonicalize_no_dummies():
Lorentz = TensorIndexType('Lorentz', dummy_name='L')
a, b, c, d = tensor_indices('a, b, c, d', Lorentz)
# A commuting
# A^c A^b A^a
# T_c = A^a A^b A^c
A = TensorHead('A', [Lorentz], TensorSymmetry.no_symmetry(1))
t = A(c)*A(b)*A(a)
tc = t.canon_bp()
assert str(tc) == 'A(a)*A(b)*A(c)'
# A anticommuting
# A^c A^b A^a
# T_c = -A^a A^b A^c
A = TensorHead('A', [Lorentz], TensorSymmetry.no_symmetry(1), 1)
t = A(c)*A(b)*A(a)
tc = t.canon_bp()
assert str(tc) == '-A(a)*A(b)*A(c)'
# A commuting and symmetric
# A^{b,d}*A^{c,a}
# T_c = A^{a c}*A^{b d}
A = TensorHead('A', [Lorentz]*2, TensorSymmetry.fully_symmetric(2))
t = A(b, d)*A(c, a)
tc = t.canon_bp()
assert str(tc) == 'A(a, c)*A(b, d)'
# A anticommuting and symmetric
# A^{b,d}*A^{c,a}
# T_c = -A^{a c}*A^{b d}
A = TensorHead('A', [Lorentz]*2, TensorSymmetry.fully_symmetric(2), 1)
t = A(b, d)*A(c, a)
tc = t.canon_bp()
assert str(tc) == '-A(a, c)*A(b, d)'
# A^{c,a}*A^{b,d}
# T_c = A^{a c}*A^{b d}
t = A(c, a)*A(b, d)
tc = t.canon_bp()
assert str(tc) == 'A(a, c)*A(b, d)'
def test_tensorhead_construction_without_symmetry():
L = TensorIndexType('Lorentz')
A1 = TensorHead('A', [L, L])
A2 = TensorHead('A', [L, L], TensorSymmetry.no_symmetry(2))
assert A1 == A2
A3 = TensorHead('A', [L, L], TensorSymmetry.fully_symmetric(2)) # Symmetric
assert A1 != A3
def test_no_metric_symmetry():
# no metric symmetry; A no symmetry
# A^d1_d0 * A^d0_d1
# T_c = A^d0_d1 * A^d1_d0
Lorentz = TensorIndexType('Lorentz', dummy_name='L', metric_symmetry=0)
d0, d1, d2, d3 = tensor_indices('d:4', Lorentz)
A = TensorHead('A', [Lorentz]*2, TensorSymmetry.no_symmetry(2))
t = A(d1, -d0)*A(d0, -d1)
tc = t.canon_bp()
assert str(tc) == 'A(L_0, -L_1)*A(L_1, -L_0)'
# A^d1_d2 * A^d0_d3 * A^d2_d1 * A^d3_d0
# T_c = A^d0_d1 * A^d1_d0 * A^d2_d3 * A^d3_d2
t = A(d1, -d2)*A(d0, -d3)*A(d2, -d1)*A(d3, -d0)
tc = t.canon_bp()
assert str(tc) == 'A(L_0, -L_1)*A(L_1, -L_0)*A(L_2, -L_3)*A(L_3, -L_2)'
# A^d0_d2 * A^d1_d3 * A^d3_d0 * A^d2_d1
# T_c = A^d0_d1 * A^d1_d2 * A^d2_d3 * A^d3_d0
t = A(d0, -d1)*A(d1, -d2)*A(d2, -d3)*A(d3, -d0)
tc = t.canon_bp()
assert str(tc) == 'A(L_0, -L_1)*A(L_1, -L_2)*A(L_2, -L_3)*A(L_3, -L_0)'
def test_canonicalize1():
Lorentz = TensorIndexType('Lorentz', dummy_name='L')
a, a0, a1, a2, a3, b, d0, d1, d2, d3 = \
tensor_indices('a,a0,a1,a2,a3,b,d0,d1,d2,d3', Lorentz)
# A_d0*A^d0; ord = [d0,-d0]
# T_c = A^d0*A_d0
A = TensorHead('A', [Lorentz], TensorSymmetry.no_symmetry(1))
t = A(-d0)*A(d0)
tc = t.canon_bp()
assert str(tc) == 'A(L_0)*A(-L_0)'
# A commuting
# A_d0*A_d1*A_d2*A^d2*A^d1*A^d0
# T_c = A^d0*A_d0*A^d1*A_d1*A^d2*A_d2
t = A(-d0)*A(-d1)*A(-d2)*A(d2)*A(d1)*A(d0)
tc = t.canon_bp()
assert str(tc) == 'A(L_0)*A(-L_0)*A(L_1)*A(-L_1)*A(L_2)*A(-L_2)'
# A anticommuting
# A_d0*A_d1*A_d2*A^d2*A^d1*A^d0
# T_c 0
A = TensorHead('A', [Lorentz], TensorSymmetry.no_symmetry(1), 1)
t = A(-d0)*A(-d1)*A(-d2)*A(d2)*A(d1)*A(d0)
tc = t.canon_bp()
assert tc == 0
# A commuting symmetric
# A^{d0 b}*A^a_d1*A^d1_d0
# T_c = A^{a d0}*A^{b d1}*A_{d0 d1}
A = TensorHead('A', [Lorentz]*2, TensorSymmetry.fully_symmetric(2))
t = A(d0, b)*A(a, -d1)*A(d1, -d0)
tc = t.canon_bp()
assert str(tc) == 'A(a, L_0)*A(b, L_1)*A(-L_0, -L_1)'
# A, B commuting symmetric
# A^{d0 b}*A^d1_d0*B^a_d1
# T_c = A^{b d0}*A_d0^d1*B^a_d1
B = TensorHead('B', [Lorentz]*2, TensorSymmetry.fully_symmetric(2))
t = A(d0, b)*A(d1, -d0)*B(a, -d1)
tc = t.canon_bp()
assert str(tc) == 'A(b, L_0)*A(-L_0, L_1)*B(a, -L_1)'
# A commuting symmetric
# A^{d1 d0 b}*A^{a}_{d1 d0}; ord=[a,b, d0,-d0,d1,-d1]
# T_c = A^{a d0 d1}*A^{b}_{d0 d1}
A = TensorHead('A', [Lorentz]*3, TensorSymmetry.fully_symmetric(3))
t = A(d1, d0, b)*A(a, -d1, -d0)
tc = t.canon_bp()
assert str(tc) == 'A(a, L_0, L_1)*A(b, -L_0, -L_1)'
# A^{d3 d0 d2}*A^a0_{d1 d2}*A^d1_d3^a1*A^{a2 a3}_d0
# T_c = A^{a0 d0 d1}*A^a1_d0^d2*A^{a2 a3 d3}*A_{d1 d2 d3}
t = A(d3, d0, d2)*A(a0, -d1, -d2)*A(d1, -d3, a1)*A(a2, a3, -d0)
tc = t.canon_bp()
assert str(tc) == 'A(a0, L_0, L_1)*A(a1, -L_0, L_2)*A(a2, a3, L_3)*A(-L_1, -L_2, -L_3)'
# A commuting symmetric, B antisymmetric
# A^{d0 d1 d2} * A_{d2 d3 d1} * B_d0^d3
# in this esxample and in the next three,
# renaming dummy indices and using symmetry of A,
# T = A^{d0 d1 d2} * A_{d0 d1 d3} * B_d2^d3
# can = 0
A = TensorHead('A', [Lorentz]*3, TensorSymmetry.fully_symmetric(3))
B = TensorHead('B', [Lorentz]*2, TensorSymmetry.fully_symmetric(-2))
t = A(d0, d1, d2)*A(-d2, -d3, -d1)*B(-d0, d3)
tc = t.canon_bp()
assert tc == 0
# A anticommuting symmetric, B antisymmetric
# A^{d0 d1 d2} * A_{d2 d3 d1} * B_d0^d3
# T_c = A^{d0 d1 d2} * A_{d0 d1}^d3 * B_{d2 d3}
A = TensorHead('A', [Lorentz]*3, TensorSymmetry.fully_symmetric(3), 1)
B = TensorHead('B', [Lorentz]*2, TensorSymmetry.fully_symmetric(-2))
t = A(d0, d1, d2)*A(-d2, -d3, -d1)*B(-d0, d3)
tc = t.canon_bp()
assert str(tc) == 'A(L_0, L_1, L_2)*A(-L_0, -L_1, L_3)*B(-L_2, -L_3)'
# A anticommuting symmetric, B antisymmetric commuting, antisymmetric metric
# A^{d0 d1 d2} * A_{d2 d3 d1} * B_d0^d3
# T_c = -A^{d0 d1 d2} * A_{d0 d1}^d3 * B_{d2 d3}
Spinor = TensorIndexType('Spinor', dummy_name='S', metric_symmetry=-1)
a, a0, a1, a2, a3, b, d0, d1, d2, d3 = \
tensor_indices('a,a0,a1,a2,a3,b,d0,d1,d2,d3', Spinor)
A = TensorHead('A', [Spinor]*3, TensorSymmetry.fully_symmetric(3), 1)
B = TensorHead('B', [Spinor]*2, TensorSymmetry.fully_symmetric(-2))
t = A(d0, d1, d2)*A(-d2, -d3, -d1)*B(-d0, d3)
tc = t.canon_bp()
assert str(tc) == '-A(S_0, S_1, S_2)*A(-S_0, -S_1, S_3)*B(-S_2, -S_3)'
# A anticommuting symmetric, B antisymmetric anticommuting,
# no metric symmetry
# A^{d0 d1 d2} * A_{d2 d3 d1} * B_d0^d3
# T_c = A^{d0 d1 d2} * A_{d0 d1 d3} * B_d2^d3
Mat = TensorIndexType('Mat', metric_symmetry=0, dummy_name='M')
a, a0, a1, a2, a3, b, d0, d1, d2, d3 = \
tensor_indices('a,a0,a1,a2,a3,b,d0,d1,d2,d3', Mat)
A = TensorHead('A', [Mat]*3, TensorSymmetry.fully_symmetric(3), 1)
B = TensorHead('B', [Mat]*2, TensorSymmetry.fully_symmetric(-2))
t = A(d0, d1, d2)*A(-d2, -d3, -d1)*B(-d0, d3)
tc = t.canon_bp()
assert str(tc) == 'A(M_0, M_1, M_2)*A(-M_0, -M_1, -M_3)*B(-M_2, M_3)'
# Gamma anticommuting
# Gamma_{mu nu} * gamma^rho * Gamma^{nu mu alpha}
# T_c = -Gamma^{mu nu} * gamma^rho * Gamma_{alpha mu nu}
alpha, beta, gamma, mu, nu, rho = \
tensor_indices('alpha,beta,gamma,mu,nu,rho', Lorentz)
Gamma = TensorHead('Gamma', [Lorentz],
TensorSymmetry.fully_symmetric(1), 2)
Gamma2 = TensorHead('Gamma', [Lorentz]*2,
TensorSymmetry.fully_symmetric(-2), 2)
Gamma3 = TensorHead('Gamma', [Lorentz]*3,
TensorSymmetry.fully_symmetric(-3), 2)
t = Gamma2(-mu, -nu)*Gamma(rho)*Gamma3(nu, mu, alpha)
tc = t.canon_bp()
assert str(tc) == '-Gamma(L_0, L_1)*Gamma(rho)*Gamma(alpha, -L_0, -L_1)'
# Gamma_{mu nu} * Gamma^{gamma beta} * gamma_rho * Gamma^{nu mu alpha}
# T_c = Gamma^{mu nu} * Gamma^{beta gamma} * gamma_rho * Gamma^alpha_{mu nu}
t = Gamma2(mu, nu)*Gamma2(beta, gamma)*Gamma(-rho)*Gamma3(alpha, -mu, -nu)
tc = t.canon_bp()
assert str(tc) == 'Gamma(L_0, L_1)*Gamma(beta, gamma)*Gamma(-rho)*Gamma(alpha, -L_0, -L_1)'
# f^a_{b,c} antisymmetric in b,c; A_mu^a no symmetry
# f^c_{d a} * f_{c e b} * A_mu^d * A_nu^a * A^{nu e} * A^{mu b}
# g = [8,11,5, 9,13,7, 1,10, 3,4, 2,12, 0,6, 14,15]
# T_c = -f^{a b c} * f_a^{d e} * A^mu_b * A_{mu d} * A^nu_c * A_{nu e}
Flavor = TensorIndexType('Flavor', dummy_name='F')
a, b, c, d, e, ff = tensor_indices('a,b,c,d,e,f', Flavor)
mu, nu = tensor_indices('mu,nu', Lorentz)
f = TensorHead('f', [Flavor]*3, TensorSymmetry.direct_product(1, -2))
A = TensorHead('A', [Lorentz, Flavor], TensorSymmetry.no_symmetry(2))
t = f(c, -d, -a)*f(-c, -e, -b)*A(-mu, d)*A(-nu, a)*A(nu, e)*A(mu, b)
tc = t.canon_bp()
assert str(tc) == '-f(F_0, F_1, F_2)*f(-F_0, F_3, F_4)*A(L_0, -F_1)*A(-L_0, -F_3)*A(L_1, -F_2)*A(-L_1, -F_4)'
def test_bug_correction_tensor_indices():
# to make sure that tensor_indices does not return a list if creating
# only one index:
A = TensorIndexType("A")
i = tensor_indices('i', A)
assert not isinstance(i, (tuple, list))
assert isinstance(i, TensorIndex)
def test_riemann_invariants():
Lorentz = TensorIndexType('Lorentz', dummy_name='L')
d0, d1, d2, d3, d4, d5, d6, d7, d8, d9, d10, d11 = \
tensor_indices('d0:12', Lorentz)
# R^{d0 d1}_{d1 d0}; ord = [d0,-d0,d1,-d1]
# T_c = -R^{d0 d1}_{d0 d1}
R = TensorHead('R', [Lorentz]*4, TensorSymmetry.riemann())
t = R(d0, d1, -d1, -d0)
tc = t.canon_bp()
assert str(tc) == '-R(L_0, L_1, -L_0, -L_1)'
# R_d11^d1_d0^d5 * R^{d6 d4 d0}_d5 * R_{d7 d2 d8 d9} *
# R_{d10 d3 d6 d4} * R^{d2 d7 d11}_d1 * R^{d8 d9 d3 d10}
# can = [0,2,4,6, 1,3,8,10, 5,7,12,14, 9,11,16,18, 13,15,20,22,
# 17,19,21<F10,23, 24,25]
# T_c = R^{d0 d1 d2 d3} * R_{d0 d1}^{d4 d5} * R_{d2 d3}^{d6 d7} *
# R_{d4 d5}^{d8 d9} * R_{d6 d7}^{d10 d11} * R_{d8 d9 d10 d11}
t = R(-d11,d1,-d0,d5)*R(d6,d4,d0,-d5)*R(-d7,-d2,-d8,-d9)* \
R(-d10,-d3,-d6,-d4)*R(d2,d7,d11,-d1)*R(d8,d9,d3,d10)
tc = t.canon_bp()
assert str(tc) == 'R(L_0, L_1, L_2, L_3)*R(-L_0, -L_1, L_4, L_5)*R(-L_2, -L_3, L_6, L_7)*R(-L_4, -L_5, L_8, L_9)*R(-L_6, -L_7, L_10, L_11)*R(-L_8, -L_9, -L_10, -L_11)'
def test_riemann_products():
Lorentz = TensorIndexType('Lorentz', dummy_name='L')
d0, d1, d2, d3, d4, d5, d6 = tensor_indices('d0:7', Lorentz)
a0, a1, a2, a3, a4, a5 = tensor_indices('a0:6', Lorentz)
a, b = tensor_indices('a,b', Lorentz)
R = TensorHead('R', [Lorentz]*4, TensorSymmetry.riemann())
# R^{a b d0}_d0 = 0
t = R(a, b, d0, -d0)
tc = t.canon_bp()
assert tc == 0
# R^{d0 b a}_d0
# T_c = -R^{a d0 b}_d0
t = R(d0, b, a, -d0)
tc = t.canon_bp()
assert str(tc) == '-R(a, L_0, b, -L_0)'
# R^d1_d2^b_d0 * R^{d0 a}_d1^d2; ord=[a,b,d0,-d0,d1,-d1,d2,-d2]
# T_c = -R^{a d0 d1 d2}* R^b_{d0 d1 d2}
t = R(d1, -d2, b, -d0)*R(d0, a, -d1, d2)
tc = t.canon_bp()
assert str(tc) == '-R(a, L_0, L_1, L_2)*R(b, -L_0, -L_1, -L_2)'
# A symmetric commuting
# R^{d6 d5}_d2^d1 * R^{d4 d0 d2 d3} * A_{d6 d0} A_{d3 d1} * A_{d4 d5}
# g = [12,10,5,2, 8,0,4,6, 13,1, 7,3, 9,11,14,15]
# T_c = -R^{d0 d1 d2 d3} * R_d0^{d4 d5 d6} * A_{d1 d4}*A_{d2 d5}*A_{d3 d6}
V = TensorHead('V', [Lorentz]*2, TensorSymmetry.fully_symmetric(2))
t = R(d6, d5, -d2, d1)*R(d4, d0, d2, d3)*V(-d6, -d0)*V(-d3, -d1)*V(-d4, -d5)
tc = t.canon_bp()
assert str(tc) == '-R(L_0, L_1, L_2, L_3)*R(-L_0, L_4, L_5, L_6)*V(-L_1, -L_4)*V(-L_2, -L_5)*V(-L_3, -L_6)'
# R^{d2 a0 a2 d0} * R^d1_d2^{a1 a3} * R^{a4 a5}_{d0 d1}
# T_c = R^{a0 d0 a2 d1}*R^{a1 a3}_d0^d2*R^{a4 a5}_{d1 d2}
t = R(d2, a0, a2, d0)*R(d1, -d2, a1, a3)*R(a4, a5, -d0, -d1)
tc = t.canon_bp()
assert str(tc) == 'R(a0, L_0, a2, L_1)*R(a1, a3, -L_0, L_2)*R(a4, a5, -L_1, -L_2)'
######################################################################
def test_canonicalize2():
D = Symbol('D')
Eucl = TensorIndexType('Eucl', metric_symmetry=1, dim=D, dummy_name='E')
i0,i1,i2,i3,i4,i5,i6,i7,i8,i9,i10,i11,i12,i13,i14 = \
tensor_indices('i0:15', Eucl)
A = TensorHead('A', [Eucl]*3, TensorSymmetry.fully_symmetric(-3))
# two examples from Cvitanovic, Group Theory page 59
# of identities for antisymmetric tensors of rank 3
# contracted according to the Kuratowski graph eq.(6.59)
t = A(i0,i1,i2)*A(-i1,i3,i4)*A(-i3,i7,i5)*A(-i2,-i5,i6)*A(-i4,-i6,i8)
t1 = t.canon_bp()
assert t1 == 0
# eq.(6.60)
#t = A(i0,i1,i2)*A(-i1,i3,i4)*A(-i2,i5,i6)*A(-i3,i7,i8)*A(-i6,-i7,i9)*
# A(-i8,i10,i13)*A(-i5,-i10,i11)*A(-i4,-i11,i12)*A(-i3,-i12,i14)
t = A(i0,i1,i2)*A(-i1,i3,i4)*A(-i2,i5,i6)*A(-i3,i7,i8)*A(-i6,-i7,i9)*\
A(-i8,i10,i13)*A(-i5,-i10,i11)*A(-i4,-i11,i12)*A(-i9,-i12,i14)
t1 = t.canon_bp()
assert t1 == 0
def test_canonicalize3():
D = Symbol('D')
Spinor = TensorIndexType('Spinor', dim=D, metric_symmetry=-1, dummy_name='S')
a0,a1,a2,a3,a4 = tensor_indices('a0:5', Spinor)
chi, psi = tensor_heads('chi,psi', [Spinor], TensorSymmetry.no_symmetry(1), 1)
t = chi(a1)*psi(a0)
t1 = t.canon_bp()
assert t1 == t
t = psi(a1)*chi(a0)
t1 = t.canon_bp()
assert t1 == -chi(a0)*psi(a1)
def test_TensorIndexType():
D = Symbol('D')
Lorentz = TensorIndexType('Lorentz', metric_name='g', metric_symmetry=1,
dim=D, dummy_name='L')
m0, m1, m2, m3, m4 = tensor_indices('m0:5', Lorentz)
sym2 = TensorSymmetry.fully_symmetric(2)
sym2n = TensorSymmetry(*get_symmetric_group_sgs(2))
assert sym2 == sym2n
g = Lorentz.metric
assert str(g) == 'g(Lorentz,Lorentz)'
assert Lorentz.eps_dim == Lorentz.dim
TSpace = TensorIndexType('TSpace', dummy_name = 'TSpace')
i0, i1 = tensor_indices('i0 i1', TSpace)
g = TSpace.metric
A = TensorHead('A', [TSpace]*2, sym2)
assert str(A(i0,-i0).canon_bp()) == 'A(TSpace_0, -TSpace_0)'
def test_indices():
Lorentz = TensorIndexType('Lorentz', dummy_name='L')
a, b, c, d = tensor_indices('a,b,c,d', Lorentz)
assert a.tensor_index_type == Lorentz
assert a != -a
A, B = tensor_heads('A B', [Lorentz]*2, TensorSymmetry.fully_symmetric(2))
t = A(a,b)*B(-b,c)
indices = t.get_indices()
L_0 = TensorIndex('L_0', Lorentz)
assert indices == [a, L_0, -L_0, c]
raises(ValueError, lambda: tensor_indices(3, Lorentz))
raises(ValueError, lambda: A(a,b,c))
def test_TensorSymmetry():
assert TensorSymmetry.fully_symmetric(2) == \
TensorSymmetry(get_symmetric_group_sgs(2))
assert TensorSymmetry.fully_symmetric(-3) == \
TensorSymmetry(get_symmetric_group_sgs(3, True))
assert TensorSymmetry.direct_product(-4) == \
TensorSymmetry.fully_symmetric(-4)
assert TensorSymmetry.fully_symmetric(-1) == \
TensorSymmetry.fully_symmetric(1)
assert TensorSymmetry.direct_product(1, -1, 1) == \
TensorSymmetry.no_symmetry(3)
assert TensorSymmetry(get_symmetric_group_sgs(2)) == \
TensorSymmetry(*get_symmetric_group_sgs(2))
# TODO: add check for *get_symmetric_group_sgs(0)
sym = TensorSymmetry.fully_symmetric(-3)
assert sym.rank == 3
assert sym.base == Tuple(0, 1)
assert sym.generators == Tuple(Permutation(0, 1)(3, 4), Permutation(1, 2)(3, 4))
def test_TensExpr():
Lorentz = TensorIndexType('Lorentz', dummy_name='L')
a, b, c, d = tensor_indices('a,b,c,d', Lorentz)
g = Lorentz.metric
A, B = tensor_heads('A B', [Lorentz]*2, TensorSymmetry.fully_symmetric(2))
raises(ValueError, lambda: g(c, d)/g(a, b))
raises(ValueError, lambda: S.One/g(a, b))
raises(ValueError, lambda: (A(c, d) + g(c, d))/g(a, b))
raises(ValueError, lambda: S.One/(A(c, d) + g(c, d)))
raises(ValueError, lambda: A(a, b) + A(a, c))
A(a, b) + B(a, b) # assigned to t for below
#raises(NotImplementedError, lambda: TensExpr.__mul__(t, 'a'))
#raises(NotImplementedError, lambda: TensExpr.__add__(t, 'a'))
#raises(NotImplementedError, lambda: TensExpr.__radd__(t, 'a'))
#raises(NotImplementedError, lambda: TensExpr.__sub__(t, 'a'))
#raises(NotImplementedError, lambda: TensExpr.__rsub__(t, 'a'))
#raises(NotImplementedError, lambda: TensExpr.__div__(t, 'a'))
#raises(NotImplementedError, lambda: TensExpr.__rdiv__(t, 'a'))
with ignore_warnings(SymPyDeprecationWarning):
# DO NOT REMOVE THIS AFTER DEPRECATION REMOVED:
raises(ValueError, lambda: A(a, b)**2)
raises(NotImplementedError, lambda: 2**A(a, b))
raises(NotImplementedError, lambda: abs(A(a, b)))
def test_TensorHead():
# simple example of algebraic expression
Lorentz = TensorIndexType('Lorentz', dummy_name='L')
A = TensorHead('A', [Lorentz]*2)
assert A.name == 'A'
assert A.index_types == [Lorentz, Lorentz]
assert A.rank == 2
assert A.symmetry == TensorSymmetry.no_symmetry(2)
assert A.comm == 0
def test_add1():
assert TensAdd().args == ()
assert TensAdd().doit() == 0
# simple example of algebraic expression
Lorentz = TensorIndexType('Lorentz', dummy_name='L')
a,b,d0,d1,i,j,k = tensor_indices('a,b,d0,d1,i,j,k', Lorentz)
# A, B symmetric
A, B = tensor_heads('A,B', [Lorentz]*2, TensorSymmetry.fully_symmetric(2))
t1 = A(b, -d0)*B(d0, a)
assert TensAdd(t1).equals(t1)
t2a = B(d0, a) + A(d0, a)
t2 = A(b, -d0)*t2a
assert str(t2) == 'A(b, -L_0)*(A(L_0, a) + B(L_0, a))'
t2 = t2.expand()
assert str(t2) == 'A(b, -L_0)*A(L_0, a) + A(b, -L_0)*B(L_0, a)'
t2 = t2.canon_bp()
assert str(t2) == 'A(a, L_0)*A(b, -L_0) + A(b, L_0)*B(a, -L_0)'
t2b = t2 + t1
assert str(t2b) == 'A(a, L_0)*A(b, -L_0) + A(b, -L_0)*B(L_0, a) + A(b, L_0)*B(a, -L_0)'
t2b = t2b.canon_bp()
assert str(t2b) == 'A(a, L_0)*A(b, -L_0) + 2*A(b, L_0)*B(a, -L_0)'
p, q, r = tensor_heads('p,q,r', [Lorentz])
t = q(d0)*2
assert str(t) == '2*q(d0)'
t = 2*q(d0)
assert str(t) == '2*q(d0)'
t1 = p(d0) + 2*q(d0)
assert str(t1) == '2*q(d0) + p(d0)'
t2 = p(-d0) + 2*q(-d0)
assert str(t2) == '2*q(-d0) + p(-d0)'
t1 = p(d0)
t3 = t1*t2
assert str(t3) == 'p(L_0)*(2*q(-L_0) + p(-L_0))'
t3 = t3.expand()
assert str(t3) == 'p(L_0)*p(-L_0) + 2*p(L_0)*q(-L_0)'
t3 = t2*t1
t3 = t3.expand()
assert str(t3) == 'p(-L_0)*p(L_0) + 2*q(-L_0)*p(L_0)'
t3 = t3.canon_bp()
assert str(t3) == 'p(L_0)*p(-L_0) + 2*p(L_0)*q(-L_0)'
t1 = p(d0) + 2*q(d0)
t3 = t1*t2
t3 = t3.canon_bp()
assert str(t3) == 'p(L_0)*p(-L_0) + 4*p(L_0)*q(-L_0) + 4*q(L_0)*q(-L_0)'
t1 = p(d0) - 2*q(d0)
assert str(t1) == '-2*q(d0) + p(d0)'
t2 = p(-d0) + 2*q(-d0)
t3 = t1*t2
t3 = t3.canon_bp()
assert t3 == p(d0)*p(-d0) - 4*q(d0)*q(-d0)
t = p(i)*p(j)*(p(k) + q(k)) + p(i)*(p(j) + q(j))*(p(k) - 3*q(k))
t = t.canon_bp()
assert t == 2*p(i)*p(j)*p(k) - 2*p(i)*p(j)*q(k) + p(i)*p(k)*q(j) - 3*p(i)*q(j)*q(k)
t1 = (p(i) + q(i) + 2*r(i))*(p(j) - q(j))
t2 = (p(j) + q(j) + 2*r(j))*(p(i) - q(i))
t = t1 + t2
t = t.canon_bp()
assert t == 2*p(i)*p(j) + 2*p(i)*r(j) + 2*p(j)*r(i) - 2*q(i)*q(j) - 2*q(i)*r(j) - 2*q(j)*r(i)
t = p(i)*q(j)/2
assert 2*t == p(i)*q(j)
t = (p(i) + q(i))/2
assert 2*t == p(i) + q(i)
t = S.One - p(i)*p(-i)
t = t.canon_bp()
tz1 = t + p(-j)*p(j)
assert tz1 != 1
tz1 = tz1.canon_bp()
assert tz1.equals(1)
t = S.One + p(i)*p(-i)
assert (t - p(-j)*p(j)).canon_bp().equals(1)
t = A(a, b) + B(a, b)
assert t.rank == 2
t1 = t - A(a, b) - B(a, b)
assert t1 == 0
t = 1 - (A(a, -a) + B(a, -a))
t1 = 1 + (A(a, -a) + B(a, -a))
assert (t + t1).expand().equals(2)
t2 = 1 + A(a, -a)
assert t1 != t2
assert t2 != TensMul.from_data(0, [], [], [])
def test_special_eq_ne():
# test special equality cases:
Lorentz = TensorIndexType('Lorentz', dummy_name='L')
a, b, d0, d1, i, j, k = tensor_indices('a,b,d0,d1,i,j,k', Lorentz)
# A, B symmetric
A, B = tensor_heads('A,B', [Lorentz]*2, TensorSymmetry.fully_symmetric(2))
p, q, r = tensor_heads('p,q,r', [Lorentz])
t = 0*A(a, b)
assert _is_equal(t, 0)
assert _is_equal(t, S.Zero)
assert p(i) != A(a, b)
assert A(a, -a) != A(a, b)
assert 0*(A(a, b) + B(a, b)) == 0
assert 0*(A(a, b) + B(a, b)) is S.Zero
assert 3*(A(a, b) - A(a, b)) is S.Zero
assert p(i) + q(i) != A(a, b)
assert p(i) + q(i) != A(a, b) + B(a, b)
assert p(i) - p(i) == 0
assert p(i) - p(i) is S.Zero
assert _is_equal(A(a, b), A(b, a))
def test_add2():
Lorentz = TensorIndexType('Lorentz', dummy_name='L')
m, n, p, q = tensor_indices('m,n,p,q', Lorentz)
R = TensorHead('R', [Lorentz]*4, TensorSymmetry.riemann())
A = TensorHead('A', [Lorentz]*3, TensorSymmetry.fully_symmetric(-3))
t1 = 2*R(m, n, p, q) - R(m, q, n, p) + R(m, p, n, q)
t2 = t1*A(-n, -p, -q)
t2 = t2.canon_bp()
assert t2 == 0
t1 = Rational(2, 3)*R(m,n,p,q) - Rational(1, 3)*R(m,q,n,p) + Rational(1, 3)*R(m,p,n,q)
t2 = t1*A(-n, -p, -q)
t2 = t2.canon_bp()
assert t2 == 0
t = A(m, -m, n) + A(n, p, -p)
t = t.canon_bp()
assert t == 0
def test_add3():
Lorentz = TensorIndexType('Lorentz', dummy_name='L')
i0, i1 = tensor_indices('i0:2', Lorentz)
E, px, py, pz = symbols('E px py pz')
A = TensorHead('A', [Lorentz])
B = TensorHead('B', [Lorentz])
expr1 = A(i0)*A(-i0) - (E**2 - px**2 - py**2 - pz**2)
assert expr1.args == (-E**2, px**2, py**2, pz**2, A(i0)*A(-i0))
expr2 = E**2 - px**2 - py**2 - pz**2 - A(i0)*A(-i0)
assert expr2.args == (E**2, -px**2, -py**2, -pz**2, -A(i0)*A(-i0))
expr3 = A(i0)*A(-i0) - E**2 + px**2 + py**2 + pz**2
assert expr3.args == (-E**2, px**2, py**2, pz**2, A(i0)*A(-i0))
expr4 = B(i1)*B(-i1) + 2*E**2 - 2*px**2 - 2*py**2 - 2*pz**2 - A(i0)*A(-i0)
assert expr4.args == (2*E**2, -2*px**2, -2*py**2, -2*pz**2, B(i1)*B(-i1), -A(i0)*A(-i0))
def test_mul():
from sympy.abc import x
Lorentz = TensorIndexType('Lorentz', dummy_name='L')
a, b, c, d = tensor_indices('a,b,c,d', Lorentz)
t = TensMul.from_data(S.One, [], [], [])
assert str(t) == '1'
A, B = tensor_heads('A B', [Lorentz]*2, TensorSymmetry.fully_symmetric(2))
t = (1 + x)*A(a, b)
assert str(t) == '(x + 1)*A(a, b)'
assert t.index_types == [Lorentz, Lorentz]
assert t.rank == 2
assert t.dum == []
assert t.coeff == 1 + x
assert sorted(t.free) == [(a, 0), (b, 1)]
assert t.components == [A]
ts = A(a, b)
assert str(ts) == 'A(a, b)'
assert ts.index_types == [Lorentz, Lorentz]
assert ts.rank == 2
assert ts.dum == []
assert ts.coeff == 1
assert sorted(ts.free) == [(a, 0), (b, 1)]
assert ts.components == [A]
t = A(-b, a)*B(-a, c)*A(-c, d)
t1 = tensor_mul(*t.split())
assert t == t1
assert tensor_mul(*[]) == TensMul.from_data(S.One, [], [], [])
t = TensMul.from_data(1, [], [], [])
C = TensorHead('C', [])
assert str(C()) == 'C'
assert str(t) == '1'
assert t == 1
raises(ValueError, lambda: A(a, b)*A(a, c))
def test_substitute_indices():
Lorentz = TensorIndexType('Lorentz', dummy_name='L')
i, j, k, l, m, n, p, q = tensor_indices('i,j,k,l,m,n,p,q', Lorentz)
A, B = tensor_heads('A,B', [Lorentz]*2, TensorSymmetry.fully_symmetric(2))
p = TensorHead('p', [Lorentz])
t = p(i)
t1 = t.substitute_indices((j, k))
assert t1 == t
t1 = t.substitute_indices((i, j))
assert t1 == p(j)
t1 = t.substitute_indices((i, -j))
assert t1 == p(-j)
t1 = t.substitute_indices((-i, j))
assert t1 == p(-j)
t1 = t.substitute_indices((-i, -j))
assert t1 == p(j)
t = A(m, n)
t1 = t.substitute_indices((m, i), (n, -i))
assert t1 == A(n, -n)
t1 = substitute_indices(t, (m, i), (n, -i))
assert t1 == A(n, -n)
t = A(i, k)*B(-k, -j)
t1 = t.substitute_indices((i, j), (j, k))
t1a = A(j, l)*B(-l, -k)
assert t1 == t1a
t1 = substitute_indices(t, (i, j), (j, k))
assert t1 == t1a
t = A(i, j) + B(i, j)
t1 = t.substitute_indices((j, -i))
t1a = A(i, -i) + B(i, -i)
assert t1 == t1a
t1 = substitute_indices(t, (j, -i))
assert t1 == t1a
def test_riemann_cyclic_replace():
Lorentz = TensorIndexType('Lorentz', dummy_name='L')
m0, m1, m2, m3 = tensor_indices('m:4', Lorentz)
R = TensorHead('R', [Lorentz]*4, TensorSymmetry.riemann())
t = R(m0, m2, m1, m3)
t1 = riemann_cyclic_replace(t)
t1a = Rational(-1, 3)*R(m0, m3, m2, m1) + Rational(1, 3)*R(m0, m1, m2, m3) + Rational(2, 3)*R(m0, m2, m1, m3)
assert t1 == t1a
def test_riemann_cyclic():
Lorentz = TensorIndexType('Lorentz', dummy_name='L')
i, j, k, l, m, n, p, q = tensor_indices('i,j,k,l,m,n,p,q', Lorentz)
R = TensorHead('R', [Lorentz]*4, TensorSymmetry.riemann())
t = R(i,j,k,l) + R(i,l,j,k) + R(i,k,l,j) - \
R(i,j,l,k) - R(i,l,k,j) - R(i,k,j,l)
t2 = t*R(-i,-j,-k,-l)
t3 = riemann_cyclic(t2)
assert t3 == 0
t = R(i,j,k,l)*(R(-i,-j,-k,-l) - 2*R(-i,-k,-j,-l))
t1 = riemann_cyclic(t)
assert t1 == 0
t = R(i,j,k,l)
t1 = riemann_cyclic(t)
assert t1 == Rational(-1, 3)*R(i, l, j, k) + Rational(1, 3)*R(i, k, j, l) + Rational(2, 3)*R(i, j, k, l)
t = R(i,j,k,l)*R(-k,-l,m,n)*(R(-m,-n,-i,-j) + 2*R(-m,-j,-n,-i))
t1 = riemann_cyclic(t)
assert t1 == 0
@XFAIL
def test_div():
Lorentz = TensorIndexType('Lorentz', dummy_name='L')
m0, m1, m2, m3 = tensor_indices('m0:4', Lorentz)
R = TensorHead('R', [Lorentz]*4, TensorSymmetry.riemann())
t = R(m0,m1,-m1,m3)
t1 = t/S(4)
assert str(t1) == '(1/4)*R(m0, L_0, -L_0, m3)'
t = t.canon_bp()
assert not t1._is_canon_bp
t1 = t*4
assert t1._is_canon_bp
t1 = t1/4
assert t1._is_canon_bp
def test_contract_metric1():
D = Symbol('D')
Lorentz = TensorIndexType('Lorentz', dim=D, dummy_name='L')
a, b, c, d, e = tensor_indices('a,b,c,d,e', Lorentz)
g = Lorentz.metric
p = TensorHead('p', [Lorentz])
t = g(a, b)*p(-b)
t1 = t.contract_metric(g)
assert t1 == p(a)
A, B = tensor_heads('A,B', [Lorentz]*2, TensorSymmetry.fully_symmetric(2))
# case with g with all free indices
t1 = A(a,b)*B(-b,c)*g(d, e)
t2 = t1.contract_metric(g)
assert t1 == t2
# case of g(d, -d)
t1 = A(a,b)*B(-b,c)*g(-d, d)
t2 = t1.contract_metric(g)
assert t2 == D*A(a, d)*B(-d, c)
# g with one free index
t1 = A(a,b)*B(-b,-c)*g(c, d)
t2 = t1.contract_metric(g)
assert t2 == A(a, c)*B(-c, d)
# g with both indices contracted with another tensor
t1 = A(a,b)*B(-b,-c)*g(c, -a)
t2 = t1.contract_metric(g)
assert _is_equal(t2, A(a, b)*B(-b, -a))
t1 = A(a,b)*B(-b,-c)*g(c, d)*g(-a, -d)
t2 = t1.contract_metric(g)
assert _is_equal(t2, A(a,b)*B(-b,-a))
t1 = A(a,b)*g(-a,-b)
t2 = t1.contract_metric(g)
assert _is_equal(t2, A(a, -a))
assert not t2.free
Lorentz = TensorIndexType('Lorentz', dummy_name='L')
a, b = tensor_indices('a,b', Lorentz)
g = Lorentz.metric
assert _is_equal(g(a, -a).contract_metric(g), Lorentz.dim) # no dim
def test_contract_metric2():
D = Symbol('D')
Lorentz = TensorIndexType('Lorentz', dim=D, dummy_name='L')
a, b, c, d, e, L_0 = tensor_indices('a,b,c,d,e,L_0', Lorentz)
g = Lorentz.metric
p, q = tensor_heads('p,q', [Lorentz])
t1 = g(a,b)*p(c)*p(-c)
t2 = 3*g(-a,-b)*q(c)*q(-c)
t = t1*t2
t = t.contract_metric(g)
assert t == 3*D*p(a)*p(-a)*q(b)*q(-b)
t1 = g(a,b)*p(c)*p(-c)
t2 = 3*q(-a)*q(-b)
t = t1*t2
t = t.contract_metric(g)
t = t.canon_bp()
assert t == 3*p(a)*p(-a)*q(b)*q(-b)
t1 = 2*g(a,b)*p(c)*p(-c)
t2 = - 3*g(-a,-b)*q(c)*q(-c)
t = t1*t2
t = t.contract_metric(g)
t = 6*g(a,b)*g(-a,-b)*p(c)*p(-c)*q(d)*q(-d)
t = t.contract_metric(g)
t1 = 2*g(a,b)*p(c)*p(-c)
t2 = q(-a)*q(-b) + 3*g(-a,-b)*q(c)*q(-c)
t = t1*t2
t = t.contract_metric(g)
assert t == (2 + 6*D)*p(a)*p(-a)*q(b)*q(-b)
t1 = p(a)*p(b) + p(a)*q(b) + 2*g(a,b)*p(c)*p(-c)
t2 = q(-a)*q(-b) - g(-a,-b)*q(c)*q(-c)
t = t1*t2
t = t.contract_metric(g)
t1 = (1 - 2*D)*p(a)*p(-a)*q(b)*q(-b) + p(a)*q(-a)*p(b)*q(-b)
assert canon_bp(t - t1) == 0
t = g(a,b)*g(c,d)*g(-b,-c)
t1 = t.contract_metric(g)
assert t1 == g(a, d)
t1 = g(a,b)*g(c,d) + g(a,c)*g(b,d) + g(a,d)*g(b,c)
t2 = t1.substitute_indices((a,-a),(b,-b),(c,-c),(d,-d))
t = t1*t2
t = t.contract_metric(g)
assert t.equals(3*D**2 + 6*D)
t = 2*p(a)*g(b,-b)
t1 = t.contract_metric(g)
assert t1.equals(2*D*p(a))
t = 2*p(a)*g(b,-a)
t1 = t.contract_metric(g)
assert t1 == 2*p(b)
M = Symbol('M')
t = (p(a)*p(b) + g(a, b)*M**2)*g(-a, -b) - D*M**2
t1 = t.contract_metric(g)
assert t1 == p(a)*p(-a)
A = TensorHead('A', [Lorentz]*2, TensorSymmetry.fully_symmetric(2))
t = A(a, b)*p(L_0)*g(-a, -b)
t1 = t.contract_metric(g)
assert str(t1) == 'A(L_1, -L_1)*p(L_0)' or str(t1) == 'A(-L_1, L_1)*p(L_0)'
def test_metric_contract3():
D = Symbol('D')
Spinor = TensorIndexType('Spinor', dim=D, metric_symmetry=-1, dummy_name='S')
a0, a1, a2, a3, a4 = tensor_indices('a0:5', Spinor)
C = Spinor.metric
chi, psi = tensor_heads('chi,psi', [Spinor], TensorSymmetry.no_symmetry(1), 1)
B = TensorHead('B', [Spinor]*2, TensorSymmetry.no_symmetry(2))
t = C(a0,-a0)
t1 = t.contract_metric(C)
assert t1.equals(-D)
t = C(-a0,a0)
t1 = t.contract_metric(C)
assert t1.equals(D)
t = C(a0,a1)*C(-a0,-a1)
t1 = t.contract_metric(C)
assert t1.equals(D)
t = C(a1,a0)*C(-a0,-a1)
t1 = t.contract_metric(C)
assert t1.equals(-D)
t = C(-a0,a1)*C(a0,-a1)
t1 = t.contract_metric(C)
assert t1.equals(-D)
t = C(a1,-a0)*C(a0,-a1)
t1 = t.contract_metric(C)
assert t1.equals(D)
t = C(a0,a1)*B(-a1,-a0)
t1 = t.contract_metric(C)
t1 = t1.canon_bp()
assert _is_equal(t1, B(a0,-a0))
t = C(a1,a0)*B(-a1,-a0)
t1 = t.contract_metric(C)
assert _is_equal(t1, -B(a0,-a0))
t = C(a0,-a1)*B(a1,-a0)
t1 = t.contract_metric(C)
assert _is_equal(t1, -B(a0,-a0))
t = C(-a0,a1)*B(-a1,a0)
t1 = t.contract_metric(C)
assert _is_equal(t1, -B(a0,-a0))
t = C(-a0,-a1)*B(a1,a0)
t1 = t.contract_metric(C)
assert _is_equal(t1, B(a0,-a0))
t = C(-a1, a0)*B(a1,-a0)
t1 = t.contract_metric(C)
assert _is_equal(t1, B(a0,-a0))
t = C(a0,a1)*psi(-a1)
t1 = t.contract_metric(C)
assert _is_equal(t1, psi(a0))
t = C(a1,a0)*psi(-a1)
t1 = t.contract_metric(C)
assert _is_equal(t1, -psi(a0))
t = C(a0,a1)*chi(-a0)*psi(-a1)
t1 = t.contract_metric(C)
assert _is_equal(t1, -chi(a1)*psi(-a1))
t = C(a1,a0)*chi(-a0)*psi(-a1)
t1 = t.contract_metric(C)
assert _is_equal(t1, chi(a1)*psi(-a1))
t = C(-a1,a0)*chi(-a0)*psi(a1)
t1 = t.contract_metric(C)
assert _is_equal(t1, chi(-a1)*psi(a1))
t = C(a0,-a1)*chi(-a0)*psi(a1)
t1 = t.contract_metric(C)
assert _is_equal(t1, -chi(-a1)*psi(a1))
t = C(-a0,-a1)*chi(a0)*psi(a1)
t1 = t.contract_metric(C)
assert _is_equal(t1, chi(-a1)*psi(a1))
t = C(-a1,-a0)*chi(a0)*psi(a1)
t1 = t.contract_metric(C)
assert _is_equal(t1, -chi(-a1)*psi(a1))
t = C(-a1,-a0)*B(a0,a2)*psi(a1)
t1 = t.contract_metric(C)
assert _is_equal(t1, -B(-a1,a2)*psi(a1))
t = C(a1,a0)*B(-a2,-a0)*psi(-a1)
t1 = t.contract_metric(C)
assert _is_equal(t1, B(-a2,a1)*psi(-a1))
def test_epsilon():
Lorentz = TensorIndexType('Lorentz', dim=4, dummy_name='L')
a, b, c, d, e = tensor_indices('a,b,c,d,e', Lorentz)
epsilon = Lorentz.epsilon
p, q, r, s = tensor_heads('p,q,r,s', [Lorentz])
t = epsilon(b,a,c,d)
t1 = t.canon_bp()
assert t1 == -epsilon(a,b,c,d)
t = epsilon(c,b,d,a)
t1 = t.canon_bp()
assert t1 == epsilon(a,b,c,d)
t = epsilon(c,a,d,b)
t1 = t.canon_bp()
assert t1 == -epsilon(a,b,c,d)
t = epsilon(a,b,c,d)*p(-a)*q(-b)
t1 = t.canon_bp()
assert t1 == epsilon(c,d,a,b)*p(-a)*q(-b)
t = epsilon(c,b,d,a)*p(-a)*q(-b)
t1 = t.canon_bp()
assert t1 == epsilon(c,d,a,b)*p(-a)*q(-b)
t = epsilon(c,a,d,b)*p(-a)*q(-b)
t1 = t.canon_bp()
assert t1 == -epsilon(c,d,a,b)*p(-a)*q(-b)
t = epsilon(c,a,d,b)*p(-a)*p(-b)
t1 = t.canon_bp()
assert t1 == 0
t = epsilon(c,a,d,b)*p(-a)*q(-b) + epsilon(a,b,c,d)*p(-b)*q(-a)
t1 = t.canon_bp()
assert t1 == -2*epsilon(c,d,a,b)*p(-a)*q(-b)
# Test that epsilon can be create with a SymPy integer:
Lorentz = TensorIndexType('Lorentz', dim=Integer(4), dummy_name='L')
epsilon = Lorentz.epsilon
assert isinstance(epsilon, TensorHead)
def test_contract_delta1():
# see Group Theory by Cvitanovic page 9
n = Symbol('n')
Color = TensorIndexType('Color', dim=n, dummy_name='C')
a, b, c, d, e, f = tensor_indices('a,b,c,d,e,f', Color)
delta = Color.delta
def idn(a, b, d, c):
assert a.is_up and d.is_up
assert not (b.is_up or c.is_up)
return delta(a,c)*delta(d,b)
def T(a, b, d, c):
assert a.is_up and d.is_up
assert not (b.is_up or c.is_up)
return delta(a,b)*delta(d,c)
def P1(a, b, c, d):
return idn(a,b,c,d) - 1/n*T(a,b,c,d)
def P2(a, b, c, d):
return 1/n*T(a,b,c,d)
t = P1(a, -b, e, -f)*P1(f, -e, d, -c)
t1 = t.contract_delta(delta)
assert canon_bp(t1 - P1(a, -b, d, -c)) == 0
t = P2(a, -b, e, -f)*P2(f, -e, d, -c)
t1 = t.contract_delta(delta)
assert t1 == P2(a, -b, d, -c)
t = P1(a, -b, e, -f)*P2(f, -e, d, -c)
t1 = t.contract_delta(delta)
assert t1 == 0
t = P1(a, -b, b, -a)
t1 = t.contract_delta(delta)
assert t1.equals(n**2 - 1)
@filter_warnings_decorator
def test_fun():
D = Symbol('D')
Lorentz = TensorIndexType('Lorentz', dim=D, dummy_name='L')
a, b, c, d, e = tensor_indices('a,b,c,d,e', Lorentz)
g = Lorentz.metric
p, q = tensor_heads('p q', [Lorentz])
t = q(c)*p(a)*q(b) + g(a,b)*g(c,d)*q(-d)
assert t(a,b,c) == t
assert canon_bp(t - t(b,a,c) - q(c)*p(a)*q(b) + q(c)*p(b)*q(a)) == 0
assert t(b,c,d) == q(d)*p(b)*q(c) + g(b,c)*g(d,e)*q(-e)
t1 = t.substitute_indices((a,b),(b,a))
assert canon_bp(t1 - q(c)*p(b)*q(a) - g(a,b)*g(c,d)*q(-d)) == 0
# check that g_{a b; c} = 0
# example taken from L. Brewin
# "A brief introduction to Cadabra" arxiv:0903.2085
# dg_{a b c} = \partial_{a} g_{b c} is symmetric in b, c
dg = TensorHead('dg', [Lorentz]*3, TensorSymmetry.direct_product(1, 2))
# gamma^a_{b c} is the Christoffel symbol
gamma = S.Half*g(a,d)*(dg(-b,-d,-c) + dg(-c,-b,-d) - dg(-d,-b,-c))
# t = g_{a b; c}
t = dg(-c,-a,-b) - g(-a,-d)*gamma(d,-b,-c) - g(-b,-d)*gamma(d,-a,-c)
t = t.contract_metric(g)
assert t == 0
t = q(c)*p(a)*q(b)
assert t(b,c,d) == q(d)*p(b)*q(c)
def test_TensorManager():
Lorentz = TensorIndexType('Lorentz', dummy_name='L')
LorentzH = TensorIndexType('LorentzH', dummy_name='LH')
i, j = tensor_indices('i,j', Lorentz)
ih, jh = tensor_indices('ih,jh', LorentzH)
p, q = tensor_heads('p q', [Lorentz])
ph, qh = tensor_heads('ph qh', [LorentzH])
Gsymbol = Symbol('Gsymbol')
GHsymbol = Symbol('GHsymbol')
TensorManager.set_comm(Gsymbol, GHsymbol, 0)
G = TensorHead('G', [Lorentz], TensorSymmetry.no_symmetry(1), Gsymbol)
assert TensorManager._comm_i2symbol[G.comm] == Gsymbol
GH = TensorHead('GH', [LorentzH], TensorSymmetry.no_symmetry(1), GHsymbol)
ps = G(i)*p(-i)
psh = GH(ih)*ph(-ih)
t = ps + psh
t1 = t*t
assert canon_bp(t1 - ps*ps - 2*ps*psh - psh*psh) == 0
qs = G(i)*q(-i)
qsh = GH(ih)*qh(-ih)
assert _is_equal(ps*qsh, qsh*ps)
assert not _is_equal(ps*qs, qs*ps)
n = TensorManager.comm_symbols2i(Gsymbol)
assert TensorManager.comm_i2symbol(n) == Gsymbol
assert GHsymbol in TensorManager._comm_symbols2i
raises(ValueError, lambda: TensorManager.set_comm(GHsymbol, 1, 2))
TensorManager.set_comms((Gsymbol,GHsymbol,0),(Gsymbol,1,1))
assert TensorManager.get_comm(n, 1) == TensorManager.get_comm(1, n) == 1
TensorManager.clear()
assert TensorManager.comm == [{0:0, 1:0, 2:0}, {0:0, 1:1, 2:None}, {0:0, 1:None}]
assert GHsymbol not in TensorManager._comm_symbols2i
nh = TensorManager.comm_symbols2i(GHsymbol)
assert TensorManager.comm_i2symbol(nh) == GHsymbol
assert GHsymbol in TensorManager._comm_symbols2i
def test_hash():
D = Symbol('D')
Lorentz = TensorIndexType('Lorentz', dim=D, dummy_name='L')
a, b, c, d, e = tensor_indices('a,b,c,d,e', Lorentz)
g = Lorentz.metric
p, q = tensor_heads('p q', [Lorentz])
p_type = p.args[1]
t1 = p(a)*q(b)
t2 = p(a)*p(b)
assert hash(t1) != hash(t2)
t3 = p(a)*p(b) + g(a,b)
t4 = p(a)*p(b) - g(a,b)
assert hash(t3) != hash(t4)
assert a.func(*a.args) == a
assert Lorentz.func(*Lorentz.args) == Lorentz
assert g.func(*g.args) == g
assert p.func(*p.args) == p
assert p_type.func(*p_type.args) == p_type
assert p(a).func(*(p(a)).args) == p(a)
assert t1.func(*t1.args) == t1
assert t2.func(*t2.args) == t2
assert t3.func(*t3.args) == t3
assert t4.func(*t4.args) == t4
assert hash(a.func(*a.args)) == hash(a)
assert hash(Lorentz.func(*Lorentz.args)) == hash(Lorentz)
assert hash(g.func(*g.args)) == hash(g)
assert hash(p.func(*p.args)) == hash(p)
assert hash(p_type.func(*p_type.args)) == hash(p_type)
assert hash(p(a).func(*(p(a)).args)) == hash(p(a))
assert hash(t1.func(*t1.args)) == hash(t1)
assert hash(t2.func(*t2.args)) == hash(t2)
assert hash(t3.func(*t3.args)) == hash(t3)
assert hash(t4.func(*t4.args)) == hash(t4)
def check_all(obj):
return all([isinstance(_, Basic) for _ in obj.args])
assert check_all(a)
assert check_all(Lorentz)
assert check_all(g)
assert check_all(p)
assert check_all(p_type)
assert check_all(p(a))
assert check_all(t1)
assert check_all(t2)
assert check_all(t3)
assert check_all(t4)
tsymmetry = TensorSymmetry.direct_product(-2, 1, 3)
assert tsymmetry.func(*tsymmetry.args) == tsymmetry
assert hash(tsymmetry.func(*tsymmetry.args)) == hash(tsymmetry)
assert check_all(tsymmetry)
### TEST VALUED TENSORS ###
def _get_valued_base_test_variables():
minkowski = Matrix((
(1, 0, 0, 0),
(0, -1, 0, 0),
(0, 0, -1, 0),
(0, 0, 0, -1),
))
Lorentz = TensorIndexType('Lorentz', dim=4)
Lorentz.data = minkowski
i0, i1, i2, i3, i4 = tensor_indices('i0:5', Lorentz)
E, px, py, pz = symbols('E px py pz')
A = TensorHead('A', [Lorentz])
A.data = [E, px, py, pz]
B = TensorHead('B', [Lorentz], TensorSymmetry.no_symmetry(1), 'Gcomm')
B.data = range(4)
AB = TensorHead("AB", [Lorentz]*2)
AB.data = minkowski
ba_matrix = Matrix((
(1, 2, 3, 4),
(5, 6, 7, 8),
(9, 0, -1, -2),
(-3, -4, -5, -6),
))
BA = TensorHead("BA", [Lorentz]*2)
BA.data = ba_matrix
# Let's test the diagonal metric, with inverted Minkowski metric:
LorentzD = TensorIndexType('LorentzD')
LorentzD.data = [-1, 1, 1, 1]
mu0, mu1, mu2 = tensor_indices('mu0:3', LorentzD)
C = TensorHead('C', [LorentzD])
C.data = [E, px, py, pz]
### non-diagonal metric ###
ndm_matrix = (
(1, 1, 0,),
(1, 0, 1),
(0, 1, 0,),
)
ndm = TensorIndexType("ndm")
ndm.data = ndm_matrix
n0, n1, n2 = tensor_indices('n0:3', ndm)
NA = TensorHead('NA', [ndm])
NA.data = range(10, 13)
NB = TensorHead('NB', [ndm]*2)
NB.data = [[i+j for j in range(10, 13)] for i in range(10, 13)]
NC = TensorHead('NC', [ndm]*3)
NC.data = [[[i+j+k for k in range(4, 7)] for j in range(1, 4)] for i in range(2, 5)]
return (A, B, AB, BA, C, Lorentz, E, px, py, pz, LorentzD, mu0, mu1, mu2, ndm, n0, n1,
n2, NA, NB, NC, minkowski, ba_matrix, ndm_matrix, i0, i1, i2, i3, i4)
@filter_warnings_decorator
def test_valued_tensor_iter():
(A, B, AB, BA, C, Lorentz, E, px, py, pz, LorentzD, mu0, mu1, mu2, ndm, n0, n1,
n2, NA, NB, NC, minkowski, ba_matrix, ndm_matrix, i0, i1, i2, i3, i4) = _get_valued_base_test_variables()
list_BA = [Array([1, 2, 3, 4]), Array([5, 6, 7, 8]), Array([9, 0, -1, -2]), Array([-3, -4, -5, -6])]
# iteration on VTensorHead
assert list(A) == [E, px, py, pz]
assert list(ba_matrix) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, -1, -2, -3, -4, -5, -6]
assert list(BA) == list_BA
# iteration on VTensMul
assert list(A(i1)) == [E, px, py, pz]
assert list(BA(i1, i2)) == list_BA
assert list(3 * BA(i1, i2)) == [3 * i for i in list_BA]
assert list(-5 * BA(i1, i2)) == [-5 * i for i in list_BA]
# iteration on VTensAdd
# A(i1) + A(i1)
assert list(A(i1) + A(i1)) == [2*E, 2*px, 2*py, 2*pz]
assert BA(i1, i2) - BA(i1, i2) == 0
assert list(BA(i1, i2) - 2 * BA(i1, i2)) == [-i for i in list_BA]
@filter_warnings_decorator
def test_valued_tensor_covariant_contravariant_elements():
(A, B, AB, BA, C, Lorentz, E, px, py, pz, LorentzD, mu0, mu1, mu2, ndm, n0, n1,
n2, NA, NB, NC, minkowski, ba_matrix, ndm_matrix, i0, i1, i2, i3, i4) = _get_valued_base_test_variables()
assert A(-i0)[0] == A(i0)[0]
assert A(-i0)[1] == -A(i0)[1]
assert AB(i0, i1)[1, 1] == -1
assert AB(i0, -i1)[1, 1] == 1
assert AB(-i0, -i1)[1, 1] == -1
assert AB(-i0, i1)[1, 1] == 1
@filter_warnings_decorator
def test_valued_tensor_get_matrix():
(A, B, AB, BA, C, Lorentz, E, px, py, pz, LorentzD, mu0, mu1, mu2, ndm, n0, n1,
n2, NA, NB, NC, minkowski, ba_matrix, ndm_matrix, i0, i1, i2, i3, i4) = _get_valued_base_test_variables()
matab = AB(i0, i1).get_matrix()
assert matab == Matrix([
[1, 0, 0, 0],
[0, -1, 0, 0],
[0, 0, -1, 0],
[0, 0, 0, -1],
])
# when alternating contravariant/covariant with [1, -1, -1, -1] metric
# it becomes the identity matrix:
assert AB(i0, -i1).get_matrix() == eye(4)
# covariant and contravariant forms:
assert A(i0).get_matrix() == Matrix([E, px, py, pz])
assert A(-i0).get_matrix() == Matrix([E, -px, -py, -pz])
@filter_warnings_decorator
def test_valued_tensor_contraction():
(A, B, AB, BA, C, Lorentz, E, px, py, pz, LorentzD, mu0, mu1, mu2, ndm, n0, n1,
n2, NA, NB, NC, minkowski, ba_matrix, ndm_matrix, i0, i1, i2, i3, i4) = _get_valued_base_test_variables()
assert (A(i0) * A(-i0)).data == E ** 2 - px ** 2 - py ** 2 - pz ** 2
assert (A(i0) * A(-i0)).data == A ** 2
assert (A(i0) * A(-i0)).data == A(i0) ** 2
assert (A(i0) * B(-i0)).data == -px - 2 * py - 3 * pz
for i in range(4):
for j in range(4):
assert (A(i0) * B(-i1))[i, j] == [E, px, py, pz][i] * [0, -1, -2, -3][j]
# test contraction on the alternative Minkowski metric: [-1, 1, 1, 1]
assert (C(mu0) * C(-mu0)).data == -E ** 2 + px ** 2 + py ** 2 + pz ** 2
contrexp = A(i0) * AB(i1, -i0)
assert A(i0).rank == 1
assert AB(i1, -i0).rank == 2
assert contrexp.rank == 1
for i in range(4):
assert contrexp[i] == [E, px, py, pz][i]
@filter_warnings_decorator
def test_valued_tensor_self_contraction():
(A, B, AB, BA, C, Lorentz, E, px, py, pz, LorentzD, mu0, mu1, mu2, ndm, n0, n1,
n2, NA, NB, NC, minkowski, ba_matrix, ndm_matrix, i0, i1, i2, i3, i4) = _get_valued_base_test_variables()
assert AB(i0, -i0).data == 4
assert BA(i0, -i0).data == 2
@filter_warnings_decorator
def test_valued_tensor_pow():
(A, B, AB, BA, C, Lorentz, E, px, py, pz, LorentzD, mu0, mu1, mu2, ndm, n0, n1,
n2, NA, NB, NC, minkowski, ba_matrix, ndm_matrix, i0, i1, i2, i3, i4) = _get_valued_base_test_variables()
assert C**2 == -E**2 + px**2 + py**2 + pz**2
assert C**1 == sqrt(-E**2 + px**2 + py**2 + pz**2)
assert C(mu0)**2 == C**2
assert C(mu0)**1 == C**1
@filter_warnings_decorator
def test_valued_tensor_expressions():
(A, B, AB, BA, C, Lorentz, E, px, py, pz, LorentzD, mu0, mu1, mu2, ndm, n0, n1,
n2, NA, NB, NC, minkowski, ba_matrix, ndm_matrix, i0, i1, i2, i3, i4) = _get_valued_base_test_variables()
x1, x2, x3 = symbols('x1:4')
# test coefficient in contraction:
rank2coeff = x1 * A(i3) * B(i2)
assert rank2coeff[1, 1] == x1 * px
assert rank2coeff[3, 3] == 3 * pz * x1
coeff_expr = ((x1 * A(i4)) * (B(-i4) / x2)).data
assert coeff_expr.expand() == -px*x1/x2 - 2*py*x1/x2 - 3*pz*x1/x2
add_expr = A(i0) + B(i0)
assert add_expr[0] == E
assert add_expr[1] == px + 1
assert add_expr[2] == py + 2
assert add_expr[3] == pz + 3
sub_expr = A(i0) - B(i0)
assert sub_expr[0] == E
assert sub_expr[1] == px - 1
assert sub_expr[2] == py - 2
assert sub_expr[3] == pz - 3
assert (add_expr * B(-i0)).data == -px - 2*py - 3*pz - 14
expr1 = x1*A(i0) + x2*B(i0)
expr2 = expr1 * B(i1) * (-4)
expr3 = expr2 + 3*x3*AB(i0, i1)
expr4 = expr3 / 2
assert expr4 * 2 == expr3
expr5 = (expr4 * BA(-i1, -i0))
assert expr5.data.expand() == 28*E*x1 + 12*px*x1 + 20*py*x1 + 28*pz*x1 + 136*x2 + 3*x3
@filter_warnings_decorator
def test_valued_tensor_add_scalar():
(A, B, AB, BA, C, Lorentz, E, px, py, pz, LorentzD, mu0, mu1, mu2, ndm, n0, n1,
n2, NA, NB, NC, minkowski, ba_matrix, ndm_matrix, i0, i1, i2, i3, i4) = _get_valued_base_test_variables()
# one scalar summand after the contracted tensor
expr1 = A(i0)*A(-i0) - (E**2 - px**2 - py**2 - pz**2)
assert expr1.data == 0
# multiple scalar summands in front of the contracted tensor
expr2 = E**2 - px**2 - py**2 - pz**2 - A(i0)*A(-i0)
assert expr2.data == 0
# multiple scalar summands after the contracted tensor
expr3 = A(i0)*A(-i0) - E**2 + px**2 + py**2 + pz**2
assert expr3.data == 0
# multiple scalar summands and multiple tensors
expr4 = C(mu0)*C(-mu0) + 2*E**2 - 2*px**2 - 2*py**2 - 2*pz**2 - A(i0)*A(-i0)
assert expr4.data == 0
@filter_warnings_decorator
def test_noncommuting_components():
(A, B, AB, BA, C, Lorentz, E, px, py, pz, LorentzD, mu0, mu1, mu2, ndm, n0, n1,
n2, NA, NB, NC, minkowski, ba_matrix, ndm_matrix, i0, i1, i2, i3, i4) = _get_valued_base_test_variables()
euclid = TensorIndexType('Euclidean')
euclid.data = [1, 1]
i1, i2, i3 = tensor_indices('i1:4', euclid)
a, b, c, d = symbols('a b c d', commutative=False)
V1 = TensorHead('V1', [euclid]*2)
V1.data = [[a, b], (c, d)]
V2 = TensorHead('V2', [euclid]*2)
V2.data = [[a, c], [b, d]]
vtp = V1(i1, i2) * V2(-i2, -i1)
assert vtp.data == a**2 + b**2 + c**2 + d**2
assert vtp.data != a**2 + 2*b*c + d**2
vtp2 = V1(i1, i2)*V1(-i2, -i1)
assert vtp2.data == a**2 + b*c + c*b + d**2
assert vtp2.data != a**2 + 2*b*c + d**2
Vc = (b * V1(i1, -i1)).data
assert Vc.expand() == b * a + b * d
@filter_warnings_decorator
def test_valued_non_diagonal_metric():
(A, B, AB, BA, C, Lorentz, E, px, py, pz, LorentzD, mu0, mu1, mu2, ndm, n0, n1,
n2, NA, NB, NC, minkowski, ba_matrix, ndm_matrix, i0, i1, i2, i3, i4) = _get_valued_base_test_variables()
mmatrix = Matrix(ndm_matrix)
assert (NA(n0)*NA(-n0)).data == (NA(n0).get_matrix().T * mmatrix * NA(n0).get_matrix())[0, 0]
@filter_warnings_decorator
def test_valued_assign_numpy_ndarray():
(A, B, AB, BA, C, Lorentz, E, px, py, pz, LorentzD, mu0, mu1, mu2, ndm, n0, n1,
n2, NA, NB, NC, minkowski, ba_matrix, ndm_matrix, i0, i1, i2, i3, i4) = _get_valued_base_test_variables()
# this is needed to make sure that a numpy.ndarray can be assigned to a
# tensor.
arr = [E+1, px-1, py, pz]
A.data = Array(arr)
for i in range(4):
assert A(i0).data[i] == arr[i]
qx, qy, qz = symbols('qx qy qz')
A(-i0).data = Array([E, qx, qy, qz])
for i in range(4):
assert A(i0).data[i] == [E, -qx, -qy, -qz][i]
assert A.data[i] == [E, -qx, -qy, -qz][i]
# test on multi-indexed tensors.
random_4x4_data = [[(i**3-3*i**2)%(j+7) for i in range(4)] for j in range(4)]
AB(-i0, -i1).data = random_4x4_data
for i in range(4):
for j in range(4):
assert AB(i0, i1).data[i, j] == random_4x4_data[i][j]*(-1 if i else 1)*(-1 if j else 1)
assert AB(-i0, i1).data[i, j] == random_4x4_data[i][j]*(-1 if j else 1)
assert AB(i0, -i1).data[i, j] == random_4x4_data[i][j]*(-1 if i else 1)
assert AB(-i0, -i1).data[i, j] == random_4x4_data[i][j]
AB(-i0, i1).data = random_4x4_data
for i in range(4):
for j in range(4):
assert AB(i0, i1).data[i, j] == random_4x4_data[i][j]*(-1 if i else 1)
assert AB(-i0, i1).data[i, j] == random_4x4_data[i][j]
assert AB(i0, -i1).data[i, j] == random_4x4_data[i][j]*(-1 if i else 1)*(-1 if j else 1)
assert AB(-i0, -i1).data[i, j] == random_4x4_data[i][j]*(-1 if j else 1)
@filter_warnings_decorator
def test_valued_metric_inverse():
(A, B, AB, BA, C, Lorentz, E, px, py, pz, LorentzD, mu0, mu1, mu2, ndm, n0, n1,
n2, NA, NB, NC, minkowski, ba_matrix, ndm_matrix, i0, i1, i2, i3, i4) = _get_valued_base_test_variables()
# let's assign some fancy matrix, just to verify it:
# (this has no physical sense, it's just testing sympy);
# it is symmetrical:
md = [[2, 2, 2, 1], [2, 3, 1, 0], [2, 1, 2, 3], [1, 0, 3, 2]]
Lorentz.data = md
m = Matrix(md)
metric = Lorentz.metric
minv = m.inv()
meye = eye(4)
# the Kronecker Delta:
KD = Lorentz.get_kronecker_delta()
for i in range(4):
for j in range(4):
assert metric(i0, i1).data[i, j] == m[i, j]
assert metric(-i0, -i1).data[i, j] == minv[i, j]
assert metric(i0, -i1).data[i, j] == meye[i, j]
assert metric(-i0, i1).data[i, j] == meye[i, j]
assert metric(i0, i1)[i, j] == m[i, j]
assert metric(-i0, -i1)[i, j] == minv[i, j]
assert metric(i0, -i1)[i, j] == meye[i, j]
assert metric(-i0, i1)[i, j] == meye[i, j]
assert KD(i0, -i1)[i, j] == meye[i, j]
@filter_warnings_decorator
def test_valued_canon_bp_swapaxes():
(A, B, AB, BA, C, Lorentz, E, px, py, pz, LorentzD, mu0, mu1, mu2, ndm, n0, n1,
n2, NA, NB, NC, minkowski, ba_matrix, ndm_matrix, i0, i1, i2, i3, i4) = _get_valued_base_test_variables()
e1 = A(i1)*A(i0)
e2 = e1.canon_bp()
assert e2 == A(i0)*A(i1)
for i in range(4):
for j in range(4):
assert e1[i, j] == e2[j, i]
o1 = B(i2)*A(i1)*B(i0)
o2 = o1.canon_bp()
for i in range(4):
for j in range(4):
for k in range(4):
assert o1[i, j, k] == o2[j, i, k]
@filter_warnings_decorator
def test_valued_components_with_wrong_symmetry():
IT = TensorIndexType('IT', dim=3)
i0, i1, i2, i3 = tensor_indices('i0:4', IT)
IT.data = [1, 1, 1]
A_nosym = TensorHead('A', [IT]*2)
A_sym = TensorHead('A', [IT]*2, TensorSymmetry.fully_symmetric(2))
A_antisym = TensorHead('A', [IT]*2, TensorSymmetry.fully_symmetric(-2))
mat_nosym = Matrix([[1,2,3],[4,5,6],[7,8,9]])
mat_sym = mat_nosym + mat_nosym.T
mat_antisym = mat_nosym - mat_nosym.T
A_nosym.data = mat_nosym
A_nosym.data = mat_sym
A_nosym.data = mat_antisym
def assign(A, dat):
A.data = dat
A_sym.data = mat_sym
raises(ValueError, lambda: assign(A_sym, mat_nosym))
raises(ValueError, lambda: assign(A_sym, mat_antisym))
A_antisym.data = mat_antisym
raises(ValueError, lambda: assign(A_antisym, mat_sym))
raises(ValueError, lambda: assign(A_antisym, mat_nosym))
A_sym.data = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
A_antisym.data = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
@filter_warnings_decorator
def test_issue_10972_TensMul_data():
Lorentz = TensorIndexType('Lorentz', metric_symmetry=1, dummy_name='i', dim=2)
Lorentz.data = [-1, 1]
mu, nu, alpha, beta = tensor_indices('\\mu, \\nu, \\alpha, \\beta',
Lorentz)
u = TensorHead('u', [Lorentz])
u.data = [1, 0]
F = TensorHead('F', [Lorentz]*2, TensorSymmetry.fully_symmetric(-2))
F.data = [[0, 1],
[-1, 0]]
mul_1 = F(mu, alpha) * u(-alpha) * F(nu, beta) * u(-beta)
assert (mul_1.data == Array([[0, 0], [0, 1]]))
mul_2 = F(mu, alpha) * F(nu, beta) * u(-alpha) * u(-beta)
assert (mul_2.data == mul_1.data)
assert ((mul_1 + mul_1).data == 2 * mul_1.data)
@filter_warnings_decorator
def test_TensMul_data():
Lorentz = TensorIndexType('Lorentz', metric_symmetry=1, dummy_name='L', dim=4)
Lorentz.data = [-1, 1, 1, 1]
mu, nu, alpha, beta = tensor_indices('\\mu, \\nu, \\alpha, \\beta',
Lorentz)
u = TensorHead('u', [Lorentz])
u.data = [1, 0, 0, 0]
F = TensorHead('F', [Lorentz]*2, TensorSymmetry.fully_symmetric(-2))
Ex, Ey, Ez, Bx, By, Bz = symbols('E_x E_y E_z B_x B_y B_z')
F.data = [
[0, Ex, Ey, Ez],
[-Ex, 0, Bz, -By],
[-Ey, -Bz, 0, Bx],
[-Ez, By, -Bx, 0]]
E = F(mu, nu) * u(-nu)
assert ((E(mu) * E(nu)).data ==
Array([[0, 0, 0, 0],
[0, Ex ** 2, Ex * Ey, Ex * Ez],
[0, Ex * Ey, Ey ** 2, Ey * Ez],
[0, Ex * Ez, Ey * Ez, Ez ** 2]])
)
assert ((E(mu) * E(nu)).canon_bp().data == (E(mu) * E(nu)).data)
assert ((F(mu, alpha) * F(beta, nu) * u(-alpha) * u(-beta)).data ==
- (E(mu) * E(nu)).data
)
assert ((F(alpha, mu) * F(beta, nu) * u(-alpha) * u(-beta)).data ==
(E(mu) * E(nu)).data
)
g = TensorHead('g', [Lorentz]*2, TensorSymmetry.fully_symmetric(2))
g.data = Lorentz.data
# tensor 'perp' is orthogonal to vector 'u'
perp = u(mu) * u(nu) + g(mu, nu)
mul_1 = u(-mu) * perp(mu, nu)
assert (mul_1.data == Array([0, 0, 0, 0]))
mul_2 = u(-mu) * perp(mu, alpha) * perp(nu, beta)
assert (mul_2.data == Array.zeros(4, 4, 4))
Fperp = perp(mu, alpha) * perp(nu, beta) * F(-alpha, -beta)
assert (Fperp.data[0, :] == Array([0, 0, 0, 0]))
assert (Fperp.data[:, 0] == Array([0, 0, 0, 0]))
mul_3 = u(-mu) * Fperp(mu, nu)
assert (mul_3.data == Array([0, 0, 0, 0]))
@filter_warnings_decorator
def test_issue_11020_TensAdd_data():
Lorentz = TensorIndexType('Lorentz', metric_symmetry=1, dummy_name='i', dim=2)
Lorentz.data = [-1, 1]
a, b, c, d = tensor_indices('a, b, c, d', Lorentz)
i0, i1 = tensor_indices('i_0:2', Lorentz)
# metric tensor
g = TensorHead('g', [Lorentz]*2, TensorSymmetry.fully_symmetric(2))
g.data = Lorentz.data
u = TensorHead('u', [Lorentz])
u.data = [1, 0]
add_1 = g(b, c) * g(d, i0) * u(-i0) - g(b, c) * u(d)
assert (add_1.data == Array.zeros(2, 2, 2))
# Now let us replace index `d` with `a`:
add_2 = g(b, c) * g(a, i0) * u(-i0) - g(b, c) * u(a)
assert (add_2.data == Array.zeros(2, 2, 2))
# some more tests
# perp is tensor orthogonal to u^\mu
perp = u(a) * u(b) + g(a, b)
mul_1 = u(-a) * perp(a, b)
assert (mul_1.data == Array([0, 0]))
mul_2 = u(-c) * perp(c, a) * perp(d, b)
assert (mul_2.data == Array.zeros(2, 2, 2))
def test_index_iteration():
L = TensorIndexType("Lorentz", dummy_name="L")
i0, i1, i2, i3, i4 = tensor_indices('i0:5', L)
L0 = tensor_indices('L_0', L)
L1 = tensor_indices('L_1', L)
A = TensorHead("A", [L, L])
B = TensorHead("B", [L, L], TensorSymmetry.fully_symmetric(2))
e1 = A(i0,i2)
e2 = A(i0,-i0)
e3 = A(i0,i1)*B(i2,i3)
e4 = A(i0,i1)*B(i2,-i1)
e5 = A(i0,i1)*B(-i0,-i1)
e6 = e1 + e4
assert list(e1._iterate_free_indices) == [(i0, (1, 0)), (i2, (1, 1))]
assert list(e1._iterate_dummy_indices) == []
assert list(e1._iterate_indices) == [(i0, (1, 0)), (i2, (1, 1))]
assert list(e2._iterate_free_indices) == []
assert list(e2._iterate_dummy_indices) == [(L0, (1, 0)), (-L0, (1, 1))]
assert list(e2._iterate_indices) == [(L0, (1, 0)), (-L0, (1, 1))]
assert list(e3._iterate_free_indices) == [(i0, (0, 1, 0)), (i1, (0, 1, 1)), (i2, (1, 1, 0)), (i3, (1, 1, 1))]
assert list(e3._iterate_dummy_indices) == []
assert list(e3._iterate_indices) == [(i0, (0, 1, 0)), (i1, (0, 1, 1)), (i2, (1, 1, 0)), (i3, (1, 1, 1))]
assert list(e4._iterate_free_indices) == [(i0, (0, 1, 0)), (i2, (1, 1, 0))]
assert list(e4._iterate_dummy_indices) == [(L0, (0, 1, 1)), (-L0, (1, 1, 1))]
assert list(e4._iterate_indices) == [(i0, (0, 1, 0)), (L0, (0, 1, 1)), (i2, (1, 1, 0)), (-L0, (1, 1, 1))]
assert list(e5._iterate_free_indices) == []
assert list(e5._iterate_dummy_indices) == [(L0, (0, 1, 0)), (L1, (0, 1, 1)), (-L0, (1, 1, 0)), (-L1, (1, 1, 1))]
assert list(e5._iterate_indices) == [(L0, (0, 1, 0)), (L1, (0, 1, 1)), (-L0, (1, 1, 0)), (-L1, (1, 1, 1))]
assert list(e6._iterate_free_indices) == [(i0, (0, 0, 1, 0)), (i2, (0, 1, 1, 0)), (i0, (1, 1, 0)), (i2, (1, 1, 1))]
assert list(e6._iterate_dummy_indices) == [(L0, (0, 0, 1, 1)), (-L0, (0, 1, 1, 1))]
assert list(e6._iterate_indices) == [(i0, (0, 0, 1, 0)), (L0, (0, 0, 1, 1)), (i2, (0, 1, 1, 0)), (-L0, (0, 1, 1, 1)), (i0, (1, 1, 0)), (i2, (1, 1, 1))]
assert e1.get_indices() == [i0, i2]
assert e1.get_free_indices() == [i0, i2]
assert e2.get_indices() == [L0, -L0]
assert e2.get_free_indices() == []
assert e3.get_indices() == [i0, i1, i2, i3]
assert e3.get_free_indices() == [i0, i1, i2, i3]
assert e4.get_indices() == [i0, L0, i2, -L0]
assert e4.get_free_indices() == [i0, i2]
assert e5.get_indices() == [L0, L1, -L0, -L1]
assert e5.get_free_indices() == []
def test_tensor_expand():
L = TensorIndexType("L")
i, j, k = tensor_indices("i j k", L)
L_0 = TensorIndex("L_0", L)
A, B, C, D = tensor_heads("A B C D", [L])
assert isinstance(Add(A(i), B(i)), TensAdd)
assert isinstance(expand(A(i)+B(i)), TensAdd)
expr = A(i)*(A(-i)+B(-i))
assert expr.args == (A(L_0), A(-L_0) + B(-L_0))
assert expr != A(i)*A(-i) + A(i)*B(-i)
assert expr.expand() == A(i)*A(-i) + A(i)*B(-i)
assert str(expr) == "A(L_0)*(A(-L_0) + B(-L_0))"
expr = A(i)*A(j) + A(i)*B(j)
assert str(expr) == "A(i)*A(j) + A(i)*B(j)"
expr = A(-i)*(A(i)*A(j) + A(i)*B(j)*C(k)*C(-k))
assert expr != A(-i)*A(i)*A(j) + A(-i)*A(i)*B(j)*C(k)*C(-k)
assert expr.expand() == A(-i)*A(i)*A(j) + A(-i)*A(i)*B(j)*C(k)*C(-k)
assert str(expr) == "A(-L_0)*(A(L_0)*A(j) + A(L_0)*B(j)*C(L_1)*C(-L_1))"
assert str(expr.canon_bp()) == 'A(j)*A(L_0)*A(-L_0) + A(L_0)*A(-L_0)*B(j)*C(L_1)*C(-L_1)'
expr = A(-i)*(2*A(i)*A(j) + A(i)*B(j))
assert expr.expand() == 2*A(-i)*A(i)*A(j) + A(-i)*A(i)*B(j)
expr = 2*A(i)*A(-i)
assert expr.coeff == 2
expr = A(i)*(B(j)*C(k) + C(j)*(A(k) + D(k)))
assert str(expr) == "A(i)*(B(j)*C(k) + C(j)*(A(k) + D(k)))"
assert str(expr.expand()) == "A(i)*B(j)*C(k) + A(i)*C(j)*A(k) + A(i)*C(j)*D(k)"
assert isinstance(TensMul(3), TensMul)
tm = TensMul(3).doit()
assert tm == 3
assert isinstance(tm, Integer)
p1 = B(j)*B(-j) + B(j)*C(-j)
p2 = C(-i)*p1
p3 = A(i)*p2
assert p3.expand() == A(i)*C(-i)*B(j)*B(-j) + A(i)*C(-i)*B(j)*C(-j)
expr = A(i)*(B(-i) + C(-i)*(B(j)*B(-j) + B(j)*C(-j)))
assert expr.expand() == A(i)*B(-i) + A(i)*C(-i)*B(j)*B(-j) + A(i)*C(-i)*B(j)*C(-j)
expr = C(-i)*(B(j)*B(-j) + B(j)*C(-j))
assert expr.expand() == C(-i)*B(j)*B(-j) + C(-i)*B(j)*C(-j)
def test_tensor_alternative_construction():
L = TensorIndexType("L")
i0, i1, i2, i3 = tensor_indices('i0:4', L)
A = TensorHead("A", [L])
x, y = symbols("x y")
assert A(i0) == A(Symbol("i0"))
assert A(-i0) == A(-Symbol("i0"))
raises(TypeError, lambda: A(x+y))
raises(ValueError, lambda: A(2*x))
def test_tensor_replacement():
L = TensorIndexType("L")
L2 = TensorIndexType("L2", dim=2)
i, j, k, l = tensor_indices("i j k l", L)
A, B, C, D = tensor_heads("A B C D", [L])
H = TensorHead("H", [L, L])
K = TensorHead("K", [L]*4)
expr = H(i, j)
repl = {H(i,-j): [[1,2],[3,4]], L: diag(1, -1)}
assert expr._extract_data(repl) == ([i, j], Array([[1, -2], [3, -4]]))
assert expr.replace_with_arrays(repl) == Array([[1, -2], [3, -4]])
assert expr.replace_with_arrays(repl, [i, j]) == Array([[1, -2], [3, -4]])
assert expr.replace_with_arrays(repl, [i, -j]) == Array([[1, 2], [3, 4]])
assert expr.replace_with_arrays(repl, [-i, j]) == Array([[1, -2], [-3, 4]])
assert expr.replace_with_arrays(repl, [-i, -j]) == Array([[1, 2], [-3, -4]])
assert expr.replace_with_arrays(repl, [j, i]) == Array([[1, 3], [-2, -4]])
assert expr.replace_with_arrays(repl, [j, -i]) == Array([[1, -3], [-2, 4]])
assert expr.replace_with_arrays(repl, [-j, i]) == Array([[1, 3], [2, 4]])
assert expr.replace_with_arrays(repl, [-j, -i]) == Array([[1, -3], [2, -4]])
# Test stability of optional parameter 'indices'
assert expr.replace_with_arrays(repl) == Array([[1, -2], [3, -4]])
expr = H(i,j)
repl = {H(i,j): [[1,2],[3,4]], L: diag(1, -1)}
assert expr._extract_data(repl) == ([i, j], Array([[1, 2], [3, 4]]))
assert expr.replace_with_arrays(repl) == Array([[1, 2], [3, 4]])
assert expr.replace_with_arrays(repl, [i, j]) == Array([[1, 2], [3, 4]])
assert expr.replace_with_arrays(repl, [i, -j]) == Array([[1, -2], [3, -4]])
assert expr.replace_with_arrays(repl, [-i, j]) == Array([[1, 2], [-3, -4]])
assert expr.replace_with_arrays(repl, [-i, -j]) == Array([[1, -2], [-3, 4]])
assert expr.replace_with_arrays(repl, [j, i]) == Array([[1, 3], [2, 4]])
assert expr.replace_with_arrays(repl, [j, -i]) == Array([[1, -3], [2, -4]])
assert expr.replace_with_arrays(repl, [-j, i]) == Array([[1, 3], [-2, -4]])
assert expr.replace_with_arrays(repl, [-j, -i]) == Array([[1, -3], [-2, 4]])
# Not the same indices:
expr = H(i,k)
repl = {H(i,j): [[1,2],[3,4]], L: diag(1, -1)}
assert expr._extract_data(repl) == ([i, k], Array([[1, 2], [3, 4]]))
expr = A(i)*A(-i)
repl = {A(i): [1,2], L: diag(1, -1)}
assert expr._extract_data(repl) == ([], -3)
assert expr.replace_with_arrays(repl, []) == -3
expr = K(i, j, -j, k)*A(-i)*A(-k)
repl = {A(i): [1, 2], K(i,j,k,l): Array([1]*2**4).reshape(2,2,2,2), L: diag(1, -1)}
assert expr._extract_data(repl)
expr = H(j, k)
repl = {H(i,j): [[1,2],[3,4]], L: diag(1, -1)}
raises(ValueError, lambda: expr._extract_data(repl))
expr = A(i)
repl = {B(i): [1, 2]}
raises(ValueError, lambda: expr._extract_data(repl))
expr = A(i)
repl = {A(i): [[1, 2], [3, 4]]}
raises(ValueError, lambda: expr._extract_data(repl))
# TensAdd:
expr = A(k)*H(i, j) + B(k)*H(i, j)
repl = {A(k): [1], B(k): [1], H(i, j): [[1, 2],[3,4]], L:diag(1,1)}
assert expr._extract_data(repl) == ([k, i, j], Array([[[2, 4], [6, 8]]]))
assert expr.replace_with_arrays(repl, [k, i, j]) == Array([[[2, 4], [6, 8]]])
assert expr.replace_with_arrays(repl, [k, j, i]) == Array([[[2, 6], [4, 8]]])
expr = A(k)*A(-k) + 100
repl = {A(k): [2, 3], L: diag(1, 1)}
assert expr.replace_with_arrays(repl, []) == 113
## Symmetrization:
expr = H(i, j) + H(j, i)
repl = {H(i, j): [[1, 2], [3, 4]]}
assert expr._extract_data(repl) == ([i, j], Array([[2, 5], [5, 8]]))
assert expr.replace_with_arrays(repl, [i, j]) == Array([[2, 5], [5, 8]])
assert expr.replace_with_arrays(repl, [j, i]) == Array([[2, 5], [5, 8]])
## Anti-symmetrization:
expr = H(i, j) - H(j, i)
repl = {H(i, j): [[1, 2], [3, 4]]}
assert expr.replace_with_arrays(repl, [i, j]) == Array([[0, -1], [1, 0]])
assert expr.replace_with_arrays(repl, [j, i]) == Array([[0, 1], [-1, 0]])
# Tensors with contractions in replacements:
expr = K(i, j, k, -k)
repl = {K(i, j, k, -k): [[1, 2], [3, 4]]}
assert expr._extract_data(repl) == ([i, j], Array([[1, 2], [3, 4]]))
expr = H(i, -i)
repl = {H(i, -i): 42}
assert expr._extract_data(repl) == ([], 42)
expr = H(i, -i)
repl = {
H(-i, -j): Array([[1, 0, 0, 0], [0, -1, 0, 0], [0, 0, -1, 0], [0, 0, 0, -1]]),
L: Array([[1, 0, 0, 0], [0, -1, 0, 0], [0, 0, -1, 0], [0, 0, 0, -1]]),
}
assert expr._extract_data(repl) == ([], 4)
# Replace with array, raise exception if indices are not compatible:
expr = A(i)*A(j)
repl = {A(i): [1, 2]}
raises(ValueError, lambda: expr.replace_with_arrays(repl, [j]))
# Raise exception if array dimension is not compatible:
expr = A(i)
repl = {A(i): [[1, 2]]}
raises(ValueError, lambda: expr.replace_with_arrays(repl, [i]))
# TensorIndexType with dimension, wrong dimension in replacement array:
u1, u2, u3 = tensor_indices("u1:4", L2)
U = TensorHead("U", [L2])
expr = U(u1)*U(-u2)
repl = {U(u1): [[1]]}
raises(ValueError, lambda: expr.replace_with_arrays(repl, [u1, -u2]))
def test_rewrite_tensor_to_Indexed():
L = TensorIndexType("L", dim=4)
A = TensorHead("A", [L]*4)
B = TensorHead("B", [L])
i0, i1, i2, i3 = symbols("i0:4")
L_0, L_1 = symbols("L_0:2")
a1 = A(i0, i1, i2, i3)
assert a1.rewrite(Indexed) == Indexed(Symbol("A"), i0, i1, i2, i3)
a2 = A(i0, -i0, i2, i3)
assert a2.rewrite(Indexed) == Sum(Indexed(Symbol("A"), L_0, L_0, i2, i3), (L_0, 0, 3))
a3 = a2 + A(i2, i3, i0, -i0)
assert a3.rewrite(Indexed) == \
Sum(Indexed(Symbol("A"), L_0, L_0, i2, i3), (L_0, 0, 3)) +\
Sum(Indexed(Symbol("A"), i2, i3, L_0, L_0), (L_0, 0, 3))
b1 = B(-i0)*a1
assert b1.rewrite(Indexed) == Sum(Indexed(Symbol("B"), L_0)*Indexed(Symbol("A"), L_0, i1, i2, i3), (L_0, 0, 3))
b2 = B(-i3)*a2
assert b2.rewrite(Indexed) == Sum(Indexed(Symbol("B"), L_1)*Indexed(Symbol("A"), L_0, L_0, i2, L_1), (L_0, 0, 3), (L_1, 0, 3))
def test_tensorsymmetry():
with warns_deprecated_sympy():
tensorsymmetry([1]*2)
def test_tensorhead():
with warns_deprecated_sympy():
tensorhead('A', [])
def test_TensorType():
with warns_deprecated_sympy():
sym2 = TensorSymmetry.fully_symmetric(2)
Lorentz = TensorIndexType('Lorentz')
S2 = TensorType([Lorentz]*2, sym2)
assert isinstance(S2, TensorType)
|
976251ebb4dac17276e2ea022d150cd91eafc41689340f02bbf72538ce380125 | from sympy.tensor.array.array_comprehension import ArrayComprehension, ArrayComprehensionMap
from sympy.tensor.array import ImmutableDenseNDimArray
from sympy.abc import i, j, k, l
from sympy.testing.pytest import raises, warns_deprecated_sympy
from sympy.matrices import Matrix
def test_array_comprehension():
a = ArrayComprehension(i*j, (i, 1, 3), (j, 2, 4))
b = ArrayComprehension(i, (i, 1, j+1))
c = ArrayComprehension(i+j+k+l, (i, 1, 2), (j, 1, 3), (k, 1, 4), (l, 1, 5))
d = ArrayComprehension(k, (i, 1, 5))
e = ArrayComprehension(i, (j, k+1, k+5))
assert a.doit().tolist() == [[2, 3, 4], [4, 6, 8], [6, 9, 12]]
assert a.shape == (3, 3)
assert a.is_shape_numeric == True
assert a.tolist() == [[2, 3, 4], [4, 6, 8], [6, 9, 12]]
assert a.tomatrix() == Matrix([
[2, 3, 4],
[4, 6, 8],
[6, 9, 12]])
assert len(a) == 9
assert isinstance(b.doit(), ArrayComprehension)
assert isinstance(a.doit(), ImmutableDenseNDimArray)
assert b.subs(j, 3) == ArrayComprehension(i, (i, 1, 4))
assert b.free_symbols == {j}
assert b.shape == (j + 1,)
assert b.rank() == 1
assert b.is_shape_numeric == False
assert c.free_symbols == set()
assert c.function == i + j + k + l
assert c.limits == ((i, 1, 2), (j, 1, 3), (k, 1, 4), (l, 1, 5))
assert c.doit().tolist() == [[[[4, 5, 6, 7, 8], [5, 6, 7, 8, 9], [6, 7, 8, 9, 10], [7, 8, 9, 10, 11]],
[[5, 6, 7, 8, 9], [6, 7, 8, 9, 10], [7, 8, 9, 10, 11], [8, 9, 10, 11, 12]],
[[6, 7, 8, 9, 10], [7, 8, 9, 10, 11], [8, 9, 10, 11, 12], [9, 10, 11, 12, 13]]],
[[[5, 6, 7, 8, 9], [6, 7, 8, 9, 10], [7, 8, 9, 10, 11], [8, 9, 10, 11, 12]],
[[6, 7, 8, 9, 10], [7, 8, 9, 10, 11], [8, 9, 10, 11, 12], [9, 10, 11, 12, 13]],
[[7, 8, 9, 10, 11], [8, 9, 10, 11, 12], [9, 10, 11, 12, 13], [10, 11, 12, 13, 14]]]]
assert c.free_symbols == set()
assert c.variables == [i, j, k, l]
assert c.bound_symbols == [i, j, k, l]
assert d.doit().tolist() == [k, k, k, k, k]
assert len(e) == 5
raises(TypeError, lambda: ArrayComprehension(i*j, (i, 1, 3), (j, 2, [1, 3, 2])))
raises(ValueError, lambda: ArrayComprehension(i*j, (i, 1, 3), (j, 2, 1)))
raises(ValueError, lambda: ArrayComprehension(i*j, (i, 1, 3), (j, 2, j+1)))
raises(ValueError, lambda: len(ArrayComprehension(i*j, (i, 1, 3), (j, 2, j+4))))
raises(TypeError, lambda: ArrayComprehension(i*j, (i, 0, i + 1.5), (j, 0, 2)))
raises(ValueError, lambda: b.tolist())
raises(ValueError, lambda: b.tomatrix())
raises(ValueError, lambda: c.tomatrix())
def test_arraycomprehensionmap():
a = ArrayComprehensionMap(lambda i: i+1, (i, 1, 5))
assert a.doit().tolist() == [2, 3, 4, 5, 6]
assert a.shape == (5,)
assert a.is_shape_numeric
assert a.tolist() == [2, 3, 4, 5, 6]
assert len(a) == 5
assert isinstance(a.doit(), ImmutableDenseNDimArray)
expr = ArrayComprehensionMap(lambda i: i+1, (i, 1, k))
assert expr.doit() == expr
assert expr.subs(k, 4) == ArrayComprehensionMap(lambda i: i+1, (i, 1, 4))
assert expr.subs(k, 4).doit() == ImmutableDenseNDimArray([2, 3, 4, 5])
b = ArrayComprehensionMap(lambda i: i+1, (i, 1, 2), (i, 1, 3), (i, 1, 4), (i, 1, 5))
assert b.doit().tolist() == [[[[2, 3, 4, 5, 6], [3, 5, 7, 9, 11], [4, 7, 10, 13, 16], [5, 9, 13, 17, 21]],
[[3, 5, 7, 9, 11], [5, 9, 13, 17, 21], [7, 13, 19, 25, 31], [9, 17, 25, 33, 41]],
[[4, 7, 10, 13, 16], [7, 13, 19, 25, 31], [10, 19, 28, 37, 46], [13, 25, 37, 49, 61]]],
[[[3, 5, 7, 9, 11], [5, 9, 13, 17, 21], [7, 13, 19, 25, 31], [9, 17, 25, 33, 41]],
[[5, 9, 13, 17, 21], [9, 17, 25, 33, 41], [13, 25, 37, 49, 61], [17, 33, 49, 65, 81]],
[[7, 13, 19, 25, 31], [13, 25, 37, 49, 61], [19, 37, 55, 73, 91], [25, 49, 73, 97, 121]]]]
# tests about lambda expression
assert ArrayComprehensionMap(lambda: 3, (i, 1, 5)).doit().tolist() == [3, 3, 3, 3, 3]
assert ArrayComprehensionMap(lambda i: i+1, (i, 1, 5)).doit().tolist() == [2, 3, 4, 5, 6]
raises(ValueError, lambda: ArrayComprehensionMap(i*j, (i, 1, 3), (j, 2, 4)))
with warns_deprecated_sympy():
a = ArrayComprehensionMap(lambda i, j: i+j, (i, 1, 5))
raises(ValueError, lambda: a.doit())
|
ed8d66c7fc9df15c618ed0f5844e530ca147fc493c2e52bf297a4c79d1ceefad | from typing import Dict, Any
from sympy.multipledispatch import dispatch
from sympy.multipledispatch.conflict import AmbiguityWarning
from sympy.testing.pytest import raises, XFAIL, warns
from functools import partial
test_namespace = dict() # type: Dict[str, Any]
orig_dispatch = dispatch
dispatch = partial(dispatch, namespace=test_namespace)
@XFAIL
def test_singledispatch():
@dispatch(int)
def f(x): # noqa:F811
return x + 1
@dispatch(int)
def g(x): # noqa:F811
return x + 2
@dispatch(float) # noqa:F811
def f(x): # noqa:F811
return x - 1
assert f(1) == 2
assert g(1) == 3
assert f(1.0) == 0
assert raises(NotImplementedError, lambda: f('hello'))
def test_multipledispatch():
@dispatch(int, int)
def f(x, y): # noqa:F811
return x + y
@dispatch(float, float) # noqa:F811
def f(x, y): # noqa:F811
return x - y
assert f(1, 2) == 3
assert f(1.0, 2.0) == -1.0
class A: pass
class B: pass
class C(A): pass
class D(C): pass
class E(C): pass
def test_inheritance():
@dispatch(A)
def f(x): # noqa:F811
return 'a'
@dispatch(B) # noqa:F811
def f(x): # noqa:F811
return 'b'
assert f(A()) == 'a'
assert f(B()) == 'b'
assert f(C()) == 'a'
@XFAIL
def test_inheritance_and_multiple_dispatch():
@dispatch(A, A)
def f(x, y): # noqa:F811
return type(x), type(y)
@dispatch(A, B) # noqa:F811
def f(x, y): # noqa:F811
return 0
assert f(A(), A()) == (A, A)
assert f(A(), C()) == (A, C)
assert f(A(), B()) == 0
assert f(C(), B()) == 0
assert raises(NotImplementedError, lambda: f(B(), B()))
def test_competing_solutions():
@dispatch(A)
def h(x): # noqa:F811
return 1
@dispatch(C) # noqa:F811
def h(x): # noqa:F811
return 2
assert h(D()) == 2
def test_competing_multiple():
@dispatch(A, B)
def h(x, y): # noqa:F811
return 1
@dispatch(C, B) # noqa:F811
def h(x, y): # noqa:F811
return 2
assert h(D(), B()) == 2
def test_competing_ambiguous():
test_namespace = dict()
dispatch = partial(orig_dispatch, namespace=test_namespace)
@dispatch(A, C)
def f(x, y): # noqa:F811
return 2
with warns(AmbiguityWarning):
@dispatch(C, A) # noqa:F811
def f(x, y): # noqa:F811
return 2
assert f(A(), C()) == f(C(), A()) == 2
# assert raises(Warning, lambda : f(C(), C()))
def test_caching_correct_behavior():
@dispatch(A)
def f(x): # noqa:F811
return 1
assert f(C()) == 1
@dispatch(C)
def f(x): # noqa:F811
return 2
assert f(C()) == 2
def test_union_types():
@dispatch((A, C))
def f(x): # noqa:F811
return 1
assert f(A()) == 1
assert f(C()) == 1
def test_namespaces():
ns1 = dict()
ns2 = dict()
def foo(x):
return 1
foo1 = orig_dispatch(int, namespace=ns1)(foo)
def foo(x):
return 2
foo2 = orig_dispatch(int, namespace=ns2)(foo)
assert foo1(0) == 1
assert foo2(0) == 2
"""
Fails
def test_dispatch_on_dispatch():
@dispatch(A)
@dispatch(C)
def q(x): # noqa:F811
return 1
assert q(A()) == 1
assert q(C()) == 1
"""
def test_methods():
class Foo:
@dispatch(float)
def f(self, x): # noqa:F811
return x - 1
@dispatch(int) # noqa:F811
def f(self, x): # noqa:F811
return x + 1
@dispatch(int)
def g(self, x): # noqa:F811
return x + 3
foo = Foo()
assert foo.f(1) == 2
assert foo.f(1.0) == 0.0
assert foo.g(1) == 4
def test_methods_multiple_dispatch():
class Foo:
@dispatch(A, A)
def f(x, y): # noqa:F811
return 1
@dispatch(A, C) # noqa:F811
def f(x, y): # noqa:F811
return 2
foo = Foo()
assert foo.f(A(), A()) == 1
assert foo.f(A(), C()) == 2
assert foo.f(C(), C()) == 2
|
9ac3554a28a4b8f3aab049bf30c1a68ec35b036080474175159687b24cf3a34e | from sympy.multipledispatch.conflict import (supercedes, ordering, ambiguities,
ambiguous, super_signature, consistent)
class A: pass
class B(A): pass
class C: pass
def test_supercedes():
assert supercedes([B], [A])
assert supercedes([B, A], [A, A])
assert not supercedes([B, A], [A, B])
assert not supercedes([A], [B])
def test_consistent():
assert consistent([A], [A])
assert consistent([B], [B])
assert not consistent([A], [C])
assert consistent([A, B], [A, B])
assert consistent([B, A], [A, B])
assert not consistent([B, A], [B])
assert not consistent([B, A], [B, C])
def test_super_signature():
assert super_signature([[A]]) == [A]
assert super_signature([[A], [B]]) == [B]
assert super_signature([[A, B], [B, A]]) == [B, B]
assert super_signature([[A, A, B], [A, B, A], [B, A, A]]) == [B, B, B]
def test_ambiguous():
assert not ambiguous([A], [A])
assert not ambiguous([A], [B])
assert not ambiguous([B], [B])
assert not ambiguous([A, B], [B, B])
assert ambiguous([A, B], [B, A])
def test_ambiguities():
signatures = [[A], [B], [A, B], [B, A], [A, C]]
expected = {((A, B), (B, A))}
result = ambiguities(signatures)
assert set(map(frozenset, expected)) == set(map(frozenset, result))
signatures = [[A], [B], [A, B], [B, A], [A, C], [B, B]]
expected = set()
result = ambiguities(signatures)
assert set(map(frozenset, expected)) == set(map(frozenset, result))
def test_ordering():
signatures = [[A, A], [A, B], [B, A], [B, B], [A, C]]
ord = ordering(signatures)
assert ord[0] == (B, B) or ord[0] == (A, C)
assert ord[-1] == (A, A) or ord[-1] == (A, C)
def test_type_mro():
assert super_signature([[object], [type]]) == [type]
|
9a6640570b67c4915ae7c2c4d0332733888af24436920a098fb37e139ac76c29 | from sympy.multipledispatch.dispatcher import (Dispatcher, MDNotImplementedError,
MethodDispatcher, halt_ordering,
restart_ordering)
from sympy.testing.pytest import raises, XFAIL, warns
def identity(x):
return x
def inc(x):
return x + 1
def dec(x):
return x - 1
def test_dispatcher():
f = Dispatcher('f')
f.add((int,), inc)
f.add((float,), dec)
with warns(DeprecationWarning):
assert f.resolve((int,)) == inc
assert f.dispatch(int) is inc
assert f(1) == 2
assert f(1.0) == 0.0
def test_union_types():
f = Dispatcher('f')
f.register((int, float))(inc)
assert f(1) == 2
assert f(1.0) == 2.0
def test_dispatcher_as_decorator():
f = Dispatcher('f')
@f.register(int)
def inc(x): # noqa:F811
return x + 1
@f.register(float) # noqa:F811
def inc(x): # noqa:F811
return x - 1
assert f(1) == 2
assert f(1.0) == 0.0
def test_register_instance_method():
class Test:
__init__ = MethodDispatcher('f')
@__init__.register(list)
def _init_list(self, data):
self.data = data
@__init__.register(object)
def _init_obj(self, datum):
self.data = [datum]
a = Test(3)
b = Test([3])
assert a.data == b.data
def test_on_ambiguity():
f = Dispatcher('f')
def identity(x): return x
ambiguities = [False]
def on_ambiguity(dispatcher, amb):
ambiguities[0] = True
f.add((object, object), identity, on_ambiguity=on_ambiguity)
assert not ambiguities[0]
f.add((object, float), identity, on_ambiguity=on_ambiguity)
assert not ambiguities[0]
f.add((float, object), identity, on_ambiguity=on_ambiguity)
assert ambiguities[0]
@XFAIL
def test_raise_error_on_non_class():
f = Dispatcher('f')
assert raises(TypeError, lambda: f.add((1,), inc))
def test_docstring():
def one(x, y):
""" Docstring number one """
return x + y
def two(x, y):
""" Docstring number two """
return x + y
def three(x, y):
return x + y
master_doc = 'Doc of the multimethod itself'
f = Dispatcher('f', doc=master_doc)
f.add((object, object), one)
f.add((int, int), two)
f.add((float, float), three)
assert one.__doc__.strip() in f.__doc__
assert two.__doc__.strip() in f.__doc__
assert f.__doc__.find(one.__doc__.strip()) < \
f.__doc__.find(two.__doc__.strip())
assert 'object, object' in f.__doc__
assert master_doc in f.__doc__
def test_help():
def one(x, y):
""" Docstring number one """
return x + y
def two(x, y):
""" Docstring number two """
return x + y
def three(x, y):
""" Docstring number three """
return x + y
master_doc = 'Doc of the multimethod itself'
f = Dispatcher('f', doc=master_doc)
f.add((object, object), one)
f.add((int, int), two)
f.add((float, float), three)
assert f._help(1, 1) == two.__doc__
assert f._help(1.0, 2.0) == three.__doc__
def test_source():
def one(x, y):
""" Docstring number one """
return x + y
def two(x, y):
""" Docstring number two """
return x - y
master_doc = 'Doc of the multimethod itself'
f = Dispatcher('f', doc=master_doc)
f.add((int, int), one)
f.add((float, float), two)
assert 'x + y' in f._source(1, 1)
assert 'x - y' in f._source(1.0, 1.0)
@XFAIL
def test_source_raises_on_missing_function():
f = Dispatcher('f')
assert raises(TypeError, lambda: f.source(1))
def test_halt_method_resolution():
g = [0]
def on_ambiguity(a, b):
g[0] += 1
f = Dispatcher('f')
halt_ordering()
def func(*args):
pass
f.add((int, object), func)
f.add((object, int), func)
assert g == [0]
restart_ordering(on_ambiguity=on_ambiguity)
assert g == [1]
assert set(f.ordering) == {(int, object), (object, int)}
@XFAIL
def test_no_implementations():
f = Dispatcher('f')
assert raises(NotImplementedError, lambda: f('hello'))
@XFAIL
def test_register_stacking():
f = Dispatcher('f')
@f.register(list)
@f.register(tuple)
def rev(x):
return x[::-1]
assert f((1, 2, 3)) == (3, 2, 1)
assert f([1, 2, 3]) == [3, 2, 1]
assert raises(NotImplementedError, lambda: f('hello'))
assert rev('hello') == 'olleh'
def test_dispatch_method():
f = Dispatcher('f')
@f.register(list)
def rev(x):
return x[::-1]
@f.register(int, int)
def add(x, y):
return x + y
class MyList(list):
pass
assert f.dispatch(list) is rev
assert f.dispatch(MyList) is rev
assert f.dispatch(int, int) is add
@XFAIL
def test_not_implemented():
f = Dispatcher('f')
@f.register(object)
def _(x):
return 'default'
@f.register(int)
def _(x):
if x % 2 == 0:
return 'even'
else:
raise MDNotImplementedError()
assert f('hello') == 'default' # default behavior
assert f(2) == 'even' # specialized behavior
assert f(3) == 'default' # fall bac to default behavior
assert raises(NotImplementedError, lambda: f(1, 2))
@XFAIL
def test_not_implemented_error():
f = Dispatcher('f')
@f.register(float)
def _(a):
raise MDNotImplementedError()
assert raises(NotImplementedError, lambda: f(1.0))
|
0aa3fa77c9729cbe23a5780a4357943b343366c3ce5bc48fddb35b8e582e6ac9 | from sympy.assumptions.cnf import EncodedCNF
def pycosat_satisfiable(expr, all_models=False):
import pycosat
if not isinstance(expr, EncodedCNF):
exprs = EncodedCNF()
exprs.add_prop(expr)
expr = exprs
# Return UNSAT when False (encoded as 0) is present in the CNF
if {0} in expr.data:
if all_models:
return (f for f in [False])
return False
if not all_models:
r = pycosat.solve(expr.data)
result = (r != "UNSAT")
if not result:
return result
return {expr.symbols[abs(lit) - 1]: lit > 0 for lit in r}
else:
r = pycosat.itersolve(expr.data)
result = (r != "UNSAT")
if not result:
return result
# Make solutions sympy compatible by creating a generator
def _gen(results):
satisfiable = False
try:
while True:
sol = next(results)
yield {expr.symbols[abs(lit) - 1]: lit > 0 for lit in sol}
satisfiable = True
except StopIteration:
if not satisfiable:
yield False
return _gen(r)
|
187eeee15bdb35ddbdc33a0cd396c0ba135165ba658e48a2334701f63ec1916d | """Implementation of DPLL algorithm
Features:
- Clause learning
- Watch literal scheme
- VSIDS heuristic
References:
- https://en.wikipedia.org/wiki/DPLL_algorithm
"""
from collections import defaultdict
from heapq import heappush, heappop
from sympy import ordered
from sympy.assumptions.cnf import EncodedCNF
def dpll_satisfiable(expr, all_models=False):
"""
Check satisfiability of a propositional sentence.
It returns a model rather than True when it succeeds.
Returns a generator of all models if all_models is True.
Examples
========
>>> from sympy.abc import A, B
>>> from sympy.logic.algorithms.dpll2 import dpll_satisfiable
>>> dpll_satisfiable(A & ~B)
{A: True, B: False}
>>> dpll_satisfiable(A & ~A)
False
"""
if not isinstance(expr, EncodedCNF):
exprs = EncodedCNF()
exprs.add_prop(expr)
expr = exprs
# Return UNSAT when False (encoded as 0) is present in the CNF
if {0} in expr.data:
if all_models:
return (f for f in [False])
return False
solver = SATSolver(expr.data, expr.variables, set(), expr.symbols)
models = solver._find_model()
if all_models:
return _all_models(models)
try:
return next(models)
except StopIteration:
return False
# Uncomment to confirm the solution is valid (hitting set for the clauses)
#else:
#for cls in clauses_int_repr:
#assert solver.var_settings.intersection(cls)
def _all_models(models):
satisfiable = False
try:
while True:
yield next(models)
satisfiable = True
except StopIteration:
if not satisfiable:
yield False
class SATSolver:
"""
Class for representing a SAT solver capable of
finding a model to a boolean theory in conjunctive
normal form.
"""
def __init__(self, clauses, variables, var_settings, symbols=None,
heuristic='vsids', clause_learning='none', INTERVAL=500):
self.var_settings = var_settings
self.heuristic = heuristic
self.is_unsatisfied = False
self._unit_prop_queue = []
self.update_functions = []
self.INTERVAL = INTERVAL
if symbols is None:
self.symbols = list(ordered(variables))
else:
self.symbols = symbols
self._initialize_variables(variables)
self._initialize_clauses(clauses)
if 'vsids' == heuristic:
self._vsids_init()
self.heur_calculate = self._vsids_calculate
self.heur_lit_assigned = self._vsids_lit_assigned
self.heur_lit_unset = self._vsids_lit_unset
self.heur_clause_added = self._vsids_clause_added
# Note: Uncomment this if/when clause learning is enabled
#self.update_functions.append(self._vsids_decay)
else:
raise NotImplementedError
if 'simple' == clause_learning:
self.add_learned_clause = self._simple_add_learned_clause
self.compute_conflict = self.simple_compute_conflict
self.update_functions.append(self.simple_clean_clauses)
elif 'none' == clause_learning:
self.add_learned_clause = lambda x: None
self.compute_conflict = lambda: None
else:
raise NotImplementedError
# Create the base level
self.levels = [Level(0)]
self._current_level.varsettings = var_settings
# Keep stats
self.num_decisions = 0
self.num_learned_clauses = 0
self.original_num_clauses = len(self.clauses)
def _initialize_variables(self, variables):
"""Set up the variable data structures needed."""
self.sentinels = defaultdict(set)
self.occurrence_count = defaultdict(int)
self.variable_set = [False] * (len(variables) + 1)
def _initialize_clauses(self, clauses):
"""Set up the clause data structures needed.
For each clause, the following changes are made:
- Unit clauses are queued for propagation right away.
- Non-unit clauses have their first and last literals set as sentinels.
- The number of clauses a literal appears in is computed.
"""
self.clauses = []
for cls in clauses:
self.clauses.append(list(cls))
for i in range(len(self.clauses)):
# Handle the unit clauses
if 1 == len(self.clauses[i]):
self._unit_prop_queue.append(self.clauses[i][0])
continue
self.sentinels[self.clauses[i][0]].add(i)
self.sentinels[self.clauses[i][-1]].add(i)
for lit in self.clauses[i]:
self.occurrence_count[lit] += 1
def _find_model(self):
"""
Main DPLL loop. Returns a generator of models.
Variables are chosen successively, and assigned to be either
True or False. If a solution is not found with this setting,
the opposite is chosen and the search continues. The solver
halts when every variable has a setting.
Examples
========
>>> from sympy.logic.algorithms.dpll2 import SATSolver
>>> l = SATSolver([{2, -3}, {1}, {3, -3}, {2, -2},
... {3, -2}], {1, 2, 3}, set())
>>> list(l._find_model())
[{1: True, 2: False, 3: False}, {1: True, 2: True, 3: True}]
>>> from sympy.abc import A, B, C
>>> l = SATSolver([{2, -3}, {1}, {3, -3}, {2, -2},
... {3, -2}], {1, 2, 3}, set(), [A, B, C])
>>> list(l._find_model())
[{A: True, B: False, C: False}, {A: True, B: True, C: True}]
"""
# We use this variable to keep track of if we should flip a
# variable setting in successive rounds
flip_var = False
# Check if unit prop says the theory is unsat right off the bat
self._simplify()
if self.is_unsatisfied:
return
# While the theory still has clauses remaining
while True:
# Perform cleanup / fixup at regular intervals
if self.num_decisions % self.INTERVAL == 0:
for func in self.update_functions:
func()
if flip_var:
# We have just backtracked and we are trying to opposite literal
flip_var = False
lit = self._current_level.decision
else:
# Pick a literal to set
lit = self.heur_calculate()
self.num_decisions += 1
# Stopping condition for a satisfying theory
if 0 == lit:
yield {self.symbols[abs(lit) - 1]:
lit > 0 for lit in self.var_settings}
while self._current_level.flipped:
self._undo()
if len(self.levels) == 1:
return
flip_lit = -self._current_level.decision
self._undo()
self.levels.append(Level(flip_lit, flipped=True))
flip_var = True
continue
# Start the new decision level
self.levels.append(Level(lit))
# Assign the literal, updating the clauses it satisfies
self._assign_literal(lit)
# _simplify the theory
self._simplify()
# Check if we've made the theory unsat
if self.is_unsatisfied:
self.is_unsatisfied = False
# We unroll all of the decisions until we can flip a literal
while self._current_level.flipped:
self._undo()
# If we've unrolled all the way, the theory is unsat
if 1 == len(self.levels):
return
# Detect and add a learned clause
self.add_learned_clause(self.compute_conflict())
# Try the opposite setting of the most recent decision
flip_lit = -self._current_level.decision
self._undo()
self.levels.append(Level(flip_lit, flipped=True))
flip_var = True
########################
# Helper Methods #
########################
@property
def _current_level(self):
"""The current decision level data structure
Examples
========
>>> from sympy.logic.algorithms.dpll2 import SATSolver
>>> l = SATSolver([{1}, {2}], {1, 2}, set())
>>> next(l._find_model())
{1: True, 2: True}
>>> l._current_level.decision
0
>>> l._current_level.flipped
False
>>> l._current_level.var_settings
{1, 2}
"""
return self.levels[-1]
def _clause_sat(self, cls):
"""Check if a clause is satisfied by the current variable setting.
Examples
========
>>> from sympy.logic.algorithms.dpll2 import SATSolver
>>> l = SATSolver([{1}, {-1}], {1}, set())
>>> try:
... next(l._find_model())
... except StopIteration:
... pass
>>> l._clause_sat(0)
False
>>> l._clause_sat(1)
True
"""
for lit in self.clauses[cls]:
if lit in self.var_settings:
return True
return False
def _is_sentinel(self, lit, cls):
"""Check if a literal is a sentinel of a given clause.
Examples
========
>>> from sympy.logic.algorithms.dpll2 import SATSolver
>>> l = SATSolver([{2, -3}, {1}, {3, -3}, {2, -2},
... {3, -2}], {1, 2, 3}, set())
>>> next(l._find_model())
{1: True, 2: False, 3: False}
>>> l._is_sentinel(2, 3)
True
>>> l._is_sentinel(-3, 1)
False
"""
return cls in self.sentinels[lit]
def _assign_literal(self, lit):
"""Make a literal assignment.
The literal assignment must be recorded as part of the current
decision level. Additionally, if the literal is marked as a
sentinel of any clause, then a new sentinel must be chosen. If
this is not possible, then unit propagation is triggered and
another literal is added to the queue to be set in the future.
Examples
========
>>> from sympy.logic.algorithms.dpll2 import SATSolver
>>> l = SATSolver([{2, -3}, {1}, {3, -3}, {2, -2},
... {3, -2}], {1, 2, 3}, set())
>>> next(l._find_model())
{1: True, 2: False, 3: False}
>>> l.var_settings
{-3, -2, 1}
>>> l = SATSolver([{2, -3}, {1}, {3, -3}, {2, -2},
... {3, -2}], {1, 2, 3}, set())
>>> l._assign_literal(-1)
>>> try:
... next(l._find_model())
... except StopIteration:
... pass
>>> l.var_settings
{-1}
"""
self.var_settings.add(lit)
self._current_level.var_settings.add(lit)
self.variable_set[abs(lit)] = True
self.heur_lit_assigned(lit)
sentinel_list = list(self.sentinels[-lit])
for cls in sentinel_list:
if not self._clause_sat(cls):
other_sentinel = None
for newlit in self.clauses[cls]:
if newlit != -lit:
if self._is_sentinel(newlit, cls):
other_sentinel = newlit
elif not self.variable_set[abs(newlit)]:
self.sentinels[-lit].remove(cls)
self.sentinels[newlit].add(cls)
other_sentinel = None
break
# Check if no sentinel update exists
if other_sentinel:
self._unit_prop_queue.append(other_sentinel)
def _undo(self):
"""
_undo the changes of the most recent decision level.
Examples
========
>>> from sympy.logic.algorithms.dpll2 import SATSolver
>>> l = SATSolver([{2, -3}, {1}, {3, -3}, {2, -2},
... {3, -2}], {1, 2, 3}, set())
>>> next(l._find_model())
{1: True, 2: False, 3: False}
>>> level = l._current_level
>>> level.decision, level.var_settings, level.flipped
(-3, {-3, -2}, False)
>>> l._undo()
>>> level = l._current_level
>>> level.decision, level.var_settings, level.flipped
(0, {1}, False)
"""
# Undo the variable settings
for lit in self._current_level.var_settings:
self.var_settings.remove(lit)
self.heur_lit_unset(lit)
self.variable_set[abs(lit)] = False
# Pop the level off the stack
self.levels.pop()
#########################
# Propagation #
#########################
"""
Propagation methods should attempt to soundly simplify the boolean
theory, and return True if any simplification occurred and False
otherwise.
"""
def _simplify(self):
"""Iterate over the various forms of propagation to simplify the theory.
Examples
========
>>> from sympy.logic.algorithms.dpll2 import SATSolver
>>> l = SATSolver([{2, -3}, {1}, {3, -3}, {2, -2},
... {3, -2}], {1, 2, 3}, set())
>>> l.variable_set
[False, False, False, False]
>>> l.sentinels
{-3: {0, 2}, -2: {3, 4}, 2: {0, 3}, 3: {2, 4}}
>>> l._simplify()
>>> l.variable_set
[False, True, False, False]
>>> l.sentinels
{-3: {0, 2}, -2: {3, 4}, -1: set(), 2: {0, 3},
...3: {2, 4}}
"""
changed = True
while changed:
changed = False
changed |= self._unit_prop()
changed |= self._pure_literal()
def _unit_prop(self):
"""Perform unit propagation on the current theory."""
result = len(self._unit_prop_queue) > 0
while self._unit_prop_queue:
next_lit = self._unit_prop_queue.pop()
if -next_lit in self.var_settings:
self.is_unsatisfied = True
self._unit_prop_queue = []
return False
else:
self._assign_literal(next_lit)
return result
def _pure_literal(self):
"""Look for pure literals and assign them when found."""
return False
#########################
# Heuristics #
#########################
def _vsids_init(self):
"""Initialize the data structures needed for the VSIDS heuristic."""
self.lit_heap = []
self.lit_scores = {}
for var in range(1, len(self.variable_set)):
self.lit_scores[var] = float(-self.occurrence_count[var])
self.lit_scores[-var] = float(-self.occurrence_count[-var])
heappush(self.lit_heap, (self.lit_scores[var], var))
heappush(self.lit_heap, (self.lit_scores[-var], -var))
def _vsids_decay(self):
"""Decay the VSIDS scores for every literal.
Examples
========
>>> from sympy.logic.algorithms.dpll2 import SATSolver
>>> l = SATSolver([{2, -3}, {1}, {3, -3}, {2, -2},
... {3, -2}], {1, 2, 3}, set())
>>> l.lit_scores
{-3: -2.0, -2: -2.0, -1: 0.0, 1: 0.0, 2: -2.0, 3: -2.0}
>>> l._vsids_decay()
>>> l.lit_scores
{-3: -1.0, -2: -1.0, -1: 0.0, 1: 0.0, 2: -1.0, 3: -1.0}
"""
# We divide every literal score by 2 for a decay factor
# Note: This doesn't change the heap property
for lit in self.lit_scores.keys():
self.lit_scores[lit] /= 2.0
def _vsids_calculate(self):
"""
VSIDS Heuristic Calculation
Examples
========
>>> from sympy.logic.algorithms.dpll2 import SATSolver
>>> l = SATSolver([{2, -3}, {1}, {3, -3}, {2, -2},
... {3, -2}], {1, 2, 3}, set())
>>> l.lit_heap
[(-2.0, -3), (-2.0, 2), (-2.0, -2), (0.0, 1), (-2.0, 3), (0.0, -1)]
>>> l._vsids_calculate()
-3
>>> l.lit_heap
[(-2.0, -2), (-2.0, 2), (0.0, -1), (0.0, 1), (-2.0, 3)]
"""
if len(self.lit_heap) == 0:
return 0
# Clean out the front of the heap as long the variables are set
while self.variable_set[abs(self.lit_heap[0][1])]:
heappop(self.lit_heap)
if len(self.lit_heap) == 0:
return 0
return heappop(self.lit_heap)[1]
def _vsids_lit_assigned(self, lit):
"""Handle the assignment of a literal for the VSIDS heuristic."""
pass
def _vsids_lit_unset(self, lit):
"""Handle the unsetting of a literal for the VSIDS heuristic.
Examples
========
>>> from sympy.logic.algorithms.dpll2 import SATSolver
>>> l = SATSolver([{2, -3}, {1}, {3, -3}, {2, -2},
... {3, -2}], {1, 2, 3}, set())
>>> l.lit_heap
[(-2.0, -3), (-2.0, 2), (-2.0, -2), (0.0, 1), (-2.0, 3), (0.0, -1)]
>>> l._vsids_lit_unset(2)
>>> l.lit_heap
[(-2.0, -3), (-2.0, -2), (-2.0, -2), (-2.0, 2), (-2.0, 3), (0.0, -1),
...(-2.0, 2), (0.0, 1)]
"""
var = abs(lit)
heappush(self.lit_heap, (self.lit_scores[var], var))
heappush(self.lit_heap, (self.lit_scores[-var], -var))
def _vsids_clause_added(self, cls):
"""Handle the addition of a new clause for the VSIDS heuristic.
Examples
========
>>> from sympy.logic.algorithms.dpll2 import SATSolver
>>> l = SATSolver([{2, -3}, {1}, {3, -3}, {2, -2},
... {3, -2}], {1, 2, 3}, set())
>>> l.num_learned_clauses
0
>>> l.lit_scores
{-3: -2.0, -2: -2.0, -1: 0.0, 1: 0.0, 2: -2.0, 3: -2.0}
>>> l._vsids_clause_added({2, -3})
>>> l.num_learned_clauses
1
>>> l.lit_scores
{-3: -1.0, -2: -2.0, -1: 0.0, 1: 0.0, 2: -1.0, 3: -2.0}
"""
self.num_learned_clauses += 1
for lit in cls:
self.lit_scores[lit] += 1
########################
# Clause Learning #
########################
def _simple_add_learned_clause(self, cls):
"""Add a new clause to the theory.
Examples
========
>>> from sympy.logic.algorithms.dpll2 import SATSolver
>>> l = SATSolver([{2, -3}, {1}, {3, -3}, {2, -2},
... {3, -2}], {1, 2, 3}, set())
>>> l.num_learned_clauses
0
>>> l.clauses
[[2, -3], [1], [3, -3], [2, -2], [3, -2]]
>>> l.sentinels
{-3: {0, 2}, -2: {3, 4}, 2: {0, 3}, 3: {2, 4}}
>>> l._simple_add_learned_clause([3])
>>> l.clauses
[[2, -3], [1], [3, -3], [2, -2], [3, -2], [3]]
>>> l.sentinels
{-3: {0, 2}, -2: {3, 4}, 2: {0, 3}, 3: {2, 4, 5}}
"""
cls_num = len(self.clauses)
self.clauses.append(cls)
for lit in cls:
self.occurrence_count[lit] += 1
self.sentinels[cls[0]].add(cls_num)
self.sentinels[cls[-1]].add(cls_num)
self.heur_clause_added(cls)
def _simple_compute_conflict(self):
""" Build a clause representing the fact that at least one decision made
so far is wrong.
Examples
========
>>> from sympy.logic.algorithms.dpll2 import SATSolver
>>> l = SATSolver([{2, -3}, {1}, {3, -3}, {2, -2},
... {3, -2}], {1, 2, 3}, set())
>>> next(l._find_model())
{1: True, 2: False, 3: False}
>>> l._simple_compute_conflict()
[3]
"""
return [-(level.decision) for level in self.levels[1:]]
def _simple_clean_clauses(self):
"""Clean up learned clauses."""
pass
class Level:
"""
Represents a single level in the DPLL algorithm, and contains
enough information for a sound backtracking procedure.
"""
def __init__(self, decision, flipped=False):
self.decision = decision
self.var_settings = set()
self.flipped = flipped
|
4a0a4039e083397a3b5d0045f553199f8f4be8c923d6c81a432659982920ee66 | """Implementation of DPLL algorithm
Further improvements: eliminate calls to pl_true, implement branching rules,
efficient unit propagation.
References:
- https://en.wikipedia.org/wiki/DPLL_algorithm
- https://www.researchgate.net/publication/242384772_Implementations_of_the_DPLL_Algorithm
"""
from sympy import default_sort_key
from sympy.logic.boolalg import Or, Not, conjuncts, disjuncts, to_cnf, \
to_int_repr, _find_predicates
from sympy.assumptions.cnf import CNF
from sympy.logic.inference import pl_true, literal_symbol
def dpll_satisfiable(expr):
"""
Check satisfiability of a propositional sentence.
It returns a model rather than True when it succeeds
>>> from sympy.abc import A, B
>>> from sympy.logic.algorithms.dpll import dpll_satisfiable
>>> dpll_satisfiable(A & ~B)
{A: True, B: False}
>>> dpll_satisfiable(A & ~A)
False
"""
if not isinstance(expr, CNF):
clauses = conjuncts(to_cnf(expr))
else:
clauses = expr.clauses
if False in clauses:
return False
symbols = sorted(_find_predicates(expr), key=default_sort_key)
symbols_int_repr = set(range(1, len(symbols) + 1))
clauses_int_repr = to_int_repr(clauses, symbols)
result = dpll_int_repr(clauses_int_repr, symbols_int_repr, {})
if not result:
return result
output = {}
for key in result:
output.update({symbols[key - 1]: result[key]})
return output
def dpll(clauses, symbols, model):
"""
Compute satisfiability in a partial model.
Clauses is an array of conjuncts.
>>> from sympy.abc import A, B, D
>>> from sympy.logic.algorithms.dpll import dpll
>>> dpll([A, B, D], [A, B], {D: False})
False
"""
# compute DP kernel
P, value = find_unit_clause(clauses, model)
while P:
model.update({P: value})
symbols.remove(P)
if not value:
P = ~P
clauses = unit_propagate(clauses, P)
P, value = find_unit_clause(clauses, model)
P, value = find_pure_symbol(symbols, clauses)
while P:
model.update({P: value})
symbols.remove(P)
if not value:
P = ~P
clauses = unit_propagate(clauses, P)
P, value = find_pure_symbol(symbols, clauses)
# end DP kernel
unknown_clauses = []
for c in clauses:
val = pl_true(c, model)
if val is False:
return False
if val is not True:
unknown_clauses.append(c)
if not unknown_clauses:
return model
if not clauses:
return model
P = symbols.pop()
model_copy = model.copy()
model.update({P: True})
model_copy.update({P: False})
symbols_copy = symbols[:]
return (dpll(unit_propagate(unknown_clauses, P), symbols, model) or
dpll(unit_propagate(unknown_clauses, Not(P)), symbols_copy, model_copy))
def dpll_int_repr(clauses, symbols, model):
"""
Compute satisfiability in a partial model.
Arguments are expected to be in integer representation
>>> from sympy.logic.algorithms.dpll import dpll_int_repr
>>> dpll_int_repr([{1}, {2}, {3}], {1, 2}, {3: False})
False
"""
# compute DP kernel
P, value = find_unit_clause_int_repr(clauses, model)
while P:
model.update({P: value})
symbols.remove(P)
if not value:
P = -P
clauses = unit_propagate_int_repr(clauses, P)
P, value = find_unit_clause_int_repr(clauses, model)
P, value = find_pure_symbol_int_repr(symbols, clauses)
while P:
model.update({P: value})
symbols.remove(P)
if not value:
P = -P
clauses = unit_propagate_int_repr(clauses, P)
P, value = find_pure_symbol_int_repr(symbols, clauses)
# end DP kernel
unknown_clauses = []
for c in clauses:
val = pl_true_int_repr(c, model)
if val is False:
return False
if val is not True:
unknown_clauses.append(c)
if not unknown_clauses:
return model
P = symbols.pop()
model_copy = model.copy()
model.update({P: True})
model_copy.update({P: False})
symbols_copy = symbols.copy()
return (dpll_int_repr(unit_propagate_int_repr(unknown_clauses, P), symbols, model) or
dpll_int_repr(unit_propagate_int_repr(unknown_clauses, -P), symbols_copy, model_copy))
### helper methods for DPLL
def pl_true_int_repr(clause, model={}):
"""
Lightweight version of pl_true.
Argument clause represents the set of args of an Or clause. This is used
inside dpll_int_repr, it is not meant to be used directly.
>>> from sympy.logic.algorithms.dpll import pl_true_int_repr
>>> pl_true_int_repr({1, 2}, {1: False})
>>> pl_true_int_repr({1, 2}, {1: False, 2: False})
False
"""
result = False
for lit in clause:
if lit < 0:
p = model.get(-lit)
if p is not None:
p = not p
else:
p = model.get(lit)
if p is True:
return True
elif p is None:
result = None
return result
def unit_propagate(clauses, symbol):
"""
Returns an equivalent set of clauses
If a set of clauses contains the unit clause l, the other clauses are
simplified by the application of the two following rules:
1. every clause containing l is removed
2. in every clause that contains ~l this literal is deleted
Arguments are expected to be in CNF.
>>> from sympy import symbols
>>> from sympy.abc import A, B, D
>>> from sympy.logic.algorithms.dpll import unit_propagate
>>> unit_propagate([A | B, D | ~B, B], B)
[D, B]
"""
output = []
for c in clauses:
if c.func != Or:
output.append(c)
continue
for arg in c.args:
if arg == ~symbol:
output.append(Or(*[x for x in c.args if x != ~symbol]))
break
if arg == symbol:
break
else:
output.append(c)
return output
def unit_propagate_int_repr(clauses, s):
"""
Same as unit_propagate, but arguments are expected to be in integer
representation
>>> from sympy.logic.algorithms.dpll import unit_propagate_int_repr
>>> unit_propagate_int_repr([{1, 2}, {3, -2}, {2}], 2)
[{3}]
"""
negated = {-s}
return [clause - negated for clause in clauses if s not in clause]
def find_pure_symbol(symbols, unknown_clauses):
"""
Find a symbol and its value if it appears only as a positive literal
(or only as a negative) in clauses.
>>> from sympy import symbols
>>> from sympy.abc import A, B, D
>>> from sympy.logic.algorithms.dpll import find_pure_symbol
>>> find_pure_symbol([A, B, D], [A|~B,~B|~D,D|A])
(A, True)
"""
for sym in symbols:
found_pos, found_neg = False, False
for c in unknown_clauses:
if not found_pos and sym in disjuncts(c):
found_pos = True
if not found_neg and Not(sym) in disjuncts(c):
found_neg = True
if found_pos != found_neg:
return sym, found_pos
return None, None
def find_pure_symbol_int_repr(symbols, unknown_clauses):
"""
Same as find_pure_symbol, but arguments are expected
to be in integer representation
>>> from sympy.logic.algorithms.dpll import find_pure_symbol_int_repr
>>> find_pure_symbol_int_repr({1,2,3},
... [{1, -2}, {-2, -3}, {3, 1}])
(1, True)
"""
all_symbols = set().union(*unknown_clauses)
found_pos = all_symbols.intersection(symbols)
found_neg = all_symbols.intersection([-s for s in symbols])
for p in found_pos:
if -p not in found_neg:
return p, True
for p in found_neg:
if -p not in found_pos:
return -p, False
return None, None
def find_unit_clause(clauses, model):
"""
A unit clause has only 1 variable that is not bound in the model.
>>> from sympy import symbols
>>> from sympy.abc import A, B, D
>>> from sympy.logic.algorithms.dpll import find_unit_clause
>>> find_unit_clause([A | B | D, B | ~D, A | ~B], {A:True})
(B, False)
"""
for clause in clauses:
num_not_in_model = 0
for literal in disjuncts(clause):
sym = literal_symbol(literal)
if sym not in model:
num_not_in_model += 1
P, value = sym, not isinstance(literal, Not)
if num_not_in_model == 1:
return P, value
return None, None
def find_unit_clause_int_repr(clauses, model):
"""
Same as find_unit_clause, but arguments are expected to be in
integer representation.
>>> from sympy.logic.algorithms.dpll import find_unit_clause_int_repr
>>> find_unit_clause_int_repr([{1, 2, 3},
... {2, -3}, {1, -2}], {1: True})
(2, False)
"""
bound = set(model) | {-sym for sym in model}
for clause in clauses:
unbound = clause - bound
if len(unbound) == 1:
p = unbound.pop()
if p < 0:
return -p, False
else:
return p, True
return None, None
|
69a1dd5d4383f2464759b4f3b9973a739c4c33c3b5a076d1c723b13e954c31d4 | """For reading in DIMACS file format
www.cs.ubc.ca/~hoos/SATLIB/Benchmarks/SAT/satformat.ps
"""
from sympy.core import Symbol
from sympy.logic.boolalg import And, Or
import re
def load(s):
"""Loads a boolean expression from a string.
Examples
========
>>> from sympy.logic.utilities.dimacs import load
>>> load('1')
cnf_1
>>> load('1 2')
cnf_1 | cnf_2
>>> load('1 \\n 2')
cnf_1 & cnf_2
>>> load('1 2 \\n 3')
cnf_3 & (cnf_1 | cnf_2)
"""
clauses = []
lines = s.split('\n')
pComment = re.compile(r'c.*')
pStats = re.compile(r'p\s*cnf\s*(\d*)\s*(\d*)')
while len(lines) > 0:
line = lines.pop(0)
# Only deal with lines that aren't comments
if not pComment.match(line):
m = pStats.match(line)
if not m:
nums = line.rstrip('\n').split(' ')
list = []
for lit in nums:
if lit != '':
if int(lit) == 0:
continue
num = abs(int(lit))
sign = True
if int(lit) < 0:
sign = False
if sign:
list.append(Symbol("cnf_%s" % num))
else:
list.append(~Symbol("cnf_%s" % num))
if len(list) > 0:
clauses.append(Or(*list))
return And(*clauses)
def load_file(location):
"""Loads a boolean expression from a file."""
with open(location) as f:
s = f.read()
return load(s)
|
86756e8cc522c5be382fcbb9b53065251e3fa11b94cd561833fb61575a2016ec | from sympy.assumptions.ask import Q
from sympy.core.numbers import oo
from sympy.core.relational import Equality, Eq, Ne
from sympy.core.singleton import S
from sympy.core.symbol import (Dummy, symbols)
from sympy.functions import Piecewise
from sympy.functions.elementary.miscellaneous import Max, Min
from sympy.functions.elementary.trigonometric import sin
from sympy.sets.sets import (EmptySet, Interval, Union)
from sympy.simplify.simplify import simplify
from sympy.logic.boolalg import (
And, Boolean, Equivalent, ITE, Implies, Nand, Nor, Not, Or,
POSform, SOPform, Xor, Xnor, conjuncts, disjuncts,
distribute_or_over_and, distribute_and_over_or,
eliminate_implications, is_nnf, is_cnf, is_dnf, simplify_logic,
to_nnf, to_cnf, to_dnf, to_int_repr, bool_map, true, false,
BooleanAtom, is_literal, term_to_integer, integer_to_term,
truth_table, as_Boolean, to_anf, is_anf, distribute_xor_over_and,
anf_coeffs, ANFform, bool_minterm, bool_maxterm, bool_monomial)
from sympy.assumptions.cnf import CNF
from sympy.testing.pytest import raises, XFAIL, slow
from sympy.utilities.iterables import cartes
from itertools import combinations, permutations
A, B, C, D = symbols('A:D')
a, b, c, d, e, w, x, y, z = symbols('a:e w:z')
def test_overloading():
"""Test that |, & are overloaded as expected"""
assert A & B == And(A, B)
assert A | B == Or(A, B)
assert (A & B) | C == Or(And(A, B), C)
assert A >> B == Implies(A, B)
assert A << B == Implies(B, A)
assert ~A == Not(A)
assert A ^ B == Xor(A, B)
def test_And():
assert And() is true
assert And(A) == A
assert And(True) is true
assert And(False) is false
assert And(True, True) is true
assert And(True, False) is false
assert And(False, False) is false
assert And(True, A) == A
assert And(False, A) is false
assert And(True, True, True) is true
assert And(True, True, A) == A
assert And(True, False, A) is false
assert And(1, A) == A
raises(TypeError, lambda: And(2, A))
raises(TypeError, lambda: And(A < 2, A))
assert And(A < 1, A >= 1) is false
e = A > 1
assert And(e, e.canonical) == e.canonical
g, l, ge, le = A > B, B < A, A >= B, B <= A
assert And(g, l, ge, le) == And(ge, g)
assert {And(*i) for i in permutations((l,g,le,ge))} == {And(ge, g)}
assert And(And(Eq(a, 0), Eq(b, 0)), And(Ne(a, 0), Eq(c, 0))) is false
def test_Or():
assert Or() is false
assert Or(A) == A
assert Or(True) is true
assert Or(False) is false
assert Or(True, True) is true
assert Or(True, False) is true
assert Or(False, False) is false
assert Or(True, A) is true
assert Or(False, A) == A
assert Or(True, False, False) is true
assert Or(True, False, A) is true
assert Or(False, False, A) == A
assert Or(1, A) is true
raises(TypeError, lambda: Or(2, A))
raises(TypeError, lambda: Or(A < 2, A))
assert Or(A < 1, A >= 1) is true
e = A > 1
assert Or(e, e.canonical) == e
g, l, ge, le = A > B, B < A, A >= B, B <= A
assert Or(g, l, ge, le) == Or(g, ge)
def test_Xor():
assert Xor() is false
assert Xor(A) == A
assert Xor(A, A) is false
assert Xor(True, A, A) is true
assert Xor(A, A, A, A, A) == A
assert Xor(True, False, False, A, B) == ~Xor(A, B)
assert Xor(True) is true
assert Xor(False) is false
assert Xor(True, True) is false
assert Xor(True, False) is true
assert Xor(False, False) is false
assert Xor(True, A) == ~A
assert Xor(False, A) == A
assert Xor(True, False, False) is true
assert Xor(True, False, A) == ~A
assert Xor(False, False, A) == A
assert isinstance(Xor(A, B), Xor)
assert Xor(A, B, Xor(C, D)) == Xor(A, B, C, D)
assert Xor(A, B, Xor(B, C)) == Xor(A, C)
assert Xor(A < 1, A >= 1, B) == Xor(0, 1, B) == Xor(1, 0, B)
e = A > 1
assert Xor(e, e.canonical) == Xor(0, 0) == Xor(1, 1)
def test_rewrite_as_And():
expr = x ^ y
assert expr.rewrite(And) == (x | y) & (~x | ~y)
def test_rewrite_as_Or():
expr = x ^ y
assert expr.rewrite(Or) == (x & ~y) | (y & ~x)
def test_rewrite_as_Nand():
expr = (y & z) | (z & ~w)
assert expr.rewrite(Nand) == ~(~(y & z) & ~(z & ~w))
def test_rewrite_as_Nor():
expr = z & (y | ~w)
assert expr.rewrite(Nor) == ~(~z | ~(y | ~w))
def test_Not():
raises(TypeError, lambda: Not(True, False))
assert Not(True) is false
assert Not(False) is true
assert Not(0) is true
assert Not(1) is false
assert Not(2) is false
def test_Nand():
assert Nand() is false
assert Nand(A) == ~A
assert Nand(True) is false
assert Nand(False) is true
assert Nand(True, True) is false
assert Nand(True, False) is true
assert Nand(False, False) is true
assert Nand(True, A) == ~A
assert Nand(False, A) is true
assert Nand(True, True, True) is false
assert Nand(True, True, A) == ~A
assert Nand(True, False, A) is true
def test_Nor():
assert Nor() is true
assert Nor(A) == ~A
assert Nor(True) is false
assert Nor(False) is true
assert Nor(True, True) is false
assert Nor(True, False) is false
assert Nor(False, False) is true
assert Nor(True, A) is false
assert Nor(False, A) == ~A
assert Nor(True, True, True) is false
assert Nor(True, True, A) is false
assert Nor(True, False, A) is false
def test_Xnor():
assert Xnor() is true
assert Xnor(A) == ~A
assert Xnor(A, A) is true
assert Xnor(True, A, A) is false
assert Xnor(A, A, A, A, A) == ~A
assert Xnor(True) is false
assert Xnor(False) is true
assert Xnor(True, True) is true
assert Xnor(True, False) is false
assert Xnor(False, False) is true
assert Xnor(True, A) == A
assert Xnor(False, A) == ~A
assert Xnor(True, False, False) is false
assert Xnor(True, False, A) == A
assert Xnor(False, False, A) == ~A
def test_Implies():
raises(ValueError, lambda: Implies(A, B, C))
assert Implies(True, True) is true
assert Implies(True, False) is false
assert Implies(False, True) is true
assert Implies(False, False) is true
assert Implies(0, A) is true
assert Implies(1, 1) is true
assert Implies(1, 0) is false
assert A >> B == B << A
assert (A < 1) >> (A >= 1) == (A >= 1)
assert (A < 1) >> (S.One > A) is true
assert A >> A is true
def test_Equivalent():
assert Equivalent(A, B) == Equivalent(B, A) == Equivalent(A, B, A)
assert Equivalent() is true
assert Equivalent(A, A) == Equivalent(A) is true
assert Equivalent(True, True) == Equivalent(False, False) is true
assert Equivalent(True, False) == Equivalent(False, True) is false
assert Equivalent(A, True) == A
assert Equivalent(A, False) == Not(A)
assert Equivalent(A, B, True) == A & B
assert Equivalent(A, B, False) == ~A & ~B
assert Equivalent(1, A) == A
assert Equivalent(0, A) == Not(A)
assert Equivalent(A, Equivalent(B, C)) != Equivalent(Equivalent(A, B), C)
assert Equivalent(A < 1, A >= 1) is false
assert Equivalent(A < 1, A >= 1, 0) is false
assert Equivalent(A < 1, A >= 1, 1) is false
assert Equivalent(A < 1, S.One > A) == Equivalent(1, 1) == Equivalent(0, 0)
assert Equivalent(Equality(A, B), Equality(B, A)) is true
def test_equals():
assert Not(Or(A, B)).equals(And(Not(A), Not(B))) is True
assert Equivalent(A, B).equals((A >> B) & (B >> A)) is True
assert ((A | ~B) & (~A | B)).equals((~A & ~B) | (A & B)) is True
assert (A >> B).equals(~A >> ~B) is False
assert (A >> (B >> A)).equals(A >> (C >> A)) is False
raises(NotImplementedError, lambda: (A & B).equals(A > B))
def test_simplification():
"""
Test working of simplification methods.
"""
set1 = [[0, 0, 1], [0, 1, 1], [1, 0, 0], [1, 1, 0]]
set2 = [[0, 0, 0], [0, 1, 0], [1, 0, 1], [1, 1, 1]]
assert SOPform([x, y, z], set1) == Or(And(Not(x), z), And(Not(z), x))
assert Not(SOPform([x, y, z], set2)) == \
Not(Or(And(Not(x), Not(z)), And(x, z)))
assert POSform([x, y, z], set1 + set2) is true
assert SOPform([x, y, z], set1 + set2) is true
assert SOPform([Dummy(), Dummy(), Dummy()], set1 + set2) is true
minterms = [[0, 0, 0, 1], [0, 0, 1, 1], [0, 1, 1, 1], [1, 0, 1, 1],
[1, 1, 1, 1]]
dontcares = [[0, 0, 0, 0], [0, 0, 1, 0], [0, 1, 0, 1]]
assert (
SOPform([w, x, y, z], minterms, dontcares) ==
Or(And(Not(w), z), And(y, z)))
assert POSform([w, x, y, z], minterms, dontcares) == And(Or(Not(w), y), z)
minterms = [1, 3, 7, 11, 15]
dontcares = [0, 2, 5]
assert (
SOPform([w, x, y, z], minterms, dontcares) ==
Or(And(Not(w), z), And(y, z)))
assert POSform([w, x, y, z], minterms, dontcares) == And(Or(Not(w), y), z)
minterms = [1, [0, 0, 1, 1], 7, [1, 0, 1, 1],
[1, 1, 1, 1]]
dontcares = [0, [0, 0, 1, 0], 5]
assert (
SOPform([w, x, y, z], minterms, dontcares) ==
Or(And(Not(w), z), And(y, z)))
assert POSform([w, x, y, z], minterms, dontcares) == And(Or(Not(w), y), z)
minterms = [1, {y: 1, z: 1}]
dontcares = [0, [0, 0, 1, 0], 5]
assert (
SOPform([w, x, y, z], minterms, dontcares) ==
Or(And(Not(w), z), And(y, z)))
assert POSform([w, x, y, z], minterms, dontcares) == And(Or(Not(w), y), z)
minterms = [{y: 1, z: 1}, 1]
dontcares = [[0, 0, 0, 0]]
minterms = [[0, 0, 0]]
raises(ValueError, lambda: SOPform([w, x, y, z], minterms))
raises(ValueError, lambda: POSform([w, x, y, z], minterms))
raises(TypeError, lambda: POSform([w, x, y, z], ["abcdefg"]))
# test simplification
ans = And(A, Or(B, C))
assert simplify_logic(A & (B | C)) == ans
assert simplify_logic((A & B) | (A & C)) == ans
assert simplify_logic(Implies(A, B)) == Or(Not(A), B)
assert simplify_logic(Equivalent(A, B)) == \
Or(And(A, B), And(Not(A), Not(B)))
assert simplify_logic(And(Equality(A, 2), C)) == And(Equality(A, 2), C)
assert simplify_logic(And(Equality(A, 2), A)) is S.false
assert simplify_logic(And(Equality(A, 2), A)) == And(Equality(A, 2), A)
assert simplify_logic(And(Equality(A, B), C)) == And(Equality(A, B), C)
assert simplify_logic(Or(And(Equality(A, 3), B), And(Equality(A, 3), C))) \
== And(Equality(A, 3), Or(B, C))
b = (~x & ~y & ~z) | (~x & ~y & z)
e = And(A, b)
assert simplify_logic(e) == A & ~x & ~y
raises(ValueError, lambda: simplify_logic(A & (B | C), form='blabla'))
# Check that expressions with nine variables or more are not simplified
# (without the force-flag)
a, b, c, d, e, f, g, h, j = symbols('a b c d e f g h j')
expr = a & b & c & d & e & f & g & h & j | \
a & b & c & d & e & f & g & h & ~j
# This expression can be simplified to get rid of the j variables
assert simplify_logic(expr) == expr
# check input
ans = SOPform([x, y], [[1, 0]])
assert SOPform([x, y], [[1, 0]]) == ans
assert POSform([x, y], [[1, 0]]) == ans
raises(ValueError, lambda: SOPform([x], [[1]], [[1]]))
assert SOPform([x], [[1]], [[0]]) is true
assert SOPform([x], [[0]], [[1]]) is true
assert SOPform([x], [], []) is false
raises(ValueError, lambda: POSform([x], [[1]], [[1]]))
assert POSform([x], [[1]], [[0]]) is true
assert POSform([x], [[0]], [[1]]) is true
assert POSform([x], [], []) is false
# check working of simplify
assert simplify((A & B) | (A & C)) == And(A, Or(B, C))
assert simplify(And(x, Not(x))) == False
assert simplify(Or(x, Not(x))) == True
assert simplify(And(Eq(x, 0), Eq(x, y))) == And(Eq(x, 0), Eq(y, 0))
assert And(Eq(x - 1, 0), Eq(x, y)).simplify() == And(Eq(x, 1), Eq(y, 1))
assert And(Ne(x - 1, 0), Ne(x, y)).simplify() == And(Ne(x, 1), Ne(x, y))
assert And(Eq(x - 1, 0), Ne(x, y)).simplify() == And(Eq(x, 1), Ne(y, 1))
assert And(Eq(x - 1, 0), Eq(x, z + y), Eq(y + x, 0)).simplify(
) == And(Eq(x, 1), Eq(y, -1), Eq(z, 2))
assert And(Eq(x - 1, 0), Eq(x + 2, 3)).simplify() == Eq(x, 1)
assert And(Ne(x - 1, 0), Ne(x + 2, 3)).simplify() == Ne(x, 1)
assert And(Eq(x - 1, 0), Eq(x + 2, 2)).simplify() == False
assert And(Ne(x - 1, 0), Ne(x + 2, 2)).simplify(
) == And(Ne(x, 1), Ne(x, 0))
def test_bool_map():
"""
Test working of bool_map function.
"""
minterms = [[0, 0, 0, 1], [0, 0, 1, 1], [0, 1, 1, 1], [1, 0, 1, 1],
[1, 1, 1, 1]]
assert bool_map(Not(Not(a)), a) == (a, {a: a})
assert bool_map(SOPform([w, x, y, z], minterms),
POSform([w, x, y, z], minterms)) == \
(And(Or(Not(w), y), Or(Not(x), y), z), {x: x, w: w, z: z, y: y})
assert bool_map(SOPform([x, z, y], [[1, 0, 1]]),
SOPform([a, b, c], [[1, 0, 1]])) != False
function1 = SOPform([x, z, y], [[1, 0, 1], [0, 0, 1]])
function2 = SOPform([a, b, c], [[1, 0, 1], [1, 0, 0]])
assert bool_map(function1, function2) == \
(function1, {y: a, z: b})
assert bool_map(Xor(x, y), ~Xor(x, y)) == False
assert bool_map(And(x, y), Or(x, y)) is None
assert bool_map(And(x, y), And(x, y, z)) is None
# issue 16179
assert bool_map(Xor(x, y, z), ~Xor(x, y, z)) == False
assert bool_map(Xor(a, x, y, z), ~Xor(a, x, y, z)) == False
def test_bool_symbol():
"""Test that mixing symbols with boolean values
works as expected"""
assert And(A, True) == A
assert And(A, True, True) == A
assert And(A, False) is false
assert And(A, True, False) is false
assert Or(A, True) is true
assert Or(A, False) == A
def test_is_boolean():
assert isinstance(True, Boolean) is False
assert isinstance(true, Boolean) is True
assert 1 == True
assert 1 != true
assert (1 == true) is False
assert 0 == False
assert 0 != false
assert (0 == false) is False
assert true.is_Boolean is True
assert (A & B).is_Boolean
assert (A | B).is_Boolean
assert (~A).is_Boolean
assert (A ^ B).is_Boolean
assert A.is_Boolean != isinstance(A, Boolean)
assert isinstance(A, Boolean)
def test_subs():
assert (A & B).subs(A, True) == B
assert (A & B).subs(A, False) is false
assert (A & B).subs(B, True) == A
assert (A & B).subs(B, False) is false
assert (A & B).subs({A: True, B: True}) is true
assert (A | B).subs(A, True) is true
assert (A | B).subs(A, False) == B
assert (A | B).subs(B, True) is true
assert (A | B).subs(B, False) == A
assert (A | B).subs({A: True, B: True}) is true
"""
we test for axioms of boolean algebra
see https://en.wikipedia.org/wiki/Boolean_algebra_(structure)
"""
def test_commutative():
"""Test for commutativity of And and Or"""
A, B = map(Boolean, symbols('A,B'))
assert A & B == B & A
assert A | B == B | A
def test_and_associativity():
"""Test for associativity of And"""
assert (A & B) & C == A & (B & C)
def test_or_assicativity():
assert ((A | B) | C) == (A | (B | C))
def test_double_negation():
a = Boolean()
assert ~(~a) == a
# test methods
def test_eliminate_implications():
assert eliminate_implications(Implies(A, B, evaluate=False)) == (~A) | B
assert eliminate_implications(
A >> (C >> Not(B))) == Or(Or(Not(B), Not(C)), Not(A))
assert eliminate_implications(Equivalent(A, B, C, D)) == \
(~A | B) & (~B | C) & (~C | D) & (~D | A)
def test_conjuncts():
assert conjuncts(A & B & C) == {A, B, C}
assert conjuncts((A | B) & C) == {A | B, C}
assert conjuncts(A) == {A}
assert conjuncts(True) == {True}
assert conjuncts(False) == {False}
def test_disjuncts():
assert disjuncts(A | B | C) == {A, B, C}
assert disjuncts((A | B) & C) == {(A | B) & C}
assert disjuncts(A) == {A}
assert disjuncts(True) == {True}
assert disjuncts(False) == {False}
def test_distribute():
assert distribute_and_over_or(Or(And(A, B), C)) == And(Or(A, C), Or(B, C))
assert distribute_or_over_and(And(A, Or(B, C))) == Or(And(A, B), And(A, C))
assert distribute_xor_over_and(And(A, Xor(B, C))) == Xor(And(A, B), And(A, C))
def test_to_anf():
x, y, z = symbols('x,y,z')
assert to_anf(And(x, y)) == And(x, y)
assert to_anf(Or(x, y)) == Xor(x, y, And(x, y))
assert to_anf(Or(Implies(x, y), And(x, y), y)) == \
Xor(x, True, x & y, remove_true=False)
assert to_anf(Or(Nand(x, y), Nor(x, y), Xnor(x, y), Implies(x, y))) == True
assert to_anf(Or(x, Not(y), Nor(x,z), And(x, y), Nand(y, z))) == \
Xor(True, And(y, z), And(x, y, z), remove_true=False)
assert to_anf(Xor(x, y)) == Xor(x, y)
assert to_anf(Not(x)) == Xor(x, True, remove_true=False)
assert to_anf(Nand(x, y)) == Xor(True, And(x, y), remove_true=False)
assert to_anf(Nor(x, y)) == Xor(x, y, True, And(x, y), remove_true=False)
assert to_anf(Implies(x, y)) == Xor(x, True, And(x, y), remove_true=False)
assert to_anf(Equivalent(x, y)) == Xor(x, y, True, remove_true=False)
assert to_anf(Nand(x | y, x >> y), deep=False) == \
Xor(True, And(Or(x, y), Implies(x, y)), remove_true=False)
assert to_anf(Nor(x ^ y, x & y), deep=False) == \
Xor(True, Or(Xor(x, y), And(x, y)), remove_true=False)
def test_to_nnf():
assert to_nnf(true) is true
assert to_nnf(false) is false
assert to_nnf(A) == A
assert to_nnf(A | ~A | B) is true
assert to_nnf(A & ~A & B) is false
assert to_nnf(A >> B) == ~A | B
assert to_nnf(Equivalent(A, B, C)) == (~A | B) & (~B | C) & (~C | A)
assert to_nnf(A ^ B ^ C) == \
(A | B | C) & (~A | ~B | C) & (A | ~B | ~C) & (~A | B | ~C)
assert to_nnf(ITE(A, B, C)) == (~A | B) & (A | C)
assert to_nnf(Not(A | B | C)) == ~A & ~B & ~C
assert to_nnf(Not(A & B & C)) == ~A | ~B | ~C
assert to_nnf(Not(A >> B)) == A & ~B
assert to_nnf(Not(Equivalent(A, B, C))) == And(Or(A, B, C), Or(~A, ~B, ~C))
assert to_nnf(Not(A ^ B ^ C)) == \
(~A | B | C) & (A | ~B | C) & (A | B | ~C) & (~A | ~B | ~C)
assert to_nnf(Not(ITE(A, B, C))) == (~A | ~B) & (A | ~C)
assert to_nnf((A >> B) ^ (B >> A)) == (A & ~B) | (~A & B)
assert to_nnf((A >> B) ^ (B >> A), False) == \
(~A | ~B | A | B) & ((A & ~B) | (~A & B))
assert ITE(A, 1, 0).to_nnf() == A
assert ITE(A, 0, 1).to_nnf() == ~A
# although ITE can hold non-Boolean, it will complain if
# an attempt is made to convert the ITE to Boolean nnf
raises(TypeError, lambda: ITE(A < 1, [1], B).to_nnf())
def test_to_cnf():
assert to_cnf(~(B | C)) == And(Not(B), Not(C))
assert to_cnf((A & B) | C) == And(Or(A, C), Or(B, C))
assert to_cnf(A >> B) == (~A) | B
assert to_cnf(A >> (B & C)) == (~A | B) & (~A | C)
assert to_cnf(A & (B | C) | ~A & (B | C), True) == B | C
assert to_cnf(A & B) == And(A, B)
assert to_cnf(Equivalent(A, B)) == And(Or(A, Not(B)), Or(B, Not(A)))
assert to_cnf(Equivalent(A, B & C)) == \
(~A | B) & (~A | C) & (~B | ~C | A)
assert to_cnf(Equivalent(A, B | C), True) == \
And(Or(Not(B), A), Or(Not(C), A), Or(B, C, Not(A)))
assert to_cnf(A + 1) == A + 1
def test_issue_18904():
x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15 = symbols('x1:16')
eq = (( x1 & x2 & x3 & x4 & x5 & x6 & x7 & x8 & x9 ) |
( x1 & x2 & x3 & x4 & x5 & x6 & x7 & x10 & x9 ) |
( x1 & x11 & x3 & x12 & x5 & x13 & x14 & x15 & x9 ))
assert is_cnf(to_cnf(eq))
raises(ValueError, lambda: to_cnf(eq, simplify=True))
for f, t in zip((And, Or), (to_cnf, to_dnf)):
eq = f(x1, x2, x3, x4, x5, x6, x7, x8, x9)
raises(ValueError, lambda: to_cnf(eq, simplify=True))
assert t(eq, simplify=True, force=True) == eq
def test_issue_9949():
assert is_cnf(to_cnf((b > -5) | (a > 2) & (a < 4)))
def test_to_CNF():
assert CNF.CNF_to_cnf(CNF.to_CNF(~(B | C))) == to_cnf(~(B | C))
assert CNF.CNF_to_cnf(CNF.to_CNF((A & B) | C)) == to_cnf((A & B) | C)
assert CNF.CNF_to_cnf(CNF.to_CNF(A >> B)) == to_cnf(A >> B)
assert CNF.CNF_to_cnf(CNF.to_CNF(A >> (B & C))) == to_cnf(A >> (B & C))
assert CNF.CNF_to_cnf(CNF.to_CNF(A & (B | C) | ~A & (B | C))) == to_cnf(A & (B | C) | ~A & (B | C))
assert CNF.CNF_to_cnf(CNF.to_CNF(A & B)) == to_cnf(A & B)
def test_to_dnf():
assert to_dnf(~(B | C)) == And(Not(B), Not(C))
assert to_dnf(A & (B | C)) == Or(And(A, B), And(A, C))
assert to_dnf(A >> B) == (~A) | B
assert to_dnf(A >> (B & C)) == (~A) | (B & C)
assert to_dnf(A | B) == A | B
assert to_dnf(Equivalent(A, B), True) == \
Or(And(A, B), And(Not(A), Not(B)))
assert to_dnf(Equivalent(A, B & C), True) == \
Or(And(A, B, C), And(Not(A), Not(B)), And(Not(A), Not(C)))
assert to_dnf(A + 1) == A + 1
def test_to_int_repr():
x, y, z = map(Boolean, symbols('x,y,z'))
def sorted_recursive(arg):
try:
return sorted(sorted_recursive(x) for x in arg)
except TypeError: # arg is not a sequence
return arg
assert sorted_recursive(to_int_repr([x | y, z | x], [x, y, z])) == \
sorted_recursive([[1, 2], [1, 3]])
assert sorted_recursive(to_int_repr([x | y, z | ~x], [x, y, z])) == \
sorted_recursive([[1, 2], [3, -1]])
def test_is_anf():
x, y = symbols('x,y')
assert is_anf(true) is True
assert is_anf(false) is True
assert is_anf(x) is True
assert is_anf(And(x, y)) is True
assert is_anf(Xor(x, y, And(x, y))) is True
assert is_anf(Xor(x, y, Or(x, y))) is False
assert is_anf(Xor(Not(x), y)) is False
def test_is_nnf():
assert is_nnf(true) is True
assert is_nnf(A) is True
assert is_nnf(~A) is True
assert is_nnf(A & B) is True
assert is_nnf((A & B) | (~A & A) | (~B & B) | (~A & ~B), False) is True
assert is_nnf((A | B) & (~A | ~B)) is True
assert is_nnf(Not(Or(A, B))) is False
assert is_nnf(A ^ B) is False
assert is_nnf((A & B) | (~A & A) | (~B & B) | (~A & ~B), True) is False
def test_is_cnf():
assert is_cnf(x) is True
assert is_cnf(x | y | z) is True
assert is_cnf(x & y & z) is True
assert is_cnf((x | y) & z) is True
assert is_cnf((x & y) | z) is False
assert is_cnf(~(x & y) | z) is False
def test_is_dnf():
assert is_dnf(x) is True
assert is_dnf(x | y | z) is True
assert is_dnf(x & y & z) is True
assert is_dnf((x & y) | z) is True
assert is_dnf((x | y) & z) is False
assert is_dnf(~(x | y) & z) is False
def test_ITE():
A, B, C = symbols('A:C')
assert ITE(True, False, True) is false
assert ITE(True, True, False) is true
assert ITE(False, True, False) is false
assert ITE(False, False, True) is true
assert isinstance(ITE(A, B, C), ITE)
A = True
assert ITE(A, B, C) == B
A = False
assert ITE(A, B, C) == C
B = True
assert ITE(And(A, B), B, C) == C
assert ITE(Or(A, False), And(B, True), False) is false
assert ITE(x, A, B) == Not(x)
assert ITE(x, B, A) == x
assert ITE(1, x, y) == x
assert ITE(0, x, y) == y
raises(TypeError, lambda: ITE(2, x, y))
raises(TypeError, lambda: ITE(1, [], y))
raises(TypeError, lambda: ITE(1, (), y))
raises(TypeError, lambda: ITE(1, y, []))
assert ITE(1, 1, 1) is S.true
assert isinstance(ITE(1, 1, 1, evaluate=False), ITE)
raises(TypeError, lambda: ITE(x > 1, y, x))
assert ITE(Eq(x, True), y, x) == ITE(x, y, x)
assert ITE(Eq(x, False), y, x) == ITE(~x, y, x)
assert ITE(Ne(x, True), y, x) == ITE(~x, y, x)
assert ITE(Ne(x, False), y, x) == ITE(x, y, x)
assert ITE(Eq(S. true, x), y, x) == ITE(x, y, x)
assert ITE(Eq(S.false, x), y, x) == ITE(~x, y, x)
assert ITE(Ne(S.true, x), y, x) == ITE(~x, y, x)
assert ITE(Ne(S.false, x), y, x) == ITE(x, y, x)
# 0 and 1 in the context are not treated as True/False
# so the equality must always be False since dissimilar
# objects cannot be equal
assert ITE(Eq(x, 0), y, x) == x
assert ITE(Eq(x, 1), y, x) == x
assert ITE(Ne(x, 0), y, x) == y
assert ITE(Ne(x, 1), y, x) == y
assert ITE(Eq(x, 0), y, z).subs(x, 0) == y
assert ITE(Eq(x, 0), y, z).subs(x, 1) == z
raises(ValueError, lambda: ITE(x > 1, y, x, z))
def test_is_literal():
assert is_literal(True) is True
assert is_literal(False) is True
assert is_literal(A) is True
assert is_literal(~A) is True
assert is_literal(Or(A, B)) is False
assert is_literal(Q.zero(A)) is True
assert is_literal(Not(Q.zero(A))) is True
assert is_literal(Or(A, B)) is False
assert is_literal(And(Q.zero(A), Q.zero(B))) is False
assert is_literal(x < 3)
assert not is_literal(x + y < 3)
def test_operators():
# Mostly test __and__, __rand__, and so on
assert True & A == A & True == A
assert False & A == A & False == False
assert A & B == And(A, B)
assert True | A == A | True == True
assert False | A == A | False == A
assert A | B == Or(A, B)
assert ~A == Not(A)
assert True >> A == A << True == A
assert False >> A == A << False == True
assert A >> True == True << A == True
assert A >> False == False << A == ~A
assert A >> B == B << A == Implies(A, B)
assert True ^ A == A ^ True == ~A
assert False ^ A == A ^ False == A
assert A ^ B == Xor(A, B)
def test_true_false():
assert true is S.true
assert false is S.false
assert true is not True
assert false is not False
assert true
assert not false
assert true == True
assert false == False
assert not (true == False)
assert not (false == True)
assert not (true == false)
assert hash(true) == hash(True)
assert hash(false) == hash(False)
assert len({true, True}) == len({false, False}) == 1
assert isinstance(true, BooleanAtom)
assert isinstance(false, BooleanAtom)
# We don't want to subclass from bool, because bool subclasses from
# int. But operators like &, |, ^, <<, >>, and ~ act differently on 0 and
# 1 then we want them to on true and false. See the docstrings of the
# various And, Or, etc. functions for examples.
assert not isinstance(true, bool)
assert not isinstance(false, bool)
# Note: using 'is' comparison is important here. We want these to return
# true and false, not True and False
assert Not(true) is false
assert Not(True) is false
assert Not(false) is true
assert Not(False) is true
assert ~true is false
assert ~false is true
for T, F in cartes([True, true], [False, false]):
assert And(T, F) is false
assert And(F, T) is false
assert And(F, F) is false
assert And(T, T) is true
assert And(T, x) == x
assert And(F, x) is false
if not (T is True and F is False):
assert T & F is false
assert F & T is false
if F is not False:
assert F & F is false
if T is not True:
assert T & T is true
assert Or(T, F) is true
assert Or(F, T) is true
assert Or(F, F) is false
assert Or(T, T) is true
assert Or(T, x) is true
assert Or(F, x) == x
if not (T is True and F is False):
assert T | F is true
assert F | T is true
if F is not False:
assert F | F is false
if T is not True:
assert T | T is true
assert Xor(T, F) is true
assert Xor(F, T) is true
assert Xor(F, F) is false
assert Xor(T, T) is false
assert Xor(T, x) == ~x
assert Xor(F, x) == x
if not (T is True and F is False):
assert T ^ F is true
assert F ^ T is true
if F is not False:
assert F ^ F is false
if T is not True:
assert T ^ T is false
assert Nand(T, F) is true
assert Nand(F, T) is true
assert Nand(F, F) is true
assert Nand(T, T) is false
assert Nand(T, x) == ~x
assert Nand(F, x) is true
assert Nor(T, F) is false
assert Nor(F, T) is false
assert Nor(F, F) is true
assert Nor(T, T) is false
assert Nor(T, x) is false
assert Nor(F, x) == ~x
assert Implies(T, F) is false
assert Implies(F, T) is true
assert Implies(F, F) is true
assert Implies(T, T) is true
assert Implies(T, x) == x
assert Implies(F, x) is true
assert Implies(x, T) is true
assert Implies(x, F) == ~x
if not (T is True and F is False):
assert T >> F is false
assert F << T is false
assert F >> T is true
assert T << F is true
if F is not False:
assert F >> F is true
assert F << F is true
if T is not True:
assert T >> T is true
assert T << T is true
assert Equivalent(T, F) is false
assert Equivalent(F, T) is false
assert Equivalent(F, F) is true
assert Equivalent(T, T) is true
assert Equivalent(T, x) == x
assert Equivalent(F, x) == ~x
assert Equivalent(x, T) == x
assert Equivalent(x, F) == ~x
assert ITE(T, T, T) is true
assert ITE(T, T, F) is true
assert ITE(T, F, T) is false
assert ITE(T, F, F) is false
assert ITE(F, T, T) is true
assert ITE(F, T, F) is false
assert ITE(F, F, T) is true
assert ITE(F, F, F) is false
assert all(i.simplify(1, 2) is i for i in (S.true, S.false))
def test_bool_as_set():
assert ITE(y <= 0, False, y >= 1).as_set() == Interval(1, oo)
assert And(x <= 2, x >= -2).as_set() == Interval(-2, 2)
assert Or(x >= 2, x <= -2).as_set() == Interval(-oo, -2) + Interval(2, oo)
assert Not(x > 2).as_set() == Interval(-oo, 2)
# issue 10240
assert Not(And(x > 2, x < 3)).as_set() == \
Union(Interval(-oo, 2), Interval(3, oo))
assert true.as_set() == S.UniversalSet
assert false.as_set() == EmptySet()
assert x.as_set() == S.UniversalSet
assert And(Or(x < 1, x > 3), x < 2).as_set() == Interval.open(-oo, 1)
assert And(x < 1, sin(x) < 3).as_set() == (x < 1).as_set()
raises(NotImplementedError, lambda: (sin(x) < 1).as_set())
@XFAIL
def test_multivariate_bool_as_set():
x, y = symbols('x,y')
assert And(x >= 0, y >= 0).as_set() == Interval(0, oo)*Interval(0, oo)
assert Or(x >= 0, y >= 0).as_set() == S.Reals*S.Reals - \
Interval(-oo, 0, True, True)*Interval(-oo, 0, True, True)
def test_all_or_nothing():
x = symbols('x', extended_real=True)
args = x >= -oo, x <= oo
v = And(*args)
if v.func is And:
assert len(v.args) == len(args) - args.count(S.true)
else:
assert v == True
v = Or(*args)
if v.func is Or:
assert len(v.args) == 2
else:
assert v == True
def test_canonical_atoms():
assert true.canonical == true
assert false.canonical == false
def test_negated_atoms():
assert true.negated == false
assert false.negated == true
def test_issue_8777():
assert And(x > 2, x < oo).as_set() == Interval(2, oo, left_open=True)
assert And(x >= 1, x < oo).as_set() == Interval(1, oo)
assert (x < oo).as_set() == Interval(-oo, oo)
assert (x > -oo).as_set() == Interval(-oo, oo)
def test_issue_8975():
assert Or(And(-oo < x, x <= -2), And(2 <= x, x < oo)).as_set() == \
Interval(-oo, -2) + Interval(2, oo)
def test_term_to_integer():
assert term_to_integer([1, 0, 1, 0, 0, 1, 0]) == 82
assert term_to_integer('0010101000111001') == 10809
def test_integer_to_term():
assert integer_to_term(777) == [1, 1, 0, 0, 0, 0, 1, 0, 0, 1]
assert integer_to_term(123, 3) == [1, 1, 1, 1, 0, 1, 1]
assert integer_to_term(456, 16) == [0, 0, 0, 0, 0, 0, 0, 1,
1, 1, 0, 0, 1, 0, 0, 0]
def test_truth_table():
assert list(truth_table(And(x, y), [x, y], input=False)) == \
[False, False, False, True]
assert list(truth_table(x | y, [x, y], input=False)) == \
[False, True, True, True]
assert list(truth_table(x >> y, [x, y], input=False)) == \
[True, True, False, True]
assert list(truth_table(And(x, y), [x, y])) == \
[([0, 0], False), ([0, 1], False), ([1, 0], False), ([1, 1], True)]
def test_issue_8571():
for t in (S.true, S.false):
raises(TypeError, lambda: +t)
raises(TypeError, lambda: -t)
raises(TypeError, lambda: abs(t))
# use int(bool(t)) to get 0 or 1
raises(TypeError, lambda: int(t))
for o in [S.Zero, S.One, x]:
for _ in range(2):
raises(TypeError, lambda: o + t)
raises(TypeError, lambda: o - t)
raises(TypeError, lambda: o % t)
raises(TypeError, lambda: o*t)
raises(TypeError, lambda: o/t)
raises(TypeError, lambda: o**t)
o, t = t, o # do again in reversed order
def test_expand_relational():
n = symbols('n', negative=True)
p, q = symbols('p q', positive=True)
r = ((n + q*(-n/q + 1))/(q*(-n/q + 1)) < 0)
assert r is not S.false
assert r.expand() is S.false
assert (q > 0).expand() is S.true
def test_issue_12717():
assert S.true.is_Atom == True
assert S.false.is_Atom == True
def test_as_Boolean():
nz = symbols('nz', nonzero=True)
assert all(as_Boolean(i) is S.true for i in (True, S.true, 1, nz))
z = symbols('z', zero=True)
assert all(as_Boolean(i) is S.false for i in (False, S.false, 0, z))
assert all(as_Boolean(i) == i for i in (x, x < 0))
for i in (2, S(2), x + 1, []):
raises(TypeError, lambda: as_Boolean(i))
def test_binary_symbols():
assert ITE(x < 1, y, z).binary_symbols == {y, z}
for f in (Eq, Ne):
assert f(x, 1).binary_symbols == set()
assert f(x, True).binary_symbols == {x}
assert f(x, False).binary_symbols == {x}
assert S.true.binary_symbols == set()
assert S.false.binary_symbols == set()
assert x.binary_symbols == {x}
assert And(x, Eq(y, False), Eq(z, 1)).binary_symbols == {x, y}
assert Q.prime(x).binary_symbols == set()
assert Q.is_true(x < 1).binary_symbols == set()
assert Q.is_true(x).binary_symbols == {x}
assert Q.is_true(Eq(x, True)).binary_symbols == {x}
assert Q.prime(x).binary_symbols == set()
def test_BooleanFunction_diff():
assert And(x, y).diff(x) == Piecewise((0, Eq(y, False)), (1, True))
def test_issue_14700():
A, B, C, D, E, F, G, H = symbols('A B C D E F G H')
q = ((B & D & H & ~F) | (B & H & ~C & ~D) | (B & H & ~C & ~F) |
(B & H & ~D & ~G) | (B & H & ~F & ~G) | (C & G & ~B & ~D) |
(C & G & ~D & ~H) | (C & G & ~F & ~H) | (D & F & H & ~B) |
(D & F & ~G & ~H) | (B & D & F & ~C & ~H) | (D & E & F & ~B & ~C) |
(D & F & ~A & ~B & ~C) | (D & F & ~A & ~C & ~H) |
(A & B & D & F & ~E & ~H))
soldnf = ((B & D & H & ~F) | (D & F & H & ~B) | (B & H & ~C & ~D) |
(B & H & ~D & ~G) | (C & G & ~B & ~D) | (C & G & ~D & ~H) |
(C & G & ~F & ~H) | (D & F & ~G & ~H) | (D & E & F & ~C & ~H) |
(D & F & ~A & ~C & ~H) | (A & B & D & F & ~E & ~H))
solcnf = ((B | C | D) & (B | D | G) & (C | D | H) & (C | F | H) &
(D | G | H) & (F | G | H) & (B | F | ~D | ~H) &
(~B | ~D | ~F | ~H) & (D | ~B | ~C | ~G | ~H) &
(A | H | ~C | ~D | ~F | ~G) & (H | ~C | ~D | ~E | ~F | ~G) &
(B | E | H | ~A | ~D | ~F | ~G))
assert simplify_logic(q, "dnf") == soldnf
assert simplify_logic(q, "cnf") == solcnf
minterms = [[0, 1, 0, 0], [0, 1, 0, 1], [0, 1, 1, 0], [0, 1, 1, 1],
[0, 0, 1, 1], [1, 0, 1, 1]]
dontcares = [[1, 0, 0, 0], [1, 0, 0, 1], [1, 1, 0, 0], [1, 1, 0, 1]]
assert SOPform([w, x, y, z], minterms) == (x & ~w) | (y & z & ~x)
# Should not be more complicated with don't cares
assert SOPform([w, x, y, z], minterms, dontcares) == \
(x & ~w) | (y & z & ~x)
def test_relational_simplification():
w, x, y, z = symbols('w x y z', real=True)
d, e = symbols('d e', real=False)
# Test all combinations or sign and order
assert Or(x >= y, x < y).simplify() == S.true
assert Or(x >= y, y > x).simplify() == S.true
assert Or(x >= y, -x > -y).simplify() == S.true
assert Or(x >= y, -y < -x).simplify() == S.true
assert Or(-x <= -y, x < y).simplify() == S.true
assert Or(-x <= -y, -x > -y).simplify() == S.true
assert Or(-x <= -y, y > x).simplify() == S.true
assert Or(-x <= -y, -y < -x).simplify() == S.true
assert Or(y <= x, x < y).simplify() == S.true
assert Or(y <= x, y > x).simplify() == S.true
assert Or(y <= x, -x > -y).simplify() == S.true
assert Or(y <= x, -y < -x).simplify() == S.true
assert Or(-y >= -x, x < y).simplify() == S.true
assert Or(-y >= -x, y > x).simplify() == S.true
assert Or(-y >= -x, -x > -y).simplify() == S.true
assert Or(-y >= -x, -y < -x).simplify() == S.true
assert Or(x < y, x >= y).simplify() == S.true
assert Or(y > x, x >= y).simplify() == S.true
assert Or(-x > -y, x >= y).simplify() == S.true
assert Or(-y < -x, x >= y).simplify() == S.true
assert Or(x < y, -x <= -y).simplify() == S.true
assert Or(-x > -y, -x <= -y).simplify() == S.true
assert Or(y > x, -x <= -y).simplify() == S.true
assert Or(-y < -x, -x <= -y).simplify() == S.true
assert Or(x < y, y <= x).simplify() == S.true
assert Or(y > x, y <= x).simplify() == S.true
assert Or(-x > -y, y <= x).simplify() == S.true
assert Or(-y < -x, y <= x).simplify() == S.true
assert Or(x < y, -y >= -x).simplify() == S.true
assert Or(y > x, -y >= -x).simplify() == S.true
assert Or(-x > -y, -y >= -x).simplify() == S.true
assert Or(-y < -x, -y >= -x).simplify() == S.true
# Some other tests
assert Or(x >= y, w < z, x <= y).simplify() == S.true
assert And(x >= y, x < y).simplify() == S.false
assert Or(x >= y, Eq(y, x)).simplify() == (x >= y)
assert And(x >= y, Eq(y, x)).simplify() == Eq(x, y)
assert Or(Eq(x, y), x >= y, w < y, z < y).simplify() == \
Or(x >= y, y > Min(w, z))
assert And(Eq(x, y), x >= y, w < y, y >= z, z < y).simplify() == \
And(Eq(x, y), y > Max(w, z))
assert Or(Eq(x, y), x >= 1, 2 < y, y >= 5, z < y).simplify() == \
(Eq(x, y) | (x >= 1) | (y > Min(2, z)))
assert And(Eq(x, y), x >= 1, 2 < y, y >= 5, z < y).simplify() == \
(Eq(x, y) & (x >= 1) & (y >= 5) & (y > z))
assert (Eq(x, y) & Eq(d, e) & (x >= y) & (d >= e)).simplify() == \
(Eq(x, y) & Eq(d, e) & (d >= e))
assert And(Eq(x, y), Eq(x, -y)).simplify() == And(Eq(x, 0), Eq(y, 0))
assert Xor(x >= y, x <= y).simplify() == Ne(x, y)
@slow
def test_relational_simplification_numerically():
def test_simplification_numerically_function(original, simplified):
symb = original.free_symbols
n = len(symb)
valuelist = list(set(list(combinations(list(range(-(n-1), n))*n, n))))
for values in valuelist:
sublist = dict(zip(symb, values))
originalvalue = original.subs(sublist)
simplifiedvalue = simplified.subs(sublist)
assert originalvalue == simplifiedvalue, "Original: {}\nand"\
" simplified: {}\ndo not evaluate to the same value for {}"\
"".format(original, simplified, sublist)
w, x, y, z = symbols('w x y z', real=True)
d, e = symbols('d e', real=False)
expressions = (And(Eq(x, y), x >= y, w < y, y >= z, z < y),
And(Eq(x, y), x >= 1, 2 < y, y >= 5, z < y),
Or(Eq(x, y), x >= 1, 2 < y, y >= 5, z < y),
And(x >= y, Eq(y, x)),
Or(And(Eq(x, y), x >= y, w < y, Or(y >= z, z < y)),
And(Eq(x, y), x >= 1, 2 < y, y >= -1, z < y)),
(Eq(x, y) & Eq(d, e) & (x >= y) & (d >= e)),
)
for expression in expressions:
test_simplification_numerically_function(expression,
expression.simplify())
def test_relational_simplification_patterns_numerically():
from sympy.core import Wild
from sympy.logic.boolalg import simplify_patterns_and, \
simplify_patterns_or, simplify_patterns_xor
a = Wild('a')
b = Wild('b')
c = Wild('c')
symb = [a, b, c]
patternlists = [simplify_patterns_and(), simplify_patterns_or(),
simplify_patterns_xor()]
for patternlist in patternlists:
for pattern in patternlist:
original = pattern[0]
simplified = pattern[1]
valuelist = list(set(list(combinations(list(range(-2, 2))*3, 3))))
for values in valuelist:
sublist = dict(zip(symb, values))
originalvalue = original.subs(sublist)
simplifiedvalue = simplified.subs(sublist)
assert originalvalue == simplifiedvalue, "Original: {}\nand"\
" simplified: {}\ndo not evaluate to the same value for"\
"{}".format(original, simplified, sublist)
def test_issue_16803():
n = symbols('n')
# No simplification done, but should not raise an exception
assert ((n > 3) | (n < 0) | ((n > 0) & (n < 3))).simplify() == \
((n > 3) | (n < 0) | ((n > 0) & (n < 3)))
def test_issue_17530():
r = {x: oo, y: oo}
assert Or(x + y > 0, x - y < 0).subs(r)
assert not And(x + y < 0, x - y < 0).subs(r)
raises(TypeError, lambda: Or(x + y < 0, x - y < 0).subs(r))
raises(TypeError, lambda: And(x + y > 0, x - y < 0).subs(r))
raises(TypeError, lambda: And(x + y > 0, x - y < 0).subs(r))
def test_anf_coeffs():
assert anf_coeffs([1, 0]) == [1, 1]
assert anf_coeffs([0, 0, 0, 1]) == [0, 0, 0, 1]
assert anf_coeffs([0, 1, 1, 1]) == [0, 1, 1, 1]
assert anf_coeffs([1, 1, 1, 0]) == [1, 0, 0, 1]
assert anf_coeffs([1, 0, 0, 0]) == [1, 1, 1, 1]
assert anf_coeffs([1, 0, 0, 1]) == [1, 1, 1, 0]
assert anf_coeffs([1, 1, 0, 1]) == [1, 0, 1, 1]
def test_ANFform():
x, y = symbols('x,y')
assert ANFform([x], [1, 1]) == True
assert ANFform([x], [0, 0]) == False
assert ANFform([x], [1, 0]) == Xor(x, True, remove_true=False)
assert ANFform([x, y], [1, 1, 1, 0]) == \
Xor(True, And(x, y), remove_true=False)
def test_bool_minterm():
x, y = symbols('x,y')
assert bool_minterm(3, [x, y]) == And(x, y)
assert bool_minterm([1, 0], [x, y]) == And(Not(y), x)
def test_bool_maxterm():
x, y = symbols('x,y')
assert bool_maxterm(2, [x, y]) == Or(Not(x), y)
assert bool_maxterm([0, 1], [x, y]) == Or(Not(y), x)
def test_bool_monomial():
x, y = symbols('x,y')
assert bool_monomial(1, [x, y]) == y
assert bool_monomial([1, 1], [x, y]) == And(x, y)
|
85fb8792b8d60bfb55b0e656738bb71d196351cfb3996caf847e2217fbbe91db | """For more tests on satisfiability, see test_dimacs"""
from sympy import symbols, Q
from sympy.logic.boolalg import And, Implies, Equivalent, true, false
from sympy.logic.inference import literal_symbol, \
pl_true, satisfiable, valid, entails, PropKB
from sympy.logic.algorithms.dpll import dpll, dpll_satisfiable, \
find_pure_symbol, find_unit_clause, unit_propagate, \
find_pure_symbol_int_repr, find_unit_clause_int_repr, \
unit_propagate_int_repr
from sympy.logic.algorithms.dpll2 import dpll_satisfiable as dpll2_satisfiable
from sympy.testing.pytest import raises
def test_literal():
A, B = symbols('A,B')
assert literal_symbol(True) is True
assert literal_symbol(False) is False
assert literal_symbol(A) is A
assert literal_symbol(~A) is A
def test_find_pure_symbol():
A, B, C = symbols('A,B,C')
assert find_pure_symbol([A], [A]) == (A, True)
assert find_pure_symbol([A, B], [~A | B, ~B | A]) == (None, None)
assert find_pure_symbol([A, B, C], [ A | ~B, ~B | ~C, C | A]) == (A, True)
assert find_pure_symbol([A, B, C], [~A | B, B | ~C, C | A]) == (B, True)
assert find_pure_symbol([A, B, C], [~A | ~B, ~B | ~C, C | A]) == (B, False)
assert find_pure_symbol(
[A, B, C], [~A | B, ~B | ~C, C | A]) == (None, None)
def test_find_pure_symbol_int_repr():
assert find_pure_symbol_int_repr([1], [{1}]) == (1, True)
assert find_pure_symbol_int_repr([1, 2],
[{-1, 2}, {-2, 1}]) == (None, None)
assert find_pure_symbol_int_repr([1, 2, 3],
[{1, -2}, {-2, -3}, {3, 1}]) == (1, True)
assert find_pure_symbol_int_repr([1, 2, 3],
[{-1, 2}, {2, -3}, {3, 1}]) == (2, True)
assert find_pure_symbol_int_repr([1, 2, 3],
[{-1, -2}, {-2, -3}, {3, 1}]) == (2, False)
assert find_pure_symbol_int_repr([1, 2, 3],
[{-1, 2}, {-2, -3}, {3, 1}]) == (None, None)
def test_unit_clause():
A, B, C = symbols('A,B,C')
assert find_unit_clause([A], {}) == (A, True)
assert find_unit_clause([A, ~A], {}) == (A, True) # Wrong ??
assert find_unit_clause([A | B], {A: True}) == (B, True)
assert find_unit_clause([A | B], {B: True}) == (A, True)
assert find_unit_clause(
[A | B | C, B | ~C, A | ~B], {A: True}) == (B, False)
assert find_unit_clause([A | B | C, B | ~C, A | B], {A: True}) == (B, True)
assert find_unit_clause([A | B | C, B | ~C, A ], {}) == (A, True)
def test_unit_clause_int_repr():
assert find_unit_clause_int_repr(map(set, [[1]]), {}) == (1, True)
assert find_unit_clause_int_repr(map(set, [[1], [-1]]), {}) == (1, True)
assert find_unit_clause_int_repr([{1, 2}], {1: True}) == (2, True)
assert find_unit_clause_int_repr([{1, 2}], {2: True}) == (1, True)
assert find_unit_clause_int_repr(map(set,
[[1, 2, 3], [2, -3], [1, -2]]), {1: True}) == (2, False)
assert find_unit_clause_int_repr(map(set,
[[1, 2, 3], [3, -3], [1, 2]]), {1: True}) == (2, True)
A, B, C = symbols('A,B,C')
assert find_unit_clause([A | B | C, B | ~C, A ], {}) == (A, True)
def test_unit_propagate():
A, B, C = symbols('A,B,C')
assert unit_propagate([A | B], A) == []
assert unit_propagate([A | B, ~A | C, ~C | B, A], A) == [C, ~C | B, A]
def test_unit_propagate_int_repr():
assert unit_propagate_int_repr([{1, 2}], 1) == []
assert unit_propagate_int_repr(map(set,
[[1, 2], [-1, 3], [-3, 2], [1]]), 1) == [{3}, {-3, 2}]
def test_dpll():
"""This is also tested in test_dimacs"""
A, B, C = symbols('A,B,C')
assert dpll([A | B], [A, B], {A: True, B: True}) == {A: True, B: True}
def test_dpll_satisfiable():
A, B, C = symbols('A,B,C')
assert dpll_satisfiable( A & ~A ) is False
assert dpll_satisfiable( A & ~B ) == {A: True, B: False}
assert dpll_satisfiable(
A | B ) in ({A: True}, {B: True}, {A: True, B: True})
assert dpll_satisfiable(
(~A | B) & (~B | A) ) in ({A: True, B: True}, {A: False, B: False})
assert dpll_satisfiable( (A | B) & (~B | C) ) in ({A: True, B: False},
{A: True, C: True}, {B: True, C: True})
assert dpll_satisfiable( A & B & C ) == {A: True, B: True, C: True}
assert dpll_satisfiable( (A | B) & (A >> B) ) == {B: True}
assert dpll_satisfiable( Equivalent(A, B) & A ) == {A: True, B: True}
assert dpll_satisfiable( Equivalent(A, B) & ~A ) == {A: False, B: False}
def test_dpll2_satisfiable():
A, B, C = symbols('A,B,C')
assert dpll2_satisfiable( A & ~A ) is False
assert dpll2_satisfiable( A & ~B ) == {A: True, B: False}
assert dpll2_satisfiable(
A | B ) in ({A: True}, {B: True}, {A: True, B: True})
assert dpll2_satisfiable(
(~A | B) & (~B | A) ) in ({A: True, B: True}, {A: False, B: False})
assert dpll2_satisfiable( (A | B) & (~B | C) ) in ({A: True, B: False, C: True},
{A: True, B: True, C: True})
assert dpll2_satisfiable( A & B & C ) == {A: True, B: True, C: True}
assert dpll2_satisfiable( (A | B) & (A >> B) ) in ({B: True, A: False},
{B: True, A: True})
assert dpll2_satisfiable( Equivalent(A, B) & A ) == {A: True, B: True}
assert dpll2_satisfiable( Equivalent(A, B) & ~A ) == {A: False, B: False}
def test_satisfiable():
A, B, C = symbols('A,B,C')
assert satisfiable(A & (A >> B) & ~B) is False
def test_valid():
A, B, C = symbols('A,B,C')
assert valid(A >> (B >> A)) is True
assert valid((A >> (B >> C)) >> ((A >> B) >> (A >> C))) is True
assert valid((~B >> ~A) >> (A >> B)) is True
assert valid(A | B | C) is False
assert valid(A >> B) is False
def test_pl_true():
A, B, C = symbols('A,B,C')
assert pl_true(True) is True
assert pl_true( A & B, {A: True, B: True}) is True
assert pl_true( A | B, {A: True}) is True
assert pl_true( A | B, {B: True}) is True
assert pl_true( A | B, {A: None, B: True}) is True
assert pl_true( A >> B, {A: False}) is True
assert pl_true( A | B | ~C, {A: False, B: True, C: True}) is True
assert pl_true(Equivalent(A, B), {A: False, B: False}) is True
# test for false
assert pl_true(False) is False
assert pl_true( A & B, {A: False, B: False}) is False
assert pl_true( A & B, {A: False}) is False
assert pl_true( A & B, {B: False}) is False
assert pl_true( A | B, {A: False, B: False}) is False
#test for None
assert pl_true(B, {B: None}) is None
assert pl_true( A & B, {A: True, B: None}) is None
assert pl_true( A >> B, {A: True, B: None}) is None
assert pl_true(Equivalent(A, B), {A: None}) is None
assert pl_true(Equivalent(A, B), {A: True, B: None}) is None
# Test for deep
assert pl_true(A | B, {A: False}, deep=True) is None
assert pl_true(~A & ~B, {A: False}, deep=True) is None
assert pl_true(A | B, {A: False, B: False}, deep=True) is False
assert pl_true(A & B & (~A | ~B), {A: True}, deep=True) is False
assert pl_true((C >> A) >> (B >> A), {C: True}, deep=True) is True
def test_pl_true_wrong_input():
from sympy import pi
raises(ValueError, lambda: pl_true('John Cleese'))
raises(ValueError, lambda: pl_true(42 + pi + pi ** 2))
raises(ValueError, lambda: pl_true(42))
def test_entails():
A, B, C = symbols('A, B, C')
assert entails(A, [A >> B, ~B]) is False
assert entails(B, [Equivalent(A, B), A]) is True
assert entails((A >> B) >> (~A >> ~B)) is False
assert entails((A >> B) >> (~B >> ~A)) is True
def test_PropKB():
A, B, C = symbols('A,B,C')
kb = PropKB()
assert kb.ask(A >> B) is False
assert kb.ask(A >> (B >> A)) is True
kb.tell(A >> B)
kb.tell(B >> C)
assert kb.ask(A) is False
assert kb.ask(B) is False
assert kb.ask(C) is False
assert kb.ask(~A) is False
assert kb.ask(~B) is False
assert kb.ask(~C) is False
assert kb.ask(A >> C) is True
kb.tell(A)
assert kb.ask(A) is True
assert kb.ask(B) is True
assert kb.ask(C) is True
assert kb.ask(~C) is False
kb.retract(A)
assert kb.ask(C) is False
def test_propKB_tolerant():
""""tolerant to bad input"""
kb = PropKB()
A, B, C = symbols('A,B,C')
assert kb.ask(B) is False
def test_satisfiable_non_symbols():
x, y = symbols('x y')
assumptions = Q.zero(x*y)
facts = Implies(Q.zero(x*y), Q.zero(x) | Q.zero(y))
query = ~Q.zero(x) & ~Q.zero(y)
refutations = [
{Q.zero(x): True, Q.zero(x*y): True},
{Q.zero(y): True, Q.zero(x*y): True},
{Q.zero(x): True, Q.zero(y): True, Q.zero(x*y): True},
{Q.zero(x): True, Q.zero(y): False, Q.zero(x*y): True},
{Q.zero(x): False, Q.zero(y): True, Q.zero(x*y): True}]
assert not satisfiable(And(assumptions, facts, query), algorithm='dpll')
assert satisfiable(And(assumptions, facts, ~query), algorithm='dpll') in refutations
assert not satisfiable(And(assumptions, facts, query), algorithm='dpll2')
assert satisfiable(And(assumptions, facts, ~query), algorithm='dpll2') in refutations
def test_satisfiable_bool():
from sympy.core.singleton import S
assert satisfiable(true) == {true: true}
assert satisfiable(S.true) == {true: true}
assert satisfiable(false) is False
assert satisfiable(S.false) is False
def test_satisfiable_all_models():
from sympy.abc import A, B
assert next(satisfiable(False, all_models=True)) is False
assert list(satisfiable((A >> ~A) & A , all_models=True)) == [False]
assert list(satisfiable(True, all_models=True)) == [{true: true}]
models = [{A: True, B: False}, {A: False, B: True}]
result = satisfiable(A ^ B, all_models=True)
models.remove(next(result))
models.remove(next(result))
raises(StopIteration, lambda: next(result))
assert not models
assert list(satisfiable(Equivalent(A, B), all_models=True)) == \
[{A: False, B: False}, {A: True, B: True}]
models = [{A: False, B: False}, {A: False, B: True}, {A: True, B: True}]
for model in satisfiable(A >> B, all_models=True):
models.remove(model)
assert not models
# This is a santiy test to check that only the required number
# of solutions are generated. The expr below has 2**100 - 1 models
# which would time out the test if all are generated at once.
from sympy import numbered_symbols
from sympy.logic.boolalg import Or
sym = numbered_symbols()
X = [next(sym) for i in range(100)]
result = satisfiable(Or(*X), all_models=True)
for i in range(10):
assert next(result)
|
ba3e429367dced2b9f537355132c6e6e26506dfb9181feba2bc0545789c99c23 | from sympy import eye, zeros, Integer
i3 = Integer(3)
M = eye(100)
def timeit_Matrix__getitem_ii():
M[3, 3]
def timeit_Matrix__getitem_II():
M[i3, i3]
def timeit_Matrix__getslice():
M[:, :]
def timeit_Matrix_zeronm():
zeros(100, 100)
|
d63ab9781da4e875c5b00482d1a7ff19fe1fc23c56cb067012ce8cab5ac369fe | from sympy import (
Rational, Symbol, N, I, Abs, sqrt, exp, Float, sin,
cos, symbols)
from sympy.matrices import eye, Matrix
from sympy.matrices.matrices import MatrixEigen
from sympy.matrices.common import _MinimalMatrix, _CastableMatrix
from sympy.core.singleton import S
from sympy.testing.pytest import raises, XFAIL
from sympy.matrices.matrices import NonSquareMatrixError, MatrixError
from sympy.simplify.simplify import simplify
from sympy.matrices.immutable import ImmutableMatrix
from sympy.testing.pytest import slow
class EigenOnlyMatrix(_MinimalMatrix, _CastableMatrix, MatrixEigen):
pass
def test_eigen():
R = Rational
M = Matrix.eye(3)
assert M.eigenvals(multiple=False) == {S.One: 3}
assert M.eigenvals(multiple=True) == [1, 1, 1]
assert M.eigenvects() == (
[(1, 3, [Matrix([1, 0, 0]),
Matrix([0, 1, 0]),
Matrix([0, 0, 1])])])
assert M.left_eigenvects() == (
[(1, 3, [Matrix([[1, 0, 0]]),
Matrix([[0, 1, 0]]),
Matrix([[0, 0, 1]])])])
M = Matrix([[0, 1, 1],
[1, 0, 0],
[1, 1, 1]])
assert M.eigenvals() == {2*S.One: 1, -S.One: 1, S.Zero: 1}
assert M.eigenvects() == (
[
(-1, 1, [Matrix([-1, 1, 0])]),
( 0, 1, [Matrix([0, -1, 1])]),
( 2, 1, [Matrix([R(2, 3), R(1, 3), 1])])
])
assert M.left_eigenvects() == (
[
(-1, 1, [Matrix([[-2, 1, 1]])]),
(0, 1, [Matrix([[-1, -1, 1]])]),
(2, 1, [Matrix([[1, 1, 1]])])
])
a = Symbol('a')
M = Matrix([[a, 0],
[0, 1]])
assert M.eigenvals() == {a: 1, S.One: 1}
M = Matrix([[1, -1],
[1, 3]])
assert M.eigenvects() == ([(2, 2, [Matrix(2, 1, [-1, 1])])])
assert M.left_eigenvects() == ([(2, 2, [Matrix([[1, 1]])])])
M = Matrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
a = R(15, 2)
b = 3*33**R(1, 2)
c = R(13, 2)
d = (R(33, 8) + 3*b/8)
e = (R(33, 8) - 3*b/8)
def NS(e, n):
return str(N(e, n))
r = [
(a - b/2, 1, [Matrix([(12 + 24/(c - b/2))/((c - b/2)*e) + 3/(c - b/2),
(6 + 12/(c - b/2))/e, 1])]),
( 0, 1, [Matrix([1, -2, 1])]),
(a + b/2, 1, [Matrix([(12 + 24/(c + b/2))/((c + b/2)*d) + 3/(c + b/2),
(6 + 12/(c + b/2))/d, 1])]),
]
r1 = [(NS(r[i][0], 2), NS(r[i][1], 2),
[NS(j, 2) for j in r[i][2][0]]) for i in range(len(r))]
r = M.eigenvects()
r2 = [(NS(r[i][0], 2), NS(r[i][1], 2),
[NS(j, 2) for j in r[i][2][0]]) for i in range(len(r))]
assert sorted(r1) == sorted(r2)
eps = Symbol('eps', real=True)
M = Matrix([[abs(eps), I*eps ],
[-I*eps, abs(eps) ]])
assert M.eigenvects() == (
[
( 0, 1, [Matrix([[-I*eps/abs(eps)], [1]])]),
( 2*abs(eps), 1, [ Matrix([[I*eps/abs(eps)], [1]]) ] ),
])
assert M.left_eigenvects() == (
[
(0, 1, [Matrix([[I*eps/Abs(eps), 1]])]),
(2*Abs(eps), 1, [Matrix([[-I*eps/Abs(eps), 1]])])
])
M = Matrix(3, 3, [1, 2, 0, 0, 3, 0, 2, -4, 2])
M._eigenvects = M.eigenvects(simplify=False)
assert max(i.q for i in M._eigenvects[0][2][0]) > 1
M._eigenvects = M.eigenvects(simplify=True)
assert max(i.q for i in M._eigenvects[0][2][0]) == 1
M = Matrix([[Rational(1, 4), 1], [1, 1]])
assert M.eigenvects(simplify=True) == [
(Rational(5, 8) - sqrt(73)/8, 1, [Matrix([[-sqrt(73)/8 - Rational(3, 8)], [1]])]),
(Rational(5, 8) + sqrt(73)/8, 1, [Matrix([[Rational(-3, 8) + sqrt(73)/8], [1]])])]
assert M.eigenvects(simplify=False) == [
(Rational(5, 8) - sqrt(73)/8, 1, [Matrix([[-1/(-Rational(3, 8) + sqrt(73)/8)], [1]])]),
(Rational(5, 8) + sqrt(73)/8, 1, [Matrix([[8/(3 + sqrt(73))], [1]])])]
# issue 10719
assert Matrix([]).eigenvals() == {}
assert Matrix([]).eigenvects() == []
# issue 15119
raises(NonSquareMatrixError, lambda : Matrix([[1, 2], [0, 4], [0, 0]]).eigenvals())
raises(NonSquareMatrixError, lambda : Matrix([[1, 0], [3, 4], [5, 6]]).eigenvals())
raises(NonSquareMatrixError, lambda : Matrix([[1, 2, 3], [0, 5, 6]]).eigenvals())
raises(NonSquareMatrixError, lambda : Matrix([[1, 0, 0], [4, 5, 0]]).eigenvals())
raises(NonSquareMatrixError, lambda : Matrix([[1, 2, 3], [0, 5, 6]]).eigenvals(error_when_incomplete = False))
raises(NonSquareMatrixError, lambda : Matrix([[1, 0, 0], [4, 5, 0]]).eigenvals(error_when_incomplete = False))
# issue 15125
from sympy.core.function import count_ops
q = Symbol("q", positive = True)
m = Matrix([[-2, exp(-q), 1], [exp(q), -2, 1], [1, 1, -2]])
assert count_ops(m.eigenvals(simplify=False)) > count_ops(m.eigenvals(simplify=True))
assert count_ops(m.eigenvals(simplify=lambda x: x)) > count_ops(m.eigenvals(simplify=True))
assert isinstance(m.eigenvals(simplify=True, multiple=False), dict)
assert isinstance(m.eigenvals(simplify=True, multiple=True), list)
assert isinstance(m.eigenvals(simplify=lambda x: x, multiple=False), dict)
assert isinstance(m.eigenvals(simplify=lambda x: x, multiple=True), list)
def test_float_eigenvals():
m = Matrix([[1, .6, .6], [.6, .9, .9], [.9, .6, .6]])
evals = [
Rational(5, 4) - sqrt(385)/20,
sqrt(385)/20 + Rational(5, 4),
S.Zero]
n_evals = m.eigenvals(rational=True, multiple=True)
n_evals = sorted(n_evals)
s_evals = [x.evalf() for x in evals]
s_evals = sorted(s_evals)
for x, y in zip(n_evals, s_evals):
assert abs(x-y) < 10**-9
@XFAIL
def test_eigen_vects():
m = Matrix(2, 2, [1, 0, 0, I])
raises(NotImplementedError, lambda: m.is_diagonalizable(True))
# !!! bug because of eigenvects() or roots(x**2 + (-1 - I)*x + I, x)
# see issue 5292
assert not m.is_diagonalizable(True)
raises(MatrixError, lambda: m.diagonalize(True))
(P, D) = m.diagonalize(True)
def test_issue_8240():
# Eigenvalues of large triangular matrices
x, y = symbols('x y')
n = 200
diagonal_variables = [Symbol('x%s' % i) for i in range(n)]
M = [[0 for i in range(n)] for j in range(n)]
for i in range(n):
M[i][i] = diagonal_variables[i]
M = Matrix(M)
eigenvals = M.eigenvals()
assert len(eigenvals) == n
for i in range(n):
assert eigenvals[diagonal_variables[i]] == 1
eigenvals = M.eigenvals(multiple=True)
assert set(eigenvals) == set(diagonal_variables)
# with multiplicity
M = Matrix([[x, 0, 0], [1, y, 0], [2, 3, x]])
eigenvals = M.eigenvals()
assert eigenvals == {x: 2, y: 1}
eigenvals = M.eigenvals(multiple=True)
assert len(eigenvals) == 3
assert eigenvals.count(x) == 2
assert eigenvals.count(y) == 1
# EigenOnlyMatrix tests
def test_eigenvals():
M = EigenOnlyMatrix([[0, 1, 1],
[1, 0, 0],
[1, 1, 1]])
assert M.eigenvals() == {2*S.One: 1, -S.One: 1, S.Zero: 1}
# if we cannot factor the char poly, we raise an error
m = Matrix([
[3, 0, 0, 0, -3],
[0, -3, -3, 0, 3],
[0, 3, 0, 3, 0],
[0, 0, 3, 0, 3],
[3, 0, 0, 3, 0]])
raises(MatrixError, lambda: m.eigenvals())
def test_eigenvects():
M = EigenOnlyMatrix([[0, 1, 1],
[1, 0, 0],
[1, 1, 1]])
vecs = M.eigenvects()
for val, mult, vec_list in vecs:
assert len(vec_list) == 1
assert M*vec_list[0] == val*vec_list[0]
def test_left_eigenvects():
M = EigenOnlyMatrix([[0, 1, 1],
[1, 0, 0],
[1, 1, 1]])
vecs = M.left_eigenvects()
for val, mult, vec_list in vecs:
assert len(vec_list) == 1
assert vec_list[0]*M == val*vec_list[0]
@slow
def test_bidiagonalize():
M = Matrix([[1, 0, 0],
[0, 1, 0],
[0, 0, 1]])
assert M.bidiagonalize() == M
assert M.bidiagonalize(upper=False) == M
assert M.bidiagonalize() == M
assert M.bidiagonal_decomposition() == (M, M, M)
assert M.bidiagonal_decomposition(upper=False) == (M, M, M)
assert M.bidiagonalize() == M
import random
#Real Tests
for real_test in range(2):
test_values = []
row = 2
col = 2
for _ in range(row * col):
value = random.randint(-1000000000, 1000000000)
test_values = test_values + [value]
# L -> Lower Bidiagonalization
# M -> Mutable Matrix
# N -> Immutable Matrix
# 0 -> Bidiagonalized form
# 1,2,3 -> Bidiagonal_decomposition matrices
# 4 -> Product of 1 2 3
M = Matrix(row, col, test_values)
N = ImmutableMatrix(M)
N1, N2, N3 = N.bidiagonal_decomposition()
M1, M2, M3 = M.bidiagonal_decomposition()
M0 = M.bidiagonalize()
N0 = N.bidiagonalize()
N4 = N1 * N2 * N3
M4 = M1 * M2 * M3
N2.simplify()
N4.simplify()
N0.simplify()
M0.simplify()
M2.simplify()
M4.simplify()
LM0 = M.bidiagonalize(upper=False)
LM1, LM2, LM3 = M.bidiagonal_decomposition(upper=False)
LN0 = N.bidiagonalize(upper=False)
LN1, LN2, LN3 = N.bidiagonal_decomposition(upper=False)
LN4 = LN1 * LN2 * LN3
LM4 = LM1 * LM2 * LM3
LN2.simplify()
LN4.simplify()
LN0.simplify()
LM0.simplify()
LM2.simplify()
LM4.simplify()
assert M == M4
assert M2 == M0
assert N == N4
assert N2 == N0
assert M == LM4
assert LM2 == LM0
assert N == LN4
assert LN2 == LN0
#Complex Tests
for complex_test in range(2):
test_values = []
size = 2
for _ in range(size * size):
real = random.randint(-1000000000, 1000000000)
comp = random.randint(-1000000000, 1000000000)
value = real + comp * I
test_values = test_values + [value]
M = Matrix(size, size, test_values)
N = ImmutableMatrix(M)
# L -> Lower Bidiagonalization
# M -> Mutable Matrix
# N -> Immutable Matrix
# 0 -> Bidiagonalized form
# 1,2,3 -> Bidiagonal_decomposition matrices
# 4 -> Product of 1 2 3
N1, N2, N3 = N.bidiagonal_decomposition()
M1, M2, M3 = M.bidiagonal_decomposition()
M0 = M.bidiagonalize()
N0 = N.bidiagonalize()
N4 = N1 * N2 * N3
M4 = M1 * M2 * M3
N2.simplify()
N4.simplify()
N0.simplify()
M0.simplify()
M2.simplify()
M4.simplify()
LM0 = M.bidiagonalize(upper=False)
LM1, LM2, LM3 = M.bidiagonal_decomposition(upper=False)
LN0 = N.bidiagonalize(upper=False)
LN1, LN2, LN3 = N.bidiagonal_decomposition(upper=False)
LN4 = LN1 * LN2 * LN3
LM4 = LM1 * LM2 * LM3
LN2.simplify()
LN4.simplify()
LN0.simplify()
LM0.simplify()
LM2.simplify()
LM4.simplify()
assert M == M4
assert M2 == M0
assert N == N4
assert N2 == N0
assert M == LM4
assert LM2 == LM0
assert N == LN4
assert LN2 == LN0
M = Matrix(18, 8, range(1, 145))
M = M.applyfunc(lambda i: Float(i))
assert M.bidiagonal_decomposition()[1] == M.bidiagonalize()
assert M.bidiagonal_decomposition(upper=False)[1] == M.bidiagonalize(upper=False)
a, b, c = M.bidiagonal_decomposition()
diff = a * b * c - M
assert abs(max(diff)) < 10**-12
def test_diagonalize():
m = EigenOnlyMatrix(2, 2, [0, -1, 1, 0])
raises(MatrixError, lambda: m.diagonalize(reals_only=True))
P, D = m.diagonalize()
assert D.is_diagonal()
assert D == Matrix([
[-I, 0],
[ 0, I]])
# make sure we use floats out if floats are passed in
m = EigenOnlyMatrix(2, 2, [0, .5, .5, 0])
P, D = m.diagonalize()
assert all(isinstance(e, Float) for e in D.values())
assert all(isinstance(e, Float) for e in P.values())
_, D2 = m.diagonalize(reals_only=True)
assert D == D2
def test_is_diagonalizable():
a, b, c = symbols('a b c')
m = EigenOnlyMatrix(2, 2, [a, c, c, b])
assert m.is_symmetric()
assert m.is_diagonalizable()
assert not EigenOnlyMatrix(2, 2, [1, 1, 0, 1]).is_diagonalizable()
m = EigenOnlyMatrix(2, 2, [0, -1, 1, 0])
assert m.is_diagonalizable()
assert not m.is_diagonalizable(reals_only=True)
def test_jordan_form():
m = Matrix(3, 2, [-3, 1, -3, 20, 3, 10])
raises(NonSquareMatrixError, lambda: m.jordan_form())
# the next two tests test the cases where the old
# algorithm failed due to the fact that the block structure can
# *NOT* be determined from algebraic and geometric multiplicity alone
# This can be seen most easily when one lets compute the J.c.f. of a matrix that
# is in J.c.f already.
m = EigenOnlyMatrix(4, 4, [2, 1, 0, 0,
0, 2, 1, 0,
0, 0, 2, 0,
0, 0, 0, 2
])
P, J = m.jordan_form()
assert m == J
m = EigenOnlyMatrix(4, 4, [2, 1, 0, 0,
0, 2, 0, 0,
0, 0, 2, 1,
0, 0, 0, 2
])
P, J = m.jordan_form()
assert m == J
A = Matrix([[ 2, 4, 1, 0],
[-4, 2, 0, 1],
[ 0, 0, 2, 4],
[ 0, 0, -4, 2]])
P, J = A.jordan_form()
assert simplify(P*J*P.inv()) == A
assert EigenOnlyMatrix(1, 1, [1]).jordan_form() == (
Matrix([1]), Matrix([1]))
assert EigenOnlyMatrix(1, 1, [1]).jordan_form(
calc_transform=False) == Matrix([1])
# make sure if we cannot factor the characteristic polynomial, we raise an error
m = Matrix([[3, 0, 0, 0, -3], [0, -3, -3, 0, 3], [0, 3, 0, 3, 0], [0, 0, 3, 0, 3], [3, 0, 0, 3, 0]])
raises(MatrixError, lambda: m.jordan_form())
# make sure that if the input has floats, the output does too
m = Matrix([
[ 0.6875, 0.125 + 0.1875*sqrt(3)],
[0.125 + 0.1875*sqrt(3), 0.3125]])
P, J = m.jordan_form()
assert all(isinstance(x, Float) or x == 0 for x in P)
assert all(isinstance(x, Float) or x == 0 for x in J)
def test_singular_values():
x = Symbol('x', real=True)
A = EigenOnlyMatrix([[0, 1*I], [2, 0]])
# if singular values can be sorted, they should be in decreasing order
assert A.singular_values() == [2, 1]
A = eye(3)
A[1, 1] = x
A[2, 2] = 5
vals = A.singular_values()
# since Abs(x) cannot be sorted, test set equality
assert set(vals) == {5, 1, Abs(x)}
A = EigenOnlyMatrix([[sin(x), cos(x)], [-cos(x), sin(x)]])
vals = [sv.trigsimp() for sv in A.singular_values()]
assert vals == [S.One, S.One]
A = EigenOnlyMatrix([
[2, 4],
[1, 3],
[0, 0],
[0, 0]
])
assert A.singular_values() == \
[sqrt(sqrt(221) + 15), sqrt(15 - sqrt(221))]
assert A.T.singular_values() == \
[sqrt(sqrt(221) + 15), sqrt(15 - sqrt(221)), 0, 0]
def test___eq__():
assert (EigenOnlyMatrix(
[[0, 1, 1],
[1, 0, 0],
[1, 1, 1]]) == {}) is False
def test_definite():
# Examples from Gilbert Strang, "Introduction to Linear Algebra"
# Positive definite matrices
m = Matrix([[2, -1, 0], [-1, 2, -1], [0, -1, 2]])
assert m.is_positive_definite == True
assert m.is_positive_semidefinite == True
assert m.is_negative_definite == False
assert m.is_negative_semidefinite == False
assert m.is_indefinite == False
m = Matrix([[5, 4], [4, 5]])
assert m.is_positive_definite == True
assert m.is_positive_semidefinite == True
assert m.is_negative_definite == False
assert m.is_negative_semidefinite == False
assert m.is_indefinite == False
# Positive semidefinite matrices
m = Matrix([[2, -1, -1], [-1, 2, -1], [-1, -1, 2]])
assert m.is_positive_definite == False
assert m.is_positive_semidefinite == True
assert m.is_negative_definite == False
assert m.is_negative_semidefinite == False
assert m.is_indefinite == False
m = Matrix([[1, 2], [2, 4]])
assert m.is_positive_definite == False
assert m.is_positive_semidefinite == True
assert m.is_negative_definite == False
assert m.is_negative_semidefinite == False
assert m.is_indefinite == False
# Examples from Mathematica documentation
# Non-hermitian positive definite matrices
m = Matrix([[2, 3], [4, 8]])
assert m.is_positive_definite == True
assert m.is_positive_semidefinite == True
assert m.is_negative_definite == False
assert m.is_negative_semidefinite == False
assert m.is_indefinite == False
m = Matrix([[1, 2*I], [-I, 4]])
assert m.is_positive_definite == True
assert m.is_positive_semidefinite == True
assert m.is_negative_definite == False
assert m.is_negative_semidefinite == False
assert m.is_indefinite == False
# Symbolic matrices examples
a = Symbol('a', positive=True)
b = Symbol('b', negative=True)
m = Matrix([[a, 0, 0], [0, a, 0], [0, 0, a]])
assert m.is_positive_definite == True
assert m.is_positive_semidefinite == True
assert m.is_negative_definite == False
assert m.is_negative_semidefinite == False
assert m.is_indefinite == False
m = Matrix([[b, 0, 0], [0, b, 0], [0, 0, b]])
assert m.is_positive_definite == False
assert m.is_positive_semidefinite == False
assert m.is_negative_definite == True
assert m.is_negative_semidefinite == True
assert m.is_indefinite == False
m = Matrix([[a, 0], [0, b]])
assert m.is_positive_definite == False
assert m.is_positive_semidefinite == False
assert m.is_negative_definite == False
assert m.is_negative_semidefinite == False
assert m.is_indefinite == True
m = Matrix([
[0.0228202735623867, 0.00518748979085398,
-0.0743036351048907, -0.00709135324903921],
[0.00518748979085398, 0.0349045359786350,
0.0830317991056637, 0.00233147902806909],
[-0.0743036351048907, 0.0830317991056637,
1.15859676366277, 0.340359081555988],
[-0.00709135324903921, 0.00233147902806909,
0.340359081555988, 0.928147644848199]
])
assert m.is_positive_definite == True
assert m.is_positive_semidefinite == True
assert m.is_indefinite == False
|
aff40a55b68a06a2ee574bee882db701e43e3e16ade8e1e5e254ab7976bb7039 | from sympy.assumptions import Q
from sympy.core.add import Add
from sympy.core.function import Function
from sympy.core.numbers import I, Integer, oo, pi, Rational
from sympy.core.singleton import S
from sympy.core.symbol import Symbol, symbols
from sympy.functions.elementary.complexes import Abs
from sympy.functions.elementary.exponential import exp
from sympy.functions.elementary.miscellaneous import sqrt
from sympy.functions.elementary.trigonometric import cos, sin
from sympy.matrices.common import (ShapeError, NonSquareMatrixError,
_MinimalMatrix, _CastableMatrix, MatrixShaping, MatrixProperties,
MatrixOperations, MatrixArithmetic, MatrixSpecial)
from sympy.matrices.matrices import MatrixCalculus
from sympy.matrices import (Matrix, diag, eye,
matrix_multiply_elementwise, ones, zeros, SparseMatrix, banded,
MutableDenseMatrix, MutableSparseMatrix, ImmutableDenseMatrix,
ImmutableSparseMatrix)
from sympy.utilities.iterables import flatten
from sympy.testing.pytest import raises, XFAIL, warns_deprecated_sympy
from sympy.abc import x, y, z
# classes to test the basic matrix classes
class ShapingOnlyMatrix(_MinimalMatrix, _CastableMatrix, MatrixShaping):
pass
def eye_Shaping(n):
return ShapingOnlyMatrix(n, n, lambda i, j: int(i == j))
def zeros_Shaping(n):
return ShapingOnlyMatrix(n, n, lambda i, j: 0)
class PropertiesOnlyMatrix(_MinimalMatrix, _CastableMatrix, MatrixProperties):
pass
def eye_Properties(n):
return PropertiesOnlyMatrix(n, n, lambda i, j: int(i == j))
def zeros_Properties(n):
return PropertiesOnlyMatrix(n, n, lambda i, j: 0)
class OperationsOnlyMatrix(_MinimalMatrix, _CastableMatrix, MatrixOperations):
pass
def eye_Operations(n):
return OperationsOnlyMatrix(n, n, lambda i, j: int(i == j))
def zeros_Operations(n):
return OperationsOnlyMatrix(n, n, lambda i, j: 0)
class ArithmeticOnlyMatrix(_MinimalMatrix, _CastableMatrix, MatrixArithmetic):
pass
def eye_Arithmetic(n):
return ArithmeticOnlyMatrix(n, n, lambda i, j: int(i == j))
def zeros_Arithmetic(n):
return ArithmeticOnlyMatrix(n, n, lambda i, j: 0)
class SpecialOnlyMatrix(_MinimalMatrix, _CastableMatrix, MatrixSpecial):
pass
class CalculusOnlyMatrix(_MinimalMatrix, _CastableMatrix, MatrixCalculus):
pass
def test__MinimalMatrix():
x = _MinimalMatrix(2, 3, [1, 2, 3, 4, 5, 6])
assert x.rows == 2
assert x.cols == 3
assert x[2] == 3
assert x[1, 1] == 5
assert list(x) == [1, 2, 3, 4, 5, 6]
assert list(x[1, :]) == [4, 5, 6]
assert list(x[:, 1]) == [2, 5]
assert list(x[:, :]) == list(x)
assert x[:, :] == x
assert _MinimalMatrix(x) == x
assert _MinimalMatrix([[1, 2, 3], [4, 5, 6]]) == x
assert _MinimalMatrix(([1, 2, 3], [4, 5, 6])) == x
assert _MinimalMatrix([(1, 2, 3), (4, 5, 6)]) == x
assert _MinimalMatrix(((1, 2, 3), (4, 5, 6))) == x
assert not (_MinimalMatrix([[1, 2], [3, 4], [5, 6]]) == x)
# ShapingOnlyMatrix tests
def test_vec():
m = ShapingOnlyMatrix(2, 2, [1, 3, 2, 4])
m_vec = m.vec()
assert m_vec.cols == 1
for i in range(4):
assert m_vec[i] == i + 1
def test_todok():
a, b, c, d = symbols('a:d')
m1 = MutableDenseMatrix([[a, b], [c, d]])
m2 = ImmutableDenseMatrix([[a, b], [c, d]])
m3 = MutableSparseMatrix([[a, b], [c, d]])
m4 = ImmutableSparseMatrix([[a, b], [c, d]])
assert m1.todok() == m2.todok() == m3.todok() == m4.todok() == \
{(0, 0): a, (0, 1): b, (1, 0): c, (1, 1): d}
def test_tolist():
lst = [[S.One, S.Half, x*y, S.Zero], [x, y, z, x**2], [y, -S.One, z*x, 3]]
flat_lst = [S.One, S.Half, x*y, S.Zero, x, y, z, x**2, y, -S.One, z*x, 3]
m = ShapingOnlyMatrix(3, 4, flat_lst)
assert m.tolist() == lst
def test_row_col_del():
e = ShapingOnlyMatrix(3, 3, [1, 2, 3, 4, 5, 6, 7, 8, 9])
raises(ValueError, lambda: e.row_del(5))
raises(ValueError, lambda: e.row_del(-5))
raises(ValueError, lambda: e.col_del(5))
raises(ValueError, lambda: e.col_del(-5))
assert e.row_del(2) == e.row_del(-1) == Matrix([[1, 2, 3], [4, 5, 6]])
assert e.col_del(2) == e.col_del(-1) == Matrix([[1, 2], [4, 5], [7, 8]])
assert e.row_del(1) == e.row_del(-2) == Matrix([[1, 2, 3], [7, 8, 9]])
assert e.col_del(1) == e.col_del(-2) == Matrix([[1, 3], [4, 6], [7, 9]])
def test_get_diag_blocks1():
a = Matrix([[1, 2], [2, 3]])
b = Matrix([[3, x], [y, 3]])
c = Matrix([[3, x, 3], [y, 3, z], [x, y, z]])
assert a.get_diag_blocks() == [a]
assert b.get_diag_blocks() == [b]
assert c.get_diag_blocks() == [c]
def test_get_diag_blocks2():
a = Matrix([[1, 2], [2, 3]])
b = Matrix([[3, x], [y, 3]])
c = Matrix([[3, x, 3], [y, 3, z], [x, y, z]])
A, B, C, D = diag(a, b, b), diag(a, b, c), diag(a, c, b), diag(c, c, b)
A = ShapingOnlyMatrix(A.rows, A.cols, A)
B = ShapingOnlyMatrix(B.rows, B.cols, B)
C = ShapingOnlyMatrix(C.rows, C.cols, C)
D = ShapingOnlyMatrix(D.rows, D.cols, D)
assert A.get_diag_blocks() == [a, b, b]
assert B.get_diag_blocks() == [a, b, c]
assert C.get_diag_blocks() == [a, c, b]
assert D.get_diag_blocks() == [c, c, b]
def test_shape():
m = ShapingOnlyMatrix(1, 2, [0, 0])
m.shape == (1, 2)
def test_reshape():
m0 = eye_Shaping(3)
assert m0.reshape(1, 9) == Matrix(1, 9, (1, 0, 0, 0, 1, 0, 0, 0, 1))
m1 = ShapingOnlyMatrix(3, 4, lambda i, j: i + j)
assert m1.reshape(
4, 3) == Matrix(((0, 1, 2), (3, 1, 2), (3, 4, 2), (3, 4, 5)))
assert m1.reshape(2, 6) == Matrix(((0, 1, 2, 3, 1, 2), (3, 4, 2, 3, 4, 5)))
def test_row_col():
m = ShapingOnlyMatrix(3, 3, [1, 2, 3, 4, 5, 6, 7, 8, 9])
assert m.row(0) == Matrix(1, 3, [1, 2, 3])
assert m.col(0) == Matrix(3, 1, [1, 4, 7])
def test_row_join():
assert eye_Shaping(3).row_join(Matrix([7, 7, 7])) == \
Matrix([[1, 0, 0, 7],
[0, 1, 0, 7],
[0, 0, 1, 7]])
def test_col_join():
assert eye_Shaping(3).col_join(Matrix([[7, 7, 7]])) == \
Matrix([[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[7, 7, 7]])
def test_row_insert():
r4 = Matrix([[4, 4, 4]])
for i in range(-4, 5):
l = [1, 0, 0]
l.insert(i, 4)
assert flatten(eye_Shaping(3).row_insert(i, r4).col(0).tolist()) == l
def test_col_insert():
c4 = Matrix([4, 4, 4])
for i in range(-4, 5):
l = [0, 0, 0]
l.insert(i, 4)
assert flatten(zeros_Shaping(3).col_insert(i, c4).row(0).tolist()) == l
# issue 13643
assert eye_Shaping(6).col_insert(3, Matrix([[2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2]])) == \
Matrix([[1, 0, 0, 2, 2, 0, 0, 0],
[0, 1, 0, 2, 2, 0, 0, 0],
[0, 0, 1, 2, 2, 0, 0, 0],
[0, 0, 0, 2, 2, 1, 0, 0],
[0, 0, 0, 2, 2, 0, 1, 0],
[0, 0, 0, 2, 2, 0, 0, 1]])
def test_extract():
m = ShapingOnlyMatrix(4, 3, lambda i, j: i*3 + j)
assert m.extract([0, 1, 3], [0, 1]) == Matrix(3, 2, [0, 1, 3, 4, 9, 10])
assert m.extract([0, 3], [0, 0, 2]) == Matrix(2, 3, [0, 0, 2, 9, 9, 11])
assert m.extract(range(4), range(3)) == m
raises(IndexError, lambda: m.extract([4], [0]))
raises(IndexError, lambda: m.extract([0], [3]))
def test_hstack():
m = ShapingOnlyMatrix(4, 3, lambda i, j: i*3 + j)
m2 = ShapingOnlyMatrix(3, 4, lambda i, j: i*3 + j)
assert m == m.hstack(m)
assert m.hstack(m, m, m) == ShapingOnlyMatrix.hstack(m, m, m) == Matrix([
[0, 1, 2, 0, 1, 2, 0, 1, 2],
[3, 4, 5, 3, 4, 5, 3, 4, 5],
[6, 7, 8, 6, 7, 8, 6, 7, 8],
[9, 10, 11, 9, 10, 11, 9, 10, 11]])
raises(ShapeError, lambda: m.hstack(m, m2))
assert Matrix.hstack() == Matrix()
# test regression #12938
M1 = Matrix.zeros(0, 0)
M2 = Matrix.zeros(0, 1)
M3 = Matrix.zeros(0, 2)
M4 = Matrix.zeros(0, 3)
m = ShapingOnlyMatrix.hstack(M1, M2, M3, M4)
assert m.rows == 0 and m.cols == 6
def test_vstack():
m = ShapingOnlyMatrix(4, 3, lambda i, j: i*3 + j)
m2 = ShapingOnlyMatrix(3, 4, lambda i, j: i*3 + j)
assert m == m.vstack(m)
assert m.vstack(m, m, m) == ShapingOnlyMatrix.vstack(m, m, m) == Matrix([
[0, 1, 2],
[3, 4, 5],
[6, 7, 8],
[9, 10, 11],
[0, 1, 2],
[3, 4, 5],
[6, 7, 8],
[9, 10, 11],
[0, 1, 2],
[3, 4, 5],
[6, 7, 8],
[9, 10, 11]])
raises(ShapeError, lambda: m.vstack(m, m2))
assert Matrix.vstack() == Matrix()
# PropertiesOnlyMatrix tests
def test_atoms():
m = PropertiesOnlyMatrix(2, 2, [1, 2, x, 1 - 1/x])
assert m.atoms() == {S.One, S(2), S.NegativeOne, x}
assert m.atoms(Symbol) == {x}
def test_free_symbols():
assert PropertiesOnlyMatrix([[x], [0]]).free_symbols == {x}
def test_has():
A = PropertiesOnlyMatrix(((x, y), (2, 3)))
assert A.has(x)
assert not A.has(z)
assert A.has(Symbol)
A = PropertiesOnlyMatrix(((2, y), (2, 3)))
assert not A.has(x)
def test_is_anti_symmetric():
x = symbols('x')
assert PropertiesOnlyMatrix(2, 1, [1, 2]).is_anti_symmetric() is False
m = PropertiesOnlyMatrix(3, 3, [0, x**2 + 2*x + 1, y, -(x + 1)**2, 0, x*y, -y, -x*y, 0])
assert m.is_anti_symmetric() is True
assert m.is_anti_symmetric(simplify=False) is False
assert m.is_anti_symmetric(simplify=lambda x: x) is False
m = PropertiesOnlyMatrix(3, 3, [x.expand() for x in m])
assert m.is_anti_symmetric(simplify=False) is True
m = PropertiesOnlyMatrix(3, 3, [x.expand() for x in [S.One] + list(m)[1:]])
assert m.is_anti_symmetric() is False
def test_diagonal_symmetrical():
m = PropertiesOnlyMatrix(2, 2, [0, 1, 1, 0])
assert not m.is_diagonal()
assert m.is_symmetric()
assert m.is_symmetric(simplify=False)
m = PropertiesOnlyMatrix(2, 2, [1, 0, 0, 1])
assert m.is_diagonal()
m = PropertiesOnlyMatrix(3, 3, diag(1, 2, 3))
assert m.is_diagonal()
assert m.is_symmetric()
m = PropertiesOnlyMatrix(3, 3, [1, 0, 0, 0, 2, 0, 0, 0, 3])
assert m == diag(1, 2, 3)
m = PropertiesOnlyMatrix(2, 3, zeros(2, 3))
assert not m.is_symmetric()
assert m.is_diagonal()
m = PropertiesOnlyMatrix(((5, 0), (0, 6), (0, 0)))
assert m.is_diagonal()
m = PropertiesOnlyMatrix(((5, 0, 0), (0, 6, 0)))
assert m.is_diagonal()
m = Matrix(3, 3, [1, x**2 + 2*x + 1, y, (x + 1)**2, 2, 0, y, 0, 3])
assert m.is_symmetric()
assert not m.is_symmetric(simplify=False)
assert m.expand().is_symmetric(simplify=False)
def test_is_hermitian():
a = PropertiesOnlyMatrix([[1, I], [-I, 1]])
assert a.is_hermitian
a = PropertiesOnlyMatrix([[2*I, I], [-I, 1]])
assert a.is_hermitian is False
a = PropertiesOnlyMatrix([[x, I], [-I, 1]])
assert a.is_hermitian is None
a = PropertiesOnlyMatrix([[x, 1], [-I, 1]])
assert a.is_hermitian is False
def test_is_Identity():
assert eye_Properties(3).is_Identity
assert not PropertiesOnlyMatrix(zeros(3)).is_Identity
assert not PropertiesOnlyMatrix(ones(3)).is_Identity
# issue 6242
assert not PropertiesOnlyMatrix([[1, 0, 0]]).is_Identity
def test_is_symbolic():
a = PropertiesOnlyMatrix([[x, x], [x, x]])
assert a.is_symbolic() is True
a = PropertiesOnlyMatrix([[1, 2, 3, 4], [5, 6, 7, 8]])
assert a.is_symbolic() is False
a = PropertiesOnlyMatrix([[1, 2, 3, 4], [5, 6, x, 8]])
assert a.is_symbolic() is True
a = PropertiesOnlyMatrix([[1, x, 3]])
assert a.is_symbolic() is True
a = PropertiesOnlyMatrix([[1, 2, 3]])
assert a.is_symbolic() is False
a = PropertiesOnlyMatrix([[1], [x], [3]])
assert a.is_symbolic() is True
a = PropertiesOnlyMatrix([[1], [2], [3]])
assert a.is_symbolic() is False
def test_is_upper():
a = PropertiesOnlyMatrix([[1, 2, 3]])
assert a.is_upper is True
a = PropertiesOnlyMatrix([[1], [2], [3]])
assert a.is_upper is False
def test_is_lower():
a = PropertiesOnlyMatrix([[1, 2, 3]])
assert a.is_lower is False
a = PropertiesOnlyMatrix([[1], [2], [3]])
assert a.is_lower is True
def test_is_square():
m = PropertiesOnlyMatrix([[1], [1]])
m2 = PropertiesOnlyMatrix([[2, 2], [2, 2]])
assert not m.is_square
assert m2.is_square
def test_is_symmetric():
m = PropertiesOnlyMatrix(2, 2, [0, 1, 1, 0])
assert m.is_symmetric()
m = PropertiesOnlyMatrix(2, 2, [0, 1, 0, 1])
assert not m.is_symmetric()
def test_is_hessenberg():
A = PropertiesOnlyMatrix([[3, 4, 1], [2, 4, 5], [0, 1, 2]])
assert A.is_upper_hessenberg
A = PropertiesOnlyMatrix(3, 3, [3, 2, 0, 4, 4, 1, 1, 5, 2])
assert A.is_lower_hessenberg
A = PropertiesOnlyMatrix(3, 3, [3, 2, -1, 4, 4, 1, 1, 5, 2])
assert A.is_lower_hessenberg is False
assert A.is_upper_hessenberg is False
A = PropertiesOnlyMatrix([[3, 4, 1], [2, 4, 5], [3, 1, 2]])
assert not A.is_upper_hessenberg
def test_is_zero():
assert PropertiesOnlyMatrix(0, 0, []).is_zero_matrix
assert PropertiesOnlyMatrix([[0, 0], [0, 0]]).is_zero_matrix
assert PropertiesOnlyMatrix(zeros(3, 4)).is_zero_matrix
assert not PropertiesOnlyMatrix(eye(3)).is_zero_matrix
assert PropertiesOnlyMatrix([[x, 0], [0, 0]]).is_zero_matrix == None
assert PropertiesOnlyMatrix([[x, 1], [0, 0]]).is_zero_matrix == False
a = Symbol('a', nonzero=True)
assert PropertiesOnlyMatrix([[a, 0], [0, 0]]).is_zero_matrix == False
def test_values():
assert set(PropertiesOnlyMatrix(2, 2, [0, 1, 2, 3]
).values()) == {1, 2, 3}
x = Symbol('x', real=True)
assert set(PropertiesOnlyMatrix(2, 2, [x, 0, 0, 1]
).values()) == {x, 1}
# OperationsOnlyMatrix tests
def test_applyfunc():
m0 = OperationsOnlyMatrix(eye(3))
assert m0.applyfunc(lambda x: 2*x) == eye(3)*2
assert m0.applyfunc(lambda x: 0) == zeros(3)
assert m0.applyfunc(lambda x: 1) == ones(3)
def test_adjoint():
dat = [[0, I], [1, 0]]
ans = OperationsOnlyMatrix([[0, 1], [-I, 0]])
assert ans.adjoint() == Matrix(dat)
def test_as_real_imag():
m1 = OperationsOnlyMatrix(2, 2, [1, 2, 3, 4])
m3 = OperationsOnlyMatrix(2, 2,
[1 + S.ImaginaryUnit, 2 + 2*S.ImaginaryUnit,
3 + 3*S.ImaginaryUnit, 4 + 4*S.ImaginaryUnit])
a, b = m3.as_real_imag()
assert a == m1
assert b == m1
def test_conjugate():
M = OperationsOnlyMatrix([[0, I, 5],
[1, 2, 0]])
assert M.T == Matrix([[0, 1],
[I, 2],
[5, 0]])
assert M.C == Matrix([[0, -I, 5],
[1, 2, 0]])
assert M.C == M.conjugate()
assert M.H == M.T.C
assert M.H == Matrix([[ 0, 1],
[-I, 2],
[ 5, 0]])
def test_doit():
a = OperationsOnlyMatrix([[Add(x, x, evaluate=False)]])
assert a[0] != 2*x
assert a.doit() == Matrix([[2*x]])
def test_evalf():
a = OperationsOnlyMatrix(2, 1, [sqrt(5), 6])
assert all(a.evalf()[i] == a[i].evalf() for i in range(2))
assert all(a.evalf(2)[i] == a[i].evalf(2) for i in range(2))
assert all(a.n(2)[i] == a[i].n(2) for i in range(2))
def test_expand():
m0 = OperationsOnlyMatrix([[x*(x + y), 2], [((x + y)*y)*x, x*(y + x*(x + y))]])
# Test if expand() returns a matrix
m1 = m0.expand()
assert m1 == Matrix(
[[x*y + x**2, 2], [x*y**2 + y*x**2, x*y + y*x**2 + x**3]])
a = Symbol('a', real=True)
assert OperationsOnlyMatrix(1, 1, [exp(I*a)]).expand(complex=True) == \
Matrix([cos(a) + I*sin(a)])
def test_refine():
m0 = OperationsOnlyMatrix([[Abs(x)**2, sqrt(x**2)],
[sqrt(x**2)*Abs(y)**2, sqrt(y**2)*Abs(x)**2]])
m1 = m0.refine(Q.real(x) & Q.real(y))
assert m1 == Matrix([[x**2, Abs(x)], [y**2*Abs(x), x**2*Abs(y)]])
m1 = m0.refine(Q.positive(x) & Q.positive(y))
assert m1 == Matrix([[x**2, x], [x*y**2, x**2*y]])
m1 = m0.refine(Q.negative(x) & Q.negative(y))
assert m1 == Matrix([[x**2, -x], [-x*y**2, -x**2*y]])
def test_replace():
F, G = symbols('F, G', cls=Function)
K = OperationsOnlyMatrix(2, 2, lambda i, j: G(i+j))
M = OperationsOnlyMatrix(2, 2, lambda i, j: F(i+j))
N = M.replace(F, G)
assert N == K
def test_replace_map():
F, G = symbols('F, G', cls=Function)
K = OperationsOnlyMatrix(2, 2, [(G(0), {F(0): G(0)}), (G(1), {F(1): G(1)}), (G(1), {F(1) \
: G(1)}), (G(2), {F(2): G(2)})])
M = OperationsOnlyMatrix(2, 2, lambda i, j: F(i+j))
N = M.replace(F, G, True)
assert N == K
def test_rot90():
A = Matrix([[1, 2], [3, 4]])
assert A == A.rot90(0) == A.rot90(4)
assert A.rot90(2) == A.rot90(-2) == A.rot90(6) == Matrix(((4, 3), (2, 1)))
assert A.rot90(3) == A.rot90(-1) == A.rot90(7) == Matrix(((2, 4), (1, 3)))
assert A.rot90() == A.rot90(-7) == A.rot90(-3) == Matrix(((3, 1), (4, 2)))
def test_simplify():
n = Symbol('n')
f = Function('f')
M = OperationsOnlyMatrix([[ 1/x + 1/y, (x + x*y) / x ],
[ (f(x) + y*f(x))/f(x), 2 * (1/n - cos(n * pi)/n) / pi ]])
assert M.simplify() == Matrix([[ (x + y)/(x * y), 1 + y ],
[ 1 + y, 2*((1 - 1*cos(pi*n))/(pi*n)) ]])
eq = (1 + x)**2
M = OperationsOnlyMatrix([[eq]])
assert M.simplify() == Matrix([[eq]])
assert M.simplify(ratio=oo) == Matrix([[eq.simplify(ratio=oo)]])
def test_subs():
assert OperationsOnlyMatrix([[1, x], [x, 4]]).subs(x, 5) == Matrix([[1, 5], [5, 4]])
assert OperationsOnlyMatrix([[x, 2], [x + y, 4]]).subs([[x, -1], [y, -2]]) == \
Matrix([[-1, 2], [-3, 4]])
assert OperationsOnlyMatrix([[x, 2], [x + y, 4]]).subs([(x, -1), (y, -2)]) == \
Matrix([[-1, 2], [-3, 4]])
assert OperationsOnlyMatrix([[x, 2], [x + y, 4]]).subs({x: -1, y: -2}) == \
Matrix([[-1, 2], [-3, 4]])
assert OperationsOnlyMatrix([[x*y]]).subs({x: y - 1, y: x - 1}, simultaneous=True) == \
Matrix([[(x - 1)*(y - 1)]])
def test_trace():
M = OperationsOnlyMatrix([[1, 0, 0],
[0, 5, 0],
[0, 0, 8]])
assert M.trace() == 14
def test_xreplace():
assert OperationsOnlyMatrix([[1, x], [x, 4]]).xreplace({x: 5}) == \
Matrix([[1, 5], [5, 4]])
assert OperationsOnlyMatrix([[x, 2], [x + y, 4]]).xreplace({x: -1, y: -2}) == \
Matrix([[-1, 2], [-3, 4]])
def test_permute():
a = OperationsOnlyMatrix(3, 4, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12])
raises(IndexError, lambda: a.permute([[0, 5]]))
raises(ValueError, lambda: a.permute(Symbol('x')))
b = a.permute_rows([[0, 2], [0, 1]])
assert a.permute([[0, 2], [0, 1]]) == b == Matrix([
[5, 6, 7, 8],
[9, 10, 11, 12],
[1, 2, 3, 4]])
b = a.permute_cols([[0, 2], [0, 1]])
assert a.permute([[0, 2], [0, 1]], orientation='cols') == b ==\
Matrix([
[ 2, 3, 1, 4],
[ 6, 7, 5, 8],
[10, 11, 9, 12]])
b = a.permute_cols([[0, 2], [0, 1]], direction='backward')
assert a.permute([[0, 2], [0, 1]], orientation='cols', direction='backward') == b ==\
Matrix([
[ 3, 1, 2, 4],
[ 7, 5, 6, 8],
[11, 9, 10, 12]])
assert a.permute([1, 2, 0, 3]) == Matrix([
[5, 6, 7, 8],
[9, 10, 11, 12],
[1, 2, 3, 4]])
from sympy.combinatorics import Permutation
assert a.permute(Permutation([1, 2, 0, 3])) == Matrix([
[5, 6, 7, 8],
[9, 10, 11, 12],
[1, 2, 3, 4]])
# ArithmeticOnlyMatrix tests
def test_abs():
m = ArithmeticOnlyMatrix([[1, -2], [x, y]])
assert abs(m) == ArithmeticOnlyMatrix([[1, 2], [Abs(x), Abs(y)]])
def test_add():
m = ArithmeticOnlyMatrix([[1, 2, 3], [x, y, x], [2*y, -50, z*x]])
assert m + m == ArithmeticOnlyMatrix([[2, 4, 6], [2*x, 2*y, 2*x], [4*y, -100, 2*z*x]])
n = ArithmeticOnlyMatrix(1, 2, [1, 2])
raises(ShapeError, lambda: m + n)
def test_multiplication():
a = ArithmeticOnlyMatrix((
(1, 2),
(3, 1),
(0, 6),
))
b = ArithmeticOnlyMatrix((
(1, 2),
(3, 0),
))
raises(ShapeError, lambda: b*a)
raises(TypeError, lambda: a*{})
c = a*b
assert c[0, 0] == 7
assert c[0, 1] == 2
assert c[1, 0] == 6
assert c[1, 1] == 6
assert c[2, 0] == 18
assert c[2, 1] == 0
try:
eval('c = a @ b')
except SyntaxError:
pass
else:
assert c[0, 0] == 7
assert c[0, 1] == 2
assert c[1, 0] == 6
assert c[1, 1] == 6
assert c[2, 0] == 18
assert c[2, 1] == 0
h = a.multiply_elementwise(c)
assert h == matrix_multiply_elementwise(a, c)
assert h[0, 0] == 7
assert h[0, 1] == 4
assert h[1, 0] == 18
assert h[1, 1] == 6
assert h[2, 0] == 0
assert h[2, 1] == 0
raises(ShapeError, lambda: a.multiply_elementwise(b))
c = b * Symbol("x")
assert isinstance(c, ArithmeticOnlyMatrix)
assert c[0, 0] == x
assert c[0, 1] == 2*x
assert c[1, 0] == 3*x
assert c[1, 1] == 0
c2 = x * b
assert c == c2
c = 5 * b
assert isinstance(c, ArithmeticOnlyMatrix)
assert c[0, 0] == 5
assert c[0, 1] == 2*5
assert c[1, 0] == 3*5
assert c[1, 1] == 0
try:
eval('c = 5 @ b')
except SyntaxError:
pass
else:
assert isinstance(c, ArithmeticOnlyMatrix)
assert c[0, 0] == 5
assert c[0, 1] == 2*5
assert c[1, 0] == 3*5
assert c[1, 1] == 0
def test_matmul():
a = Matrix([[1, 2], [3, 4]])
assert a.__matmul__(2) == NotImplemented
assert a.__rmatmul__(2) == NotImplemented
#This is done this way because @ is only supported in Python 3.5+
#To check 2@a case
try:
eval('2 @ a')
except SyntaxError:
pass
except TypeError: #TypeError is raised in case of NotImplemented is returned
pass
#Check a@2 case
try:
eval('a @ 2')
except SyntaxError:
pass
except TypeError: #TypeError is raised in case of NotImplemented is returned
pass
def test_power():
raises(NonSquareMatrixError, lambda: Matrix((1, 2))**2)
A = ArithmeticOnlyMatrix([[2, 3], [4, 5]])
assert (A**5)[:] == (6140, 8097, 10796, 14237)
A = ArithmeticOnlyMatrix([[2, 1, 3], [4, 2, 4], [6, 12, 1]])
assert (A**3)[:] == (290, 262, 251, 448, 440, 368, 702, 954, 433)
assert A**0 == eye(3)
assert A**1 == A
assert (ArithmeticOnlyMatrix([[2]]) ** 100)[0, 0] == 2**100
assert ArithmeticOnlyMatrix([[1, 2], [3, 4]])**Integer(2) == ArithmeticOnlyMatrix([[7, 10], [15, 22]])
A = Matrix([[1,2],[4,5]])
assert A.pow(20, method='cayley') == A.pow(20, method='multiply')
def test_neg():
n = ArithmeticOnlyMatrix(1, 2, [1, 2])
assert -n == ArithmeticOnlyMatrix(1, 2, [-1, -2])
def test_sub():
n = ArithmeticOnlyMatrix(1, 2, [1, 2])
assert n - n == ArithmeticOnlyMatrix(1, 2, [0, 0])
def test_div():
n = ArithmeticOnlyMatrix(1, 2, [1, 2])
assert n/2 == ArithmeticOnlyMatrix(1, 2, [S.Half, S(2)/2])
# SpecialOnlyMatrix tests
def test_eye():
assert list(SpecialOnlyMatrix.eye(2, 2)) == [1, 0, 0, 1]
assert list(SpecialOnlyMatrix.eye(2)) == [1, 0, 0, 1]
assert type(SpecialOnlyMatrix.eye(2)) == SpecialOnlyMatrix
assert type(SpecialOnlyMatrix.eye(2, cls=Matrix)) == Matrix
def test_ones():
assert list(SpecialOnlyMatrix.ones(2, 2)) == [1, 1, 1, 1]
assert list(SpecialOnlyMatrix.ones(2)) == [1, 1, 1, 1]
assert SpecialOnlyMatrix.ones(2, 3) == Matrix([[1, 1, 1], [1, 1, 1]])
assert type(SpecialOnlyMatrix.ones(2)) == SpecialOnlyMatrix
assert type(SpecialOnlyMatrix.ones(2, cls=Matrix)) == Matrix
def test_zeros():
assert list(SpecialOnlyMatrix.zeros(2, 2)) == [0, 0, 0, 0]
assert list(SpecialOnlyMatrix.zeros(2)) == [0, 0, 0, 0]
assert SpecialOnlyMatrix.zeros(2, 3) == Matrix([[0, 0, 0], [0, 0, 0]])
assert type(SpecialOnlyMatrix.zeros(2)) == SpecialOnlyMatrix
assert type(SpecialOnlyMatrix.zeros(2, cls=Matrix)) == Matrix
def test_diag_make():
diag = SpecialOnlyMatrix.diag
a = Matrix([[1, 2], [2, 3]])
b = Matrix([[3, x], [y, 3]])
c = Matrix([[3, x, 3], [y, 3, z], [x, y, z]])
assert diag(a, b, b) == Matrix([
[1, 2, 0, 0, 0, 0],
[2, 3, 0, 0, 0, 0],
[0, 0, 3, x, 0, 0],
[0, 0, y, 3, 0, 0],
[0, 0, 0, 0, 3, x],
[0, 0, 0, 0, y, 3],
])
assert diag(a, b, c) == Matrix([
[1, 2, 0, 0, 0, 0, 0],
[2, 3, 0, 0, 0, 0, 0],
[0, 0, 3, x, 0, 0, 0],
[0, 0, y, 3, 0, 0, 0],
[0, 0, 0, 0, 3, x, 3],
[0, 0, 0, 0, y, 3, z],
[0, 0, 0, 0, x, y, z],
])
assert diag(a, c, b) == Matrix([
[1, 2, 0, 0, 0, 0, 0],
[2, 3, 0, 0, 0, 0, 0],
[0, 0, 3, x, 3, 0, 0],
[0, 0, y, 3, z, 0, 0],
[0, 0, x, y, z, 0, 0],
[0, 0, 0, 0, 0, 3, x],
[0, 0, 0, 0, 0, y, 3],
])
a = Matrix([x, y, z])
b = Matrix([[1, 2], [3, 4]])
c = Matrix([[5, 6]])
# this "wandering diagonal" is what makes this
# a block diagonal where each block is independent
# of the others
assert diag(a, 7, b, c) == Matrix([
[x, 0, 0, 0, 0, 0],
[y, 0, 0, 0, 0, 0],
[z, 0, 0, 0, 0, 0],
[0, 7, 0, 0, 0, 0],
[0, 0, 1, 2, 0, 0],
[0, 0, 3, 4, 0, 0],
[0, 0, 0, 0, 5, 6]])
raises(ValueError, lambda: diag(a, 7, b, c, rows=5))
assert diag(1) == Matrix([[1]])
assert diag(1, rows=2) == Matrix([[1, 0], [0, 0]])
assert diag(1, cols=2) == Matrix([[1, 0], [0, 0]])
assert diag(1, rows=3, cols=2) == Matrix([[1, 0], [0, 0], [0, 0]])
assert diag(*[2, 3]) == Matrix([
[2, 0],
[0, 3]])
assert diag(Matrix([2, 3])) == Matrix([
[2],
[3]])
assert diag([1, [2, 3], 4], unpack=False) == \
diag([[1], [2, 3], [4]], unpack=False) == Matrix([
[1, 0],
[2, 3],
[4, 0]])
assert type(diag(1)) == SpecialOnlyMatrix
assert type(diag(1, cls=Matrix)) == Matrix
assert Matrix.diag([1, 2, 3]) == Matrix.diag(1, 2, 3)
assert Matrix.diag([1, 2, 3], unpack=False).shape == (3, 1)
assert Matrix.diag([[1, 2, 3]]).shape == (3, 1)
assert Matrix.diag([[1, 2, 3]], unpack=False).shape == (1, 3)
assert Matrix.diag([[[1, 2, 3]]]).shape == (1, 3)
# kerning can be used to move the starting point
assert Matrix.diag(ones(0, 2), 1, 2) == Matrix([
[0, 0, 1, 0],
[0, 0, 0, 2]])
assert Matrix.diag(ones(2, 0), 1, 2) == Matrix([
[0, 0],
[0, 0],
[1, 0],
[0, 2]])
def test_diagonal():
m = Matrix(3, 3, range(9))
d = m.diagonal()
assert d == m.diagonal(0)
assert tuple(d) == (0, 4, 8)
assert tuple(m.diagonal(1)) == (1, 5)
assert tuple(m.diagonal(-1)) == (3, 7)
assert tuple(m.diagonal(2)) == (2,)
assert type(m.diagonal()) == type(m)
s = SparseMatrix(3, 3, {(1, 1): 1})
assert type(s.diagonal()) == type(s)
assert type(m) != type(s)
raises(ValueError, lambda: m.diagonal(3))
raises(ValueError, lambda: m.diagonal(-3))
raises(ValueError, lambda: m.diagonal(pi))
M = ones(2, 3)
assert banded({i: list(M.diagonal(i))
for i in range(1-M.rows, M.cols)}) == M
def test_jordan_block():
assert SpecialOnlyMatrix.jordan_block(3, 2) == SpecialOnlyMatrix.jordan_block(3, eigenvalue=2) \
== SpecialOnlyMatrix.jordan_block(size=3, eigenvalue=2) \
== SpecialOnlyMatrix.jordan_block(3, 2, band='upper') \
== SpecialOnlyMatrix.jordan_block(
size=3, eigenval=2, eigenvalue=2) \
== Matrix([
[2, 1, 0],
[0, 2, 1],
[0, 0, 2]])
assert SpecialOnlyMatrix.jordan_block(3, 2, band='lower') == Matrix([
[2, 0, 0],
[1, 2, 0],
[0, 1, 2]])
# missing eigenvalue
raises(ValueError, lambda: SpecialOnlyMatrix.jordan_block(2))
# non-integral size
raises(ValueError, lambda: SpecialOnlyMatrix.jordan_block(3.5, 2))
# size not specified
raises(ValueError, lambda: SpecialOnlyMatrix.jordan_block(eigenvalue=2))
# inconsistent eigenvalue
raises(ValueError,
lambda: SpecialOnlyMatrix.jordan_block(
eigenvalue=2, eigenval=4))
# Deprecated feature
with warns_deprecated_sympy():
assert (SpecialOnlyMatrix.jordan_block(cols=3, eigenvalue=2) ==
SpecialOnlyMatrix(3, 3, (2, 1, 0, 0, 2, 1, 0, 0, 2)))
with warns_deprecated_sympy():
assert (SpecialOnlyMatrix.jordan_block(rows=3, eigenvalue=2) ==
SpecialOnlyMatrix(3, 3, (2, 1, 0, 0, 2, 1, 0, 0, 2)))
with warns_deprecated_sympy():
assert SpecialOnlyMatrix.jordan_block(3, 2) == \
SpecialOnlyMatrix.jordan_block(cols=3, eigenvalue=2) == \
SpecialOnlyMatrix.jordan_block(rows=3, eigenvalue=2)
with warns_deprecated_sympy():
assert SpecialOnlyMatrix.jordan_block(
rows=4, cols=3, eigenvalue=2) == \
Matrix([
[2, 1, 0],
[0, 2, 1],
[0, 0, 2],
[0, 0, 0]])
# Using alias keyword
assert SpecialOnlyMatrix.jordan_block(size=3, eigenvalue=2) == \
SpecialOnlyMatrix.jordan_block(size=3, eigenval=2)
def test_orthogonalize():
m = Matrix([[1, 2], [3, 4]])
assert m.orthogonalize(Matrix([[2], [1]])) == [Matrix([[2], [1]])]
assert m.orthogonalize(Matrix([[2], [1]]), normalize=True) == \
[Matrix([[2*sqrt(5)/5], [sqrt(5)/5]])]
assert m.orthogonalize(Matrix([[1], [2]]), Matrix([[-1], [4]])) == \
[Matrix([[1], [2]]), Matrix([[Rational(-12, 5)], [Rational(6, 5)]])]
assert m.orthogonalize(Matrix([[0], [0]]), Matrix([[-1], [4]])) == \
[Matrix([[-1], [4]])]
assert m.orthogonalize(Matrix([[0], [0]])) == []
n = Matrix([[9, 1, 9], [3, 6, 10], [8, 5, 2]])
vecs = [Matrix([[-5], [1]]), Matrix([[-5], [2]]), Matrix([[-5], [-2]])]
assert n.orthogonalize(*vecs) == \
[Matrix([[-5], [1]]), Matrix([[Rational(5, 26)], [Rational(25, 26)]])]
vecs = [Matrix([0, 0, 0]), Matrix([1, 2, 3]), Matrix([1, 4, 5])]
raises(ValueError, lambda: Matrix.orthogonalize(*vecs, rankcheck=True))
vecs = [Matrix([1, 2, 3]), Matrix([4, 5, 6]), Matrix([7, 8, 9])]
raises(ValueError, lambda: Matrix.orthogonalize(*vecs, rankcheck=True))
# CalculusOnlyMatrix tests
@XFAIL
def test_diff():
x, y = symbols('x y')
m = CalculusOnlyMatrix(2, 1, [x, y])
# TODO: currently not working as ``_MinimalMatrix`` cannot be sympified:
assert m.diff(x) == Matrix(2, 1, [1, 0])
def test_integrate():
x, y = symbols('x y')
m = CalculusOnlyMatrix(2, 1, [x, y])
assert m.integrate(x) == Matrix(2, 1, [x**2/2, y*x])
def test_jacobian2():
rho, phi = symbols("rho,phi")
X = CalculusOnlyMatrix(3, 1, [rho*cos(phi), rho*sin(phi), rho**2])
Y = CalculusOnlyMatrix(2, 1, [rho, phi])
J = Matrix([
[cos(phi), -rho*sin(phi)],
[sin(phi), rho*cos(phi)],
[ 2*rho, 0],
])
assert X.jacobian(Y) == J
m = CalculusOnlyMatrix(2, 2, [1, 2, 3, 4])
m2 = CalculusOnlyMatrix(4, 1, [1, 2, 3, 4])
raises(TypeError, lambda: m.jacobian(Matrix([1, 2])))
raises(TypeError, lambda: m2.jacobian(m))
def test_limit():
x, y = symbols('x y')
m = CalculusOnlyMatrix(2, 1, [1/x, y])
assert m.limit(x, 5) == Matrix(2, 1, [Rational(1, 5), y])
def test_issue_13774():
M = Matrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
v = [1, 1, 1]
raises(TypeError, lambda: M*v)
raises(TypeError, lambda: v*M)
|
ff1f7817dfa86ad20b4bb01887b5d46af6c23ac88431988c06b446f6a69466d6 | from sympy.combinatorics import Permutation
from sympy.core.symbol import symbols
from sympy.matrices import Matrix
from sympy.matrices.expressions import PermutationMatrix, BlockDiagMatrix
def test_connected_components():
a, b, c, d, e, f, g, h, i, j, k, l, m = symbols('a:m')
M = Matrix([
[a, 0, 0, 0, b, 0, 0, 0, 0, 0, c, 0, 0],
[0, d, 0, 0, 0, e, 0, 0, 0, 0, 0, f, 0],
[0, 0, g, 0, 0, 0, h, 0, 0, 0, 0, 0, i],
[0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[m, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0],
[0, m, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0],
[0, 0, m, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0],
[j, 0, 0, 0, k, 0, 0, 1, 0, 0, l, 0, 0],
[0, j, 0, 0, 0, k, 0, 0, 1, 0, 0, l, 0],
[0, 0, j, 0, 0, 0, k, 0, 0, 1, 0, 0, l],
[0, 0, 0, 0, d, 0, 0, 0, 0, 0, 1, 0, 0],
[0, 0, 0, 0, 0, d, 0, 0, 0, 0, 0, 1, 0],
[0, 0, 0, 0, 0, 0, d, 0, 0, 0, 0, 0, 1]])
cc = M.connected_components()
assert cc == [[0, 4, 7, 10], [1, 5, 8, 11], [2, 6, 9, 12], [3]]
P, B = M.connected_components_decomposition()
p = Permutation([0, 4, 7, 10, 1, 5, 8, 11, 2, 6, 9, 12, 3])
assert P == PermutationMatrix(p)
B0 = Matrix([
[a, b, 0, c],
[m, 1, 0, 0],
[j, k, 1, l],
[0, d, 0, 1]])
B1 = Matrix([
[d, e, 0, f],
[m, 1, 0, 0],
[j, k, 1, l],
[0, d, 0, 1]])
B2 = Matrix([
[g, h, 0, i],
[m, 1, 0, 0],
[j, k, 1, l],
[0, d, 0, 1]])
B3 = Matrix([[1]])
assert B == BlockDiagMatrix(B0, B1, B2, B3)
|
073be1116ec976d1e1fea4d6c04f2bc3a2c8f912f4d58dc536f3ab82efbce631 | from sympy import Abs, S, Symbol, symbols, I, Rational, PurePoly, Float
from sympy.matrices import \
Matrix, MutableSparseMatrix, ImmutableSparseMatrix, SparseMatrix, eye, \
ones, zeros, ShapeError
from sympy.testing.pytest import raises
def test_sparse_matrix():
def sparse_eye(n):
return SparseMatrix.eye(n)
def sparse_zeros(n):
return SparseMatrix.zeros(n)
# creation args
raises(TypeError, lambda: SparseMatrix(1, 2))
a = SparseMatrix((
(1, 0),
(0, 1)
))
assert SparseMatrix(a) == a
from sympy.matrices import MutableSparseMatrix, MutableDenseMatrix
a = MutableSparseMatrix([])
b = MutableDenseMatrix([1, 2])
assert a.row_join(b) == b
assert a.col_join(b) == b
assert type(a.row_join(b)) == type(a)
assert type(a.col_join(b)) == type(a)
# make sure 0 x n matrices get stacked correctly
sparse_matrices = [SparseMatrix.zeros(0, n) for n in range(4)]
assert SparseMatrix.hstack(*sparse_matrices) == Matrix(0, 6, [])
sparse_matrices = [SparseMatrix.zeros(n, 0) for n in range(4)]
assert SparseMatrix.vstack(*sparse_matrices) == Matrix(6, 0, [])
# test element assignment
a = SparseMatrix((
(1, 0),
(0, 1)
))
a[3] = 4
assert a[1, 1] == 4
a[3] = 1
a[0, 0] = 2
assert a == SparseMatrix((
(2, 0),
(0, 1)
))
a[1, 0] = 5
assert a == SparseMatrix((
(2, 0),
(5, 1)
))
a[1, 1] = 0
assert a == SparseMatrix((
(2, 0),
(5, 0)
))
assert a._smat == {(0, 0): 2, (1, 0): 5}
# test_multiplication
a = SparseMatrix((
(1, 2),
(3, 1),
(0, 6),
))
b = SparseMatrix((
(1, 2),
(3, 0),
))
c = a*b
assert c[0, 0] == 7
assert c[0, 1] == 2
assert c[1, 0] == 6
assert c[1, 1] == 6
assert c[2, 0] == 18
assert c[2, 1] == 0
try:
eval('c = a @ b')
except SyntaxError:
pass
else:
assert c[0, 0] == 7
assert c[0, 1] == 2
assert c[1, 0] == 6
assert c[1, 1] == 6
assert c[2, 0] == 18
assert c[2, 1] == 0
x = Symbol("x")
c = b * Symbol("x")
assert isinstance(c, SparseMatrix)
assert c[0, 0] == x
assert c[0, 1] == 2*x
assert c[1, 0] == 3*x
assert c[1, 1] == 0
c = 5 * b
assert isinstance(c, SparseMatrix)
assert c[0, 0] == 5
assert c[0, 1] == 2*5
assert c[1, 0] == 3*5
assert c[1, 1] == 0
#test_power
A = SparseMatrix([[2, 3], [4, 5]])
assert (A**5)[:] == [6140, 8097, 10796, 14237]
A = SparseMatrix([[2, 1, 3], [4, 2, 4], [6, 12, 1]])
assert (A**3)[:] == [290, 262, 251, 448, 440, 368, 702, 954, 433]
# test_creation
x = Symbol("x")
a = SparseMatrix([[x, 0], [0, 0]])
m = a
assert m.cols == m.rows
assert m.cols == 2
assert m[:] == [x, 0, 0, 0]
b = SparseMatrix(2, 2, [x, 0, 0, 0])
m = b
assert m.cols == m.rows
assert m.cols == 2
assert m[:] == [x, 0, 0, 0]
assert a == b
S = sparse_eye(3)
S.row_del(1)
assert S == SparseMatrix([
[1, 0, 0],
[0, 0, 1]])
S = sparse_eye(3)
S.col_del(1)
assert S == SparseMatrix([
[1, 0],
[0, 0],
[0, 1]])
S = SparseMatrix.eye(3)
S[2, 1] = 2
S.col_swap(1, 0)
assert S == SparseMatrix([
[0, 1, 0],
[1, 0, 0],
[2, 0, 1]])
a = SparseMatrix(1, 2, [1, 2])
b = a.copy()
c = a.copy()
assert a[0] == 1
a.row_del(0)
assert a == SparseMatrix(0, 2, [])
b.col_del(1)
assert b == SparseMatrix(1, 1, [1])
assert SparseMatrix([[1, 2, 3], [1, 2], [1]]) == Matrix([
[1, 2, 3],
[1, 2, 0],
[1, 0, 0]])
assert SparseMatrix(4, 4, {(1, 1): sparse_eye(2)}) == Matrix([
[0, 0, 0, 0],
[0, 1, 0, 0],
[0, 0, 1, 0],
[0, 0, 0, 0]])
raises(ValueError, lambda: SparseMatrix(1, 1, {(1, 1): 1}))
assert SparseMatrix(1, 2, [1, 2]).tolist() == [[1, 2]]
assert SparseMatrix(2, 2, [1, [2, 3]]).tolist() == [[1, 0], [2, 3]]
raises(ValueError, lambda: SparseMatrix(2, 2, [1]))
raises(ValueError, lambda: SparseMatrix(1, 1, [[1, 2]]))
assert SparseMatrix([.1]).has(Float)
# autosizing
assert SparseMatrix(None, {(0, 1): 0}).shape == (0, 0)
assert SparseMatrix(None, {(0, 1): 1}).shape == (1, 2)
assert SparseMatrix(None, None, {(0, 1): 1}).shape == (1, 2)
raises(ValueError, lambda: SparseMatrix(None, 1, [[1, 2]]))
raises(ValueError, lambda: SparseMatrix(1, None, [[1, 2]]))
raises(ValueError, lambda: SparseMatrix(3, 3, {(0, 0): ones(2), (1, 1): 2}))
# test_determinant
x, y = Symbol('x'), Symbol('y')
assert SparseMatrix(1, 1, [0]).det() == 0
assert SparseMatrix([[1]]).det() == 1
assert SparseMatrix(((-3, 2), (8, -5))).det() == -1
assert SparseMatrix(((x, 1), (y, 2*y))).det() == 2*x*y - y
assert SparseMatrix(( (1, 1, 1),
(1, 2, 3),
(1, 3, 6) )).det() == 1
assert SparseMatrix(( ( 3, -2, 0, 5),
(-2, 1, -2, 2),
( 0, -2, 5, 0),
( 5, 0, 3, 4) )).det() == -289
assert SparseMatrix(( ( 1, 2, 3, 4),
( 5, 6, 7, 8),
( 9, 10, 11, 12),
(13, 14, 15, 16) )).det() == 0
assert SparseMatrix(( (3, 2, 0, 0, 0),
(0, 3, 2, 0, 0),
(0, 0, 3, 2, 0),
(0, 0, 0, 3, 2),
(2, 0, 0, 0, 3) )).det() == 275
assert SparseMatrix(( (1, 0, 1, 2, 12),
(2, 0, 1, 1, 4),
(2, 1, 1, -1, 3),
(3, 2, -1, 1, 8),
(1, 1, 1, 0, 6) )).det() == -55
assert SparseMatrix(( (-5, 2, 3, 4, 5),
( 1, -4, 3, 4, 5),
( 1, 2, -3, 4, 5),
( 1, 2, 3, -2, 5),
( 1, 2, 3, 4, -1) )).det() == 11664
assert SparseMatrix(( ( 3, 0, 0, 0),
(-2, 1, 0, 0),
( 0, -2, 5, 0),
( 5, 0, 3, 4) )).det() == 60
assert SparseMatrix(( ( 1, 0, 0, 0),
( 5, 0, 0, 0),
( 9, 10, 11, 0),
(13, 14, 15, 16) )).det() == 0
assert SparseMatrix(( (3, 2, 0, 0, 0),
(0, 3, 2, 0, 0),
(0, 0, 3, 2, 0),
(0, 0, 0, 3, 2),
(0, 0, 0, 0, 3) )).det() == 243
assert SparseMatrix(( ( 2, 7, -1, 3, 2),
( 0, 0, 1, 0, 1),
(-2, 0, 7, 0, 2),
(-3, -2, 4, 5, 3),
( 1, 0, 0, 0, 1) )).det() == 123
# test_slicing
m0 = sparse_eye(4)
assert m0[:3, :3] == sparse_eye(3)
assert m0[2:4, 0:2] == sparse_zeros(2)
m1 = SparseMatrix(3, 3, lambda i, j: i + j)
assert m1[0, :] == SparseMatrix(1, 3, (0, 1, 2))
assert m1[1:3, 1] == SparseMatrix(2, 1, (2, 3))
m2 = SparseMatrix(
[[0, 1, 2, 3], [4, 5, 6, 7], [8, 9, 10, 11], [12, 13, 14, 15]])
assert m2[:, -1] == SparseMatrix(4, 1, [3, 7, 11, 15])
assert m2[-2:, :] == SparseMatrix([[8, 9, 10, 11], [12, 13, 14, 15]])
assert SparseMatrix([[1, 2], [3, 4]])[[1], [1]] == Matrix([[4]])
# test_submatrix_assignment
m = sparse_zeros(4)
m[2:4, 2:4] = sparse_eye(2)
assert m == SparseMatrix([(0, 0, 0, 0),
(0, 0, 0, 0),
(0, 0, 1, 0),
(0, 0, 0, 1)])
assert len(m._smat) == 2
m[:2, :2] = sparse_eye(2)
assert m == sparse_eye(4)
m[:, 0] = SparseMatrix(4, 1, (1, 2, 3, 4))
assert m == SparseMatrix([(1, 0, 0, 0),
(2, 1, 0, 0),
(3, 0, 1, 0),
(4, 0, 0, 1)])
m[:, :] = sparse_zeros(4)
assert m == sparse_zeros(4)
m[:, :] = ((1, 2, 3, 4), (5, 6, 7, 8), (9, 10, 11, 12), (13, 14, 15, 16))
assert m == SparseMatrix((( 1, 2, 3, 4),
( 5, 6, 7, 8),
( 9, 10, 11, 12),
(13, 14, 15, 16)))
m[:2, 0] = [0, 0]
assert m == SparseMatrix((( 0, 2, 3, 4),
( 0, 6, 7, 8),
( 9, 10, 11, 12),
(13, 14, 15, 16)))
# test_reshape
m0 = sparse_eye(3)
assert m0.reshape(1, 9) == SparseMatrix(1, 9, (1, 0, 0, 0, 1, 0, 0, 0, 1))
m1 = SparseMatrix(3, 4, lambda i, j: i + j)
assert m1.reshape(4, 3) == \
SparseMatrix([(0, 1, 2), (3, 1, 2), (3, 4, 2), (3, 4, 5)])
assert m1.reshape(2, 6) == \
SparseMatrix([(0, 1, 2, 3, 1, 2), (3, 4, 2, 3, 4, 5)])
# test_applyfunc
m0 = sparse_eye(3)
assert m0.applyfunc(lambda x: 2*x) == sparse_eye(3)*2
assert m0.applyfunc(lambda x: 0 ) == sparse_zeros(3)
# test__eval_Abs
assert abs(SparseMatrix(((x, 1), (y, 2*y)))) == SparseMatrix(((Abs(x), 1), (Abs(y), 2*Abs(y))))
# test_LUdecomp
testmat = SparseMatrix([[ 0, 2, 5, 3],
[ 3, 3, 7, 4],
[ 8, 4, 0, 2],
[-2, 6, 3, 4]])
L, U, p = testmat.LUdecomposition()
assert L.is_lower
assert U.is_upper
assert (L*U).permute_rows(p, 'backward') - testmat == sparse_zeros(4)
testmat = SparseMatrix([[ 6, -2, 7, 4],
[ 0, 3, 6, 7],
[ 1, -2, 7, 4],
[-9, 2, 6, 3]])
L, U, p = testmat.LUdecomposition()
assert L.is_lower
assert U.is_upper
assert (L*U).permute_rows(p, 'backward') - testmat == sparse_zeros(4)
x, y, z = Symbol('x'), Symbol('y'), Symbol('z')
M = Matrix(((1, x, 1), (2, y, 0), (y, 0, z)))
L, U, p = M.LUdecomposition()
assert L.is_lower
assert U.is_upper
assert (L*U).permute_rows(p, 'backward') - M == sparse_zeros(3)
# test_LUsolve
A = SparseMatrix([[2, 3, 5],
[3, 6, 2],
[8, 3, 6]])
x = SparseMatrix(3, 1, [3, 7, 5])
b = A*x
soln = A.LUsolve(b)
assert soln == x
A = SparseMatrix([[0, -1, 2],
[5, 10, 7],
[8, 3, 4]])
x = SparseMatrix(3, 1, [-1, 2, 5])
b = A*x
soln = A.LUsolve(b)
assert soln == x
# test_inverse
A = sparse_eye(4)
assert A.inv() == sparse_eye(4)
assert A.inv(method="CH") == sparse_eye(4)
assert A.inv(method="LDL") == sparse_eye(4)
A = SparseMatrix([[2, 3, 5],
[3, 6, 2],
[7, 2, 6]])
Ainv = SparseMatrix(Matrix(A).inv())
assert A*Ainv == sparse_eye(3)
assert A.inv(method="CH") == Ainv
assert A.inv(method="LDL") == Ainv
A = SparseMatrix([[2, 3, 5],
[3, 6, 2],
[5, 2, 6]])
Ainv = SparseMatrix(Matrix(A).inv())
assert A*Ainv == sparse_eye(3)
assert A.inv(method="CH") == Ainv
assert A.inv(method="LDL") == Ainv
# test_cross
v1 = Matrix(1, 3, [1, 2, 3])
v2 = Matrix(1, 3, [3, 4, 5])
assert v1.cross(v2) == Matrix(1, 3, [-2, 4, -2])
assert v1.norm(2)**2 == 14
# conjugate
a = SparseMatrix(((1, 2 + I), (3, 4)))
assert a.C == SparseMatrix([
[1, 2 - I],
[3, 4]
])
# mul
assert a*Matrix(2, 2, [1, 0, 0, 1]) == a
assert a + Matrix(2, 2, [1, 1, 1, 1]) == SparseMatrix([
[2, 3 + I],
[4, 5]
])
# col join
assert a.col_join(sparse_eye(2)) == SparseMatrix([
[1, 2 + I],
[3, 4],
[1, 0],
[0, 1]
])
# symmetric
assert not a.is_symmetric(simplify=False)
# test_cofactor
assert sparse_eye(3) == sparse_eye(3).cofactor_matrix()
test = SparseMatrix([[1, 3, 2], [2, 6, 3], [2, 3, 6]])
assert test.cofactor_matrix() == \
SparseMatrix([[27, -6, -6], [-12, 2, 3], [-3, 1, 0]])
test = SparseMatrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
assert test.cofactor_matrix() == \
SparseMatrix([[-3, 6, -3], [6, -12, 6], [-3, 6, -3]])
# test_jacobian
x = Symbol('x')
y = Symbol('y')
L = SparseMatrix(1, 2, [x**2*y, 2*y**2 + x*y])
syms = [x, y]
assert L.jacobian(syms) == Matrix([[2*x*y, x**2], [y, 4*y + x]])
L = SparseMatrix(1, 2, [x, x**2*y**3])
assert L.jacobian(syms) == SparseMatrix([[1, 0], [2*x*y**3, x**2*3*y**2]])
# test_QR
A = Matrix([[1, 2], [2, 3]])
Q, S = A.QRdecomposition()
R = Rational
assert Q == Matrix([
[ 5**R(-1, 2), (R(2)/5)*(R(1)/5)**R(-1, 2)],
[2*5**R(-1, 2), (-R(1)/5)*(R(1)/5)**R(-1, 2)]])
assert S == Matrix([
[5**R(1, 2), 8*5**R(-1, 2)],
[ 0, (R(1)/5)**R(1, 2)]])
assert Q*S == A
assert Q.T * Q == sparse_eye(2)
R = Rational
# test nullspace
# first test reduced row-ech form
M = SparseMatrix([[5, 7, 2, 1],
[1, 6, 2, -1]])
out, tmp = M.rref()
assert out == Matrix([[1, 0, -R(2)/23, R(13)/23],
[0, 1, R(8)/23, R(-6)/23]])
M = SparseMatrix([[ 1, 3, 0, 2, 6, 3, 1],
[-2, -6, 0, -2, -8, 3, 1],
[ 3, 9, 0, 0, 6, 6, 2],
[-1, -3, 0, 1, 0, 9, 3]])
out, tmp = M.rref()
assert out == Matrix([[1, 3, 0, 0, 2, 0, 0],
[0, 0, 0, 1, 2, 0, 0],
[0, 0, 0, 0, 0, 1, R(1)/3],
[0, 0, 0, 0, 0, 0, 0]])
# now check the vectors
basis = M.nullspace()
assert basis[0] == Matrix([-3, 1, 0, 0, 0, 0, 0])
assert basis[1] == Matrix([0, 0, 1, 0, 0, 0, 0])
assert basis[2] == Matrix([-2, 0, 0, -2, 1, 0, 0])
assert basis[3] == Matrix([0, 0, 0, 0, 0, R(-1)/3, 1])
# test eigen
x = Symbol('x')
y = Symbol('y')
sparse_eye3 = sparse_eye(3)
assert sparse_eye3.charpoly(x) == PurePoly((x - 1)**3)
assert sparse_eye3.charpoly(y) == PurePoly((y - 1)**3)
# test values
M = Matrix([( 0, 1, -1),
( 1, 1, 0),
(-1, 0, 1)])
vals = M.eigenvals()
assert sorted(vals.keys()) == [-1, 1, 2]
R = Rational
M = Matrix([[1, 0, 0],
[0, 1, 0],
[0, 0, 1]])
assert M.eigenvects() == [(1, 3, [
Matrix([1, 0, 0]),
Matrix([0, 1, 0]),
Matrix([0, 0, 1])])]
M = Matrix([[5, 0, 2],
[3, 2, 0],
[0, 0, 1]])
assert M.eigenvects() == [(1, 1, [Matrix([R(-1)/2, R(3)/2, 1])]),
(2, 1, [Matrix([0, 1, 0])]),
(5, 1, [Matrix([1, 1, 0])])]
assert M.zeros(3, 5) == SparseMatrix(3, 5, {})
A = SparseMatrix(10, 10, {(0, 0): 18, (0, 9): 12, (1, 4): 18, (2, 7): 16, (3, 9): 12, (4, 2): 19, (5, 7): 16, (6, 2): 12, (9, 7): 18})
assert A.row_list() == [(0, 0, 18), (0, 9, 12), (1, 4, 18), (2, 7, 16), (3, 9, 12), (4, 2, 19), (5, 7, 16), (6, 2, 12), (9, 7, 18)]
assert A.col_list() == [(0, 0, 18), (4, 2, 19), (6, 2, 12), (1, 4, 18), (2, 7, 16), (5, 7, 16), (9, 7, 18), (0, 9, 12), (3, 9, 12)]
assert SparseMatrix.eye(2).nnz() == 2
def test_transpose():
assert SparseMatrix(((1, 2), (3, 4))).transpose() == \
SparseMatrix(((1, 3), (2, 4)))
def test_trace():
assert SparseMatrix(((1, 2), (3, 4))).trace() == 5
assert SparseMatrix(((0, 0), (0, 4))).trace() == 4
def test_CL_RL():
assert SparseMatrix(((1, 2), (3, 4))).row_list() == \
[(0, 0, 1), (0, 1, 2), (1, 0, 3), (1, 1, 4)]
assert SparseMatrix(((1, 2), (3, 4))).col_list() == \
[(0, 0, 1), (1, 0, 3), (0, 1, 2), (1, 1, 4)]
def test_add():
assert SparseMatrix(((1, 0), (0, 1))) + SparseMatrix(((0, 1), (1, 0))) == \
SparseMatrix(((1, 1), (1, 1)))
a = SparseMatrix(100, 100, lambda i, j: int(j != 0 and i % j == 0))
b = SparseMatrix(100, 100, lambda i, j: int(i != 0 and j % i == 0))
assert (len(a._smat) + len(b._smat) - len((a + b)._smat) > 0)
def test_errors():
raises(ValueError, lambda: SparseMatrix(1.4, 2, lambda i, j: 0))
raises(TypeError, lambda: SparseMatrix([1, 2, 3], [1, 2]))
raises(ValueError, lambda: SparseMatrix([[1, 2], [3, 4]])[(1, 2, 3)])
raises(IndexError, lambda: SparseMatrix([[1, 2], [3, 4]])[5])
raises(ValueError, lambda: SparseMatrix([[1, 2], [3, 4]])[1, 2, 3])
raises(TypeError,
lambda: SparseMatrix([[1, 2], [3, 4]]).copyin_list([0, 1], set()))
raises(
IndexError, lambda: SparseMatrix([[1, 2], [3, 4]])[1, 2])
raises(TypeError, lambda: SparseMatrix([1, 2, 3]).cross(1))
raises(IndexError, lambda: SparseMatrix(1, 2, [1, 2])[3])
raises(ShapeError,
lambda: SparseMatrix(1, 2, [1, 2]) + SparseMatrix(2, 1, [2, 1]))
def test_len():
assert not SparseMatrix()
assert SparseMatrix() == SparseMatrix([])
assert SparseMatrix() == SparseMatrix([[]])
def test_sparse_zeros_sparse_eye():
assert SparseMatrix.eye(3) == eye(3, cls=SparseMatrix)
assert len(SparseMatrix.eye(3)._smat) == 3
assert SparseMatrix.zeros(3) == zeros(3, cls=SparseMatrix)
assert len(SparseMatrix.zeros(3)._smat) == 0
def test_copyin():
s = SparseMatrix(3, 3, {})
s[1, 0] = 1
assert s[:, 0] == SparseMatrix(Matrix([0, 1, 0]))
assert s[3] == 1
assert s[3: 4] == [1]
s[1, 1] = 42
assert s[1, 1] == 42
assert s[1, 1:] == SparseMatrix([[42, 0]])
s[1, 1:] = Matrix([[5, 6]])
assert s[1, :] == SparseMatrix([[1, 5, 6]])
s[1, 1:] = [[42, 43]]
assert s[1, :] == SparseMatrix([[1, 42, 43]])
s[0, 0] = 17
assert s[:, :1] == SparseMatrix([17, 1, 0])
s[0, 0] = [1, 1, 1]
assert s[:, 0] == SparseMatrix([1, 1, 1])
s[0, 0] = Matrix([1, 1, 1])
assert s[:, 0] == SparseMatrix([1, 1, 1])
s[0, 0] = SparseMatrix([1, 1, 1])
assert s[:, 0] == SparseMatrix([1, 1, 1])
def test_sparse_solve():
from sympy.matrices import SparseMatrix
A = SparseMatrix(((25, 15, -5), (15, 18, 0), (-5, 0, 11)))
assert A.cholesky() == Matrix([
[ 5, 0, 0],
[ 3, 3, 0],
[-1, 1, 3]])
assert A.cholesky() * A.cholesky().T == Matrix([
[25, 15, -5],
[15, 18, 0],
[-5, 0, 11]])
A = SparseMatrix(((25, 15, -5), (15, 18, 0), (-5, 0, 11)))
L, D = A.LDLdecomposition()
assert 15*L == Matrix([
[15, 0, 0],
[ 9, 15, 0],
[-3, 5, 15]])
assert D == Matrix([
[25, 0, 0],
[ 0, 9, 0],
[ 0, 0, 9]])
assert L * D * L.T == A
A = SparseMatrix(((3, 0, 2), (0, 0, 1), (1, 2, 0)))
assert A.inv() * A == SparseMatrix(eye(3))
A = SparseMatrix([
[ 2, -1, 0],
[-1, 2, -1],
[ 0, 0, 2]])
ans = SparseMatrix([
[Rational(2, 3), Rational(1, 3), Rational(1, 6)],
[Rational(1, 3), Rational(2, 3), Rational(1, 3)],
[ 0, 0, S.Half]])
assert A.inv(method='CH') == ans
assert A.inv(method='LDL') == ans
assert A * ans == SparseMatrix(eye(3))
s = A.solve(A[:, 0], 'LDL')
assert A*s == A[:, 0]
s = A.solve(A[:, 0], 'CH')
assert A*s == A[:, 0]
A = A.col_join(A)
s = A.solve_least_squares(A[:, 0], 'CH')
assert A*s == A[:, 0]
s = A.solve_least_squares(A[:, 0], 'LDL')
assert A*s == A[:, 0]
def test_lower_triangular_solve():
a, b, c, d = symbols('a:d')
u, v, w, x = symbols('u:x')
A = SparseMatrix([[a, 0], [c, d]])
B = MutableSparseMatrix([[u, v], [w, x]])
C = ImmutableSparseMatrix([[u, v], [w, x]])
sol = Matrix([[u/a, v/a], [(w - c*u/a)/d, (x - c*v/a)/d]])
assert A.lower_triangular_solve(B) == sol
assert A.lower_triangular_solve(C) == sol
def test_upper_triangular_solve():
a, b, c, d = symbols('a:d')
u, v, w, x = symbols('u:x')
A = SparseMatrix([[a, b], [0, d]])
B = MutableSparseMatrix([[u, v], [w, x]])
C = ImmutableSparseMatrix([[u, v], [w, x]])
sol = Matrix([[(u - b*w/d)/a, (v - b*x/d)/a], [w/d, x/d]])
assert A.upper_triangular_solve(B) == sol
assert A.upper_triangular_solve(C) == sol
def test_diagonal_solve():
a, d = symbols('a d')
u, v, w, x = symbols('u:x')
A = SparseMatrix([[a, 0], [0, d]])
B = MutableSparseMatrix([[u, v], [w, x]])
C = ImmutableSparseMatrix([[u, v], [w, x]])
sol = Matrix([[u/a, v/a], [w/d, x/d]])
assert A.diagonal_solve(B) == sol
assert A.diagonal_solve(C) == sol
def test_hermitian():
x = Symbol('x')
a = SparseMatrix([[0, I], [-I, 0]])
assert a.is_hermitian
a = SparseMatrix([[1, I], [-I, 1]])
assert a.is_hermitian
a[0, 0] = 2*I
assert a.is_hermitian is False
a[0, 0] = x
assert a.is_hermitian is None
a[0, 1] = a[1, 0]*I
assert a.is_hermitian is False
|
ebc75f5e97d52c0e09762db41bec64fc7d1bc5682b5ac6325878f18a38724941 | from sympy import Rational, I, expand_mul, S, simplify
from sympy.matrices.matrices import NonSquareMatrixError
from sympy.matrices import Matrix, zeros, eye, SparseMatrix
from sympy.abc import x, y, z
from sympy.testing.pytest import raises
from sympy.testing.matrices import allclose
def test_LUdecomp():
testmat = Matrix([[0, 2, 5, 3],
[3, 3, 7, 4],
[8, 4, 0, 2],
[-2, 6, 3, 4]])
L, U, p = testmat.LUdecomposition()
assert L.is_lower
assert U.is_upper
assert (L*U).permute_rows(p, 'backward') - testmat == zeros(4)
testmat = Matrix([[6, -2, 7, 4],
[0, 3, 6, 7],
[1, -2, 7, 4],
[-9, 2, 6, 3]])
L, U, p = testmat.LUdecomposition()
assert L.is_lower
assert U.is_upper
assert (L*U).permute_rows(p, 'backward') - testmat == zeros(4)
# non-square
testmat = Matrix([[1, 2, 3],
[4, 5, 6],
[7, 8, 9],
[10, 11, 12]])
L, U, p = testmat.LUdecomposition(rankcheck=False)
assert L.is_lower
assert U.is_upper
assert (L*U).permute_rows(p, 'backward') - testmat == zeros(4, 3)
# square and singular
testmat = Matrix([[1, 2, 3],
[2, 4, 6],
[4, 5, 6]])
L, U, p = testmat.LUdecomposition(rankcheck=False)
assert L.is_lower
assert U.is_upper
assert (L*U).permute_rows(p, 'backward') - testmat == zeros(3)
M = Matrix(((1, x, 1), (2, y, 0), (y, 0, z)))
L, U, p = M.LUdecomposition()
assert L.is_lower
assert U.is_upper
assert (L*U).permute_rows(p, 'backward') - M == zeros(3)
mL = Matrix((
(1, 0, 0),
(2, 3, 0),
))
assert mL.is_lower is True
assert mL.is_upper is False
mU = Matrix((
(1, 2, 3),
(0, 4, 5),
))
assert mU.is_lower is False
assert mU.is_upper is True
# test FF LUdecomp
M = Matrix([[1, 3, 3],
[3, 2, 6],
[3, 2, 2]])
P, L, Dee, U = M.LUdecompositionFF()
assert P*M == L*Dee.inv()*U
M = Matrix([[1, 2, 3, 4],
[3, -1, 2, 3],
[3, 1, 3, -2],
[6, -1, 0, 2]])
P, L, Dee, U = M.LUdecompositionFF()
assert P*M == L*Dee.inv()*U
M = Matrix([[0, 0, 1],
[2, 3, 0],
[3, 1, 4]])
P, L, Dee, U = M.LUdecompositionFF()
assert P*M == L*Dee.inv()*U
# issue 15794
M = Matrix(
[[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
)
raises(ValueError, lambda : M.LUdecomposition_Simple(rankcheck=True))
def test_QR():
A = Matrix([[1, 2], [2, 3]])
Q, S = A.QRdecomposition()
R = Rational
assert Q == Matrix([
[ 5**R(-1, 2), (R(2)/5)*(R(1)/5)**R(-1, 2)],
[2*5**R(-1, 2), (-R(1)/5)*(R(1)/5)**R(-1, 2)]])
assert S == Matrix([[5**R(1, 2), 8*5**R(-1, 2)], [0, (R(1)/5)**R(1, 2)]])
assert Q*S == A
assert Q.T * Q == eye(2)
A = Matrix([[1, 1, 1], [1, 1, 3], [2, 3, 4]])
Q, R = A.QRdecomposition()
assert Q.T * Q == eye(Q.cols)
assert R.is_upper
assert A == Q*R
def test_QR_non_square():
# Narrow (cols < rows) matrices
A = Matrix([[9, 0, 26], [12, 0, -7], [0, 4, 4], [0, -3, -3]])
Q, R = A.QRdecomposition()
assert Q.T * Q == eye(Q.cols)
assert R.is_upper
assert A == Q*R
A = Matrix([[1, -1, 4], [1, 4, -2], [1, 4, 2], [1, -1, 0]])
Q, R = A.QRdecomposition()
assert Q.T * Q == eye(Q.cols)
assert R.is_upper
assert A == Q*R
A = Matrix(2, 1, [1, 2])
Q, R = A.QRdecomposition()
assert Q.T * Q == eye(Q.cols)
assert R.is_upper
assert A == Q*R
# Wide (cols > rows) matrices
A = Matrix([[1, 2, 3], [4, 5, 6]])
Q, R = A.QRdecomposition()
assert Q.T * Q == eye(Q.cols)
assert R.is_upper
assert A == Q*R
A = Matrix([[1, 2, 3, 4], [1, 4, 9, 16], [1, 8, 27, 64]])
Q, R = A.QRdecomposition()
assert Q.T * Q == eye(Q.cols)
assert R.is_upper
assert A == Q*R
A = Matrix(1, 2, [1, 2])
Q, R = A.QRdecomposition()
assert Q.T * Q == eye(Q.cols)
assert R.is_upper
assert A == Q*R
def test_QR_trivial():
# Rank deficient matrices
A = Matrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
Q, R = A.QRdecomposition()
assert Q.T * Q == eye(Q.cols)
assert R.is_upper
assert A == Q*R
A = Matrix([[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4]])
Q, R = A.QRdecomposition()
assert Q.T * Q == eye(Q.cols)
assert R.is_upper
assert A == Q*R
A = Matrix([[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4]]).T
Q, R = A.QRdecomposition()
assert Q.T * Q == eye(Q.cols)
assert R.is_upper
assert A == Q*R
# Zero rank matrices
A = Matrix([[0, 0, 0]])
Q, R = A.QRdecomposition()
assert Q.T * Q == eye(Q.cols)
assert R.is_upper
assert A == Q*R
A = Matrix([[0, 0, 0]]).T
Q, R = A.QRdecomposition()
assert Q.T * Q == eye(Q.cols)
assert R.is_upper
assert A == Q*R
A = Matrix([[0, 0, 0], [0, 0, 0]])
Q, R = A.QRdecomposition()
assert Q.T * Q == eye(Q.cols)
assert R.is_upper
assert A == Q*R
A = Matrix([[0, 0, 0], [0, 0, 0]]).T
Q, R = A.QRdecomposition()
assert Q.T * Q == eye(Q.cols)
assert R.is_upper
assert A == Q*R
# Rank deficient matrices with zero norm from beginning columns
A = Matrix([[0, 0, 0], [1, 2, 3]]).T
Q, R = A.QRdecomposition()
assert Q.T * Q == eye(Q.cols)
assert R.is_upper
assert A == Q*R
A = Matrix([[0, 0, 0, 0], [1, 2, 3, 4], [0, 0, 0, 0]]).T
Q, R = A.QRdecomposition()
assert Q.T * Q == eye(Q.cols)
assert R.is_upper
assert A == Q*R
A = Matrix([[0, 0, 0, 0], [1, 2, 3, 4], [0, 0, 0, 0], [2, 4, 6, 8]]).T
Q, R = A.QRdecomposition()
assert Q.T * Q == eye(Q.cols)
assert R.is_upper
assert A == Q*R
A = Matrix([[0, 0, 0], [0, 0, 0], [0, 0, 0], [1, 2, 3]]).T
Q, R = A.QRdecomposition()
assert Q.T * Q == eye(Q.cols)
assert R.is_upper
assert A == Q*R
def test_QR_float():
A = Matrix([[1, 1], [1, 1.01]])
Q, R = A.QRdecomposition()
assert allclose(Q * R, A)
assert allclose(Q * Q.T, Matrix.eye(2))
assert allclose(Q.T * Q, Matrix.eye(2))
A = Matrix([[1, 1], [1, 1.001]])
Q, R = A.QRdecomposition()
assert allclose(Q * R, A)
assert allclose(Q * Q.T, Matrix.eye(2))
assert allclose(Q.T * Q, Matrix.eye(2))
def test_LUdecomposition_Simple_iszerofunc():
# Test if callable passed to matrices.LUdecomposition_Simple() as iszerofunc keyword argument is used inside
# matrices.LUdecomposition_Simple()
magic_string = "I got passed in!"
def goofyiszero(value):
raise ValueError(magic_string)
try:
lu, p = Matrix([[1, 0], [0, 1]]).LUdecomposition_Simple(iszerofunc=goofyiszero)
except ValueError as err:
assert magic_string == err.args[0]
return
assert False
def test_LUdecomposition_iszerofunc():
# Test if callable passed to matrices.LUdecomposition() as iszerofunc keyword argument is used inside
# matrices.LUdecomposition_Simple()
magic_string = "I got passed in!"
def goofyiszero(value):
raise ValueError(magic_string)
try:
l, u, p = Matrix([[1, 0], [0, 1]]).LUdecomposition(iszerofunc=goofyiszero)
except ValueError as err:
assert magic_string == err.args[0]
return
assert False
def test_LDLdecomposition():
raises(NonSquareMatrixError, lambda: Matrix((1, 2)).LDLdecomposition())
raises(ValueError, lambda: Matrix(((1, 2), (3, 4))).LDLdecomposition())
raises(ValueError, lambda: Matrix(((5 + I, 0), (0, 1))).LDLdecomposition())
raises(ValueError, lambda: Matrix(((1, 5), (5, 1))).LDLdecomposition())
raises(ValueError, lambda: Matrix(((1, 2), (3, 4))).LDLdecomposition(hermitian=False))
A = Matrix(((1, 5), (5, 1)))
L, D = A.LDLdecomposition(hermitian=False)
assert L * D * L.T == A
A = Matrix(((25, 15, -5), (15, 18, 0), (-5, 0, 11)))
L, D = A.LDLdecomposition()
assert L * D * L.T == A
assert L.is_lower
assert L == Matrix([[1, 0, 0], [ Rational(3, 5), 1, 0], [Rational(-1, 5), Rational(1, 3), 1]])
assert D.is_diagonal()
assert D == Matrix([[25, 0, 0], [0, 9, 0], [0, 0, 9]])
A = Matrix(((4, -2*I, 2 + 2*I), (2*I, 2, -1 + I), (2 - 2*I, -1 - I, 11)))
L, D = A.LDLdecomposition()
assert expand_mul(L * D * L.H) == A
assert L.expand() == Matrix([[1, 0, 0], [I/2, 1, 0], [S.Half - I/2, 0, 1]])
assert D.expand() == Matrix(((4, 0, 0), (0, 1, 0), (0, 0, 9)))
raises(NonSquareMatrixError, lambda: SparseMatrix((1, 2)).LDLdecomposition())
raises(ValueError, lambda: SparseMatrix(((1, 2), (3, 4))).LDLdecomposition())
raises(ValueError, lambda: SparseMatrix(((5 + I, 0), (0, 1))).LDLdecomposition())
raises(ValueError, lambda: SparseMatrix(((1, 5), (5, 1))).LDLdecomposition())
raises(ValueError, lambda: SparseMatrix(((1, 2), (3, 4))).LDLdecomposition(hermitian=False))
A = SparseMatrix(((1, 5), (5, 1)))
L, D = A.LDLdecomposition(hermitian=False)
assert L * D * L.T == A
A = SparseMatrix(((25, 15, -5), (15, 18, 0), (-5, 0, 11)))
L, D = A.LDLdecomposition()
assert L * D * L.T == A
assert L.is_lower
assert L == Matrix([[1, 0, 0], [ Rational(3, 5), 1, 0], [Rational(-1, 5), Rational(1, 3), 1]])
assert D.is_diagonal()
assert D == Matrix([[25, 0, 0], [0, 9, 0], [0, 0, 9]])
A = SparseMatrix(((4, -2*I, 2 + 2*I), (2*I, 2, -1 + I), (2 - 2*I, -1 - I, 11)))
L, D = A.LDLdecomposition()
assert expand_mul(L * D * L.H) == A
assert L == Matrix(((1, 0, 0), (I/2, 1, 0), (S.Half - I/2, 0, 1)))
assert D == Matrix(((4, 0, 0), (0, 1, 0), (0, 0, 9)))
def test_pinv_succeeds_with_rank_decomposition_method():
# Test rank decomposition method of pseudoinverse succeeding
As = [Matrix([
[61, 89, 55, 20, 71, 0],
[62, 96, 85, 85, 16, 0],
[69, 56, 17, 4, 54, 0],
[10, 54, 91, 41, 71, 0],
[ 7, 30, 10, 48, 90, 0],
[0,0,0,0,0,0]])]
for A in As:
A_pinv = A.pinv(method="RD")
AAp = A * A_pinv
ApA = A_pinv * A
assert simplify(AAp * A) == A
assert simplify(ApA * A_pinv) == A_pinv
assert AAp.H == AAp
assert ApA.H == ApA
def test_rank_decomposition():
a = Matrix(0, 0, [])
c, f = a.rank_decomposition()
assert f.is_echelon
assert c.cols == f.rows == a.rank()
assert c * f == a
a = Matrix(1, 1, [5])
c, f = a.rank_decomposition()
assert f.is_echelon
assert c.cols == f.rows == a.rank()
assert c * f == a
a = Matrix(3, 3, [1, 2, 3, 1, 2, 3, 1, 2, 3])
c, f = a.rank_decomposition()
assert f.is_echelon
assert c.cols == f.rows == a.rank()
assert c * f == a
a = Matrix([
[0, 0, 1, 2, 2, -5, 3],
[-1, 5, 2, 2, 1, -7, 5],
[0, 0, -2, -3, -3, 8, -5],
[-1, 5, 0, -1, -2, 1, 0]])
c, f = a.rank_decomposition()
assert f.is_echelon
assert c.cols == f.rows == a.rank()
assert c * f == a
|
70602342227ae95adac541fa38569dee61086d334af88ea922efe586bd151d40 | from itertools import product
from sympy import (ImmutableMatrix, Matrix, eye, zeros, S, Equality,
Unequality, SparseMatrix, sympify, integrate)
from sympy.matrices.immutable import \
ImmutableDenseMatrix, ImmutableSparseMatrix
from sympy.abc import x, y
from sympy.testing.pytest import raises
IM = ImmutableDenseMatrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
ISM = ImmutableSparseMatrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
ieye = ImmutableDenseMatrix(eye(3))
def test_creation():
assert IM.shape == ISM.shape == (3, 3)
assert IM[1, 2] == ISM[1, 2] == 6
assert IM[2, 2] == ISM[2, 2] == 9
def test_immutability():
with raises(TypeError):
IM[2, 2] = 5
with raises(TypeError):
ISM[2, 2] = 5
def test_slicing():
assert IM[1, :] == ImmutableDenseMatrix([[4, 5, 6]])
assert IM[:2, :2] == ImmutableDenseMatrix([[1, 2], [4, 5]])
assert ISM[1, :] == ImmutableSparseMatrix([[4, 5, 6]])
assert ISM[:2, :2] == ImmutableSparseMatrix([[1, 2], [4, 5]])
def test_subs():
A = ImmutableMatrix([[1, 2], [3, 4]])
B = ImmutableMatrix([[1, 2], [x, 4]])
C = ImmutableMatrix([[-x, x*y], [-(x + y), y**2]])
assert B.subs(x, 3) == A
assert (x*B).subs(x, 3) == 3*A
assert (x*eye(2) + B).subs(x, 3) == 3*eye(2) + A
assert C.subs([[x, -1], [y, -2]]) == A
assert C.subs([(x, -1), (y, -2)]) == A
assert C.subs({x: -1, y: -2}) == A
assert C.subs({x: y - 1, y: x - 1}, simultaneous=True) == \
ImmutableMatrix([[1 - y, (x - 1)*(y - 1)], [2 - x - y, (x - 1)**2]])
def test_as_immutable():
data = [[1, 2], [3, 4]]
X = Matrix(data)
assert sympify(X) == X.as_immutable() == ImmutableMatrix(data)
data = {(0, 0): 1, (0, 1): 2, (1, 0): 3, (1, 1): 4}
X = SparseMatrix(2, 2, data)
assert sympify(X) == X.as_immutable() == ImmutableSparseMatrix(2, 2, data)
def test_function_return_types():
# Lets ensure that decompositions of immutable matrices remain immutable
# I.e. do MatrixBase methods return the correct class?
X = ImmutableMatrix([[1, 2], [3, 4]])
Y = ImmutableMatrix([[1], [0]])
q, r = X.QRdecomposition()
assert (type(q), type(r)) == (ImmutableMatrix, ImmutableMatrix)
assert type(X.LUsolve(Y)) == ImmutableMatrix
assert type(X.QRsolve(Y)) == ImmutableMatrix
X = ImmutableMatrix([[5, 2], [2, 7]])
assert X.T == X
assert X.is_symmetric
assert type(X.cholesky()) == ImmutableMatrix
L, D = X.LDLdecomposition()
assert (type(L), type(D)) == (ImmutableMatrix, ImmutableMatrix)
X = ImmutableMatrix([[1, 2], [2, 1]])
assert X.is_diagonalizable()
assert X.det() == -3
assert X.norm(2) == 3
assert type(X.eigenvects()[0][2][0]) == ImmutableMatrix
assert type(zeros(3, 3).as_immutable().nullspace()[0]) == ImmutableMatrix
X = ImmutableMatrix([[1, 0], [2, 1]])
assert type(X.lower_triangular_solve(Y)) == ImmutableMatrix
assert type(X.T.upper_triangular_solve(Y)) == ImmutableMatrix
assert type(X.minor_submatrix(0, 0)) == ImmutableMatrix
# issue 6279
# https://github.com/sympy/sympy/issues/6279
# Test that Immutable _op_ Immutable => Immutable and not MatExpr
def test_immutable_evaluation():
X = ImmutableMatrix(eye(3))
A = ImmutableMatrix(3, 3, range(9))
assert isinstance(X + A, ImmutableMatrix)
assert isinstance(X * A, ImmutableMatrix)
assert isinstance(X * 2, ImmutableMatrix)
assert isinstance(2 * X, ImmutableMatrix)
assert isinstance(A**2, ImmutableMatrix)
def test_deterimant():
assert ImmutableMatrix(4, 4, lambda i, j: i + j).det() == 0
def test_Equality():
assert Equality(IM, IM) is S.true
assert Unequality(IM, IM) is S.false
assert Equality(IM, IM.subs(1, 2)) is S.false
assert Unequality(IM, IM.subs(1, 2)) is S.true
assert Equality(IM, 2) is S.false
assert Unequality(IM, 2) is S.true
M = ImmutableMatrix([x, y])
assert Equality(M, IM) is S.false
assert Unequality(M, IM) is S.true
assert Equality(M, M.subs(x, 2)).subs(x, 2) is S.true
assert Unequality(M, M.subs(x, 2)).subs(x, 2) is S.false
assert Equality(M, M.subs(x, 2)).subs(x, 3) is S.false
assert Unequality(M, M.subs(x, 2)).subs(x, 3) is S.true
def test_integrate():
intIM = integrate(IM, x)
assert intIM.shape == IM.shape
assert all([intIM[i, j] == (1 + j + 3*i)*x for i, j in
product(range(3), range(3))])
|
1f15d5cf25881d5f547124414ce457671f3c3cba199509c6e28f574af3ebb49d | import random
from sympy import (
Abs, Add, E, Float, I, Integer, Max, Min, Poly, Pow, PurePoly, Rational,
S, Symbol, cos, exp, log, oo, pi, signsimp, simplify, sin,
sqrt, symbols, sympify, trigsimp, tan, sstr, diff, Function, expand)
from sympy.matrices.matrices import (ShapeError, MatrixError,
NonSquareMatrixError, DeferredVector, _find_reasonable_pivot_naive,
_simplify)
from sympy.matrices import (
GramSchmidt, ImmutableMatrix, ImmutableSparseMatrix, Matrix,
SparseMatrix, casoratian, diag, eye, hessian,
matrix_multiply_elementwise, ones, randMatrix, rot_axis1, rot_axis2,
rot_axis3, wronskian, zeros, MutableDenseMatrix, ImmutableDenseMatrix, MatrixSymbol)
from sympy.core.compatibility import iterable, Hashable
from sympy.core import Tuple, Wild
from sympy.functions.special.tensor_functions import KroneckerDelta
from sympy.utilities.iterables import flatten, capture
from sympy.testing.pytest import raises, XFAIL, skip, warns_deprecated_sympy
from sympy.assumptions import Q
from sympy.tensor.array import Array
from sympy.matrices.expressions import MatPow
from sympy.abc import a, b, c, d, x, y, z, t
# don't re-order this list
classes = (Matrix, SparseMatrix, ImmutableMatrix, ImmutableSparseMatrix)
def test_args():
for n, cls in enumerate(classes):
m = cls.zeros(3, 2)
# all should give back the same type of arguments, e.g. ints for shape
assert m.shape == (3, 2) and all(type(i) is int for i in m.shape)
assert m.rows == 3 and type(m.rows) is int
assert m.cols == 2 and type(m.cols) is int
if not n % 2:
assert type(m._mat) in (list, tuple, Tuple)
else:
assert type(m._smat) is dict
def test_division():
v = Matrix(1, 2, [x, y])
assert v.__div__(z) == Matrix(1, 2, [x/z, y/z])
assert v.__truediv__(z) == Matrix(1, 2, [x/z, y/z])
assert v/z == Matrix(1, 2, [x/z, y/z])
def test_sum():
m = Matrix([[1, 2, 3], [x, y, x], [2*y, -50, z*x]])
assert m + m == Matrix([[2, 4, 6], [2*x, 2*y, 2*x], [4*y, -100, 2*z*x]])
n = Matrix(1, 2, [1, 2])
raises(ShapeError, lambda: m + n)
def test_abs():
m = Matrix(1, 2, [-3, x])
n = Matrix(1, 2, [3, Abs(x)])
assert abs(m) == n
def test_addition():
a = Matrix((
(1, 2),
(3, 1),
))
b = Matrix((
(1, 2),
(3, 0),
))
assert a + b == a.add(b) == Matrix([[2, 4], [6, 1]])
def test_fancy_index_matrix():
for M in (Matrix, SparseMatrix):
a = M(3, 3, range(9))
assert a == a[:, :]
assert a[1, :] == Matrix(1, 3, [3, 4, 5])
assert a[:, 1] == Matrix([1, 4, 7])
assert a[[0, 1], :] == Matrix([[0, 1, 2], [3, 4, 5]])
assert a[[0, 1], 2] == a[[0, 1], [2]]
assert a[2, [0, 1]] == a[[2], [0, 1]]
assert a[:, [0, 1]] == Matrix([[0, 1], [3, 4], [6, 7]])
assert a[0, 0] == 0
assert a[0:2, :] == Matrix([[0, 1, 2], [3, 4, 5]])
assert a[:, 0:2] == Matrix([[0, 1], [3, 4], [6, 7]])
assert a[::2, 1] == a[[0, 2], 1]
assert a[1, ::2] == a[1, [0, 2]]
a = M(3, 3, range(9))
assert a[[0, 2, 1, 2, 1], :] == Matrix([
[0, 1, 2],
[6, 7, 8],
[3, 4, 5],
[6, 7, 8],
[3, 4, 5]])
assert a[:, [0,2,1,2,1]] == Matrix([
[0, 2, 1, 2, 1],
[3, 5, 4, 5, 4],
[6, 8, 7, 8, 7]])
a = SparseMatrix.zeros(3)
a[1, 2] = 2
a[0, 1] = 3
a[2, 0] = 4
assert a.extract([1, 1], [2]) == Matrix([
[2],
[2]])
assert a.extract([1, 0], [2, 2, 2]) == Matrix([
[2, 2, 2],
[0, 0, 0]])
assert a.extract([1, 0, 1, 2], [2, 0, 1, 0]) == Matrix([
[2, 0, 0, 0],
[0, 0, 3, 0],
[2, 0, 0, 0],
[0, 4, 0, 4]])
def test_multiplication():
a = Matrix((
(1, 2),
(3, 1),
(0, 6),
))
b = Matrix((
(1, 2),
(3, 0),
))
c = a*b
assert c[0, 0] == 7
assert c[0, 1] == 2
assert c[1, 0] == 6
assert c[1, 1] == 6
assert c[2, 0] == 18
assert c[2, 1] == 0
try:
eval('c = a @ b')
except SyntaxError:
pass
else:
assert c[0, 0] == 7
assert c[0, 1] == 2
assert c[1, 0] == 6
assert c[1, 1] == 6
assert c[2, 0] == 18
assert c[2, 1] == 0
h = matrix_multiply_elementwise(a, c)
assert h == a.multiply_elementwise(c)
assert h[0, 0] == 7
assert h[0, 1] == 4
assert h[1, 0] == 18
assert h[1, 1] == 6
assert h[2, 0] == 0
assert h[2, 1] == 0
raises(ShapeError, lambda: matrix_multiply_elementwise(a, b))
c = b * Symbol("x")
assert isinstance(c, Matrix)
assert c[0, 0] == x
assert c[0, 1] == 2*x
assert c[1, 0] == 3*x
assert c[1, 1] == 0
c2 = x * b
assert c == c2
c = 5 * b
assert isinstance(c, Matrix)
assert c[0, 0] == 5
assert c[0, 1] == 2*5
assert c[1, 0] == 3*5
assert c[1, 1] == 0
try:
eval('c = 5 @ b')
except SyntaxError:
pass
else:
assert isinstance(c, Matrix)
assert c[0, 0] == 5
assert c[0, 1] == 2*5
assert c[1, 0] == 3*5
assert c[1, 1] == 0
def test_power():
raises(NonSquareMatrixError, lambda: Matrix((1, 2))**2)
R = Rational
A = Matrix([[2, 3], [4, 5]])
assert (A**-3)[:] == [R(-269)/8, R(153)/8, R(51)/2, R(-29)/2]
assert (A**5)[:] == [6140, 8097, 10796, 14237]
A = Matrix([[2, 1, 3], [4, 2, 4], [6, 12, 1]])
assert (A**3)[:] == [290, 262, 251, 448, 440, 368, 702, 954, 433]
assert A**0 == eye(3)
assert A**1 == A
assert (Matrix([[2]]) ** 100)[0, 0] == 2**100
assert eye(2)**10000000 == eye(2)
assert Matrix([[1, 2], [3, 4]])**Integer(2) == Matrix([[7, 10], [15, 22]])
A = Matrix([[33, 24], [48, 57]])
assert (A**S.Half)[:] == [5, 2, 4, 7]
A = Matrix([[0, 4], [-1, 5]])
assert (A**S.Half)**2 == A
assert Matrix([[1, 0], [1, 1]])**S.Half == Matrix([[1, 0], [S.Half, 1]])
assert Matrix([[1, 0], [1, 1]])**0.5 == Matrix([[1.0, 0], [0.5, 1.0]])
from sympy.abc import a, b, n
assert Matrix([[1, a], [0, 1]])**n == Matrix([[1, a*n], [0, 1]])
assert Matrix([[b, a], [0, b]])**n == Matrix([[b**n, a*b**(n-1)*n], [0, b**n]])
assert Matrix([
[a**n, a**(n - 1)*n, (a**n*n**2 - a**n*n)/(2*a**2)],
[ 0, a**n, a**(n - 1)*n],
[ 0, 0, a**n]])
assert Matrix([[a, 1, 0], [0, a, 0], [0, 0, b]])**n == Matrix([
[a**n, a**(n-1)*n, 0],
[0, a**n, 0],
[0, 0, b**n]])
A = Matrix([[1, 0], [1, 7]])
assert A._matrix_pow_by_jordan_blocks(S(3)) == A._eval_pow_by_recursion(3)
A = Matrix([[2]])
assert A**10 == Matrix([[2**10]]) == A._matrix_pow_by_jordan_blocks(S(10)) == \
A._eval_pow_by_recursion(10)
# testing a matrix that cannot be jordan blocked issue 11766
m = Matrix([[3, 0, 0, 0, -3], [0, -3, -3, 0, 3], [0, 3, 0, 3, 0], [0, 0, 3, 0, 3], [3, 0, 0, 3, 0]])
raises(MatrixError, lambda: m._matrix_pow_by_jordan_blocks(S(10)))
# test issue 11964
raises(MatrixError, lambda: Matrix([[1, 1], [3, 3]])._matrix_pow_by_jordan_blocks(S(-10)))
A = Matrix([[0, 1, 0], [0, 0, 1], [0, 0, 0]]) # Nilpotent jordan block size 3
assert A**10.0 == Matrix([[0, 0, 0], [0, 0, 0], [0, 0, 0]])
raises(ValueError, lambda: A**2.1)
raises(ValueError, lambda: A**Rational(3, 2))
A = Matrix([[8, 1], [3, 2]])
assert A**10.0 == Matrix([[1760744107, 272388050], [817164150, 126415807]])
A = Matrix([[0, 0, 1], [0, 0, 1], [0, 0, 1]]) # Nilpotent jordan block size 1
assert A**10.0 == Matrix([[0, 0, 1], [0, 0, 1], [0, 0, 1]])
A = Matrix([[0, 1, 0], [0, 0, 1], [0, 0, 1]]) # Nilpotent jordan block size 2
assert A**10.0 == Matrix([[0, 0, 1], [0, 0, 1], [0, 0, 1]])
n = Symbol('n', integer=True)
assert isinstance(A**n, MatPow)
n = Symbol('n', integer=True, negative=True)
raises(ValueError, lambda: A**n)
n = Symbol('n', integer=True, nonnegative=True)
assert A**n == Matrix([
[KroneckerDelta(0, n), KroneckerDelta(1, n), -KroneckerDelta(0, n) - KroneckerDelta(1, n) + 1],
[ 0, KroneckerDelta(0, n), 1 - KroneckerDelta(0, n)],
[ 0, 0, 1]])
assert A**(n + 2) == Matrix([[0, 0, 1], [0, 0, 1], [0, 0, 1]])
raises(ValueError, lambda: A**Rational(3, 2))
A = Matrix([[0, 0, 1], [3, 0, 1], [4, 3, 1]])
assert A**5.0 == Matrix([[168, 72, 89], [291, 144, 161], [572, 267, 329]])
assert A**5.0 == A**5
A = Matrix([[0, 1, 0],[-1, 0, 0],[0, 0, 0]])
n = Symbol("n")
An = A**n
assert An.subs(n, 2).doit() == A**2
raises(ValueError, lambda: An.subs(n, -2).doit())
assert An * An == A**(2*n)
# concretizing behavior for non-integer and complex powers
A = Matrix([[0,0,0],[0,0,0],[0,0,0]])
n = Symbol('n', integer=True, positive=True)
assert A**n == A
n = Symbol('n', integer=True, nonnegative=True)
assert A**n == diag(0**n, 0**n, 0**n)
assert (A**n).subs(n, 0) == eye(3)
assert (A**n).subs(n, 1) == zeros(3)
A = Matrix ([[2,0,0],[0,2,0],[0,0,2]])
assert A**2.1 == diag (2**2.1, 2**2.1, 2**2.1)
assert A**I == diag (2**I, 2**I, 2**I)
A = Matrix([[0, 1, 0], [0, 0, 1], [0, 0, 1]])
raises(ValueError, lambda: A**2.1)
raises(ValueError, lambda: A**I)
A = Matrix([[S.Half, S.Half], [S.Half, S.Half]])
assert A**S.Half == A
A = Matrix([[1, 1],[3, 3]])
assert A**S.Half == Matrix ([[S.Half, S.Half], [3*S.Half, 3*S.Half]])
def test_issue_17247_expression_blowup_1():
M = Matrix([[1+x, 1-x], [1-x, 1+x]])
assert M.exp().expand() == Matrix([
[ (exp(2*x) + exp(2))/2, (-exp(2*x) + exp(2))/2],
[(-exp(2*x) + exp(2))/2, (exp(2*x) + exp(2))/2]])
def test_issue_17247_expression_blowup_2():
M = Matrix([[1+x, 1-x], [1-x, 1+x]])
P, J = M.jordan_form ()
assert P*J*P.inv()
def test_issue_17247_expression_blowup_3():
M = Matrix([[1+x, 1-x], [1-x, 1+x]])
assert M**100 == Matrix([
[633825300114114700748351602688*x**100 + 633825300114114700748351602688, 633825300114114700748351602688 - 633825300114114700748351602688*x**100],
[633825300114114700748351602688 - 633825300114114700748351602688*x**100, 633825300114114700748351602688*x**100 + 633825300114114700748351602688]])
def test_issue_17247_expression_blowup_4():
# This matrix takes extremely long on current master even with intermediate simplification so an abbreviated version is used. It is left here for test in case of future optimizations.
# M = Matrix(S('''[
# [ -3/4, 45/32 - 37*I/16, 1/4 + I/2, -129/64 - 9*I/64, 1/4 - 5*I/16, 65/128 + 87*I/64, -9/32 - I/16, 183/256 - 97*I/128, 3/64 + 13*I/64, -23/32 - 59*I/256, 15/128 - 3*I/32, 19/256 + 551*I/1024],
# [-149/64 + 49*I/32, -177/128 - 1369*I/128, 125/64 + 87*I/64, -2063/256 + 541*I/128, 85/256 - 33*I/16, 805/128 + 2415*I/512, -219/128 + 115*I/256, 6301/4096 - 6609*I/1024, 119/128 + 143*I/128, -10879/2048 + 4343*I/4096, 129/256 - 549*I/512, 42533/16384 + 29103*I/8192],
# [ 1/2 - I, 9/4 + 55*I/16, -3/4, 45/32 - 37*I/16, 1/4 + I/2, -129/64 - 9*I/64, 1/4 - 5*I/16, 65/128 + 87*I/64, -9/32 - I/16, 183/256 - 97*I/128, 3/64 + 13*I/64, -23/32 - 59*I/256],
# [ -5/8 - 39*I/16, 2473/256 + 137*I/64, -149/64 + 49*I/32, -177/128 - 1369*I/128, 125/64 + 87*I/64, -2063/256 + 541*I/128, 85/256 - 33*I/16, 805/128 + 2415*I/512, -219/128 + 115*I/256, 6301/4096 - 6609*I/1024, 119/128 + 143*I/128, -10879/2048 + 4343*I/4096],
# [ 1 + I, -19/4 + 5*I/4, 1/2 - I, 9/4 + 55*I/16, -3/4, 45/32 - 37*I/16, 1/4 + I/2, -129/64 - 9*I/64, 1/4 - 5*I/16, 65/128 + 87*I/64, -9/32 - I/16, 183/256 - 97*I/128],
# [ 21/8 + I, -537/64 + 143*I/16, -5/8 - 39*I/16, 2473/256 + 137*I/64, -149/64 + 49*I/32, -177/128 - 1369*I/128, 125/64 + 87*I/64, -2063/256 + 541*I/128, 85/256 - 33*I/16, 805/128 + 2415*I/512, -219/128 + 115*I/256, 6301/4096 - 6609*I/1024],
# [ -2, 17/4 - 13*I/2, 1 + I, -19/4 + 5*I/4, 1/2 - I, 9/4 + 55*I/16, -3/4, 45/32 - 37*I/16, 1/4 + I/2, -129/64 - 9*I/64, 1/4 - 5*I/16, 65/128 + 87*I/64],
# [ 1/4 + 13*I/4, -825/64 - 147*I/32, 21/8 + I, -537/64 + 143*I/16, -5/8 - 39*I/16, 2473/256 + 137*I/64, -149/64 + 49*I/32, -177/128 - 1369*I/128, 125/64 + 87*I/64, -2063/256 + 541*I/128, 85/256 - 33*I/16, 805/128 + 2415*I/512],
# [ -4*I, 27/2 + 6*I, -2, 17/4 - 13*I/2, 1 + I, -19/4 + 5*I/4, 1/2 - I, 9/4 + 55*I/16, -3/4, 45/32 - 37*I/16, 1/4 + I/2, -129/64 - 9*I/64],
# [ 1/4 + 5*I/2, -23/8 - 57*I/16, 1/4 + 13*I/4, -825/64 - 147*I/32, 21/8 + I, -537/64 + 143*I/16, -5/8 - 39*I/16, 2473/256 + 137*I/64, -149/64 + 49*I/32, -177/128 - 1369*I/128, 125/64 + 87*I/64, -2063/256 + 541*I/128],
# [ -4, 9 - 5*I, -4*I, 27/2 + 6*I, -2, 17/4 - 13*I/2, 1 + I, -19/4 + 5*I/4, 1/2 - I, 9/4 + 55*I/16, -3/4, 45/32 - 37*I/16],
# [ -2*I, 119/8 + 29*I/4, 1/4 + 5*I/2, -23/8 - 57*I/16, 1/4 + 13*I/4, -825/64 - 147*I/32, 21/8 + I, -537/64 + 143*I/16, -5/8 - 39*I/16, 2473/256 + 137*I/64, -149/64 + 49*I/32, -177/128 - 1369*I/128]]'''))
# assert M**10 == Matrix([
# [ 7*(-221393644768594642173548179825793834595 - 1861633166167425978847110897013541127952*I)/9671406556917033397649408, 15*(31670992489131684885307005100073928751695 + 10329090958303458811115024718207404523808*I)/77371252455336267181195264, 7*(-3710978679372178839237291049477017392703 + 1377706064483132637295566581525806894169*I)/19342813113834066795298816, (9727707023582419994616144751727760051598 - 59261571067013123836477348473611225724433*I)/9671406556917033397649408, (31896723509506857062605551443641668183707 + 54643444538699269118869436271152084599580*I)/38685626227668133590597632, (-2024044860947539028275487595741003997397402 + 130959428791783397562960461903698670485863*I)/309485009821345068724781056, 3*(26190251453797590396533756519358368860907 - 27221191754180839338002754608545400941638*I)/77371252455336267181195264, (1154643595139959842768960128434994698330461 + 3385496216250226964322872072260446072295634*I)/618970019642690137449562112, 3*(-31849347263064464698310044805285774295286 - 11877437776464148281991240541742691164309*I)/77371252455336267181195264, (4661330392283532534549306589669150228040221 - 4171259766019818631067810706563064103956871*I)/1237940039285380274899124224, (9598353794289061833850770474812760144506 + 358027153990999990968244906482319780943983*I)/309485009821345068724781056, (-9755135335127734571547571921702373498554177 - 4837981372692695195747379349593041939686540*I)/2475880078570760549798248448],
# [(-379516731607474268954110071392894274962069 - 422272153179747548473724096872271700878296*I)/77371252455336267181195264, (41324748029613152354787280677832014263339501 - 12715121258662668420833935373453570749288074*I)/1237940039285380274899124224, (-339216903907423793947110742819264306542397 + 494174755147303922029979279454787373566517*I)/77371252455336267181195264, (-18121350839962855576667529908850640619878381 - 37413012454129786092962531597292531089199003*I)/1237940039285380274899124224, (2489661087330511608618880408199633556675926 + 1137821536550153872137379935240732287260863*I)/309485009821345068724781056, (-136644109701594123227587016790354220062972119 + 110130123468183660555391413889600443583585272*I)/4951760157141521099596496896, (1488043981274920070468141664150073426459593 - 9691968079933445130866371609614474474327650*I)/1237940039285380274899124224, 27*(4636797403026872518131756991410164760195942 + 3369103221138229204457272860484005850416533*I)/4951760157141521099596496896, (-8534279107365915284081669381642269800472363 + 2241118846262661434336333368511372725482742*I)/1237940039285380274899124224, (60923350128174260992536531692058086830950875 - 263673488093551053385865699805250505661590126*I)/9903520314283042199192993792, (18520943561240714459282253753348921824172569 + 24846649186468656345966986622110971925703604*I)/4951760157141521099596496896, (-232781130692604829085973604213529649638644431 + 35981505277760667933017117949103953338570617*I)/9903520314283042199192993792],
# [ (8742968295129404279528270438201520488950 + 3061473358639249112126847237482570858327*I)/4835703278458516698824704, (-245657313712011778432792959787098074935273 + 253113767861878869678042729088355086740856*I)/38685626227668133590597632, (1947031161734702327107371192008011621193 - 19462330079296259148177542369999791122762*I)/9671406556917033397649408, (552856485625209001527688949522750288619217 + 392928441196156725372494335248099016686580*I)/77371252455336267181195264, (-44542866621905323121630214897126343414629 + 3265340021421335059323962377647649632959*I)/19342813113834066795298816, (136272594005759723105646069956434264218730 - 330975364731707309489523680957584684763587*I)/38685626227668133590597632, (27392593965554149283318732469825168894401 + 75157071243800133880129376047131061115278*I)/38685626227668133590597632, 7*(-357821652913266734749960136017214096276154 - 45509144466378076475315751988405961498243*I)/309485009821345068724781056, (104485001373574280824835174390219397141149 - 99041000529599568255829489765415726168162*I)/77371252455336267181195264, (1198066993119982409323525798509037696321291 + 4249784165667887866939369628840569844519936*I)/618970019642690137449562112, (-114985392587849953209115599084503853611014 - 52510376847189529234864487459476242883449*I)/77371252455336267181195264, (6094620517051332877965959223269600650951573 - 4683469779240530439185019982269137976201163*I)/1237940039285380274899124224],
# [ (611292255597977285752123848828590587708323 - 216821743518546668382662964473055912169502*I)/77371252455336267181195264, (-1144023204575811464652692396337616594307487 + 12295317806312398617498029126807758490062855*I)/309485009821345068724781056, (-374093027769390002505693378578475235158281 - 573533923565898290299607461660384634333639*I)/77371252455336267181195264, (47405570632186659000138546955372796986832987 - 2837476058950808941605000274055970055096534*I)/1237940039285380274899124224, (-571573207393621076306216726219753090535121 + 533381457185823100878764749236639320783831*I)/77371252455336267181195264, (-7096548151856165056213543560958582513797519 - 24035731898756040059329175131592138642195366*I)/618970019642690137449562112, (2396762128833271142000266170154694033849225 + 1448501087375679588770230529017516492953051*I)/309485009821345068724781056, (-150609293845161968447166237242456473262037053 + 92581148080922977153207018003184520294188436*I)/4951760157141521099596496896, 5*(270278244730804315149356082977618054486347 - 1997830155222496880429743815321662710091562*I)/1237940039285380274899124224, (62978424789588828258068912690172109324360330 + 44803641177219298311493356929537007630129097*I)/2475880078570760549798248448, 19*(-451431106327656743945775812536216598712236 + 114924966793632084379437683991151177407937*I)/1237940039285380274899124224, (63417747628891221594106738815256002143915995 - 261508229397507037136324178612212080871150958*I)/9903520314283042199192993792],
# [ (-2144231934021288786200752920446633703357 + 2305614436009705803670842248131563850246*I)/1208925819614629174706176, (-90720949337459896266067589013987007078153 - 221951119475096403601562347412753844534569*I)/19342813113834066795298816, (11590973613116630788176337262688659880376 + 6514520676308992726483494976339330626159*I)/4835703278458516698824704, 3*(-131776217149000326618649542018343107657237 + 79095042939612668486212006406818285287004*I)/38685626227668133590597632, (10100577916793945997239221374025741184951 - 28631383488085522003281589065994018550748*I)/9671406556917033397649408, 67*(10090295594251078955008130473573667572549 + 10449901522697161049513326446427839676762*I)/77371252455336267181195264, (-54270981296988368730689531355811033930513 - 3413683117592637309471893510944045467443*I)/19342813113834066795298816, (440372322928679910536575560069973699181278 - 736603803202303189048085196176918214409081*I)/77371252455336267181195264, (33220374714789391132887731139763250155295 + 92055083048787219934030779066298919603554*I)/38685626227668133590597632, 5*(-594638554579967244348856981610805281527116 - 82309245323128933521987392165716076704057*I)/309485009821345068724781056, (128056368815300084550013708313312073721955 - 114619107488668120303579745393765245911404*I)/77371252455336267181195264, 21*(59839959255173222962789517794121843393573 + 241507883613676387255359616163487405826334*I)/618970019642690137449562112],
# [ (-13454485022325376674626653802541391955147 + 184471402121905621396582628515905949793486*I)/19342813113834066795298816, (-6158730123400322562149780662133074862437105 - 3416173052604643794120262081623703514107476*I)/154742504910672534362390528, (770558003844914708453618983120686116100419 - 127758381209767638635199674005029818518766*I)/77371252455336267181195264, (-4693005771813492267479835161596671660631703 + 12703585094750991389845384539501921531449948*I)/309485009821345068724781056, (-295028157441149027913545676461260860036601 - 841544569970643160358138082317324743450770*I)/77371252455336267181195264, (56716442796929448856312202561538574275502893 + 7216818824772560379753073185990186711454778*I)/1237940039285380274899124224, 15*(-87061038932753366532685677510172566368387 + 61306141156647596310941396434445461895538*I)/154742504910672534362390528, (-3455315109680781412178133042301025723909347 - 24969329563196972466388460746447646686670670*I)/618970019642690137449562112, (2453418854160886481106557323699250865361849 + 1497886802326243014471854112161398141242514*I)/309485009821345068724781056, (-151343224544252091980004429001205664193082173 + 90471883264187337053549090899816228846836628*I)/4951760157141521099596496896, (1652018205533026103358164026239417416432989 - 9959733619236515024261775397109724431400162*I)/1237940039285380274899124224, 3*(40676374242956907656984876692623172736522006 + 31023357083037817469535762230872667581366205*I)/4951760157141521099596496896],
# [ (-1226990509403328460274658603410696548387 - 4131739423109992672186585941938392788458*I)/1208925819614629174706176, (162392818524418973411975140074368079662703 + 23706194236915374831230612374344230400704*I)/9671406556917033397649408, (-3935678233089814180000602553655565621193 + 2283744757287145199688061892165659502483*I)/1208925819614629174706176, (-2400210250844254483454290806930306285131 - 315571356806370996069052930302295432758205*I)/19342813113834066795298816, (13365917938215281056563183751673390817910 + 15911483133819801118348625831132324863881*I)/4835703278458516698824704, 3*(-215950551370668982657516660700301003897855 + 51684341999223632631602864028309400489378*I)/38685626227668133590597632, (20886089946811765149439844691320027184765 - 30806277083146786592790625980769214361844*I)/9671406556917033397649408, (562180634592713285745940856221105667874855 + 1031543963988260765153550559766662245114916*I)/77371252455336267181195264, (-65820625814810177122941758625652476012867 - 12429918324787060890804395323920477537595*I)/19342813113834066795298816, (319147848192012911298771180196635859221089 - 402403304933906769233365689834404519960394*I)/38685626227668133590597632, (23035615120921026080284733394359587955057 + 115351677687031786114651452775242461310624*I)/38685626227668133590597632, (-3426830634881892756966440108592579264936130 - 1022954961164128745603407283836365128598559*I)/309485009821345068724781056],
# [ (-192574788060137531023716449082856117537757 - 69222967328876859586831013062387845780692*I)/19342813113834066795298816, (2736383768828013152914815341491629299773262 - 2773252698016291897599353862072533475408743*I)/77371252455336267181195264, (-23280005281223837717773057436155921656805 + 214784953368021840006305033048142888879224*I)/19342813113834066795298816, (-3035247484028969580570400133318947903462326 - 2195168903335435855621328554626336958674325*I)/77371252455336267181195264, (984552428291526892214541708637840971548653 - 64006622534521425620714598573494988589378*I)/77371252455336267181195264, (-3070650452470333005276715136041262898509903 + 7286424705750810474140953092161794621989080*I)/154742504910672534362390528, (-147848877109756404594659513386972921139270 - 416306113044186424749331418059456047650861*I)/38685626227668133590597632, (55272118474097814260289392337160619494260781 + 7494019668394781211907115583302403519488058*I)/1237940039285380274899124224, (-581537886583682322424771088996959213068864 + 542191617758465339135308203815256798407429*I)/77371252455336267181195264, (-6422548983676355789975736799494791970390991 - 23524183982209004826464749309156698827737702*I)/618970019642690137449562112, 7*(180747195387024536886923192475064903482083 + 84352527693562434817771649853047924991804*I)/154742504910672534362390528, (-135485179036717001055310712747643466592387031 + 102346575226653028836678855697782273460527608*I)/4951760157141521099596496896],
# [ (3384238362616083147067025892852431152105 + 156724444932584900214919898954874618256*I)/604462909807314587353088, (-59558300950677430189587207338385764871866 + 114427143574375271097298201388331237478857*I)/4835703278458516698824704, (-1356835789870635633517710130971800616227 - 7023484098542340388800213478357340875410*I)/1208925819614629174706176, (234884918567993750975181728413524549575881 + 79757294640629983786895695752733890213506*I)/9671406556917033397649408, (-7632732774935120473359202657160313866419 + 2905452608512927560554702228553291839465*I)/1208925819614629174706176, (52291747908702842344842889809762246649489 - 520996778817151392090736149644507525892649*I)/19342813113834066795298816, (17472406829219127839967951180375981717322 + 23464704213841582137898905375041819568669*I)/4835703278458516698824704, (-911026971811893092350229536132730760943307 + 150799318130900944080399439626714846752360*I)/38685626227668133590597632, (26234457233977042811089020440646443590687 - 45650293039576452023692126463683727692890*I)/9671406556917033397649408, 3*(288348388717468992528382586652654351121357 + 454526517721403048270274049572136109264668*I)/77371252455336267181195264, (-91583492367747094223295011999405657956347 - 12704691128268298435362255538069612411331*I)/19342813113834066795298816, (411208730251327843849027957710164064354221 - 569898526380691606955496789378230959965898*I)/38685626227668133590597632],
# [ (27127513117071487872628354831658811211795 - 37765296987901990355760582016892124833857*I)/4835703278458516698824704, (1741779916057680444272938534338833170625435 + 3083041729779495966997526404685535449810378*I)/77371252455336267181195264, 3*(-60642236251815783728374561836962709533401 - 24630301165439580049891518846174101510744*I)/19342813113834066795298816, 3*(445885207364591681637745678755008757483408 - 350948497734812895032502179455610024541643*I)/38685626227668133590597632, (-47373295621391195484367368282471381775684 + 219122969294089357477027867028071400054973*I)/19342813113834066795298816, (-2801565819673198722993348253876353741520438 - 2250142129822658548391697042460298703335701*I)/77371252455336267181195264, (801448252275607253266997552356128790317119 - 50890367688077858227059515894356594900558*I)/77371252455336267181195264, (-5082187758525931944557763799137987573501207 + 11610432359082071866576699236013484487676124*I)/309485009821345068724781056, (-328925127096560623794883760398247685166830 - 643447969697471610060622160899409680422019*I)/77371252455336267181195264, 15*(2954944669454003684028194956846659916299765 + 33434406416888505837444969347824812608566*I)/1237940039285380274899124224, (-415749104352001509942256567958449835766827 + 479330966144175743357171151440020955412219*I)/77371252455336267181195264, 3*(-4639987285852134369449873547637372282914255 - 11994411888966030153196659207284951579243273*I)/1237940039285380274899124224],
# [ (-478846096206269117345024348666145495601 + 1249092488629201351470551186322814883283*I)/302231454903657293676544, (-17749319421930878799354766626365926894989 - 18264580106418628161818752318217357231971*I)/1208925819614629174706176, (2801110795431528876849623279389579072819 + 363258850073786330770713557775566973248*I)/604462909807314587353088, (-59053496693129013745775512127095650616252 + 78143588734197260279248498898321500167517*I)/4835703278458516698824704, (-283186724922498212468162690097101115349 - 6443437753863179883794497936345437398276*I)/1208925819614629174706176, (188799118826748909206887165661384998787543 + 84274736720556630026311383931055307398820*I)/9671406556917033397649408, (-5482217151670072904078758141270295025989 + 1818284338672191024475557065444481298568*I)/1208925819614629174706176, (56564463395350195513805521309731217952281 - 360208541416798112109946262159695452898431*I)/19342813113834066795298816, 11*(1259539805728870739006416869463689438068 + 1409136581547898074455004171305324917387*I)/4835703278458516698824704, 5*(-123701190701414554945251071190688818343325 + 30997157322590424677294553832111902279712*I)/38685626227668133590597632, (16130917381301373033736295883982414239781 - 32752041297570919727145380131926943374516*I)/9671406556917033397649408, (650301385108223834347093740500375498354925 + 899526407681131828596801223402866051809258*I)/77371252455336267181195264],
# [ (9011388245256140876590294262420614839483 + 8167917972423946282513000869327525382672*I)/1208925819614629174706176, (-426393174084720190126376382194036323028924 + 180692224825757525982858693158209545430621*I)/9671406556917033397649408, (24588556702197802674765733448108154175535 - 45091766022876486566421953254051868331066*I)/4835703278458516698824704, (1872113939365285277373877183750416985089691 + 3030392393733212574744122057679633775773130*I)/77371252455336267181195264, (-222173405538046189185754954524429864167549 - 75193157893478637039381059488387511299116*I)/19342813113834066795298816, (2670821320766222522963689317316937579844558 - 2645837121493554383087981511645435472169191*I)/77371252455336267181195264, 5*(-2100110309556476773796963197283876204940 + 41957457246479840487980315496957337371937*I)/19342813113834066795298816, (-5733743755499084165382383818991531258980593 - 3328949988392698205198574824396695027195732*I)/154742504910672534362390528, (707827994365259025461378911159398206329247 - 265730616623227695108042528694302299777294*I)/77371252455336267181195264, (-1442501604682933002895864804409322823788319 + 11504137805563265043376405214378288793343879*I)/309485009821345068724781056, (-56130472299445561499538726459719629522285 - 61117552419727805035810982426639329818864*I)/9671406556917033397649408, (39053692321126079849054272431599539429908717 - 10209127700342570953247177602860848130710666*I)/1237940039285380274899124224]])
M = Matrix(S('''[
[ -3/4, 45/32 - 37*I/16, 1/4 + I/2, -129/64 - 9*I/64, 1/4 - 5*I/16, 65/128 + 87*I/64],
[-149/64 + 49*I/32, -177/128 - 1369*I/128, 125/64 + 87*I/64, -2063/256 + 541*I/128, 85/256 - 33*I/16, 805/128 + 2415*I/512],
[ 1/2 - I, 9/4 + 55*I/16, -3/4, 45/32 - 37*I/16, 1/4 + I/2, -129/64 - 9*I/64],
[ -5/8 - 39*I/16, 2473/256 + 137*I/64, -149/64 + 49*I/32, -177/128 - 1369*I/128, 125/64 + 87*I/64, -2063/256 + 541*I/128],
[ 1 + I, -19/4 + 5*I/4, 1/2 - I, 9/4 + 55*I/16, -3/4, 45/32 - 37*I/16],
[ 21/8 + I, -537/64 + 143*I/16, -5/8 - 39*I/16, 2473/256 + 137*I/64, -149/64 + 49*I/32, -177/128 - 1369*I/128]]'''))
assert M**10 == Matrix(S('''[
[ 7369525394972778926719607798014571861/604462909807314587353088 - 229284202061790301477392339912557559*I/151115727451828646838272, -19704281515163975949388435612632058035/1208925819614629174706176 + 14319858347987648723768698170712102887*I/302231454903657293676544, -3623281909451783042932142262164941211/604462909807314587353088 - 6039240602494288615094338643452320495*I/604462909807314587353088, 109260497799140408739847239685705357695/2417851639229258349412352 - 7427566006564572463236368211555511431*I/2417851639229258349412352, -16095803767674394244695716092817006641/2417851639229258349412352 + 10336681897356760057393429626719177583*I/1208925819614629174706176, -42207883340488041844332828574359769743/2417851639229258349412352 - 182332262671671273188016400290188468499*I/4835703278458516698824704],
[50566491050825573392726324995779608259/1208925819614629174706176 - 90047007594468146222002432884052362145*I/2417851639229258349412352, 74273703462900000967697427843983822011/1208925819614629174706176 + 265947522682943571171988741842776095421*I/1208925819614629174706176, -116900341394390200556829767923360888429/2417851639229258349412352 - 53153263356679268823910621474478756845*I/2417851639229258349412352, 195407378023867871243426523048612490249/1208925819614629174706176 - 1242417915995360200584837585002906728929*I/9671406556917033397649408, -863597594389821970177319682495878193/302231454903657293676544 + 476936100741548328800725360758734300481*I/9671406556917033397649408, -3154451590535653853562472176601754835575/19342813113834066795298816 - 232909875490506237386836489998407329215*I/2417851639229258349412352],
[ -1715444997702484578716037230949868543/302231454903657293676544 + 5009695651321306866158517287924120777*I/302231454903657293676544, -30551582497996879620371947949342101301/604462909807314587353088 - 7632518367986526187139161303331519629*I/151115727451828646838272, 312680739924495153190604170938220575/18889465931478580854784 - 108664334509328818765959789219208459*I/75557863725914323419136, -14693696966703036206178521686918865509/604462909807314587353088 + 72345386220900843930147151999899692401*I/1208925819614629174706176, -8218872496728882299722894680635296519/1208925819614629174706176 - 16776782833358893712645864791807664983*I/1208925819614629174706176, 143237839169380078671242929143670635137/2417851639229258349412352 + 2883817094806115974748882735218469447*I/2417851639229258349412352],
[ 3087979417831061365023111800749855987/151115727451828646838272 + 34441942370802869368851419102423997089*I/604462909807314587353088, -148309181940158040917731426845476175667/604462909807314587353088 - 263987151804109387844966835369350904919*I/9671406556917033397649408, 50259518594816377378747711930008883165/1208925819614629174706176 - 95713974916869240305450001443767979653*I/2417851639229258349412352, 153466447023875527996457943521467271119/2417851639229258349412352 + 517285524891117105834922278517084871349*I/2417851639229258349412352, -29184653615412989036678939366291205575/604462909807314587353088 - 27551322282526322041080173287022121083*I/1208925819614629174706176, 196404220110085511863671393922447671649/1208925819614629174706176 - 1204712019400186021982272049902206202145*I/9671406556917033397649408],
[ -2632581805949645784625606590600098779/151115727451828646838272 - 589957435912868015140272627522612771*I/37778931862957161709568, 26727850893953715274702844733506310247/302231454903657293676544 - 10825791956782128799168209600694020481*I/302231454903657293676544, -1036348763702366164044671908440791295/151115727451828646838272 + 3188624571414467767868303105288107375*I/151115727451828646838272, -36814959939970644875593411585393242449/604462909807314587353088 - 18457555789119782404850043842902832647*I/302231454903657293676544, 12454491297984637815063964572803058647/604462909807314587353088 - 340489532842249733975074349495329171*I/302231454903657293676544, -19547211751145597258386735573258916681/604462909807314587353088 + 87299583775782199663414539883938008933*I/1208925819614629174706176],
[ -40281994229560039213253423262678393183/604462909807314587353088 - 2939986850065527327299273003299736641*I/604462909807314587353088, 331940684638052085845743020267462794181/2417851639229258349412352 - 284574901963624403933361315517248458969*I/1208925819614629174706176, 6453843623051745485064693628073010961/302231454903657293676544 + 36062454107479732681350914931391590957*I/604462909807314587353088, -147665869053634695632880753646441962067/604462909807314587353088 - 305987938660447291246597544085345123927*I/9671406556917033397649408, 107821369195275772166593879711259469423/2417851639229258349412352 - 11645185518211204108659001435013326687*I/302231454903657293676544, 64121228424717666402009446088588091619/1208925819614629174706176 + 265557133337095047883844369272389762133*I/1208925819614629174706176]]'''))
def test_issue_17247_expression_blowup_5():
M = Matrix(6, 6, lambda i, j: 1 + (-1)**(i+j)*I)
assert M.charpoly('x') == PurePoly(x**6 + (-6 - 6*I)*x**5 + 36*I*x**4, x, domain='EX')
def test_issue_17247_expression_blowup_6():
M = Matrix(8, 8, [x+i for i in range (64)])
assert M.det('bareiss') == 0
def test_issue_17247_expression_blowup_7():
M = Matrix(6, 6, lambda i, j: 1 + (-1)**(i+j)*I)
assert M.det('berkowitz') == 0
@XFAIL # dotprodsimp is not on by default in this function
def test_issue_17247_expression_blowup_8():
M = Matrix(8, 8, [x+i for i in range (64)])
assert M.det('lu') == 0
def test_issue_17247_expression_blowup_9():
M = Matrix(8, 8, [x+i for i in range (64)])
assert M.rref() == (Matrix([
[1, 0, -1, -2, -3, -4, -5, -6],
[0, 1, 2, 3, 4, 5, 6, 7],
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0]]), (0, 1))
def test_issue_17247_expression_blowup_10():
M = Matrix(6, 6, lambda i, j: 1 + (-1)**(i+j)*I)
assert M.cofactor(0, 0) == 0
def test_issue_17247_expression_blowup_11():
M = Matrix(6, 6, lambda i, j: 1 + (-1)**(i+j)*I)
assert M.cofactor_matrix() == Matrix(6, 6, [0]*36)
def test_issue_17247_expression_blowup_12():
M = Matrix(6, 6, lambda i, j: 1 + (-1)**(i+j)*I)
assert M.eigenvals() == {6: 1, 6*I: 1, 0: 4}
def test_issue_17247_expression_blowup_13():
M = Matrix([
[ 0, 1 - x, x + 1, 1 - x],
[1 - x, x + 1, 0, x + 1],
[ 0, 1 - x, x + 1, 1 - x],
[ 0, 0, 1 - x, 0]])
ev = M.eigenvects()
assert ev[0][:2] == (0, 2)
assert ev[0][2][0] == Matrix([[0],[-1],[0],[1]])
assert ev[1][:2] == (x - sqrt(2)*(x - 1) + 1, 1)
assert (ev[1][2][0] - Matrix([
[-(-17*x**4 + 12*sqrt(2)*x**4 - 4*sqrt(2)*x**3 + 6*x**3 - 6*x - 4*sqrt(2)*x + 12*sqrt(2) + 17)/(-7*x**4 + 5*sqrt(2)*x**4 - 6*sqrt(2)*x**3 + 8*x**3 - 2*x**2 + 8*x + 6*sqrt(2)*x - 5*sqrt(2) - 7)],
[ (-7*x**3 + 5*sqrt(2)*x**3 - x**2 + sqrt(2)*x**2 - sqrt(2)*x - x - 5*sqrt(2) - 7)/(-3*x**3 + 2*sqrt(2)*x**3 - 2*sqrt(2)*x**2 + 3*x**2 + 2*sqrt(2)*x + 3*x - 3 - 2*sqrt(2))],
[ -(-3*x**2 + 2*sqrt(2)*x**2 + 2*x - 3 - 2*sqrt(2))/(-x**2 + sqrt(2)*x**2 - 2*sqrt(2)*x + 1 + sqrt(2))],
[ 1]])).expand() == Matrix([[0],[0],[0],[0]])
assert ev[2][:2] == (x + sqrt(2)*(x - 1) + 1, 1)
assert (ev[2][2][0] - Matrix([
[-(12*sqrt(2)*x**4 + 17*x**4 - 6*x**3 - 4*sqrt(2)*x**3 - 4*sqrt(2)*x + 6*x - 17 + 12*sqrt(2))/(7*x**4 + 5*sqrt(2)*x**4 - 6*sqrt(2)*x**3 - 8*x**3 + 2*x**2 - 8*x + 6*sqrt(2)*x - 5*sqrt(2) + 7)],
[ (7*x**3 + 5*sqrt(2)*x**3 + x**2 + sqrt(2)*x**2 - sqrt(2)*x + x - 5*sqrt(2) + 7)/(2*sqrt(2)*x**3 + 3*x**3 - 3*x**2 - 2*sqrt(2)*x**2 - 3*x + 2*sqrt(2)*x - 2*sqrt(2) + 3)],
[ -(2*sqrt(2)*x**2 + 3*x**2 - 2*x - 2*sqrt(2) + 3)/(x**2 + sqrt(2)*x**2 - 2*sqrt(2)*x - 1 + sqrt(2))],
[ 1]])).expand() == Matrix([[0],[0],[0],[0]])
def test_issue_17247_expression_blowup_14():
M = Matrix(8, 8, ([1+x, 1-x]*4 + [1-x, 1+x]*4)*4)
assert M.echelon_form() == Matrix([
[x + 1, 1 - x, x + 1, 1 - x, x + 1, 1 - x, x + 1, 1 - x],
[ 0, 4*x, 0, 4*x, 0, 4*x, 0, 4*x],
[ 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0]])
def test_issue_17247_expression_blowup_15():
M = Matrix(8, 8, ([1+x, 1-x]*4 + [1-x, 1+x]*4)*4)
assert M.rowspace() == [Matrix([[x + 1, 1 - x, x + 1, 1 - x, x + 1, 1 - x, x + 1, 1 - x]]), Matrix([[0, 4*x, 0, 4*x, 0, 4*x, 0, 4*x]])]
def test_issue_17247_expression_blowup_16():
M = Matrix(8, 8, ([1+x, 1-x]*4 + [1-x, 1+x]*4)*4)
assert M.columnspace() == [Matrix([[x + 1],[1 - x],[x + 1],[1 - x],[x + 1],[1 - x],[x + 1],[1 - x]]), Matrix([[1 - x],[x + 1],[1 - x],[x + 1],[1 - x],[x + 1],[1 - x],[x + 1]])]
def test_issue_17247_expression_blowup_17():
M = Matrix(8, 8, [x+i for i in range (64)])
assert M.nullspace() == [
Matrix([[1],[-2],[1],[0],[0],[0],[0],[0]]),
Matrix([[2],[-3],[0],[1],[0],[0],[0],[0]]),
Matrix([[3],[-4],[0],[0],[1],[0],[0],[0]]),
Matrix([[4],[-5],[0],[0],[0],[1],[0],[0]]),
Matrix([[5],[-6],[0],[0],[0],[0],[1],[0]]),
Matrix([[6],[-7],[0],[0],[0],[0],[0],[1]])]
def test_issue_17247_expression_blowup_18():
M = Matrix(6, 6, ([1+x, 1-x]*3 + [1-x, 1+x]*3)*3)
assert not M.is_nilpotent()
def test_issue_17247_expression_blowup_19():
M = Matrix(S('''[
[ -3/4, 0, 1/4 + I/2, 0],
[ 0, -177/128 - 1369*I/128, 0, -2063/256 + 541*I/128],
[ 1/2 - I, 0, 0, 0],
[ 0, 0, 0, -177/128 - 1369*I/128]]'''))
assert not M.is_diagonalizable()
def test_issue_17247_expression_blowup_20():
M = Matrix([
[x + 1, 1 - x, 0, 0],
[1 - x, x + 1, 0, x + 1],
[ 0, 1 - x, x + 1, 0],
[ 0, 0, 0, x + 1]])
assert M.diagonalize() == (Matrix([
[1, 1, 0, (x + 1)/(x - 1)],
[1, -1, 0, 0],
[1, 1, 1, 0],
[0, 0, 0, 1]]),
Matrix([
[2, 0, 0, 0],
[0, 2*x, 0, 0],
[0, 0, x + 1, 0],
[0, 0, 0, x + 1]]))
def test_issue_17247_expression_blowup_21():
M = Matrix(S('''[
[ -3/4, 45/32 - 37*I/16, 0, 0],
[-149/64 + 49*I/32, -177/128 - 1369*I/128, 0, -2063/256 + 541*I/128],
[ 0, 9/4 + 55*I/16, 2473/256 + 137*I/64, 0],
[ 0, 0, 0, -177/128 - 1369*I/128]]'''))
assert M.inv(method='GE') == Matrix(S('''[
[-26194832/3470993 - 31733264*I/3470993, 156352/3470993 + 10325632*I/3470993, 0, -7741283181072/3306971225785 + 2999007604624*I/3306971225785],
[4408224/3470993 - 9675328*I/3470993, -2422272/3470993 + 1523712*I/3470993, 0, -1824666489984/3306971225785 - 1401091949952*I/3306971225785],
[-26406945676288/22270005630769 + 10245925485056*I/22270005630769, 7453523312640/22270005630769 + 1601616519168*I/22270005630769, 633088/6416033 - 140288*I/6416033, 872209227109521408/21217636514687010905 + 6066405081802389504*I/21217636514687010905],
[0, 0, 0, -11328/952745 + 87616*I/952745]]'''))
@XFAIL # dotprodsimp is not on by default in this function
def test_issue_17247_expression_blowup_22():
M = Matrix(S('''[
[ -3/4, 45/32 - 37*I/16, 0, 0],
[-149/64 + 49*I/32, -177/128 - 1369*I/128, 0, -2063/256 + 541*I/128],
[ 0, 9/4 + 55*I/16, 2473/256 + 137*I/64, 0],
[ 0, 0, 0, -177/128 - 1369*I/128]]'''))
assert M.inv(method='LU') == Matrix(S('''[
[-26194832/3470993 - 31733264*I/3470993, 156352/3470993 + 10325632*I/3470993, 0, -7741283181072/3306971225785 + 2999007604624*I/3306971225785],
[4408224/3470993 - 9675328*I/3470993, -2422272/3470993 + 1523712*I/3470993, 0, -1824666489984/3306971225785 - 1401091949952*I/3306971225785],
[-26406945676288/22270005630769 + 10245925485056*I/22270005630769, 7453523312640/22270005630769 + 1601616519168*I/22270005630769, 633088/6416033 - 140288*I/6416033, 872209227109521408/21217636514687010905 + 6066405081802389504*I/21217636514687010905],
[0, 0, 0, -11328/952745 + 87616*I/952745]]'''))
def test_issue_17247_expression_blowup_23():
M = Matrix(S('''[
[ -3/4, 45/32 - 37*I/16, 0, 0],
[-149/64 + 49*I/32, -177/128 - 1369*I/128, 0, -2063/256 + 541*I/128],
[ 0, 9/4 + 55*I/16, 2473/256 + 137*I/64, 0],
[ 0, 0, 0, -177/128 - 1369*I/128]]'''))
assert M.inv(method='ADJ').expand() == Matrix(S('''[
[-26194832/3470993 - 31733264*I/3470993, 156352/3470993 + 10325632*I/3470993, 0, -7741283181072/3306971225785 + 2999007604624*I/3306971225785],
[4408224/3470993 - 9675328*I/3470993, -2422272/3470993 + 1523712*I/3470993, 0, -1824666489984/3306971225785 - 1401091949952*I/3306971225785],
[-26406945676288/22270005630769 + 10245925485056*I/22270005630769, 7453523312640/22270005630769 + 1601616519168*I/22270005630769, 633088/6416033 - 140288*I/6416033, 872209227109521408/21217636514687010905 + 6066405081802389504*I/21217636514687010905],
[0, 0, 0, -11328/952745 + 87616*I/952745]]'''))
@XFAIL # dotprodsimp is not on by default in this function
def test_issue_17247_expression_blowup_24():
M = SparseMatrix(S('''[
[ -3/4, 45/32 - 37*I/16, 0, 0],
[-149/64 + 49*I/32, -177/128 - 1369*I/128, 0, -2063/256 + 541*I/128],
[ 0, 9/4 + 55*I/16, 2473/256 + 137*I/64, 0],
[ 0, 0, 0, -177/128 - 1369*I/128]]'''))
assert M.inv(method='CH') == Matrix(S('''[
[-26194832/3470993 - 31733264*I/3470993, 156352/3470993 + 10325632*I/3470993, 0, -7741283181072/3306971225785 + 2999007604624*I/3306971225785],
[4408224/3470993 - 9675328*I/3470993, -2422272/3470993 + 1523712*I/3470993, 0, -1824666489984/3306971225785 - 1401091949952*I/3306971225785],
[-26406945676288/22270005630769 + 10245925485056*I/22270005630769, 7453523312640/22270005630769 + 1601616519168*I/22270005630769, 633088/6416033 - 140288*I/6416033, 872209227109521408/21217636514687010905 + 6066405081802389504*I/21217636514687010905],
[0, 0, 0, -11328/952745 + 87616*I/952745]]'''))
@XFAIL # dotprodsimp is not on by default in this function
def test_issue_17247_expression_blowup_25():
M = SparseMatrix(S('''[
[ -3/4, 45/32 - 37*I/16, 0, 0],
[-149/64 + 49*I/32, -177/128 - 1369*I/128, 0, -2063/256 + 541*I/128],
[ 0, 9/4 + 55*I/16, 2473/256 + 137*I/64, 0],
[ 0, 0, 0, -177/128 - 1369*I/128]]'''))
assert M.inv(method='LDL') == Matrix(S('''[
[-26194832/3470993 - 31733264*I/3470993, 156352/3470993 + 10325632*I/3470993, 0, -7741283181072/3306971225785 + 2999007604624*I/3306971225785],
[4408224/3470993 - 9675328*I/3470993, -2422272/3470993 + 1523712*I/3470993, 0, -1824666489984/3306971225785 - 1401091949952*I/3306971225785],
[-26406945676288/22270005630769 + 10245925485056*I/22270005630769, 7453523312640/22270005630769 + 1601616519168*I/22270005630769, 633088/6416033 - 140288*I/6416033, 872209227109521408/21217636514687010905 + 6066405081802389504*I/21217636514687010905],
[0, 0, 0, -11328/952745 + 87616*I/952745]]'''))
def test_issue_17247_expression_blowup_26():
M = Matrix(S('''[
[ -3/4, 45/32 - 37*I/16, 1/4 + I/2, -129/64 - 9*I/64, 1/4 - 5*I/16, 65/128 + 87*I/64, -9/32 - I/16, 183/256 - 97*I/128],
[-149/64 + 49*I/32, -177/128 - 1369*I/128, 125/64 + 87*I/64, -2063/256 + 541*I/128, 85/256 - 33*I/16, 805/128 + 2415*I/512, -219/128 + 115*I/256, 6301/4096 - 6609*I/1024],
[ 1/2 - I, 9/4 + 55*I/16, -3/4, 45/32 - 37*I/16, 1/4 + I/2, -129/64 - 9*I/64, 1/4 - 5*I/16, 65/128 + 87*I/64],
[ -5/8 - 39*I/16, 2473/256 + 137*I/64, -149/64 + 49*I/32, -177/128 - 1369*I/128, 125/64 + 87*I/64, -2063/256 + 541*I/128, 85/256 - 33*I/16, 805/128 + 2415*I/512],
[ 1 + I, -19/4 + 5*I/4, 1/2 - I, 9/4 + 55*I/16, -3/4, 45/32 - 37*I/16, 1/4 + I/2, -129/64 - 9*I/64],
[ 21/8 + I, -537/64 + 143*I/16, -5/8 - 39*I/16, 2473/256 + 137*I/64, -149/64 + 49*I/32, -177/128 - 1369*I/128, 125/64 + 87*I/64, -2063/256 + 541*I/128],
[ -2, 17/4 - 13*I/2, 1 + I, -19/4 + 5*I/4, 1/2 - I, 9/4 + 55*I/16, -3/4, 45/32 - 37*I/16],
[ 1/4 + 13*I/4, -825/64 - 147*I/32, 21/8 + I, -537/64 + 143*I/16, -5/8 - 39*I/16, 2473/256 + 137*I/64, -149/64 + 49*I/32, -177/128 - 1369*I/128]]'''))
assert M.rank() == 4
def test_issue_17247_expression_blowup_27():
M = Matrix([
[ 0, 1 - x, x + 1, 1 - x],
[1 - x, x + 1, 0, x + 1],
[ 0, 1 - x, x + 1, 1 - x],
[ 0, 0, 1 - x, 0]])
P, J = M.jordan_form()
assert P.expand() == Matrix(S('''[
[ 0, 4*x/(x**2 - 2*x + 1), -(-17*x**4 + 12*sqrt(2)*x**4 - 4*sqrt(2)*x**3 + 6*x**3 - 6*x - 4*sqrt(2)*x + 12*sqrt(2) + 17)/(-7*x**4 + 5*sqrt(2)*x**4 - 6*sqrt(2)*x**3 + 8*x**3 - 2*x**2 + 8*x + 6*sqrt(2)*x - 5*sqrt(2) - 7), -(12*sqrt(2)*x**4 + 17*x**4 - 6*x**3 - 4*sqrt(2)*x**3 - 4*sqrt(2)*x + 6*x - 17 + 12*sqrt(2))/(7*x**4 + 5*sqrt(2)*x**4 - 6*sqrt(2)*x**3 - 8*x**3 + 2*x**2 - 8*x + 6*sqrt(2)*x - 5*sqrt(2) + 7)],
[x - 1, x/(x - 1) + 1/(x - 1), (-7*x**3 + 5*sqrt(2)*x**3 - x**2 + sqrt(2)*x**2 - sqrt(2)*x - x - 5*sqrt(2) - 7)/(-3*x**3 + 2*sqrt(2)*x**3 - 2*sqrt(2)*x**2 + 3*x**2 + 2*sqrt(2)*x + 3*x - 3 - 2*sqrt(2)), (7*x**3 + 5*sqrt(2)*x**3 + x**2 + sqrt(2)*x**2 - sqrt(2)*x + x - 5*sqrt(2) + 7)/(2*sqrt(2)*x**3 + 3*x**3 - 3*x**2 - 2*sqrt(2)*x**2 - 3*x + 2*sqrt(2)*x - 2*sqrt(2) + 3)],
[ 0, 1, -(-3*x**2 + 2*sqrt(2)*x**2 + 2*x - 3 - 2*sqrt(2))/(-x**2 + sqrt(2)*x**2 - 2*sqrt(2)*x + 1 + sqrt(2)), -(2*sqrt(2)*x**2 + 3*x**2 - 2*x - 2*sqrt(2) + 3)/(x**2 + sqrt(2)*x**2 - 2*sqrt(2)*x - 1 + sqrt(2))],
[1 - x, 0, 1, 1]]''')).expand()
assert J == Matrix(S('''[
[0, 1, 0, 0],
[0, 0, 0, 0],
[0, 0, x - sqrt(2)*(x - 1) + 1, 0],
[0, 0, 0, x + sqrt(2)*(x - 1) + 1]]'''))
def test_issue_17247_expression_blowup_28():
M = Matrix(S('''[
[ -3/4, 45/32 - 37*I/16, 0, 0],
[-149/64 + 49*I/32, -177/128 - 1369*I/128, 0, -2063/256 + 541*I/128],
[ 0, 9/4 + 55*I/16, 2473/256 + 137*I/64, 0],
[ 0, 0, 0, -177/128 - 1369*I/128]]'''))
assert M.singular_values() == S('''[
sqrt(14609315/131072 + sqrt(64789115132571/2147483648 - 2*(25895222463957462655758224991455280215303/633825300114114700748351602688 + sqrt(1213909058710955930446995195883114969038524625997915131236390724543989220134670)*I/22282920707136844948184236032)**(1/3) + 76627253330829751075/(35184372088832*sqrt(64789115132571/4294967296 + 3546944054712886603889144627/(110680464442257309696*(25895222463957462655758224991455280215303/633825300114114700748351602688 + sqrt(1213909058710955930446995195883114969038524625997915131236390724543989220134670)*I/22282920707136844948184236032)**(1/3)) + 2*(25895222463957462655758224991455280215303/633825300114114700748351602688 + sqrt(1213909058710955930446995195883114969038524625997915131236390724543989220134670)*I/22282920707136844948184236032)**(1/3))) - 3546944054712886603889144627/(110680464442257309696*(25895222463957462655758224991455280215303/633825300114114700748351602688 + sqrt(1213909058710955930446995195883114969038524625997915131236390724543989220134670)*I/22282920707136844948184236032)**(1/3)))/2 + sqrt(64789115132571/4294967296 + 3546944054712886603889144627/(110680464442257309696*(25895222463957462655758224991455280215303/633825300114114700748351602688 + sqrt(1213909058710955930446995195883114969038524625997915131236390724543989220134670)*I/22282920707136844948184236032)**(1/3)) + 2*(25895222463957462655758224991455280215303/633825300114114700748351602688 + sqrt(1213909058710955930446995195883114969038524625997915131236390724543989220134670)*I/22282920707136844948184236032)**(1/3))/2),
sqrt(14609315/131072 - sqrt(64789115132571/2147483648 - 2*(25895222463957462655758224991455280215303/633825300114114700748351602688 + sqrt(1213909058710955930446995195883114969038524625997915131236390724543989220134670)*I/22282920707136844948184236032)**(1/3) + 76627253330829751075/(35184372088832*sqrt(64789115132571/4294967296 + 3546944054712886603889144627/(110680464442257309696*(25895222463957462655758224991455280215303/633825300114114700748351602688 + sqrt(1213909058710955930446995195883114969038524625997915131236390724543989220134670)*I/22282920707136844948184236032)**(1/3)) + 2*(25895222463957462655758224991455280215303/633825300114114700748351602688 + sqrt(1213909058710955930446995195883114969038524625997915131236390724543989220134670)*I/22282920707136844948184236032)**(1/3))) - 3546944054712886603889144627/(110680464442257309696*(25895222463957462655758224991455280215303/633825300114114700748351602688 + sqrt(1213909058710955930446995195883114969038524625997915131236390724543989220134670)*I/22282920707136844948184236032)**(1/3)))/2 + sqrt(64789115132571/4294967296 + 3546944054712886603889144627/(110680464442257309696*(25895222463957462655758224991455280215303/633825300114114700748351602688 + sqrt(1213909058710955930446995195883114969038524625997915131236390724543989220134670)*I/22282920707136844948184236032)**(1/3)) + 2*(25895222463957462655758224991455280215303/633825300114114700748351602688 + sqrt(1213909058710955930446995195883114969038524625997915131236390724543989220134670)*I/22282920707136844948184236032)**(1/3))/2),
sqrt(14609315/131072 - sqrt(64789115132571/4294967296 + 3546944054712886603889144627/(110680464442257309696*(25895222463957462655758224991455280215303/633825300114114700748351602688 + sqrt(1213909058710955930446995195883114969038524625997915131236390724543989220134670)*I/22282920707136844948184236032)**(1/3)) + 2*(25895222463957462655758224991455280215303/633825300114114700748351602688 + sqrt(1213909058710955930446995195883114969038524625997915131236390724543989220134670)*I/22282920707136844948184236032)**(1/3))/2 + sqrt(64789115132571/2147483648 - 2*(25895222463957462655758224991455280215303/633825300114114700748351602688 + sqrt(1213909058710955930446995195883114969038524625997915131236390724543989220134670)*I/22282920707136844948184236032)**(1/3) - 76627253330829751075/(35184372088832*sqrt(64789115132571/4294967296 + 3546944054712886603889144627/(110680464442257309696*(25895222463957462655758224991455280215303/633825300114114700748351602688 + sqrt(1213909058710955930446995195883114969038524625997915131236390724543989220134670)*I/22282920707136844948184236032)**(1/3)) + 2*(25895222463957462655758224991455280215303/633825300114114700748351602688 + sqrt(1213909058710955930446995195883114969038524625997915131236390724543989220134670)*I/22282920707136844948184236032)**(1/3))) - 3546944054712886603889144627/(110680464442257309696*(25895222463957462655758224991455280215303/633825300114114700748351602688 + sqrt(1213909058710955930446995195883114969038524625997915131236390724543989220134670)*I/22282920707136844948184236032)**(1/3)))/2),
sqrt(14609315/131072 - sqrt(64789115132571/4294967296 + 3546944054712886603889144627/(110680464442257309696*(25895222463957462655758224991455280215303/633825300114114700748351602688 + sqrt(1213909058710955930446995195883114969038524625997915131236390724543989220134670)*I/22282920707136844948184236032)**(1/3)) + 2*(25895222463957462655758224991455280215303/633825300114114700748351602688 + sqrt(1213909058710955930446995195883114969038524625997915131236390724543989220134670)*I/22282920707136844948184236032)**(1/3))/2 - sqrt(64789115132571/2147483648 - 2*(25895222463957462655758224991455280215303/633825300114114700748351602688 + sqrt(1213909058710955930446995195883114969038524625997915131236390724543989220134670)*I/22282920707136844948184236032)**(1/3) - 76627253330829751075/(35184372088832*sqrt(64789115132571/4294967296 + 3546944054712886603889144627/(110680464442257309696*(25895222463957462655758224991455280215303/633825300114114700748351602688 + sqrt(1213909058710955930446995195883114969038524625997915131236390724543989220134670)*I/22282920707136844948184236032)**(1/3)) + 2*(25895222463957462655758224991455280215303/633825300114114700748351602688 + sqrt(1213909058710955930446995195883114969038524625997915131236390724543989220134670)*I/22282920707136844948184236032)**(1/3))) - 3546944054712886603889144627/(110680464442257309696*(25895222463957462655758224991455280215303/633825300114114700748351602688 + sqrt(1213909058710955930446995195883114969038524625997915131236390724543989220134670)*I/22282920707136844948184236032)**(1/3)))/2)]''')
def test_issue_16823():
# This still needs to be fixed if not using dotprodsimp.
M = Matrix(S('''[
[1+I,-19/4+5/4*I,1/2-I,9/4+55/16*I,-3/4,45/32-37/16*I,1/4+1/2*I,-129/64-9/64*I,1/4-5/16*I,65/128+87/64*I,-9/32-1/16*I,183/256-97/128*I,3/64+13/64*I,-23/32-59/256*I,15/128-3/32*I,19/256+551/1024*I],
[21/8+I,-537/64+143/16*I,-5/8-39/16*I,2473/256+137/64*I,-149/64+49/32*I,-177/128-1369/128*I,125/64+87/64*I,-2063/256+541/128*I,85/256-33/16*I,805/128+2415/512*I,-219/128+115/256*I,6301/4096-6609/1024*I,119/128+143/128*I,-10879/2048+4343/4096*I,129/256-549/512*I,42533/16384+29103/8192*I],
[-2,17/4-13/2*I,1+I,-19/4+5/4*I,1/2-I,9/4+55/16*I,-3/4,45/32-37/16*I,1/4+1/2*I,-129/64-9/64*I,1/4-5/16*I,65/128+87/64*I,-9/32-1/16*I,183/256-97/128*I,3/64+13/64*I,-23/32-59/256*I],
[1/4+13/4*I,-825/64-147/32*I,21/8+I,-537/64+143/16*I,-5/8-39/16*I,2473/256+137/64*I,-149/64+49/32*I,-177/128-1369/128*I,125/64+87/64*I,-2063/256+541/128*I,85/256-33/16*I,805/128+2415/512*I,-219/128+115/256*I,6301/4096-6609/1024*I,119/128+143/128*I,-10879/2048+4343/4096*I],
[-4*I,27/2+6*I,-2,17/4-13/2*I,1+I,-19/4+5/4*I,1/2-I,9/4+55/16*I,-3/4,45/32-37/16*I,1/4+1/2*I,-129/64-9/64*I,1/4-5/16*I,65/128+87/64*I,-9/32-1/16*I,183/256-97/128*I],
[1/4+5/2*I,-23/8-57/16*I,1/4+13/4*I,-825/64-147/32*I,21/8+I,-537/64+143/16*I,-5/8-39/16*I,2473/256+137/64*I,-149/64+49/32*I,-177/128-1369/128*I,125/64+87/64*I,-2063/256+541/128*I,85/256-33/16*I,805/128+2415/512*I,-219/128+115/256*I,6301/4096-6609/1024*I],
[-4,9-5*I,-4*I,27/2+6*I,-2,17/4-13/2*I,1+I,-19/4+5/4*I,1/2-I,9/4+55/16*I,-3/4,45/32-37/16*I,1/4+1/2*I,-129/64-9/64*I,1/4-5/16*I,65/128+87/64*I],
[-2*I,119/8+29/4*I,1/4+5/2*I,-23/8-57/16*I,1/4+13/4*I,-825/64-147/32*I,21/8+I,-537/64+143/16*I,-5/8-39/16*I,2473/256+137/64*I,-149/64+49/32*I,-177/128-1369/128*I,125/64+87/64*I,-2063/256+541/128*I,85/256-33/16*I,805/128+2415/512*I],
[0,-6,-4,9-5*I,-4*I,27/2+6*I,-2,17/4-13/2*I,1+I,-19/4+5/4*I,1/2-I,9/4+55/16*I,-3/4,45/32-37/16*I,1/4+1/2*I,-129/64-9/64*I],
[1,-9/4+3*I,-2*I,119/8+29/4*I,1/4+5/2*I,-23/8-57/16*I,1/4+13/4*I,-825/64-147/32*I,21/8+I,-537/64+143/16*I,-5/8-39/16*I,2473/256+137/64*I,-149/64+49/32*I,-177/128-1369/128*I,125/64+87/64*I,-2063/256+541/128*I],
[0,-4*I,0,-6,-4,9-5*I,-4*I,27/2+6*I,-2,17/4-13/2*I,1+I,-19/4+5/4*I,1/2-I,9/4+55/16*I,-3/4,45/32-37/16*I],
[0,1/4+1/2*I,1,-9/4+3*I,-2*I,119/8+29/4*I,1/4+5/2*I,-23/8-57/16*I,1/4+13/4*I,-825/64-147/32*I,21/8+I,-537/64+143/16*I,-5/8-39/16*I,2473/256+137/64*I,-149/64+49/32*I,-177/128-1369/128*I]]'''))
assert M.rank() == 8
def test_issue_18531():
# solve_linear_system still needs fixing but the rref works.
M = Matrix([
[1, 1, 1, 1, 1, 0, 1, 0, 0],
[1 + sqrt(2), -1 + sqrt(2), 1 - sqrt(2), -sqrt(2) - 1, 1, 1, -1, 1, 1],
[-5 + 2*sqrt(2), -5 - 2*sqrt(2), -5 - 2*sqrt(2), -5 + 2*sqrt(2), -7, 2, -7, -2, 0],
[-3*sqrt(2) - 1, 1 - 3*sqrt(2), -1 + 3*sqrt(2), 1 + 3*sqrt(2), -7, -5, 7, -5, 3],
[7 - 4*sqrt(2), 4*sqrt(2) + 7, 4*sqrt(2) + 7, 7 - 4*sqrt(2), 7, -12, 7, 12, 0],
[-1 + 3*sqrt(2), 1 + 3*sqrt(2), -3*sqrt(2) - 1, 1 - 3*sqrt(2), 7, -5, -7, -5, 3],
[-3 + 2*sqrt(2), -3 - 2*sqrt(2), -3 - 2*sqrt(2), -3 + 2*sqrt(2), -1, 2, -1, -2, 0],
[1 - sqrt(2), -sqrt(2) - 1, 1 + sqrt(2), -1 + sqrt(2), -1, 1, 1, 1, 1]
])
assert M.rref() == (Matrix([
[1, 0, 0, 0, 0, 0, 0, 0, 1/2],
[0, 1, 0, 0, 0, 0, 0, 0, -1/2],
[0, 0, 1, 0, 0, 0, 0, 0, 1/2],
[0, 0, 0, 1, 0, 0, 0, 0, -1/2],
[0, 0, 0, 0, 1, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 1, 0, 0, -1/2],
[0, 0, 0, 0, 0, 0, 1, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 1, -1/2]]), (0, 1, 2, 3, 4, 5, 6, 7))
def test_creation():
raises(ValueError, lambda: Matrix(5, 5, range(20)))
raises(ValueError, lambda: Matrix(5, -1, []))
raises(IndexError, lambda: Matrix((1, 2))[2])
with raises(IndexError):
Matrix((1, 2))[1:2] = 5
with raises(IndexError):
Matrix((1, 2))[3] = 5
assert Matrix() == Matrix([]) == Matrix([[]]) == Matrix(0, 0, [])
# anything can go into a matrix (laplace_transform uses tuples)
assert Matrix([[[], ()]]).tolist() == [[[], ()]]
assert Matrix([[[], ()]]).T.tolist() == [[[]], [()]]
a = Matrix([[x, 0], [0, 0]])
m = a
assert m.cols == m.rows
assert m.cols == 2
assert m[:] == [x, 0, 0, 0]
b = Matrix(2, 2, [x, 0, 0, 0])
m = b
assert m.cols == m.rows
assert m.cols == 2
assert m[:] == [x, 0, 0, 0]
assert a == b
assert Matrix(b) == b
c23 = Matrix(2, 3, range(1, 7))
c13 = Matrix(1, 3, range(7, 10))
c = Matrix([c23, c13])
assert c.cols == 3
assert c.rows == 3
assert c[:] == [1, 2, 3, 4, 5, 6, 7, 8, 9]
assert Matrix(eye(2)) == eye(2)
assert ImmutableMatrix(ImmutableMatrix(eye(2))) == ImmutableMatrix(eye(2))
assert ImmutableMatrix(c) == c.as_immutable()
assert Matrix(ImmutableMatrix(c)) == ImmutableMatrix(c).as_mutable()
assert c is not Matrix(c)
dat = [[ones(3,2), ones(3,3)*2], [ones(2,3)*3, ones(2,2)*4]]
M = Matrix(dat)
assert M == Matrix([
[1, 1, 2, 2, 2],
[1, 1, 2, 2, 2],
[1, 1, 2, 2, 2],
[3, 3, 3, 4, 4],
[3, 3, 3, 4, 4]])
assert M.tolist() != dat
# keep block form if evaluate=False
assert Matrix(dat, evaluate=False).tolist() == dat
A = MatrixSymbol("A", 2, 2)
dat = [ones(2), A]
assert Matrix(dat) == Matrix([
[ 1, 1],
[ 1, 1],
[A[0, 0], A[0, 1]],
[A[1, 0], A[1, 1]]])
assert Matrix(dat, evaluate=False).tolist() == [[i] for i in dat]
# 0-dim tolerance
assert Matrix([ones(2), ones(0)]) == Matrix([ones(2)])
raises(ValueError, lambda: Matrix([ones(2), ones(0, 3)]))
raises(ValueError, lambda: Matrix([ones(2), ones(3, 0)]))
def test_irregular_block():
assert Matrix.irregular(3, ones(2,1), ones(3,3)*2, ones(2,2)*3,
ones(1,1)*4, ones(2,2)*5, ones(1,2)*6, ones(1,2)*7) == Matrix([
[1, 2, 2, 2, 3, 3],
[1, 2, 2, 2, 3, 3],
[4, 2, 2, 2, 5, 5],
[6, 6, 7, 7, 5, 5]])
def test_tolist():
lst = [[S.One, S.Half, x*y, S.Zero], [x, y, z, x**2], [y, -S.One, z*x, 3]]
m = Matrix(lst)
assert m.tolist() == lst
def test_as_mutable():
assert zeros(0, 3).as_mutable() == zeros(0, 3)
assert zeros(0, 3).as_immutable() == ImmutableMatrix(zeros(0, 3))
assert zeros(3, 0).as_immutable() == ImmutableMatrix(zeros(3, 0))
def test_slicing():
m0 = eye(4)
assert m0[:3, :3] == eye(3)
assert m0[2:4, 0:2] == zeros(2)
m1 = Matrix(3, 3, lambda i, j: i + j)
assert m1[0, :] == Matrix(1, 3, (0, 1, 2))
assert m1[1:3, 1] == Matrix(2, 1, (2, 3))
m2 = Matrix([[0, 1, 2, 3], [4, 5, 6, 7], [8, 9, 10, 11], [12, 13, 14, 15]])
assert m2[:, -1] == Matrix(4, 1, [3, 7, 11, 15])
assert m2[-2:, :] == Matrix([[8, 9, 10, 11], [12, 13, 14, 15]])
def test_submatrix_assignment():
m = zeros(4)
m[2:4, 2:4] = eye(2)
assert m == Matrix(((0, 0, 0, 0),
(0, 0, 0, 0),
(0, 0, 1, 0),
(0, 0, 0, 1)))
m[:2, :2] = eye(2)
assert m == eye(4)
m[:, 0] = Matrix(4, 1, (1, 2, 3, 4))
assert m == Matrix(((1, 0, 0, 0),
(2, 1, 0, 0),
(3, 0, 1, 0),
(4, 0, 0, 1)))
m[:, :] = zeros(4)
assert m == zeros(4)
m[:, :] = [(1, 2, 3, 4), (5, 6, 7, 8), (9, 10, 11, 12), (13, 14, 15, 16)]
assert m == Matrix(((1, 2, 3, 4),
(5, 6, 7, 8),
(9, 10, 11, 12),
(13, 14, 15, 16)))
m[:2, 0] = [0, 0]
assert m == Matrix(((0, 2, 3, 4),
(0, 6, 7, 8),
(9, 10, 11, 12),
(13, 14, 15, 16)))
def test_extract():
m = Matrix(4, 3, lambda i, j: i*3 + j)
assert m.extract([0, 1, 3], [0, 1]) == Matrix(3, 2, [0, 1, 3, 4, 9, 10])
assert m.extract([0, 3], [0, 0, 2]) == Matrix(2, 3, [0, 0, 2, 9, 9, 11])
assert m.extract(range(4), range(3)) == m
raises(IndexError, lambda: m.extract([4], [0]))
raises(IndexError, lambda: m.extract([0], [3]))
def test_reshape():
m0 = eye(3)
assert m0.reshape(1, 9) == Matrix(1, 9, (1, 0, 0, 0, 1, 0, 0, 0, 1))
m1 = Matrix(3, 4, lambda i, j: i + j)
assert m1.reshape(
4, 3) == Matrix(((0, 1, 2), (3, 1, 2), (3, 4, 2), (3, 4, 5)))
assert m1.reshape(2, 6) == Matrix(((0, 1, 2, 3, 1, 2), (3, 4, 2, 3, 4, 5)))
def test_applyfunc():
m0 = eye(3)
assert m0.applyfunc(lambda x: 2*x) == eye(3)*2
assert m0.applyfunc(lambda x: 0) == zeros(3)
def test_expand():
m0 = Matrix([[x*(x + y), 2], [((x + y)*y)*x, x*(y + x*(x + y))]])
# Test if expand() returns a matrix
m1 = m0.expand()
assert m1 == Matrix(
[[x*y + x**2, 2], [x*y**2 + y*x**2, x*y + y*x**2 + x**3]])
a = Symbol('a', real=True)
assert Matrix([exp(I*a)]).expand(complex=True) == \
Matrix([cos(a) + I*sin(a)])
assert Matrix([[0, 1, 2], [0, 0, -1], [0, 0, 0]]).exp() == Matrix([
[1, 1, Rational(3, 2)],
[0, 1, -1],
[0, 0, 1]]
)
def test_refine():
m0 = Matrix([[Abs(x)**2, sqrt(x**2)],
[sqrt(x**2)*Abs(y)**2, sqrt(y**2)*Abs(x)**2]])
m1 = m0.refine(Q.real(x) & Q.real(y))
assert m1 == Matrix([[x**2, Abs(x)], [y**2*Abs(x), x**2*Abs(y)]])
m1 = m0.refine(Q.positive(x) & Q.positive(y))
assert m1 == Matrix([[x**2, x], [x*y**2, x**2*y]])
m1 = m0.refine(Q.negative(x) & Q.negative(y))
assert m1 == Matrix([[x**2, -x], [-x*y**2, -x**2*y]])
def test_random():
M = randMatrix(3, 3)
M = randMatrix(3, 3, seed=3)
assert M == randMatrix(3, 3, seed=3)
M = randMatrix(3, 4, 0, 150)
M = randMatrix(3, seed=4, symmetric=True)
assert M == randMatrix(3, seed=4, symmetric=True)
S = M.copy()
S.simplify()
assert S == M # doesn't fail when elements are Numbers, not int
rng = random.Random(4)
assert M == randMatrix(3, symmetric=True, prng=rng)
# Ensure symmetry
for size in (10, 11): # Test odd and even
for percent in (100, 70, 30):
M = randMatrix(size, symmetric=True, percent=percent, prng=rng)
assert M == M.T
M = randMatrix(10, min=1, percent=70)
zero_count = 0
for i in range(M.shape[0]):
for j in range(M.shape[1]):
if M[i, j] == 0:
zero_count += 1
assert zero_count == 30
def test_inverse():
A = eye(4)
assert A.inv() == eye(4)
assert A.inv(method="LU") == eye(4)
assert A.inv(method="ADJ") == eye(4)
assert A.inv(method="CH") == eye(4)
assert A.inv(method="LDL") == eye(4)
assert A.inv(method="QR") == eye(4)
A = Matrix([[2, 3, 5],
[3, 6, 2],
[8, 3, 6]])
Ainv = A.inv()
assert A*Ainv == eye(3)
assert A.inv(method="LU") == Ainv
assert A.inv(method="ADJ") == Ainv
assert A.inv(method="CH") == Ainv
assert A.inv(method="LDL") == Ainv
assert A.inv(method="QR") == Ainv
AA = Matrix([[0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0],
[1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0],
[1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1],
[1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0],
[1, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0],
[1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1],
[0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0],
[1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1],
[0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1],
[1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0],
[0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0],
[1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0],
[0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1],
[1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0],
[0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0],
[1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0],
[0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1],
[0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1],
[1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1],
[0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1],
[0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1],
[0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0],
[0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0],
[0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0]])
assert AA.inv(method="BLOCK") * AA == eye(AA.shape[0])
# test that immutability is not a problem
cls = ImmutableMatrix
m = cls([[48, 49, 31],
[ 9, 71, 94],
[59, 28, 65]])
assert all(type(m.inv(s)) is cls for s in 'GE ADJ LU CH LDL QR'.split())
cls = ImmutableSparseMatrix
m = cls([[48, 49, 31],
[ 9, 71, 94],
[59, 28, 65]])
assert all(type(m.inv(s)) is cls for s in 'GE ADJ LU CH LDL QR'.split())
def test_matrix_inverse_mod():
A = Matrix(2, 1, [1, 0])
raises(NonSquareMatrixError, lambda: A.inv_mod(2))
A = Matrix(2, 2, [1, 0, 0, 0])
raises(ValueError, lambda: A.inv_mod(2))
A = Matrix(2, 2, [1, 2, 3, 4])
Ai = Matrix(2, 2, [1, 1, 0, 1])
assert A.inv_mod(3) == Ai
A = Matrix(2, 2, [1, 0, 0, 1])
assert A.inv_mod(2) == A
A = Matrix(3, 3, [1, 2, 3, 4, 5, 6, 7, 8, 9])
raises(ValueError, lambda: A.inv_mod(5))
A = Matrix(3, 3, [5, 1, 3, 2, 6, 0, 2, 1, 1])
Ai = Matrix(3, 3, [6, 8, 0, 1, 5, 6, 5, 6, 4])
assert A.inv_mod(9) == Ai
A = Matrix(3, 3, [1, 6, -3, 4, 1, -5, 3, -5, 5])
Ai = Matrix(3, 3, [4, 3, 3, 1, 2, 5, 1, 5, 1])
assert A.inv_mod(6) == Ai
A = Matrix(3, 3, [1, 6, 1, 4, 1, 5, 3, 2, 5])
Ai = Matrix(3, 3, [6, 0, 3, 6, 6, 4, 1, 6, 1])
assert A.inv_mod(7) == Ai
def test_jacobian_hessian():
L = Matrix(1, 2, [x**2*y, 2*y**2 + x*y])
syms = [x, y]
assert L.jacobian(syms) == Matrix([[2*x*y, x**2], [y, 4*y + x]])
L = Matrix(1, 2, [x, x**2*y**3])
assert L.jacobian(syms) == Matrix([[1, 0], [2*x*y**3, x**2*3*y**2]])
f = x**2*y
syms = [x, y]
assert hessian(f, syms) == Matrix([[2*y, 2*x], [2*x, 0]])
f = x**2*y**3
assert hessian(f, syms) == \
Matrix([[2*y**3, 6*x*y**2], [6*x*y**2, 6*x**2*y]])
f = z + x*y**2
g = x**2 + 2*y**3
ans = Matrix([[0, 2*y],
[2*y, 2*x]])
assert ans == hessian(f, Matrix([x, y]))
assert ans == hessian(f, Matrix([x, y]).T)
assert hessian(f, (y, x), [g]) == Matrix([
[ 0, 6*y**2, 2*x],
[6*y**2, 2*x, 2*y],
[ 2*x, 2*y, 0]])
def test_wronskian():
assert wronskian([cos(x), sin(x)], x) == cos(x)**2 + sin(x)**2
assert wronskian([exp(x), exp(2*x)], x) == exp(3*x)
assert wronskian([exp(x), x], x) == exp(x) - x*exp(x)
assert wronskian([1, x, x**2], x) == 2
w1 = -6*exp(x)*sin(x)*x + 6*cos(x)*exp(x)*x**2 - 6*exp(x)*cos(x)*x - \
exp(x)*cos(x)*x**3 + exp(x)*sin(x)*x**3
assert wronskian([exp(x), cos(x), x**3], x).expand() == w1
assert wronskian([exp(x), cos(x), x**3], x, method='berkowitz').expand() \
== w1
w2 = -x**3*cos(x)**2 - x**3*sin(x)**2 - 6*x*cos(x)**2 - 6*x*sin(x)**2
assert wronskian([sin(x), cos(x), x**3], x).expand() == w2
assert wronskian([sin(x), cos(x), x**3], x, method='berkowitz').expand() \
== w2
assert wronskian([], x) == 1
def test_subs():
assert Matrix([[1, x], [x, 4]]).subs(x, 5) == Matrix([[1, 5], [5, 4]])
assert Matrix([[x, 2], [x + y, 4]]).subs([[x, -1], [y, -2]]) == \
Matrix([[-1, 2], [-3, 4]])
assert Matrix([[x, 2], [x + y, 4]]).subs([(x, -1), (y, -2)]) == \
Matrix([[-1, 2], [-3, 4]])
assert Matrix([[x, 2], [x + y, 4]]).subs({x: -1, y: -2}) == \
Matrix([[-1, 2], [-3, 4]])
assert Matrix([x*y]).subs({x: y - 1, y: x - 1}, simultaneous=True) == \
Matrix([(x - 1)*(y - 1)])
for cls in classes:
assert Matrix([[2, 0], [0, 2]]) == cls.eye(2).subs(1, 2)
def test_xreplace():
assert Matrix([[1, x], [x, 4]]).xreplace({x: 5}) == \
Matrix([[1, 5], [5, 4]])
assert Matrix([[x, 2], [x + y, 4]]).xreplace({x: -1, y: -2}) == \
Matrix([[-1, 2], [-3, 4]])
for cls in classes:
assert Matrix([[2, 0], [0, 2]]) == cls.eye(2).xreplace({1: 2})
def test_simplify():
n = Symbol('n')
f = Function('f')
M = Matrix([[ 1/x + 1/y, (x + x*y) / x ],
[ (f(x) + y*f(x))/f(x), 2 * (1/n - cos(n * pi)/n) / pi ]])
M.simplify()
assert M == Matrix([[ (x + y)/(x * y), 1 + y ],
[ 1 + y, 2*((1 - 1*cos(pi*n))/(pi*n)) ]])
eq = (1 + x)**2
M = Matrix([[eq]])
M.simplify()
assert M == Matrix([[eq]])
M.simplify(ratio=oo) == M
assert M == Matrix([[eq.simplify(ratio=oo)]])
def test_transpose():
M = Matrix([[1, 2, 3, 4, 5, 6, 7, 8, 9, 0],
[1, 2, 3, 4, 5, 6, 7, 8, 9, 0]])
assert M.T == Matrix( [ [1, 1],
[2, 2],
[3, 3],
[4, 4],
[5, 5],
[6, 6],
[7, 7],
[8, 8],
[9, 9],
[0, 0] ])
assert M.T.T == M
assert M.T == M.transpose()
def test_conjugate():
M = Matrix([[0, I, 5],
[1, 2, 0]])
assert M.T == Matrix([[0, 1],
[I, 2],
[5, 0]])
assert M.C == Matrix([[0, -I, 5],
[1, 2, 0]])
assert M.C == M.conjugate()
assert M.H == M.T.C
assert M.H == Matrix([[ 0, 1],
[-I, 2],
[ 5, 0]])
def test_conj_dirac():
raises(AttributeError, lambda: eye(3).D)
M = Matrix([[1, I, I, I],
[0, 1, I, I],
[0, 0, 1, I],
[0, 0, 0, 1]])
assert M.D == Matrix([[ 1, 0, 0, 0],
[-I, 1, 0, 0],
[-I, -I, -1, 0],
[-I, -I, I, -1]])
def test_trace():
M = Matrix([[1, 0, 0],
[0, 5, 0],
[0, 0, 8]])
assert M.trace() == 14
def test_shape():
M = Matrix([[x, 0, 0],
[0, y, 0]])
assert M.shape == (2, 3)
def test_col_row_op():
M = Matrix([[x, 0, 0],
[0, y, 0]])
M.row_op(1, lambda r, j: r + j + 1)
assert M == Matrix([[x, 0, 0],
[1, y + 2, 3]])
M.col_op(0, lambda c, j: c + y**j)
assert M == Matrix([[x + 1, 0, 0],
[1 + y, y + 2, 3]])
# neither row nor slice give copies that allow the original matrix to
# be changed
assert M.row(0) == Matrix([[x + 1, 0, 0]])
r1 = M.row(0)
r1[0] = 42
assert M[0, 0] == x + 1
r1 = M[0, :-1] # also testing negative slice
r1[0] = 42
assert M[0, 0] == x + 1
c1 = M.col(0)
assert c1 == Matrix([x + 1, 1 + y])
c1[0] = 0
assert M[0, 0] == x + 1
c1 = M[:, 0]
c1[0] = 42
assert M[0, 0] == x + 1
def test_zip_row_op():
for cls in classes[:2]: # XXX: immutable matrices don't support row ops
M = cls.eye(3)
M.zip_row_op(1, 0, lambda v, u: v + 2*u)
assert M == cls([[1, 0, 0],
[2, 1, 0],
[0, 0, 1]])
M = cls.eye(3)*2
M[0, 1] = -1
M.zip_row_op(1, 0, lambda v, u: v + 2*u); M
assert M == cls([[2, -1, 0],
[4, 0, 0],
[0, 0, 2]])
def test_issue_3950():
m = Matrix([1, 2, 3])
a = Matrix([1, 2, 3])
b = Matrix([2, 2, 3])
assert not (m in [])
assert not (m in [1])
assert m != 1
assert m == a
assert m != b
def test_issue_3981():
class Index1:
def __index__(self):
return 1
class Index2:
def __index__(self):
return 2
index1 = Index1()
index2 = Index2()
m = Matrix([1, 2, 3])
assert m[index2] == 3
m[index2] = 5
assert m[2] == 5
m = Matrix([[1, 2, 3], [4, 5, 6]])
assert m[index1, index2] == 6
assert m[1, index2] == 6
assert m[index1, 2] == 6
m[index1, index2] = 4
assert m[1, 2] == 4
m[1, index2] = 6
assert m[1, 2] == 6
m[index1, 2] = 8
assert m[1, 2] == 8
def test_evalf():
a = Matrix([sqrt(5), 6])
assert all(a.evalf()[i] == a[i].evalf() for i in range(2))
assert all(a.evalf(2)[i] == a[i].evalf(2) for i in range(2))
assert all(a.n(2)[i] == a[i].n(2) for i in range(2))
def test_is_symbolic():
a = Matrix([[x, x], [x, x]])
assert a.is_symbolic() is True
a = Matrix([[1, 2, 3, 4], [5, 6, 7, 8]])
assert a.is_symbolic() is False
a = Matrix([[1, 2, 3, 4], [5, 6, x, 8]])
assert a.is_symbolic() is True
a = Matrix([[1, x, 3]])
assert a.is_symbolic() is True
a = Matrix([[1, 2, 3]])
assert a.is_symbolic() is False
a = Matrix([[1], [x], [3]])
assert a.is_symbolic() is True
a = Matrix([[1], [2], [3]])
assert a.is_symbolic() is False
def test_is_upper():
a = Matrix([[1, 2, 3]])
assert a.is_upper is True
a = Matrix([[1], [2], [3]])
assert a.is_upper is False
a = zeros(4, 2)
assert a.is_upper is True
def test_is_lower():
a = Matrix([[1, 2, 3]])
assert a.is_lower is False
a = Matrix([[1], [2], [3]])
assert a.is_lower is True
def test_is_nilpotent():
a = Matrix(4, 4, [0, 2, 1, 6, 0, 0, 1, 2, 0, 0, 0, 3, 0, 0, 0, 0])
assert a.is_nilpotent()
a = Matrix([[1, 0], [0, 1]])
assert not a.is_nilpotent()
a = Matrix([])
assert a.is_nilpotent()
def test_zeros_ones_fill():
n, m = 3, 5
a = zeros(n, m)
a.fill( 5 )
b = 5 * ones(n, m)
assert a == b
assert a.rows == b.rows == 3
assert a.cols == b.cols == 5
assert a.shape == b.shape == (3, 5)
assert zeros(2) == zeros(2, 2)
assert ones(2) == ones(2, 2)
assert zeros(2, 3) == Matrix(2, 3, [0]*6)
assert ones(2, 3) == Matrix(2, 3, [1]*6)
def test_empty_zeros():
a = zeros(0)
assert a == Matrix()
a = zeros(0, 2)
assert a.rows == 0
assert a.cols == 2
a = zeros(2, 0)
assert a.rows == 2
assert a.cols == 0
def test_issue_3749():
a = Matrix([[x**2, x*y], [x*sin(y), x*cos(y)]])
assert a.diff(x) == Matrix([[2*x, y], [sin(y), cos(y)]])
assert Matrix([
[x, -x, x**2],
[exp(x), 1/x - exp(-x), x + 1/x]]).limit(x, oo) == \
Matrix([[oo, -oo, oo], [oo, 0, oo]])
assert Matrix([
[(exp(x) - 1)/x, 2*x + y*x, x**x ],
[1/x, abs(x), abs(sin(x + 1))]]).limit(x, 0) == \
Matrix([[1, 0, 1], [oo, 0, sin(1)]])
assert a.integrate(x) == Matrix([
[Rational(1, 3)*x**3, y*x**2/2],
[x**2*sin(y)/2, x**2*cos(y)/2]])
def test_inv_iszerofunc():
A = eye(4)
A.col_swap(0, 1)
for method in "GE", "LU":
assert A.inv(method=method, iszerofunc=lambda x: x == 0) == \
A.inv(method="ADJ")
def test_jacobian_metrics():
rho, phi = symbols("rho,phi")
X = Matrix([rho*cos(phi), rho*sin(phi)])
Y = Matrix([rho, phi])
J = X.jacobian(Y)
assert J == X.jacobian(Y.T)
assert J == (X.T).jacobian(Y)
assert J == (X.T).jacobian(Y.T)
g = J.T*eye(J.shape[0])*J
g = g.applyfunc(trigsimp)
assert g == Matrix([[1, 0], [0, rho**2]])
def test_jacobian2():
rho, phi = symbols("rho,phi")
X = Matrix([rho*cos(phi), rho*sin(phi), rho**2])
Y = Matrix([rho, phi])
J = Matrix([
[cos(phi), -rho*sin(phi)],
[sin(phi), rho*cos(phi)],
[ 2*rho, 0],
])
assert X.jacobian(Y) == J
def test_issue_4564():
X = Matrix([exp(x + y + z), exp(x + y + z), exp(x + y + z)])
Y = Matrix([x, y, z])
for i in range(1, 3):
for j in range(1, 3):
X_slice = X[:i, :]
Y_slice = Y[:j, :]
J = X_slice.jacobian(Y_slice)
assert J.rows == i
assert J.cols == j
for k in range(j):
assert J[:, k] == X_slice
def test_nonvectorJacobian():
X = Matrix([[exp(x + y + z), exp(x + y + z)],
[exp(x + y + z), exp(x + y + z)]])
raises(TypeError, lambda: X.jacobian(Matrix([x, y, z])))
X = X[0, :]
Y = Matrix([[x, y], [x, z]])
raises(TypeError, lambda: X.jacobian(Y))
raises(TypeError, lambda: X.jacobian(Matrix([ [x, y], [x, z] ])))
def test_vec():
m = Matrix([[1, 3], [2, 4]])
m_vec = m.vec()
assert m_vec.cols == 1
for i in range(4):
assert m_vec[i] == i + 1
def test_vech():
m = Matrix([[1, 2], [2, 3]])
m_vech = m.vech()
assert m_vech.cols == 1
for i in range(3):
assert m_vech[i] == i + 1
m_vech = m.vech(diagonal=False)
assert m_vech[0] == 2
m = Matrix([[1, x*(x + y)], [y*x + x**2, 1]])
m_vech = m.vech(diagonal=False)
assert m_vech[0] == x*(x + y)
m = Matrix([[1, x*(x + y)], [y*x, 1]])
m_vech = m.vech(diagonal=False, check_symmetry=False)
assert m_vech[0] == y*x
def test_vech_errors():
m = Matrix([[1, 3]])
raises(ShapeError, lambda: m.vech())
m = Matrix([[1, 3], [2, 4]])
raises(ValueError, lambda: m.vech())
raises(ShapeError, lambda: Matrix([ [1, 3] ]).vech())
raises(ValueError, lambda: Matrix([ [1, 3], [2, 4] ]).vech())
def test_diag():
# mostly tested in testcommonmatrix.py
assert diag([1, 2, 3]) == Matrix([1, 2, 3])
m = [1, 2, [3]]
raises(ValueError, lambda: diag(m))
assert diag(m, strict=False) == Matrix([1, 2, 3])
def test_get_diag_blocks1():
a = Matrix([[1, 2], [2, 3]])
b = Matrix([[3, x], [y, 3]])
c = Matrix([[3, x, 3], [y, 3, z], [x, y, z]])
assert a.get_diag_blocks() == [a]
assert b.get_diag_blocks() == [b]
assert c.get_diag_blocks() == [c]
def test_get_diag_blocks2():
a = Matrix([[1, 2], [2, 3]])
b = Matrix([[3, x], [y, 3]])
c = Matrix([[3, x, 3], [y, 3, z], [x, y, z]])
assert diag(a, b, b).get_diag_blocks() == [a, b, b]
assert diag(a, b, c).get_diag_blocks() == [a, b, c]
assert diag(a, c, b).get_diag_blocks() == [a, c, b]
assert diag(c, c, b).get_diag_blocks() == [c, c, b]
def test_inv_block():
a = Matrix([[1, 2], [2, 3]])
b = Matrix([[3, x], [y, 3]])
c = Matrix([[3, x, 3], [y, 3, z], [x, y, z]])
A = diag(a, b, b)
assert A.inv(try_block_diag=True) == diag(a.inv(), b.inv(), b.inv())
A = diag(a, b, c)
assert A.inv(try_block_diag=True) == diag(a.inv(), b.inv(), c.inv())
A = diag(a, c, b)
assert A.inv(try_block_diag=True) == diag(a.inv(), c.inv(), b.inv())
A = diag(a, a, b, a, c, a)
assert A.inv(try_block_diag=True) == diag(
a.inv(), a.inv(), b.inv(), a.inv(), c.inv(), a.inv())
assert A.inv(try_block_diag=True, method="ADJ") == diag(
a.inv(method="ADJ"), a.inv(method="ADJ"), b.inv(method="ADJ"),
a.inv(method="ADJ"), c.inv(method="ADJ"), a.inv(method="ADJ"))
def test_creation_args():
"""
Check that matrix dimensions can be specified using any reasonable type
(see issue 4614).
"""
raises(ValueError, lambda: zeros(3, -1))
raises(TypeError, lambda: zeros(1, 2, 3, 4))
assert zeros(int(3)) == zeros(3)
assert zeros(Integer(3)) == zeros(3)
raises(ValueError, lambda: zeros(3.))
assert eye(int(3)) == eye(3)
assert eye(Integer(3)) == eye(3)
raises(ValueError, lambda: eye(3.))
assert ones(int(3), Integer(4)) == ones(3, 4)
raises(TypeError, lambda: Matrix(5))
raises(TypeError, lambda: Matrix(1, 2))
raises(ValueError, lambda: Matrix([1, [2]]))
def test_diagonal_symmetrical():
m = Matrix(2, 2, [0, 1, 1, 0])
assert not m.is_diagonal()
assert m.is_symmetric()
assert m.is_symmetric(simplify=False)
m = Matrix(2, 2, [1, 0, 0, 1])
assert m.is_diagonal()
m = diag(1, 2, 3)
assert m.is_diagonal()
assert m.is_symmetric()
m = Matrix(3, 3, [1, 0, 0, 0, 2, 0, 0, 0, 3])
assert m == diag(1, 2, 3)
m = Matrix(2, 3, zeros(2, 3))
assert not m.is_symmetric()
assert m.is_diagonal()
m = Matrix(((5, 0), (0, 6), (0, 0)))
assert m.is_diagonal()
m = Matrix(((5, 0, 0), (0, 6, 0)))
assert m.is_diagonal()
m = Matrix(3, 3, [1, x**2 + 2*x + 1, y, (x + 1)**2, 2, 0, y, 0, 3])
assert m.is_symmetric()
assert not m.is_symmetric(simplify=False)
assert m.expand().is_symmetric(simplify=False)
def test_diagonalization():
m = Matrix([[1, 2+I], [2-I, 3]])
assert m.is_diagonalizable()
m = Matrix(3, 2, [-3, 1, -3, 20, 3, 10])
assert not m.is_diagonalizable()
assert not m.is_symmetric()
raises(NonSquareMatrixError, lambda: m.diagonalize())
# diagonalizable
m = diag(1, 2, 3)
(P, D) = m.diagonalize()
assert P == eye(3)
assert D == m
m = Matrix(2, 2, [0, 1, 1, 0])
assert m.is_symmetric()
assert m.is_diagonalizable()
(P, D) = m.diagonalize()
assert P.inv() * m * P == D
m = Matrix(2, 2, [1, 0, 0, 3])
assert m.is_symmetric()
assert m.is_diagonalizable()
(P, D) = m.diagonalize()
assert P.inv() * m * P == D
assert P == eye(2)
assert D == m
m = Matrix(2, 2, [1, 1, 0, 0])
assert m.is_diagonalizable()
(P, D) = m.diagonalize()
assert P.inv() * m * P == D
m = Matrix(3, 3, [1, 2, 0, 0, 3, 0, 2, -4, 2])
assert m.is_diagonalizable()
(P, D) = m.diagonalize()
assert P.inv() * m * P == D
for i in P:
assert i.as_numer_denom()[1] == 1
m = Matrix(2, 2, [1, 0, 0, 0])
assert m.is_diagonal()
assert m.is_diagonalizable()
(P, D) = m.diagonalize()
assert P.inv() * m * P == D
assert P == Matrix([[0, 1], [1, 0]])
# diagonalizable, complex only
m = Matrix(2, 2, [0, 1, -1, 0])
assert not m.is_diagonalizable(True)
raises(MatrixError, lambda: m.diagonalize(True))
assert m.is_diagonalizable()
(P, D) = m.diagonalize()
assert P.inv() * m * P == D
# not diagonalizable
m = Matrix(2, 2, [0, 1, 0, 0])
assert not m.is_diagonalizable()
raises(MatrixError, lambda: m.diagonalize())
m = Matrix(3, 3, [-3, 1, -3, 20, 3, 10, 2, -2, 4])
assert not m.is_diagonalizable()
raises(MatrixError, lambda: m.diagonalize())
# symbolic
a, b, c, d = symbols('a b c d')
m = Matrix(2, 2, [a, c, c, b])
assert m.is_symmetric()
assert m.is_diagonalizable()
def test_issue_15887():
# Mutable matrix should not use cache
a = MutableDenseMatrix([[0, 1], [1, 0]])
assert a.is_diagonalizable() is True
a[1, 0] = 0
assert a.is_diagonalizable() is False
a = MutableDenseMatrix([[0, 1], [1, 0]])
a.diagonalize()
a[1, 0] = 0
raises(MatrixError, lambda: a.diagonalize())
# Test deprecated cache and kwargs
with warns_deprecated_sympy():
a.is_diagonalizable(clear_cache=True)
with warns_deprecated_sympy():
a.is_diagonalizable(clear_subproducts=True)
def test_jordan_form():
m = Matrix(3, 2, [-3, 1, -3, 20, 3, 10])
raises(NonSquareMatrixError, lambda: m.jordan_form())
# diagonalizable
m = Matrix(3, 3, [7, -12, 6, 10, -19, 10, 12, -24, 13])
Jmust = Matrix(3, 3, [-1, 0, 0, 0, 1, 0, 0, 0, 1])
P, J = m.jordan_form()
assert Jmust == J
assert Jmust == m.diagonalize()[1]
# m = Matrix(3, 3, [0, 6, 3, 1, 3, 1, -2, 2, 1])
# m.jordan_form() # very long
# m.jordan_form() #
# diagonalizable, complex only
# Jordan cells
# complexity: one of eigenvalues is zero
m = Matrix(3, 3, [0, 1, 0, -4, 4, 0, -2, 1, 2])
# The blocks are ordered according to the value of their eigenvalues,
# in order to make the matrix compatible with .diagonalize()
Jmust = Matrix(3, 3, [2, 1, 0, 0, 2, 0, 0, 0, 2])
P, J = m.jordan_form()
assert Jmust == J
# complexity: all of eigenvalues are equal
m = Matrix(3, 3, [2, 6, -15, 1, 1, -5, 1, 2, -6])
# Jmust = Matrix(3, 3, [-1, 0, 0, 0, -1, 1, 0, 0, -1])
# same here see 1456ff
Jmust = Matrix(3, 3, [-1, 1, 0, 0, -1, 0, 0, 0, -1])
P, J = m.jordan_form()
assert Jmust == J
# complexity: two of eigenvalues are zero
m = Matrix(3, 3, [4, -5, 2, 5, -7, 3, 6, -9, 4])
Jmust = Matrix(3, 3, [0, 1, 0, 0, 0, 0, 0, 0, 1])
P, J = m.jordan_form()
assert Jmust == J
m = Matrix(4, 4, [6, 5, -2, -3, -3, -1, 3, 3, 2, 1, -2, -3, -1, 1, 5, 5])
Jmust = Matrix(4, 4, [2, 1, 0, 0,
0, 2, 0, 0,
0, 0, 2, 1,
0, 0, 0, 2]
)
P, J = m.jordan_form()
assert Jmust == J
m = Matrix(4, 4, [6, 2, -8, -6, -3, 2, 9, 6, 2, -2, -8, -6, -1, 0, 3, 4])
# Jmust = Matrix(4, 4, [2, 0, 0, 0, 0, 2, 1, 0, 0, 0, 2, 0, 0, 0, 0, -2])
# same here see 1456ff
Jmust = Matrix(4, 4, [-2, 0, 0, 0,
0, 2, 1, 0,
0, 0, 2, 0,
0, 0, 0, 2])
P, J = m.jordan_form()
assert Jmust == J
m = Matrix(4, 4, [5, 4, 2, 1, 0, 1, -1, -1, -1, -1, 3, 0, 1, 1, -1, 2])
assert not m.is_diagonalizable()
Jmust = Matrix(4, 4, [1, 0, 0, 0, 0, 2, 0, 0, 0, 0, 4, 1, 0, 0, 0, 4])
P, J = m.jordan_form()
assert Jmust == J
# checking for maximum precision to remain unchanged
m = Matrix([[Float('1.0', precision=110), Float('2.0', precision=110)],
[Float('3.14159265358979323846264338327', precision=110), Float('4.0', precision=110)]])
P, J = m.jordan_form()
for term in J._mat:
if isinstance(term, Float):
assert term._prec == 110
def test_jordan_form_complex_issue_9274():
A = Matrix([[ 2, 4, 1, 0],
[-4, 2, 0, 1],
[ 0, 0, 2, 4],
[ 0, 0, -4, 2]])
p = 2 - 4*I;
q = 2 + 4*I;
Jmust1 = Matrix([[p, 1, 0, 0],
[0, p, 0, 0],
[0, 0, q, 1],
[0, 0, 0, q]])
Jmust2 = Matrix([[q, 1, 0, 0],
[0, q, 0, 0],
[0, 0, p, 1],
[0, 0, 0, p]])
P, J = A.jordan_form()
assert J == Jmust1 or J == Jmust2
assert simplify(P*J*P.inv()) == A
def test_issue_10220():
# two non-orthogonal Jordan blocks with eigenvalue 1
M = Matrix([[1, 0, 0, 1],
[0, 1, 1, 0],
[0, 0, 1, 1],
[0, 0, 0, 1]])
P, J = M.jordan_form()
assert P == Matrix([[0, 1, 0, 1],
[1, 0, 0, 0],
[0, 1, 0, 0],
[0, 0, 1, 0]])
assert J == Matrix([
[1, 1, 0, 0],
[0, 1, 1, 0],
[0, 0, 1, 0],
[0, 0, 0, 1]])
def test_jordan_form_issue_15858():
A = Matrix([
[1, 1, 1, 0],
[-2, -1, 0, -1],
[0, 0, -1, -1],
[0, 0, 2, 1]])
(P, J) = A.jordan_form()
assert P.expand() == Matrix([
[ -I, -I/2, I, I/2],
[-1 + I, 0, -1 - I, 0],
[ 0, -S(1)/2 - I/2, 0, -S(1)/2 + I/2],
[ 0, 1, 0, 1]])
assert J == Matrix([
[-I, 1, 0, 0],
[0, -I, 0, 0],
[0, 0, I, 1],
[0, 0, 0, I]])
def test_Matrix_berkowitz_charpoly():
UA, K_i, K_w = symbols('UA K_i K_w')
A = Matrix([[-K_i - UA + K_i**2/(K_i + K_w), K_i*K_w/(K_i + K_w)],
[ K_i*K_w/(K_i + K_w), -K_w + K_w**2/(K_i + K_w)]])
charpoly = A.charpoly(x)
assert charpoly == \
Poly(x**2 + (K_i*UA + K_w*UA + 2*K_i*K_w)/(K_i + K_w)*x +
K_i*K_w*UA/(K_i + K_w), x, domain='ZZ(K_i,K_w,UA)')
assert type(charpoly) is PurePoly
A = Matrix([[1, 3], [2, 0]])
assert A.charpoly() == A.charpoly(x) == PurePoly(x**2 - x - 6)
A = Matrix([[1, 2], [x, 0]])
p = A.charpoly(x)
assert p.gen != x
assert p.as_expr().subs(p.gen, x) == x**2 - 3*x
def test_exp_jordan_block():
l = Symbol('lamda')
m = Matrix.jordan_block(1, l)
assert m._eval_matrix_exp_jblock() == Matrix([[exp(l)]])
m = Matrix.jordan_block(3, l)
assert m._eval_matrix_exp_jblock() == \
Matrix([
[exp(l), exp(l), exp(l)/2],
[0, exp(l), exp(l)],
[0, 0, exp(l)]])
def test_exp():
m = Matrix([[3, 4], [0, -2]])
m_exp = Matrix([[exp(3), -4*exp(-2)/5 + 4*exp(3)/5], [0, exp(-2)]])
assert m.exp() == m_exp
assert exp(m) == m_exp
m = Matrix([[1, 0], [0, 1]])
assert m.exp() == Matrix([[E, 0], [0, E]])
assert exp(m) == Matrix([[E, 0], [0, E]])
m = Matrix([[1, -1], [1, 1]])
assert m.exp() == Matrix([[E*cos(1), -E*sin(1)], [E*sin(1), E*cos(1)]])
def test_log():
l = Symbol('lamda')
m = Matrix.jordan_block(1, l)
assert m._eval_matrix_log_jblock() == Matrix([[log(l)]])
m = Matrix.jordan_block(4, l)
assert m._eval_matrix_log_jblock() == \
Matrix(
[
[log(l), 1/l, -1/(2*l**2), 1/(3*l**3)],
[0, log(l), 1/l, -1/(2*l**2)],
[0, 0, log(l), 1/l],
[0, 0, 0, log(l)]
]
)
m = Matrix(
[[0, 0, 1],
[0, 0, 0],
[-1, 0, 0]]
)
raises(MatrixError, lambda: m.log())
def test_has():
A = Matrix(((x, y), (2, 3)))
assert A.has(x)
assert not A.has(z)
assert A.has(Symbol)
A = A.subs(x, 2)
assert not A.has(x)
def test_find_reasonable_pivot_naive_finds_guaranteed_nonzero1():
# Test if matrices._find_reasonable_pivot_naive()
# finds a guaranteed non-zero pivot when the
# some of the candidate pivots are symbolic expressions.
# Keyword argument: simpfunc=None indicates that no simplifications
# should be performed during the search.
x = Symbol('x')
column = Matrix(3, 1, [x, cos(x)**2 + sin(x)**2, S.Half])
pivot_offset, pivot_val, pivot_assumed_nonzero, simplified =\
_find_reasonable_pivot_naive(column)
assert pivot_val == S.Half
def test_find_reasonable_pivot_naive_finds_guaranteed_nonzero2():
# Test if matrices._find_reasonable_pivot_naive()
# finds a guaranteed non-zero pivot when the
# some of the candidate pivots are symbolic expressions.
# Keyword argument: simpfunc=_simplify indicates that the search
# should attempt to simplify candidate pivots.
x = Symbol('x')
column = Matrix(3, 1,
[x,
cos(x)**2+sin(x)**2+x**2,
cos(x)**2+sin(x)**2])
pivot_offset, pivot_val, pivot_assumed_nonzero, simplified =\
_find_reasonable_pivot_naive(column, simpfunc=_simplify)
assert pivot_val == 1
def test_find_reasonable_pivot_naive_simplifies():
# Test if matrices._find_reasonable_pivot_naive()
# simplifies candidate pivots, and reports
# their offsets correctly.
x = Symbol('x')
column = Matrix(3, 1,
[x,
cos(x)**2+sin(x)**2+x,
cos(x)**2+sin(x)**2])
pivot_offset, pivot_val, pivot_assumed_nonzero, simplified =\
_find_reasonable_pivot_naive(column, simpfunc=_simplify)
assert len(simplified) == 2
assert simplified[0][0] == 1
assert simplified[0][1] == 1+x
assert simplified[1][0] == 2
assert simplified[1][1] == 1
def test_errors():
raises(ValueError, lambda: Matrix([[1, 2], [1]]))
raises(IndexError, lambda: Matrix([[1, 2]])[1.2, 5])
raises(IndexError, lambda: Matrix([[1, 2]])[1, 5.2])
raises(ValueError, lambda: randMatrix(3, c=4, symmetric=True))
raises(ValueError, lambda: Matrix([1, 2]).reshape(4, 6))
raises(ShapeError,
lambda: Matrix([[1, 2], [3, 4]]).copyin_matrix([1, 0], Matrix([1, 2])))
raises(TypeError, lambda: Matrix([[1, 2], [3, 4]]).copyin_list([0,
1], set()))
raises(NonSquareMatrixError, lambda: Matrix([[1, 2, 3], [2, 3, 0]]).inv())
raises(ShapeError,
lambda: Matrix(1, 2, [1, 2]).row_join(Matrix([[1, 2], [3, 4]])))
raises(
ShapeError, lambda: Matrix([1, 2]).col_join(Matrix([[1, 2], [3, 4]])))
raises(ShapeError, lambda: Matrix([1]).row_insert(1, Matrix([[1,
2], [3, 4]])))
raises(ShapeError, lambda: Matrix([1]).col_insert(1, Matrix([[1,
2], [3, 4]])))
raises(NonSquareMatrixError, lambda: Matrix([1, 2]).trace())
raises(TypeError, lambda: Matrix([1]).applyfunc(1))
raises(ValueError, lambda: Matrix([[1, 2], [3, 4]]).minor(4, 5))
raises(ValueError, lambda: Matrix([[1, 2], [3, 4]]).minor_submatrix(4, 5))
raises(TypeError, lambda: Matrix([1, 2, 3]).cross(1))
raises(TypeError, lambda: Matrix([1, 2, 3]).dot(1))
raises(ShapeError, lambda: Matrix([1, 2, 3]).dot(Matrix([1, 2])))
raises(ShapeError, lambda: Matrix([1, 2]).dot([]))
raises(TypeError, lambda: Matrix([1, 2]).dot('a'))
with warns_deprecated_sympy():
Matrix([[1, 2], [3, 4]]).dot(Matrix([[4, 3], [1, 2]]))
raises(ShapeError, lambda: Matrix([1, 2]).dot([1, 2, 3]))
raises(NonSquareMatrixError, lambda: Matrix([1, 2, 3]).exp())
raises(ShapeError, lambda: Matrix([[1, 2], [3, 4]]).normalized())
raises(ValueError, lambda: Matrix([1, 2]).inv(method='not a method'))
raises(NonSquareMatrixError, lambda: Matrix([1, 2]).inverse_GE())
raises(ValueError, lambda: Matrix([[1, 2], [1, 2]]).inverse_GE())
raises(NonSquareMatrixError, lambda: Matrix([1, 2]).inverse_ADJ())
raises(ValueError, lambda: Matrix([[1, 2], [1, 2]]).inverse_ADJ())
raises(NonSquareMatrixError, lambda: Matrix([1, 2]).inverse_LU())
raises(NonSquareMatrixError, lambda: Matrix([1, 2]).is_nilpotent())
raises(NonSquareMatrixError, lambda: Matrix([1, 2]).det())
raises(ValueError,
lambda: Matrix([[1, 2], [3, 4]]).det(method='Not a real method'))
raises(ValueError,
lambda: Matrix([[1, 2, 3, 4], [5, 6, 7, 8],
[9, 10, 11, 12], [13, 14, 15, 16]]).det(iszerofunc="Not function"))
raises(ValueError,
lambda: Matrix([[1, 2, 3, 4], [5, 6, 7, 8],
[9, 10, 11, 12], [13, 14, 15, 16]]).det(iszerofunc=False))
raises(ValueError,
lambda: hessian(Matrix([[1, 2], [3, 4]]), Matrix([[1, 2], [2, 1]])))
raises(ValueError, lambda: hessian(Matrix([[1, 2], [3, 4]]), []))
raises(ValueError, lambda: hessian(Symbol('x')**2, 'a'))
raises(IndexError, lambda: eye(3)[5, 2])
raises(IndexError, lambda: eye(3)[2, 5])
M = Matrix(((1, 2, 3, 4), (5, 6, 7, 8), (9, 10, 11, 12), (13, 14, 15, 16)))
raises(ValueError, lambda: M.det('method=LU_decomposition()'))
V = Matrix([[10, 10, 10]])
M = Matrix([[1, 2, 3], [2, 3, 4], [3, 4, 5]])
raises(ValueError, lambda: M.row_insert(4.7, V))
M = Matrix([[1, 2, 3], [2, 3, 4], [3, 4, 5]])
raises(ValueError, lambda: M.col_insert(-4.2, V))
def test_len():
assert len(Matrix()) == 0
assert len(Matrix([[1, 2]])) == len(Matrix([[1], [2]])) == 2
assert len(Matrix(0, 2, lambda i, j: 0)) == \
len(Matrix(2, 0, lambda i, j: 0)) == 0
assert len(Matrix([[0, 1, 2], [3, 4, 5]])) == 6
assert Matrix([1]) == Matrix([[1]])
assert not Matrix()
assert Matrix() == Matrix([])
def test_integrate():
A = Matrix(((1, 4, x), (y, 2, 4), (10, 5, x**2)))
assert A.integrate(x) == \
Matrix(((x, 4*x, x**2/2), (x*y, 2*x, 4*x), (10*x, 5*x, x**3/3)))
assert A.integrate(y) == \
Matrix(((y, 4*y, x*y), (y**2/2, 2*y, 4*y), (10*y, 5*y, y*x**2)))
def test_limit():
A = Matrix(((1, 4, sin(x)/x), (y, 2, 4), (10, 5, x**2 + 1)))
assert A.limit(x, 0) == Matrix(((1, 4, 1), (y, 2, 4), (10, 5, 1)))
def test_diff():
A = MutableDenseMatrix(((1, 4, x), (y, 2, 4), (10, 5, x**2 + 1)))
assert isinstance(A.diff(x), type(A))
assert A.diff(x) == MutableDenseMatrix(((0, 0, 1), (0, 0, 0), (0, 0, 2*x)))
assert A.diff(y) == MutableDenseMatrix(((0, 0, 0), (1, 0, 0), (0, 0, 0)))
assert diff(A, x) == MutableDenseMatrix(((0, 0, 1), (0, 0, 0), (0, 0, 2*x)))
assert diff(A, y) == MutableDenseMatrix(((0, 0, 0), (1, 0, 0), (0, 0, 0)))
A_imm = A.as_immutable()
assert isinstance(A_imm.diff(x), type(A_imm))
assert A_imm.diff(x) == ImmutableDenseMatrix(((0, 0, 1), (0, 0, 0), (0, 0, 2*x)))
assert A_imm.diff(y) == ImmutableDenseMatrix(((0, 0, 0), (1, 0, 0), (0, 0, 0)))
assert diff(A_imm, x) == ImmutableDenseMatrix(((0, 0, 1), (0, 0, 0), (0, 0, 2*x)))
assert diff(A_imm, y) == ImmutableDenseMatrix(((0, 0, 0), (1, 0, 0), (0, 0, 0)))
def test_diff_by_matrix():
# Derive matrix by matrix:
A = MutableDenseMatrix([[x, y], [z, t]])
assert A.diff(A) == Array([[[[1, 0], [0, 0]], [[0, 1], [0, 0]]], [[[0, 0], [1, 0]], [[0, 0], [0, 1]]]])
assert diff(A, A) == Array([[[[1, 0], [0, 0]], [[0, 1], [0, 0]]], [[[0, 0], [1, 0]], [[0, 0], [0, 1]]]])
A_imm = A.as_immutable()
assert A_imm.diff(A_imm) == Array([[[[1, 0], [0, 0]], [[0, 1], [0, 0]]], [[[0, 0], [1, 0]], [[0, 0], [0, 1]]]])
assert diff(A_imm, A_imm) == Array([[[[1, 0], [0, 0]], [[0, 1], [0, 0]]], [[[0, 0], [1, 0]], [[0, 0], [0, 1]]]])
# Derive a constant matrix:
assert A.diff(a) == MutableDenseMatrix([[0, 0], [0, 0]])
B = ImmutableDenseMatrix([a, b])
assert A.diff(B) == Array.zeros(2, 1, 2, 2)
assert A.diff(A) == Array([[[[1, 0], [0, 0]], [[0, 1], [0, 0]]], [[[0, 0], [1, 0]], [[0, 0], [0, 1]]]])
# Test diff with tuples:
dB = B.diff([[a, b]])
assert dB.shape == (2, 2, 1)
assert dB == Array([[[1], [0]], [[0], [1]]])
f = Function("f")
fxyz = f(x, y, z)
assert fxyz.diff([[x, y, z]]) == Array([fxyz.diff(x), fxyz.diff(y), fxyz.diff(z)])
assert fxyz.diff(([x, y, z], 2)) == Array([
[fxyz.diff(x, 2), fxyz.diff(x, y), fxyz.diff(x, z)],
[fxyz.diff(x, y), fxyz.diff(y, 2), fxyz.diff(y, z)],
[fxyz.diff(x, z), fxyz.diff(z, y), fxyz.diff(z, 2)],
])
expr = sin(x)*exp(y)
assert expr.diff([[x, y]]) == Array([cos(x)*exp(y), sin(x)*exp(y)])
assert expr.diff(y, ((x, y),)) == Array([cos(x)*exp(y), sin(x)*exp(y)])
assert expr.diff(x, ((x, y),)) == Array([-sin(x)*exp(y), cos(x)*exp(y)])
assert expr.diff(((y, x),), [[x, y]]) == Array([[cos(x)*exp(y), -sin(x)*exp(y)], [sin(x)*exp(y), cos(x)*exp(y)]])
# Test different notations:
fxyz.diff(x).diff(y).diff(x) == fxyz.diff(((x, y, z),), 3)[0, 1, 0]
fxyz.diff(z).diff(y).diff(x) == fxyz.diff(((x, y, z),), 3)[2, 1, 0]
fxyz.diff([[x, y, z]], ((z, y, x),)) == Array([[fxyz.diff(i).diff(j) for i in (x, y, z)] for j in (z, y, x)])
# Test scalar derived by matrix remains matrix:
res = x.diff(Matrix([[x, y]]))
assert isinstance(res, ImmutableDenseMatrix)
assert res == Matrix([[1, 0]])
res = (x**3).diff(Matrix([[x, y]]))
assert isinstance(res, ImmutableDenseMatrix)
assert res == Matrix([[3*x**2, 0]])
def test_getattr():
A = Matrix(((1, 4, x), (y, 2, 4), (10, 5, x**2 + 1)))
raises(AttributeError, lambda: A.nonexistantattribute)
assert getattr(A, 'diff')(x) == Matrix(((0, 0, 1), (0, 0, 0), (0, 0, 2*x)))
def test_hessenberg():
A = Matrix([[3, 4, 1], [2, 4, 5], [0, 1, 2]])
assert A.is_upper_hessenberg
A = A.T
assert A.is_lower_hessenberg
A[0, -1] = 1
assert A.is_lower_hessenberg is False
A = Matrix([[3, 4, 1], [2, 4, 5], [3, 1, 2]])
assert not A.is_upper_hessenberg
A = zeros(5, 2)
assert A.is_upper_hessenberg
def test_cholesky():
raises(NonSquareMatrixError, lambda: Matrix((1, 2)).cholesky())
raises(ValueError, lambda: Matrix(((1, 2), (3, 4))).cholesky())
raises(ValueError, lambda: Matrix(((5 + I, 0), (0, 1))).cholesky())
raises(ValueError, lambda: Matrix(((1, 5), (5, 1))).cholesky())
raises(ValueError, lambda: Matrix(((1, 2), (3, 4))).cholesky(hermitian=False))
assert Matrix(((5 + I, 0), (0, 1))).cholesky(hermitian=False) == Matrix([
[sqrt(5 + I), 0], [0, 1]])
A = Matrix(((1, 5), (5, 1)))
L = A.cholesky(hermitian=False)
assert L == Matrix([[1, 0], [5, 2*sqrt(6)*I]])
assert L*L.T == A
A = Matrix(((25, 15, -5), (15, 18, 0), (-5, 0, 11)))
L = A.cholesky()
assert L * L.T == A
assert L.is_lower
assert L == Matrix([[5, 0, 0], [3, 3, 0], [-1, 1, 3]])
A = Matrix(((4, -2*I, 2 + 2*I), (2*I, 2, -1 + I), (2 - 2*I, -1 - I, 11)))
assert A.cholesky().expand() == Matrix(((2, 0, 0), (I, 1, 0), (1 - I, 0, 3)))
raises(NonSquareMatrixError, lambda: SparseMatrix((1, 2)).cholesky())
raises(ValueError, lambda: SparseMatrix(((1, 2), (3, 4))).cholesky())
raises(ValueError, lambda: SparseMatrix(((5 + I, 0), (0, 1))).cholesky())
raises(ValueError, lambda: SparseMatrix(((1, 5), (5, 1))).cholesky())
raises(ValueError, lambda: SparseMatrix(((1, 2), (3, 4))).cholesky(hermitian=False))
assert SparseMatrix(((5 + I, 0), (0, 1))).cholesky(hermitian=False) == Matrix([
[sqrt(5 + I), 0], [0, 1]])
A = SparseMatrix(((1, 5), (5, 1)))
L = A.cholesky(hermitian=False)
assert L == Matrix([[1, 0], [5, 2*sqrt(6)*I]])
assert L*L.T == A
A = SparseMatrix(((25, 15, -5), (15, 18, 0), (-5, 0, 11)))
L = A.cholesky()
assert L * L.T == A
assert L.is_lower
assert L == Matrix([[5, 0, 0], [3, 3, 0], [-1, 1, 3]])
A = SparseMatrix(((4, -2*I, 2 + 2*I), (2*I, 2, -1 + I), (2 - 2*I, -1 - I, 11)))
assert A.cholesky() == Matrix(((2, 0, 0), (I, 1, 0), (1 - I, 0, 3)))
def test_matrix_norm():
# Vector Tests
# Test columns and symbols
x = Symbol('x', real=True)
v = Matrix([cos(x), sin(x)])
assert trigsimp(v.norm(2)) == 1
assert v.norm(10) == Pow(cos(x)**10 + sin(x)**10, Rational(1, 10))
# Test Rows
A = Matrix([[5, Rational(3, 2)]])
assert A.norm() == Pow(25 + Rational(9, 4), S.Half)
assert A.norm(oo) == max(A._mat)
assert A.norm(-oo) == min(A._mat)
# Matrix Tests
# Intuitive test
A = Matrix([[1, 1], [1, 1]])
assert A.norm(2) == 2
assert A.norm(-2) == 0
assert A.norm('frobenius') == 2
assert eye(10).norm(2) == eye(10).norm(-2) == 1
assert A.norm(oo) == 2
# Test with Symbols and more complex entries
A = Matrix([[3, y, y], [x, S.Half, -pi]])
assert (A.norm('fro')
== sqrt(Rational(37, 4) + 2*abs(y)**2 + pi**2 + x**2))
# Check non-square
A = Matrix([[1, 2, -3], [4, 5, Rational(13, 2)]])
assert A.norm(2) == sqrt(Rational(389, 8) + sqrt(78665)/8)
assert A.norm(-2) is S.Zero
assert A.norm('frobenius') == sqrt(389)/2
# Test properties of matrix norms
# https://en.wikipedia.org/wiki/Matrix_norm#Definition
# Two matrices
A = Matrix([[1, 2], [3, 4]])
B = Matrix([[5, 5], [-2, 2]])
C = Matrix([[0, -I], [I, 0]])
D = Matrix([[1, 0], [0, -1]])
L = [A, B, C, D]
alpha = Symbol('alpha', real=True)
for order in ['fro', 2, -2]:
# Zero Check
assert zeros(3).norm(order) is S.Zero
# Check Triangle Inequality for all Pairs of Matrices
for X in L:
for Y in L:
dif = (X.norm(order) + Y.norm(order) -
(X + Y).norm(order))
assert (dif >= 0)
# Scalar multiplication linearity
for M in [A, B, C, D]:
dif = simplify((alpha*M).norm(order) -
abs(alpha) * M.norm(order))
assert dif == 0
# Test Properties of Vector Norms
# https://en.wikipedia.org/wiki/Vector_norm
# Two column vectors
a = Matrix([1, 1 - 1*I, -3])
b = Matrix([S.Half, 1*I, 1])
c = Matrix([-1, -1, -1])
d = Matrix([3, 2, I])
e = Matrix([Integer(1e2), Rational(1, 1e2), 1])
L = [a, b, c, d, e]
alpha = Symbol('alpha', real=True)
for order in [1, 2, -1, -2, S.Infinity, S.NegativeInfinity, pi]:
# Zero Check
if order > 0:
assert Matrix([0, 0, 0]).norm(order) is S.Zero
# Triangle inequality on all pairs
if order >= 1: # Triangle InEq holds only for these norms
for X in L:
for Y in L:
dif = (X.norm(order) + Y.norm(order) -
(X + Y).norm(order))
assert simplify(dif >= 0) is S.true
# Linear to scalar multiplication
if order in [1, 2, -1, -2, S.Infinity, S.NegativeInfinity]:
for X in L:
dif = simplify((alpha*X).norm(order) -
(abs(alpha) * X.norm(order)))
assert dif == 0
# ord=1
M = Matrix(3, 3, [1, 3, 0, -2, -1, 0, 3, 9, 6])
assert M.norm(1) == 13
def test_condition_number():
x = Symbol('x', real=True)
A = eye(3)
A[0, 0] = 10
A[2, 2] = Rational(1, 10)
assert A.condition_number() == 100
A[1, 1] = x
assert A.condition_number() == Max(10, Abs(x)) / Min(Rational(1, 10), Abs(x))
M = Matrix([[cos(x), sin(x)], [-sin(x), cos(x)]])
Mc = M.condition_number()
assert all(Float(1.).epsilon_eq(Mc.subs(x, val).evalf()) for val in
[Rational(1, 5), S.Half, Rational(1, 10), pi/2, pi, pi*Rational(7, 4) ])
#issue 10782
assert Matrix([]).condition_number() == 0
def test_equality():
A = Matrix(((1, 2, 3), (4, 5, 6), (7, 8, 9)))
B = Matrix(((9, 8, 7), (6, 5, 4), (3, 2, 1)))
assert A == A[:, :]
assert not A != A[:, :]
assert not A == B
assert A != B
assert A != 10
assert not A == 10
# A SparseMatrix can be equal to a Matrix
C = SparseMatrix(((1, 0, 0), (0, 1, 0), (0, 0, 1)))
D = Matrix(((1, 0, 0), (0, 1, 0), (0, 0, 1)))
assert C == D
assert not C != D
def test_col_join():
assert eye(3).col_join(Matrix([[7, 7, 7]])) == \
Matrix([[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[7, 7, 7]])
def test_row_insert():
r4 = Matrix([[4, 4, 4]])
for i in range(-4, 5):
l = [1, 0, 0]
l.insert(i, 4)
assert flatten(eye(3).row_insert(i, r4).col(0).tolist()) == l
def test_col_insert():
c4 = Matrix([4, 4, 4])
for i in range(-4, 5):
l = [0, 0, 0]
l.insert(i, 4)
assert flatten(zeros(3).col_insert(i, c4).row(0).tolist()) == l
def test_normalized():
assert Matrix([3, 4]).normalized() == \
Matrix([Rational(3, 5), Rational(4, 5)])
# Zero vector trivial cases
assert Matrix([0, 0, 0]).normalized() == Matrix([0, 0, 0])
# Machine precision error truncation trivial cases
m = Matrix([0,0,1.e-100])
assert m.normalized(
iszerofunc=lambda x: x.evalf(n=10, chop=True).is_zero
) == Matrix([0, 0, 0])
def test_print_nonzero():
assert capture(lambda: eye(3).print_nonzero()) == \
'[X ]\n[ X ]\n[ X]\n'
assert capture(lambda: eye(3).print_nonzero('.')) == \
'[. ]\n[ . ]\n[ .]\n'
def test_zeros_eye():
assert Matrix.eye(3) == eye(3)
assert Matrix.zeros(3) == zeros(3)
assert ones(3, 4) == Matrix(3, 4, [1]*12)
i = Matrix([[1, 0], [0, 1]])
z = Matrix([[0, 0], [0, 0]])
for cls in classes:
m = cls.eye(2)
assert i == m # but m == i will fail if m is immutable
assert i == eye(2, cls=cls)
assert type(m) == cls
m = cls.zeros(2)
assert z == m
assert z == zeros(2, cls=cls)
assert type(m) == cls
def test_is_zero():
assert Matrix().is_zero_matrix
assert Matrix([[0, 0], [0, 0]]).is_zero_matrix
assert zeros(3, 4).is_zero_matrix
assert not eye(3).is_zero_matrix
assert Matrix([[x, 0], [0, 0]]).is_zero_matrix == None
assert SparseMatrix([[x, 0], [0, 0]]).is_zero_matrix == None
assert ImmutableMatrix([[x, 0], [0, 0]]).is_zero_matrix == None
assert ImmutableSparseMatrix([[x, 0], [0, 0]]).is_zero_matrix == None
assert Matrix([[x, 1], [0, 0]]).is_zero_matrix == False
a = Symbol('a', nonzero=True)
assert Matrix([[a, 0], [0, 0]]).is_zero_matrix == False
def test_rotation_matrices():
# This tests the rotation matrices by rotating about an axis and back.
theta = pi/3
r3_plus = rot_axis3(theta)
r3_minus = rot_axis3(-theta)
r2_plus = rot_axis2(theta)
r2_minus = rot_axis2(-theta)
r1_plus = rot_axis1(theta)
r1_minus = rot_axis1(-theta)
assert r3_minus*r3_plus*eye(3) == eye(3)
assert r2_minus*r2_plus*eye(3) == eye(3)
assert r1_minus*r1_plus*eye(3) == eye(3)
# Check the correctness of the trace of the rotation matrix
assert r1_plus.trace() == 1 + 2*cos(theta)
assert r2_plus.trace() == 1 + 2*cos(theta)
assert r3_plus.trace() == 1 + 2*cos(theta)
# Check that a rotation with zero angle doesn't change anything.
assert rot_axis1(0) == eye(3)
assert rot_axis2(0) == eye(3)
assert rot_axis3(0) == eye(3)
def test_DeferredVector():
assert str(DeferredVector("vector")[4]) == "vector[4]"
assert sympify(DeferredVector("d")) == DeferredVector("d")
raises(IndexError, lambda: DeferredVector("d")[-1])
assert str(DeferredVector("d")) == "d"
assert repr(DeferredVector("test")) == "DeferredVector('test')"
def test_DeferredVector_not_iterable():
assert not iterable(DeferredVector('X'))
def test_DeferredVector_Matrix():
raises(TypeError, lambda: Matrix(DeferredVector("V")))
def test_GramSchmidt():
R = Rational
m1 = Matrix(1, 2, [1, 2])
m2 = Matrix(1, 2, [2, 3])
assert GramSchmidt([m1, m2]) == \
[Matrix(1, 2, [1, 2]), Matrix(1, 2, [R(2)/5, R(-1)/5])]
assert GramSchmidt([m1.T, m2.T]) == \
[Matrix(2, 1, [1, 2]), Matrix(2, 1, [R(2)/5, R(-1)/5])]
# from wikipedia
assert GramSchmidt([Matrix([3, 1]), Matrix([2, 2])], True) == [
Matrix([3*sqrt(10)/10, sqrt(10)/10]),
Matrix([-sqrt(10)/10, 3*sqrt(10)/10])]
def test_casoratian():
assert casoratian([1, 2, 3, 4], 1) == 0
assert casoratian([1, 2, 3, 4], 1, zero=False) == 0
def test_zero_dimension_multiply():
assert (Matrix()*zeros(0, 3)).shape == (0, 3)
assert zeros(3, 0)*zeros(0, 3) == zeros(3, 3)
assert zeros(0, 3)*zeros(3, 0) == Matrix()
def test_slice_issue_2884():
m = Matrix(2, 2, range(4))
assert m[1, :] == Matrix([[2, 3]])
assert m[-1, :] == Matrix([[2, 3]])
assert m[:, 1] == Matrix([[1, 3]]).T
assert m[:, -1] == Matrix([[1, 3]]).T
raises(IndexError, lambda: m[2, :])
raises(IndexError, lambda: m[2, 2])
def test_slice_issue_3401():
assert zeros(0, 3)[:, -1].shape == (0, 1)
assert zeros(3, 0)[0, :] == Matrix(1, 0, [])
def test_copyin():
s = zeros(3, 3)
s[3] = 1
assert s[:, 0] == Matrix([0, 1, 0])
assert s[3] == 1
assert s[3: 4] == [1]
s[1, 1] = 42
assert s[1, 1] == 42
assert s[1, 1:] == Matrix([[42, 0]])
s[1, 1:] = Matrix([[5, 6]])
assert s[1, :] == Matrix([[1, 5, 6]])
s[1, 1:] = [[42, 43]]
assert s[1, :] == Matrix([[1, 42, 43]])
s[0, 0] = 17
assert s[:, :1] == Matrix([17, 1, 0])
s[0, 0] = [1, 1, 1]
assert s[:, 0] == Matrix([1, 1, 1])
s[0, 0] = Matrix([1, 1, 1])
assert s[:, 0] == Matrix([1, 1, 1])
s[0, 0] = SparseMatrix([1, 1, 1])
assert s[:, 0] == Matrix([1, 1, 1])
def test_invertible_check():
# sometimes a singular matrix will have a pivot vector shorter than
# the number of rows in a matrix...
assert Matrix([[1, 2], [1, 2]]).rref() == (Matrix([[1, 2], [0, 0]]), (0,))
raises(ValueError, lambda: Matrix([[1, 2], [1, 2]]).inv())
m = Matrix([
[-1, -1, 0],
[ x, 1, 1],
[ 1, x, -1],
])
assert len(m.rref()[1]) != m.rows
# in addition, unless simplify=True in the call to rref, the identity
# matrix will be returned even though m is not invertible
assert m.rref()[0] != eye(3)
assert m.rref(simplify=signsimp)[0] != eye(3)
raises(ValueError, lambda: m.inv(method="ADJ"))
raises(ValueError, lambda: m.inv(method="GE"))
raises(ValueError, lambda: m.inv(method="LU"))
def test_issue_3959():
x, y = symbols('x, y')
e = x*y
assert e.subs(x, Matrix([3, 5, 3])) == Matrix([3, 5, 3])*y
def test_issue_5964():
assert str(Matrix([[1, 2], [3, 4]])) == 'Matrix([[1, 2], [3, 4]])'
def test_issue_7604():
x, y = symbols("x y")
assert sstr(Matrix([[x, 2*y], [y**2, x + 3]])) == \
'Matrix([\n[ x, 2*y],\n[y**2, x + 3]])'
def test_is_Identity():
assert eye(3).is_Identity
assert eye(3).as_immutable().is_Identity
assert not zeros(3).is_Identity
assert not ones(3).is_Identity
# issue 6242
assert not Matrix([[1, 0, 0]]).is_Identity
# issue 8854
assert SparseMatrix(3,3, {(0,0):1, (1,1):1, (2,2):1}).is_Identity
assert not SparseMatrix(2,3, range(6)).is_Identity
assert not SparseMatrix(3,3, {(0,0):1, (1,1):1}).is_Identity
assert not SparseMatrix(3,3, {(0,0):1, (1,1):1, (2,2):1, (0,1):2, (0,2):3}).is_Identity
def test_dot():
assert ones(1, 3).dot(ones(3, 1)) == 3
assert ones(1, 3).dot([1, 1, 1]) == 3
assert Matrix([1, 2, 3]).dot(Matrix([1, 2, 3])) == 14
assert Matrix([1, 2, 3*I]).dot(Matrix([I, 2, 3*I])) == -5 + I
assert Matrix([1, 2, 3*I]).dot(Matrix([I, 2, 3*I]), hermitian=False) == -5 + I
assert Matrix([1, 2, 3*I]).dot(Matrix([I, 2, 3*I]), hermitian=True) == 13 + I
assert Matrix([1, 2, 3*I]).dot(Matrix([I, 2, 3*I]), hermitian=True, conjugate_convention="physics") == 13 - I
assert Matrix([1, 2, 3*I]).dot(Matrix([4, 5*I, 6]), hermitian=True, conjugate_convention="right") == 4 + 8*I
assert Matrix([1, 2, 3*I]).dot(Matrix([4, 5*I, 6]), hermitian=True, conjugate_convention="left") == 4 - 8*I
assert Matrix([I, 2*I]).dot(Matrix([I, 2*I]), hermitian=False, conjugate_convention="left") == -5
assert Matrix([I, 2*I]).dot(Matrix([I, 2*I]), conjugate_convention="left") == 5
raises(ValueError, lambda: Matrix([1, 2]).dot(Matrix([3, 4]), hermitian=True, conjugate_convention="test"))
def test_dual():
B_x, B_y, B_z, E_x, E_y, E_z = symbols(
'B_x B_y B_z E_x E_y E_z', real=True)
F = Matrix((
( 0, E_x, E_y, E_z),
(-E_x, 0, B_z, -B_y),
(-E_y, -B_z, 0, B_x),
(-E_z, B_y, -B_x, 0)
))
Fd = Matrix((
( 0, -B_x, -B_y, -B_z),
(B_x, 0, E_z, -E_y),
(B_y, -E_z, 0, E_x),
(B_z, E_y, -E_x, 0)
))
assert F.dual().equals(Fd)
assert eye(3).dual().equals(zeros(3))
assert F.dual().dual().equals(-F)
def test_anti_symmetric():
assert Matrix([1, 2]).is_anti_symmetric() is False
m = Matrix(3, 3, [0, x**2 + 2*x + 1, y, -(x + 1)**2, 0, x*y, -y, -x*y, 0])
assert m.is_anti_symmetric() is True
assert m.is_anti_symmetric(simplify=False) is False
assert m.is_anti_symmetric(simplify=lambda x: x) is False
# tweak to fail
m[2, 1] = -m[2, 1]
assert m.is_anti_symmetric() is False
# untweak
m[2, 1] = -m[2, 1]
m = m.expand()
assert m.is_anti_symmetric(simplify=False) is True
m[0, 0] = 1
assert m.is_anti_symmetric() is False
def test_normalize_sort_diogonalization():
A = Matrix(((1, 2), (2, 1)))
P, Q = A.diagonalize(normalize=True)
assert P*P.T == P.T*P == eye(P.cols)
P, Q = A.diagonalize(normalize=True, sort=True)
assert P*P.T == P.T*P == eye(P.cols)
assert P*Q*P.inv() == A
def test_issue_5321():
raises(ValueError, lambda: Matrix([[1, 2, 3], Matrix(0, 1, [])]))
def test_issue_5320():
assert Matrix.hstack(eye(2), 2*eye(2)) == Matrix([
[1, 0, 2, 0],
[0, 1, 0, 2]
])
assert Matrix.vstack(eye(2), 2*eye(2)) == Matrix([
[1, 0],
[0, 1],
[2, 0],
[0, 2]
])
cls = SparseMatrix
assert cls.hstack(cls(eye(2)), cls(2*eye(2))) == Matrix([
[1, 0, 2, 0],
[0, 1, 0, 2]
])
def test_issue_11944():
A = Matrix([[1]])
AIm = sympify(A)
assert Matrix.hstack(AIm, A) == Matrix([[1, 1]])
assert Matrix.vstack(AIm, A) == Matrix([[1], [1]])
def test_cross():
a = [1, 2, 3]
b = [3, 4, 5]
col = Matrix([-2, 4, -2])
row = col.T
def test(M, ans):
assert ans == M
assert type(M) == cls
for cls in classes:
A = cls(a)
B = cls(b)
test(A.cross(B), col)
test(A.cross(B.T), col)
test(A.T.cross(B.T), row)
test(A.T.cross(B), row)
raises(ShapeError, lambda:
Matrix(1, 2, [1, 1]).cross(Matrix(1, 2, [1, 1])))
def test_hash():
for cls in classes[-2:]:
s = {cls.eye(1), cls.eye(1)}
assert len(s) == 1 and s.pop() == cls.eye(1)
# issue 3979
for cls in classes[:2]:
assert not isinstance(cls.eye(1), Hashable)
@XFAIL
def test_issue_3979():
# when this passes, delete this and change the [1:2]
# to [:2] in the test_hash above for issue 3979
cls = classes[0]
raises(AttributeError, lambda: hash(cls.eye(1)))
def test_adjoint():
dat = [[0, I], [1, 0]]
ans = Matrix([[0, 1], [-I, 0]])
for cls in classes:
assert ans == cls(dat).adjoint()
def test_simplify_immutable():
from sympy import simplify, sin, cos
assert simplify(ImmutableMatrix([[sin(x)**2 + cos(x)**2]])) == \
ImmutableMatrix([[1]])
def test_replace():
from sympy import symbols, Function, Matrix
F, G = symbols('F, G', cls=Function)
K = Matrix(2, 2, lambda i, j: G(i+j))
M = Matrix(2, 2, lambda i, j: F(i+j))
N = M.replace(F, G)
assert N == K
def test_replace_map():
from sympy import symbols, Function, Matrix
F, G = symbols('F, G', cls=Function)
K = Matrix(2, 2, [(G(0), {F(0): G(0)}), (G(1), {F(1): G(1)}), (G(1), {F(1)\
: G(1)}), (G(2), {F(2): G(2)})])
M = Matrix(2, 2, lambda i, j: F(i+j))
N = M.replace(F, G, True)
assert N == K
def test_atoms():
m = Matrix([[1, 2], [x, 1 - 1/x]])
assert m.atoms() == {S.One,S(2),S.NegativeOne, x}
assert m.atoms(Symbol) == {x}
def test_pinv():
# Pseudoinverse of an invertible matrix is the inverse.
A1 = Matrix([[a, b], [c, d]])
assert simplify(A1.pinv(method="RD")) == simplify(A1.inv())
# Test the four properties of the pseudoinverse for various matrices.
As = [Matrix([[13, 104], [2212, 3], [-3, 5]]),
Matrix([[1, 7, 9], [11, 17, 19]]),
Matrix([a, b])]
for A in As:
A_pinv = A.pinv(method="RD")
AAp = A * A_pinv
ApA = A_pinv * A
assert simplify(AAp * A) == A
assert simplify(ApA * A_pinv) == A_pinv
assert AAp.H == AAp
assert ApA.H == ApA
# XXX Pinv with diagonalization makes expression too complicated.
for A in As:
A_pinv = simplify(A.pinv(method="ED"))
AAp = A * A_pinv
ApA = A_pinv * A
assert simplify(AAp * A) == A
assert simplify(ApA * A_pinv) == A_pinv
assert AAp.H == AAp
assert ApA.H == ApA
# XXX Computing pinv using diagonalization makes an expression that
# is too complicated to simplify.
# A1 = Matrix([[a, b], [c, d]])
# assert simplify(A1.pinv(method="ED")) == simplify(A1.inv())
# so this is tested numerically at a fixed random point
from sympy.core.numbers import comp
q = A1.pinv(method="ED")
w = A1.inv()
reps = {a: -73633, b: 11362, c: 55486, d: 62570}
assert all(
comp(i.n(), j.n())
for i, j in zip(q.subs(reps), w.subs(reps))
)
@XFAIL
def test_pinv_rank_deficient_when_diagonalization_fails():
# Test the four properties of the pseudoinverse for matrices when
# diagonalization of A.H*A fails.
As = [Matrix([
[61, 89, 55, 20, 71, 0],
[62, 96, 85, 85, 16, 0],
[69, 56, 17, 4, 54, 0],
[10, 54, 91, 41, 71, 0],
[ 7, 30, 10, 48, 90, 0],
[0,0,0,0,0,0]])]
for A in As:
A_pinv = A.pinv(method="ED")
AAp = A * A_pinv
ApA = A_pinv * A
assert simplify(AAp * A) == A
assert simplify(ApA * A_pinv) == A_pinv
assert AAp.H == AAp
assert ApA.H == ApA
def test_issue_7201():
assert ones(0, 1) + ones(0, 1) == Matrix(0, 1, [])
assert ones(1, 0) + ones(1, 0) == Matrix(1, 0, [])
def test_free_symbols():
for M in ImmutableMatrix, ImmutableSparseMatrix, Matrix, SparseMatrix:
assert M([[x], [0]]).free_symbols == {x}
def test_from_ndarray():
"""See issue 7465."""
try:
from numpy import array
except ImportError:
skip('NumPy must be available to test creating matrices from ndarrays')
assert Matrix(array([1, 2, 3])) == Matrix([1, 2, 3])
assert Matrix(array([[1, 2, 3]])) == Matrix([[1, 2, 3]])
assert Matrix(array([[1, 2, 3], [4, 5, 6]])) == \
Matrix([[1, 2, 3], [4, 5, 6]])
assert Matrix(array([x, y, z])) == Matrix([x, y, z])
raises(NotImplementedError,
lambda: Matrix(array([[[1, 2], [3, 4]], [[5, 6], [7, 8]]])))
assert Matrix([array([1, 2]), array([3, 4])]) == Matrix([[1, 2], [3, 4]])
assert Matrix([array([1, 2]), [3, 4]]) == Matrix([[1, 2], [3, 4]])
assert Matrix([array([]), array([])]) == Matrix([])
def test_17522_numpy():
from sympy.matrices.common import _matrixify
try:
from numpy import array, matrix
except ImportError:
skip('NumPy must be available to test indexing matrixified NumPy ndarrays and matrices')
m = _matrixify(array([[1, 2], [3, 4]]))
assert m[3] == 4
assert list(m) == [1, 2, 3, 4]
m = _matrixify(matrix([[1, 2], [3, 4]]))
assert m[3] == 4
assert list(m) == [1, 2, 3, 4]
def test_17522_mpmath():
from sympy.matrices.common import _matrixify
try:
from mpmath import matrix
except ImportError:
skip('mpmath must be available to test indexing matrixified mpmath matrices')
m = _matrixify(matrix([[1, 2], [3, 4]]))
assert m[3] == 4
assert list(m) == [1, 2, 3, 4]
def test_17522_scipy():
from sympy.matrices.common import _matrixify
try:
from scipy.sparse import csr_matrix
except ImportError:
skip('SciPy must be available to test indexing matrixified SciPy sparse matrices')
m = _matrixify(csr_matrix([[1, 2], [3, 4]]))
assert m[3] == 4
assert list(m) == [1, 2, 3, 4]
def test_hermitian():
a = Matrix([[1, I], [-I, 1]])
assert a.is_hermitian
a[0, 0] = 2*I
assert a.is_hermitian is False
a[0, 0] = x
assert a.is_hermitian is None
a[0, 1] = a[1, 0]*I
assert a.is_hermitian is False
def test_doit():
a = Matrix([[Add(x,x, evaluate=False)]])
assert a[0] != 2*x
assert a.doit() == Matrix([[2*x]])
def test_issue_9457_9467_9876():
# for row_del(index)
M = Matrix([[1, 2, 3], [2, 3, 4], [3, 4, 5]])
M.row_del(1)
assert M == Matrix([[1, 2, 3], [3, 4, 5]])
N = Matrix([[1, 2, 3], [2, 3, 4], [3, 4, 5]])
N.row_del(-2)
assert N == Matrix([[1, 2, 3], [3, 4, 5]])
O = Matrix([[1, 2, 3], [5, 6, 7], [9, 10, 11]])
O.row_del(-1)
assert O == Matrix([[1, 2, 3], [5, 6, 7]])
P = Matrix([[1, 2, 3], [2, 3, 4], [3, 4, 5]])
raises(IndexError, lambda: P.row_del(10))
Q = Matrix([[1, 2, 3], [2, 3, 4], [3, 4, 5]])
raises(IndexError, lambda: Q.row_del(-10))
# for col_del(index)
M = Matrix([[1, 2, 3], [2, 3, 4], [3, 4, 5]])
M.col_del(1)
assert M == Matrix([[1, 3], [2, 4], [3, 5]])
N = Matrix([[1, 2, 3], [2, 3, 4], [3, 4, 5]])
N.col_del(-2)
assert N == Matrix([[1, 3], [2, 4], [3, 5]])
P = Matrix([[1, 2, 3], [2, 3, 4], [3, 4, 5]])
raises(IndexError, lambda: P.col_del(10))
Q = Matrix([[1, 2, 3], [2, 3, 4], [3, 4, 5]])
raises(IndexError, lambda: Q.col_del(-10))
def test_issue_9422():
x, y = symbols('x y', commutative=False)
a, b = symbols('a b')
M = eye(2)
M1 = Matrix(2, 2, [x, y, y, z])
assert y*x*M != x*y*M
assert b*a*M == a*b*M
assert x*M1 != M1*x
assert a*M1 == M1*a
assert y*x*M == Matrix([[y*x, 0], [0, y*x]])
def test_issue_10770():
M = Matrix([])
a = ['col_insert', 'row_join'], Matrix([9, 6, 3])
b = ['row_insert', 'col_join'], a[1].T
c = ['row_insert', 'col_insert'], Matrix([[1, 2], [3, 4]])
for ops, m in (a, b, c):
for op in ops:
f = getattr(M, op)
new = f(m) if 'join' in op else f(42, m)
assert new == m and id(new) != id(m)
def test_issue_10658():
A = Matrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
assert A.extract([0, 1, 2], [True, True, False]) == \
Matrix([[1, 2], [4, 5], [7, 8]])
assert A.extract([0, 1, 2], [True, False, False]) == Matrix([[1], [4], [7]])
assert A.extract([True, False, False], [0, 1, 2]) == Matrix([[1, 2, 3]])
assert A.extract([True, False, True], [0, 1, 2]) == \
Matrix([[1, 2, 3], [7, 8, 9]])
assert A.extract([0, 1, 2], [False, False, False]) == Matrix(3, 0, [])
assert A.extract([False, False, False], [0, 1, 2]) == Matrix(0, 3, [])
assert A.extract([True, False, True], [False, True, False]) == \
Matrix([[2], [8]])
def test_opportunistic_simplification():
# this test relates to issue #10718, #9480, #11434
# issue #9480
m = Matrix([[-5 + 5*sqrt(2), -5], [-5*sqrt(2)/2 + 5, -5*sqrt(2)/2]])
assert m.rank() == 1
# issue #10781
m = Matrix([[3+3*sqrt(3)*I, -9],[4,-3+3*sqrt(3)*I]])
assert simplify(m.rref()[0] - Matrix([[1, -9/(3 + 3*sqrt(3)*I)], [0, 0]])) == zeros(2, 2)
# issue #11434
ax,ay,bx,by,cx,cy,dx,dy,ex,ey,t0,t1 = symbols('a_x a_y b_x b_y c_x c_y d_x d_y e_x e_y t_0 t_1')
m = Matrix([[ax,ay,ax*t0,ay*t0,0],[bx,by,bx*t0,by*t0,0],[cx,cy,cx*t0,cy*t0,1],[dx,dy,dx*t0,dy*t0,1],[ex,ey,2*ex*t1-ex*t0,2*ey*t1-ey*t0,0]])
assert m.rank() == 4
def test_partial_pivoting():
# example from https://en.wikipedia.org/wiki/Pivot_element
# partial pivoting with back substitution gives a perfect result
# naive pivoting give an error ~1e-13, so anything better than
# 1e-15 is good
mm=Matrix([[0.003 ,59.14, 59.17],[ 5.291, -6.13,46.78]])
assert (mm.rref()[0] - Matrix([[1.0, 0, 10.0], [ 0, 1.0, 1.0]])).norm() < 1e-15
# issue #11549
m_mixed = Matrix([[6e-17, 1.0, 4],[ -1.0, 0, 8],[ 0, 0, 1]])
m_float = Matrix([[6e-17, 1.0, 4.],[ -1.0, 0., 8.],[ 0., 0., 1.]])
m_inv = Matrix([[ 0, -1.0, 8.0],[1.0, 6.0e-17, -4.0],[ 0, 0, 1]])
# this example is numerically unstable and involves a matrix with a norm >= 8,
# this comparing the difference of the results with 1e-15 is numerically sound.
assert (m_mixed.inv() - m_inv).norm() < 1e-15
assert (m_float.inv() - m_inv).norm() < 1e-15
def test_iszero_substitution():
""" When doing numerical computations, all elements that pass
the iszerofunc test should be set to numerically zero if they
aren't already. """
# Matrix from issue #9060
m = Matrix([[0.9, -0.1, -0.2, 0],[-0.8, 0.9, -0.4, 0],[-0.1, -0.8, 0.6, 0]])
m_rref = m.rref(iszerofunc=lambda x: abs(x)<6e-15)[0]
m_correct = Matrix([[1.0, 0, -0.301369863013699, 0],[ 0, 1.0, -0.712328767123288, 0],[ 0, 0, 0, 0]])
m_diff = m_rref - m_correct
assert m_diff.norm() < 1e-15
# if a zero-substitution wasn't made, this entry will be -1.11022302462516e-16
assert m_rref[2,2] == 0
def test_issue_11238():
from sympy import Point
xx = 8*tan(pi*Rational(13, 45))/(tan(pi*Rational(13, 45)) + sqrt(3))
yy = (-8*sqrt(3)*tan(pi*Rational(13, 45))**2 + 24*tan(pi*Rational(13, 45)))/(-3 + tan(pi*Rational(13, 45))**2)
p1 = Point(0, 0)
p2 = Point(1, -sqrt(3))
p0 = Point(xx,yy)
m1 = Matrix([p1 - simplify(p0), p2 - simplify(p0)])
m2 = Matrix([p1 - p0, p2 - p0])
m3 = Matrix([simplify(p1 - p0), simplify(p2 - p0)])
# This system has expressions which are zero and
# cannot be easily proved to be such, so without
# numerical testing, these assertions will fail.
Z = lambda x: abs(x.n()) < 1e-20
assert m1.rank(simplify=True, iszerofunc=Z) == 1
assert m2.rank(simplify=True, iszerofunc=Z) == 1
assert m3.rank(simplify=True, iszerofunc=Z) == 1
def test_as_real_imag():
m1 = Matrix(2,2,[1,2,3,4])
m2 = m1*S.ImaginaryUnit
m3 = m1 + m2
for kls in classes:
a,b = kls(m3).as_real_imag()
assert list(a) == list(m1)
assert list(b) == list(m1)
def test_deprecated():
# Maintain tests for deprecated functions. We must capture
# the deprecation warnings. When the deprecated functionality is
# removed, the corresponding tests should be removed.
m = Matrix(3, 3, [0, 1, 0, -4, 4, 0, -2, 1, 2])
P, Jcells = m.jordan_cells()
assert Jcells[1] == Matrix(1, 1, [2])
assert Jcells[0] == Matrix(2, 2, [2, 1, 0, 2])
with warns_deprecated_sympy():
assert Matrix([[1,2],[3,4]]).dot(Matrix([[1,3],[4,5]])) == [10, 19, 14, 28]
def test_issue_14489():
from sympy import Mod
A = Matrix([-1, 1, 2])
B = Matrix([10, 20, -15])
assert Mod(A, 3) == Matrix([2, 1, 2])
assert Mod(B, 4) == Matrix([2, 0, 1])
def test_issue_14943():
# Test that __array__ accepts the optional dtype argument
try:
from numpy import array
except ImportError:
skip('NumPy must be available to test creating matrices from ndarrays')
M = Matrix([[1,2], [3,4]])
assert array(M, dtype=float).dtype.name == 'float64'
def test_case_6913():
m = MatrixSymbol('m', 1, 1)
a = Symbol("a")
a = m[0, 0]>0
assert str(a) == 'm[0, 0] > 0'
def test_issue_11948():
A = MatrixSymbol('A', 3, 3)
a = Wild('a')
assert A.match(a) == {a: A}
def test_gramschmidt_conjugate_dot():
vecs = [Matrix([1, I]), Matrix([1, -I])]
assert Matrix.orthogonalize(*vecs) == \
[Matrix([[1], [I]]), Matrix([[1], [-I]])]
mat = Matrix([[1, I], [1, -I]])
Q, R = mat.QRdecomposition()
assert Q * Q.H == Matrix.eye(2)
def test_issue_8207():
a = Matrix(MatrixSymbol('a', 3, 1))
b = Matrix(MatrixSymbol('b', 3, 1))
c = a.dot(b)
d = diff(c, a[0, 0])
e = diff(d, a[0, 0])
assert d == b[0, 0]
assert e == 0
def test_func():
from sympy.simplify.simplify import nthroot
A = Matrix([[1, 2],[0, 3]])
assert A.analytic_func(sin(x*t), x) == Matrix([[sin(t), sin(3*t) - sin(t)], [0, sin(3*t)]])
A = Matrix([[2, 1],[1, 2]])
assert (pi * A / 6).analytic_func(cos(x), x) == Matrix([[sqrt(3)/4, -sqrt(3)/4], [-sqrt(3)/4, sqrt(3)/4]])
raises(ValueError, lambda : zeros(5).analytic_func(log(x), x))
raises(ValueError, lambda : (A*x).analytic_func(log(x), x))
A = Matrix([[0, -1, -2, 3], [0, -1, -2, 3], [0, 1, 0, -1], [0, 0, -1, 1]])
assert A.analytic_func(exp(x), x) == A.exp()
raises(ValueError, lambda : A.analytic_func(sqrt(x), x))
A = Matrix([[41, 12],[12, 34]])
assert simplify(A.analytic_func(sqrt(x), x)**2) == A
A = Matrix([[3, -12, 4], [-1, 0, -2], [-1, 5, -1]])
assert simplify(A.analytic_func(nthroot(x, 3), x)**3) == A
A = Matrix([[2, 0, 0, 0], [1, 2, 0, 0], [0, 1, 3, 0], [0, 0, 1, 3]])
assert A.analytic_func(exp(x), x) == A.exp()
A = Matrix([[0, 2, 1, 6], [0, 0, 1, 2], [0, 0, 0, 3], [0, 0, 0, 0]])
assert A.analytic_func(exp(x*t), x) == expand(simplify((A*t).exp()))
|
2fab3c45a94a3817a86a3d8f640e5179eb2ae51c4d56f6d5072026d85f688c37 | from sympy import Basic, Expr, S, sympify
from sympy.matrices.common import NonSquareMatrixError
class Determinant(Expr):
"""Matrix Determinant
Represents the determinant of a matrix expression.
Examples
========
>>> from sympy import MatrixSymbol, Determinant, eye
>>> A = MatrixSymbol('A', 3, 3)
>>> Determinant(A)
Determinant(A)
>>> Determinant(eye(3)).doit()
1
"""
def __new__(cls, mat):
mat = sympify(mat)
if not mat.is_Matrix:
raise TypeError("Input to Determinant, %s, not a matrix" % str(mat))
if not mat.is_square:
raise NonSquareMatrixError("Det of a non-square matrix")
return Basic.__new__(cls, mat)
@property
def arg(self):
return self.args[0]
def doit(self, expand=False):
try:
return self.arg._eval_determinant()
except (AttributeError, NotImplementedError):
return self
def det(matexpr):
""" Matrix Determinant
Examples
========
>>> from sympy import MatrixSymbol, det, eye
>>> A = MatrixSymbol('A', 3, 3)
>>> det(A)
Determinant(A)
>>> det(eye(3))
1
"""
return Determinant(matexpr).doit()
from sympy.assumptions.ask import ask, Q
from sympy.assumptions.refine import handlers_dict
def refine_Determinant(expr, assumptions):
"""
>>> from sympy import MatrixSymbol, Q, assuming, refine, det
>>> X = MatrixSymbol('X', 2, 2)
>>> det(X)
Determinant(X)
>>> with assuming(Q.orthogonal(X)):
... print(refine(det(X)))
1
"""
if ask(Q.orthogonal(expr.arg), assumptions):
return S.One
elif ask(Q.singular(expr.arg), assumptions):
return S.Zero
elif ask(Q.unit_triangular(expr.arg), assumptions):
return S.One
return expr
handlers_dict['Determinant'] = refine_Determinant
|
3fe6bd3836c309a1bb4803e234cd03961acb90efe6ef69956924f5469362c8b1 | from sympy.core.sympify import _sympify
from sympy.core import S, Basic
from sympy.matrices.common import NonSquareMatrixError
from sympy.matrices.expressions.matpow import MatPow
class Inverse(MatPow):
"""
The multiplicative inverse of a matrix expression
This is a symbolic object that simply stores its argument without
evaluating it. To actually compute the inverse, use the ``.inverse()``
method of matrices.
Examples
========
>>> from sympy import MatrixSymbol, Inverse
>>> A = MatrixSymbol('A', 3, 3)
>>> B = MatrixSymbol('B', 3, 3)
>>> Inverse(A)
A**(-1)
>>> A.inverse() == Inverse(A)
True
>>> (A*B).inverse()
B**(-1)*A**(-1)
>>> Inverse(A*B)
(A*B)**(-1)
"""
is_Inverse = True
exp = S.NegativeOne
def __new__(cls, mat, exp=S.NegativeOne):
# exp is there to make it consistent with
# inverse.func(*inverse.args) == inverse
mat = _sympify(mat)
if not mat.is_Matrix:
raise TypeError("mat should be a matrix")
if not mat.is_square:
raise NonSquareMatrixError("Inverse of non-square matrix %s" % mat)
return Basic.__new__(cls, mat, exp)
@property
def arg(self):
return self.args[0]
@property
def shape(self):
return self.arg.shape
def _eval_inverse(self):
return self.arg
def _eval_determinant(self):
from sympy.matrices.expressions.determinant import det
return 1/det(self.arg)
def doit(self, **hints):
if 'inv_expand' in hints and hints['inv_expand'] == False:
return self
arg = self.arg
if hints.get('deep', True):
arg = arg.doit(**hints)
return arg.inverse()
def _eval_derivative_matrix_lines(self, x):
arg = self.args[0]
lines = arg._eval_derivative_matrix_lines(x)
for line in lines:
line.first_pointer *= -self.T
line.second_pointer *= self
return lines
from sympy.assumptions.ask import ask, Q
from sympy.assumptions.refine import handlers_dict
def refine_Inverse(expr, assumptions):
"""
>>> from sympy import MatrixSymbol, Q, assuming, refine
>>> X = MatrixSymbol('X', 2, 2)
>>> X.I
X**(-1)
>>> with assuming(Q.orthogonal(X)):
... print(refine(X.I))
X.T
"""
if ask(Q.orthogonal(expr), assumptions):
return expr.arg.T
elif ask(Q.unitary(expr), assumptions):
return expr.arg.conjugate()
elif ask(Q.singular(expr), assumptions):
raise ValueError("Inverse of singular matrix %s" % expr.arg)
return expr
handlers_dict['Inverse'] = refine_Inverse
|
68433322cdc321955803bff45aaef352be2bbdd014b1aef391732383edeacace | from sympy.matrices.expressions import MatrixExpr
from sympy import Q
class Factorization(MatrixExpr):
arg = property(lambda self: self.args[0])
shape = property(lambda self: self.arg.shape)
class LofLU(Factorization):
predicates = Q.lower_triangular,
class UofLU(Factorization):
predicates = Q.upper_triangular,
class LofCholesky(LofLU): pass
class UofCholesky(UofLU): pass
class QofQR(Factorization):
predicates = Q.orthogonal,
class RofQR(Factorization):
predicates = Q.upper_triangular,
class EigenVectors(Factorization):
predicates = Q.orthogonal,
class EigenValues(Factorization):
predicates = Q.diagonal,
class UofSVD(Factorization):
predicates = Q.orthogonal,
class SofSVD(Factorization):
predicates = Q.diagonal,
class VofSVD(Factorization):
predicates = Q.orthogonal,
def lu(expr):
return LofLU(expr), UofLU(expr)
def qr(expr):
return QofQR(expr), RofQR(expr)
def eig(expr):
return EigenValues(expr), EigenVectors(expr)
def svd(expr):
return UofSVD(expr), SofSVD(expr), VofSVD(expr)
|
23466ff7abbc21e13a896ecfe9d8926841cdfd28518352087864c18c4dc308db | from sympy import Basic
from sympy.functions import adjoint, conjugate
from sympy.matrices.expressions.matexpr import MatrixExpr
class Transpose(MatrixExpr):
"""
The transpose of a matrix expression.
This is a symbolic object that simply stores its argument without
evaluating it. To actually compute the transpose, use the ``transpose()``
function, or the ``.T`` attribute of matrices.
Examples
========
>>> from sympy.matrices import MatrixSymbol, Transpose
>>> from sympy.functions import transpose
>>> A = MatrixSymbol('A', 3, 5)
>>> B = MatrixSymbol('B', 5, 3)
>>> Transpose(A)
A.T
>>> A.T == transpose(A) == Transpose(A)
True
>>> Transpose(A*B)
(A*B).T
>>> transpose(A*B)
B.T*A.T
"""
is_Transpose = True
def doit(self, **hints):
arg = self.arg
if hints.get('deep', True) and isinstance(arg, Basic):
arg = arg.doit(**hints)
_eval_transpose = getattr(arg, '_eval_transpose', None)
if _eval_transpose is not None:
result = _eval_transpose()
return result if result is not None else Transpose(arg)
else:
return Transpose(arg)
@property
def arg(self):
return self.args[0]
@property
def shape(self):
return self.arg.shape[::-1]
def _entry(self, i, j, expand=False, **kwargs):
return self.arg._entry(j, i, expand=expand, **kwargs)
def _eval_adjoint(self):
return conjugate(self.arg)
def _eval_conjugate(self):
return adjoint(self.arg)
def _eval_transpose(self):
return self.arg
def _eval_trace(self):
from .trace import Trace
return Trace(self.arg) # Trace(X.T) => Trace(X)
def _eval_determinant(self):
from sympy.matrices.expressions.determinant import det
return det(self.arg)
def _eval_derivative(self, x):
# x is a scalar:
return self.arg._eval_derivative(x)
def _eval_derivative_matrix_lines(self, x):
lines = self.args[0]._eval_derivative_matrix_lines(x)
return [i.transpose() for i in lines]
def transpose(expr):
"""Matrix transpose"""
return Transpose(expr).doit(deep=False)
from sympy.assumptions.ask import ask, Q
from sympy.assumptions.refine import handlers_dict
def refine_Transpose(expr, assumptions):
"""
>>> from sympy import MatrixSymbol, Q, assuming, refine
>>> X = MatrixSymbol('X', 2, 2)
>>> X.T
X.T
>>> with assuming(Q.symmetric(X)):
... print(refine(X.T))
X
"""
if ask(Q.symmetric(expr), assumptions):
return expr.arg
return expr
handlers_dict['Transpose'] = refine_Transpose
|
486b45ab04c73f4d31d615dd812e79aadb91f2f5cebec5a2e04abace847ec900 | from sympy import Number
from sympy.core import Mul, Basic, sympify, S
from sympy.functions import adjoint
from sympy.strategies import (rm_id, unpack, typed, flatten, exhaust,
do_one, new)
from sympy.matrices.common import ShapeError, NonInvertibleMatrixError
from sympy.matrices.matrices import MatrixBase
from .inverse import Inverse
from .matexpr import \
MatrixExpr, Identity, ZeroMatrix, OneMatrix, GenericIdentity
from .matpow import MatPow
from .transpose import transpose
from .permutation import PermutationMatrix
# XXX: MatMul should perhaps not subclass directly from Mul
class MatMul(MatrixExpr, Mul):
"""
A product of matrix expressions
Examples
========
>>> from sympy import MatMul, MatrixSymbol
>>> A = MatrixSymbol('A', 5, 4)
>>> B = MatrixSymbol('B', 4, 3)
>>> C = MatrixSymbol('C', 3, 6)
>>> MatMul(A, B, C)
A*B*C
"""
is_MatMul = True
identity = GenericIdentity()
def __new__(cls, *args, evaluate=False, **kwargs):
check = kwargs.get('check', True)
if not args:
return cls.identity
# This must be removed aggressively in the constructor to avoid
# TypeErrors from GenericIdentity().shape
args = filter(lambda i: cls.identity != i, args)
args = list(map(sympify, args))
obj = Basic.__new__(cls, *args)
factor, matrices = obj.as_coeff_matrices()
if check:
validate(*matrices)
if not matrices:
# Should it be
#
# return Basic.__neq__(cls, factor, GenericIdentity()) ?
return factor
if evaluate:
return canonicalize(obj)
return obj
@property
def shape(self):
matrices = [arg for arg in self.args if arg.is_Matrix]
return (matrices[0].rows, matrices[-1].cols)
def _entry(self, i, j, expand=True, **kwargs):
from sympy import Dummy, Sum, Mul, ImmutableMatrix, Integer
coeff, matrices = self.as_coeff_matrices()
if len(matrices) == 1: # situation like 2*X, matmul is just X
return coeff * matrices[0][i, j]
indices = [None]*(len(matrices) + 1)
ind_ranges = [None]*(len(matrices) - 1)
indices[0] = i
indices[-1] = j
def f():
counter = 1
while True:
yield Dummy("i_%i" % counter)
counter += 1
dummy_generator = kwargs.get("dummy_generator", f())
for i in range(1, len(matrices)):
indices[i] = next(dummy_generator)
for i, arg in enumerate(matrices[:-1]):
ind_ranges[i] = arg.shape[1] - 1
matrices = [arg._entry(indices[i], indices[i+1], dummy_generator=dummy_generator) for i, arg in enumerate(matrices)]
expr_in_sum = Mul.fromiter(matrices)
if any(v.has(ImmutableMatrix) for v in matrices):
expand = True
result = coeff*Sum(
expr_in_sum,
*zip(indices[1:-1], [0]*len(ind_ranges), ind_ranges)
)
# Don't waste time in result.doit() if the sum bounds are symbolic
if not any(isinstance(v, (Integer, int)) for v in ind_ranges):
expand = False
return result.doit() if expand else result
def as_coeff_matrices(self):
scalars = [x for x in self.args if not x.is_Matrix]
matrices = [x for x in self.args if x.is_Matrix]
coeff = Mul(*scalars)
if coeff.is_commutative is False:
raise NotImplementedError("noncommutative scalars in MatMul are not supported.")
return coeff, matrices
def as_coeff_mmul(self):
coeff, matrices = self.as_coeff_matrices()
return coeff, MatMul(*matrices)
def _eval_transpose(self):
"""Transposition of matrix multiplication.
Notes
=====
The following rules are applied.
Transposition for matrix multiplied with another matrix:
`\\left(A B\\right)^{T} = B^{T} A^{T}`
Transposition for matrix multiplied with scalar:
`\\left(c A\\right)^{T} = c A^{T}`
References
==========
.. [1] https://en.wikipedia.org/wiki/Transpose
"""
coeff, matrices = self.as_coeff_matrices()
return MatMul(
coeff, *[transpose(arg) for arg in matrices[::-1]]).doit()
def _eval_adjoint(self):
return MatMul(*[adjoint(arg) for arg in self.args[::-1]]).doit()
def _eval_trace(self):
factor, mmul = self.as_coeff_mmul()
if factor != 1:
from .trace import trace
return factor * trace(mmul.doit())
else:
raise NotImplementedError("Can't simplify any further")
def _eval_determinant(self):
from sympy.matrices.expressions.determinant import Determinant
factor, matrices = self.as_coeff_matrices()
square_matrices = only_squares(*matrices)
return factor**self.rows * Mul(*list(map(Determinant, square_matrices)))
def _eval_inverse(self):
try:
return MatMul(*[
arg.inverse() if isinstance(arg, MatrixExpr) else arg**-1
for arg in self.args[::-1]]).doit()
except ShapeError:
return Inverse(self)
def doit(self, **kwargs):
deep = kwargs.get('deep', True)
if deep:
args = [arg.doit(**kwargs) for arg in self.args]
else:
args = self.args
# treat scalar*MatrixSymbol or scalar*MatPow separately
expr = canonicalize(MatMul(*args))
return expr
# Needed for partial compatibility with Mul
def args_cnc(self, **kwargs):
coeff_c = [x for x in self.args if x.is_commutative]
coeff_nc = [x for x in self.args if not x.is_commutative]
return [coeff_c, coeff_nc]
def _eval_derivative_matrix_lines(self, x):
from .transpose import Transpose
with_x_ind = [i for i, arg in enumerate(self.args) if arg.has(x)]
lines = []
for ind in with_x_ind:
left_args = self.args[:ind]
right_args = self.args[ind+1:]
if right_args:
right_mat = MatMul.fromiter(right_args)
else:
right_mat = Identity(self.shape[1])
if left_args:
left_rev = MatMul.fromiter([Transpose(i).doit() if i.is_Matrix else i for i in reversed(left_args)])
else:
left_rev = Identity(self.shape[0])
d = self.args[ind]._eval_derivative_matrix_lines(x)
for i in d:
i.append_first(left_rev)
i.append_second(right_mat)
lines.append(i)
return lines
def validate(*matrices):
""" Checks for valid shapes for args of MatMul """
for i in range(len(matrices)-1):
A, B = matrices[i:i+2]
if A.cols != B.rows:
raise ShapeError("Matrices %s and %s are not aligned"%(A, B))
# Rules
def newmul(*args):
if args[0] == 1:
args = args[1:]
return new(MatMul, *args)
def any_zeros(mul):
if any([arg.is_zero or (arg.is_Matrix and arg.is_ZeroMatrix)
for arg in mul.args]):
matrices = [arg for arg in mul.args if arg.is_Matrix]
return ZeroMatrix(matrices[0].rows, matrices[-1].cols)
return mul
def merge_explicit(matmul):
""" Merge explicit MatrixBase arguments
>>> from sympy import MatrixSymbol, eye, Matrix, MatMul, pprint
>>> from sympy.matrices.expressions.matmul import merge_explicit
>>> A = MatrixSymbol('A', 2, 2)
>>> B = Matrix([[1, 1], [1, 1]])
>>> C = Matrix([[1, 2], [3, 4]])
>>> X = MatMul(A, B, C)
>>> pprint(X)
[1 1] [1 2]
A*[ ]*[ ]
[1 1] [3 4]
>>> pprint(merge_explicit(X))
[4 6]
A*[ ]
[4 6]
>>> X = MatMul(B, A, C)
>>> pprint(X)
[1 1] [1 2]
[ ]*A*[ ]
[1 1] [3 4]
>>> pprint(merge_explicit(X))
[1 1] [1 2]
[ ]*A*[ ]
[1 1] [3 4]
"""
if not any(isinstance(arg, MatrixBase) for arg in matmul.args):
return matmul
newargs = []
last = matmul.args[0]
for arg in matmul.args[1:]:
if isinstance(arg, (MatrixBase, Number)) and isinstance(last, (MatrixBase, Number)):
last = last * arg
else:
newargs.append(last)
last = arg
newargs.append(last)
return MatMul(*newargs)
def remove_ids(mul):
""" Remove Identities from a MatMul
This is a modified version of sympy.strategies.rm_id.
This is necesssary because MatMul may contain both MatrixExprs and Exprs
as args.
See Also
========
sympy.strategies.rm_id
"""
# Separate Exprs from MatrixExprs in args
factor, mmul = mul.as_coeff_mmul()
# Apply standard rm_id for MatMuls
result = rm_id(lambda x: x.is_Identity is True)(mmul)
if result != mmul:
return newmul(factor, *result.args) # Recombine and return
else:
return mul
def factor_in_front(mul):
factor, matrices = mul.as_coeff_matrices()
if factor != 1:
return newmul(factor, *matrices)
return mul
def combine_powers(mul):
"""Combine consecutive powers with the same base into one
e.g. A*A**2 -> A**3
This also cancels out the possible matrix inverses using the
knowledgebase of ``Inverse``.
e.g. Y * X * X.I -> Y
"""
factor, args = mul.as_coeff_matrices()
new_args = [args[0]]
for B in args[1:]:
A = new_args[-1]
if A.is_square == False or B.is_square == False:
new_args.append(B)
continue
if isinstance(A, MatPow):
A_base, A_exp = A.args
else:
A_base, A_exp = A, S.One
if isinstance(B, MatPow):
B_base, B_exp = B.args
else:
B_base, B_exp = B, S.One
if A_base == B_base:
new_exp = A_exp + B_exp
new_args[-1] = MatPow(A_base, new_exp).doit(deep=False)
continue
elif not isinstance(B_base, MatrixBase):
try:
B_base_inv = B_base.inverse()
except NonInvertibleMatrixError:
B_base_inv = None
if B_base_inv is not None and A_base == B_base_inv:
new_exp = A_exp - B_exp
new_args[-1] = MatPow(A_base, new_exp).doit(deep=False)
continue
new_args.append(B)
return newmul(factor, *new_args)
def combine_permutations(mul):
"""Refine products of permutation matrices as the products of cycles.
"""
args = mul.args
l = len(args)
if l < 2:
return mul
result = [args[0]]
for i in range(1, l):
A = result[-1]
B = args[i]
if isinstance(A, PermutationMatrix) and \
isinstance(B, PermutationMatrix):
cycle_1 = A.args[0]
cycle_2 = B.args[0]
result[-1] = PermutationMatrix(cycle_1 * cycle_2)
else:
result.append(B)
return MatMul(*result)
def combine_one_matrices(mul):
"""
Combine products of OneMatrix
e.g. OneMatrix(2, 3) * OneMatrix(3, 4) -> 3 * OneMatrix(2, 4)
"""
factor, args = mul.as_coeff_matrices()
new_args = [args[0]]
for B in args[1:]:
A = new_args[-1]
if not isinstance(A, OneMatrix) or not isinstance(B, OneMatrix):
new_args.append(B)
continue
new_args.pop()
new_args.append(OneMatrix(A.shape[0], B.shape[1]))
factor *= A.shape[1]
return newmul(factor, *new_args)
rules = (
any_zeros, remove_ids, combine_one_matrices, combine_powers, unpack, rm_id(lambda x: x == 1),
merge_explicit, factor_in_front, flatten, combine_permutations)
canonicalize = exhaust(typed({MatMul: do_one(*rules)}))
def only_squares(*matrices):
"""factor matrices only if they are square"""
if matrices[0].rows != matrices[-1].cols:
raise RuntimeError("Invalid matrices being multiplied")
out = []
start = 0
for i, M in enumerate(matrices):
if M.cols == matrices[start].rows:
out.append(MatMul(*matrices[start:i+1]).doit())
start = i+1
return out
from sympy.assumptions.ask import ask, Q
from sympy.assumptions.refine import handlers_dict
def refine_MatMul(expr, assumptions):
"""
>>> from sympy import MatrixSymbol, Q, assuming, refine
>>> X = MatrixSymbol('X', 2, 2)
>>> expr = X * X.T
>>> print(expr)
X*X.T
>>> with assuming(Q.orthogonal(X)):
... print(refine(expr))
I
"""
newargs = []
exprargs = []
for args in expr.args:
if args.is_Matrix:
exprargs.append(args)
else:
newargs.append(args)
last = exprargs[0]
for arg in exprargs[1:]:
if arg == last.T and ask(Q.orthogonal(arg), assumptions):
last = Identity(arg.shape[0])
elif arg == last.conjugate() and ask(Q.unitary(arg), assumptions):
last = Identity(arg.shape[0])
else:
newargs.append(last)
last = arg
newargs.append(last)
return MatMul(*newargs)
handlers_dict['MatMul'] = refine_MatMul
|
c622d237b316d884e638f28eca90644ef5bda9b399c87e0f063d58140a826f8c | from sympy.matrices.common import NonSquareMatrixError
from .matexpr import MatrixExpr, Identity
from sympy.core import S
from sympy.core.sympify import _sympify
from sympy.matrices import MatrixBase
class MatPow(MatrixExpr):
def __new__(cls, base, exp, evaluate=False, **options):
base = _sympify(base)
if not base.is_Matrix:
raise TypeError("MatPow base should be a matrix")
if not base.is_square:
raise NonSquareMatrixError("Power of non-square matrix %s" % base)
exp = _sympify(exp)
obj = super().__new__(cls, base, exp)
if evaluate:
obj = obj.doit(deep=False)
return obj
@property
def base(self):
return self.args[0]
@property
def exp(self):
return self.args[1]
@property
def shape(self):
return self.base.shape
def _entry(self, i, j, **kwargs):
from sympy.matrices.expressions import MatMul
A = self.doit()
if isinstance(A, MatPow):
# We still have a MatPow, make an explicit MatMul out of it.
if A.exp.is_Integer and A.exp.is_positive:
A = MatMul(*[A.base for k in range(A.exp)])
#elif A.exp.is_Integer and self.exp.is_negative:
# Note: possible future improvement: in principle we can take
# positive powers of the inverse, but carefully avoid recursion,
# perhaps by adding `_entry` to Inverse (as it is our subclass).
# T = A.base.as_explicit().inverse()
# A = MatMul(*[T for k in range(-A.exp)])
else:
# Leave the expression unevaluated:
from sympy.matrices.expressions.matexpr import MatrixElement
return MatrixElement(self, i, j)
return A[i, j]
def doit(self, **kwargs):
if kwargs.get('deep', True):
base, exp = [arg.doit(**kwargs) for arg in self.args]
else:
base, exp = self.args
# combine all powers, e.g. (A ** 2) ** 3 -> A ** 6
while isinstance(base, MatPow):
exp *= base.args[1]
base = base.args[0]
if isinstance(base, MatrixBase):
# Delegate
return base ** exp
# Handle simple cases so that _eval_power() in MatrixExpr sub-classes can ignore them
if exp == S.One:
return base
if exp == S.Zero:
return Identity(base.rows)
if exp == S.NegativeOne:
from sympy.matrices.expressions import Inverse
return Inverse(base).doit(**kwargs)
eval_power = getattr(base, '_eval_power', None)
if eval_power is not None:
return eval_power(exp)
return MatPow(base, exp)
def _eval_transpose(self):
base, exp = self.args
return MatPow(base.T, exp)
def _eval_derivative(self, x):
from sympy import Pow
return Pow._eval_derivative(self, x)
def _eval_derivative_matrix_lines(self, x):
from sympy.core.expr import ExprBuilder
from sympy.codegen.array_utils import CodegenArrayContraction, CodegenArrayTensorProduct
from .matmul import MatMul
from .inverse import Inverse
exp = self.exp
if self.base.shape == (1, 1) and not exp.has(x):
lr = self.base._eval_derivative_matrix_lines(x)
for i in lr:
subexpr = ExprBuilder(
CodegenArrayContraction,
[
ExprBuilder(
CodegenArrayTensorProduct,
[
Identity(1),
i._lines[0],
exp*self.base**(exp-1),
i._lines[1],
Identity(1),
]
),
(0, 3, 4), (5, 7, 8)
],
validator=CodegenArrayContraction._validate
)
i._first_pointer_parent = subexpr.args[0].args
i._first_pointer_index = 0
i._second_pointer_parent = subexpr.args[0].args
i._second_pointer_index = 4
i._lines = [subexpr]
return lr
if (exp > 0) == True:
newexpr = MatMul.fromiter([self.base for i in range(exp)])
elif (exp == -1) == True:
return Inverse(self.base)._eval_derivative_matrix_lines(x)
elif (exp < 0) == True:
newexpr = MatMul.fromiter([Inverse(self.base) for i in range(-exp)])
elif (exp == 0) == True:
return self.doit()._eval_derivative_matrix_lines(x)
else:
raise NotImplementedError("cannot evaluate %s derived by %s" % (self, x))
return newexpr._eval_derivative_matrix_lines(x)
def _eval_inverse(self):
return MatPow(self.base, -self.exp)
|
82cf42b505fdcd99d25366ea468a05dca5cd6c841198ac26bf750a58c8a3fbe5 | from sympy.core import S
from sympy.core.sympify import _sympify
from sympy.functions import KroneckerDelta
from .matexpr import MatrixExpr, Identity, ZeroMatrix, OneMatrix
class PermutationMatrix(MatrixExpr):
"""A Permutation Matrix
Parameters
==========
perm : Permutation
The permutation the matrix uses.
The size of the permutation determines the matrix size.
See the documentation of
:class:`sympy.combinatorics.permutations.Permutation` for
the further information of how to create a permutation object.
Examples
========
>>> from sympy.matrices import Matrix, PermutationMatrix
>>> from sympy.combinatorics import Permutation
Creating a permutation matrix:
>>> p = Permutation(1, 2, 0)
>>> P = PermutationMatrix(p)
>>> P = P.as_explicit()
>>> P
Matrix([
[0, 1, 0],
[0, 0, 1],
[1, 0, 0]])
Permuting a matrix row and column:
>>> M = Matrix([0, 1, 2])
>>> Matrix(P*M)
Matrix([
[1],
[2],
[0]])
>>> Matrix(M.T*P)
Matrix([[2, 0, 1]])
See Also
========
sympy.combinatorics.permutations.Permutation
"""
def __new__(cls, perm):
from sympy.combinatorics.permutations import Permutation
perm = _sympify(perm)
if not isinstance(perm, Permutation):
raise ValueError(
"{} must be a SymPy Permutation instance.".format(perm))
return super().__new__(cls, perm)
@property
def shape(self):
size = self.args[0].size
return (size, size)
@property
def is_Identity(self):
return self.args[0].is_Identity
def doit(self):
if self.is_Identity:
return Identity(self.rows)
return self
def _entry(self, i, j, **kwargs):
perm = self.args[0]
return KroneckerDelta(perm.apply(i), j)
def _eval_power(self, exp):
return PermutationMatrix(self.args[0] ** exp).doit()
def _eval_inverse(self):
return PermutationMatrix(self.args[0] ** -1)
_eval_transpose = _eval_adjoint = _eval_inverse
def _eval_determinant(self):
sign = self.args[0].signature()
if sign == 1:
return S.One
elif sign == -1:
return S.NegativeOne
raise NotImplementedError
def _eval_rewrite_as_BlockDiagMatrix(self, *args, **kwargs):
from sympy.combinatorics.permutations import Permutation
from .blockmatrix import BlockDiagMatrix
perm = self.args[0]
full_cyclic_form = perm.full_cyclic_form
cycles_picks = []
# Stage 1. Decompose the cycles into the blockable form.
a, b, c = 0, 0, 0
flag = False
for cycle in full_cyclic_form:
l = len(cycle)
m = max(cycle)
if not flag:
if m + 1 > a + l:
flag = True
temp = [cycle]
b = m
c = l
else:
cycles_picks.append([cycle])
a += l
else:
if m > b:
if m + 1 == a + c + l:
temp.append(cycle)
cycles_picks.append(temp)
flag = False
a = m+1
else:
b = m
temp.append(cycle)
c += l
else:
if b + 1 == a + c + l:
temp.append(cycle)
cycles_picks.append(temp)
flag = False
a = b+1
else:
temp.append(cycle)
c += l
# Stage 2. Normalize each decomposed cycles and build matrix.
p = 0
args = []
for pick in cycles_picks:
new_cycles = []
l = 0
for cycle in pick:
new_cycle = [i - p for i in cycle]
new_cycles.append(new_cycle)
l += len(cycle)
p += l
perm = Permutation(new_cycles)
mat = PermutationMatrix(perm)
args.append(mat)
return BlockDiagMatrix(*args)
class MatrixPermute(MatrixExpr):
r"""Symbolic representation for permuting matrix rows or columns.
Parameters
==========
perm : Permutation, PermutationMatrix
The permutation to use for permuting the matrix.
The permutation can be resized to the suitable one,
axis : 0 or 1
The axis to permute alongside.
If `0`, it will permute the matrix rows.
If `1`, it will permute the matrix columns.
Notes
=====
This follows the same notation used in
:meth:`sympy.matrices.common.MatrixCommon.permute`.
Examples
========
>>> from sympy.matrices import Matrix, MatrixPermute
>>> from sympy.combinatorics import Permutation
Permuting the matrix rows:
>>> p = Permutation(1, 2, 0)
>>> A = Matrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
>>> B = MatrixPermute(A, p, axis=0)
>>> B.as_explicit()
Matrix([
[4, 5, 6],
[7, 8, 9],
[1, 2, 3]])
Permuting the matrix columns:
>>> B = MatrixPermute(A, p, axis=1)
>>> B.as_explicit()
Matrix([
[2, 3, 1],
[5, 6, 4],
[8, 9, 7]])
See Also
========
sympy.matrices.common.MatrixCommon.permute
"""
def __new__(cls, mat, perm, axis=S.Zero):
from sympy.combinatorics.permutations import Permutation
mat = _sympify(mat)
if not mat.is_Matrix:
raise ValueError(
"{} must be a SymPy matrix instance.".format(perm))
perm = _sympify(perm)
if isinstance(perm, PermutationMatrix):
perm = perm.args[0]
if not isinstance(perm, Permutation):
raise ValueError(
"{} must be a SymPy Permutation or a PermutationMatrix " \
"instance".format(perm))
axis = _sympify(axis)
if axis not in (0, 1):
raise ValueError("The axis must be 0 or 1.")
mat_size = mat.shape[axis]
if mat_size != perm.size:
try:
perm = perm.resize(mat_size)
except ValueError:
raise ValueError(
"Size does not match between the permutation {} "
"and the matrix {} threaded over the axis {} "
"and cannot be converted."
.format(perm, mat, axis))
return super().__new__(cls, mat, perm, axis)
def doit(self, deep=True):
mat, perm, axis = self.args
if deep:
mat = mat.doit(deep=deep)
perm = perm.doit(deep=deep)
if perm.is_Identity:
return mat
if mat.is_Identity:
if axis is S.Zero:
return PermutationMatrix(perm)
elif axis is S.One:
return PermutationMatrix(perm**-1)
if isinstance(mat, (ZeroMatrix, OneMatrix)):
return mat
if isinstance(mat, MatrixPermute) and mat.args[2] == axis:
return MatrixPermute(mat.args[0], perm * mat.args[1], axis)
return self
@property
def shape(self):
return self.args[0].shape
def _entry(self, i, j, **kwargs):
mat, perm, axis = self.args
if axis == 0:
return mat[perm.apply(i), j]
elif axis == 1:
return mat[i, perm.apply(j)]
def _eval_rewrite_as_MatMul(self, *args, **kwargs):
from .matmul import MatMul
mat, perm, axis = self.args
deep = kwargs.get("deep", True)
if deep:
mat = mat.rewrite(MatMul)
if axis == 0:
return MatMul(PermutationMatrix(perm), mat)
elif axis == 1:
return MatMul(mat, PermutationMatrix(perm**-1))
|
1feb5c0d375a44582a0987e690f151be10f05e36e3bf64da63bd6e323a3f14ca | from sympy.core import Basic
from sympy.functions import adjoint, conjugate
from sympy.matrices.expressions.transpose import transpose
from sympy.matrices.expressions.matexpr import MatrixExpr
class Adjoint(MatrixExpr):
"""
The Hermitian adjoint of a matrix expression.
This is a symbolic object that simply stores its argument without
evaluating it. To actually compute the adjoint, use the ``adjoint()``
function.
Examples
========
>>> from sympy.matrices import MatrixSymbol, Adjoint
>>> from sympy.functions import adjoint
>>> A = MatrixSymbol('A', 3, 5)
>>> B = MatrixSymbol('B', 5, 3)
>>> Adjoint(A*B)
Adjoint(A*B)
>>> adjoint(A*B)
Adjoint(B)*Adjoint(A)
>>> adjoint(A*B) == Adjoint(A*B)
False
>>> adjoint(A*B) == Adjoint(A*B).doit()
True
"""
is_Adjoint = True
def doit(self, **hints):
arg = self.arg
if hints.get('deep', True) and isinstance(arg, Basic):
return adjoint(arg.doit(**hints))
else:
return adjoint(self.arg)
@property
def arg(self):
return self.args[0]
@property
def shape(self):
return self.arg.shape[::-1]
def _entry(self, i, j, **kwargs):
return conjugate(self.arg._entry(j, i, **kwargs))
def _eval_adjoint(self):
return self.arg
def _eval_conjugate(self):
return transpose(self.arg)
def _eval_trace(self):
from sympy.matrices.expressions.trace import Trace
return conjugate(Trace(self.arg))
def _eval_transpose(self):
return conjugate(self.arg)
|
03dac964b0b1edee430d634e4bf4a312bcc1cc08fb46b83f7885bd3fb388abb3 | from typing import Any, Callable
from sympy.core.logic import FuzzyBool
from functools import wraps, reduce
import collections
from sympy.core import S, Symbol, Tuple, Integer, Basic, Expr, Eq, Mul, Add
from sympy.core.decorators import call_highest_priority
from sympy.core.compatibility import SYMPY_INTS, default_sort_key
from sympy.core.sympify import SympifyError, _sympify
from sympy.functions import conjugate, adjoint
from sympy.functions.special.tensor_functions import KroneckerDelta
from sympy.matrices.common import NonSquareMatrixError, NonInvertibleMatrixError
from sympy.simplify import simplify
from sympy.utilities.misc import filldedent
from sympy.assumptions.ask import ask, Q
def _sympifyit(arg, retval=None):
# This version of _sympifyit sympifies MutableMatrix objects
def deco(func):
@wraps(func)
def __sympifyit_wrapper(a, b):
try:
b = _sympify(b)
return func(a, b)
except SympifyError:
return retval
return __sympifyit_wrapper
return deco
class MatrixExpr(Expr):
"""Superclass for Matrix Expressions
MatrixExprs represent abstract matrices, linear transformations represented
within a particular basis.
Examples
========
>>> from sympy import MatrixSymbol
>>> A = MatrixSymbol('A', 3, 3)
>>> y = MatrixSymbol('y', 3, 1)
>>> x = (A.T*A).I * A * y
See Also
========
MatrixSymbol, MatAdd, MatMul, Transpose, Inverse
"""
# Should not be considered iterable by the
# sympy.core.compatibility.iterable function. Subclass that actually are
# iterable (i.e., explicit matrices) should set this to True.
_iterable = False
_op_priority = 11.0
is_Matrix = True # type: bool
is_MatrixExpr = True # type: bool
is_Identity = None # type: FuzzyBool
is_Inverse = False
is_Transpose = False
is_ZeroMatrix = False
is_MatAdd = False
is_MatMul = False
is_commutative = False
is_number = False
is_symbol = False
is_scalar = False
def __new__(cls, *args, **kwargs):
args = map(_sympify, args)
return Basic.__new__(cls, *args, **kwargs)
# The following is adapted from the core Expr object
def __neg__(self):
return MatMul(S.NegativeOne, self).doit()
def __abs__(self):
raise NotImplementedError
@_sympifyit('other', NotImplemented)
@call_highest_priority('__radd__')
def __add__(self, other):
return MatAdd(self, other, check=True).doit()
@_sympifyit('other', NotImplemented)
@call_highest_priority('__add__')
def __radd__(self, other):
return MatAdd(other, self, check=True).doit()
@_sympifyit('other', NotImplemented)
@call_highest_priority('__rsub__')
def __sub__(self, other):
return MatAdd(self, -other, check=True).doit()
@_sympifyit('other', NotImplemented)
@call_highest_priority('__sub__')
def __rsub__(self, other):
return MatAdd(other, -self, check=True).doit()
@_sympifyit('other', NotImplemented)
@call_highest_priority('__rmul__')
def __mul__(self, other):
return MatMul(self, other).doit()
@_sympifyit('other', NotImplemented)
@call_highest_priority('__rmul__')
def __matmul__(self, other):
return MatMul(self, other).doit()
@_sympifyit('other', NotImplemented)
@call_highest_priority('__mul__')
def __rmul__(self, other):
return MatMul(other, self).doit()
@_sympifyit('other', NotImplemented)
@call_highest_priority('__mul__')
def __rmatmul__(self, other):
return MatMul(other, self).doit()
@_sympifyit('other', NotImplemented)
@call_highest_priority('__rpow__')
def __pow__(self, other):
return MatPow(self, other).doit()
@_sympifyit('other', NotImplemented)
@call_highest_priority('__pow__')
def __rpow__(self, other):
raise NotImplementedError("Matrix Power not defined")
@_sympifyit('other', NotImplemented)
@call_highest_priority('__rdiv__')
def __div__(self, other):
return self * other**S.NegativeOne
@_sympifyit('other', NotImplemented)
@call_highest_priority('__div__')
def __rdiv__(self, other):
raise NotImplementedError()
#return MatMul(other, Pow(self, S.NegativeOne))
__truediv__ = __div__ # type: Callable[[MatrixExpr, Any], Any]
__rtruediv__ = __rdiv__ # type: Callable[[MatrixExpr, Any], Any]
@property
def rows(self):
return self.shape[0]
@property
def cols(self):
return self.shape[1]
@property
def is_square(self):
return self.rows == self.cols
def _eval_conjugate(self):
from sympy.matrices.expressions.adjoint import Adjoint
from sympy.matrices.expressions.transpose import Transpose
return Adjoint(Transpose(self))
def as_real_imag(self, deep=True, **hints):
from sympy import I
real = S.Half * (self + self._eval_conjugate())
im = (self - self._eval_conjugate())/(2*I)
return (real, im)
def _eval_inverse(self):
from sympy.matrices.expressions.inverse import Inverse
return Inverse(self)
def _eval_transpose(self):
return Transpose(self)
def _eval_power(self, exp):
"""
Override this in sub-classes to implement simplification of powers. The cases where the exponent
is -1, 0, 1 are already covered in MatPow.doit(), so implementations can exclude these cases.
"""
return MatPow(self, exp)
def _eval_simplify(self, **kwargs):
if self.is_Atom:
return self
else:
return self.func(*[simplify(x, **kwargs) for x in self.args])
def _eval_adjoint(self):
from sympy.matrices.expressions.adjoint import Adjoint
return Adjoint(self)
def _eval_derivative_array(self, x):
if isinstance(x, MatrixExpr):
return _matrix_derivative(self, x)
else:
return self._eval_derivative(x)
def _eval_derivative_n_times(self, x, n):
return Basic._eval_derivative_n_times(self, x, n)
def _visit_eval_derivative_scalar(self, x):
# `x` is a scalar:
if x.has(self):
return _matrix_derivative(x, self)
else:
return ZeroMatrix(*self.shape)
def _visit_eval_derivative_array(self, x):
if x.has(self):
return _matrix_derivative(x, self)
else:
from sympy import Derivative
return Derivative(x, self)
def _accept_eval_derivative(self, s):
from sympy import MatrixBase, NDimArray
if isinstance(s, (MatrixBase, NDimArray, MatrixExpr)):
return s._visit_eval_derivative_array(self)
else:
return s._visit_eval_derivative_scalar(self)
@classmethod
def _check_dim(cls, dim):
"""Helper function to check invalid matrix dimensions"""
from sympy.core.assumptions import check_assumptions
ok = check_assumptions(dim, integer=True, nonnegative=True)
if ok is False:
raise ValueError(
"The dimension specification {} should be "
"a nonnegative integer.".format(dim))
def _entry(self, i, j, **kwargs):
raise NotImplementedError(
"Indexing not implemented for %s" % self.__class__.__name__)
def adjoint(self):
return adjoint(self)
def as_coeff_Mul(self, rational=False):
"""Efficiently extract the coefficient of a product. """
return S.One, self
def conjugate(self):
return conjugate(self)
def transpose(self):
from sympy.matrices.expressions.transpose import transpose
return transpose(self)
@property
def T(self):
'''Matrix transposition'''
return self.transpose()
def inverse(self):
if not self.is_square:
raise NonSquareMatrixError('Inverse of non-square matrix')
return self._eval_inverse()
def inv(self):
return self.inverse()
@property
def I(self):
return self.inverse()
def valid_index(self, i, j):
def is_valid(idx):
return isinstance(idx, (int, Integer, Symbol, Expr))
return (is_valid(i) and is_valid(j) and
(self.rows is None or
(0 <= i) != False and (i < self.rows) != False) and
(0 <= j) != False and (j < self.cols) != False)
def __getitem__(self, key):
if not isinstance(key, tuple) and isinstance(key, slice):
from sympy.matrices.expressions.slice import MatrixSlice
return MatrixSlice(self, key, (0, None, 1))
if isinstance(key, tuple) and len(key) == 2:
i, j = key
if isinstance(i, slice) or isinstance(j, slice):
from sympy.matrices.expressions.slice import MatrixSlice
return MatrixSlice(self, i, j)
i, j = _sympify(i), _sympify(j)
if self.valid_index(i, j) != False:
return self._entry(i, j)
else:
raise IndexError("Invalid indices (%s, %s)" % (i, j))
elif isinstance(key, (SYMPY_INTS, Integer)):
# row-wise decomposition of matrix
rows, cols = self.shape
# allow single indexing if number of columns is known
if not isinstance(cols, Integer):
raise IndexError(filldedent('''
Single indexing is only supported when the number
of columns is known.'''))
key = _sympify(key)
i = key // cols
j = key % cols
if self.valid_index(i, j) != False:
return self._entry(i, j)
else:
raise IndexError("Invalid index %s" % key)
elif isinstance(key, (Symbol, Expr)):
raise IndexError(filldedent('''
Only integers may be used when addressing the matrix
with a single index.'''))
raise IndexError("Invalid index, wanted %s[i,j]" % self)
def as_explicit(self):
"""
Returns a dense Matrix with elements represented explicitly
Returns an object of type ImmutableDenseMatrix.
Examples
========
>>> from sympy import Identity
>>> I = Identity(3)
>>> I
I
>>> I.as_explicit()
Matrix([
[1, 0, 0],
[0, 1, 0],
[0, 0, 1]])
See Also
========
as_mutable: returns mutable Matrix type
"""
if (not isinstance(self.rows, (SYMPY_INTS, Integer))
or not isinstance(self.cols, (SYMPY_INTS, Integer))):
raise ValueError(
'Matrix with symbolic shape '
'cannot be represented explicitly.')
from sympy.matrices.immutable import ImmutableDenseMatrix
return ImmutableDenseMatrix([[self[i, j]
for j in range(self.cols)]
for i in range(self.rows)])
def as_mutable(self):
"""
Returns a dense, mutable matrix with elements represented explicitly
Examples
========
>>> from sympy import Identity
>>> I = Identity(3)
>>> I
I
>>> I.shape
(3, 3)
>>> I.as_mutable()
Matrix([
[1, 0, 0],
[0, 1, 0],
[0, 0, 1]])
See Also
========
as_explicit: returns ImmutableDenseMatrix
"""
return self.as_explicit().as_mutable()
def __array__(self):
from numpy import empty
a = empty(self.shape, dtype=object)
for i in range(self.rows):
for j in range(self.cols):
a[i, j] = self[i, j]
return a
def equals(self, other):
"""
Test elementwise equality between matrices, potentially of different
types
>>> from sympy import Identity, eye
>>> Identity(3).equals(eye(3))
True
"""
return self.as_explicit().equals(other)
def canonicalize(self):
return self
def as_coeff_mmul(self):
return 1, MatMul(self)
@staticmethod
def from_index_summation(expr, first_index=None, last_index=None, dimensions=None):
r"""
Parse expression of matrices with explicitly summed indices into a
matrix expression without indices, if possible.
This transformation expressed in mathematical notation:
`\sum_{j=0}^{N-1} A_{i,j} B_{j,k} \Longrightarrow \mathbf{A}\cdot \mathbf{B}`
Optional parameter ``first_index``: specify which free index to use as
the index starting the expression.
Examples
========
>>> from sympy import MatrixSymbol, MatrixExpr, Sum, Symbol
>>> from sympy.abc import i, j, k, l, N
>>> A = MatrixSymbol("A", N, N)
>>> B = MatrixSymbol("B", N, N)
>>> expr = Sum(A[i, j]*B[j, k], (j, 0, N-1))
>>> MatrixExpr.from_index_summation(expr)
A*B
Transposition is detected:
>>> expr = Sum(A[j, i]*B[j, k], (j, 0, N-1))
>>> MatrixExpr.from_index_summation(expr)
A.T*B
Detect the trace:
>>> expr = Sum(A[i, i], (i, 0, N-1))
>>> MatrixExpr.from_index_summation(expr)
Trace(A)
More complicated expressions:
>>> expr = Sum(A[i, j]*B[k, j]*A[l, k], (j, 0, N-1), (k, 0, N-1))
>>> MatrixExpr.from_index_summation(expr)
A*B.T*A.T
"""
from sympy import Sum, Mul, Add, MatMul, transpose, trace
from sympy.strategies.traverse import bottom_up
def remove_matelement(expr, i1, i2):
def repl_match(pos):
def func(x):
if not isinstance(x, MatrixElement):
return False
if x.args[pos] != i1:
return False
if x.args[3-pos] == 0:
if x.args[0].shape[2-pos] == 1:
return True
else:
return False
return True
return func
expr = expr.replace(repl_match(1),
lambda x: x.args[0])
expr = expr.replace(repl_match(2),
lambda x: transpose(x.args[0]))
# Make sure that all Mul are transformed to MatMul and that they
# are flattened:
rule = bottom_up(lambda x: reduce(lambda a, b: a*b, x.args) if isinstance(x, (Mul, MatMul)) else x)
return rule(expr)
def recurse_expr(expr, index_ranges={}):
if expr.is_Mul:
nonmatargs = []
pos_arg = []
pos_ind = []
dlinks = {}
link_ind = []
counter = 0
args_ind = []
for arg in expr.args:
retvals = recurse_expr(arg, index_ranges)
assert isinstance(retvals, list)
if isinstance(retvals, list):
for i in retvals:
args_ind.append(i)
else:
args_ind.append(retvals)
for arg_symbol, arg_indices in args_ind:
if arg_indices is None:
nonmatargs.append(arg_symbol)
continue
if isinstance(arg_symbol, MatrixElement):
arg_symbol = arg_symbol.args[0]
pos_arg.append(arg_symbol)
pos_ind.append(arg_indices)
link_ind.append([None]*len(arg_indices))
for i, ind in enumerate(arg_indices):
if ind in dlinks:
other_i = dlinks[ind]
link_ind[counter][i] = other_i
link_ind[other_i[0]][other_i[1]] = (counter, i)
dlinks[ind] = (counter, i)
counter += 1
counter2 = 0
lines = {}
while counter2 < len(link_ind):
for i, e in enumerate(link_ind):
if None in e:
line_start_index = (i, e.index(None))
break
cur_ind_pos = line_start_index
cur_line = []
index1 = pos_ind[cur_ind_pos[0]][cur_ind_pos[1]]
while True:
d, r = cur_ind_pos
if pos_arg[d] != 1:
if r % 2 == 1:
cur_line.append(transpose(pos_arg[d]))
else:
cur_line.append(pos_arg[d])
next_ind_pos = link_ind[d][1-r]
counter2 += 1
# Mark as visited, there will be no `None` anymore:
link_ind[d] = (-1, -1)
if next_ind_pos is None:
index2 = pos_ind[d][1-r]
lines[(index1, index2)] = cur_line
break
cur_ind_pos = next_ind_pos
lines = {k: MatMul.fromiter(v) if len(v) != 1 else v[0] for k, v in lines.items()}
return [(Mul.fromiter(nonmatargs), None)] + [
(MatrixElement(a, i, j), (i, j)) for (i, j), a in lines.items()
]
elif expr.is_Add:
res = [recurse_expr(i) for i in expr.args]
d = collections.defaultdict(list)
for res_addend in res:
scalar = 1
for elem, indices in res_addend:
if indices is None:
scalar = elem
continue
indices = tuple(sorted(indices, key=default_sort_key))
d[indices].append(scalar*remove_matelement(elem, *indices))
scalar = 1
return [(MatrixElement(Add.fromiter(v), *k), k) for k, v in d.items()]
elif isinstance(expr, KroneckerDelta):
i1, i2 = expr.args
if dimensions is not None:
identity = Identity(dimensions[0])
else:
identity = S.One
return [(MatrixElement(identity, i1, i2), (i1, i2))]
elif isinstance(expr, MatrixElement):
matrix_symbol, i1, i2 = expr.args
if i1 in index_ranges:
r1, r2 = index_ranges[i1]
if r1 != 0 or matrix_symbol.shape[0] != r2+1:
raise ValueError("index range mismatch: {} vs. (0, {})".format(
(r1, r2), matrix_symbol.shape[0]))
if i2 in index_ranges:
r1, r2 = index_ranges[i2]
if r1 != 0 or matrix_symbol.shape[1] != r2+1:
raise ValueError("index range mismatch: {} vs. (0, {})".format(
(r1, r2), matrix_symbol.shape[1]))
if (i1 == i2) and (i1 in index_ranges):
return [(trace(matrix_symbol), None)]
return [(MatrixElement(matrix_symbol, i1, i2), (i1, i2))]
elif isinstance(expr, Sum):
return recurse_expr(
expr.args[0],
index_ranges={i[0]: i[1:] for i in expr.args[1:]}
)
else:
return [(expr, None)]
retvals = recurse_expr(expr)
factors, indices = zip(*retvals)
retexpr = Mul.fromiter(factors)
if len(indices) == 0 or list(set(indices)) == [None]:
return retexpr
if first_index is None:
for i in indices:
if i is not None:
ind0 = i
break
return remove_matelement(retexpr, *ind0)
else:
return remove_matelement(retexpr, first_index, last_index)
def applyfunc(self, func):
from .applyfunc import ElementwiseApplyFunction
return ElementwiseApplyFunction(func, self)
def _eval_Eq(self, other):
if not isinstance(other, MatrixExpr):
return False
if self.shape != other.shape:
return False
if (self - other).is_ZeroMatrix:
return True
return Eq(self, other, evaluate=False)
def get_postprocessor(cls):
def _postprocessor(expr):
# To avoid circular imports, we can't have MatMul/MatAdd on the top level
mat_class = {Mul: MatMul, Add: MatAdd}[cls]
nonmatrices = []
matrices = []
for term in expr.args:
if isinstance(term, MatrixExpr):
matrices.append(term)
else:
nonmatrices.append(term)
if not matrices:
return cls._from_args(nonmatrices)
if nonmatrices:
if cls == Mul:
for i in range(len(matrices)):
if not matrices[i].is_MatrixExpr:
# If one of the matrices explicit, absorb the scalar into it
# (doit will combine all explicit matrices into one, so it
# doesn't matter which)
matrices[i] = matrices[i].__mul__(cls._from_args(nonmatrices))
nonmatrices = []
break
else:
# Maintain the ability to create Add(scalar, matrix) without
# raising an exception. That way different algorithms can
# replace matrix expressions with non-commutative symbols to
# manipulate them like non-commutative scalars.
return cls._from_args(nonmatrices + [mat_class(*matrices).doit(deep=False)])
if mat_class == MatAdd:
return mat_class(*matrices).doit(deep=False)
return mat_class(cls._from_args(nonmatrices), *matrices).doit(deep=False)
return _postprocessor
Basic._constructor_postprocessor_mapping[MatrixExpr] = {
"Mul": [get_postprocessor(Mul)],
"Add": [get_postprocessor(Add)],
}
def _matrix_derivative(expr, x):
from sympy import Derivative
lines = expr._eval_derivative_matrix_lines(x)
parts = [i.build() for i in lines]
from sympy.codegen.array_utils import recognize_matrix_expression
parts = [[recognize_matrix_expression(j).doit() for j in i] for i in parts]
def _get_shape(elem):
if isinstance(elem, MatrixExpr):
return elem.shape
return (1, 1)
def get_rank(parts):
return sum([j not in (1, None) for i in parts for j in _get_shape(i)])
ranks = [get_rank(i) for i in parts]
rank = ranks[0]
def contract_one_dims(parts):
if len(parts) == 1:
return parts[0]
else:
p1, p2 = parts[:2]
if p2.is_Matrix:
p2 = p2.T
if p1 == Identity(1):
pbase = p2
elif p2 == Identity(1):
pbase = p1
else:
pbase = p1*p2
if len(parts) == 2:
return pbase
else: # len(parts) > 2
if pbase.is_Matrix:
raise ValueError("")
return pbase*Mul.fromiter(parts[2:])
if rank <= 2:
return Add.fromiter([contract_one_dims(i) for i in parts])
return Derivative(expr, x)
class MatrixElement(Expr):
parent = property(lambda self: self.args[0])
i = property(lambda self: self.args[1])
j = property(lambda self: self.args[2])
_diff_wrt = True
is_symbol = True
is_commutative = True
def __new__(cls, name, n, m):
n, m = map(_sympify, (n, m))
from sympy import MatrixBase
if isinstance(name, (MatrixBase,)):
if n.is_Integer and m.is_Integer:
return name[n, m]
if isinstance(name, str):
name = Symbol(name)
name = _sympify(name)
obj = Expr.__new__(cls, name, n, m)
return obj
def doit(self, **kwargs):
deep = kwargs.get('deep', True)
if deep:
args = [arg.doit(**kwargs) for arg in self.args]
else:
args = self.args
return args[0][args[1], args[2]]
@property
def indices(self):
return self.args[1:]
def _eval_derivative(self, v):
from sympy import Sum, symbols, Dummy
if not isinstance(v, MatrixElement):
from sympy import MatrixBase
if isinstance(self.parent, MatrixBase):
return self.parent.diff(v)[self.i, self.j]
return S.Zero
M = self.args[0]
m, n = self.parent.shape
if M == v.args[0]:
return KroneckerDelta(self.args[1], v.args[1], (0, m-1)) * \
KroneckerDelta(self.args[2], v.args[2], (0, n-1))
if isinstance(M, Inverse):
i, j = self.args[1:]
i1, i2 = symbols("z1, z2", cls=Dummy)
Y = M.args[0]
r1, r2 = Y.shape
return -Sum(M[i, i1]*Y[i1, i2].diff(v)*M[i2, j], (i1, 0, r1-1), (i2, 0, r2-1))
if self.has(v.args[0]):
return None
return S.Zero
class MatrixSymbol(MatrixExpr):
"""Symbolic representation of a Matrix object
Creates a SymPy Symbol to represent a Matrix. This matrix has a shape and
can be included in Matrix Expressions
Examples
========
>>> from sympy import MatrixSymbol, Identity
>>> A = MatrixSymbol('A', 3, 4) # A 3 by 4 Matrix
>>> B = MatrixSymbol('B', 4, 3) # A 4 by 3 Matrix
>>> A.shape
(3, 4)
>>> 2*A*B + Identity(3)
I + 2*A*B
"""
is_commutative = False
is_symbol = True
_diff_wrt = True
def __new__(cls, name, n, m):
n, m = _sympify(n), _sympify(m)
cls._check_dim(m)
cls._check_dim(n)
if isinstance(name, str):
name = Symbol(name)
obj = Basic.__new__(cls, name, n, m)
return obj
def _hashable_content(self):
return (self.name, self.shape)
@property
def shape(self):
return self.args[1:3]
@property
def name(self):
return self.args[0].name
def _eval_subs(self, old, new):
# only do substitutions in shape
shape = Tuple(*self.shape)._subs(old, new)
return MatrixSymbol(self.args[0], *shape)
def __call__(self, *args):
raise TypeError("%s object is not callable" % self.__class__)
def _entry(self, i, j, **kwargs):
return MatrixElement(self, i, j)
@property
def free_symbols(self):
return {self}
def doit(self, **hints):
if hints.get('deep', True):
return type(self)(self.args[0], self.args[1].doit(**hints),
self.args[2].doit(**hints))
else:
return self
def _eval_simplify(self, **kwargs):
return self
def _eval_derivative(self, x):
# x is a scalar:
return ZeroMatrix(self.shape[0], self.shape[1])
def _eval_derivative_matrix_lines(self, x):
if self != x:
first = ZeroMatrix(x.shape[0], self.shape[0]) if self.shape[0] != 1 else S.Zero
second = ZeroMatrix(x.shape[1], self.shape[1]) if self.shape[1] != 1 else S.Zero
return [_LeftRightArgs(
[first, second],
)]
else:
first = Identity(self.shape[0]) if self.shape[0] != 1 else S.One
second = Identity(self.shape[1]) if self.shape[1] != 1 else S.One
return [_LeftRightArgs(
[first, second],
)]
class Identity(MatrixExpr):
"""The Matrix Identity I - multiplicative identity
Examples
========
>>> from sympy.matrices import Identity, MatrixSymbol
>>> A = MatrixSymbol('A', 3, 5)
>>> I = Identity(3)
>>> I*A
A
"""
is_Identity = True
def __new__(cls, n):
n = _sympify(n)
cls._check_dim(n)
return super().__new__(cls, n)
@property
def rows(self):
return self.args[0]
@property
def cols(self):
return self.args[0]
@property
def shape(self):
return (self.args[0], self.args[0])
@property
def is_square(self):
return True
def _eval_transpose(self):
return self
def _eval_trace(self):
return self.rows
def _eval_inverse(self):
return self
def conjugate(self):
return self
def _entry(self, i, j, **kwargs):
eq = Eq(i, j)
if eq is S.true:
return S.One
elif eq is S.false:
return S.Zero
return KroneckerDelta(i, j, (0, self.cols-1))
def _eval_determinant(self):
return S.One
def _eval_power(self, exp):
return self
class GenericIdentity(Identity):
"""
An identity matrix without a specified shape
This exists primarily so MatMul() with no arguments can return something
meaningful.
"""
def __new__(cls):
# super(Identity, cls) instead of super(GenericIdentity, cls) because
# Identity.__new__ doesn't have the same signature
return super(Identity, cls).__new__(cls)
@property
def rows(self):
raise TypeError("GenericIdentity does not have a specified shape")
@property
def cols(self):
raise TypeError("GenericIdentity does not have a specified shape")
@property
def shape(self):
raise TypeError("GenericIdentity does not have a specified shape")
# Avoid Matrix.__eq__ which might call .shape
def __eq__(self, other):
return isinstance(other, GenericIdentity)
def __ne__(self, other):
return not (self == other)
def __hash__(self):
return super().__hash__()
class ZeroMatrix(MatrixExpr):
"""The Matrix Zero 0 - additive identity
Examples
========
>>> from sympy import MatrixSymbol, ZeroMatrix
>>> A = MatrixSymbol('A', 3, 5)
>>> Z = ZeroMatrix(3, 5)
>>> A + Z
A
>>> Z*A.T
0
"""
is_ZeroMatrix = True
def __new__(cls, m, n):
m, n = _sympify(m), _sympify(n)
cls._check_dim(m)
cls._check_dim(n)
return super().__new__(cls, m, n)
@property
def shape(self):
return (self.args[0], self.args[1])
def _eval_power(self, exp):
# exp = -1, 0, 1 are already handled at this stage
if (exp < 0) == True:
raise NonInvertibleMatrixError("Matrix det == 0; not invertible")
return self
def _eval_transpose(self):
return ZeroMatrix(self.cols, self.rows)
def _eval_trace(self):
return S.Zero
def _eval_determinant(self):
return S.Zero
def _eval_inverse(self):
raise NonInvertibleMatrixError("Matrix det == 0; not invertible.")
def conjugate(self):
return self
def _entry(self, i, j, **kwargs):
return S.Zero
class GenericZeroMatrix(ZeroMatrix):
"""
A zero matrix without a specified shape
This exists primarily so MatAdd() with no arguments can return something
meaningful.
"""
def __new__(cls):
# super(ZeroMatrix, cls) instead of super(GenericZeroMatrix, cls)
# because ZeroMatrix.__new__ doesn't have the same signature
return super(ZeroMatrix, cls).__new__(cls)
@property
def rows(self):
raise TypeError("GenericZeroMatrix does not have a specified shape")
@property
def cols(self):
raise TypeError("GenericZeroMatrix does not have a specified shape")
@property
def shape(self):
raise TypeError("GenericZeroMatrix does not have a specified shape")
# Avoid Matrix.__eq__ which might call .shape
def __eq__(self, other):
return isinstance(other, GenericZeroMatrix)
def __ne__(self, other):
return not (self == other)
def __hash__(self):
return super().__hash__()
class OneMatrix(MatrixExpr):
"""
Matrix whose all entries are ones.
"""
def __new__(cls, m, n, evaluate=False):
m, n = _sympify(m), _sympify(n)
cls._check_dim(m)
cls._check_dim(n)
if evaluate:
condition = Eq(m, 1) & Eq(n, 1)
if condition == True:
return Identity(1)
obj = super().__new__(cls, m, n)
return obj
@property
def shape(self):
return self._args
@property
def is_Identity(self):
return self._is_1x1() == True
def as_explicit(self):
from sympy import ImmutableDenseMatrix
return ImmutableDenseMatrix.ones(*self.shape)
def doit(self, **hints):
args = self.args
if hints.get('deep', True):
args = [a.doit(**hints) for a in args]
return self.func(*args, evaluate=True)
def _eval_power(self, exp):
# exp = -1, 0, 1 are already handled at this stage
if self._is_1x1() == True:
return Identity(1)
if (exp < 0) == True:
raise NonInvertibleMatrixError("Matrix det == 0; not invertible")
if ask(Q.integer(exp)):
return self.shape[0] ** (exp - 1) * OneMatrix(*self.shape)
return super()._eval_power(exp)
def _eval_transpose(self):
return OneMatrix(self.cols, self.rows)
def _eval_trace(self):
return S.One*self.rows
def _is_1x1(self):
"""Returns true if the matrix is known to be 1x1"""
shape = self.shape
return Eq(shape[0], 1) & Eq(shape[1], 1)
def _eval_determinant(self):
condition = self._is_1x1()
if condition == True:
return S.One
elif condition == False:
return S.Zero
else:
from sympy import Determinant
return Determinant(self)
def _eval_inverse(self):
condition = self._is_1x1()
if condition == True:
return Identity(1)
elif condition == False:
raise NonInvertibleMatrixError("Matrix det == 0; not invertible.")
else:
return Inverse(self)
def conjugate(self):
return self
def _entry(self, i, j, **kwargs):
return S.One
def matrix_symbols(expr):
return [sym for sym in expr.free_symbols if sym.is_Matrix]
class _LeftRightArgs:
r"""
Helper class to compute matrix derivatives.
The logic: when an expression is derived by a matrix `X_{mn}`, two lines of
matrix multiplications are created: the one contracted to `m` (first line),
and the one contracted to `n` (second line).
Transposition flips the side by which new matrices are connected to the
lines.
The trace connects the end of the two lines.
"""
def __init__(self, lines, higher=S.One):
self._lines = [i for i in lines]
self._first_pointer_parent = self._lines
self._first_pointer_index = 0
self._first_line_index = 0
self._second_pointer_parent = self._lines
self._second_pointer_index = 1
self._second_line_index = 1
self.higher = higher
@property
def first_pointer(self):
return self._first_pointer_parent[self._first_pointer_index]
@first_pointer.setter
def first_pointer(self, value):
self._first_pointer_parent[self._first_pointer_index] = value
@property
def second_pointer(self):
return self._second_pointer_parent[self._second_pointer_index]
@second_pointer.setter
def second_pointer(self, value):
self._second_pointer_parent[self._second_pointer_index] = value
def __repr__(self):
built = [self._build(i) for i in self._lines]
return "_LeftRightArgs(lines=%s, higher=%s)" % (
built,
self.higher,
)
def transpose(self):
self._first_pointer_parent, self._second_pointer_parent = self._second_pointer_parent, self._first_pointer_parent
self._first_pointer_index, self._second_pointer_index = self._second_pointer_index, self._first_pointer_index
self._first_line_index, self._second_line_index = self._second_line_index, self._first_line_index
return self
@staticmethod
def _build(expr):
from sympy.core.expr import ExprBuilder
if isinstance(expr, ExprBuilder):
return expr.build()
if isinstance(expr, list):
if len(expr) == 1:
return expr[0]
else:
return expr[0](*[_LeftRightArgs._build(i) for i in expr[1]])
else:
return expr
def build(self):
data = [self._build(i) for i in self._lines]
if self.higher != 1:
data += [self._build(self.higher)]
data = [i.doit() for i in data]
return data
def matrix_form(self):
if self.first != 1 and self.higher != 1:
raise ValueError("higher dimensional array cannot be represented")
def _get_shape(elem):
if isinstance(elem, MatrixExpr):
return elem.shape
return (None, None)
if _get_shape(self.first)[1] != _get_shape(self.second)[1]:
# Remove one-dimensional identity matrices:
# (this is needed by `a.diff(a)` where `a` is a vector)
if _get_shape(self.second) == (1, 1):
return self.first*self.second[0, 0]
if _get_shape(self.first) == (1, 1):
return self.first[1, 1]*self.second.T
raise ValueError("incompatible shapes")
if self.first != 1:
return self.first*self.second.T
else:
return self.higher
def rank(self):
"""
Number of dimensions different from trivial (warning: not related to
matrix rank).
"""
rank = 0
if self.first != 1:
rank += sum([i != 1 for i in self.first.shape])
if self.second != 1:
rank += sum([i != 1 for i in self.second.shape])
if self.higher != 1:
rank += 2
return rank
def _multiply_pointer(self, pointer, other):
from sympy.core.expr import ExprBuilder
from sympy.codegen.array_utils import CodegenArrayContraction, CodegenArrayTensorProduct
subexpr = ExprBuilder(
CodegenArrayContraction,
[
ExprBuilder(
CodegenArrayTensorProduct,
[
pointer,
other
]
),
(1, 2)
],
validator=CodegenArrayContraction._validate
)
return subexpr
def append_first(self, other):
self.first_pointer *= other
def append_second(self, other):
self.second_pointer *= other
def __hash__(self):
return hash((self.first, self.second))
def __eq__(self, other):
if not isinstance(other, _LeftRightArgs):
return False
return (self.first == other.first) and (self.second == other.second)
def _make_matrix(x):
from sympy import ImmutableDenseMatrix
if isinstance(x, MatrixExpr):
return x
return ImmutableDenseMatrix([[x]])
from .matmul import MatMul
from .matadd import MatAdd
from .matpow import MatPow
from .transpose import Transpose
from .inverse import Inverse
|
22bf11ec15f827aec39348a23b22f4e1670c21c7f4c5c253c35c2e6891b46103 | from sympy.core.sympify import _sympify
from sympy.matrices.expressions import MatrixExpr
from sympy import S, I, sqrt, exp
class DFT(MatrixExpr):
""" Discrete Fourier Transform """
def __new__(cls, n):
n = _sympify(n)
cls._check_dim(n)
obj = super().__new__(cls, n)
return obj
n = property(lambda self: self.args[0]) # type: ignore
shape = property(lambda self: (self.n, self.n))
def _entry(self, i, j, **kwargs):
w = exp(-2*S.Pi*I/self.n)
return w**(i*j) / sqrt(self.n)
def _eval_inverse(self):
return IDFT(self.n)
class IDFT(DFT):
""" Inverse Discrete Fourier Transform """
def _entry(self, i, j, **kwargs):
w = exp(-2*S.Pi*I/self.n)
return w**(-i*j) / sqrt(self.n)
def _eval_inverse(self):
return DFT(self.n)
|
512f284b131be0400bd541b8c0d71d8cb278850d2b726ea15f790d79111e6e3b | from sympy.core import Basic, Expr
from sympy.core.sympify import _sympify
from sympy.matrices.expressions.transpose import transpose
class DotProduct(Expr):
"""
Dot product of vector matrices
The input should be two 1 x n or n x 1 matrices. The output represents the
scalar dotproduct.
This is similar to using MatrixElement and MatMul, except DotProduct does
not require that one vector to be a row vector and the other vector to be
a column vector.
>>> from sympy import MatrixSymbol, DotProduct
>>> A = MatrixSymbol('A', 1, 3)
>>> B = MatrixSymbol('B', 1, 3)
>>> DotProduct(A, B)
DotProduct(A, B)
>>> DotProduct(A, B).doit()
A[0, 0]*B[0, 0] + A[0, 1]*B[0, 1] + A[0, 2]*B[0, 2]
"""
def __new__(cls, arg1, arg2):
arg1, arg2 = _sympify((arg1, arg2))
if not arg1.is_Matrix:
raise TypeError("Argument 1 of DotProduct is not a matrix")
if not arg2.is_Matrix:
raise TypeError("Argument 2 of DotProduct is not a matrix")
if not (1 in arg1.shape):
raise TypeError("Argument 1 of DotProduct is not a vector")
if not (1 in arg2.shape):
raise TypeError("Argument 2 of DotProduct is not a vector")
if set(arg1.shape) != set(arg2.shape):
raise TypeError("DotProduct arguments are not the same length")
return Basic.__new__(cls, arg1, arg2)
def doit(self, expand=False):
if self.args[0].shape == self.args[1].shape:
if self.args[0].shape[0] == 1:
mul = self.args[0]*transpose(self.args[1])
else:
mul = transpose(self.args[0])*self.args[1]
else:
if self.args[0].shape[0] == 1:
mul = self.args[0]*self.args[1]
else:
mul = transpose(self.args[0])*transpose(self.args[1])
return mul[0]
|
1cd1c7cd0b5f81d7c1f049738bd95d442844452de6121cf85e29c2c1db432834 | """Implementation of the Kronecker product"""
from sympy.core import Mul, prod, sympify
from sympy.functions import adjoint
from sympy.matrices.common import ShapeError
from sympy.matrices.expressions.matexpr import MatrixExpr, Identity
from sympy.matrices.expressions.transpose import transpose
from sympy.matrices.matrices import MatrixBase
from sympy.strategies import (
canon, condition, distribute, do_one, exhaust, flatten, typed, unpack)
from sympy.strategies.traverse import bottom_up
from sympy.utilities import sift
from .matadd import MatAdd
from .matmul import MatMul
from .matpow import MatPow
def kronecker_product(*matrices):
"""
The Kronecker product of two or more arguments.
This computes the explicit Kronecker product for subclasses of
``MatrixBase`` i.e. explicit matrices. Otherwise, a symbolic
``KroneckerProduct`` object is returned.
Examples
========
For ``MatrixSymbol`` arguments a ``KroneckerProduct`` object is returned.
Elements of this matrix can be obtained by indexing, or for MatrixSymbols
with known dimension the explicit matrix can be obtained with
``.as_explicit()``
>>> from sympy.matrices import kronecker_product, MatrixSymbol
>>> A = MatrixSymbol('A', 2, 2)
>>> B = MatrixSymbol('B', 2, 2)
>>> kronecker_product(A)
A
>>> kronecker_product(A, B)
KroneckerProduct(A, B)
>>> kronecker_product(A, B)[0, 1]
A[0, 0]*B[0, 1]
>>> kronecker_product(A, B).as_explicit()
Matrix([
[A[0, 0]*B[0, 0], A[0, 0]*B[0, 1], A[0, 1]*B[0, 0], A[0, 1]*B[0, 1]],
[A[0, 0]*B[1, 0], A[0, 0]*B[1, 1], A[0, 1]*B[1, 0], A[0, 1]*B[1, 1]],
[A[1, 0]*B[0, 0], A[1, 0]*B[0, 1], A[1, 1]*B[0, 0], A[1, 1]*B[0, 1]],
[A[1, 0]*B[1, 0], A[1, 0]*B[1, 1], A[1, 1]*B[1, 0], A[1, 1]*B[1, 1]]])
For explicit matrices the Kronecker product is returned as a Matrix
>>> from sympy.matrices import Matrix, kronecker_product
>>> sigma_x = Matrix([
... [0, 1],
... [1, 0]])
...
>>> Isigma_y = Matrix([
... [0, 1],
... [-1, 0]])
...
>>> kronecker_product(sigma_x, Isigma_y)
Matrix([
[ 0, 0, 0, 1],
[ 0, 0, -1, 0],
[ 0, 1, 0, 0],
[-1, 0, 0, 0]])
See Also
========
KroneckerProduct
"""
if not matrices:
raise TypeError("Empty Kronecker product is undefined")
validate(*matrices)
if len(matrices) == 1:
return matrices[0]
else:
return KroneckerProduct(*matrices).doit()
class KroneckerProduct(MatrixExpr):
"""
The Kronecker product of two or more arguments.
The Kronecker product is a non-commutative product of matrices.
Given two matrices of dimension (m, n) and (s, t) it produces a matrix
of dimension (m s, n t).
This is a symbolic object that simply stores its argument without
evaluating it. To actually compute the product, use the function
``kronecker_product()`` or call the the ``.doit()`` or ``.as_explicit()``
methods.
>>> from sympy.matrices import KroneckerProduct, MatrixSymbol
>>> A = MatrixSymbol('A', 5, 5)
>>> B = MatrixSymbol('B', 5, 5)
>>> isinstance(KroneckerProduct(A, B), KroneckerProduct)
True
"""
is_KroneckerProduct = True
def __new__(cls, *args, **kwargs):
args = list(map(sympify, args))
if all(a.is_Identity for a in args):
ret = Identity(prod(a.rows for a in args))
if all(isinstance(a, MatrixBase) for a in args):
return ret.as_explicit()
else:
return ret
check = kwargs.get('check', True)
if check:
validate(*args)
return super().__new__(cls, *args)
@property
def shape(self):
rows, cols = self.args[0].shape
for mat in self.args[1:]:
rows *= mat.rows
cols *= mat.cols
return (rows, cols)
def _entry(self, i, j, **kwargs):
result = 1
for mat in reversed(self.args):
i, m = divmod(i, mat.rows)
j, n = divmod(j, mat.cols)
result *= mat[m, n]
return result
def _eval_adjoint(self):
return KroneckerProduct(*list(map(adjoint, self.args))).doit()
def _eval_conjugate(self):
return KroneckerProduct(*[a.conjugate() for a in self.args]).doit()
def _eval_transpose(self):
return KroneckerProduct(*list(map(transpose, self.args))).doit()
def _eval_trace(self):
from .trace import trace
return prod(trace(a) for a in self.args)
def _eval_determinant(self):
from .determinant import det, Determinant
if not all(a.is_square for a in self.args):
return Determinant(self)
m = self.rows
return prod(det(a)**(m/a.rows) for a in self.args)
def _eval_inverse(self):
try:
return KroneckerProduct(*[a.inverse() for a in self.args])
except ShapeError:
from sympy.matrices.expressions.inverse import Inverse
return Inverse(self)
def structurally_equal(self, other):
'''Determine whether two matrices have the same Kronecker product structure
Examples
========
>>> from sympy import KroneckerProduct, MatrixSymbol, symbols
>>> m, n = symbols(r'm, n', integer=True)
>>> A = MatrixSymbol('A', m, m)
>>> B = MatrixSymbol('B', n, n)
>>> C = MatrixSymbol('C', m, m)
>>> D = MatrixSymbol('D', n, n)
>>> KroneckerProduct(A, B).structurally_equal(KroneckerProduct(C, D))
True
>>> KroneckerProduct(A, B).structurally_equal(KroneckerProduct(D, C))
False
>>> KroneckerProduct(A, B).structurally_equal(C)
False
'''
# Inspired by BlockMatrix
return (isinstance(other, KroneckerProduct)
and self.shape == other.shape
and len(self.args) == len(other.args)
and all(a.shape == b.shape for (a, b) in zip(self.args, other.args)))
def has_matching_shape(self, other):
'''Determine whether two matrices have the appropriate structure to bring matrix
multiplication inside the KroneckerProdut
Examples
========
>>> from sympy import KroneckerProduct, MatrixSymbol, symbols
>>> m, n = symbols(r'm, n', integer=True)
>>> A = MatrixSymbol('A', m, n)
>>> B = MatrixSymbol('B', n, m)
>>> KroneckerProduct(A, B).has_matching_shape(KroneckerProduct(B, A))
True
>>> KroneckerProduct(A, B).has_matching_shape(KroneckerProduct(A, B))
False
>>> KroneckerProduct(A, B).has_matching_shape(A)
False
'''
return (isinstance(other, KroneckerProduct)
and self.cols == other.rows
and len(self.args) == len(other.args)
and all(a.cols == b.rows for (a, b) in zip(self.args, other.args)))
def _eval_expand_kroneckerproduct(self, **hints):
return flatten(canon(typed({KroneckerProduct: distribute(KroneckerProduct, MatAdd)}))(self))
def _kronecker_add(self, other):
if self.structurally_equal(other):
return self.__class__(*[a + b for (a, b) in zip(self.args, other.args)])
else:
return self + other
def _kronecker_mul(self, other):
if self.has_matching_shape(other):
return self.__class__(*[a*b for (a, b) in zip(self.args, other.args)])
else:
return self * other
def doit(self, **kwargs):
deep = kwargs.get('deep', True)
if deep:
args = [arg.doit(**kwargs) for arg in self.args]
else:
args = self.args
return canonicalize(KroneckerProduct(*args))
def validate(*args):
if not all(arg.is_Matrix for arg in args):
raise TypeError("Mix of Matrix and Scalar symbols")
# rules
def extract_commutative(kron):
c_part = []
nc_part = []
for arg in kron.args:
c, nc = arg.args_cnc()
c_part.extend(c)
nc_part.append(Mul._from_args(nc))
c_part = Mul(*c_part)
if c_part != 1:
return c_part*KroneckerProduct(*nc_part)
return kron
def matrix_kronecker_product(*matrices):
"""Compute the Kronecker product of a sequence of SymPy Matrices.
This is the standard Kronecker product of matrices [1].
Parameters
==========
matrices : tuple of MatrixBase instances
The matrices to take the Kronecker product of.
Returns
=======
matrix : MatrixBase
The Kronecker product matrix.
Examples
========
>>> from sympy import Matrix
>>> from sympy.matrices.expressions.kronecker import (
... matrix_kronecker_product)
>>> m1 = Matrix([[1,2],[3,4]])
>>> m2 = Matrix([[1,0],[0,1]])
>>> matrix_kronecker_product(m1, m2)
Matrix([
[1, 0, 2, 0],
[0, 1, 0, 2],
[3, 0, 4, 0],
[0, 3, 0, 4]])
>>> matrix_kronecker_product(m2, m1)
Matrix([
[1, 2, 0, 0],
[3, 4, 0, 0],
[0, 0, 1, 2],
[0, 0, 3, 4]])
References
==========
[1] https://en.wikipedia.org/wiki/Kronecker_product
"""
# Make sure we have a sequence of Matrices
if not all(isinstance(m, MatrixBase) for m in matrices):
raise TypeError(
'Sequence of Matrices expected, got: %s' % repr(matrices)
)
# Pull out the first element in the product.
matrix_expansion = matrices[-1]
# Do the kronecker product working from right to left.
for mat in reversed(matrices[:-1]):
rows = mat.rows
cols = mat.cols
# Go through each row appending kronecker product to.
# running matrix_expansion.
for i in range(rows):
start = matrix_expansion*mat[i*cols]
# Go through each column joining each item
for j in range(cols - 1):
start = start.row_join(
matrix_expansion*mat[i*cols + j + 1]
)
# If this is the first element, make it the start of the
# new row.
if i == 0:
next = start
else:
next = next.col_join(start)
matrix_expansion = next
MatrixClass = max(matrices, key=lambda M: M._class_priority).__class__
if isinstance(matrix_expansion, MatrixClass):
return matrix_expansion
else:
return MatrixClass(matrix_expansion)
def explicit_kronecker_product(kron):
# Make sure we have a sequence of Matrices
if not all(isinstance(m, MatrixBase) for m in kron.args):
return kron
return matrix_kronecker_product(*kron.args)
rules = (unpack,
explicit_kronecker_product,
flatten,
extract_commutative)
canonicalize = exhaust(condition(lambda x: isinstance(x, KroneckerProduct),
do_one(*rules)))
def _kronecker_dims_key(expr):
if isinstance(expr, KroneckerProduct):
return tuple(a.shape for a in expr.args)
else:
return (0,)
def kronecker_mat_add(expr):
from functools import reduce
args = sift(expr.args, _kronecker_dims_key)
nonkrons = args.pop((0,), None)
if not args:
return expr
krons = [reduce(lambda x, y: x._kronecker_add(y), group)
for group in args.values()]
if not nonkrons:
return MatAdd(*krons)
else:
return MatAdd(*krons) + nonkrons
def kronecker_mat_mul(expr):
# modified from block matrix code
factor, matrices = expr.as_coeff_matrices()
i = 0
while i < len(matrices) - 1:
A, B = matrices[i:i+2]
if isinstance(A, KroneckerProduct) and isinstance(B, KroneckerProduct):
matrices[i] = A._kronecker_mul(B)
matrices.pop(i+1)
else:
i += 1
return factor*MatMul(*matrices)
def kronecker_mat_pow(expr):
if isinstance(expr.base, KroneckerProduct) and all(a.is_square for a in expr.base.args):
return KroneckerProduct(*[MatPow(a, expr.exp) for a in expr.base.args])
else:
return expr
def combine_kronecker(expr):
"""Combine KronekeckerProduct with expression.
If possible write operations on KroneckerProducts of compatible shapes
as a single KroneckerProduct.
Examples
========
>>> from sympy.matrices.expressions import MatrixSymbol, KroneckerProduct, combine_kronecker
>>> from sympy import symbols
>>> m, n = symbols(r'm, n', integer=True)
>>> A = MatrixSymbol('A', m, n)
>>> B = MatrixSymbol('B', n, m)
>>> combine_kronecker(KroneckerProduct(A, B)*KroneckerProduct(B, A))
KroneckerProduct(A*B, B*A)
>>> combine_kronecker(KroneckerProduct(A, B)+KroneckerProduct(B.T, A.T))
KroneckerProduct(A + B.T, B + A.T)
>>> C = MatrixSymbol('C', n, n)
>>> D = MatrixSymbol('D', m, m)
>>> combine_kronecker(KroneckerProduct(C, D)**m)
KroneckerProduct(C**m, D**m)
"""
def haskron(expr):
return isinstance(expr, MatrixExpr) and expr.has(KroneckerProduct)
rule = exhaust(
bottom_up(exhaust(condition(haskron, typed(
{MatAdd: kronecker_mat_add,
MatMul: kronecker_mat_mul,
MatPow: kronecker_mat_pow})))))
result = rule(expr)
doit = getattr(result, 'doit', None)
if doit is not None:
return doit()
else:
return result
|
7f8b2f702346c11b9d1b2775f8b9f225a784d6a88ace20efe2dc4e2545777ea4 | from sympy.core.sympify import _sympify
from sympy.matrices.expressions import MatrixExpr
from sympy.core import S, Eq, Ge
from sympy.functions.special.tensor_functions import KroneckerDelta
class DiagonalMatrix(MatrixExpr):
"""DiagonalMatrix(M) will create a matrix expression that
behaves as though all off-diagonal elements,
`M[i, j]` where `i != j`, are zero.
Examples
========
>>> from sympy import MatrixSymbol, DiagonalMatrix, Symbol
>>> n = Symbol('n', integer=True)
>>> m = Symbol('m', integer=True)
>>> D = DiagonalMatrix(MatrixSymbol('x', 2, 3))
>>> D[1, 2]
0
>>> D[1, 1]
x[1, 1]
The length of the diagonal -- the lesser of the two dimensions of `M` --
is accessed through the `diagonal_length` property:
>>> D.diagonal_length
2
>>> DiagonalMatrix(MatrixSymbol('x', n + 1, n)).diagonal_length
n
When one of the dimensions is symbolic the other will be treated as
though it is smaller:
>>> tall = DiagonalMatrix(MatrixSymbol('x', n, 3))
>>> tall.diagonal_length
3
>>> tall[10, 1]
0
When the size of the diagonal is not known, a value of None will
be returned:
>>> DiagonalMatrix(MatrixSymbol('x', n, m)).diagonal_length is None
True
"""
arg = property(lambda self: self.args[0])
shape = property(lambda self: self.arg.shape)
@property
def diagonal_length(self):
r, c = self.shape
if r.is_Integer and c.is_Integer:
m = min(r, c)
elif r.is_Integer and not c.is_Integer:
m = r
elif c.is_Integer and not r.is_Integer:
m = c
elif r == c:
m = r
else:
try:
m = min(r, c)
except TypeError:
m = None
return m
def _entry(self, i, j, **kwargs):
if self.diagonal_length is not None:
if Ge(i, self.diagonal_length) is S.true:
return S.Zero
elif Ge(j, self.diagonal_length) is S.true:
return S.Zero
eq = Eq(i, j)
if eq is S.true:
return self.arg[i, i]
elif eq is S.false:
return S.Zero
return self.arg[i, j]*KroneckerDelta(i, j)
class DiagonalOf(MatrixExpr):
"""DiagonalOf(M) will create a matrix expression that
is equivalent to the diagonal of `M`, represented as
a single column matrix.
Examples
========
>>> from sympy import MatrixSymbol, DiagonalOf, Symbol
>>> n = Symbol('n', integer=True)
>>> m = Symbol('m', integer=True)
>>> x = MatrixSymbol('x', 2, 3)
>>> diag = DiagonalOf(x)
>>> diag.shape
(2, 1)
The diagonal can be addressed like a matrix or vector and will
return the corresponding element of the original matrix:
>>> diag[1, 0] == diag[1] == x[1, 1]
True
The length of the diagonal -- the lesser of the two dimensions of `M` --
is accessed through the `diagonal_length` property:
>>> diag.diagonal_length
2
>>> DiagonalOf(MatrixSymbol('x', n + 1, n)).diagonal_length
n
When only one of the dimensions is symbolic the other will be
treated as though it is smaller:
>>> dtall = DiagonalOf(MatrixSymbol('x', n, 3))
>>> dtall.diagonal_length
3
When the size of the diagonal is not known, a value of None will
be returned:
>>> DiagonalOf(MatrixSymbol('x', n, m)).diagonal_length is None
True
"""
arg = property(lambda self: self.args[0])
@property
def shape(self):
r, c = self.arg.shape
if r.is_Integer and c.is_Integer:
m = min(r, c)
elif r.is_Integer and not c.is_Integer:
m = r
elif c.is_Integer and not r.is_Integer:
m = c
elif r == c:
m = r
else:
try:
m = min(r, c)
except TypeError:
m = None
return m, S.One
@property
def diagonal_length(self):
return self.shape[0]
def _entry(self, i, j, **kwargs):
return self.arg._entry(i, i, **kwargs)
class DiagMatrix(MatrixExpr):
"""
Turn a vector into a diagonal matrix.
"""
def __new__(cls, vector):
vector = _sympify(vector)
obj = MatrixExpr.__new__(cls, vector)
shape = vector.shape
dim = shape[1] if shape[0] == 1 else shape[0]
if vector.shape[0] != 1:
obj._iscolumn = True
else:
obj._iscolumn = False
obj._shape = (dim, dim)
obj._vector = vector
return obj
@property
def shape(self):
return self._shape
def _entry(self, i, j, **kwargs):
if self._iscolumn:
result = self._vector._entry(i, 0, **kwargs)
else:
result = self._vector._entry(0, j, **kwargs)
if i != j:
result *= KroneckerDelta(i, j)
return result
def _eval_transpose(self):
return self
def as_explicit(self):
from sympy import diag
return diag(*list(self._vector.as_explicit()))
def doit(self, **hints):
from sympy.assumptions import ask, Q
from sympy import Transpose, Mul, MatMul
from sympy import MatrixBase, eye
vector = self._vector
# This accounts for shape (1, 1) and identity matrices, among others:
if ask(Q.diagonal(vector)):
return vector
if isinstance(vector, MatrixBase):
ret = eye(max(vector.shape))
for i in range(ret.shape[0]):
ret[i, i] = vector[i]
return type(vector)(ret)
if vector.is_MatMul:
matrices = [arg for arg in vector.args if arg.is_Matrix]
scalars = [arg for arg in vector.args if arg not in matrices]
if scalars:
return Mul.fromiter(scalars)*DiagMatrix(MatMul.fromiter(matrices).doit()).doit()
if isinstance(vector, Transpose):
vector = vector.arg
return DiagMatrix(vector)
def diagonalize_vector(vector):
return DiagMatrix(vector).doit()
|
ab91886506bae24f397673fe44a2fb5cdc280ca922c7c9ae19d8cb26d77f8929 | from sympy import Basic, Expr, sympify, S
from sympy.matrices.matrices import MatrixBase
from sympy.matrices.common import NonSquareMatrixError
class Trace(Expr):
"""Matrix Trace
Represents the trace of a matrix expression.
Examples
========
>>> from sympy import MatrixSymbol, Trace, eye
>>> A = MatrixSymbol('A', 3, 3)
>>> Trace(A)
Trace(A)
"""
is_Trace = True
is_commutative = True
def __new__(cls, mat):
mat = sympify(mat)
if not mat.is_Matrix:
raise TypeError("input to Trace, %s, is not a matrix" % str(mat))
if not mat.is_square:
raise NonSquareMatrixError("Trace of a non-square matrix")
return Basic.__new__(cls, mat)
def _eval_transpose(self):
return self
def _eval_derivative(self, v):
from sympy import Sum
from .matexpr import MatrixElement
if isinstance(v, MatrixElement):
return self.rewrite(Sum).diff(v)
expr = self.doit()
if isinstance(expr, Trace):
# Avoid looping infinitely:
raise NotImplementedError
return expr._eval_derivative(v)
def _eval_derivative_matrix_lines(self, x):
from sympy.codegen.array_utils import CodegenArrayContraction, CodegenArrayTensorProduct
from sympy.core.expr import ExprBuilder
r = self.args[0]._eval_derivative_matrix_lines(x)
for lr in r:
if lr.higher == 1:
lr.higher = ExprBuilder(
CodegenArrayContraction,
[
ExprBuilder(
CodegenArrayTensorProduct,
[
lr._lines[0],
lr._lines[1],
]
),
(1, 3),
],
validator=CodegenArrayContraction._validate
)
else:
# This is not a matrix line:
lr.higher = ExprBuilder(
CodegenArrayContraction,
[
ExprBuilder(
CodegenArrayTensorProduct,
[
lr._lines[0],
lr._lines[1],
lr.higher,
]
),
(1, 3), (0, 2)
]
)
lr._lines = [S.One, S.One]
lr._first_pointer_parent = lr._lines
lr._second_pointer_parent = lr._lines
lr._first_pointer_index = 0
lr._second_pointer_index = 1
return r
@property
def arg(self):
return self.args[0]
def doit(self, **kwargs):
if kwargs.get('deep', True):
arg = self.arg.doit(**kwargs)
try:
return arg._eval_trace()
except (AttributeError, NotImplementedError):
return Trace(arg)
else:
# _eval_trace would go too deep here
if isinstance(self.arg, MatrixBase):
return trace(self.arg)
else:
return Trace(self.arg)
def _eval_rewrite_as_Sum(self, expr, **kwargs):
from sympy import Sum, Dummy
i = Dummy('i')
return Sum(self.arg[i, i], (i, 0, self.arg.rows-1)).doit()
def trace(expr):
"""Trace of a Matrix. Sum of the diagonal elements.
Examples
========
>>> from sympy import trace, Symbol, MatrixSymbol, pprint, eye
>>> n = Symbol('n')
>>> X = MatrixSymbol('X', n, n) # A square matrix
>>> trace(2*X)
2*Trace(X)
>>> trace(eye(3))
3
"""
return Trace(expr).doit()
|
838e1150ef60b5503887a4513f365f83d70e1fb82dcdffa80ce7202e2a3da509 | from sympy.core import Mul, sympify
from sympy.matrices.common import ShapeError
from sympy.matrices.expressions.matexpr import (
MatrixExpr, OneMatrix, ZeroMatrix
)
from sympy.strategies import (
unpack, flatten, condition, exhaust, rm_id, sort
)
def hadamard_product(*matrices):
"""
Return the elementwise (aka Hadamard) product of matrices.
Examples
========
>>> from sympy.matrices import hadamard_product, MatrixSymbol
>>> A = MatrixSymbol('A', 2, 3)
>>> B = MatrixSymbol('B', 2, 3)
>>> hadamard_product(A)
A
>>> hadamard_product(A, B)
HadamardProduct(A, B)
>>> hadamard_product(A, B)[0, 1]
A[0, 1]*B[0, 1]
"""
if not matrices:
raise TypeError("Empty Hadamard product is undefined")
validate(*matrices)
if len(matrices) == 1:
return matrices[0]
else:
matrices = [i for i in matrices if not i.is_Identity]
return HadamardProduct(*matrices).doit()
class HadamardProduct(MatrixExpr):
"""
Elementwise product of matrix expressions
Examples
========
Hadamard product for matrix symbols:
>>> from sympy.matrices import hadamard_product, HadamardProduct, MatrixSymbol
>>> A = MatrixSymbol('A', 5, 5)
>>> B = MatrixSymbol('B', 5, 5)
>>> isinstance(hadamard_product(A, B), HadamardProduct)
True
Notes
=====
This is a symbolic object that simply stores its argument without
evaluating it. To actually compute the product, use the function
``hadamard_product()`` or ``HadamardProduct.doit``
"""
is_HadamardProduct = True
def __new__(cls, *args, evaluate=False, **kwargs):
args = list(map(sympify, args))
check = kwargs.get('check', True)
if check:
validate(*args)
obj = super().__new__(cls, *args)
if evaluate:
obj = obj.doit(deep=False)
return obj
@property
def shape(self):
return self.args[0].shape
def _entry(self, i, j, **kwargs):
return Mul(*[arg._entry(i, j, **kwargs) for arg in self.args])
def _eval_transpose(self):
from sympy.matrices.expressions.transpose import transpose
return HadamardProduct(*list(map(transpose, self.args)))
def doit(self, **ignored):
expr = self.func(*[i.doit(**ignored) for i in self.args])
# Check for explicit matrices:
from sympy import MatrixBase
from sympy.matrices.immutable import ImmutableMatrix
explicit = [i for i in expr.args if isinstance(i, MatrixBase)]
if explicit:
remainder = [i for i in expr.args if i not in explicit]
expl_mat = ImmutableMatrix([
Mul.fromiter(i) for i in zip(*explicit)
]).reshape(*self.shape)
expr = HadamardProduct(*([expl_mat] + remainder))
return canonicalize(expr)
def _eval_derivative(self, x):
from sympy import Add
terms = []
args = list(self.args)
for i in range(len(args)):
factors = args[:i] + [args[i].diff(x)] + args[i+1:]
terms.append(hadamard_product(*factors))
return Add.fromiter(terms)
def _eval_derivative_matrix_lines(self, x):
from sympy.core.expr import ExprBuilder
from sympy.codegen.array_utils import CodegenArrayDiagonal, CodegenArrayTensorProduct
from sympy.matrices.expressions.matexpr import _make_matrix
with_x_ind = [i for i, arg in enumerate(self.args) if arg.has(x)]
lines = []
for ind in with_x_ind:
left_args = self.args[:ind]
right_args = self.args[ind+1:]
d = self.args[ind]._eval_derivative_matrix_lines(x)
hadam = hadamard_product(*(right_args + left_args))
diagonal = [(0, 2), (3, 4)]
diagonal = [e for j, e in enumerate(diagonal) if self.shape[j] != 1]
for i in d:
l1 = i._lines[i._first_line_index]
l2 = i._lines[i._second_line_index]
subexpr = ExprBuilder(
CodegenArrayDiagonal,
[
ExprBuilder(
CodegenArrayTensorProduct,
[
ExprBuilder(_make_matrix, [l1]),
hadam,
ExprBuilder(_make_matrix, [l2]),
]
),
*diagonal],
)
i._first_pointer_parent = subexpr.args[0].args[0].args
i._first_pointer_index = 0
i._second_pointer_parent = subexpr.args[0].args[2].args
i._second_pointer_index = 0
i._lines = [subexpr]
lines.append(i)
return lines
def validate(*args):
if not all(arg.is_Matrix for arg in args):
raise TypeError("Mix of Matrix and Scalar symbols")
A = args[0]
for B in args[1:]:
if A.shape != B.shape:
raise ShapeError("Matrices %s and %s are not aligned" % (A, B))
# TODO Implement algorithm for rewriting Hadamard product as diagonal matrix
# if matmul identy matrix is multiplied.
def canonicalize(x):
"""Canonicalize the Hadamard product ``x`` with mathematical properties.
Examples
========
>>> from sympy.matrices.expressions import MatrixSymbol, HadamardProduct
>>> from sympy.matrices.expressions import OneMatrix, ZeroMatrix
>>> from sympy.matrices.expressions.hadamard import canonicalize
>>> from sympy import init_printing
>>> init_printing(use_unicode=False)
>>> A = MatrixSymbol('A', 2, 2)
>>> B = MatrixSymbol('B', 2, 2)
>>> C = MatrixSymbol('C', 2, 2)
Hadamard product associativity:
>>> X = HadamardProduct(A, HadamardProduct(B, C))
>>> X
A.*(B.*C)
>>> canonicalize(X)
A.*B.*C
Hadamard product commutativity:
>>> X = HadamardProduct(A, B)
>>> Y = HadamardProduct(B, A)
>>> X
A.*B
>>> Y
B.*A
>>> canonicalize(X)
A.*B
>>> canonicalize(Y)
A.*B
Hadamard product identity:
>>> X = HadamardProduct(A, OneMatrix(2, 2))
>>> X
A.*1
>>> canonicalize(X)
A
Absorbing element of Hadamard product:
>>> X = HadamardProduct(A, ZeroMatrix(2, 2))
>>> X
A.*0
>>> canonicalize(X)
0
Rewriting to Hadamard Power
>>> X = HadamardProduct(A, A, A)
>>> X
A.*A.*A
>>> canonicalize(X)
.3
A
Notes
=====
As the Hadamard product is associative, nested products can be flattened.
The Hadamard product is commutative so that factors can be sorted for
canonical form.
A matrix of only ones is an identity for Hadamard product,
so every matrices of only ones can be removed.
Any zero matrix will make the whole product a zero matrix.
Duplicate elements can be collected and rewritten as HadamardPower
References
==========
.. [1] https://en.wikipedia.org/wiki/Hadamard_product_(matrices)
"""
from sympy.core.compatibility import default_sort_key
# Associativity
rule = condition(
lambda x: isinstance(x, HadamardProduct),
flatten
)
fun = exhaust(rule)
x = fun(x)
# Identity
fun = condition(
lambda x: isinstance(x, HadamardProduct),
rm_id(lambda x: isinstance(x, OneMatrix))
)
x = fun(x)
# Absorbing by Zero Matrix
def absorb(x):
if any(isinstance(c, ZeroMatrix) for c in x.args):
return ZeroMatrix(*x.shape)
else:
return x
fun = condition(
lambda x: isinstance(x, HadamardProduct),
absorb
)
x = fun(x)
# Rewriting with HadamardPower
if isinstance(x, HadamardProduct):
from collections import Counter
tally = Counter(x.args)
new_arg = []
for base, exp in tally.items():
if exp == 1:
new_arg.append(base)
else:
new_arg.append(HadamardPower(base, exp))
x = HadamardProduct(*new_arg)
# Commutativity
fun = condition(
lambda x: isinstance(x, HadamardProduct),
sort(default_sort_key)
)
x = fun(x)
# Unpacking
x = unpack(x)
return x
def hadamard_power(base, exp):
base = sympify(base)
exp = sympify(exp)
if exp == 1:
return base
if not base.is_Matrix:
return base**exp
if exp.is_Matrix:
raise ValueError("cannot raise expression to a matrix")
return HadamardPower(base, exp)
class HadamardPower(MatrixExpr):
r"""
Elementwise power of matrix expressions
Parameters
==========
base : scalar or matrix
exp : scalar or matrix
Notes
=====
There are four definitions for the hadamard power which can be used.
Let's consider `A, B` as `(m, n)` matrices, and `a, b` as scalars.
Matrix raised to a scalar exponent:
.. math::
A^{\circ b} = \begin{bmatrix}
A_{0, 0}^b & A_{0, 1}^b & \cdots & A_{0, n-1}^b \\
A_{1, 0}^b & A_{1, 1}^b & \cdots & A_{1, n-1}^b \\
\vdots & \vdots & \ddots & \vdots \\
A_{m-1, 0}^b & A_{m-1, 1}^b & \cdots & A_{m-1, n-1}^b
\end{bmatrix}
Scalar raised to a matrix exponent:
.. math::
a^{\circ B} = \begin{bmatrix}
a^{B_{0, 0}} & a^{B_{0, 1}} & \cdots & a^{B_{0, n-1}} \\
a^{B_{1, 0}} & a^{B_{1, 1}} & \cdots & a^{B_{1, n-1}} \\
\vdots & \vdots & \ddots & \vdots \\
a^{B_{m-1, 0}} & a^{B_{m-1, 1}} & \cdots & a^{B_{m-1, n-1}}
\end{bmatrix}
Matrix raised to a matrix exponent:
.. math::
A^{\circ B} = \begin{bmatrix}
A_{0, 0}^{B_{0, 0}} & A_{0, 1}^{B_{0, 1}} &
\cdots & A_{0, n-1}^{B_{0, n-1}} \\
A_{1, 0}^{B_{1, 0}} & A_{1, 1}^{B_{1, 1}} &
\cdots & A_{1, n-1}^{B_{1, n-1}} \\
\vdots & \vdots &
\ddots & \vdots \\
A_{m-1, 0}^{B_{m-1, 0}} & A_{m-1, 1}^{B_{m-1, 1}} &
\cdots & A_{m-1, n-1}^{B_{m-1, n-1}}
\end{bmatrix}
Scalar raised to a scalar exponent:
.. math::
a^{\circ b} = a^b
"""
def __new__(cls, base, exp):
base = sympify(base)
exp = sympify(exp)
if base.is_scalar and exp.is_scalar:
return base ** exp
if base.is_Matrix and exp.is_Matrix and base.shape != exp.shape:
raise ValueError(
'The shape of the base {} and '
'the shape of the exponent {} do not match.'
.format(base.shape, exp.shape)
)
obj = super().__new__(cls, base, exp)
return obj
@property
def base(self):
return self._args[0]
@property
def exp(self):
return self._args[1]
@property
def shape(self):
if self.base.is_Matrix:
return self.base.shape
return self.exp.shape
def _entry(self, i, j, **kwargs):
base = self.base
exp = self.exp
if base.is_Matrix:
a = base._entry(i, j, **kwargs)
elif base.is_scalar:
a = base
else:
raise ValueError(
'The base {} must be a scalar or a matrix.'.format(base))
if exp.is_Matrix:
b = exp._entry(i, j, **kwargs)
elif exp.is_scalar:
b = exp
else:
raise ValueError(
'The exponent {} must be a scalar or a matrix.'.format(exp))
return a ** b
def _eval_transpose(self):
from sympy.matrices.expressions.transpose import transpose
return HadamardPower(transpose(self.base), self.exp)
def _eval_derivative(self, x):
from sympy import log
dexp = self.exp.diff(x)
logbase = self.base.applyfunc(log)
dlbase = logbase.diff(x)
return hadamard_product(
dexp*logbase + self.exp*dlbase,
self
)
def _eval_derivative_matrix_lines(self, x):
from sympy.codegen.array_utils import CodegenArrayTensorProduct
from sympy.codegen.array_utils import CodegenArrayDiagonal
from sympy.core.expr import ExprBuilder
from sympy.matrices.expressions.matexpr import _make_matrix
lr = self.base._eval_derivative_matrix_lines(x)
for i in lr:
diagonal = [(1, 2), (3, 4)]
diagonal = [e for j, e in enumerate(diagonal) if self.base.shape[j] != 1]
l1 = i._lines[i._first_line_index]
l2 = i._lines[i._second_line_index]
subexpr = ExprBuilder(
CodegenArrayDiagonal,
[
ExprBuilder(
CodegenArrayTensorProduct,
[
ExprBuilder(_make_matrix, [l1]),
self.exp*hadamard_power(self.base, self.exp-1),
ExprBuilder(_make_matrix, [l2]),
]
),
*diagonal],
validator=CodegenArrayDiagonal._validate
)
i._first_pointer_parent = subexpr.args[0].args[0].args
i._first_pointer_index = 0
i._first_line_index = 0
i._second_pointer_parent = subexpr.args[0].args[2].args
i._second_pointer_index = 0
i._second_line_index = 0
i._lines = [subexpr]
return lr
|
7edce94c3086f292bb107c41fc928cbe7e26f058464eac715bb9b692f59a50bd | from sympy import ask, Q
from sympy.core import Basic, Add, Mul, S
from sympy.core.sympify import _sympify
from sympy.matrices.common import NonInvertibleMatrixError
from sympy.strategies import typed, exhaust, condition, do_one, unpack
from sympy.strategies.traverse import bottom_up
from sympy.utilities import sift
from sympy.utilities.misc import filldedent
from sympy.matrices.expressions.matexpr import MatrixExpr, ZeroMatrix, Identity, MatrixElement
from sympy.matrices.expressions.matmul import MatMul
from sympy.matrices.expressions.matadd import MatAdd
from sympy.matrices.expressions.matpow import MatPow
from sympy.matrices.expressions.transpose import Transpose, transpose
from sympy.matrices.expressions.trace import trace
from sympy.matrices.expressions.determinant import det, Determinant
from sympy.matrices.expressions.slice import MatrixSlice
from sympy.matrices.expressions.inverse import Inverse
from sympy.matrices import Matrix, ShapeError
from sympy.functions.elementary.complexes import re, im
class BlockMatrix(MatrixExpr):
"""A BlockMatrix is a Matrix comprised of other matrices.
The submatrices are stored in a SymPy Matrix object but accessed as part of
a Matrix Expression
>>> from sympy import (MatrixSymbol, BlockMatrix, symbols,
... Identity, ZeroMatrix, block_collapse)
>>> n,m,l = symbols('n m l')
>>> X = MatrixSymbol('X', n, n)
>>> Y = MatrixSymbol('Y', m ,m)
>>> Z = MatrixSymbol('Z', n, m)
>>> B = BlockMatrix([[X, Z], [ZeroMatrix(m,n), Y]])
>>> print(B)
Matrix([
[X, Z],
[0, Y]])
>>> C = BlockMatrix([[Identity(n), Z]])
>>> print(C)
Matrix([[I, Z]])
>>> print(block_collapse(C*B))
Matrix([[X, Z + Z*Y]])
Some matrices might be comprised of rows of blocks with
the matrices in each row having the same height and the
rows all having the same total number of columns but
not having the same number of columns for each matrix
in each row. In this case, the matrix is not a block
matrix and should be instantiated by Matrix.
>>> from sympy import ones, Matrix
>>> dat = [
... [ones(3,2), ones(3,3)*2],
... [ones(2,3)*3, ones(2,2)*4]]
...
>>> BlockMatrix(dat)
Traceback (most recent call last):
...
ValueError:
Although this matrix is comprised of blocks, the blocks do not fill
the matrix in a size-symmetric fashion. To create a full matrix from
these arguments, pass them directly to Matrix.
>>> Matrix(dat)
Matrix([
[1, 1, 2, 2, 2],
[1, 1, 2, 2, 2],
[1, 1, 2, 2, 2],
[3, 3, 3, 4, 4],
[3, 3, 3, 4, 4]])
See Also
========
sympy.matrices.matrices.MatrixBase.irregular
"""
def __new__(cls, *args, **kwargs):
from sympy.matrices.immutable import ImmutableDenseMatrix
from sympy.utilities.iterables import is_sequence
isMat = lambda i: getattr(i, 'is_Matrix', False)
if len(args) != 1 or \
not is_sequence(args[0]) or \
len({isMat(r) for r in args[0]}) != 1:
raise ValueError(filldedent('''
expecting a sequence of 1 or more rows
containing Matrices.'''))
rows = args[0] if args else []
if not isMat(rows):
if rows and isMat(rows[0]):
rows = [rows] # rows is not list of lists or []
# regularity check
# same number of matrices in each row
blocky = ok = len({len(r) for r in rows}) == 1
if ok:
# same number of rows for each matrix in a row
for r in rows:
ok = len({i.rows for i in r}) == 1
if not ok:
break
blocky = ok
if ok:
# same number of cols for each matrix in each col
for c in range(len(rows[0])):
ok = len({rows[i][c].cols
for i in range(len(rows))}) == 1
if not ok:
break
if not ok:
# same total cols in each row
ok = len({
sum([i.cols for i in r]) for r in rows}) == 1
if blocky and ok:
raise ValueError(filldedent('''
Although this matrix is comprised of blocks,
the blocks do not fill the matrix in a
size-symmetric fashion. To create a full matrix
from these arguments, pass them directly to
Matrix.'''))
raise ValueError(filldedent('''
When there are not the same number of rows in each
row's matrices or there are not the same number of
total columns in each row, the matrix is not a
block matrix. If this matrix is known to consist of
blocks fully filling a 2-D space then see
Matrix.irregular.'''))
mat = ImmutableDenseMatrix(rows, evaluate=False)
obj = Basic.__new__(cls, mat)
return obj
@property
def shape(self):
numrows = numcols = 0
M = self.blocks
for i in range(M.shape[0]):
numrows += M[i, 0].shape[0]
for i in range(M.shape[1]):
numcols += M[0, i].shape[1]
return (numrows, numcols)
@property
def blockshape(self):
return self.blocks.shape
@property
def blocks(self):
return self.args[0]
@property
def rowblocksizes(self):
return [self.blocks[i, 0].rows for i in range(self.blockshape[0])]
@property
def colblocksizes(self):
return [self.blocks[0, i].cols for i in range(self.blockshape[1])]
def structurally_equal(self, other):
return (isinstance(other, BlockMatrix)
and self.shape == other.shape
and self.blockshape == other.blockshape
and self.rowblocksizes == other.rowblocksizes
and self.colblocksizes == other.colblocksizes)
def _blockmul(self, other):
if (isinstance(other, BlockMatrix) and
self.colblocksizes == other.rowblocksizes):
return BlockMatrix(self.blocks*other.blocks)
return self * other
def _blockadd(self, other):
if (isinstance(other, BlockMatrix)
and self.structurally_equal(other)):
return BlockMatrix(self.blocks + other.blocks)
return self + other
def _eval_transpose(self):
# Flip all the individual matrices
matrices = [transpose(matrix) for matrix in self.blocks]
# Make a copy
M = Matrix(self.blockshape[0], self.blockshape[1], matrices)
# Transpose the block structure
M = M.transpose()
return BlockMatrix(M)
def _eval_trace(self):
if self.rowblocksizes == self.colblocksizes:
return Add(*[trace(self.blocks[i, i])
for i in range(self.blockshape[0])])
raise NotImplementedError(
"Can't perform trace of irregular blockshape")
def _eval_determinant(self):
if self.blockshape == (1, 1):
return det(self.blocks[0, 0])
if self.blockshape == (2, 2):
[[A, B],
[C, D]] = self.blocks.tolist()
if ask(Q.invertible(A)):
return det(A)*det(D - C*A.I*B)
elif ask(Q.invertible(D)):
return det(D)*det(A - B*D.I*C)
return Determinant(self)
def as_real_imag(self):
real_matrices = [re(matrix) for matrix in self.blocks]
real_matrices = Matrix(self.blockshape[0], self.blockshape[1], real_matrices)
im_matrices = [im(matrix) for matrix in self.blocks]
im_matrices = Matrix(self.blockshape[0], self.blockshape[1], im_matrices)
return (real_matrices, im_matrices)
def transpose(self):
"""Return transpose of matrix.
Examples
========
>>> from sympy import MatrixSymbol, BlockMatrix, ZeroMatrix
>>> from sympy.abc import l, m, n
>>> X = MatrixSymbol('X', n, n)
>>> Y = MatrixSymbol('Y', m ,m)
>>> Z = MatrixSymbol('Z', n, m)
>>> B = BlockMatrix([[X, Z], [ZeroMatrix(m,n), Y]])
>>> B.transpose()
Matrix([
[X.T, 0],
[Z.T, Y.T]])
>>> _.transpose()
Matrix([
[X, Z],
[0, Y]])
"""
return self._eval_transpose()
def _entry(self, i, j, **kwargs):
# Find row entry
orig_i, orig_j = i, j
for row_block, numrows in enumerate(self.rowblocksizes):
cmp = i < numrows
if cmp == True:
break
elif cmp == False:
i -= numrows
elif row_block < self.blockshape[0] - 1:
# Can't tell which block and it's not the last one, return unevaluated
return MatrixElement(self, orig_i, orig_j)
for col_block, numcols in enumerate(self.colblocksizes):
cmp = j < numcols
if cmp == True:
break
elif cmp == False:
j -= numcols
elif col_block < self.blockshape[1] - 1:
return MatrixElement(self, orig_i, orig_j)
return self.blocks[row_block, col_block][i, j]
@property
def is_Identity(self):
if self.blockshape[0] != self.blockshape[1]:
return False
for i in range(self.blockshape[0]):
for j in range(self.blockshape[1]):
if i==j and not self.blocks[i, j].is_Identity:
return False
if i!=j and not self.blocks[i, j].is_ZeroMatrix:
return False
return True
@property
def is_structurally_symmetric(self):
return self.rowblocksizes == self.colblocksizes
def equals(self, other):
if self == other:
return True
if (isinstance(other, BlockMatrix) and self.blocks == other.blocks):
return True
return super().equals(other)
class BlockDiagMatrix(BlockMatrix):
"""A sparse matrix with block matrices along its diagonals
Examples
========
>>> from sympy import MatrixSymbol, BlockDiagMatrix, symbols, Identity
>>> n, m, l = symbols('n m l')
>>> X = MatrixSymbol('X', n, n)
>>> Y = MatrixSymbol('Y', m ,m)
>>> BlockDiagMatrix(X, Y)
Matrix([
[X, 0],
[0, Y]])
Notes
=====
If you want to get the individual diagonal blocks, use
:meth:`get_diag_blocks`.
See Also
========
sympy.matrices.dense.diag
"""
def __new__(cls, *mats):
return Basic.__new__(BlockDiagMatrix, *[_sympify(m) for m in mats])
@property
def diag(self):
return self.args
@property
def blocks(self):
from sympy.matrices.immutable import ImmutableDenseMatrix
mats = self.args
data = [[mats[i] if i == j else ZeroMatrix(mats[i].rows, mats[j].cols)
for j in range(len(mats))]
for i in range(len(mats))]
return ImmutableDenseMatrix(data, evaluate=False)
@property
def shape(self):
return (sum(block.rows for block in self.args),
sum(block.cols for block in self.args))
@property
def blockshape(self):
n = len(self.args)
return (n, n)
@property
def rowblocksizes(self):
return [block.rows for block in self.args]
@property
def colblocksizes(self):
return [block.cols for block in self.args]
def _all_square_blocks(self):
"""Returns true if all blocks are square"""
return all(mat.is_square for mat in self.args)
def _eval_determinant(self):
if self._all_square_blocks():
return Mul(*[det(mat) for mat in self.args])
# At least one block is non-square. Since the entire matrix must be square we know there must
# be at least two blocks in this matrix, in which case the entire matrix is necessarily rank-deficient
return S.Zero
def _eval_inverse(self, expand='ignored'):
if self._all_square_blocks():
return BlockDiagMatrix(*[mat.inverse() for mat in self.args])
# See comment in _eval_determinant()
raise NonInvertibleMatrixError('Matrix det == 0; not invertible.')
def _eval_transpose(self):
return BlockDiagMatrix(*[mat.transpose() for mat in self.args])
def _blockmul(self, other):
if (isinstance(other, BlockDiagMatrix) and
self.colblocksizes == other.rowblocksizes):
return BlockDiagMatrix(*[a*b for a, b in zip(self.args, other.args)])
else:
return BlockMatrix._blockmul(self, other)
def _blockadd(self, other):
if (isinstance(other, BlockDiagMatrix) and
self.blockshape == other.blockshape and
self.rowblocksizes == other.rowblocksizes and
self.colblocksizes == other.colblocksizes):
return BlockDiagMatrix(*[a + b for a, b in zip(self.args, other.args)])
else:
return BlockMatrix._blockadd(self, other)
def get_diag_blocks(self):
"""Return the list of diagonal blocks of the matrix.
Examples
========
>>> from sympy.matrices import BlockDiagMatrix, Matrix
>>> A = Matrix([[1, 2], [3, 4]])
>>> B = Matrix([[5, 6], [7, 8]])
>>> M = BlockDiagMatrix(A, B)
How to get diagonal blocks from the block diagonal matrix:
>>> diag_blocks = M.get_diag_blocks()
>>> diag_blocks[0]
Matrix([
[1, 2],
[3, 4]])
>>> diag_blocks[1]
Matrix([
[5, 6],
[7, 8]])
"""
return self.args
def block_collapse(expr):
"""Evaluates a block matrix expression
>>> from sympy import MatrixSymbol, BlockMatrix, symbols, \
Identity, Matrix, ZeroMatrix, block_collapse
>>> n,m,l = symbols('n m l')
>>> X = MatrixSymbol('X', n, n)
>>> Y = MatrixSymbol('Y', m ,m)
>>> Z = MatrixSymbol('Z', n, m)
>>> B = BlockMatrix([[X, Z], [ZeroMatrix(m, n), Y]])
>>> print(B)
Matrix([
[X, Z],
[0, Y]])
>>> C = BlockMatrix([[Identity(n), Z]])
>>> print(C)
Matrix([[I, Z]])
>>> print(block_collapse(C*B))
Matrix([[X, Z + Z*Y]])
"""
from sympy.strategies.util import expr_fns
hasbm = lambda expr: isinstance(expr, MatrixExpr) and expr.has(BlockMatrix)
conditioned_rl = condition(
hasbm,
typed(
{MatAdd: do_one(bc_matadd, bc_block_plus_ident),
MatMul: do_one(bc_matmul, bc_dist),
MatPow: bc_matmul,
Transpose: bc_transpose,
Inverse: bc_inverse,
BlockMatrix: do_one(bc_unpack, deblock)}
)
)
rule = exhaust(
bottom_up(
exhaust(conditioned_rl),
fns=expr_fns
)
)
result = rule(expr)
doit = getattr(result, 'doit', None)
if doit is not None:
return doit()
else:
return result
def bc_unpack(expr):
if expr.blockshape == (1, 1):
return expr.blocks[0, 0]
return expr
def bc_matadd(expr):
args = sift(expr.args, lambda M: isinstance(M, BlockMatrix))
blocks = args[True]
if not blocks:
return expr
nonblocks = args[False]
block = blocks[0]
for b in blocks[1:]:
block = block._blockadd(b)
if nonblocks:
return MatAdd(*nonblocks) + block
else:
return block
def bc_block_plus_ident(expr):
idents = [arg for arg in expr.args if arg.is_Identity]
if not idents:
return expr
blocks = [arg for arg in expr.args if isinstance(arg, BlockMatrix)]
if (blocks and all(b.structurally_equal(blocks[0]) for b in blocks)
and blocks[0].is_structurally_symmetric):
block_id = BlockDiagMatrix(*[Identity(k)
for k in blocks[0].rowblocksizes])
rest = [arg for arg in expr.args if not arg.is_Identity and not isinstance(arg, BlockMatrix)]
return MatAdd(block_id * len(idents), *blocks, *rest).doit()
return expr
def bc_dist(expr):
""" Turn a*[X, Y] into [a*X, a*Y] """
factor, mat = expr.as_coeff_mmul()
if factor == 1:
return expr
unpacked = unpack(mat)
if isinstance(unpacked, BlockDiagMatrix):
B = unpacked.diag
new_B = [factor * mat for mat in B]
return BlockDiagMatrix(*new_B)
elif isinstance(unpacked, BlockMatrix):
B = unpacked.blocks
new_B = [
[factor * B[i, j] for j in range(B.cols)] for i in range(B.rows)]
return BlockMatrix(new_B)
return unpacked
def bc_matmul(expr):
if isinstance(expr, MatPow):
if expr.args[1].is_Integer:
factor, matrices = (1, [expr.args[0]]*expr.args[1])
else:
return expr
else:
factor, matrices = expr.as_coeff_matrices()
i = 0
while (i+1 < len(matrices)):
A, B = matrices[i:i+2]
if isinstance(A, BlockMatrix) and isinstance(B, BlockMatrix):
matrices[i] = A._blockmul(B)
matrices.pop(i+1)
elif isinstance(A, BlockMatrix):
matrices[i] = A._blockmul(BlockMatrix([[B]]))
matrices.pop(i+1)
elif isinstance(B, BlockMatrix):
matrices[i] = BlockMatrix([[A]])._blockmul(B)
matrices.pop(i+1)
else:
i+=1
return MatMul(factor, *matrices).doit()
def bc_transpose(expr):
collapse = block_collapse(expr.arg)
return collapse._eval_transpose()
def bc_inverse(expr):
if isinstance(expr.arg, BlockDiagMatrix):
return expr.inverse()
expr2 = blockinverse_1x1(expr)
if expr != expr2:
return expr2
return blockinverse_2x2(Inverse(reblock_2x2(expr.arg)))
def blockinverse_1x1(expr):
if isinstance(expr.arg, BlockMatrix) and expr.arg.blockshape == (1, 1):
mat = Matrix([[expr.arg.blocks[0].inverse()]])
return BlockMatrix(mat)
return expr
def blockinverse_2x2(expr):
if isinstance(expr.arg, BlockMatrix) and expr.arg.blockshape == (2, 2):
# See: Inverses of 2x2 Block Matrices, Tzon-Tzer Lu and Sheng-Hua Shiou
[[A, B],
[C, D]] = expr.arg.blocks.tolist()
formula = _choose_2x2_inversion_formula(A, B, C, D)
if formula == 'A':
AI = A.I
MI = (D - C * AI * B).I
return BlockMatrix([[AI + AI * B * MI * C * AI, -AI * B * MI], [-MI * C * AI, MI]])
if formula == 'B':
BI = B.I
MI = (C - D * BI * A).I
return BlockMatrix([[-MI * D * BI, MI], [BI + BI * A * MI * D * BI, -BI * A * MI]])
if formula == 'C':
CI = C.I
MI = (B - A * CI * D).I
return BlockMatrix([[-CI * D * MI, CI + CI * D * MI * A * CI], [MI, -MI * A * CI]])
if formula == 'D':
DI = D.I
MI = (A - B * DI * C).I
return BlockMatrix([[MI, -MI * B * DI], [-DI * C * MI, DI + DI * C * MI * B * DI]])
return expr
def _choose_2x2_inversion_formula(A, B, C, D):
"""
Assuming [[A, B], [C, D]] would form a valid square block matrix, find
which of the classical 2x2 block matrix inversion formulas would be
best suited.
Returns 'A', 'B', 'C', 'D' to represent the algorithm involving inversion
of the given argument or None if the matrix cannot be inverted using
any of those formulas.
"""
# Try to find a known invertible matrix. Note that the Schur complement
# is currently not being considered for this
A_inv = ask(Q.invertible(A))
if A_inv == True:
return 'A'
B_inv = ask(Q.invertible(B))
if B_inv == True:
return 'B'
C_inv = ask(Q.invertible(C))
if C_inv == True:
return 'C'
D_inv = ask(Q.invertible(D))
if D_inv == True:
return 'D'
# Otherwise try to find a matrix that isn't known to be non-invertible
if A_inv != False:
return 'A'
if B_inv != False:
return 'B'
if C_inv != False:
return 'C'
if D_inv != False:
return 'D'
return None
def deblock(B):
""" Flatten a BlockMatrix of BlockMatrices """
if not isinstance(B, BlockMatrix) or not B.blocks.has(BlockMatrix):
return B
wrap = lambda x: x if isinstance(x, BlockMatrix) else BlockMatrix([[x]])
bb = B.blocks.applyfunc(wrap) # everything is a block
from sympy import Matrix
try:
MM = Matrix(0, sum(bb[0, i].blocks.shape[1] for i in range(bb.shape[1])), [])
for row in range(0, bb.shape[0]):
M = Matrix(bb[row, 0].blocks)
for col in range(1, bb.shape[1]):
M = M.row_join(bb[row, col].blocks)
MM = MM.col_join(M)
return BlockMatrix(MM)
except ShapeError:
return B
def reblock_2x2(expr):
"""
Reblock a BlockMatrix so that it has 2x2 blocks of block matrices. If
possible in such a way that the matrix continues to be invertible using the
classical 2x2 block inversion formulas.
"""
if not isinstance(expr, BlockMatrix) or not all(d > 2 for d in expr.blockshape):
return expr
BM = BlockMatrix # for brevity's sake
rowblocks, colblocks = expr.blockshape
blocks = expr.blocks
for i in range(1, rowblocks):
for j in range(1, colblocks):
# try to split rows at i and cols at j
A = bc_unpack(BM(blocks[:i, :j]))
B = bc_unpack(BM(blocks[:i, j:]))
C = bc_unpack(BM(blocks[i:, :j]))
D = bc_unpack(BM(blocks[i:, j:]))
formula = _choose_2x2_inversion_formula(A, B, C, D)
if formula is not None:
return BlockMatrix([[A, B], [C, D]])
# else: nothing worked, just split upper left corner
return BM([[blocks[0, 0], BM(blocks[0, 1:])],
[BM(blocks[1:, 0]), BM(blocks[1:, 1:])]])
def bounds(sizes):
""" Convert sequence of numbers into pairs of low-high pairs
>>> from sympy.matrices.expressions.blockmatrix import bounds
>>> bounds((1, 10, 50))
[(0, 1), (1, 11), (11, 61)]
"""
low = 0
rv = []
for size in sizes:
rv.append((low, low + size))
low += size
return rv
def blockcut(expr, rowsizes, colsizes):
""" Cut a matrix expression into Blocks
>>> from sympy import ImmutableMatrix, blockcut
>>> M = ImmutableMatrix(4, 4, range(16))
>>> B = blockcut(M, (1, 3), (1, 3))
>>> type(B).__name__
'BlockMatrix'
>>> ImmutableMatrix(B.blocks[0, 1])
Matrix([[1, 2, 3]])
"""
rowbounds = bounds(rowsizes)
colbounds = bounds(colsizes)
return BlockMatrix([[MatrixSlice(expr, rowbound, colbound)
for colbound in colbounds]
for rowbound in rowbounds])
|
24089f9857e11ae452293b59085553e1d68875f297feb92d21efbd9a77c9b1c8 | from .matexpr import MatrixExpr
from sympy.core.function import FunctionClass, Lambda
from sympy.core.symbol import Dummy
from sympy.core.sympify import _sympify, sympify
from sympy.matrices import Matrix
from sympy.functions.elementary.complexes import re, im
class FunctionMatrix(MatrixExpr):
"""Represents a matrix using a function (``Lambda``) which gives
outputs according to the coordinates of each matrix entries.
Parameters
==========
rows : nonnegative integer. Can be symbolic.
cols : nonnegative integer. Can be symbolic.
lamda : Function, Lambda or str
If it is a SymPy ``Function`` or ``Lambda`` instance,
it should be able to accept two arguments which represents the
matrix coordinates.
If it is a pure string containing python ``lambda`` semantics,
it is interpreted by the SymPy parser and casted into a SymPy
``Lambda`` instance.
Examples
========
Creating a ``FunctionMatrix`` from ``Lambda``:
>>> from sympy import FunctionMatrix, symbols, Lambda, MatPow, Matrix
>>> i, j, n, m = symbols('i,j,n,m')
>>> FunctionMatrix(n, m, Lambda((i, j), i + j))
FunctionMatrix(n, m, Lambda((i, j), i + j))
Creating a ``FunctionMatrix`` from a sympy function:
>>> from sympy.functions import KroneckerDelta
>>> X = FunctionMatrix(3, 3, KroneckerDelta)
>>> X.as_explicit()
Matrix([
[1, 0, 0],
[0, 1, 0],
[0, 0, 1]])
Creating a ``FunctionMatrix`` from a sympy undefined function:
>>> from sympy.core.function import Function
>>> f = Function('f')
>>> X = FunctionMatrix(3, 3, f)
>>> X.as_explicit()
Matrix([
[f(0, 0), f(0, 1), f(0, 2)],
[f(1, 0), f(1, 1), f(1, 2)],
[f(2, 0), f(2, 1), f(2, 2)]])
Creating a ``FunctionMatrix`` from python ``lambda``:
>>> FunctionMatrix(n, m, 'lambda i, j: i + j')
FunctionMatrix(n, m, Lambda((i, j), i + j))
Example of lazy evaluation of matrix product:
>>> Y = FunctionMatrix(1000, 1000, Lambda((i, j), i + j))
>>> isinstance(Y*Y, MatPow) # this is an expression object
True
>>> (Y**2)[10,10] # So this is evaluated lazily
342923500
Notes
=====
This class provides an alternative way to represent an extremely
dense matrix with entries in some form of a sequence, in a most
sparse way.
"""
def __new__(cls, rows, cols, lamda):
rows, cols = _sympify(rows), _sympify(cols)
cls._check_dim(rows)
cls._check_dim(cols)
lamda = sympify(lamda)
if not isinstance(lamda, (FunctionClass, Lambda)):
raise ValueError(
"{} should be compatible with SymPy function classes."
.format(lamda))
if 2 not in lamda.nargs:
raise ValueError(
'{} should be able to accept 2 arguments.'.format(lamda))
if not isinstance(lamda, Lambda):
i, j = Dummy('i'), Dummy('j')
lamda = Lambda((i, j), lamda(i, j))
return super().__new__(cls, rows, cols, lamda)
@property
def shape(self):
return self.args[0:2]
@property
def lamda(self):
return self.args[2]
def _entry(self, i, j, **kwargs):
return self.lamda(i, j)
def _eval_trace(self):
from sympy.matrices.expressions.trace import Trace
from sympy import Sum
return Trace(self).rewrite(Sum).doit()
def as_real_imag(self):
return (re(Matrix(self)), im(Matrix(self)))
|
68e6639bb5a35c4b828dc301c3aedf467dd5465cbdbc4fd262b6993543604510 | from sympy.core.compatibility import reduce
from operator import add
from sympy.core import Add, Basic, sympify
from sympy.functions import adjoint
from sympy.matrices.common import ShapeError
from sympy.matrices.matrices import MatrixBase
from sympy.matrices.expressions.transpose import transpose
from sympy.strategies import (rm_id, unpack, flatten, sort, condition,
exhaust, do_one, glom)
from sympy.matrices.expressions.matexpr import (MatrixExpr, ZeroMatrix,
GenericZeroMatrix)
from sympy.utilities import default_sort_key, sift
# XXX: MatAdd should perhaps not subclass directly from Add
class MatAdd(MatrixExpr, Add):
"""A Sum of Matrix Expressions
MatAdd inherits from and operates like SymPy Add
Examples
========
>>> from sympy import MatAdd, MatrixSymbol
>>> A = MatrixSymbol('A', 5, 5)
>>> B = MatrixSymbol('B', 5, 5)
>>> C = MatrixSymbol('C', 5, 5)
>>> MatAdd(A, B, C)
A + B + C
"""
is_MatAdd = True
identity = GenericZeroMatrix()
def __new__(cls, *args, evaluate=False, **kwargs):
if not args:
return cls.identity
# This must be removed aggressively in the constructor to avoid
# TypeErrors from GenericZeroMatrix().shape
args = filter(lambda i: cls.identity != i, args)
args = list(map(sympify, args))
check = kwargs.get('check', False)
obj = Basic.__new__(cls, *args)
if check:
if all(not isinstance(i, MatrixExpr) for i in args):
return Add.fromiter(args)
validate(*args)
if evaluate:
if all(not isinstance(i, MatrixExpr) for i in args):
return Add(*args, evaluate=True)
obj = canonicalize(obj)
return obj
@property
def shape(self):
return self.args[0].shape
def _entry(self, i, j, **kwargs):
return Add(*[arg._entry(i, j, **kwargs) for arg in self.args])
def _eval_transpose(self):
return MatAdd(*[transpose(arg) for arg in self.args]).doit()
def _eval_adjoint(self):
return MatAdd(*[adjoint(arg) for arg in self.args]).doit()
def _eval_trace(self):
from .trace import trace
return Add(*[trace(arg) for arg in self.args]).doit()
def doit(self, **kwargs):
deep = kwargs.get('deep', True)
if deep:
args = [arg.doit(**kwargs) for arg in self.args]
else:
args = self.args
return canonicalize(MatAdd(*args))
def _eval_derivative_matrix_lines(self, x):
add_lines = [arg._eval_derivative_matrix_lines(x) for arg in self.args]
return [j for i in add_lines for j in i]
def validate(*args):
if not all(arg.is_Matrix for arg in args):
raise TypeError("Mix of Matrix and Scalar symbols")
A = args[0]
for B in args[1:]:
if A.shape != B.shape:
raise ShapeError("Matrices %s and %s are not aligned"%(A, B))
factor_of = lambda arg: arg.as_coeff_mmul()[0]
matrix_of = lambda arg: unpack(arg.as_coeff_mmul()[1])
def combine(cnt, mat):
if cnt == 1:
return mat
else:
return cnt * mat
def merge_explicit(matadd):
""" Merge explicit MatrixBase arguments
Examples
========
>>> from sympy import MatrixSymbol, eye, Matrix, MatAdd, pprint
>>> from sympy.matrices.expressions.matadd import merge_explicit
>>> A = MatrixSymbol('A', 2, 2)
>>> B = eye(2)
>>> C = Matrix([[1, 2], [3, 4]])
>>> X = MatAdd(A, B, C)
>>> pprint(X)
[1 0] [1 2]
A + [ ] + [ ]
[0 1] [3 4]
>>> pprint(merge_explicit(X))
[2 2]
A + [ ]
[3 5]
"""
groups = sift(matadd.args, lambda arg: isinstance(arg, MatrixBase))
if len(groups[True]) > 1:
return MatAdd(*(groups[False] + [reduce(add, groups[True])]))
else:
return matadd
rules = (rm_id(lambda x: x == 0 or isinstance(x, ZeroMatrix)),
unpack,
flatten,
glom(matrix_of, factor_of, combine),
merge_explicit,
sort(default_sort_key))
canonicalize = exhaust(condition(lambda x: isinstance(x, MatAdd),
do_one(*rules)))
|
95e794a2f26d95f93b2fd1c4a8d914b25e63fcb091ef2f1bda297d7953c76d21 | from sympy.matrices.expressions.matexpr import MatrixExpr
from sympy import Tuple, Basic
from sympy.functions.elementary.integers import floor
def normalize(i, parentsize):
if isinstance(i, slice):
i = (i.start, i.stop, i.step)
if not isinstance(i, (tuple, list, Tuple)):
if (i < 0) == True:
i += parentsize
i = (i, i+1, 1)
i = list(i)
if len(i) == 2:
i.append(1)
start, stop, step = i
start = start or 0
if stop is None:
stop = parentsize
if (start < 0) == True:
start += parentsize
if (stop < 0) == True:
stop += parentsize
step = step or 1
if ((stop - start) * step < 1) == True:
raise IndexError()
return (start, stop, step)
class MatrixSlice(MatrixExpr):
""" A MatrixSlice of a Matrix Expression
Examples
========
>>> from sympy import MatrixSlice, ImmutableMatrix
>>> M = ImmutableMatrix(4, 4, range(16))
>>> M
Matrix([
[ 0, 1, 2, 3],
[ 4, 5, 6, 7],
[ 8, 9, 10, 11],
[12, 13, 14, 15]])
>>> B = MatrixSlice(M, (0, 2), (2, 4))
>>> ImmutableMatrix(B)
Matrix([
[2, 3],
[6, 7]])
"""
parent = property(lambda self: self.args[0])
rowslice = property(lambda self: self.args[1])
colslice = property(lambda self: self.args[2])
def __new__(cls, parent, rowslice, colslice):
rowslice = normalize(rowslice, parent.shape[0])
colslice = normalize(colslice, parent.shape[1])
if not (len(rowslice) == len(colslice) == 3):
raise IndexError()
if ((0 > rowslice[0]) == True or
(parent.shape[0] < rowslice[1]) == True or
(0 > colslice[0]) == True or
(parent.shape[1] < colslice[1]) == True):
raise IndexError()
if isinstance(parent, MatrixSlice):
return mat_slice_of_slice(parent, rowslice, colslice)
return Basic.__new__(cls, parent, Tuple(*rowslice), Tuple(*colslice))
@property
def shape(self):
rows = self.rowslice[1] - self.rowslice[0]
rows = rows if self.rowslice[2] == 1 else floor(rows/self.rowslice[2])
cols = self.colslice[1] - self.colslice[0]
cols = cols if self.colslice[2] == 1 else floor(cols/self.colslice[2])
return rows, cols
def _entry(self, i, j, **kwargs):
return self.parent._entry(i*self.rowslice[2] + self.rowslice[0],
j*self.colslice[2] + self.colslice[0],
**kwargs)
@property
def on_diag(self):
return self.rowslice == self.colslice
def slice_of_slice(s, t):
start1, stop1, step1 = s
start2, stop2, step2 = t
start = start1 + start2*step1
step = step1 * step2
stop = start1 + step1*stop2
if stop > stop1:
raise IndexError()
return start, stop, step
def mat_slice_of_slice(parent, rowslice, colslice):
""" Collapse nested matrix slices
>>> from sympy import MatrixSymbol
>>> X = MatrixSymbol('X', 10, 10)
>>> X[:, 1:5][5:8, :]
X[5:8, 1:5]
>>> X[1:9:2, 2:6][1:3, 2]
X[3:7:2, 4:5]
"""
row = slice_of_slice(parent.rowslice, rowslice)
col = slice_of_slice(parent.colslice, colslice)
return MatrixSlice(parent.parent, row, col)
|
e16708b294ccae22e6b9c5c247d941b5dcc8ce3533123d73379e86cecc82868a | from sympy import Trace
from sympy.testing.pytest import raises, slow
from sympy.matrices.expressions.blockmatrix import (
block_collapse, bc_matmul, bc_block_plus_ident, BlockDiagMatrix,
BlockMatrix, bc_dist, bc_matadd, bc_transpose, bc_inverse,
blockcut, reblock_2x2, deblock)
from sympy.matrices.expressions import (MatrixSymbol, Identity,
Inverse, trace, Transpose, det, ZeroMatrix)
from sympy.matrices.common import NonInvertibleMatrixError
from sympy.matrices import (
Matrix, ImmutableMatrix, ImmutableSparseMatrix)
from sympy.core import Tuple, symbols, Expr
from sympy.functions import transpose
i, j, k, l, m, n, p = symbols('i:n, p', integer=True)
A = MatrixSymbol('A', n, n)
B = MatrixSymbol('B', n, n)
C = MatrixSymbol('C', n, n)
D = MatrixSymbol('D', n, n)
G = MatrixSymbol('G', n, n)
H = MatrixSymbol('H', n, n)
b1 = BlockMatrix([[G, H]])
b2 = BlockMatrix([[G], [H]])
def test_bc_matmul():
assert bc_matmul(H*b1*b2*G) == BlockMatrix([[(H*G*G + H*H*H)*G]])
def test_bc_matadd():
assert bc_matadd(BlockMatrix([[G, H]]) + BlockMatrix([[H, H]])) == \
BlockMatrix([[G+H, H+H]])
def test_bc_transpose():
assert bc_transpose(Transpose(BlockMatrix([[A, B], [C, D]]))) == \
BlockMatrix([[A.T, C.T], [B.T, D.T]])
def test_bc_dist_diag():
A = MatrixSymbol('A', n, n)
B = MatrixSymbol('B', m, m)
C = MatrixSymbol('C', l, l)
X = BlockDiagMatrix(A, B, C)
assert bc_dist(X+X).equals(BlockDiagMatrix(2*A, 2*B, 2*C))
def test_block_plus_ident():
A = MatrixSymbol('A', n, n)
B = MatrixSymbol('B', n, m)
C = MatrixSymbol('C', m, n)
D = MatrixSymbol('D', m, m)
X = BlockMatrix([[A, B], [C, D]])
Z = MatrixSymbol('Z', n + m, n + m)
assert bc_block_plus_ident(X + Identity(m + n) + Z) == \
BlockDiagMatrix(Identity(n), Identity(m)) + X + Z
def test_BlockMatrix():
A = MatrixSymbol('A', n, m)
B = MatrixSymbol('B', n, k)
C = MatrixSymbol('C', l, m)
D = MatrixSymbol('D', l, k)
M = MatrixSymbol('M', m + k, p)
N = MatrixSymbol('N', l + n, k + m)
X = BlockMatrix(Matrix([[A, B], [C, D]]))
assert X.__class__(*X.args) == X
# block_collapse does nothing on normal inputs
E = MatrixSymbol('E', n, m)
assert block_collapse(A + 2*E) == A + 2*E
F = MatrixSymbol('F', m, m)
assert block_collapse(E.T*A*F) == E.T*A*F
assert X.shape == (l + n, k + m)
assert X.blockshape == (2, 2)
assert transpose(X) == BlockMatrix(Matrix([[A.T, C.T], [B.T, D.T]]))
assert transpose(X).shape == X.shape[::-1]
# Test that BlockMatrices and MatrixSymbols can still mix
assert (X*M).is_MatMul
assert X._blockmul(M).is_MatMul
assert (X*M).shape == (n + l, p)
assert (X + N).is_MatAdd
assert X._blockadd(N).is_MatAdd
assert (X + N).shape == X.shape
E = MatrixSymbol('E', m, 1)
F = MatrixSymbol('F', k, 1)
Y = BlockMatrix(Matrix([[E], [F]]))
assert (X*Y).shape == (l + n, 1)
assert block_collapse(X*Y).blocks[0, 0] == A*E + B*F
assert block_collapse(X*Y).blocks[1, 0] == C*E + D*F
# block_collapse passes down into container objects, transposes, and inverse
assert block_collapse(transpose(X*Y)) == transpose(block_collapse(X*Y))
assert block_collapse(Tuple(X*Y, 2*X)) == (
block_collapse(X*Y), block_collapse(2*X))
# Make sure that MatrixSymbols will enter 1x1 BlockMatrix if it simplifies
Ab = BlockMatrix([[A]])
Z = MatrixSymbol('Z', *A.shape)
assert block_collapse(Ab + Z) == A + Z
def test_block_collapse_explicit_matrices():
A = Matrix([[1, 2], [3, 4]])
assert block_collapse(BlockMatrix([[A]])) == A
A = ImmutableSparseMatrix([[1, 2], [3, 4]])
assert block_collapse(BlockMatrix([[A]])) == A
def test_issue_17624():
a = MatrixSymbol("a", 2, 2)
z = ZeroMatrix(2, 2)
b = BlockMatrix([[a, z], [z, z]])
assert block_collapse(b * b) == BlockMatrix([[a**2, z], [z, z]])
assert block_collapse(b * b * b) == BlockMatrix([[a**3, z], [z, z]])
def test_issue_18618():
A = Matrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
assert A == Matrix(BlockDiagMatrix(A))
def test_BlockMatrix_trace():
A, B, C, D = [MatrixSymbol(s, 3, 3) for s in 'ABCD']
X = BlockMatrix([[A, B], [C, D]])
assert trace(X) == trace(A) + trace(D)
assert trace(BlockMatrix([ZeroMatrix(n, n)])) == 0
def test_BlockMatrix_Determinant():
A, B, C, D = [MatrixSymbol(s, 3, 3) for s in 'ABCD']
X = BlockMatrix([[A, B], [C, D]])
from sympy import assuming, Q
with assuming(Q.invertible(A)):
assert det(X) == det(A) * det(D - C*A.I*B)
assert isinstance(det(X), Expr)
assert det(BlockMatrix([A])) == det(A)
assert det(BlockMatrix([ZeroMatrix(n, n)])) == 0
def test_squareBlockMatrix():
A = MatrixSymbol('A', n, n)
B = MatrixSymbol('B', n, m)
C = MatrixSymbol('C', m, n)
D = MatrixSymbol('D', m, m)
X = BlockMatrix([[A, B], [C, D]])
Y = BlockMatrix([[A]])
assert X.is_square
Q = X + Identity(m + n)
assert (block_collapse(Q) ==
BlockMatrix([[A + Identity(n), B], [C, D + Identity(m)]]))
assert (X + MatrixSymbol('Q', n + m, n + m)).is_MatAdd
assert (X * MatrixSymbol('Q', n + m, n + m)).is_MatMul
assert block_collapse(Y.I) == A.I
assert isinstance(X.inverse(), Inverse)
assert not X.is_Identity
Z = BlockMatrix([[Identity(n), B], [C, D]])
assert not Z.is_Identity
def test_BlockMatrix_2x2_inverse_symbolic():
A = MatrixSymbol('A', n, m)
B = MatrixSymbol('B', n, k - m)
C = MatrixSymbol('C', k - n, m)
D = MatrixSymbol('D', k - n, k - m)
X = BlockMatrix([[A, B], [C, D]])
assert X.is_square and X.shape == (k, k)
assert isinstance(block_collapse(X.I), Inverse) # Can't invert when none of the blocks is square
# test code path where only A is invertible
A = MatrixSymbol('A', n, n)
B = MatrixSymbol('B', n, m)
C = MatrixSymbol('C', m, n)
D = ZeroMatrix(m, m)
X = BlockMatrix([[A, B], [C, D]])
assert block_collapse(X.inverse()) == BlockMatrix([
[A.I + A.I * B * (D - C * A.I * B).I * C * A.I, -A.I * B * (D - C * A.I * B).I],
[-(D - C * A.I * B).I * C * A.I, (D - C * A.I * B).I],
])
# test code path where only B is invertible
A = MatrixSymbol('A', n, m)
B = MatrixSymbol('B', n, n)
C = ZeroMatrix(m, m)
D = MatrixSymbol('D', m, n)
X = BlockMatrix([[A, B], [C, D]])
assert block_collapse(X.inverse()) == BlockMatrix(([
[-(C - D * B.I * A).I * D * B.I, (C - D * B.I * A).I],
[B.I + B.I * A * (C - D * B.I * A).I * D * B.I, -B.I * A * (C - D * B.I * A).I],
]))
# test code path where only C is invertible
A = MatrixSymbol('A', n, m)
B = ZeroMatrix(n, n)
C = MatrixSymbol('C', m, m)
D = MatrixSymbol('D', m, n)
X = BlockMatrix([[A, B], [C, D]])
assert block_collapse(X.inverse()) == BlockMatrix([
[-C.I * D * (B - A * C.I * D).I, C.I + C.I * D * (B - A * C.I * D).I * A * C.I],
[(B - A * C.I * D).I, -(B - A * C.I * D).I * A * C.I],
])
# test code path where only D is invertible
A = ZeroMatrix(n, n)
B = MatrixSymbol('B', n, m)
C = MatrixSymbol('C', m, n)
D = MatrixSymbol('D', m, m)
X = BlockMatrix([[A, B], [C, D]])
assert block_collapse(X.inverse()) == BlockMatrix([
[(A - B * D.I * C).I, -(A - B * D.I * C).I * B * D.I],
[-D.I * C * (A - B * D.I * C).I, D.I + D.I * C * (A - B * D.I * C).I * B * D.I],
])
def test_BlockMatrix_2x2_inverse_numeric():
"""Test 2x2 block matrix inversion numerically for all 4 formulas"""
M = Matrix([[1, 2], [3, 4]])
# rank deficient matrices that have full rank when two of them combined
D1 = Matrix([[1, 2], [2, 4]])
D2 = Matrix([[1, 3], [3, 9]])
D3 = Matrix([[1, 4], [4, 16]])
assert D1.rank() == D2.rank() == D3.rank() == 1
assert (D1 + D2).rank() == (D2 + D3).rank() == (D3 + D1).rank() == 2
# Only A is invertible
K = BlockMatrix([[M, D1], [D2, D3]])
assert block_collapse(K.inv()).as_explicit() == K.as_explicit().inv()
# Only B is invertible
K = BlockMatrix([[D1, M], [D2, D3]])
assert block_collapse(K.inv()).as_explicit() == K.as_explicit().inv()
# Only C is invertible
K = BlockMatrix([[D1, D2], [M, D3]])
assert block_collapse(K.inv()).as_explicit() == K.as_explicit().inv()
# Only D is invertible
K = BlockMatrix([[D1, D2], [D3, M]])
assert block_collapse(K.inv()).as_explicit() == K.as_explicit().inv()
@slow
def test_BlockMatrix_3x3_symbolic():
# Only test one of these, instead of all permutations, because it's slow
rowblocksizes = (n, m, k)
colblocksizes = (m, k, n)
K = BlockMatrix([
[MatrixSymbol('M%s%s' % (rows, cols), rows, cols) for cols in colblocksizes]
for rows in rowblocksizes
])
collapse = block_collapse(K.I)
assert isinstance(collapse, BlockMatrix)
def test_BlockDiagMatrix():
A = MatrixSymbol('A', n, n)
B = MatrixSymbol('B', m, m)
C = MatrixSymbol('C', l, l)
M = MatrixSymbol('M', n + m + l, n + m + l)
X = BlockDiagMatrix(A, B, C)
Y = BlockDiagMatrix(A, 2*B, 3*C)
assert X.blocks[1, 1] == B
assert X.shape == (n + m + l, n + m + l)
assert all(X.blocks[i, j].is_ZeroMatrix if i != j else X.blocks[i, j] in [A, B, C]
for i in range(3) for j in range(3))
assert X.__class__(*X.args) == X
assert X.get_diag_blocks() == (A, B, C)
assert isinstance(block_collapse(X.I * X), Identity)
assert bc_matmul(X*X) == BlockDiagMatrix(A*A, B*B, C*C)
assert block_collapse(X*X) == BlockDiagMatrix(A*A, B*B, C*C)
#XXX: should be == ??
assert block_collapse(X + X).equals(BlockDiagMatrix(2*A, 2*B, 2*C))
assert block_collapse(X*Y) == BlockDiagMatrix(A*A, 2*B*B, 3*C*C)
assert block_collapse(X + Y) == BlockDiagMatrix(2*A, 3*B, 4*C)
# Ensure that BlockDiagMatrices can still interact with normal MatrixExprs
assert (X*(2*M)).is_MatMul
assert (X + (2*M)).is_MatAdd
assert (X._blockmul(M)).is_MatMul
assert (X._blockadd(M)).is_MatAdd
def test_BlockDiagMatrix_nonsquare():
A = MatrixSymbol('A', n, m)
B = MatrixSymbol('B', k, l)
X = BlockDiagMatrix(A, B)
assert X.shape == (n + k, m + l)
assert X.shape == (n + k, m + l)
assert X.rowblocksizes == [n, k]
assert X.colblocksizes == [m, l]
C = MatrixSymbol('C', n, m)
D = MatrixSymbol('D', k, l)
Y = BlockDiagMatrix(C, D)
assert block_collapse(X + Y) == BlockDiagMatrix(A + C, B + D)
assert block_collapse(X * Y.T) == BlockDiagMatrix(A * C.T, B * D.T)
raises(NonInvertibleMatrixError, lambda: BlockDiagMatrix(A, C.T).inverse())
def test_BlockDiagMatrix_determinant():
A = MatrixSymbol('A', n, n)
B = MatrixSymbol('B', m, m)
assert det(BlockDiagMatrix()) == 1
assert det(BlockDiagMatrix(A)) == det(A)
assert det(BlockDiagMatrix(A, B)) == det(A) * det(B)
# non-square blocks
C = MatrixSymbol('C', m, n)
D = MatrixSymbol('D', n, m)
assert det(BlockDiagMatrix(C, D)) == 0
def test_BlockDiagMatrix_trace():
assert trace(BlockDiagMatrix()) == 0
assert trace(BlockDiagMatrix(ZeroMatrix(n, n))) == 0
A = MatrixSymbol('A', n, n)
assert trace(BlockDiagMatrix(A)) == trace(A)
B = MatrixSymbol('B', m, m)
assert trace(BlockDiagMatrix(A, B)) == trace(A) + trace(B)
# non-square blocks
C = MatrixSymbol('C', m, n)
D = MatrixSymbol('D', n, m)
assert isinstance(trace(BlockDiagMatrix(C, D)), Trace)
def test_BlockDiagMatrix_transpose():
A = MatrixSymbol('A', n, m)
B = MatrixSymbol('B', k, l)
assert transpose(BlockDiagMatrix()) == BlockDiagMatrix()
assert transpose(BlockDiagMatrix(A)) == BlockDiagMatrix(A.T)
assert transpose(BlockDiagMatrix(A, B)) == BlockDiagMatrix(A.T, B.T)
def test_issue_2460():
bdm1 = BlockDiagMatrix(Matrix([i]), Matrix([j]))
bdm2 = BlockDiagMatrix(Matrix([k]), Matrix([l]))
assert block_collapse(bdm1 + bdm2) == BlockDiagMatrix(Matrix([i + k]), Matrix([j + l]))
def test_blockcut():
A = MatrixSymbol('A', n, m)
B = blockcut(A, (n/2, n/2), (m/2, m/2))
assert B == BlockMatrix([[A[:n/2, :m/2], A[:n/2, m/2:]],
[A[n/2:, :m/2], A[n/2:, m/2:]]])
M = ImmutableMatrix(4, 4, range(16))
B = blockcut(M, (2, 2), (2, 2))
assert M == ImmutableMatrix(B)
B = blockcut(M, (1, 3), (2, 2))
assert ImmutableMatrix(B.blocks[0, 1]) == ImmutableMatrix([[2, 3]])
def test_reblock_2x2():
B = BlockMatrix([[MatrixSymbol('A_%d%d'%(i,j), 2, 2)
for j in range(3)]
for i in range(3)])
assert B.blocks.shape == (3, 3)
BB = reblock_2x2(B)
assert BB.blocks.shape == (2, 2)
assert B.shape == BB.shape
assert B.as_explicit() == BB.as_explicit()
def test_deblock():
B = BlockMatrix([[MatrixSymbol('A_%d%d'%(i,j), n, n)
for j in range(4)]
for i in range(4)])
assert deblock(reblock_2x2(B)) == B
def test_block_collapse_type():
bm1 = BlockDiagMatrix(ImmutableMatrix([1]), ImmutableMatrix([2]))
bm2 = BlockDiagMatrix(ImmutableMatrix([3]), ImmutableMatrix([4]))
assert bm1.T.__class__ == BlockDiagMatrix
assert block_collapse(bm1 - bm2).__class__ == BlockDiagMatrix
assert block_collapse(Inverse(bm1)).__class__ == BlockDiagMatrix
assert block_collapse(Transpose(bm1)).__class__ == BlockDiagMatrix
assert bc_transpose(Transpose(bm1)).__class__ == BlockDiagMatrix
assert bc_inverse(Inverse(bm1)).__class__ == BlockDiagMatrix
def test_invalid_block_matrix():
raises(ValueError, lambda: BlockMatrix([
[Identity(2), Identity(5)],
]))
raises(ValueError, lambda: BlockMatrix([
[Identity(n), Identity(m)],
]))
raises(ValueError, lambda: BlockMatrix([
[ZeroMatrix(n, n), ZeroMatrix(n, n)],
[ZeroMatrix(n, n - 1), ZeroMatrix(n, n + 1)],
]))
raises(ValueError, lambda: BlockMatrix([
[ZeroMatrix(n - 1, n), ZeroMatrix(n, n)],
[ZeroMatrix(n + 1, n), ZeroMatrix(n, n)],
]))
|
fcfb037a2ac34f553af75826f6a056d34f8f848c40bb69d6d663ce8854e99c47 | from sympy.core import symbols, Lambda
from sympy.functions import KroneckerDelta
from sympy.matrices import Matrix
from sympy.matrices.expressions import FunctionMatrix, MatrixExpr, Identity
from sympy.testing.pytest import raises, warns_deprecated_sympy
def test_funcmatrix_creation():
i, j, k = symbols('i j k')
assert FunctionMatrix(2, 2, Lambda((i, j), 0))
assert FunctionMatrix(0, 0, Lambda((i, j), 0))
raises(ValueError, lambda: FunctionMatrix(-1, 0, Lambda((i, j), 0)))
raises(ValueError, lambda: FunctionMatrix(2.0, 0, Lambda((i, j), 0)))
raises(ValueError, lambda: FunctionMatrix(2j, 0, Lambda((i, j), 0)))
raises(ValueError, lambda: FunctionMatrix(0, -1, Lambda((i, j), 0)))
raises(ValueError, lambda: FunctionMatrix(0, 2.0, Lambda((i, j), 0)))
raises(ValueError, lambda: FunctionMatrix(0, 2j, Lambda((i, j), 0)))
raises(ValueError, lambda: FunctionMatrix(2, 2, Lambda(i, 0)))
with warns_deprecated_sympy():
raises(ValueError, lambda: FunctionMatrix(2, 2, lambda i, j: 0))
raises(ValueError, lambda: FunctionMatrix(2, 2, Lambda((i,), 0)))
raises(ValueError, lambda: FunctionMatrix(2, 2, Lambda((i, j, k), 0)))
raises(ValueError, lambda: FunctionMatrix(2, 2, i+j))
assert FunctionMatrix(2, 2, "lambda i, j: 0") == \
FunctionMatrix(2, 2, Lambda((i, j), 0))
m = FunctionMatrix(2, 2, KroneckerDelta)
assert m.as_explicit() == Identity(2).as_explicit()
assert m.args[2] == Lambda((i, j), KroneckerDelta(i, j))
n = symbols('n')
assert FunctionMatrix(n, n, Lambda((i, j), 0))
n = symbols('n', integer=False)
raises(ValueError, lambda: FunctionMatrix(n, n, Lambda((i, j), 0)))
n = symbols('n', negative=True)
raises(ValueError, lambda: FunctionMatrix(n, n, Lambda((i, j), 0)))
def test_funcmatrix():
i, j = symbols('i,j')
X = FunctionMatrix(3, 3, Lambda((i, j), i - j))
assert X[1, 1] == 0
assert X[1, 2] == -1
assert X.shape == (3, 3)
assert X.rows == X.cols == 3
assert Matrix(X) == Matrix(3, 3, lambda i, j: i - j)
assert isinstance(X*X + X, MatrixExpr)
def test_replace_issue():
X = FunctionMatrix(3, 3, KroneckerDelta)
assert X.replace(lambda x: True, lambda x: x) == X
|
79ed392771c0c66406d2209b453ea23290bbfe3e8f90b00baebc2148de69ffce | from sympy.simplify.powsimp import powsimp
from sympy.testing.pytest import raises
from sympy.core.expr import unchanged
from sympy.core import symbols, S
from sympy.matrices import Identity, MatrixSymbol, ImmutableMatrix, ZeroMatrix, OneMatrix
from sympy.matrices.common import NonSquareMatrixError
from sympy.matrices.expressions import MatPow, MatAdd, MatMul
from sympy.matrices.expressions.inverse import Inverse
from sympy.matrices.expressions.matexpr import MatrixElement
n, m, l, k = symbols('n m l k', integer=True)
A = MatrixSymbol('A', n, m)
B = MatrixSymbol('B', m, l)
C = MatrixSymbol('C', n, n)
D = MatrixSymbol('D', n, n)
E = MatrixSymbol('E', m, n)
def test_entry_matrix():
X = ImmutableMatrix([[1, 2], [3, 4]])
assert MatPow(X, 0)[0, 0] == 1
assert MatPow(X, 0)[0, 1] == 0
assert MatPow(X, 1)[0, 0] == 1
assert MatPow(X, 1)[0, 1] == 2
assert MatPow(X, 2)[0, 0] == 7
def test_entry_symbol():
from sympy.concrete import Sum
assert MatPow(C, 0)[0, 0] == 1
assert MatPow(C, 0)[0, 1] == 0
assert MatPow(C, 1)[0, 0] == C[0, 0]
assert isinstance(MatPow(C, 2)[0, 0], Sum)
assert isinstance(MatPow(C, n)[0, 0], MatrixElement)
def test_as_explicit_symbol():
X = MatrixSymbol('X', 2, 2)
assert MatPow(X, 0).as_explicit() == ImmutableMatrix(Identity(2))
assert MatPow(X, 1).as_explicit() == X.as_explicit()
assert MatPow(X, 2).as_explicit() == (X.as_explicit())**2
assert MatPow(X, n).as_explicit() == ImmutableMatrix([
[(X ** n)[0, 0], (X ** n)[0, 1]],
[(X ** n)[1, 0], (X ** n)[1, 1]],
])
def test_as_explicit_matrix():
A = ImmutableMatrix([[1, 2], [3, 4]])
assert MatPow(A, 0).as_explicit() == ImmutableMatrix(Identity(2))
assert MatPow(A, 1).as_explicit() == A
assert MatPow(A, 2).as_explicit() == A**2
assert MatPow(A, -1).as_explicit() == A.inv()
assert MatPow(A, -2).as_explicit() == (A.inv())**2
# less expensive than testing on a 2x2
A = ImmutableMatrix([4])
assert MatPow(A, S.Half).as_explicit() == A**S.Half
def test_doit_symbol():
assert MatPow(C, 0).doit() == Identity(n)
assert MatPow(C, 1).doit() == C
assert MatPow(C, -1).doit() == C.I
for r in [2, S.Half, S.Pi, n]:
assert MatPow(C, r).doit() == MatPow(C, r)
def test_doit_matrix():
X = ImmutableMatrix([[1, 2], [3, 4]])
assert MatPow(X, 0).doit() == ImmutableMatrix(Identity(2))
assert MatPow(X, 1).doit() == X
assert MatPow(X, 2).doit() == X**2
assert MatPow(X, -1).doit() == X.inv()
assert MatPow(X, -2).doit() == (X.inv())**2
# less expensive than testing on a 2x2
assert MatPow(ImmutableMatrix([4]), S.Half).doit() == ImmutableMatrix([2])
X = ImmutableMatrix([[0, 2], [0, 4]]) # det() == 0
raises(ValueError, lambda: MatPow(X,-1).doit())
raises(ValueError, lambda: MatPow(X,-2).doit())
def test_nonsquare():
A = MatrixSymbol('A', 2, 3)
B = ImmutableMatrix([[1, 2, 3], [4, 5, 6]])
for r in [-1, 0, 1, 2, S.Half, S.Pi, n]:
raises(NonSquareMatrixError, lambda: MatPow(A, r))
raises(NonSquareMatrixError, lambda: MatPow(B, r))
def test_doit_equals_pow(): #17179
X = ImmutableMatrix ([[1,0],[0,1]])
assert MatPow(X, n).doit() == X**n == X
def test_doit_nested_MatrixExpr():
X = ImmutableMatrix([[1, 2], [3, 4]])
Y = ImmutableMatrix([[2, 3], [4, 5]])
assert MatPow(MatMul(X, Y), 2).doit() == (X*Y)**2
assert MatPow(MatAdd(X, Y), 2).doit() == (X + Y)**2
def test_identity_power():
k = Identity(n)
assert MatPow(k, 4).doit() == k
assert MatPow(k, n).doit() == k
assert MatPow(k, -3).doit() == k
assert MatPow(k, 0).doit() == k
l = Identity(3)
assert MatPow(l, n).doit() == l
assert MatPow(l, -1).doit() == l
assert MatPow(l, 0).doit() == l
def test_zero_power():
z1 = ZeroMatrix(n, n)
assert MatPow(z1, 3).doit() == z1
raises(ValueError, lambda:MatPow(z1, -1).doit())
assert MatPow(z1, 0).doit() == Identity(n)
assert MatPow(z1, n).doit() == z1
raises(ValueError, lambda:MatPow(z1, -2).doit())
z2 = ZeroMatrix(4, 4)
assert MatPow(z2, n).doit() == z2
raises(ValueError, lambda:MatPow(z2, -3).doit())
assert MatPow(z2, 2).doit() == z2
assert MatPow(z2, 0).doit() == Identity(4)
raises(ValueError, lambda:MatPow(z2, -1).doit())
def test_OneMatrix_power():
o = OneMatrix(3, 3)
assert o ** 0 == Identity(3)
assert o ** 1 == o
assert o * o == o ** 2 == 3 * o
assert o * o * o == o ** 3 == 9 * o
o = OneMatrix(n, n)
assert o * o == o ** 2 == n * o
# powsimp necessary as n ** (n - 2) * n does not produce n ** (n - 1)
assert powsimp(o ** (n - 1) * o) == o ** n == n ** (n - 1) * o
def test_transpose_power():
from sympy.matrices.expressions.transpose import Transpose as TP
assert (C*D).T**5 == ((C*D)**5).T == (D.T * C.T)**5
assert ((C*D).T**5).T == (C*D)**5
assert (C.T.I.T)**7 == C**-7
assert (C.T**l).T**k == C**(l*k)
assert ((E.T * A.T)**5).T == (A*E)**5
assert ((A*E).T**5).T**7 == (A*E)**35
assert TP(TP(C**2 * D**3)**5).doit() == (C**2 * D**3)**5
assert ((D*C)**-5).T**-5 == ((D*C)**25).T
assert (((D*C)**l).T**k).T == (D*C)**(l*k)
def test_Inverse():
assert Inverse(MatPow(C, 0)).doit() == Identity(n)
assert Inverse(MatPow(C, 1)).doit() == Inverse(C)
assert Inverse(MatPow(C, 2)).doit() == MatPow(C, -2)
assert Inverse(MatPow(C, -1)).doit() == C
assert MatPow(Inverse(C), 0).doit() == Identity(n)
assert MatPow(Inverse(C), 1).doit() == Inverse(C)
assert MatPow(Inverse(C), 2).doit() == MatPow(C, -2)
assert MatPow(Inverse(C), -1).doit() == C
def test_combine_powers():
assert (C ** 1) ** 1 == C
assert (C ** 2) ** 3 == MatPow(C, 6)
assert (C ** -2) ** -3 == MatPow(C, 6)
assert (C ** -1) ** -1 == C
assert (((C ** 2) ** 3) ** 4) ** 5 == MatPow(C, 120)
assert (C ** n) ** n == C ** (n ** 2)
def test_unchanged():
assert unchanged(MatPow, C, 0)
assert unchanged(MatPow, C, 1)
assert unchanged(MatPow, Inverse(C), -1)
assert unchanged(Inverse, MatPow(C, -1), -1)
assert unchanged(MatPow, MatPow(C, -1), -1)
assert unchanged(MatPow, MatPow(C, 1), 1)
|
dfb2c6a9a701092a8b3f23761491046750c3f97642da2510965ea24b8d9109f4 | from sympy import (KroneckerDelta, diff, Piecewise, Sum, Dummy, factor,
expand, zeros, gcd_terms, Eq, Symbol)
from sympy.core import S, symbols, Add, Mul, SympifyError, Rational
from sympy.core.expr import unchanged
from sympy.functions import transpose, sin, cos, sqrt, cbrt, exp
from sympy.simplify import simplify
from sympy.matrices import (Identity, ImmutableMatrix, Inverse, MatAdd, MatMul,
MatPow, Matrix, MatrixExpr, MatrixSymbol, ShapeError, ZeroMatrix,
SparseMatrix, Transpose, Adjoint, NonSquareMatrixError)
from sympy.matrices.expressions.matexpr import (MatrixElement,
GenericZeroMatrix, GenericIdentity, OneMatrix)
from sympy.testing.pytest import raises, XFAIL
n, m, l, k, p = symbols('n m l k p', integer=True)
x = symbols('x')
A = MatrixSymbol('A', n, m)
B = MatrixSymbol('B', m, l)
C = MatrixSymbol('C', n, n)
D = MatrixSymbol('D', n, n)
E = MatrixSymbol('E', m, n)
w = MatrixSymbol('w', n, 1)
def test_matrix_symbol_creation():
assert MatrixSymbol('A', 2, 2)
assert MatrixSymbol('A', 0, 0)
raises(ValueError, lambda: MatrixSymbol('A', -1, 2))
raises(ValueError, lambda: MatrixSymbol('A', 2.0, 2))
raises(ValueError, lambda: MatrixSymbol('A', 2j, 2))
raises(ValueError, lambda: MatrixSymbol('A', 2, -1))
raises(ValueError, lambda: MatrixSymbol('A', 2, 2.0))
raises(ValueError, lambda: MatrixSymbol('A', 2, 2j))
n = symbols('n')
assert MatrixSymbol('A', n, n)
n = symbols('n', integer=False)
raises(ValueError, lambda: MatrixSymbol('A', n, n))
n = symbols('n', negative=True)
raises(ValueError, lambda: MatrixSymbol('A', n, n))
def test_zero_matrix_creation():
assert unchanged(ZeroMatrix, 2, 2)
assert unchanged(ZeroMatrix, 0, 0)
raises(ValueError, lambda: ZeroMatrix(-1, 2))
raises(ValueError, lambda: ZeroMatrix(2.0, 2))
raises(ValueError, lambda: ZeroMatrix(2j, 2))
raises(ValueError, lambda: ZeroMatrix(2, -1))
raises(ValueError, lambda: ZeroMatrix(2, 2.0))
raises(ValueError, lambda: ZeroMatrix(2, 2j))
n = symbols('n')
assert unchanged(ZeroMatrix, n, n)
n = symbols('n', integer=False)
raises(ValueError, lambda: ZeroMatrix(n, n))
n = symbols('n', negative=True)
raises(ValueError, lambda: ZeroMatrix(n, n))
def test_one_matrix_creation():
assert OneMatrix(2, 2)
assert OneMatrix(0, 0)
assert Eq(OneMatrix(1, 1), Identity(1))
raises(ValueError, lambda: OneMatrix(-1, 2))
raises(ValueError, lambda: OneMatrix(2.0, 2))
raises(ValueError, lambda: OneMatrix(2j, 2))
raises(ValueError, lambda: OneMatrix(2, -1))
raises(ValueError, lambda: OneMatrix(2, 2.0))
raises(ValueError, lambda: OneMatrix(2, 2j))
n = symbols('n')
assert OneMatrix(n, n)
n = symbols('n', integer=False)
raises(ValueError, lambda: OneMatrix(n, n))
n = symbols('n', negative=True)
raises(ValueError, lambda: OneMatrix(n, n))
def test_identity_matrix_creation():
assert Identity(2)
assert Identity(0)
raises(ValueError, lambda: Identity(-1))
raises(ValueError, lambda: Identity(2.0))
raises(ValueError, lambda: Identity(2j))
n = symbols('n')
assert Identity(n)
n = symbols('n', integer=False)
raises(ValueError, lambda: Identity(n))
n = symbols('n', negative=True)
raises(ValueError, lambda: Identity(n))
def test_shape():
assert A.shape == (n, m)
assert (A*B).shape == (n, l)
raises(ShapeError, lambda: B*A)
def test_matexpr():
assert (x*A).shape == A.shape
assert (x*A).__class__ == MatMul
assert 2*A - A - A == ZeroMatrix(*A.shape)
assert (A*B).shape == (n, l)
def test_subs():
A = MatrixSymbol('A', n, m)
B = MatrixSymbol('B', m, l)
C = MatrixSymbol('C', m, l)
assert A.subs(n, m).shape == (m, m)
assert (A*B).subs(B, C) == A*C
assert (A*B).subs(l, n).is_square
A = SparseMatrix([[1, 2], [3, 4]])
B = Matrix([[1, 2], [3, 4]])
C, D = MatrixSymbol('C', 2, 2), MatrixSymbol('D', 2, 2)
assert (C*D).subs({C: A, D: B}) == MatMul(A, B)
def test_ZeroMatrix():
A = MatrixSymbol('A', n, m)
Z = ZeroMatrix(n, m)
assert A + Z == A
assert A*Z.T == ZeroMatrix(n, n)
assert Z*A.T == ZeroMatrix(n, n)
assert A - A == ZeroMatrix(*A.shape)
assert Z
assert transpose(Z) == ZeroMatrix(m, n)
assert Z.conjugate() == Z
assert ZeroMatrix(n, n)**0 == Identity(n)
with raises(NonSquareMatrixError):
Z**0
with raises(NonSquareMatrixError):
Z**1
with raises(NonSquareMatrixError):
Z**2
assert ZeroMatrix(3, 3).as_explicit() == ImmutableMatrix.zeros(3, 3)
def test_ZeroMatrix_doit():
Znn = ZeroMatrix(Add(n, n, evaluate=False), n)
assert isinstance(Znn.rows, Add)
assert Znn.doit() == ZeroMatrix(2*n, n)
assert isinstance(Znn.doit().rows, Mul)
def test_OneMatrix():
A = MatrixSymbol('A', n, m)
a = MatrixSymbol('a', n, 1)
U = OneMatrix(n, m)
assert U.shape == (n, m)
assert isinstance(A + U, Add)
assert transpose(U) == OneMatrix(m, n)
assert U.conjugate() == U
assert OneMatrix(n, n) ** 0 == Identity(n)
with raises(NonSquareMatrixError):
U ** 0
with raises(NonSquareMatrixError):
U ** 1
with raises(NonSquareMatrixError):
U ** 2
with raises(ShapeError):
a + U
U = OneMatrix(n, n)
assert U[1, 2] == 1
U = OneMatrix(2, 3)
assert U.as_explicit() == ImmutableMatrix.ones(2, 3)
def test_OneMatrix_doit():
Unn = OneMatrix(Add(n, n, evaluate=False), n)
assert isinstance(Unn.rows, Add)
assert Unn.doit() == OneMatrix(2 * n, n)
assert isinstance(Unn.doit().rows, Mul)
def test_OneMatrix_mul():
assert OneMatrix(n, m) * OneMatrix(m, k) == OneMatrix(n, k) * m
assert w * OneMatrix(1, 1) == w
assert OneMatrix(1, 1) * w.T == w.T
def test_Identity():
A = MatrixSymbol('A', n, m)
i, j = symbols('i j')
In = Identity(n)
Im = Identity(m)
assert A*Im == A
assert In*A == A
assert transpose(In) == In
assert In.inverse() == In
assert In.conjugate() == In
assert In[i, j] != 0
assert Sum(In[i, j], (i, 0, n-1), (j, 0, n-1)).subs(n,3).doit() == 3
assert Sum(Sum(In[i, j], (i, 0, n-1)), (j, 0, n-1)).subs(n,3).doit() == 3
# If range exceeds the limit `(0, n-1)`, do not remove `Piecewise`:
expr = Sum(In[i, j], (i, 0, n-1))
assert expr.doit() == 1
expr = Sum(In[i, j], (i, 0, n-2))
assert expr.doit().dummy_eq(
Piecewise(
(1, (j >= 0) & (j <= n-2)),
(0, True)
)
)
expr = Sum(In[i, j], (i, 1, n-1))
assert expr.doit().dummy_eq(
Piecewise(
(1, (j >= 1) & (j <= n-1)),
(0, True)
)
)
assert Identity(3).as_explicit() == ImmutableMatrix.eye(3)
def test_Identity_doit():
Inn = Identity(Add(n, n, evaluate=False))
assert isinstance(Inn.rows, Add)
assert Inn.doit() == Identity(2*n)
assert isinstance(Inn.doit().rows, Mul)
def test_addition():
A = MatrixSymbol('A', n, m)
B = MatrixSymbol('B', n, m)
assert isinstance(A + B, MatAdd)
assert (A + B).shape == A.shape
assert isinstance(A - A + 2*B, MatMul)
raises(ShapeError, lambda: A + B.T)
raises(TypeError, lambda: A + 1)
raises(TypeError, lambda: 5 + A)
raises(TypeError, lambda: 5 - A)
assert A + ZeroMatrix(n, m) - A == ZeroMatrix(n, m)
with raises(TypeError):
ZeroMatrix(n,m) + S.Zero
def test_multiplication():
A = MatrixSymbol('A', n, m)
B = MatrixSymbol('B', m, l)
C = MatrixSymbol('C', n, n)
assert (2*A*B).shape == (n, l)
assert (A*0*B) == ZeroMatrix(n, l)
raises(ShapeError, lambda: B*A)
assert (2*A).shape == A.shape
assert A * ZeroMatrix(m, m) * B == ZeroMatrix(n, l)
assert C * Identity(n) * C.I == Identity(n)
assert B/2 == S.Half*B
raises(NotImplementedError, lambda: 2/B)
A = MatrixSymbol('A', n, n)
B = MatrixSymbol('B', n, n)
assert Identity(n) * (A + B) == A + B
assert A**2*A == A**3
assert A**2*(A.I)**3 == A.I
assert A**3*(A.I)**2 == A
def test_MatPow():
A = MatrixSymbol('A', n, n)
AA = MatPow(A, 2)
assert AA.exp == 2
assert AA.base == A
assert (A**n).exp == n
assert A**0 == Identity(n)
assert A**1 == A
assert A**2 == AA
assert A**-1 == Inverse(A)
assert (A**-1)**-1 == A
assert (A**2)**3 == A**6
assert A**S.Half == sqrt(A)
assert A**Rational(1, 3) == cbrt(A)
raises(NonSquareMatrixError, lambda: MatrixSymbol('B', 3, 2)**2)
def test_MatrixSymbol():
n, m, t = symbols('n,m,t')
X = MatrixSymbol('X', n, m)
assert X.shape == (n, m)
raises(TypeError, lambda: MatrixSymbol('X', n, m)(t)) # issue 5855
assert X.doit() == X
def test_dense_conversion():
X = MatrixSymbol('X', 2, 2)
assert ImmutableMatrix(X) == ImmutableMatrix(2, 2, lambda i, j: X[i, j])
assert Matrix(X) == Matrix(2, 2, lambda i, j: X[i, j])
def test_free_symbols():
assert (C*D).free_symbols == {C, D}
def test_zero_matmul():
assert isinstance(S.Zero * MatrixSymbol('X', 2, 2), MatrixExpr)
def test_matadd_simplify():
A = MatrixSymbol('A', 1, 1)
assert simplify(MatAdd(A, ImmutableMatrix([[sin(x)**2 + cos(x)**2]]))) == \
MatAdd(A, Matrix([[1]]))
def test_matmul_simplify():
A = MatrixSymbol('A', 1, 1)
assert simplify(MatMul(A, ImmutableMatrix([[sin(x)**2 + cos(x)**2]]))) == \
MatMul(A, Matrix([[1]]))
def test_invariants():
A = MatrixSymbol('A', n, m)
B = MatrixSymbol('B', m, l)
X = MatrixSymbol('X', n, n)
objs = [Identity(n), ZeroMatrix(m, n), A, MatMul(A, B), MatAdd(A, A),
Transpose(A), Adjoint(A), Inverse(X), MatPow(X, 2), MatPow(X, -1),
MatPow(X, 0)]
for obj in objs:
assert obj == obj.__class__(*obj.args)
def test_indexing():
A = MatrixSymbol('A', n, m)
A[1, 2]
A[l, k]
A[l+1, k+1]
def test_single_indexing():
A = MatrixSymbol('A', 2, 3)
assert A[1] == A[0, 1]
assert A[int(1)] == A[0, 1]
assert A[3] == A[1, 0]
assert list(A[:2, :2]) == [A[0, 0], A[0, 1], A[1, 0], A[1, 1]]
raises(IndexError, lambda: A[6])
raises(IndexError, lambda: A[n])
B = MatrixSymbol('B', n, m)
raises(IndexError, lambda: B[1])
B = MatrixSymbol('B', n, 3)
assert B[3] == B[1, 0]
def test_MatrixElement_commutative():
assert A[0, 1]*A[1, 0] == A[1, 0]*A[0, 1]
def test_MatrixSymbol_determinant():
A = MatrixSymbol('A', 4, 4)
assert A.as_explicit().det() == A[0, 0]*A[1, 1]*A[2, 2]*A[3, 3] - \
A[0, 0]*A[1, 1]*A[2, 3]*A[3, 2] - A[0, 0]*A[1, 2]*A[2, 1]*A[3, 3] + \
A[0, 0]*A[1, 2]*A[2, 3]*A[3, 1] + A[0, 0]*A[1, 3]*A[2, 1]*A[3, 2] - \
A[0, 0]*A[1, 3]*A[2, 2]*A[3, 1] - A[0, 1]*A[1, 0]*A[2, 2]*A[3, 3] + \
A[0, 1]*A[1, 0]*A[2, 3]*A[3, 2] + A[0, 1]*A[1, 2]*A[2, 0]*A[3, 3] - \
A[0, 1]*A[1, 2]*A[2, 3]*A[3, 0] - A[0, 1]*A[1, 3]*A[2, 0]*A[3, 2] + \
A[0, 1]*A[1, 3]*A[2, 2]*A[3, 0] + A[0, 2]*A[1, 0]*A[2, 1]*A[3, 3] - \
A[0, 2]*A[1, 0]*A[2, 3]*A[3, 1] - A[0, 2]*A[1, 1]*A[2, 0]*A[3, 3] + \
A[0, 2]*A[1, 1]*A[2, 3]*A[3, 0] + A[0, 2]*A[1, 3]*A[2, 0]*A[3, 1] - \
A[0, 2]*A[1, 3]*A[2, 1]*A[3, 0] - A[0, 3]*A[1, 0]*A[2, 1]*A[3, 2] + \
A[0, 3]*A[1, 0]*A[2, 2]*A[3, 1] + A[0, 3]*A[1, 1]*A[2, 0]*A[3, 2] - \
A[0, 3]*A[1, 1]*A[2, 2]*A[3, 0] - A[0, 3]*A[1, 2]*A[2, 0]*A[3, 1] + \
A[0, 3]*A[1, 2]*A[2, 1]*A[3, 0]
def test_MatrixElement_diff():
assert (A[3, 0]*A[0, 0]).diff(A[0, 0]) == A[3, 0]
def test_MatrixElement_doit():
u = MatrixSymbol('u', 2, 1)
v = ImmutableMatrix([3, 5])
assert u[0, 0].subs(u, v).doit() == v[0, 0]
def test_identity_powers():
M = Identity(n)
assert MatPow(M, 3).doit() == M**3
assert M**n == M
assert MatPow(M, 0).doit() == M**2
assert M**-2 == M
assert MatPow(M, -2).doit() == M**0
N = Identity(3)
assert MatPow(N, 2).doit() == N**n
assert MatPow(N, 3).doit() == N
assert MatPow(N, -2).doit() == N**4
assert MatPow(N, 2).doit() == N**0
def test_Zero_power():
z1 = ZeroMatrix(n, n)
assert z1**4 == z1
raises(ValueError, lambda:z1**-2)
assert z1**0 == Identity(n)
assert MatPow(z1, 2).doit() == z1**2
raises(ValueError, lambda:MatPow(z1, -2).doit())
z2 = ZeroMatrix(3, 3)
assert MatPow(z2, 4).doit() == z2**4
raises(ValueError, lambda:z2**-3)
assert z2**3 == MatPow(z2, 3).doit()
assert z2**0 == Identity(3)
raises(ValueError, lambda:MatPow(z2, -1).doit())
def test_matrixelement_diff():
dexpr = diff((D*w)[k,0], w[p,0])
assert w[k, p].diff(w[k, p]) == 1
assert w[k, p].diff(w[0, 0]) == KroneckerDelta(0, k, (0, n-1))*KroneckerDelta(0, p, (0, 0))
_i_1 = Dummy("_i_1")
assert dexpr.dummy_eq(Sum(KroneckerDelta(_i_1, p, (0, n-1))*D[k, _i_1], (_i_1, 0, n - 1)))
assert dexpr.doit() == D[k, p]
def test_MatrixElement_with_values():
x, y, z, w = symbols("x y z w")
M = Matrix([[x, y], [z, w]])
i, j = symbols("i, j")
Mij = M[i, j]
assert isinstance(Mij, MatrixElement)
Ms = SparseMatrix([[2, 3], [4, 5]])
msij = Ms[i, j]
assert isinstance(msij, MatrixElement)
for oi, oj in [(0, 0), (0, 1), (1, 0), (1, 1)]:
assert Mij.subs({i: oi, j: oj}) == M[oi, oj]
assert msij.subs({i: oi, j: oj}) == Ms[oi, oj]
A = MatrixSymbol("A", 2, 2)
assert A[0, 0].subs(A, M) == x
assert A[i, j].subs(A, M) == M[i, j]
assert M[i, j].subs(M, A) == A[i, j]
assert isinstance(M[3*i - 2, j], MatrixElement)
assert M[3*i - 2, j].subs({i: 1, j: 0}) == M[1, 0]
assert isinstance(M[i, 0], MatrixElement)
assert M[i, 0].subs(i, 0) == M[0, 0]
assert M[0, i].subs(i, 1) == M[0, 1]
assert M[i, j].diff(x) == Matrix([[1, 0], [0, 0]])[i, j]
raises(ValueError, lambda: M[i, 2])
raises(ValueError, lambda: M[i, -1])
raises(ValueError, lambda: M[2, i])
raises(ValueError, lambda: M[-1, i])
def test_inv():
B = MatrixSymbol('B', 3, 3)
assert B.inv() == B**-1
@XFAIL
def test_factor_expand():
A = MatrixSymbol("A", n, n)
B = MatrixSymbol("B", n, n)
expr1 = (A + B)*(C + D)
expr2 = A*C + B*C + A*D + B*D
assert expr1 != expr2
assert expand(expr1) == expr2
assert factor(expr2) == expr1
expr = B**(-1)*(A**(-1)*B**(-1) - A**(-1)*C*B**(-1))**(-1)*A**(-1)
I = Identity(n)
# Ideally we get the first, but we at least don't want a wrong answer
assert factor(expr) in [I - C, B**-1*(A**-1*(I - C)*B**-1)**-1*A**-1]
def test_issue_2749():
A = MatrixSymbol("A", 5, 2)
assert (A.T * A).I.as_explicit() == Matrix([[(A.T * A).I[0, 0], (A.T * A).I[0, 1]], \
[(A.T * A).I[1, 0], (A.T * A).I[1, 1]]])
def test_issue_2750():
x = MatrixSymbol('x', 1, 1)
assert (x.T*x).as_explicit()**-1 == Matrix([[x[0, 0]**(-2)]])
def test_issue_7842():
A = MatrixSymbol('A', 3, 1)
B = MatrixSymbol('B', 2, 1)
assert Eq(A, B) == False
assert Eq(A[1,0], B[1, 0]).func is Eq
A = ZeroMatrix(2, 3)
B = ZeroMatrix(2, 3)
assert Eq(A, B) == True
def test_generic_zero_matrix():
z = GenericZeroMatrix()
A = MatrixSymbol("A", n, n)
assert z == z
assert z != A
assert A != z
assert z.is_ZeroMatrix
raises(TypeError, lambda: z.shape)
raises(TypeError, lambda: z.rows)
raises(TypeError, lambda: z.cols)
assert MatAdd() == z
assert MatAdd(z, A) == MatAdd(A)
# Make sure it is hashable
hash(z)
def test_generic_identity():
I = GenericIdentity()
A = MatrixSymbol("A", n, n)
assert I == I
assert I != A
assert A != I
assert I.is_Identity
assert I**-1 == I
raises(TypeError, lambda: I.shape)
raises(TypeError, lambda: I.rows)
raises(TypeError, lambda: I.cols)
assert MatMul() == I
assert MatMul(I, A) == MatMul(A)
# Make sure it is hashable
hash(I)
def test_MatMul_postprocessor():
z = zeros(2)
z1 = ZeroMatrix(2, 2)
assert Mul(0, z) == Mul(z, 0) in [z, z1]
M = Matrix([[1, 2], [3, 4]])
Mx = Matrix([[x, 2*x], [3*x, 4*x]])
assert Mul(x, M) == Mul(M, x) == Mx
A = MatrixSymbol("A", 2, 2)
assert Mul(A, M) == MatMul(A, M)
assert Mul(M, A) == MatMul(M, A)
# Scalars should be absorbed into constant matrices
a = Mul(x, M, A)
b = Mul(M, x, A)
c = Mul(M, A, x)
assert a == b == c == MatMul(Mx, A)
a = Mul(x, A, M)
b = Mul(A, x, M)
c = Mul(A, M, x)
assert a == b == c == MatMul(A, Mx)
assert Mul(M, M) == M**2
assert Mul(A, M, M) == MatMul(A, M**2)
assert Mul(M, M, A) == MatMul(M**2, A)
assert Mul(M, A, M) == MatMul(M, A, M)
assert Mul(A, x, M, M, x) == MatMul(A, Mx**2)
@XFAIL
def test_MatAdd_postprocessor_xfail():
# This is difficult to get working because of the way that Add processes
# its args.
z = zeros(2)
assert Add(z, S.NaN) == Add(S.NaN, z)
def test_MatAdd_postprocessor():
# Some of these are nonsensical, but we do not raise errors for Add
# because that breaks algorithms that want to replace matrices with dummy
# symbols.
z = zeros(2)
assert Add(0, z) == Add(z, 0) == z
a = Add(S.Infinity, z)
assert a == Add(z, S.Infinity)
assert isinstance(a, Add)
assert a.args == (S.Infinity, z)
a = Add(S.ComplexInfinity, z)
assert a == Add(z, S.ComplexInfinity)
assert isinstance(a, Add)
assert a.args == (S.ComplexInfinity, z)
a = Add(z, S.NaN)
# assert a == Add(S.NaN, z) # See the XFAIL above
assert isinstance(a, Add)
assert a.args == (S.NaN, z)
M = Matrix([[1, 2], [3, 4]])
a = Add(x, M)
assert a == Add(M, x)
assert isinstance(a, Add)
assert a.args == (x, M)
A = MatrixSymbol("A", 2, 2)
assert Add(A, M) == Add(M, A) == A + M
# Scalars should be absorbed into constant matrices (producing an error)
a = Add(x, M, A)
assert a == Add(M, x, A) == Add(M, A, x) == Add(x, A, M) == Add(A, x, M) == Add(A, M, x)
assert isinstance(a, Add)
assert a.args == (x, A + M)
assert Add(M, M) == 2*M
assert Add(M, A, M) == Add(M, M, A) == Add(A, M, M) == A + 2*M
a = Add(A, x, M, M, x)
assert isinstance(a, Add)
assert a.args == (2*x, A + 2*M)
def test_simplify_matrix_expressions():
# Various simplification functions
assert type(gcd_terms(C*D + D*C)) == MatAdd
a = gcd_terms(2*C*D + 4*D*C)
assert type(a) == MatMul
assert a.args == (2, (C*D + 2*D*C))
def test_exp():
A = MatrixSymbol('A', 2, 2)
B = MatrixSymbol('B', 2, 2)
expr1 = exp(A)*exp(B)
expr2 = exp(B)*exp(A)
assert expr1 != expr2
assert expr1 - expr2 != 0
assert not isinstance(expr1, exp)
assert not isinstance(expr2, exp)
def test_invalid_args():
raises(SympifyError, lambda: MatrixSymbol(1, 2, 'A'))
def test_matrixsymbol_from_symbol():
# The label should be preserved during doit and subs
A_label = Symbol('A', complex=True)
A = MatrixSymbol(A_label, 2, 2)
A_1 = A.doit()
A_2 = A.subs(2, 3)
assert A_1.args == A.args
assert A_2.args[0] == A.args[0]
def test_as_explicit():
Z = MatrixSymbol('Z', 2, 3)
assert Z.as_explicit() == ImmutableMatrix([
[Z[0, 0], Z[0, 1], Z[0, 2]],
[Z[1, 0], Z[1, 1], Z[1, 2]],
])
raises(ValueError, lambda: A.as_explicit())
|
a68a33dcb641cccfe1083e2dfc8b1ed11fcff3bd5dd59932be678ece4fb0dcf1 | from sympy.core import symbols, S
from sympy.matrices.expressions import MatrixSymbol, Inverse, MatPow, ZeroMatrix, OneMatrix
from sympy.matrices.common import NonSquareMatrixError, NonInvertibleMatrixError
from sympy.matrices import eye, Identity
from sympy.testing.pytest import raises
from sympy import refine, Q
n, m, l = symbols('n m l', integer=True)
A = MatrixSymbol('A', n, m)
B = MatrixSymbol('B', m, l)
C = MatrixSymbol('C', n, n)
D = MatrixSymbol('D', n, n)
E = MatrixSymbol('E', m, n)
def test_inverse():
assert Inverse(C).args == (C, S.NegativeOne)
assert Inverse(C).shape == (n, n)
assert Inverse(A*E).shape == (n, n)
assert Inverse(E*A).shape == (m, m)
assert Inverse(C).inverse() == C
assert Inverse(Inverse(C)).doit() == C
assert isinstance(Inverse(Inverse(C)), Inverse)
assert Inverse(*Inverse(E*A).args) == Inverse(E*A)
assert C.inverse().inverse() == C
assert C.inverse()*C == Identity(C.rows)
assert Identity(n).inverse() == Identity(n)
assert (3*Identity(n)).inverse() == Identity(n)/3
# Simplifies Muls if possible (i.e. submatrices are square)
assert (C*D).inverse() == D.I*C.I
# But still works when not possible
assert isinstance((A*E).inverse(), Inverse)
assert Inverse(C*D).doit(inv_expand=False) == Inverse(C*D)
assert Inverse(eye(3)).doit() == eye(3)
assert Inverse(eye(3)).doit(deep=False) == eye(3)
assert OneMatrix(1, 1).I == Identity(1)
assert isinstance(OneMatrix(n, n).I, Inverse)
def test_inverse_non_invertible():
raises(NonSquareMatrixError, lambda: Inverse(A))
raises(NonSquareMatrixError, lambda: Inverse(A*B))
raises(NonSquareMatrixError, lambda: ZeroMatrix(n, m).I)
raises(NonInvertibleMatrixError, lambda: ZeroMatrix(n, n).I)
raises(NonSquareMatrixError, lambda: OneMatrix(n, m).I)
raises(NonInvertibleMatrixError, lambda: OneMatrix(2, 2).I)
def test_refine():
assert refine(C.I, Q.orthogonal(C)) == C.T
def test_inverse_matpow_canonicalization():
A = MatrixSymbol('A', 3, 3)
assert Inverse(MatPow(A, 3)).doit() == MatPow(Inverse(A), 3).doit()
|
5964d8ccca8695fd8a0f424edf120ad2a95e8c30df8bd9a3d6e06641e2c59d46 | from sympy import I, symbols, Matrix, eye, Mod, floor
from sympy.matrices import MatrixSymbol, Identity
from sympy.matrices.expressions import det, trace
from sympy.matrices.expressions.kronecker import (KroneckerProduct,
kronecker_product,
combine_kronecker)
mat1 = Matrix([[1, 2 * I], [1 + I, 3]])
mat2 = Matrix([[2 * I, 3], [4 * I, 2]])
i, j, k, n, m, o, p, x = symbols('i,j,k,n,m,o,p,x')
Z = MatrixSymbol('Z', n, n)
W = MatrixSymbol('W', m, m)
A = MatrixSymbol('A', n, m)
B = MatrixSymbol('B', n, m)
C = MatrixSymbol('C', m, k)
def test_KroneckerProduct():
assert isinstance(KroneckerProduct(A, B), KroneckerProduct)
assert KroneckerProduct(A, B).subs(A, C) == KroneckerProduct(C, B)
assert KroneckerProduct(A, C).shape == (n*m, m*k)
assert (KroneckerProduct(A, C) + KroneckerProduct(-A, C)).is_ZeroMatrix
assert (KroneckerProduct(W, Z) * KroneckerProduct(W.I, Z.I)).is_Identity
def test_KroneckerProduct_identity():
assert KroneckerProduct(Identity(m), Identity(n)) == Identity(m*n)
assert KroneckerProduct(eye(2), eye(3)) == eye(6)
def test_KroneckerProduct_explicit():
X = MatrixSymbol('X', 2, 2)
Y = MatrixSymbol('Y', 2, 2)
kp = KroneckerProduct(X, Y)
assert kp.shape == (4, 4)
assert kp.as_explicit() == Matrix(
[
[X[0, 0]*Y[0, 0], X[0, 0]*Y[0, 1], X[0, 1]*Y[0, 0], X[0, 1]*Y[0, 1]],
[X[0, 0]*Y[1, 0], X[0, 0]*Y[1, 1], X[0, 1]*Y[1, 0], X[0, 1]*Y[1, 1]],
[X[1, 0]*Y[0, 0], X[1, 0]*Y[0, 1], X[1, 1]*Y[0, 0], X[1, 1]*Y[0, 1]],
[X[1, 0]*Y[1, 0], X[1, 0]*Y[1, 1], X[1, 1]*Y[1, 0], X[1, 1]*Y[1, 1]]
]
)
def test_tensor_product_adjoint():
assert KroneckerProduct(I*A, B).adjoint() == \
-I*KroneckerProduct(A.adjoint(), B.adjoint())
assert KroneckerProduct(mat1, mat2).adjoint() == \
kronecker_product(mat1.adjoint(), mat2.adjoint())
def test_tensor_product_conjugate():
assert KroneckerProduct(I*A, B).conjugate() == \
-I*KroneckerProduct(A.conjugate(), B.conjugate())
assert KroneckerProduct(mat1, mat2).conjugate() == \
kronecker_product(mat1.conjugate(), mat2.conjugate())
def test_tensor_product_transpose():
assert KroneckerProduct(I*A, B).transpose() == \
I*KroneckerProduct(A.transpose(), B.transpose())
assert KroneckerProduct(mat1, mat2).transpose() == \
kronecker_product(mat1.transpose(), mat2.transpose())
def test_KroneckerProduct_is_associative():
assert kronecker_product(A, kronecker_product(
B, C)) == kronecker_product(kronecker_product(A, B), C)
assert kronecker_product(A, kronecker_product(
B, C)) == KroneckerProduct(A, B, C)
def test_KroneckerProduct_is_bilinear():
assert kronecker_product(x*A, B) == x*kronecker_product(A, B)
assert kronecker_product(A, x*B) == x*kronecker_product(A, B)
def test_KroneckerProduct_determinant():
kp = kronecker_product(W, Z)
assert det(kp) == det(W)**n * det(Z)**m
def test_KroneckerProduct_trace():
kp = kronecker_product(W, Z)
assert trace(kp) == trace(W)*trace(Z)
def test_KroneckerProduct_isnt_commutative():
assert KroneckerProduct(A, B) != KroneckerProduct(B, A)
assert KroneckerProduct(A, B).is_commutative is False
def test_KroneckerProduct_extracts_commutative_part():
assert kronecker_product(x * A, 2 * B) == x * \
2 * KroneckerProduct(A, B)
def test_KroneckerProduct_inverse():
kp = kronecker_product(W, Z)
assert kp.inverse() == kronecker_product(W.inverse(), Z.inverse())
def test_KroneckerProduct_combine_add():
kp1 = kronecker_product(A, B)
kp2 = kronecker_product(C, W)
assert combine_kronecker(kp1*kp2) == kronecker_product(A*C, B*W)
def test_KroneckerProduct_combine_mul():
X = MatrixSymbol('X', m, n)
Y = MatrixSymbol('Y', m, n)
kp1 = kronecker_product(A, X)
kp2 = kronecker_product(B, Y)
assert combine_kronecker(kp1+kp2) == kronecker_product(A+B, X+Y)
def test_KroneckerProduct_combine_pow():
X = MatrixSymbol('X', n, n)
Y = MatrixSymbol('Y', n, n)
assert combine_kronecker(KroneckerProduct(
X, Y)**x) == KroneckerProduct(X**x, Y**x)
assert combine_kronecker(x * KroneckerProduct(X, Y)
** 2) == x * KroneckerProduct(X**2, Y**2)
assert combine_kronecker(
x * (KroneckerProduct(X, Y)**2) * KroneckerProduct(A, B)) == x * KroneckerProduct(X**2 * A, Y**2 * B)
# cannot simplify because of non-square arguments to kronecker product:
assert combine_kronecker(KroneckerProduct(A, B.T) ** m) == KroneckerProduct(A, B.T) ** m
def test_KroneckerProduct_expand():
X = MatrixSymbol('X', n, n)
Y = MatrixSymbol('Y', n, n)
assert KroneckerProduct(X + Y, Y + Z).expand(kroneckerproduct=True) == \
KroneckerProduct(X, Y) + KroneckerProduct(X, Z) + \
KroneckerProduct(Y, Y) + KroneckerProduct(Y, Z)
def test_KroneckerProduct_entry():
A = MatrixSymbol('A', n, m)
B = MatrixSymbol('B', o, p)
assert KroneckerProduct(A, B)._entry(i, j) == A[Mod(floor(i/o), n), Mod(floor(j/p), m)]*B[Mod(i, o), Mod(j, p)]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.