text:
int_rules_1_2_1_2 = @theory begin

    #= ::Subsection::Closed:: =#
    #= 1.2.1.2*(d+e*x)^m*(a+b*x+c*x^2)^p =#
    #= Antiderivative(((~d')+(~e')*(~x))^(~m')*((~a)+(~b')*(~x)+(~c')*(~x)^2)^(~p'),~x) :=  1/c^p*Antiderivative((d+e*x)^m*(b/2+c*x)^(2*p),x) <-- FreeQ([a,b,c,d,e,m],x) &&  EqQ(b^2-4*a*c,0) && IntegerQ(p) =#
    @apply_utils Antiderivative((~d + ~(e') * ~x) ^ ~(m') * (~(a') + ~(b') * ~x + ~(c') * (~x) ^ 2) ^ ~(p'), ~x) => Antiderivative((~d + ~e * ~x) ^ (~m + ~p) * (~a / ~d + (~c / ~e) * ~x) ^ ~p, ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~m], ~x) && (NeQ((~b) ^ 2 - 4 * ~a * ~c, 0) && (EqQ((~c * (~d) ^ 2 - ~b * ~d * ~e) + ~a * (~e) ^ 2, 0) && IntegerQ(~p)))
    @apply_utils Antiderivative((~d + ~(e') * ~x) ^ ~(m') * (~a + ~(c') * (~x) ^ 2) ^ ~(p'), ~x) => Antiderivative((~d + ~e * ~x) ^ (~m + ~p) * (~a / ~d + (~c / ~e) * ~x) ^ ~p, ~x) <-- FreeQ([~a, ~c, ~d, ~e, ~m, ~p], ~x) && (EqQ(~c * (~d) ^ 2 + ~a * (~e) ^ 2, 0) && (IntegerQ(~p) || GtQ(~a, 0) && (GtQ(~d, 0) && IntegerQ(~m + ~p))))
    @apply_utils Antiderivative((~d + ~(e') * ~x) / (~(a') + ~(b') * ~x + ~(c') * (~x) ^ 2), ~x) => (~d * log(RemoveContent(~a + ~b * ~x + ~c * (~x) ^ 2, ~x))) / ~b <-- FreeQ([~a, ~b, ~c, ~d, ~e], ~x) && EqQ(2 * ~c * ~d - ~b * ~e, 0)
    @apply_utils Antiderivative((~d + ~(e') * ~x) * (~(a') + ~(b') * ~x + ~(c') * (~x) ^ 2) ^ ~(p'), ~x) => (~d * (~a + ~b * ~x + ~c * (~x) ^ 2) ^ (~p + 1)) / (~b * (~p + 1)) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~p], ~x) && (EqQ(2 * ~c * ~d - ~b * ~e, 0) && NeQ(~p, -1))
    @apply_utils Antiderivative((~d + ~(e') * ~x) * (~(a') + ~(b') * ~x + ~(c') * (~x) ^ 2) ^ ~(p'), ~x) => Antiderivative((~d + ~e * ~x) ^ (~p + 1) * (~a / ~d + (~c / ~e) * ~x) ^ ~p, ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e], ~x) && (NeQ(2 * ~c * ~d - ~b * ~e, 0) && (IGtQ(~p, 0) && EqQ((~c * (~d) ^ 2 - ~b * ~d * ~e) + ~a * (~e) ^ 2, 0)))
    @apply_utils Antiderivative((~(d') + ~(e') * ~x) * (~(a') + ~(b') * ~x + ~(c') * (~x) ^ 2) ^ ~(p'), ~x) => Antiderivative(ExpandIntegrand((~d + ~e * ~x) * (~a + ~b * ~x + ~c * (~x) ^ 2) ^ ~p, ~x), ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e], ~x) && (NeQ(2 * ~c * ~d - ~b * ~e, 0) && (IntegerQ(~p) && (GtQ(~p, 0) || EqQ(~a, 0))))
    @apply_utils Antiderivative((~(d') + ~(e') * ~x) / (~a + ~(b') * ~x + ~(c') * (~x) ^ 2), ~x) => With([q = Rt((~b) ^ 2 - 4 * ~a * ~c, 2)], ((~c * ~d - ~e * (~b / 2 - q / 2)) / q) * Antiderivative(1 / ((~b / 2 - q / 2) + ~c * ~x), ~x) - ((~c * ~d - ~e * (~b / 2 + q / 2)) / q) * Antiderivative(1 / (~b / 2 + q / 2 + ~c * ~x), ~x)) <-- FreeQ([~a, ~b, ~c, ~d, ~e], ~x) && (NeQ(2 * ~c * ~d - ~b * ~e, 0) && (NeQ((~b) ^ 2 - 4 * ~a * ~c, 0) && NiceSqrtQ((~b) ^ 2 - 4 * ~a * ~c)))
    @apply_utils Antiderivative((~d + ~(e') * ~x) / (~a + ~(c') * (~x) ^ 2), ~x) => With([q = Rt(-(~a) * ~c, 2)], (~e / 2 + (~c * ~d) / (2q)) * Antiderivative(1 / (-q + ~c * ~x), ~x) + (~e / 2 - (~c * ~d) / (2q)) * Antiderivative(1 / (q + ~c * ~x), ~x)) <-- FreeQ([~a, ~c, ~d, ~e], ~x) && NiceSqrtQ(-(~a) * ~c)
    @apply_utils Antiderivative((~(d') + ~(e') * ~x) / (~a + ~(b') * ~x + ~(c') * (~x) ^ 2), ~x) => ((2 * ~c * ~d - ~b * ~e) / (2 * ~c)) * Antiderivative(1 / (~a + ~b * ~x + ~c * (~x) ^ 2), ~x) + (~e / (2 * ~c)) * Antiderivative((~b + 2 * ~c * ~x) / (~a + ~b * ~x + ~c * (~x) ^ 2), ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e], ~x) && (NeQ(2 * ~c * ~d - ~b * ~e, 0) && (NeQ((~b) ^ 2 - 4 * ~a * ~c, 0) && Not(NiceSqrtQ((~b) ^ 2 - 4 * ~a * ~c))))
    @apply_utils Antiderivative((~d + ~(e') * ~x) / (~a + ~(c') * (~x) ^ 2), ~x) => ~d * Antiderivative(1 / (~a + ~c * (~x) ^ 2), ~x) + ~e * Antiderivative(~x / (~a + ~c * (~x) ^ 2), ~x) <-- FreeQ([~a, ~c, ~d, ~e], ~x) && Not(NiceSqrtQ(-(~a) * ~c))
    @apply_utils Antiderivative((~(d') + ~(e') * ~x) / (~(a') + ~(b') * ~x + ~(c') * (~x) ^ 2) ^ (3 / 2), ~x) => (-2 * ((~b * ~d - 2 * ~a * ~e) + (2 * ~c * ~d - ~b * ~e) * ~x)) / (((~b) ^ 2 - 4 * ~a * ~c) * sqrt(~a + ~b * ~x + ~c * (~x) ^ 2)) <-- FreeQ([~a, ~b, ~c, ~d, ~e], ~x) && (NeQ(2 * ~c * ~d - ~b * ~e, 0) && NeQ((~b) ^ 2 - 4 * ~a * ~c, 0))
    @apply_utils Antiderivative((~d + ~(e') * ~x) / (~a + ~(c') * (~x) ^ 2) ^ (3 / 2), ~x) => (-(~a) * ~e + ~c * ~d * ~x) / (~a * ~c * sqrt(~a + ~c * (~x) ^ 2)) <-- FreeQ([~a, ~c, ~d, ~e], ~x)
    @apply_utils Antiderivative((~(d') + ~(e') * ~x) * (~(a') + ~(b') * ~x + ~(c') * (~x) ^ 2) ^ ~p, ~x) => (((~b * ~d - 2 * ~a * ~e) + (2 * ~c * ~d - ~b * ~e) * ~x) / ((~p + 1) * ((~b) ^ 2 - 4 * ~a * ~c))) * (~a + ~b * ~x + ~c * (~x) ^ 2) ^ (~p + 1) - (((2 * ~p + 3) * (2 * ~c * ~d - ~b * ~e)) / ((~p + 1) * ((~b) ^ 2 - 4 * ~a * ~c))) * Antiderivative((~a + ~b * ~x + ~c * (~x) ^ 2) ^ (~p + 1), ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e], ~x) && (NeQ(2 * ~c * ~d - ~b * ~e, 0) && (NeQ((~b) ^ 2 - 4 * ~a * ~c, 0) && (LtQ(~p, -1) && NeQ(~p, -3 / 2))))
    @apply_utils Antiderivative((~d + ~(e') * ~x) * (~a + ~(c') * (~x) ^ 2) ^ ~p, ~x) => ((~a * ~e - ~c * ~d * ~x) / (2 * ~a * ~c * (~p + 1))) * (~a + ~c * (~x) ^ 2) ^ (~p + 1) + ((~d * (2 * ~p + 3)) / (2 * ~a * (~p + 1))) * Antiderivative((~a + ~c * (~x) ^ 2) ^ (~p + 1), ~x) <-- FreeQ([~a, ~c, ~d, ~e], ~x) && (LtQ(~p, -1) && NeQ(~p, -3 / 2))
    @apply_utils Antiderivative((~(d') + ~(e') * ~x) * (~(a') + ~(b') * ~x + ~(c') * (~x) ^ 2) ^ ~p, ~x) => (~e * (~a + ~b * ~x + ~c * (~x) ^ 2) ^ (~p + 1)) / (2 * ~c * (~p + 1)) + ((2 * ~c * ~d - ~b * ~e) / (2 * ~c)) * Antiderivative((~a + ~b * ~x + ~c * (~x) ^ 2) ^ ~p, ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~p], ~x) && (NeQ(2 * ~c * ~d - ~b * ~e, 0) && NeQ(~p, -1))
    @apply_utils Antiderivative((~d + ~(e') * ~x) * (~a + ~(c') * (~x) ^ 2) ^ ~(p'), ~x) => (~e * (~a + ~c * (~x) ^ 2) ^ (~p + 1)) / (2 * ~c * (~p + 1)) + ~d * Antiderivative((~a + ~c * (~x) ^ 2) ^ ~p, ~x) <-- FreeQ([~a, ~c, ~d, ~e, ~p], ~x) && NeQ(~p, -1)
    @apply_utils Antiderivative((~d + ~(e') * ~x) ^ ~m * (~a + ~(b') * ~x + ~(c') * (~x) ^ 2) ^ ~p, ~x) => ((~e) ^ ~m / (~c) ^ (~m / 2)) * Antiderivative((~a + ~b * ~x + ~c * (~x) ^ 2) ^ (~p + ~m / 2), ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~p], ~x) && (EqQ((~b) ^ 2 - 4 * ~a * ~c, 0) && (Not(IntegerQ(~p)) && (EqQ(2 * ~c * ~d - ~b * ~e, 0) && IntegerQ(~m / 2))))
    @apply_utils Antiderivative((~d + ~(e') * ~x) ^ ~m * (~a + ~(b') * ~x + ~(c') * (~x) ^ 2) ^ ~p, ~x) => ((~e) ^ (~m - 1) / (~c) ^ ((~m - 1) / 2)) * Antiderivative((~d + ~e * ~x) * (~a + ~b * ~x + ~c * (~x) ^ 2) ^ (~p + (~m - 1) / 2), ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~p], ~x) && (EqQ((~b) ^ 2 - 4 * ~a * ~c, 0) && (Not(IntegerQ(~p)) && (EqQ(2 * ~c * ~d - ~b * ~e, 0) && IntegerQ((~m - 1) / 2))))
    @apply_utils Antiderivative((~d + ~(e') * ~x) ^ ~m * (~a + ~(b') * ~x + ~(c') * (~x) ^ 2) ^ ~p, ~x) => ((~a + ~b * ~x + ~c * (~x) ^ 2) ^ ~p / (~d + ~e * ~x) ^ (2 * ~p)) * Antiderivative((~d + ~e * ~x) ^ (~m + 2 * ~p), ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~m, ~p], ~x) && (EqQ((~b) ^ 2 - 4 * ~a * ~c, 0) && (Not(IntegerQ(~p)) && (EqQ(2 * ~c * ~d - ~b * ~e, 0) && Not(IntegerQ(~m)))))
    @apply_utils Antiderivative((~(d') + ~(e') * ~x) ^ ~m * (~a + ~(b') * ~x + ~(c') * (~x) ^ 2) ^ ~p, ~x) => ((~a + ~b * ~x + ~c * (~x) ^ 2) ^ FracPart(~p) / ((~c) ^ IntPart(~p) * (~b / 2 + ~c * ~x) ^ (2 * FracPart(~p)))) * Antiderivative(ExpandLinearProduct((~b / 2 + ~c * ~x) ^ (2 * ~p), (~d + ~e * ~x) ^ ~m, ~b / 2, ~c, ~x), ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~m, ~p], ~x) && (EqQ((~b) ^ 2 - 4 * ~a * ~c, 0) && (Not(IntegerQ(~p)) && (NeQ(2 * ~c * ~d - ~b * ~e, 0) && (IGtQ(~m, 0) && EqQ((~m - 2 * ~p) + 1, 0)))))
    @apply_utils Antiderivative((~(d') + ~(e') * ~x) ^ ~m * (~a + ~(b') * ~x + ~(c') * (~x) ^ 2) ^ ~p, ~x) => ((~a + ~b * ~x + ~c * (~x) ^ 2) ^ FracPart(~p) / ((~c) ^ IntPart(~p) * (~b / 2 + ~c * ~x) ^ (2 * FracPart(~p)))) * Antiderivative((~d + ~e * ~x) ^ ~m * (~b / 2 + ~c * ~x) ^ (2 * ~p), ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~m, ~p], ~x) && (EqQ((~b) ^ 2 - 4 * ~a * ~c, 0) && (Not(IntegerQ(~p)) && NeQ(2 * ~c * ~d - ~b * ~e, 0)))
    @apply_utils Antiderivative((~(e') * ~x) ^ ~(m') * (~(b') * ~x + ~(c') * (~x) ^ 2) ^ ~(p'), ~x) => (1 / (~e) ^ ~p) * Antiderivative((~e * ~x) ^ (~m + ~p) * (~b + ~c * ~x) ^ ~p, ~x) <-- FreeQ([~b, ~c, ~e, ~m], ~x) && IntegerQ(~p)
    @apply_utils Antiderivative((~(d') + ~(e') * ~x) ^ ~m * (~(a') + ~(b') * ~x + ~(c') * (~x) ^ 2) ^ ~p, ~x) => (~e * (~d + ~e * ~x) ^ (~m - 1) * (~a + ~b * ~x + ~c * (~x) ^ 2) ^ (~p + 1)) / (~c * (~p + 1)) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~m, ~p], ~x) && (NeQ((~b) ^ 2 - 4 * ~a * ~c, 0) && (EqQ((~c * (~d) ^ 2 - ~b * ~d * ~e) + ~a * (~e) ^ 2, 0) && (Not(IntegerQ(~p)) && EqQ(~m + ~p, 0))))
    @apply_utils Antiderivative((~d + ~(e') * ~x) ^ ~m * (~a + ~(c') * (~x) ^ 2) ^ ~p, ~x) => (~e * (~d + ~e * ~x) ^ (~m - 1) * (~a + ~c * (~x) ^ 2) ^ (~p + 1)) / (~c * (~p + 1)) <-- FreeQ([~a, ~c, ~d, ~e, ~m, ~p], ~x) && (EqQ(~c * (~d) ^ 2 + ~a * (~e) ^ 2, 0) && (Not(IntegerQ(~p)) && EqQ(~m + ~p, 0)))
    @apply_utils Antiderivative((~(d') + ~(e') * ~x) ^ ~m * (~(a') + ~(b') * ~x + ~(c') * (~x) ^ 2) ^ ~p, ~x) => (~e * (~d + ~e * ~x) ^ ~m * (~a + ~b * ~x + ~c * (~x) ^ 2) ^ (~p + 1)) / ((~p + 1) * (2 * ~c * ~d - ~b * ~e)) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~m, ~p], ~x) && (NeQ((~b) ^ 2 - 4 * ~a * ~c, 0) && (EqQ((~c * (~d) ^ 2 - ~b * ~d * ~e) + ~a * (~e) ^ 2, 0) && (Not(IntegerQ(~p)) && EqQ(~m + 2 * ~p + 2, 0))))
    @apply_utils Antiderivative((~d + ~(e') * ~x) ^ ~m * (~a + ~(c') * (~x) ^ 2) ^ ~p, ~x) => (~e * (~d + ~e * ~x) ^ ~m * (~a + ~c * (~x) ^ 2) ^ (~p + 1)) / (2 * ~c * ~d * (~p + 1)) <-- FreeQ([~a, ~c, ~d, ~e, ~m, ~p], ~x) && (EqQ(~c * (~d) ^ 2 + ~a * (~e) ^ 2, 0) && (Not(IntegerQ(~p)) && EqQ(~m + 2 * ~p + 2, 0)))
    @apply_utils Antiderivative((~(d') + ~(e') * ~x) ^ 2 * (~(a') + ~(b') * ~x + ~(c') * (~x) ^ 2) ^ ~p, ~x) => (~e * (~d + ~e * ~x) * (~a + ~b * ~x + ~c * (~x) ^ 2) ^ (~p + 1)) / (~c * (~p + 1)) - (((~e) ^ 2 * (~p + 2)) / (~c * (~p + 1))) * Antiderivative((~a + ~b * ~x + ~c * (~x) ^ 2) ^ (~p + 1), ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~p], ~x) && (NeQ((~b) ^ 2 - 4 * ~a * ~c, 0) && (EqQ((~c * (~d) ^ 2 - ~b * ~d * ~e) + ~a * (~e) ^ 2, 0) && (Not(IntegerQ(~p)) && LtQ(~p, -1))))
    @apply_utils Antiderivative((~d + ~(e') * ~x) ^ 2 * (~a + ~(c') * (~x) ^ 2) ^ ~p, ~x) => (~e * (~d + ~e * ~x) * (~a + ~c * (~x) ^ 2) ^ (~p + 1)) / (~c * (~p + 1)) - (((~e) ^ 2 * (~p + 2)) / (~c * (~p + 1))) * Antiderivative((~a + ~c * (~x) ^ 2) ^ (~p + 1), ~x) <-- FreeQ([~a, ~c, ~d, ~e, ~p], ~x) && (EqQ(~c * (~d) ^ 2 + ~a * (~e) ^ 2, 0) && (Not(IntegerQ(~p)) && LtQ(~p, -1)))
    @apply_utils Antiderivative((~d + ~(e') * ~x) ^ ~m * (~(a') + ~(b') * ~x + ~(c') * (~x) ^ 2) ^ ~p, ~x) => Antiderivative((~a + ~b * ~x + ~c * (~x) ^ 2) ^ (~m + ~p) / (~a / ~d + (~c * ~x) / ~e) ^ ~m, ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e], ~x) && (NeQ((~b) ^ 2 - 4 * ~a * ~c, 0) && (EqQ((~c * (~d) ^ 2 - ~b * ~d * ~e) + ~a * (~e) ^ 2, 0) && (Not(IntegerQ(~p)) && (IntegerQ(~m) && (RationalQ(~p) && ((LtQ(0, -(~m), ~p) || LtQ(~p, -(~m), 0)) && (NeQ(~m, 2) && NeQ(~m, -1))))))))
    @apply_utils Antiderivative((~d + ~(e') * ~x) ^ ~m * (~a + ~(c') * (~x) ^ 2) ^ ~p, ~x) => ((~d) ^ (2 * ~m) / (~a) ^ ~m) * Antiderivative((~a + ~c * (~x) ^ 2) ^ (~m + ~p) / (~d - ~e * ~x) ^ ~m, ~x) <-- FreeQ([~a, ~c, ~d, ~e, ~m, ~p], ~x) && (EqQ(~c * (~d) ^ 2 + ~a * (~e) ^ 2, 0) && (Not(IntegerQ(~p)) && (IntegerQ(~m) && (RationalQ(~p) && ((LtQ(0, -(~m), ~p) || LtQ(~p, -(~m), 0)) && (NeQ(~m, 2) && NeQ(~m, -1)))))))
    @apply_utils Antiderivative((~(d') + ~(e') * ~x) ^ ~m * (~(a') + ~(b') * ~x + ~(c') * (~x) ^ 2) ^ ~p, ~x) => (~e * (~d + ~e * ~x) ^ (~m - 1) * (~a + ~b * ~x + ~c * (~x) ^ 2) ^ (~p + 1)) / (~c * (~m + 2 * ~p + 1)) + ((Simplify(~m + ~p) * (2 * ~c * ~d - ~b * ~e)) / (~c * (~m + 2 * ~p + 1))) * Antiderivative((~d + ~e * ~x) ^ (~m - 1) * (~a + ~b * ~x + ~c * (~x) ^ 2) ^ ~p, ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~m, ~p], ~x) && (NeQ((~b) ^ 2 - 4 * ~a * ~c, 0) && (EqQ((~c * (~d) ^ 2 - ~b * ~d * ~e) + ~a * (~e) ^ 2, 0) && (Not(IntegerQ(~p)) && IGtQ(Simplify(~m + ~p), 0))))
    @apply_utils Antiderivative((~d + ~(e') * ~x) ^ ~m * (~a + ~(c') * (~x) ^ 2) ^ ~p, ~x) => (~e * (~d + ~e * ~x) ^ (~m - 1) * (~a + ~c * (~x) ^ 2) ^ (~p + 1)) / (~c * (~m + 2 * ~p + 1)) + ((2 * ~c * ~d * Simplify(~m + ~p)) / (~c * (~m + 2 * ~p + 1))) * Antiderivative((~d + ~e * ~x) ^ (~m - 1) * (~a + ~c * (~x) ^ 2) ^ ~p, ~x) <-- FreeQ([~a, ~c, ~d, ~e, ~m, ~p], ~x) && (EqQ(~c * (~d) ^ 2 + ~a * (~e) ^ 2, 0) && (Not(IntegerQ(~p)) && IGtQ(Simplify(~m + ~p), 0)))
    @apply_utils Antiderivative((~(d') + ~(e') * ~x) ^ ~m * (~(a') + ~(b') * ~x + ~(c') * (~x) ^ 2) ^ ~p, ~x) => (-(~e) * (~d + ~e * ~x) ^ ~m * (~a + ~b * ~x + ~c * (~x) ^ 2) ^ (~p + 1)) / ((~m + ~p + 1) * (2 * ~c * ~d - ~b * ~e)) + ((~c * Simplify(~m + 2 * ~p + 2)) / ((~m + ~p + 1) * (2 * ~c * ~d - ~b * ~e))) * Antiderivative((~d + ~e * ~x) ^ (~m + 1) * (~a + ~b * ~x + ~c * (~x) ^ 2) ^ ~p, ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~m, ~p], ~x) && (NeQ((~b) ^ 2 - 4 * ~a * ~c, 0) && (EqQ((~c * (~d) ^ 2 - ~b * ~d * ~e) + ~a * (~e) ^ 2, 0) && (Not(IntegerQ(~p)) && ILtQ(Simplify(~m + 2 * ~p + 2), 0))))
    @apply_utils Antiderivative((~d + ~(e') * ~x) ^ ~m * (~a + ~(c') * (~x) ^ 2) ^ ~p, ~x) => (-(~e) * (~d + ~e * ~x) ^ ~m * (~a + ~c * (~x) ^ 2) ^ (~p + 1)) / (2 * ~c * ~d * (~m + ~p + 1)) + (Simplify(~m + 2 * ~p + 2) / (2 * ~d * (~m + ~p + 1))) * Antiderivative((~d + ~e * ~x) ^ (~m + 1) * (~a + ~c * (~x) ^ 2) ^ ~p, ~x) <-- FreeQ([~a, ~c, ~d, ~e, ~m, ~p], ~x) && (EqQ(~c * (~d) ^ 2 + ~a * (~e) ^ 2, 0) && (Not(IntegerQ(~p)) && ILtQ(Simplify(~m + 2 * ~p + 2), 0)))
    @apply_utils Antiderivative(1 / (sqrt(~(d') + ~(e') * ~x) * sqrt(~(a') + ~(b') * ~x + ~(c') * (~x) ^ 2)), ~x) => 2 * ~e * Subst(Antiderivative(1 / ((2 * ~c * ~d - ~b * ~e) + (~e) ^ 2 * (~x) ^ 2), ~x), ~x, sqrt(~a + ~b * ~x + ~c * (~x) ^ 2) / sqrt(~d + ~e * ~x)) <-- FreeQ([~a, ~b, ~c, ~d, ~e], ~x) && (NeQ((~b) ^ 2 - 4 * ~a * ~c, 0) && EqQ((~c * (~d) ^ 2 - ~b * ~d * ~e) + ~a * (~e) ^ 2, 0))
    @apply_utils Antiderivative(1 / (sqrt(~d + ~(e') * ~x) * sqrt(~a + ~(c') * (~x) ^ 2)), ~x) => 2 * ~e * Subst(Antiderivative(1 / (2 * ~c * ~d + (~e) ^ 2 * (~x) ^ 2), ~x), ~x, sqrt(~a + ~c * (~x) ^ 2) / sqrt(~d + ~e * ~x)) <-- FreeQ([~a, ~c, ~d, ~e], ~x) && EqQ(~c * (~d) ^ 2 + ~a * (~e) ^ 2, 0)
    @apply_utils Antiderivative((~(d') + ~(e') * ~x) ^ ~m * (~(a') + ~(b') * ~x + ~(c') * (~x) ^ 2) ^ ~p, ~x) => ((~d + ~e * ~x) ^ (~m + 1) * (~a + ~b * ~x + ~c * (~x) ^ 2) ^ ~p) / (~e * (~m + ~p + 1)) - ((~c * ~p) / ((~e) ^ 2 * (~m + ~p + 1))) * Antiderivative((~d + ~e * ~x) ^ (~m + 2) * (~a + ~b * ~x + ~c * (~x) ^ 2) ^ (~p - 1), ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e], ~x) && (NeQ((~b) ^ 2 - 4 * ~a * ~c, 0) && (EqQ((~c * (~d) ^ 2 - ~b * ~d * ~e) + ~a * (~e) ^ 2, 0) && (GtQ(~p, 0) && ((LtQ(~m, -2) || EqQ(~m + 2 * ~p + 1, 0)) && (NeQ(~m + ~p + 1, 0) && IntegerQ(2 * ~p))))))
    @apply_utils Antiderivative((~d + ~(e') * ~x) ^ ~m * (~a + ~(c') * (~x) ^ 2) ^ ~p, ~x) => ((~d + ~e * ~x) ^ (~m + 1) * (~a + ~c * (~x) ^ 2) ^ ~p) / (~e * (~m + ~p + 1)) - ((~c * ~p) / ((~e) ^ 2 * (~m + ~p + 1))) * Antiderivative((~d + ~e * ~x) ^ (~m + 2) * (~a + ~c * (~x) ^ 2) ^ (~p - 1), ~x) <-- FreeQ([~a, ~c, ~d, ~e], ~x) && (EqQ(~c * (~d) ^ 2 + ~a * (~e) ^ 2, 0) && (GtQ(~p, 0) && ((LtQ(~m, -2) || EqQ(~m + 2 * ~p + 1, 0)) && (NeQ(~m + ~p + 1, 0) && IntegerQ(2 * ~p)))))
    @apply_utils Antiderivative((~(d') + ~(e') * ~x) ^ ~m * (~(a') + ~(b') * ~x + ~(c') * (~x) ^ 2) ^ ~p, ~x) => ((~d + ~e * ~x) ^ (~m + 1) * (~a + ~b * ~x + ~c * (~x) ^ 2) ^ ~p) / (~e * (~m + 2 * ~p + 1)) - ((~p * (2 * ~c * ~d - ~b * ~e)) / ((~e) ^ 2 * (~m + 2 * ~p + 1))) * Antiderivative((~d + ~e * ~x) ^ (~m + 1) * (~a + ~b * ~x + ~c * (~x) ^ 2) ^ (~p - 1), ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e], ~x) && (NeQ((~b) ^ 2 - 4 * ~a * ~c, 0) && (EqQ((~c * (~d) ^ 2 - ~b * ~d * ~e) + ~a * (~e) ^ 2, 0) && (GtQ(~p, 0) && ((LeQ(-2, ~m, 0) || EqQ(~m + ~p + 1, 0)) && (NeQ(~m + 2 * ~p + 1, 0) && IntegerQ(2 * ~p))))))
    @apply_utils Antiderivative((~d + ~(e') * ~x) ^ ~m * (~a + ~(c') * (~x) ^ 2) ^ ~p, ~x) => ((~d + ~e * ~x) ^ (~m + 1) * (~a + ~c * (~x) ^ 2) ^ ~p) / (~e * (~m + 2 * ~p + 1)) - ((2 * ~c * ~d * ~p) / ((~e) ^ 2 * (~m + 2 * ~p + 1))) * Antiderivative((~d + ~e * ~x) ^ (~m + 1) * (~a + ~c * (~x) ^ 2) ^ (~p - 1), ~x) <-- FreeQ([~a, ~c, ~d, ~e], ~x) && (EqQ(~c * (~d) ^ 2 + ~a * (~e) ^ 2, 0) && (GtQ(~p, 0) && ((LeQ(-2, ~m, 0) || EqQ(~m + ~p + 1, 0)) && (NeQ(~m + 2 * ~p + 1, 0) && IntegerQ(2 * ~p)))))
    @apply_utils Antiderivative((~(d') + ~(e') * ~x) ^ ~m * (~(a') + ~(b') * ~x + ~(c') * (~x) ^ 2) ^ ~p, ~x) => ((2 * ~c * ~d - ~b * ~e) * (~d + ~e * ~x) ^ ~m * (~a + ~b * ~x + ~c * (~x) ^ 2) ^ (~p + 1)) / (~e * (~p + 1) * ((~b) ^ 2 - 4 * ~a * ~c)) - (((2 * ~c * ~d - ~b * ~e) * (~m + 2 * ~p + 2)) / ((~p + 1) * ((~b) ^ 2 - 4 * ~a * ~c))) * Antiderivative((~d + ~e * ~x) ^ (~m - 1) * (~a + ~b * ~x + ~c * (~x) ^ 2) ^ (~p + 1), ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e], ~x) && (NeQ((~b) ^ 2 - 4 * ~a * ~c, 0) && (EqQ((~c * (~d) ^ 2 - ~b * ~d * ~e) + ~a * (~e) ^ 2, 0) && (LtQ(~p, -1) && (LtQ(0, ~m, 1) && IntegerQ(2 * ~p)))))
    @apply_utils Antiderivative((~d + ~(e') * ~x) ^ ~m * (~a + ~(c') * (~x) ^ 2) ^ ~p, ~x) => (-(~d) * (~d + ~e * ~x) ^ ~m * (~a + ~c * (~x) ^ 2) ^ (~p + 1)) / (2 * ~a * ~e * (~p + 1)) + ((~d * (~m + 2 * ~p + 2)) / (2 * ~a * (~p + 1))) * Antiderivative((~d + ~e * ~x) ^ (~m - 1) * (~a + ~c * (~x) ^ 2) ^ (~p + 1), ~x) <-- FreeQ([~a, ~c, ~d, ~e], ~x) && (EqQ(~c * (~d) ^ 2 + ~a * (~e) ^ 2, 0) && (LtQ(~p, -1) && (LtQ(0, ~m, 1) && IntegerQ(2 * ~p))))
    @apply_utils Antiderivative((~(d') + ~(e') * ~x) ^ ~m * (~(a') + ~(b') * ~x + ~(c') * (~x) ^ 2) ^ ~p, ~x) => (~e * (~d + ~e * ~x) ^ (~m - 1) * (~a + ~b * ~x + ~c * (~x) ^ 2) ^ (~p + 1)) / (~c * (~p + 1)) - (((~e) ^ 2 * (~m + ~p)) / (~c * (~p + 1))) * Antiderivative((~d + ~e * ~x) ^ (~m - 2) * (~a + ~b * ~x + ~c * (~x) ^ 2) ^ (~p + 1), ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e], ~x) && (NeQ((~b) ^ 2 - 4 * ~a * ~c, 0) && (EqQ((~c * (~d) ^ 2 - ~b * ~d * ~e) + ~a * (~e) ^ 2, 0) && (LtQ(~p, -1) && (GtQ(~m, 1) && IntegerQ(2 * ~p)))))
    @apply_utils Antiderivative((~d + ~(e') * ~x) ^ ~m * (~a + ~(c') * (~x) ^ 2) ^ ~p, ~x) => (~e * (~d + ~e * ~x) ^ (~m - 1) * (~a + ~c * (~x) ^ 2) ^ (~p + 1)) / (~c * (~p + 1)) - (((~e) ^ 2 * (~m + ~p)) / (~c * (~p + 1))) * Antiderivative((~d + ~e * ~x) ^ (~m - 2) * (~a + ~c * (~x) ^ 2) ^ (~p + 1), ~x) <-- FreeQ([~a, ~c, ~d, ~e], ~x) && (EqQ(~c * (~d) ^ 2 + ~a * (~e) ^ 2, 0) && (LtQ(~p, -1) && (GtQ(~m, 1) && IntegerQ(2 * ~p))))
    @apply_utils Antiderivative((~(d') + ~(e') * ~x) ^ ~m * (~(a') + ~(b') * ~x + ~(c') * (~x) ^ 2) ^ ~p, ~x) => (~e * (~d + ~e * ~x) ^ (~m - 1) * (~a + ~b * ~x + ~c * (~x) ^ 2) ^ (~p + 1)) / (~c * (~m + 2 * ~p + 1)) + (((~m + ~p) * (2 * ~c * ~d - ~b * ~e)) / (~c * (~m + 2 * ~p + 1))) * Antiderivative((~d + ~e * ~x) ^ (~m - 1) * (~a + ~b * ~x + ~c * (~x) ^ 2) ^ ~p, ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~p], ~x) && (NeQ((~b) ^ 2 - 4 * ~a * ~c, 0) && (EqQ((~c * (~d) ^ 2 - ~b * ~d * ~e) + ~a * (~e) ^ 2, 0) && (GtQ(~m, 1) && (NeQ(~m + 2 * ~p + 1, 0) && IntegerQ(2 * ~p)))))
    @apply_utils Antiderivative((~d + ~(e') * ~x) ^ ~m * (~a + ~(c') * (~x) ^ 2) ^ ~p, ~x) => (~e * (~d + ~e * ~x) ^ (~m - 1) * (~a + ~c * (~x) ^ 2) ^ (~p + 1)) / (~c * (~m + 2 * ~p + 1)) + ((2 * ~c * ~d * (~m + ~p)) / (~c * (~m + 2 * ~p + 1))) * Antiderivative((~d + ~e * ~x) ^ (~m - 1) * (~a + ~c * (~x) ^ 2) ^ ~p, ~x) <-- FreeQ([~a, ~c, ~d, ~e, ~p], ~x) && (EqQ(~c * (~d) ^ 2 + ~a * (~e) ^ 2, 0) && (GtQ(~m, 1) && (NeQ(~m + 2 * ~p + 1, 0) && IntegerQ(2 * ~p))))
    @apply_utils Antiderivative((~(d') + ~(e') * ~x) ^ ~m * (~(a') + ~(b') * ~x + ~(c') * (~x) ^ 2) ^ ~p, ~x) => (-(~e) * (~d + ~e * ~x) ^ ~m * (~a + ~b * ~x + ~c * (~x) ^ 2) ^ (~p + 1)) / ((~m + ~p + 1) * (2 * ~c * ~d - ~b * ~e)) + ((~c * (~m + 2 * ~p + 2)) / ((~m + ~p + 1) * (2 * ~c * ~d - ~b * ~e))) * Antiderivative((~d + ~e * ~x) ^ (~m + 1) * (~a + ~b * ~x + ~c * (~x) ^ 2) ^ ~p, ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~p], ~x) && (NeQ((~b) ^ 2 - 4 * ~a * ~c, 0) && (EqQ((~c * (~d) ^ 2 - ~b * ~d * ~e) + ~a * (~e) ^ 2, 0) && (LtQ(~m, 0) && (NeQ(~m + ~p + 1, 0) && IntegerQ(2 * ~p)))))
    @apply_utils Antiderivative((~d + ~(e') * ~x) ^ ~m * (~a + ~(c') * (~x) ^ 2) ^ ~p, ~x) => (-(~e) * (~d + ~e * ~x) ^ ~m * (~a + ~c * (~x) ^ 2) ^ (~p + 1)) / (2 * ~c * ~d * (~m + ~p + 1)) + ((~m + 2 * ~p + 2) / (2 * ~d * (~m + ~p + 1))) * Antiderivative((~d + ~e * ~x) ^ (~m + 1) * (~a + ~c * (~x) ^ 2) ^ ~p, ~x) <-- FreeQ([~a, ~c, ~d, ~e, ~p], ~x) && (EqQ(~c * (~d) ^ 2 + ~a * (~e) ^ 2, 0) && (LtQ(~m, 0) && (NeQ(~m + ~p + 1, 0) && IntegerQ(2 * ~p))))
    @apply_utils Antiderivative((~(e') * ~x) ^ ~m * (~(b') * ~x + ~(c') * (~x) ^ 2) ^ ~p, ~x) => (((~e * ~x) ^ ~m * (~b * ~x + ~c * (~x) ^ 2) ^ ~p) / ((~x) ^ (~m + ~p) * (~b + ~c * ~x) ^ ~p)) * Antiderivative((~x) ^ (~m + ~p) * (~b + ~c * ~x) ^ ~p, ~x) <-- FreeQ([~b, ~c, ~e, ~m], ~x) && Not(IntegerQ(~p))
    @apply_utils Antiderivative((~d + ~(e') * ~x) ^ ~m * (~a + ~(c') * (~x) ^ 2) ^ ~p, ~x) => Antiderivative((~d + ~e * ~x) ^ (~m + ~p) * (~a / ~d + (~c / ~e) * ~x) ^ ~p, ~x) <-- FreeQ([~a, ~c, ~d, ~e, ~m, ~p], ~x) && (EqQ(~c * (~d) ^ 2 + ~a * (~e) ^ 2, 0) && (Not(IntegerQ(~p)) && (GtQ(~a, 0) && (GtQ(~d, 0) && Not(IGtQ(~m, 0))))))
    @apply_utils Antiderivative((~d + ~(e') * ~x) ^ ~m * (~a + ~(c') * (~x) ^ 2) ^ ~p, ~x) => (((~a) ^ (~p + 1) * (~d) ^ (~m - 1) * ((~d - ~e * ~x) / ~d) ^ (~p + 1)) / (~a / ~d + (~c * ~x) / ~e) ^ (~p + 1)) * Antiderivative((1 + (~e * ~x) / ~d) ^ (~m + ~p) * (~a / ~d + (~c / ~e) * ~x) ^ ~p, ~x) <-- FreeQ([~a, ~c, ~d, ~e, ~m], ~x) && (EqQ(~c * (~d) ^ 2 + ~a * (~e) ^ 2, 0) && (Not(IntegerQ(~p)) && ((IntegerQ(~m) || GtQ(~d, 0)) && (GtQ(~a, 0) && Not(IGtQ(~m, 0) && (IntegerQ(3 * ~p) || IntegerQ(4 * ~p)))))))
    @apply_utils Antiderivative((~d + ~(e') * ~x) ^ ~m * (~(a') + ~(b') * ~x + ~(c') * (~x) ^ 2) ^ ~p, ~x) => (((~d) ^ ~m * (~a + ~b * ~x + ~c * (~x) ^ 2) ^ FracPart(~p)) / ((1 + (~e * ~x) / ~d) ^ FracPart(~p) * (~a / ~d + (~c * ~x) / ~e) ^ FracPart(~p))) * Antiderivative((1 + (~e * ~x) / ~d) ^ (~m + ~p) * (~a / ~d + (~c / ~e) * ~x) ^ ~p, ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~m], ~x) && (NeQ((~b) ^ 2 - 4 * ~a * ~c, 0) && (EqQ((~c * (~d) ^ 2 - ~b * ~d * ~e) + ~a * (~e) ^ 2, 0) && (Not(IntegerQ(~p)) && ((IntegerQ(~m) || GtQ(~d, 0)) && Not(IGtQ(~m, 0) && (IntegerQ(3 * ~p) || IntegerQ(4 * ~p)))))))
    @apply_utils Antiderivative((~d + ~(e') * ~x) ^ ~m * (~a + ~(c') * (~x) ^ 2) ^ ~p, ~x) => (((~d) ^ (~m - 1) * (~a + ~c * (~x) ^ 2) ^ (~p + 1)) / ((1 + (~e * ~x) / ~d) ^ (~p + 1) * (~a / ~d + (~c * ~x) / ~e) ^ (~p + 1))) * Antiderivative((1 + (~e * ~x) / ~d) ^ (~m + ~p) * (~a / ~d + (~c / ~e) * ~x) ^ ~p, ~x) <-- FreeQ([~a, ~c, ~d, ~e, ~m], ~x) && (EqQ(~c * (~d) ^ 2 + ~a * (~e) ^ 2, 0) && (Not(IntegerQ(~p)) && ((IntegerQ(~m) || GtQ(~d, 0)) && Not(IGtQ(~m, 0) && (IntegerQ(3 * ~p) || IntegerQ(4 * ~p))))))
    @apply_utils Antiderivative((~d + ~(e') * ~x) ^ ~m * (~(a') + ~(b') * ~x + ~(c') * (~x) ^ 2) ^ ~p, ~x) => (((~d) ^ IntPart(~m) * (~d + ~e * ~x) ^ FracPart(~m)) / (1 + (~e * ~x) / ~d) ^ FracPart(~m)) * Antiderivative((1 + (~e * ~x) / ~d) ^ ~m * (~a + ~b * ~x + ~c * (~x) ^ 2) ^ ~p, ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~m], ~x) && (NeQ((~b) ^ 2 - 4 * ~a * ~c, 0) && (EqQ((~c * (~d) ^ 2 - ~b * ~d * ~e) + ~a * (~e) ^ 2, 0) && (Not(IntegerQ(~p)) && Not(IntegerQ(~m) || GtQ(~d, 0)))))
    @apply_utils Antiderivative((~d + ~(e') * ~x) ^ ~m * (~a + ~(c') * (~x) ^ 2) ^ ~p, ~x) => (((~d) ^ IntPart(~m) * (~d + ~e * ~x) ^ FracPart(~m)) / (1 + (~e * ~x) / ~d) ^ FracPart(~m)) * Antiderivative((1 + (~e * ~x) / ~d) ^ ~m * (~a + ~c * (~x) ^ 2) ^ ~p, ~x) <-- FreeQ([~a, ~c, ~d, ~e, ~m], ~x) && (EqQ(~c * (~d) ^ 2 + ~a * (~e) ^ 2, 0) && (Not(IntegerQ(~p)) && Not(IntegerQ(~m) || GtQ(~d, 0))))
    @apply_utils Antiderivative(1 / ((~d + ~(e') * ~x) * (~(a') + ~(b') * ~x + ~(c') * (~x) ^ 2)), ~x) => ((-4 * ~b * ~c) / (~d * ((~b) ^ 2 - 4 * ~a * ~c))) * Antiderivative(1 / (~b + 2 * ~c * ~x), ~x) + ((~b) ^ 2 / ((~d) ^ 2 * ((~b) ^ 2 - 4 * ~a * ~c))) * Antiderivative((~d + ~e * ~x) / (~a + ~b * ~x + ~c * (~x) ^ 2), ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e], ~x) && (NeQ((~b) ^ 2 - 4 * ~a * ~c, 0) && EqQ(2 * ~c * ~d - ~b * ~e, 0))
    @apply_utils Antiderivative((~d + ~(e') * ~x) ^ ~m * (~(a') + ~(b') * ~x + ~(c') * (~x) ^ 2) ^ ~(p'), ~x) => (2 * ~c * (~d + ~e * ~x) ^ (~m + 1) * (~a + ~b * ~x + ~c * (~x) ^ 2) ^ (~p + 1)) / (~e * (~p + 1) * ((~b) ^ 2 - 4 * ~a * ~c)) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~m, ~p], ~x) && (NeQ((~b) ^ 2 - 4 * ~a * ~c, 0) && (EqQ(2 * ~c * ~d - ~b * ~e, 0) && (EqQ(~m + 2 * ~p + 3, 0) && NeQ(~p, -1))))
    @apply_utils Antiderivative((~(d') + ~(e') * ~x) ^ ~m * (~(a') + ~(b') * ~x + ~(c') * (~x) ^ 2) ^ ~(p'), ~x) => Antiderivative(ExpandIntegrand((~d + ~e * ~x) ^ ~m * (~a + ~b * ~x + ~c * (~x) ^ 2) ^ ~p, ~x), ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~m], ~x) && (NeQ((~b) ^ 2 - 4 * ~a * ~c, 0) && (EqQ(2 * ~c * ~d - ~b * ~e, 0) && (IGtQ(~p, 0) && Not(EqQ(~m, 3) && NeQ(~p, 1)))))
    @apply_utils Antiderivative((~d + ~(e') * ~x) ^ ~m * (~(a') + ~(b') * ~x + ~(c') * (~x) ^ 2) ^ ~(p'), ~x) => ((~d + ~e * ~x) ^ (~m + 1) * (~a + ~b * ~x + ~c * (~x) ^ 2) ^ ~p) / (~e * (~m + 1)) - ((~b * ~p) / (~d * ~e * (~m + 1))) * Antiderivative((~d + ~e * ~x) ^ (~m + 2) * (~a + ~b * ~x + ~c * (~x) ^ 2) ^ (~p - 1), ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e], ~x) && (NeQ((~b) ^ 2 - 4 * ~a * ~c, 0) && (EqQ(2 * ~c * ~d - ~b * ~e, 0) && (NeQ(~m + 2 * ~p + 3, 0) && (GtQ(~p, 0) && (LtQ(~m, -1) && (Not(IntegerQ(~m / 2) && LtQ(~m + 2 * ~p + 3, 0)) && IntegerQ(2 * ~p)))))))
    @apply_utils Antiderivative((~d + ~(e') * ~x) ^ ~m * (~(a') + ~(b') * ~x + ~(c') * (~x) ^ 2) ^ ~(p'), ~x) => ((~d + ~e * ~x) ^ (~m + 1) * (~a + ~b * ~x + ~c * (~x) ^ 2) ^ ~p) / (~e * (~m + 2 * ~p + 1)) - ((~d * ~p * ((~b) ^ 2 - 4 * ~a * ~c)) / (~b * ~e * (~m + 2 * ~p + 1))) * Antiderivative((~d + ~e * ~x) ^ ~m * (~a + ~b * ~x + ~c * (~x) ^ 2) ^ (~p - 1), ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~m], ~x) && (NeQ((~b) ^ 2 - 4 * ~a * ~c, 0) && (EqQ(2 * ~c * ~d - ~b * ~e, 0) && (NeQ(~m + 2 * ~p + 3, 0) && (GtQ(~p, 0) && (Not(LtQ(~m, -1)) && (Not(IGtQ((~m - 1) / 2, 0) && (Not(IntegerQ(~p)) || LtQ(~m, 2 * ~p))) && (RationalQ(~m) && IntegerQ(2 * ~p))))))))
    @apply_utils Antiderivative((~d + ~(e') * ~x) ^ ~m * (~(a') + ~(b') * ~x + ~(c') * (~x) ^ 2) ^ ~p, ~x) => (~d * (~d + ~e * ~x) ^ (~m - 1) * (~a + ~b * ~x + ~c * (~x) ^ 2) ^ (~p + 1)) / (~b * (~p + 1)) - ((~d * ~e * (~m - 1)) / (~b * (~p + 1))) * Antiderivative((~d + ~e * ~x) ^ (~m - 2) * (~a + ~b * ~x + ~c * (~x) ^ 2) ^ (~p + 1), ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e], ~x) && (NeQ((~b) ^ 2 - 4 * ~a * ~c, 0) && (EqQ(2 * ~c * ~d - ~b * ~e, 0) && (NeQ(~m + 2 * ~p + 3, 0) && (LtQ(~p, -1) && (GtQ(~m, 1) && IntegerQ(2 * ~p))))))
    @apply_utils Antiderivative((~d + ~(e') * ~x) ^ ~m * (~(a') + ~(b') * ~x + ~(c') * (~x) ^ 2) ^ ~(p'), ~x) => (2 * ~c * (~d + ~e * ~x) ^ (~m + 1) * (~a + ~b * ~x + ~c * (~x) ^ 2) ^ (~p + 1)) / (~e * (~p + 1) * ((~b) ^ 2 - 4 * ~a * ~c)) - ((2 * ~c * ~e * (~m + 2 * ~p + 3)) / (~e * (~p + 1) * ((~b) ^ 2 - 4 * ~a * ~c))) * Antiderivative((~d + ~e * ~x) ^ ~m * (~a + ~b * ~x + ~c * (~x) ^ 2) ^ (~p + 1), ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~m], ~x) && (NeQ((~b) ^ 2 - 4 * ~a * ~c, 0) && (EqQ(2 * ~c * ~d - ~b * ~e, 0) && (NeQ(~m + 2 * ~p + 3, 0) && (LtQ(~p, -1) && (Not(GtQ(~m, 1)) && (RationalQ(~m) && IntegerQ(2 * ~p)))))))
    @apply_utils Antiderivative(1 / ((~d + ~(e') * ~x) * sqrt(~(a') + ~(b') * ~x + ~(c') * (~x) ^ 2)), ~x) => 4 * ~c * Subst(Antiderivative(1 / (((~b) ^ 2 * ~e - 4 * ~a * ~c * ~e) + 4 * ~c * ~e * (~x) ^ 2), ~x), ~x, sqrt(~a + ~b * ~x + ~c * (~x) ^ 2)) <-- FreeQ([~a, ~b, ~c, ~d, ~e], ~x) && (NeQ((~b) ^ 2 - 4 * ~a * ~c, 0) && EqQ(2 * ~c * ~d - ~b * ~e, 0))
    @apply_utils Antiderivative(1 / (sqrt(~d + ~(e') * ~x) * sqrt(~(a') + ~(b') * ~x + ~(c') * (~x) ^ 2)), ~x) => (4 / ~e) * sqrt(-(~c) / ((~b) ^ 2 - 4 * ~a * ~c)) * Subst(Antiderivative(1 / sqrt(Simp(1 - ((~b) ^ 2 * (~x) ^ 4) / ((~d) ^ 2 * ((~b) ^ 2 - 4 * ~a * ~c)), ~x)), ~x), ~x, sqrt(~d + ~e * ~x)) <-- FreeQ([~a, ~b, ~c, ~d, ~e], ~x) && (NeQ((~b) ^ 2 - 4 * ~a * ~c, 0) && (EqQ(2 * ~c * ~d - ~b * ~e, 0) && LtQ(~c / ((~b) ^ 2 - 4 * ~a * ~c), 0)))
    @apply_utils Antiderivative(sqrt(~d + ~(e') * ~x) / sqrt(~(a') + ~(b') * ~x + ~(c') * (~x) ^ 2), ~x) => (4 / ~e) * sqrt(-(~c) / ((~b) ^ 2 - 4 * ~a * ~c)) * Subst(Antiderivative((~x) ^ 2 / sqrt(Simp(1 - ((~b) ^ 2 * (~x) ^ 4) / ((~d) ^ 2 * ((~b) ^ 2 - 4 * ~a * ~c)), ~x)), ~x), ~x, sqrt(~d + ~e * ~x)) <-- FreeQ([~a, ~b, ~c, ~d, ~e], ~x) && (NeQ((~b) ^ 2 - 4 * ~a * ~c, 0) && (EqQ(2 * ~c * ~d - ~b * ~e, 0) && LtQ(~c / ((~b) ^ 2 - 4 * ~a * ~c), 0)))
    @apply_utils Antiderivative((~d + ~(e') * ~x) ^ ~m / sqrt(~(a') + ~(b') * ~x + ~(c') * (~x) ^ 2), ~x) => (sqrt((-(~c) * (~a + ~b * ~x + ~c * (~x) ^ 2)) / ((~b) ^ 2 - 4 * ~a * ~c)) / sqrt(~a + ~b * ~x + ~c * (~x) ^ 2)) * Antiderivative((~d + ~e * ~x) ^ ~m / sqrt(((-(~a) * ~c) / ((~b) ^ 2 - 4 * ~a * ~c) - (~b * ~c * ~x) / ((~b) ^ 2 - 4 * ~a * ~c)) - ((~c) ^ 2 * (~x) ^ 2) / ((~b) ^ 2 - 4 * ~a * ~c)), ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e], ~x) && (NeQ((~b) ^ 2 - 4 * ~a * ~c, 0) && (EqQ(2 * ~c * ~d - ~b * ~e, 0) && EqQ((~m) ^ 2, 1 / 4)))
    @apply_utils Antiderivative((~d + ~(e') * ~x) ^ ~m * (~(a') + ~(b') * ~x + ~(c') * (~x) ^ 2) ^ ~(p'), ~x) => (2 * ~d * (~d + ~e * ~x) ^ (~m - 1) * (~a + ~b * ~x + ~c * (~x) ^ 2) ^ (~p + 1)) / (~b * (~m + 2 * ~p + 1)) + (((~d) ^ 2 * (~m - 1) * ((~b) ^ 2 - 4 * ~a * ~c)) / ((~b) ^ 2 * (~m + 2 * ~p + 1))) * Antiderivative((~d + ~e * ~x) ^ (~m - 2) * (~a + ~b * ~x + ~c * (~x) ^ 2) ^ ~p, ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~p], ~x) && (NeQ((~b) ^ 2 - 4 * ~a * ~c, 0) && (EqQ(2 * ~c * ~d - ~b * ~e, 0) && (NeQ(~m + 2 * ~p + 3, 0) && (GtQ(~m, 1) && (NeQ(~m + 2 * ~p + 1, 0) && (IntegerQ(2 * ~p) || (IntegerQ(~m) && RationalQ(~p) || OddQ(~m))))))))
    @apply_utils Antiderivative((~d + ~(e') * ~x) ^ ~m * (~(a') + ~(b') * ~x + ~(c') * (~x) ^ 2) ^ ~(p'), ~x) => (-2 * ~b * ~d * (~d + ~e * ~x) ^ (~m + 1) * (~a + ~b * ~x + ~c * (~x) ^ 2) ^ (~p + 1)) / ((~d) ^ 2 * (~m + 1) * ((~b) ^ 2 - 4 * ~a * ~c)) + (((~b) ^ 2 * (~m + 2 * ~p + 3)) / ((~d) ^ 2 * (~m + 1) * ((~b) ^ 2 - 4 * ~a * ~c))) * Antiderivative((~d + ~e * ~x) ^ (~m + 2) * (~a + ~b * ~x + ~c * (~x) ^ 2) ^ ~p, ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~p], ~x) && (NeQ((~b) ^ 2 - 4 * ~a * ~c, 0) && (EqQ(2 * ~c * ~d - ~b * ~e, 0) && (NeQ(~m + 2 * ~p + 3, 0) && (LtQ(~m, -1) && (IntegerQ(2 * ~p) || (IntegerQ(~m) && RationalQ(~p) || IntegerQ((~m + 2 * ~p + 3) / 2)))))))
    @apply_utils Antiderivative((~d + ~(e') * ~x) ^ ~m * (~(a') + ~(b') * ~x + ~(c') * (~x) ^ 2) ^ ~(p'), ~x) => (1 / ~e) * Subst(Antiderivative((~x) ^ ~m * ((~a - (~b) ^ 2 / (4 * ~c)) + (~c * (~x) ^ 2) / (~e) ^ 2) ^ ~p, ~x), ~x, ~d + ~e * ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~m, ~p], ~x) && (NeQ((~b) ^ 2 - 4 * ~a * ~c, 0) && EqQ(2 * ~c * ~d - ~b * ~e, 0))
    @apply_utils Antiderivative(1 / ((~d + ~(e') * ~x) * (~(a') + ~(c') * (~x) ^ 2) ^ (1 / 4)), ~x) => (1 / (2 * (-(~a)) ^ (1 / 4) * ~e)) * atan((-1 - (~c * (~x) ^ 2) / ~a) ^ (1 / 4) / ((1 - (~c * ~d * ~x) / (2 * ~a * ~e)) - sqrt(-1 - (~c * (~x) ^ 2) / ~a))) + (1 / (4 * (-(~a)) ^ (1 / 4) * ~e)) * log((((1 - (~c * ~d * ~x) / (2 * ~a * ~e)) + sqrt(-1 - (~c * (~x) ^ 2) / ~a)) - (-1 - (~c * (~x) ^ 2) / ~a) ^ (1 / 4)) / ((1 - (~c * ~d * ~x) / (2 * ~a * ~e)) + sqrt(-1 - (~c * (~x) ^ 2) / ~a) + (-1 - (~c * (~x) ^ 2) / ~a) ^ (1 / 4))) <-- FreeQ([~a, ~c, ~d, ~e], ~x) && (EqQ(~c * (~d) ^ 2 + 2 * ~a * (~e) ^ 2, 0) && LtQ(~a, 0))
    @apply_utils Antiderivative((~d + ~(e') * ~x) ^ ~m * (~a + ~(c') * (~x) ^ 2) ^ ~p, ~x) => (~e * ~m * (~d) ^ (~m - 1) * (~a + ~c * (~x) ^ 2) ^ (~p + 1)) / (2 * ~c * (~p + 1)) + Antiderivative(((~d + ~e * ~x) ^ ~m - ~e * ~m * (~d) ^ (~m - 1) * ~x) * (~a + ~c * (~x) ^ 2) ^ ~p, ~x) <-- FreeQ([~a, ~c, ~d, ~e], ~x) && (NeQ(~c * (~d) ^ 2 + ~a * (~e) ^ 2, 0) && (IGtQ(~p, 1) && (IGtQ(~m, 0) && LeQ(~m, ~p))))
    @apply_utils Antiderivative((~d + ~(e') * ~x) ^ ~m * (~a + ~(c') * (~x) ^ 2) ^ ~(p'), ~x) => Antiderivative(ExpandIntegrand((~d + ~e * ~x) ^ ~m * (~a + ~c * (~x) ^ 2) ^ ~p, ~x), ~x) <-- FreeQ([~a, ~c, ~d, ~e, ~m], ~x) && (NeQ(~c * (~d) ^ 2 + ~a * (~e) ^ 2, 0) && IGtQ(~p, 0))
    @apply_utils Antiderivative((~(d') + ~(e') * ~x) ^ ~m * (~(a') + ~(b') * ~x + ~(c') * (~x) ^ 2) ^ ~(p'), ~x) => Antiderivative(ExpandIntegrand((~d + ~e * ~x) ^ ~m * (~a + ~b * ~x + ~c * (~x) ^ 2) ^ ~p, ~x), ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~m], ~x) && (NeQ((~b) ^ 2 - 4 * ~a * ~c, 0) && (NeQ((~c * (~d) ^ 2 - ~b * ~d * ~e) + ~a * (~e) ^ 2, 0) && (NeQ(2 * ~c * ~d - ~b * ~e, 0) && (IntegerQ(~p) && (GtQ(~p, 0) || EqQ(~a, 0) && IntegerQ(~m))))))
    #= Antiderivative(sqrt((~d')+(~e')*(~x))/((~a')+(~b')*(~x)+(~c')*(~x)^2),~x) :=  With([q=Rt((c*d^2-b*d*e+a*e^2)/c,2)], 1/2*Antiderivative((d+q+e*x)/(sqrt(d+e*x)*(a+b*x+c*x^2)),x) + 1/2*Antiderivative((d-q+e*x)/(sqrt(d+e*x)*(a+b*x+c*x^2)),x)) <--  FreeQ([a,b,c,d,e],x) && NeQ(b^2-4*a*c,0) && NeQ(c*d^2-b*d*e+a*e^2,0) &&  NeQ(2*c*d-b*e,0) && LtQ(b^2-4*a*c,0) =#
    #= Antiderivative(sqrt((~d)+(~e')*(~x))/((~a)+(~c')*(~x)^2),~x) :=  With([q=Rt((c*d^2+a*e^2)/c,2)], 1/2*Antiderivative((d+q+e*x)/(sqrt(d+e*x)*(a+c*x^2)),x) + 1/2*Antiderivative((d-q+e*x)/(sqrt(d+e*x)*(a+c*x^2)),x)) <-- FreeQ([a,c,d,e],x)  && NeQ(c*d^2+a*e^2,0) && LtQ(-a*c,0) =#
    #= Antiderivative(sqrt((~d')+(~e')*(~x))/((~a')+(~b')*(~x)+(~c')*(~x)^2),~x) :=  With([q=Rt(b^2-4*a*c,2)], (2*c*d-b*e+e*q)/q*Antiderivative(1/(sqrt(d+e*x)*(b-q+2*c*x)),x) - (2*c*d-b*e-e*q)/q*Antiderivative(1/(sqrt(d+e*x)*(b+q+2*c*x)),x)) <--  FreeQ([a,b,c,d,e],x) && NeQ(b^2-4*a*c,0) && NeQ(c*d^2-b*d*e+a*e^2,0) &&  NeQ(2*c*d-b*e,0)#= && Not(LtQ(b^2-4*a*c,0)) =# =#
    #= Antiderivative(sqrt((~d)+(~e')*(~x))/((~a)+(~c')*(~x)^2),~x) :=  With([q=Rt(-a*c,2)], (c*d+e*q)/(2*q)*Antiderivative(1/(sqrt(d+e*x)*(-q+c*x)),x) - (c*d-e*q)/(2*q)*Antiderivative(1/(sqrt(d+e*x)*(+q+c*x)),x)) <--  FreeQ([a,c,d,e],x) && NeQ(c*d^2+a*e^2,0)#= && Not(LtQ(-a*c,0)) =# =#
    @apply_utils Antiderivative(sqrt(~(d') + ~(e') * ~x) / (~(a') + ~(b') * ~x + ~(c') * (~x) ^ 2), ~x) => 2 * ~e * Subst(Antiderivative((~x) ^ 2 / ((((~c * (~d) ^ 2 - ~b * ~d * ~e) + ~a * (~e) ^ 2) - (2 * ~c * ~d - ~b * ~e) * (~x) ^ 2) + ~c * (~x) ^ 4), ~x), ~x, sqrt(~d + ~e * ~x)) <-- FreeQ([~a, ~b, ~c, ~d, ~e], ~x) && (NeQ((~b) ^ 2 - 4 * ~a * ~c, 0) && (NeQ((~c * (~d) ^ 2 - ~b * ~d * ~e) + ~a * (~e) ^ 2, 0) && NeQ(2 * ~c * ~d - ~b * ~e, 0)))
    @apply_utils Antiderivative(sqrt(~d + ~(e') * ~x) / (~a + ~(c') * (~x) ^ 2), ~x) => 2 * ~e * Subst(Antiderivative((~x) ^ 2 / (((~c * (~d) ^ 2 + ~a * (~e) ^ 2) - 2 * ~c * ~d * (~x) ^ 2) + ~c * (~x) ^ 4), ~x), ~x, sqrt(~d + ~e * ~x)) <-- FreeQ([~a, ~c, ~d, ~e], ~x) && NeQ(~c * (~d) ^ 2 + ~a * (~e) ^ 2, 0)
    @apply_utils Antiderivative((~(d') + ~(e') * ~x) ^ ~m / (~(a') + ~(b') * ~x + ~(c') * (~x) ^ 2), ~x) => Antiderivative(PolynomialDivide((~d + ~e * ~x) ^ ~m, ~a + ~b * ~x + ~c * (~x) ^ 2, ~x), ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e], ~x) && (NeQ((~b) ^ 2 - 4 * ~a * ~c, 0) && (NeQ((~c * (~d) ^ 2 - ~b * ~d * ~e) + ~a * (~e) ^ 2, 0) && (NeQ(2 * ~c * ~d - ~b * ~e, 0) && (IGtQ(~m, 1) && (NeQ(~d, 0) || GtQ(~m, 2))))))
    @apply_utils Antiderivative((~d + ~(e') * ~x) ^ ~m / (~a + ~(c') * (~x) ^ 2), ~x) => Antiderivative(PolynomialDivide((~d + ~e * ~x) ^ ~m, ~a + ~c * (~x) ^ 2, ~x), ~x) <-- FreeQ([~a, ~c, ~d, ~e], ~x) && (NeQ(~c * (~d) ^ 2 + ~a * (~e) ^ 2, 0) && (IGtQ(~m, 1) && (NeQ(~d, 0) || GtQ(~m, 2))))
    @apply_utils Antiderivative((~(d') + ~(e') * ~x) ^ ~m / (~(a') + ~(b') * ~x + ~(c') * (~x) ^ 2), ~x) => (~e * (~d + ~e * ~x) ^ (~m - 1)) / (~c * (~m - 1)) + (1 / ~c) * Antiderivative(((~d + ~e * ~x) ^ (~m - 2) * Simp((~c * (~d) ^ 2 - ~a * (~e) ^ 2) + ~e * (2 * ~c * ~d - ~b * ~e) * ~x, ~x)) / (~a + ~b * ~x + ~c * (~x) ^ 2), ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e], ~x) && (NeQ((~b) ^ 2 - 4 * ~a * ~c, 0) && (NeQ((~c * (~d) ^ 2 - ~b * ~d * ~e) + ~a * (~e) ^ 2, 0) && (NeQ(2 * ~c * ~d - ~b * ~e, 0) && GtQ(~m, 1))))
    @apply_utils Antiderivative((~d + ~(e') * ~x) ^ ~m / (~a + ~(c') * (~x) ^ 2), ~x) => (~e * (~d + ~e * ~x) ^ (~m - 1)) / (~c * (~m - 1)) + (1 / ~c) * Antiderivative(((~d + ~e * ~x) ^ (~m - 2) * Simp((~c * (~d) ^ 2 - ~a * (~e) ^ 2) + 2 * ~c * ~d * ~e * ~x, ~x)) / (~a + ~c * (~x) ^ 2), ~x) <-- FreeQ([~a, ~c, ~d, ~e], ~x) && (NeQ(~c * (~d) ^ 2 + ~a * (~e) ^ 2, 0) && GtQ(~m, 1))
    @apply_utils Antiderivative(1 / ((~(d') + ~(e') * ~x) * (~(a') + ~(b') * ~x + ~(c') * (~x) ^ 2)), ~x) => ((~e) ^ 2 / ((~c * (~d) ^ 2 - ~b * ~d * ~e) + ~a * (~e) ^ 2)) * Antiderivative(1 / (~d + ~e * ~x), ~x) + (1 / ((~c * (~d) ^ 2 - ~b * ~d * ~e) + ~a * (~e) ^ 2)) * Antiderivative(((~c * ~d - ~b * ~e) - ~c * ~e * ~x) / (~a + ~b * ~x + ~c * (~x) ^ 2), ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e], ~x) && (NeQ((~b) ^ 2 - 4 * ~a * ~c, 0) && (NeQ((~c * (~d) ^ 2 - ~b * ~d * ~e) + ~a * (~e) ^ 2, 0) && NeQ(2 * ~c * ~d - ~b * ~e, 0)))
    @apply_utils Antiderivative(1 / ((~d + ~(e') * ~x) * (~a + ~(c') * (~x) ^ 2)), ~x) => ((~e) ^ 2 / (~c * (~d) ^ 2 + ~a * (~e) ^ 2)) * Antiderivative(1 / (~d + ~e * ~x), ~x) + (1 / (~c * (~d) ^ 2 + ~a * (~e) ^ 2)) * Antiderivative((~c * ~d - ~c * ~e * ~x) / (~a + ~c * (~x) ^ 2), ~x) <-- FreeQ([~a, ~c, ~d, ~e], ~x) && NeQ(~c * (~d) ^ 2 + ~a * (~e) ^ 2, 0)
    #= Antiderivative(1/(sqrt((~d')+(~e')*(~x))*((~a')+(~b')*(~x)+(~c')*(~x)^2)),~x) :=  With([q=Rt((c*d^2-b*d*e+a*e^2)/c,2)], 1/(2*q)*Antiderivative((d+q+e*x)/(sqrt(d+e*x)*(a+b*x+c*x^2)),x) - 1/(2*q)*Antiderivative((d-q+e*x)/(sqrt(d+e*x)*(a+b*x+c*x^2)),x)) <--  FreeQ([a,b,c,d,e],x) && NeQ(b^2-4*a*c,0) && NeQ(c*d^2-b*d*e+a*e^2,0) &&  NeQ(2*c*d-b*e,0) && LtQ(b^2-4*a*c,0) =#
    #= Antiderivative(1/(sqrt((~d)+(~e')*(~x))*((~a)+(~c')*(~x)^2)),~x) :=  With([q=Rt((c*d^2+a*e^2)/c,2)], 1/(2*q)*Antiderivative((d+q+e*x)/(sqrt(d+e*x)*(a+c*x^2)),x) - 1/(2*q)*Antiderivative((d-q+e*x)/(sqrt(d+e*x)*(a+c*x^2)),x)) <--  FreeQ([a,c,d,e],x) && NeQ(c*d^2+a*e^2,0) && LtQ(-a*c,0) =#
    #= Antiderivative(1/(sqrt((~d')+(~e')*(~x))*((~a')+(~b')*(~x)+(~c')*(~x)^2)),~x) :=  With([q=Rt(b^2-4*a*c,2)], 2*c/q*Antiderivative(1/(sqrt(d+e*x)*(b-q+2*c*x)),x) - 2*c/q*Antiderivative(1/(sqrt(d+e*x)*(b+q+2*c*x)),x)) <-- FreeQ([a,b,c,d,e],x) &&  NeQ(b^2-4*a*c,0) && NeQ(c*d^2-b*d*e+a*e^2,0) && NeQ(2*c*d-b*e,0)#= &&  Not(LtQ(b^2-4*a*c,0)) =# =#
    #= Antiderivative(1/(sqrt((~d)+(~e')*(~x))*((~a)+(~c')*(~x)^2)),~x) :=  With([q=Rt(-a*c,2)], c/(2*q)*Antiderivative(1/(sqrt(d+e*x)*(-q+c*x)),x) - c/(2*q)*Antiderivative(1/(sqrt(d+e*x)*(q+c*x)),x)) <-- FreeQ([a,c,d,e],x) &&  NeQ(c*d^2+a*e^2,0)#= && Not(LtQ(-a*c,0)) =# =#
    @apply_utils Antiderivative(1 / (sqrt(~(d') + ~(e') * ~x) * (~(a') + ~(b') * ~x + ~(c') * (~x) ^ 2)), ~x) => 2 * ~e * Subst(Antiderivative(1 / ((((~c * (~d) ^ 2 - ~b * ~d * ~e) + ~a * (~e) ^ 2) - (2 * ~c * ~d - ~b * ~e) * (~x) ^ 2) + ~c * (~x) ^ 4), ~x), ~x, sqrt(~d + ~e * ~x)) <-- FreeQ([~a, ~b, ~c, ~d, ~e], ~x) && (NeQ((~b) ^ 2 - 4 * ~a * ~c, 0) && (NeQ((~c * (~d) ^ 2 - ~b * ~d * ~e) + ~a * (~e) ^ 2, 0) && NeQ(2 * ~c * ~d - ~b * ~e, 0)))
    @apply_utils Antiderivative(1 / (sqrt(~d + ~(e') * ~x) * (~a + ~(c') * (~x) ^ 2)), ~x) => 2 * ~e * Subst(Antiderivative(1 / (((~c * (~d) ^ 2 + ~a * (~e) ^ 2) - 2 * ~c * ~d * (~x) ^ 2) + ~c * (~x) ^ 4), ~x), ~x, sqrt(~d + ~e * ~x)) <-- FreeQ([~a, ~c, ~d, ~e], ~x) && NeQ(~c * (~d) ^ 2 + ~a * (~e) ^ 2, 0)
    @apply_utils Antiderivative((~(d') + ~(e') * ~x) ^ ~m / (~(a') + ~(b') * ~x + ~(c') * (~x) ^ 2), ~x) => (~e * (~d + ~e * ~x) ^ (~m + 1)) / ((~m + 1) * ((~c * (~d) ^ 2 - ~b * ~d * ~e) + ~a * (~e) ^ 2)) + (1 / ((~c * (~d) ^ 2 - ~b * ~d * ~e) + ~a * (~e) ^ 2)) * Antiderivative(((~d + ~e * ~x) ^ (~m + 1) * Simp((~c * ~d - ~b * ~e) - ~c * ~e * ~x, ~x)) / (~a + ~b * ~x + ~c * (~x) ^ 2), ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~m], ~x) && (NeQ((~b) ^ 2 - 4 * ~a * ~c, 0) && (NeQ((~c * (~d) ^ 2 - ~b * ~d * ~e) + ~a * (~e) ^ 2, 0) && (NeQ(2 * ~c * ~d - ~b * ~e, 0) && LtQ(~m, -1))))
    @apply_utils Antiderivative((~d + ~(e') * ~x) ^ ~m / (~a + ~(c') * (~x) ^ 2), ~x) => (~e * (~d + ~e * ~x) ^ (~m + 1)) / ((~m + 1) * (~c * (~d) ^ 2 + ~a * (~e) ^ 2)) + (~c / (~c * (~d) ^ 2 + ~a * (~e) ^ 2)) * Antiderivative(((~d + ~e * ~x) ^ (~m + 1) * (~d - ~e * ~x)) / (~a + ~c * (~x) ^ 2), ~x) <-- FreeQ([~a, ~c, ~d, ~e, ~m], ~x) && (NeQ(~c * (~d) ^ 2 + ~a * (~e) ^ 2, 0) && LtQ(~m, -1))
    @apply_utils Antiderivative((~(d') + ~(e') * ~x) ^ ~m / (~(a') + ~(b') * ~x + ~(c') * (~x) ^ 2), ~x) => Antiderivative(ExpandIntegrand((~d + ~e * ~x) ^ ~m, 1 / (~a + ~b * ~x + ~c * (~x) ^ 2), ~x), ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~m], ~x) && (NeQ((~b) ^ 2 - 4 * ~a * ~c, 0) && (NeQ((~c * (~d) ^ 2 - ~b * ~d * ~e) + ~a * (~e) ^ 2, 0) && (NeQ(2 * ~c * ~d - ~b * ~e, 0) && Not(IntegerQ(~m)))))
    @apply_utils Antiderivative((~d + ~(e') * ~x) ^ ~m / (~a + ~(c') * (~x) ^ 2), ~x) => Antiderivative(ExpandIntegrand((~d + ~e * ~x) ^ ~m, 1 / (~a + ~c * (~x) ^ 2), ~x), ~x) <-- FreeQ([~a, ~c, ~d, ~e, ~m], ~x) && (NeQ(~c * (~d) ^ 2 + ~a * (~e) ^ 2, 0) && Not(IntegerQ(~m)))
    @apply_utils Antiderivative((~(d') + ~(e') * ~x) ^ ~m * (~a + ~(b') * ~x + ~(c') * (~x) ^ 2) ^ ~p, ~x) => (((~d + ~e * ~x) ^ FracPart(~p) * (~a + ~b * ~x + ~c * (~x) ^ 2) ^ FracPart(~p)) / (~a * ~d + ~c * ~e * (~x) ^ 3) ^ FracPart(~p)) * Antiderivative((~d + ~e * ~x) ^ (~m - ~p) * (~a * ~d + ~c * ~e * (~x) ^ 3) ^ ~p, ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~m, ~p], ~x) && (EqQ(~b * ~d + ~a * ~e, 0) && (EqQ(~c * ~d + ~b * ~e, 0) && (IGtQ((~m - ~p) + 1, 0) && Not(IntegerQ(~p)))))
    @apply_utils Antiderivative((~(d') + ~(e') * ~x) ^ ~m / sqrt(~(b') * ~x + ~(c') * (~x) ^ 2), ~x) => Antiderivative((~d + ~e * ~x) ^ ~m / (sqrt(~b * ~x) * sqrt(1 + (~c / ~b) * ~x)), ~x) <-- FreeQ([~b, ~c, ~d, ~e], ~x) && (NeQ(~c * ~d - ~b * ~e, 0) && (NeQ(2 * ~c * ~d - ~b * ~e, 0) && (EqQ((~m) ^ 2, 1 / 4) && (LtQ(~c, 0) && RationalQ(~b)))))
    @apply_utils Antiderivative((~(d') + ~(e') * ~x) ^ ~m / sqrt(~(b') * ~x + ~(c') * (~x) ^ 2), ~x) => ((sqrt(~x) * sqrt(~b + ~c * ~x)) / sqrt(~b * ~x + ~c * (~x) ^ 2)) * Antiderivative((~d + ~e * ~x) ^ ~m / (sqrt(~x) * sqrt(~b + ~c * ~x)), ~x) <-- FreeQ([~b, ~c, ~d, ~e], ~x) && (NeQ(~c * ~d - ~b * ~e, 0) && (NeQ(2 * ~c * ~d - ~b * ~e, 0) && EqQ((~m) ^ 2, 1 / 4)))
    @apply_utils Antiderivative((~x) ^ ~m / sqrt(~a + ~(b') * ~x + ~(c') * (~x) ^ 2), ~x) => 2 * Subst(Antiderivative((~x) ^ (2 * ~m + 1) / sqrt(~a + ~b * (~x) ^ 2 + ~c * (~x) ^ 4), ~x), ~x, sqrt(~x)) <-- FreeQ([~a, ~b, ~c], ~x) && (NeQ((~b) ^ 2 - 4 * ~a * ~c, 0) && EqQ((~m) ^ 2, 1 / 4))
    @apply_utils Antiderivative((~e * ~x) ^ ~m / sqrt(~a + ~(b') * ~x + ~(c') * (~x) ^ 2), ~x) => ((~e * ~x) ^ ~m / (~x) ^ ~m) * Antiderivative((~x) ^ ~m / sqrt(~a + ~b * ~x + ~c * (~x) ^ 2), ~x) <-- FreeQ([~a, ~b, ~c, ~e], ~x) && (NeQ((~b) ^ 2 - 4 * ~a * ~c, 0) && EqQ((~m) ^ 2, 1 / 4))
    @apply_utils Antiderivative((~(d') + ~(e') * ~x) ^ ~m / sqrt(~(a') + ~(b') * ~x + ~(c') * (~x) ^ 2), ~x) => ((2 * Rt((~b) ^ 2 - 4 * ~a * ~c, 2) * (~d + ~e * ~x) ^ ~m * sqrt((-(~c) * (~a + ~b * ~x + ~c * (~x) ^ 2)) / ((~b) ^ 2 - 4 * ~a * ~c))) / (~c * sqrt(~a + ~b * ~x + ~c * (~x) ^ 2) * ((2 * ~c * (~d + ~e * ~x)) / ((2 * ~c * ~d - ~b * ~e) - ~e * Rt((~b) ^ 2 - 4 * ~a * ~c, 2))) ^ ~m)) * Subst(Antiderivative((1 + (2 * ~e * Rt((~b) ^ 2 - 4 * ~a * ~c, 2) * (~x) ^ 2) / ((2 * ~c * ~d - ~b * ~e) - ~e * Rt((~b) ^ 2 - 4 * ~a * ~c, 2))) ^ ~m / sqrt(1 - (~x) ^ 2), ~x), ~x, sqrt((~b + Rt((~b) ^ 2 - 4 * ~a * ~c, 2) + 2 * ~c * ~x) / (2 * Rt((~b) ^ 2 - 4 * ~a * ~c, 2)))) <-- FreeQ([~a, ~b, ~c, ~d, ~e], ~x) && (NeQ((~b) ^ 2 - 4 * ~a * ~c, 0) && (NeQ((~c * (~d) ^ 2 - ~b * ~d * ~e) + ~a * (~e) ^ 2, 0) && (NeQ(2 * ~c * ~d - ~b * ~e, 0) && EqQ((~m) ^ 2, 1 / 4))))
    @apply_utils Antiderivative((~d + ~(e') * ~x) ^ ~m / sqrt(~a + ~(c') * (~x) ^ 2), ~x) => ((2 * ~a * Rt(-(~c) / ~a, 2) * (~d + ~e * ~x) ^ ~m * sqrt(1 + (~c * (~x) ^ 2) / ~a)) / (~c * sqrt(~a + ~c * (~x) ^ 2) * ((~c * (~d + ~e * ~x)) / (~c * ~d - ~a * ~e * Rt(-(~c) / ~a, 2))) ^ ~m)) * Subst(Antiderivative((1 + (2 * ~a * ~e * Rt(-(~c) / ~a, 2) * (~x) ^ 2) / (~c * ~d - ~a * ~e * Rt(-(~c) / ~a, 2))) ^ ~m / sqrt(1 - (~x) ^ 2), ~x), ~x, sqrt((1 - Rt(-(~c) / ~a, 2) * ~x) / 2)) <-- FreeQ([~a, ~c, ~d, ~e], ~x) && (NeQ(~c * (~d) ^ 2 + ~a * (~e) ^ 2, 0) && EqQ((~m) ^ 2, 1 / 4))
    @apply_utils Antiderivative((~(d') + ~(e') * ~x) ^ ~m * (~(a') + ~(b') * ~x + ~(c') * (~x) ^ 2) ^ ~p, ~x) => (-((~d + ~e * ~x) ^ (~m + 1)) * ((~d * ~b - 2 * ~a * ~e) + (2 * ~c * ~d - ~b * ~e) * ~x) * (~a + ~b * ~x + ~c * (~x) ^ 2) ^ ~p) / (2 * (~m + 1) * ((~c * (~d) ^ 2 - ~b * ~d * ~e) + ~a * (~e) ^ 2)) + ((~p * ((~b) ^ 2 - 4 * ~a * ~c)) / (2 * (~m + 1) * ((~c * (~d) ^ 2 - ~b * ~d * ~e) + ~a * (~e) ^ 2))) * Antiderivative((~d + ~e * ~x) ^ (~m + 2) * (~a + ~b * ~x + ~c * (~x) ^ 2) ^ (~p - 1), ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e], ~x) && (NeQ((~b) ^ 2 - 4 * ~a * ~c, 0) && (NeQ((~c * (~d) ^ 2 - ~b * ~d * ~e) + ~a * (~e) ^ 2, 0) && (NeQ(2 * ~c * ~d - ~b * ~e, 0) && (EqQ(~m + 2 * ~p + 2, 0) && GtQ(~p, 0)))))
    @apply_utils Antiderivative((~d + ~(e') * ~x) ^ ~m * (~a + ~(c') * (~x) ^ 2) ^ ~p, ~x) => (-((~d + ~e * ~x) ^ (~m + 1)) * (-2 * ~a * ~e + (2 * ~c * ~d) * ~x) * (~a + ~c * (~x) ^ 2) ^ ~p) / (2 * (~m + 1) * (~c * (~d) ^ 2 + ~a * (~e) ^ 2)) - ((4 * ~a * ~c * ~p) / (2 * (~m + 1) * (~c * (~d) ^ 2 + ~a * (~e) ^ 2))) * Antiderivative((~d + ~e * ~x) ^ (~m + 2) * (~a + ~c * (~x) ^ 2) ^ (~p - 1), ~x) <-- FreeQ([~a, ~c, ~d, ~e], ~x) && (NeQ(~c * (~d) ^ 2 + ~a * (~e) ^ 2, 0) && (EqQ(~m + 2 * ~p + 2, 0) && GtQ(~p, 0)))
    @apply_utils Antiderivative((~(d') + ~(e') * ~x) ^ ~m * (~(a') + ~(b') * ~x + ~(c') * (~x) ^ 2) ^ ~p, ~x) => ((~d + ~e * ~x) ^ (~m - 1) * ((~d * ~b - 2 * ~a * ~e) + (2 * ~c * ~d - ~b * ~e) * ~x) * (~a + ~b * ~x + ~c * (~x) ^ 2) ^ (~p + 1)) / ((~p + 1) * ((~b) ^ 2 - 4 * ~a * ~c)) - ((2 * (2 * ~p + 3) * ((~c * (~d) ^ 2 - ~b * ~d * ~e) + ~a * (~e) ^ 2)) / ((~p + 1) * ((~b) ^ 2 - 4 * ~a * ~c))) * Antiderivative((~d + ~e * ~x) ^ (~m - 2) * (~a + ~b * ~x + ~c * (~x) ^ 2) ^ (~p + 1), ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e], ~x) && (NeQ((~b) ^ 2 - 4 * ~a * ~c, 0) && (NeQ((~c * (~d) ^ 2 - ~b * ~d * ~e) + ~a * (~e) ^ 2, 0) && (NeQ(2 * ~c * ~d - ~b * ~e, 0) && (EqQ(~m + 2 * ~p + 2, 0) && LtQ(~p, -1)))))
    @apply_utils Antiderivative((~d + ~(e') * ~x) ^ ~m * (~a + ~(c') * (~x) ^ 2) ^ ~p, ~x) => ((~d + ~e * ~x) ^ (~m - 1) * (~a * ~e - ~c * ~d * ~x) * (~a + ~c * (~x) ^ 2) ^ (~p + 1)) / (2 * ~a * ~c * (~p + 1)) + (((2 * ~p + 3) * (~c * (~d) ^ 2 + ~a * (~e) ^ 2)) / (2 * ~a * ~c * (~p + 1))) * Antiderivative((~d + ~e * ~x) ^ (~m - 2) * (~a + ~c * (~x) ^ 2) ^ (~p + 1), ~x) <-- FreeQ([~a, ~c, ~d, ~e], ~x) && (NeQ(~c * (~d) ^ 2 + ~a * (~e) ^ 2, 0) && (EqQ(~m + 2 * ~p + 2, 0) && LtQ(~p, -1)))
    @apply_utils Antiderivative(1 / ((~(d') + ~(e') * ~x) * sqrt(~(a') + ~(b') * ~x + ~(c') * (~x) ^ 2)), ~x) => -2 * Subst(Antiderivative(1 / (((4 * ~c * (~d) ^ 2 - 4 * ~b * ~d * ~e) + 4 * ~a * (~e) ^ 2) - (~x) ^ 2), ~x), ~x, ((2 * ~a * ~e - ~b * ~d) - (2 * ~c * ~d - ~b * ~e) * ~x) / sqrt(~a + ~b * ~x + ~c * (~x) ^ 2)) <-- FreeQ([~a, ~b, ~c, ~d, ~e], ~x) && (NeQ((~b) ^ 2 - 4 * ~a * ~c, 0) && NeQ(2 * ~c * ~d - ~b * ~e, 0))
    @apply_utils Antiderivative(1 / ((~d + ~(e') * ~x) * sqrt(~a + ~(c') * (~x) ^ 2)), ~x) => -(Subst(Antiderivative(1 / ((~c * (~d) ^ 2 + ~a * (~e) ^ 2) - (~x) ^ 2), ~x), ~x, (~a * ~e - ~c * ~d * ~x) / sqrt(~a + ~c * (~x) ^ 2))) <-- FreeQ([~a, ~c, ~d, ~e], ~x)
    @apply_utils Antiderivative((~(d') + ~(e') * ~x) ^ ~m * (~(a') + ~(b') * ~x + ~(c') * (~x) ^ 2) ^ ~p, ~x) => ((-(((~b - Rt((~b) ^ 2 - 4 * ~a * ~c, 2)) + 2 * ~c * ~x)) * (~d + ~e * ~x) ^ (~m + 1) * (~a + ~b * ~x + ~c * (~x) ^ 2) ^ ~p) / ((~m + 1) * ((2 * ~c * ~d - ~b * ~e) + ~e * Rt((~b) ^ 2 - 4 * ~a * ~c, 2)) * ((((2 * ~c * ~d - ~b * ~e) + ~e * Rt((~b) ^ 2 - 4 * ~a * ~c, 2)) * (~b + Rt((~b) ^ 2 - 4 * ~a * ~c, 2) + 2 * ~c * ~x)) / (((2 * ~c * ~d - ~b * ~e) - ~e * Rt((~b) ^ 2 - 4 * ~a * ~c, 2)) * ((~b - Rt((~b) ^ 2 - 4 * ~a * ~c, 2)) + 2 * ~c * ~x))) ^ ~p)) * HypergeometricFunctions._₂F₁(~m + 1, -(~p), ~m + 2, (-4 * ~c * Rt((~b) ^ 2 - 4 * ~a * ~c, 2) * (~d + ~e * ~x)) / (((2 * ~c * ~d - ~b * ~e) - ~e * Rt((~b) ^ 2 - 4 * ~a * ~c, 2)) * ((~b - Rt((~b) ^ 2 - 4 * ~a * ~c, 2)) + 2 * ~c * ~x))) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~m, ~p], ~x) && (NeQ((~b) ^ 2 - 4 * ~a * ~c, 0) && (NeQ((~c * (~d) ^ 2 - ~b * ~d * ~e) + ~a * (~e) ^ 2, 0) && (NeQ(2 * ~c * ~d - ~b * ~e, 0) && (Not(IntegerQ(~p)) && EqQ(~m + 2 * ~p + 2, 0)))))
    @apply_utils Antiderivative((~d + ~(e') * ~x) ^ ~m * (~a + ~(c') * (~x) ^ 2) ^ ~p, ~x) => (((Rt(-(~a) * ~c, 2) - ~c * ~x) * (~d + ~e * ~x) ^ (~m + 1) * (~a + ~c * (~x) ^ 2) ^ ~p) / ((~m + 1) * (~c * ~d + ~e * Rt(-(~a) * ~c, 2)) * (((~c * ~d + ~e * Rt(-(~a) * ~c, 2)) * (Rt(-(~a) * ~c, 2) + ~c * ~x)) / ((~c * ~d - ~e * Rt(-(~a) * ~c, 2)) * (-(Rt(-(~a) * ~c, 2)) + ~c * ~x))) ^ ~p)) * HypergeometricFunctions._₂F₁(~m + 1, -(~p), ~m + 2, (2 * ~c * Rt(-(~a) * ~c, 2) * (~d + ~e * ~x)) / ((~c * ~d - ~e * Rt(-(~a) * ~c, 2)) * (Rt(-(~a) * ~c, 2) - ~c * ~x))) <-- FreeQ([~a, ~c, ~d, ~e, ~m, ~p], ~x) && (NeQ(~c * (~d) ^ 2 + ~a * (~e) ^ 2, 0) && (Not(IntegerQ(~p)) && EqQ(~m + 2 * ~p + 2, 0)))
    @apply_utils Antiderivative((~(d') + ~(e') * ~x) ^ ~m * (~(a') + ~(b') * ~x + ~(c') * (~x) ^ 2) ^ ~p, ~x) => ((~d + ~e * ~x) ^ ~m * (~b + 2 * ~c * ~x) * (~a + ~b * ~x + ~c * (~x) ^ 2) ^ (~p + 1)) / ((~p + 1) * ((~b) ^ 2 - 4 * ~a * ~c)) + ((~m * (2 * ~c * ~d - ~b * ~e)) / ((~p + 1) * ((~b) ^ 2 - 4 * ~a * ~c))) * Antiderivative((~d + ~e * ~x) ^ (~m - 1) * (~a + ~b * ~x + ~c * (~x) ^ 2) ^ (~p + 1), ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~m, ~p], ~x) && (NeQ((~b) ^ 2 - 4 * ~a * ~c, 0) && (NeQ((~c * (~d) ^ 2 - ~b * ~d * ~e) + ~a * (~e) ^ 2, 0) && (NeQ(2 * ~c * ~d - ~b * ~e, 0) && (EqQ(~m + 2 * ~p + 3, 0) && LtQ(~p, -1)))))
    @apply_utils Antiderivative((~d + ~(e') * ~x) ^ ~m * (~a + ~(c') * (~x) ^ 2) ^ ~p, ~x) => (-((~d + ~e * ~x) ^ ~m) * (2 * ~c * ~x) * (~a + ~c * (~x) ^ 2) ^ (~p + 1)) / (4 * ~a * ~c * (~p + 1)) - ((~m * (2 * ~c * ~d)) / (4 * ~a * ~c * (~p + 1))) * Antiderivative((~d + ~e * ~x) ^ (~m - 1) * (~a + ~c * (~x) ^ 2) ^ (~p + 1), ~x) <-- FreeQ([~a, ~c, ~d, ~e, ~m, ~p], ~x) && (NeQ(~c * (~d) ^ 2 + ~a * (~e) ^ 2, 0) && (EqQ(~m + 2 * ~p + 3, 0) && LtQ(~p, -1)))
    @apply_utils Antiderivative((~(d') + ~(e') * ~x) ^ ~m * (~(a') + ~(b') * ~x + ~(c') * (~x) ^ 2) ^ ~p, ~x) => (~e * (~d + ~e * ~x) ^ (~m + 1) * (~a + ~b * ~x + ~c * (~x) ^ 2) ^ (~p + 1)) / ((~m + 1) * ((~c * (~d) ^ 2 - ~b * ~d * ~e) + ~a * (~e) ^ 2)) + ((2 * ~c * ~d - ~b * ~e) / (2 * ((~c * (~d) ^ 2 - ~b * ~d * ~e) + ~a * (~e) ^ 2))) * Antiderivative((~d + ~e * ~x) ^ (~m + 1) * (~a + ~b * ~x + ~c * (~x) ^ 2) ^ ~p, ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~m, ~p], ~x) && (NeQ((~b) ^ 2 - 4 * ~a * ~c, 0) && (NeQ((~c * (~d) ^ 2 - ~b * ~d * ~e) + ~a * (~e) ^ 2, 0) && (NeQ(2 * ~c * ~d - ~b * ~e, 0) && EqQ(~m + 2 * ~p + 3, 0))))
    @apply_utils Antiderivative((~d + ~(e') * ~x) ^ ~m * (~a + ~(c') * (~x) ^ 2) ^ ~p, ~x) => (~e * (~d + ~e * ~x) ^ (~m + 1) * (~a + ~c * (~x) ^ 2) ^ (~p + 1)) / ((~m + 1) * (~c * (~d) ^ 2 + ~a * (~e) ^ 2)) + ((~c * ~d) / (~c * (~d) ^ 2 + ~a * (~e) ^ 2)) * Antiderivative((~d + ~e * ~x) ^ (~m + 1) * (~a + ~c * (~x) ^ 2) ^ ~p, ~x) <-- FreeQ([~a, ~c, ~d, ~e, ~m, ~p], ~x) && (NeQ(~c * (~d) ^ 2 + ~a * (~e) ^ 2, 0) && EqQ(~m + 2 * ~p + 3, 0))
    @apply_utils Antiderivative((~(d') + ~(e') * ~x) ^ ~m * (~(a') + ~(b') * ~x + ~(c') * (~x) ^ 2) ^ ~p, ~x) => ((~d + ~e * ~x) ^ (~m + 1) * (~a + ~b * ~x + ~c * (~x) ^ 2) ^ ~p) / (~e * (~m + 1)) - (~p / (~e * (~m + 1))) * Antiderivative((~d + ~e * ~x) ^ (~m + 1) * (~b + 2 * ~c * ~x) * (~a + ~b * ~x + ~c * (~x) ^ 2) ^ (~p - 1), ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~m], ~x) && (NeQ((~b) ^ 2 - 4 * ~a * ~c, 0) && (NeQ((~c * (~d) ^ 2 - ~b * ~d * ~e) + ~a * (~e) ^ 2, 0) && (NeQ(2 * ~c * ~d - ~b * ~e, 0) && (GtQ(~p, 0) && ((IntegerQ(~p) || LtQ(~m, -1)) && (NeQ(~m, -1) && (Not(ILtQ(~m + 2 * ~p + 1, 0)) && IntQuadraticQ(~a, ~b, ~c, ~d, ~e, ~m, ~p, ~x))))))))
    @apply_utils Antiderivative((~d + ~(e') * ~x) ^ ~m * (~a + ~(c') * (~x) ^ 2) ^ ~p, ~x) => ((~d + ~e * ~x) ^ (~m + 1) * (~a + ~c * (~x) ^ 2) ^ ~p) / (~e * (~m + 1)) - ((2 * ~c * ~p) / (~e * (~m + 1))) * Antiderivative(~x * (~d + ~e * ~x) ^ (~m + 1) * (~a + ~c * (~x) ^ 2) ^ (~p - 1), ~x) <-- FreeQ([~a, ~c, ~d, ~e, ~m], ~x) && (NeQ(~c * (~d) ^ 2 + ~a * (~e) ^ 2, 0) && (GtQ(~p, 0) && ((IntegerQ(~p) || LtQ(~m, -1)) && (NeQ(~m, -1) && (Not(ILtQ(~m + 2 * ~p + 1, 0)) && IntQuadraticQ(~a, 0, ~c, ~d, ~e, ~m, ~p, ~x))))))
    @apply_utils Antiderivative((~(d') + ~(e') * ~x) ^ ~m * (~(a') + ~(b') * ~x + ~(c') * (~x) ^ 2) ^ ~p, ~x) => ((~d + ~e * ~x) ^ (~m + 1) * (~a + ~b * ~x + ~c * (~x) ^ 2) ^ ~p) / (~e * (~m + 2 * ~p + 1)) - (~p / (~e * (~m + 2 * ~p + 1))) * Antiderivative((~d + ~e * ~x) ^ ~m * Simp((~b * ~d - 2 * ~a * ~e) + (2 * ~c * ~d - ~b * ~e) * ~x, ~x) * (~a + ~b * ~x + ~c * (~x) ^ 2) ^ (~p - 1), ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~m], ~x) && (NeQ((~b) ^ 2 - 4 * ~a * ~c, 0) && (NeQ((~c * (~d) ^ 2 - ~b * ~d * ~e) + ~a * (~e) ^ 2, 0) && (NeQ(2 * ~c * ~d - ~b * ~e, 0) && (GtQ(~p, 0) && (NeQ(~m + 2 * ~p + 1, 0) && ((Not(RationalQ(~m)) || LtQ(~m, 1)) && (Not(ILtQ(~m + 2 * ~p, 0)) && IntQuadraticQ(~a, ~b, ~c, ~d, ~e, ~m, ~p, ~x))))))))
    @apply_utils Antiderivative((~d + ~(e') * ~x) ^ ~m * (~a + ~(c') * (~x) ^ 2) ^ ~p, ~x) => ((~d + ~e * ~x) ^ (~m + 1) * (~a + ~c * (~x) ^ 2) ^ ~p) / (~e * (~m + 2 * ~p + 1)) + ((2 * ~p) / (~e * (~m + 2 * ~p + 1))) * Antiderivative((~d + ~e * ~x) ^ ~m * Simp(~a * ~e - ~c * ~d * ~x, ~x) * (~a + ~c * (~x) ^ 2) ^ (~p - 1), ~x) <-- FreeQ([~a, ~c, ~d, ~e, ~m], ~x) && (NeQ(~c * (~d) ^ 2 + ~a * (~e) ^ 2, 0) && (GtQ(~p, 0) && (NeQ(~m + 2 * ~p + 1, 0) && ((Not(RationalQ(~m)) || LtQ(~m, 1)) && (Not(ILtQ(~m + 2 * ~p, 0)) && IntQuadraticQ(~a, 0, ~c, ~d, ~e, ~m, ~p, ~x))))))
    @apply_utils Antiderivative((~(d') + ~(e') * ~x) ^ ~m * (~(a') + ~(b') * ~x + ~(c') * (~x) ^ 2) ^ ~p, ~x) => ((~d + ~e * ~x) ^ ~m * (~b + 2 * ~c * ~x) * (~a + ~b * ~x + ~c * (~x) ^ 2) ^ (~p + 1)) / ((~p + 1) * ((~b) ^ 2 - 4 * ~a * ~c)) - (1 / ((~p + 1) * ((~b) ^ 2 - 4 * ~a * ~c))) * Antiderivative((~d + ~e * ~x) ^ (~m - 1) * (~b * ~e * ~m + 2 * ~c * ~d * (2 * ~p + 3) + 2 * ~c * ~e * (~m + 2 * ~p + 3) * ~x) * (~a + ~b * ~x + ~c * (~x) ^ 2) ^ (~p + 1), ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e], ~x) && (NeQ((~b) ^ 2 - 4 * ~a * ~c, 0) && (NeQ((~c * (~d) ^ 2 - ~b * ~d * ~e) + ~a * (~e) ^ 2, 0) && (NeQ(2 * ~c * ~d - ~b * ~e, 0) && (LtQ(~p, -1) && (GtQ(~m, 0) && ((LtQ(~m, 1) || ILtQ(~m + 2 * ~p + 3, 0) && NeQ(~m, 2)) && IntQuadraticQ(~a, ~b, ~c, ~d, ~e, ~m, ~p, ~x)))))))
    @apply_utils Antiderivative((~d + ~(e') * ~x) ^ ~m * (~a + ~(c') * (~x) ^ 2) ^ ~p, ~x) => (-(~x) * (~d + ~e * ~x) ^ ~m * (~a + ~c * (~x) ^ 2) ^ (~p + 1)) / (2 * ~a * (~p + 1)) + (1 / (2 * ~a * (~p + 1))) * Antiderivative((~d + ~e * ~x) ^ (~m - 1) * (~d * (2 * ~p + 3) + ~e * (~m + 2 * ~p + 3) * ~x) * (~a + ~c * (~x) ^ 2) ^ (~p + 1), ~x) <-- FreeQ([~a, ~c, ~d, ~e], ~x) && (NeQ(~c * (~d) ^ 2 + ~a * (~e) ^ 2, 0) && (LtQ(~p, -1) && (GtQ(~m, 0) && ((LtQ(~m, 1) || ILtQ(~m + 2 * ~p + 3, 0) && NeQ(~m, 2)) && IntQuadraticQ(~a, 0, ~c, ~d, ~e, ~m, ~p, ~x)))))
    @apply_utils Antiderivative((~(d') + ~(e') * ~x) ^ ~m * (~(a') + ~(b') * ~x + ~(c') * (~x) ^ 2) ^ ~p, ~x) => ((~d + ~e * ~x) ^ (~m - 1) * ((~d * ~b - 2 * ~a * ~e) + (2 * ~c * ~d - ~b * ~e) * ~x) * (~a + ~b * ~x + ~c * (~x) ^ 2) ^ (~p + 1)) / ((~p + 1) * ((~b) ^ 2 - 4 * ~a * ~c)) + (1 / ((~p + 1) * ((~b) ^ 2 - 4 * ~a * ~c))) * Antiderivative((~d + ~e * ~x) ^ (~m - 2) * Simp((~e * (2 * ~a * ~e * (~m - 1) + ~b * ~d * ((2 * ~p - ~m) + 4)) - 2 * ~c * (~d) ^ 2 * (2 * ~p + 3)) + ~e * (~b * ~e - 2 * ~d * ~c) * (~m + 2 * ~p + 2) * ~x, ~x) * (~a + ~b * ~x + ~c * (~x) ^ 2) ^ (~p + 1), ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e], ~x) && (NeQ((~b) ^ 2 - 4 * ~a * ~c, 0) && (NeQ((~c * (~d) ^ 2 - ~b * ~d * ~e) + ~a * (~e) ^ 2, 0) && (NeQ(2 * ~c * ~d - ~b * ~e, 0) && (LtQ(~p, -1) && (GtQ(~m, 1) && IntQuadraticQ(~a, ~b, ~c, ~d, ~e, ~m, ~p, ~x))))))
    @apply_utils Antiderivative((~d + ~(e') * ~x) ^ ~m * (~a + ~(c') * (~x) ^ 2) ^ ~p, ~x) => ((~d + ~e * ~x) ^ (~m - 1) * (~a * ~e - ~c * ~d * ~x) * (~a + ~c * (~x) ^ 2) ^ (~p + 1)) / (2 * ~a * ~c * (~p + 1)) + (1 / ((~p + 1) * (-2 * ~a * ~c))) * Antiderivative((~d + ~e * ~x) ^ (~m - 2) * Simp((~a * (~e) ^ 2 * (~m - 1) - ~c * (~d) ^ 2 * (2 * ~p + 3)) - ~d * ~c * ~e * (~m + 2 * ~p + 2) * ~x, ~x) * (~a + ~c * (~x) ^ 2) ^ (~p + 1), ~x) <-- FreeQ([~a, ~c, ~d, ~e], ~x) && (NeQ(~c * (~d) ^ 2 + ~a * (~e) ^ 2, 0) && (LtQ(~p, -1) && (GtQ(~m, 1) && IntQuadraticQ(~a, 0, ~c, ~d, ~e, ~m, ~p, ~x))))
    @apply_utils Antiderivative((~(d') + ~(e') * ~x) ^ ~m * (~(a') + ~(b') * ~x + ~(c') * (~x) ^ 2) ^ ~p, ~x) => ((~d + ~e * ~x) ^ (~m + 1) * ((~b * ~c * ~d - (~b) ^ 2 * ~e) + 2 * ~a * ~c * ~e + ~c * (2 * ~c * ~d - ~b * ~e) * ~x) * (~a + ~b * ~x + ~c * (~x) ^ 2) ^ (~p + 1)) / ((~p + 1) * ((~b) ^ 2 - 4 * ~a * ~c) * ((~c * (~d) ^ 2 - ~b * ~d * ~e) + ~a * (~e) ^ 2)) + (1 / ((~p + 1) * ((~b) ^ 2 - 4 * ~a * ~c) * ((~c * (~d) ^ 2 - ~b * ~d * ~e) + ~a * (~e) ^ 2))) * Antiderivative((~d + ~e * ~x) ^ ~m * Simp((((~b * ~c * ~d * ~e * ((2 * ~p - ~m) + 2) + (~b) ^ 2 * (~e) ^ 2 * (~m + ~p + 2)) - 2 * (~c) ^ 2 * (~d) ^ 2 * (2 * ~p + 3)) - 2 * ~a * ~c * (~e) ^ 2 * (~m + 2 * ~p + 3)) - ~c * ~e * (2 * ~c * ~d - ~b * ~e) * (~m + 2 * ~p + 4) * ~x, ~x) * (~a + ~b * ~x + ~c * (~x) ^ 2) ^ (~p + 1), ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~m], ~x) && (NeQ((~b) ^ 2 - 4 * ~a * ~c, 0) && (NeQ((~c * (~d) ^ 2 - ~b * ~d * ~e) + ~a * (~e) ^ 2, 0) && (NeQ(2 * ~c * ~d - ~b * ~e, 0) && (LtQ(~p, -1) && IntQuadraticQ(~a, ~b, ~c, ~d, ~e, ~m, ~p, ~x)))))
    @apply_utils Antiderivative((~d + ~(e') * ~x) ^ ~m * (~a + ~(c') * (~x) ^ 2) ^ ~p, ~x) => (-((~d + ~e * ~x) ^ (~m + 1)) * (~a * ~e + ~c * ~d * ~x) * (~a + ~c * (~x) ^ 2) ^ (~p + 1)) / (2 * ~a * (~p + 1) * (~c * (~d) ^ 2 + ~a * (~e) ^ 2)) + (1 / (2 * ~a * (~p + 1) * (~c * (~d) ^ 2 + ~a * (~e) ^ 2))) * Antiderivative((~d + ~e * ~x) ^ ~m * Simp(~c * (~d) ^ 2 * (2 * ~p + 3) + ~a * (~e) ^ 2 * (~m + 2 * ~p + 3) + ~c * ~e * ~d * (~m + 2 * ~p + 4) * ~x, ~x) * (~a + ~c * (~x) ^ 2) ^ (~p + 1), ~x) <-- FreeQ([~a, ~c, ~d, ~e, ~m], ~x) && (NeQ(~c * (~d) ^ 2 + ~a * (~e) ^ 2, 0) && (LtQ(~p, -1) && IntQuadraticQ(~a, 0, ~c, ~d, ~e, ~m, ~p, ~x)))
    @apply_utils Antiderivative((~(d') + ~(e') * ~x) ^ ~m * (~(a') + ~(b') * ~x + ~(c') * (~x) ^ 2) ^ ~p, ~x) => (~e * (~d + ~e * ~x) ^ (~m - 1) * (~a + ~b * ~x + ~c * (~x) ^ 2) ^ (~p + 1)) / (~c * (~m + 2 * ~p + 1)) + (1 / (~c * (~m + 2 * ~p + 1))) * Antiderivative((~d + ~e * ~x) ^ (~m - 2) * Simp((~c * (~d) ^ 2 * (~m + 2 * ~p + 1) - ~e * (~a * ~e * (~m - 1) + ~b * ~d * (~p + 1))) + ~e * (2 * ~c * ~d - ~b * ~e) * (~m + ~p) * ~x, ~x) * (~a + ~b * ~x + ~c * (~x) ^ 2) ^ ~p, ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~m, ~p], ~x) && (NeQ((~b) ^ 2 - 4 * ~a * ~c, 0) && (NeQ((~c * (~d) ^ 2 - ~b * ~d * ~e) + ~a * (~e) ^ 2, 0) && (NeQ(2 * ~c * ~d - ~b * ~e, 0) && (If(RationalQ(~m), GtQ(~m, 1), SumSimplerQ(~m, -2)) && (NeQ(~m + 2 * ~p + 1, 0) && IntQuadraticQ(~a, ~b, ~c, ~d, ~e, ~m, ~p, ~x))))))
    @apply_utils Antiderivative((~d + ~(e') * ~x) ^ ~m * (~a + ~(c') * (~x) ^ 2) ^ ~p, ~x) => (~e * (~d + ~e * ~x) ^ (~m - 1) * (~a + ~c * (~x) ^ 2) ^ (~p + 1)) / (~c * (~m + 2 * ~p + 1)) + (1 / (~c * (~m + 2 * ~p + 1))) * Antiderivative((~d + ~e * ~x) ^ (~m - 2) * Simp((~c * (~d) ^ 2 * (~m + 2 * ~p + 1) - ~a * (~e) ^ 2 * (~m - 1)) + 2 * ~c * ~d * ~e * (~m + ~p) * ~x, ~x) * (~a + ~c * (~x) ^ 2) ^ ~p, ~x) <-- FreeQ([~a, ~c, ~d, ~e, ~m, ~p], ~x) && (NeQ(~c * (~d) ^ 2 + ~a * (~e) ^ 2, 0) && (If(RationalQ(~m), GtQ(~m, 1), SumSimplerQ(~m, -2)) && (NeQ(~m + 2 * ~p + 1, 0) && IntQuadraticQ(~a, 0, ~c, ~d, ~e, ~m, ~p, ~x))))
    @apply_utils Antiderivative((~(d') + ~(e') * ~x) ^ ~m * (~(a') + ~(b') * ~x + ~(c') * (~x) ^ 2) ^ ~p, ~x) => (~e * (~d + ~e * ~x) ^ (~m + 1) * (~a + ~b * ~x + ~c * (~x) ^ 2) ^ (~p + 1)) / ((~m + 1) * ((~c * (~d) ^ 2 - ~b * ~d * ~e) + ~a * (~e) ^ 2)) + (1 / ((~m + 1) * ((~c * (~d) ^ 2 - ~b * ~d * ~e) + ~a * (~e) ^ 2))) * Antiderivative((~d + ~e * ~x) ^ (~m + 1) * Simp((~c * ~d * (~m + 1) - ~b * ~e * (~m + ~p + 2)) - ~c * ~e * (~m + 2 * ~p + 3) * ~x, ~x) * (~a + ~b * ~x + ~c * (~x) ^ 2) ^ ~p, ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~m, ~p], ~x) && (NeQ((~b) ^ 2 - 4 * ~a * ~c, 0) && (NeQ((~c * (~d) ^ 2 - ~b * ~d * ~e) + ~a * (~e) ^ 2, 0) && (NeQ(2 * ~c * ~d - ~b * ~e, 0) && (NeQ(~m, -1) && (LtQ(~m, -1) && IntQuadraticQ(~a, ~b, ~c, ~d, ~e, ~m, ~p, ~x) || (SumSimplerQ(~m, 1) && IntegerQ(~p) || ILtQ(Simplify(~m + 2 * ~p + 3), 0)))))))
    @apply_utils Antiderivative((~d + ~(e') * ~x) ^ ~m * (~a + ~(c') * (~x) ^ 2) ^ ~p, ~x) => (~e * (~d + ~e * ~x) ^ (~m + 1) * (~a + ~c * (~x) ^ 2) ^ (~p + 1)) / ((~m + 1) * (~c * (~d) ^ 2 + ~a * (~e) ^ 2)) + (~c / ((~m + 1) * (~c * (~d) ^ 2 + ~a * (~e) ^ 2))) * Antiderivative((~d + ~e * ~x) ^ (~m + 1) * Simp(~d * (~m + 1) - ~e * (~m + 2 * ~p + 3) * ~x, ~x) * (~a + ~c * (~x) ^ 2) ^ ~p, ~x) <-- FreeQ([~a, ~c, ~d, ~e, ~m, ~p], ~x) && (NeQ(~c * (~d) ^ 2 + ~a * (~e) ^ 2, 0) && (NeQ(~m, -1) && (LtQ(~m, -1) && IntQuadraticQ(~a, 0, ~c, ~d, ~e, ~m, ~p, ~x) || (SumSimplerQ(~m, 1) && IntegerQ(~p) || ILtQ(Simplify(~m + 2 * ~p + 3), 0)))))
    @apply_utils Antiderivative(1 / ((~d + ~(e') * ~x) * (~a + ~(c') * (~x) ^ 2) ^ (1 / 4)), ~x) => ~d * Antiderivative(1 / (((~d) ^ 2 - (~e) ^ 2 * (~x) ^ 2) * (~a + ~c * (~x) ^ 2) ^ (1 / 4)), ~x) - ~e * Antiderivative(~x / (((~d) ^ 2 - (~e) ^ 2 * (~x) ^ 2) * (~a + ~c * (~x) ^ 2) ^ (1 / 4)), ~x) <-- FreeQ([~a, ~c, ~d, ~e], ~x) && NeQ(~c * (~d) ^ 2 + ~a * (~e) ^ 2, 0)
    @apply_utils Antiderivative(1 / ((~d + ~(e') * ~x) * (~a + ~(c') * (~x) ^ 2) ^ (3 / 4)), ~x) => ~d * Antiderivative(1 / (((~d) ^ 2 - (~e) ^ 2 * (~x) ^ 2) * (~a + ~c * (~x) ^ 2) ^ (3 / 4)), ~x) - ~e * Antiderivative(~x / (((~d) ^ 2 - (~e) ^ 2 * (~x) ^ 2) * (~a + ~c * (~x) ^ 2) ^ (3 / 4)), ~x) <-- FreeQ([~a, ~c, ~d, ~e], ~x) && NeQ(~c * (~d) ^ 2 + ~a * (~e) ^ 2, 0)
    @apply_utils Antiderivative((~(a') + ~(b') * ~x + ~(c') * (~x) ^ 2) ^ ~p / (~(d') + ~(e') * ~x), ~x) => (1 / ((-4 * ~c) / ((~b) ^ 2 - 4 * ~a * ~c)) ^ ~p) * Subst(Antiderivative(Simp(1 - (~x) ^ 2 / ((~b) ^ 2 - 4 * ~a * ~c), ~x) ^ ~p / Simp((2 * ~c * ~d - ~b * ~e) + ~e * ~x, ~x), ~x), ~x, ~b + 2 * ~c * ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~p], ~x) && (GtQ(4 * ~a - (~b) ^ 2 / ~c, 0) && IntegerQ(4 * ~p))
    @apply_utils Antiderivative((~(a') + ~(b') * ~x + ~(c') * (~x) ^ 2) ^ ~p / (~(d') + ~(e') * ~x), ~x) => ((~a + ~b * ~x + ~c * (~x) ^ 2) ^ ~p / ((-(~c) * (~a + ~b * ~x + ~c * (~x) ^ 2)) / ((~b) ^ 2 - 4 * ~a * ~c)) ^ ~p) * Antiderivative((((-(~a) * ~c) / ((~b) ^ 2 - 4 * ~a * ~c) - (~b * ~c * ~x) / ((~b) ^ 2 - 4 * ~a * ~c)) - ((~c) ^ 2 * (~x) ^ 2) / ((~b) ^ 2 - 4 * ~a * ~c)) ^ ~p / (~d + ~e * ~x), ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~p], ~x) && (Not(GtQ(4 * ~a - (~b) ^ 2 / ~c, 0)) && IntegerQ(4 * ~p))
    @apply_utils Antiderivative(1 / ((~(d') + ~(e') * ~x) * (~a + ~(b') * ~x + ~(c') * (~x) ^ 2) ^ (1 / 3)), ~x) => With([q = Rt(3 * ~c * (~e) ^ 2 * (2 * ~c * ~d - ~b * ~e), 3)], ((-(sqrt(3)) * ~c * ~e * atan(1 / sqrt(3) + (2 * ((~c * ~d - ~b * ~e) - ~c * ~e * ~x)) / (sqrt(3) * q * (~a + ~b * ~x + ~c * (~x) ^ 2) ^ (1 / 3)))) / q ^ 2 - (3 * ~c * ~e * log(~d + ~e * ~x)) / (2 * q ^ 2)) + (3 * ~c * ~e * log(((~c * ~d - ~b * ~e) - ~c * ~e * ~x) - q * (~a + ~b * ~x + ~c * (~x) ^ 2) ^ (1 / 3))) / (2 * q ^ 2)) <-- FreeQ([~a, ~b, ~c, ~d, ~e], ~x) && (NeQ(2 * ~c * ~d - ~b * ~e, 0) && (EqQ((((~c) ^ 2 * (~d) ^ 2 - ~b * ~c * ~d * ~e) + (~b) ^ 2 * (~e) ^ 2) - 3 * ~a * ~c * (~e) ^ 2, 0) && PosQ(~c * (~e) ^ 2 * (2 * ~c * ~d - ~b * ~e))))
    @apply_utils Antiderivative(1 / ((~d + ~(e') * ~x) * (~a + ~(c') * (~x) ^ 2) ^ (1 / 3)), ~x) => With([q = Rt((6 * (~c) ^ 2 * (~e) ^ 2) / (~d) ^ 2, 3)], ((-(sqrt(3)) * ~c * ~e * atan(1 / sqrt(3) + (2 * ~c * (~d - ~e * ~x)) / (sqrt(3) * ~d * q * (~a + ~c * (~x) ^ 2) ^ (1 / 3)))) / ((~d) ^ 2 * q ^ 2) - (3 * ~c * ~e * log(~d + ~e * ~x)) / (2 * (~d) ^ 2 * q ^ 2)) + (3 * ~c * ~e * log((~c * ~d - ~c * ~e * ~x) - ~d * q * (~a + ~c * (~x) ^ 2) ^ (1 / 3))) / (2 * (~d) ^ 2 * q ^ 2)) <-- FreeQ([~a, ~c, ~d, ~e], ~x) && EqQ(~c * (~d) ^ 2 - 3 * ~a * (~e) ^ 2, 0)
    @apply_utils Antiderivative(1 / ((~(d') + ~(e') * ~x) * (~a + ~(b') * ~x + ~(c') * (~x) ^ 2) ^ (1 / 3)), ~x) => With([q = Rt(-3 * ~c * (~e) ^ 2 * (2 * ~c * ~d - ~b * ~e), 3)], ((-(sqrt(3)) * ~c * ~e * atan(1 / sqrt(3) - (2 * ((~c * ~d - ~b * ~e) - ~c * ~e * ~x)) / (sqrt(3) * q * (~a + ~b * ~x + ~c * (~x) ^ 2) ^ (1 / 3)))) / q ^ 2 - (3 * ~c * ~e * log(~d + ~e * ~x)) / (2 * q ^ 2)) + (3 * ~c * ~e * log(((~c * ~d - ~b * ~e) - ~c * ~e * ~x) + q * (~a + ~b * ~x + ~c * (~x) ^ 2) ^ (1 / 3))) / (2 * q ^ 2)) <-- FreeQ([~a, ~b, ~c, ~d, ~e], ~x) && (NeQ(2 * ~c * ~d - ~b * ~e, 0) && (EqQ((((~c) ^ 2 * (~d) ^ 2 - ~b * ~c * ~d * ~e) + (~b) ^ 2 * (~e) ^ 2) - 3 * ~a * ~c * (~e) ^ 2, 0) && NegQ(~c * (~e) ^ 2 * (2 * ~c * ~d - ~b * ~e))))
    #= Antiderivative(1/(((~d)+(~e')*(~x))*((~a)+(~c')*(~x)^2)^(1/3)),~x) :=  With([q=Rt(-6*c^2*d*e^2,3)], -sqrt(3)*c*e*atan(1/sqrt(3)-2*(c*d-c*e*x)/(sqrt(3)*q*(a+c*x^2)^(1/ 3)))/q^2 - 3*c*e*log(d+e*x)/(2*q^2) + 3*c*e*log(c*d-c*e*x+q*(a+c*x^2)^(1/3))/(2*q^2)) <--  FreeQ([a,c,d,e],x) && EqQ(c*d^2-3*a*e^2,0) && NegQ(c^2*d*e^2) =#
    @apply_utils Antiderivative(1 / ((~d + ~(e') * ~x) * (~a + ~(c') * (~x) ^ 2) ^ (1 / 3)), ~x) => (~a) ^ (1 / 3) * Antiderivative(1 / ((~d + ~e * ~x) * (1 - (3 * ~e * ~x) / ~d) ^ (1 / 3) * (1 + (3 * ~e * ~x) / ~d) ^ (1 / 3)), ~x) <-- FreeQ([~a, ~c, ~d, ~e], ~x) && (EqQ(~c * (~d) ^ 2 + 9 * ~a * (~e) ^ 2, 0) && GtQ(~a, 0))
    @apply_utils Antiderivative(1 / ((~d + ~(e') * ~x) * (~a + ~(c') * (~x) ^ 2) ^ (1 / 3)), ~x) => ((1 + (~c * (~x) ^ 2) / ~a) ^ (1 / 3) / (~a + ~c * (~x) ^ 2) ^ (1 / 3)) * Antiderivative(1 / ((~d + ~e * ~x) * (1 + (~c * (~x) ^ 2) / ~a) ^ (1 / 3)), ~x) <-- FreeQ([~a, ~c, ~d, ~e], ~x) && (EqQ(~c * (~d) ^ 2 + 9 * ~a * (~e) ^ 2, 0) && Not(GtQ(~a, 0)))
    @apply_utils Antiderivative(1 / ((~(d') + ~(e') * ~x) * (~a + ~(b') * ~x + ~(c') * (~x) ^ 2) ^ (1 / 3)), ~x) => With([q = Rt((~b) ^ 2 - 4 * ~a * ~c, 2)], (((~b + q + 2 * ~c * ~x) ^ (1 / 3) * ((~b - q) + 2 * ~c * ~x) ^ (1 / 3)) / (~a + ~b * ~x + ~c * (~x) ^ 2) ^ (1 / 3)) * Antiderivative(1 / ((~d + ~e * ~x) * (~b + q + 2 * ~c * ~x) ^ (1 / 3) * ((~b - q) + 2 * ~c * ~x) ^ (1 / 3)), ~x)) <-- FreeQ([~a, ~b, ~c, ~d, ~e], ~x) && (NeQ((~b) ^ 2 - 4 * ~a * ~c, 0) && EqQ((((~c) ^ 2 * (~d) ^ 2 - ~b * ~c * ~d * ~e) - 2 * (~b) ^ 2 * (~e) ^ 2) + 9 * ~a * ~c * (~e) ^ 2, 0))
    @apply_utils Antiderivative((~d + ~(e') * ~x) ^ ~m * (~a + ~(c') * (~x) ^ 2) ^ ~p, ~x) => Antiderivative((~d + ~e * ~x) ^ ~m * (Rt(~a, 2) + Rt(-(~c), 2) * ~x) ^ ~p * (Rt(~a, 2) - Rt(-(~c), 2) * ~x) ^ ~p, ~x) <-- FreeQ([~a, ~c, ~d, ~e, ~m, ~p], ~x) && (NeQ(~c * (~d) ^ 2 + ~a * (~e) ^ 2, 0) && (Not(IntegerQ(~p)) && (GtQ(~a, 0) && LtQ(~c, 0))))
    @apply_utils Antiderivative((~d + ~(e') * ~x) ^ ~m * (~a + ~(c') * (~x) ^ 2) ^ ~p, ~x) => Antiderivative(ExpandIntegrand((~a + ~c * (~x) ^ 2) ^ ~p, (~d / ((~d) ^ 2 - (~e) ^ 2 * (~x) ^ 2) - (~e * ~x) / ((~d) ^ 2 - (~e) ^ 2 * (~x) ^ 2)) ^ -(~m), ~x), ~x) <-- FreeQ([~a, ~c, ~d, ~e, ~p], ~x) && (NeQ(~c * (~d) ^ 2 + ~a * (~e) ^ 2, 0) && (Not(IntegerQ(~p)) && ILtQ(~m, 0)))
    @apply_utils Antiderivative((~(d') + ~(e') * ~x) ^ ~m * (~(a') + ~(b') * ~x + ~(c') * (~x) ^ 2) ^ ~p, ~x) => With([q = Rt((~b) ^ 2 - 4 * ~a * ~c, 2)], ((-((1 / (~d + ~e * ~x)) ^ (2 * ~p)) * (~a + ~b * ~x + ~c * (~x) ^ 2) ^ ~p) / (~e * ((~e * ((~b - q) + 2 * ~c * ~x)) / (2 * ~c * (~d + ~e * ~x))) ^ ~p * ((~e * (~b + q + 2 * ~c * ~x)) / (2 * ~c * (~d + ~e * ~x))) ^ ~p)) * Subst(Antiderivative((~x) ^ (-(~m) - 2 * (~p + 1)) * Simp(1 - (~d - (~e * (~b - q)) / (2 * ~c)) * ~x, ~x) ^ ~p * Simp(1 - (~d - (~e * (~b + q)) / (2 * ~c)) * ~x, ~x) ^ ~p, ~x), ~x, 1 / (~d + ~e * ~x))) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~p], ~x) && (NeQ((~b) ^ 2 - 4 * ~a * ~c, 0) && (NeQ((~c * (~d) ^ 2 - ~b * ~d * ~e) + ~a * (~e) ^ 2, 0) && (NeQ(2 * ~c * ~d - ~b * ~e, 0) && (Not(IntegerQ(~p)) && ILtQ(~m, 0)))))
    @apply_utils Antiderivative((~(d') + ~(e') * ~x) ^ ~m * (~(a') + ~(b') * ~x + ~(c') * (~x) ^ 2) ^ ~p, ~x) => With([q = Rt((~b) ^ 2 - 4 * ~a * ~c, 2)], ((~a + ~b * ~x + ~c * (~x) ^ 2) ^ ~p / (~e * (1 - (~d + ~e * ~x) / (~d - (~e * (~b - q)) / (2 * ~c))) ^ ~p * (1 - (~d + ~e * ~x) / (~d - (~e * (~b + q)) / (2 * ~c))) ^ ~p)) * Subst(Antiderivative((~x) ^ ~m * Simp(1 - ~x / (~d - (~e * (~b - q)) / (2 * ~c)), ~x) ^ ~p * Simp(1 - ~x / (~d - (~e * (~b + q)) / (2 * ~c)), ~x) ^ ~p, ~x), ~x, ~d + ~e * ~x)) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~m, ~p], ~x) && (NeQ((~b) ^ 2 - 4 * ~a * ~c, 0) && (NeQ((~c * (~d) ^ 2 - ~b * ~d * ~e) + ~a * (~e) ^ 2, 0) && (NeQ(2 * ~c * ~d - ~b * ~e, 0) && Not(IntegerQ(~p)))))
    @apply_utils Antiderivative((~d + ~(e') * ~x) ^ ~m * (~a + ~(c') * (~x) ^ 2) ^ ~p, ~x) => With([q = Rt(-(~a) * ~c, 2)], ((~a + ~c * (~x) ^ 2) ^ ~p / (~e * (1 - (~d + ~e * ~x) / (~d + (~e * q) / ~c)) ^ ~p * (1 - (~d + ~e * ~x) / (~d - (~e * q) / ~c)) ^ ~p)) * Subst(Antiderivative((~x) ^ ~m * Simp(1 - ~x / (~d + (~e * q) / ~c), ~x) ^ ~p * Simp(1 - ~x / (~d - (~e * q) / ~c), ~x) ^ ~p, ~x), ~x, ~d + ~e * ~x)) <-- FreeQ([~a, ~c, ~d, ~e, ~m, ~p], ~x) && (NeQ(~c * (~d) ^ 2 + ~a * (~e) ^ 2, 0) && Not(IntegerQ(~p)))
    @apply_utils Antiderivative((~(d') + ~(e') * ~u) ^ ~(m') * (~a + ~(b') * ~u + ~(c') * (~u) ^ 2) ^ ~(p'), ~x) => (1 / Coefficient(~u, ~x, 1)) * Subst(Antiderivative((~d + ~e * ~x) ^ ~m * (~a + ~b * ~x + ~c * (~x) ^ 2) ^ ~p, ~x), ~x, ~u) <-- FreeQ([~a, ~b, ~c, ~d, ~e, ~m, ~p], ~x) && (LinearQ(~u, ~x) && NeQ(~u, ~x))
    @apply_utils Antiderivative((~(d') + ~(e') * ~u) ^ ~(m') * (~a + ~(c') * (~u) ^ 2) ^ ~(p'), ~x) => (1 / Coefficient(~u, ~x, 1)) * Subst(Antiderivative((~d + ~e * ~x) ^ ~m * (~a + ~c * (~x) ^ 2) ^ ~p, ~x), ~x, ~u) <-- FreeQ([~a, ~c, ~d, ~e, ~m, ~p], ~x) && (LinearQ(~u, ~x) && NeQ(~u, ~x))
    #= IntQuadraticQ(a,b,c,d,e,m,p,x)*returns*True*iff  (d+e*x)^m*(a+b*x+c*x^2)^p*is*integrable*wrt*x*in*terms*of*non-Appell  functions. =#IntQuadraticQ((~a), (~b), (~c), (~d), (~e), (~m), (~p), (~x)) := IntegerQ(p) || IGtQ(m, 0) || IntegersQ(2*m, 2*p) || IntegersQ(m, 4*p) || IntegersQ(m, p + 1/3) && (EqQ(c^2*d^2 - b*c*d*e + b^2*e^2 - 3*a*c*e^2, 0) || EqQ(c^2*d^2 - b*c*d*e - 2*b^2*e^2 + 9*a*c*e^2, 0))
end

max_stars_repo_path: src/rules/1 Algebraic functions/1.2 Trinomial products/1.2.1 Quadratic/1.2.1.2 (d+e x)^m (a+b x+c x^2)^p.jl


text:
struct ZeroTo{T<:Signed} <: AbstractUnitRange{T}
    stop::T
    function ZeroTo{T}(stop) where T
        Base.depwarn("ZeroTo is deprecated, use ZeroRange instead", :ZeroTo)
        new{T}(max(T(-1), stop))
    end
end
ZeroTo(stop::T) where {T<:Signed} = ZeroTo{T}(stop)

Base.length(r::ZeroTo) = r.stop+1

Base.length(r::ZeroTo{T}) where {T<:Union{Int,Int64}} = T(r.stop+1)

let smallint = (Int === Int64 ?
                Union{Int8,UInt8,Int16,UInt16,Int32,UInt32} :
                Union{Int8,UInt8,Int16,UInt16})
    Base.length(r::ZeroTo{T}) where {T <: smallint} = Int(r.stop)+1
end

Base.first(r::ZeroTo{T}) where {T} = zero(T)

function Base.iterate(r::ZeroTo{T}) where {T}
    x = zero(T)
    return (r.stop <= x ? nothing : (x,x))
end
function Base.iterate(r::ZeroTo{T}, i) where T
    x = i + one(T)
    return (x > oftype(x, r.stop) ? nothing : (x,x))
end

@inline function Base.getindex(v::ZeroTo{T}, i::Integer) where T
    @boundscheck ((i > 0) & (i <= length(v))) || Base.throw_boundserror(v, i)
    convert(T, i-1)
end

@inline function Base.getindex(r::ZeroTo{T}, s::ZeroTo) where T
    @boundscheck checkbounds(r, s)
    ZeroTo(T(s.stop))
end

@inline function Base.getindex(r::ZeroTo{T}, s::AbstractUnitRange) where T
    @boundscheck checkbounds(r, s)
    T(first(s)-1):T(last(s)-1)
end

Base.intersect(r::ZeroTo, s::ZeroTo) = ZeroTo(min(r.stop,s.stop))

Base.promote_rule(::Type{ZeroTo{T1}},::Type{ZeroTo{T2}}) where {T1,T2} =
    ZeroTo{promote_type(T1,T2)}
Base.convert(::Type{ZeroTo{T}}, r::ZeroTo{T}) where {T<:Real} = r
Base.convert(::Type{ZeroTo{T}}, r::ZeroTo) where {T<:Real} = ZeroTo{T}(r.stop)
ZeroTo{T}(r::ZeroTo) where {T} = convert(Type{ZeroTo{T}}, r)

Base.show(io::IO, r::ZeroTo) = print(io, typeof(r).name, "(", r.stop, ")")

ext: jl


text:
# """
# rmp-treeで所望の加速度を計算
# """
# module RMPTree

# export update_nodes
# export calc_desired_ddq

#push!(LOAD_PATH, ".")

using LinearAlgebra

include("utils.jl")

include("rmp.jl")
include("kinematics.jl")

using .Kinematics: calc_all, q_max, q_min, q_neutral, cpoints_local
# using .RMP
#using .Utilis

# """所望の加速度を計算（resolve演算結果を返す）

# # args
# - nodes :
# - rmp_param :
# - goal :
# - obs :
# """
# function calc_desired_ddq(
#     nodes::Vector{Vector{Node{T}}},
#     rmp_param::NamedTuple,
#     goal::State{T},
#     obs::Vector{State{T}}
#     ) where T

#     root_f = zeros(T, 7)
#     root_M = zeros(T, 7, 7)

#     for i in 1:9
#         if i == 1  # ジョイント制限rmp
#             _f, _M = get_natural(
#                 rmp_param.joint_limit_avoidance, nodes[i][1].x, nodes[i][1].dx,
#                 q_max, q_min, q_neutral
#             )
#             #_f = zeros(T, 7)
#             #_M = zeros(T, 7, 7)
#             @. root_f += _f
#             @. root_M += _M

#         else
#             if i == 9  # 目標王達rmpを追加
#             _f, _M = get_natural(
#                 rmp_param.attractor, nodes[i][1].x, nodes[i][1].dx, goal.x
#             )
#             _pulled_f, _pulled_M = pullbacked_rmp(_f, _M, nodes[i][1].Jo,)
#             @. root_f += _pulled_f
#             @. root_M += _pulled_M
#             end

#             # 障害物回避rmpを追加
#             for j in 1:length(nodes[i])
#                 for k in 1:length(obs)
#                     _f, _M = get_natural(
#                         rmp_param.obs_avoidance[i-1], nodes[i][j].x, nodes[i][j].dx, obs[k].x
#                     )
#                     _pulled_f, _pulled_M = pullbacked_rmp(_f, _M, nodes[i][j].Jo,)
#                     @. root_f += _pulled_f
#                     @. root_M += _pulled_M
#                 end
#             end
#         end
#     end

#     #root_f += zeros(T, 7)
#     #root_M += zeros(T, 7, 7)

#     #println("root_f = ", root_f)
#     #println("root_M = ", root_M)

#     ddq = pinv(root_M) * root_f
#     #println("ddq = ", ddq)
#     #ddq = np.linalg.pinv(root_M) * root_f

#     #ddq = zeros(T, 7)
#     return ddq
# end

"""nodeを新規作成"""
function update_nodes(nodes::Nothing, q::Vector{T}, dq::Vector{T}) where T
    # 更新
    _, _,
    _, _, _, _,
    _, Jos_cpoint_all,
    cpoints_x_global, cpoints_dx_global,
    joints_x_global, joints_dx_global = calc_all(q, dq)
    nodes = Vector{Vector{Node{T}}}(undef, 9)
    for i in 1:9
        #println("i = ", i)
        if i == 1  # rootノード
            _children_node = Vector{Node{T}}(undef, 1)
            _children_node[1] = Node(
                x = q,
                dx = dq,
                Jo = Matrix{T}(I, 7, 7),
                f = zeros(T, 7),
                M = zeros(T, 7, 7)
                )
            #println("wow")
        else
            n = length(cpoints_local[i-1]) + 1
            _children_node = Vector{Node{T}}(undef, n)
            _children_node[1] = Node(
                x = joints_x_global[i+2],
                dx = joints_dx_global[i+2],
                Jo = nothing,
                f = nothing,
                M = nothing
            )  # ジョイント点

            for j in 2:n  # 制御点
                _children_node[j] = Node(
                    x = cpoints_x_global[i-1][j-1],
                    dx = cpoints_dx_global[i-1][j-1],
                    Jo = Jos_cpoint_all[i-1][j-1],
                    f = zeros(T, 3),
                    M = zeros(T, 3, 3),
                )
            end
        end
        nodes[i] = _children_node
    end
    return nodes
end

"""nodeを更新"""
function update_nodes!(;
    nodes::Vector{Vector{Node{T}}}, q::Vector{T}, dq::Vector{T},
    rmp_param::NamedTuple, goal::State{T}, obs::Vector{State{T}}
    ) where T
    # 更新
    _, _,
    _, _, _, _,
    _, Jos_cpoint_all,
    cpoints_x_global, cpoints_dx_global,
    joints_x_global, joints_dx_global = calc_all(q, dq)

    #hoge = nodes[1][1].x
    #nodes = copy(nodes)
    #println(old[1][1].x)

    for i in 1:9
        for j in 1:length(nodes[i])
            if i == 1  # root
                nodes[i][j].x = q
                nodes[i][j].dx = dq
                nodes[i][j].Jo = Matrix{T}(I, 7, 7)
                nodes[i][j].f, nodes[i][j].M = get_natural(
                    rmp_param.joint_limit_avoidance, nodes[i][1].x, nodes[i][1].dx,
                    q_max, q_min, q_neutral
                )

                # # ジョイント制限を考慮しない
                # nodes[i][j].f = zeros(T, 7)
                # nodes[i][j].M = zeros(T, 7, 7)

            else  # root以外
                if j == 1   # ジョイント位置
                    nodes[i][j].x = joints_x_global[i+2]
                    nodes[i][j].dx = joints_dx_global[i+2]
                    nodes[i][j].Jo = nothing
                    nodes[i][j].f = nothing
                    nodes[i][j].M = nothing
                else
                    nodes[i][j].x = cpoints_x_global[i-1][j-1]
                    nodes[i][j].dx = cpoints_dx_global[i-1][j-1]
                    nodes[i][j].Jo = Jos_cpoint_all[i-1][j-1]

                    f = zeros(T, 3)
                    M = zeros(T, 3, 3)
                    for k in 1:length(obs)
                        _f, _M = get_natural(
                            rmp_param.obs_avoidance[i-1], nodes[i][j].x, nodes[i][j].dx, obs[k].x
                        )
                        @. f += _f
                        @. M += _M
                    end
                    nodes[i][j].f = f
                    nodes[i][j].M = M

                    if i==9  # エンドエフェクタのときはさらに目標rmpを追加
                        _f, _M = get_natural(
                            rmp_param.attractor, nodes[i][j].x, nodes[i][j].dx, goal.x
                        )
                        @. nodes[i][j].f += _f
                        @. nodes[i][j].M += _M
                    end
                end
            end
        end
    end
    # println(nodes[1][1].x)
    # println(nodes[1][1].x == old[1][1].x)
    return nodes
end

"""nodesからf, Mを集めて所望の加速度を生成

新手法
"""
function calc_desired_ddq(nodes::Vector{Vector{Node{T}}}) where T
    root_f = zeros(T, 7)
    root_M = zeros(T, 7, 7)

    for i in 1:9
        for j in 1:length(nodes[i])  # 目標rmpと障害物rmpの合算
            if i == 1 && !isnothing(nodes[i][j].f)
                _pulled_f, _pulled_M = pullbacked_rmp(
                    nodes[i][j].f, nodes[i][j].M, nodes[i][j].Jo,
                )
                @. root_f += _pulled_f
                @. root_M += _pulled_M
            elseif i > 1 && !isnothing(nodes[i][j].f)
                _pulled_f, _pulled_M = pullbacked_rmp(
                    nodes[i][j].f, nodes[i][j].M, nodes[i][j].Jo,
                )
                @. root_f += _pulled_f
                @. root_M += _pulled_M
            end
        end
    end

    #root_f += zeros(T, 7)
    #root_M += zeros(T, 7, 7)

    #println("root_f = ", root_f)
    #println("root_M = ", root_M)
    ddq = pinv(root_M) * root_f
    #println("ddq = ", ddq)
    #ddq = np.linalg.pinv(root_M) * root_f

    #ddq = zeros(T, 7)
    return ddq
end

"""nodesからジョイント原点位置を取得（アニメ用）"""
function get_joint_positions_from_nodes(nodes::Vector{Vector{Node{T}}}) where T

    xs = Vector{Vector{T}}(undef, 8)

    for i in 2:9
        xs[i-1] = nodes[i][1].x
    end
        return xs
end

"""nodesから制御点位置を取得（アニメ用）"""
function get_cpoints_from_nodes(nodes::Vector{Vector{Node{T}}}) where T

    xs = Vector{Vector{Vector{T}}}(undef, 8)
    for i in 2:9
        _xs = Vector{Vector{T}}(undef, length(nodes[i])-1)
        for j in 2:length(nodes[i])
            _xs[j-1] = nodes[i][j].x
        end
        xs[i-1] = _xs
    end

    return xs

end

"""nodesからrmpを取得（グラフアニメ用）"""
function get_rmps_from_nodes(nodes::Vector{Vector{Node{T}}}) where T
    fs = Vector{Vector{Vector{T}}}(undef, 9)
    Ms = Vector{Vector{Matrix{T}}}(undef, 9)

    # fs[1][1] = nodes[1][1].f
    # Ms[1][1] = nodes[1][1].M

    for i in 1:9
        if i == 1
            _fs = Vector{Vector{T}}(undef, length(nodes[i]))
            _Ms = Vector{Matrix{T}}(undef, length(nodes[i]))
            _fs[i] = nodes[1][1].f
            _Ms[i] = nodes[1][1].M

        else

            _fs = Vector{Vector{T}}(undef, length(nodes[i]) - 1)
            _Ms = Vector{Matrix{T}}(undef, length(nodes[i]) - 1)
            for j in 2:length(nodes[i])
                _fs[j-1] = nodes[i][j].f
                _Ms[j-1] = nodes[i][j].M
            end
        end
        fs[i] = _fs
        Ms[i] = _Ms
    end

    return fs, Ms
end

"""fsからfのノルムだけ取得"""
function get_f_norms_from_fs(fs::Vector{Vector{Vector{T}}}) where T
    f_norms = Vector{Vector{T}}(undef, 9)

    for (i, _fs) in enumerate(fs)
        _f_norms = Vector{T}(undef, length(_fs))
        for (j, f) in enumerate(_fs)
            _f_norms[j] = norm(f)
        end
        f_norms[i] = _f_norms
    end
    return f_norms
end

"""fノルムsを時刻でまとめる"""
function get_f_norms_from_nodes_list(
    t_max::Int64,
    nodes_list::Vector{Vector{Vector{Node{T}}}}
    ) where T

    f_norms_list = Vector{Vector{Vector{T}}}(undef, 9)

    for (t, nodes) in enumerate(nodes_list)
        fs, _ = get_rmps_from_nodes(nodes)
        f_norms = get_f_norms_from_fs(fs)

        if t == 1  # 1回目は配列を宣言する

            for (i, f) in enumerate(f_norms)
                _f_norms_list = Vector{Vector{T}}(undef, length(f))
                for (j, _f) in enumerate(f)
                    _f_norms_list[j] = Vector{T}(undef, t_max)
                    _f_norms_list[j][1] = _f
                end
                f_norms_list[i] = _f_norms_list
            end
        else
            for (i, f) in enumerate(f_norms)
                for (j, _f) in enumerate(f)
                    f_norms_list[i][j][t] = _f
                end
            end
        end
    end
    return f_norms_list
end

#end


text:
line(x0, x1, x) = x0 + (x1-x0)*x

function array2dist(xs :: AbstractArray{<:AbstractFloat})
    len = length(xs)
    @assert mod(len, 3) |> iszero

    nmodes = len÷3
    μs = xs[begin:nmodes]
    σs = xs[nmodes+1:2nmodes]
    ws = xs[2nmodes+1:end]
    ws = ws ./ sum(ws)

    return truncated(MixtureModel(Normal, zip(μs, σs) |> collect, ws), 0, Inf)
end

function target_function(image  :: AbstractArray{Bool},
                         ncloud :: Integer,
                         cutoff :: Integer)
    cf = corrfn(image, cutoff)
    p  = porosity(image)
    s  = size(image)

    return xs -> -likelihood(cf, s, p, array2dist(xs); ncloud = ncloud)
end

"""
~~~~
sandcorn_parameters(image; nmodes     = 1,
                           ncloud     = 100,
                           cutoff     = 100,
                           iterations = 15,
                           μ_bounds   = (0.0,  40.0),
                           σ_bounds   = (1e-3, 10.0),
                           w_bounds   = (0.05, 1.0))
~~~~

Find a distribution of radii in an image which consists of partially
overlapping grains (like an slice of a sandstone). `nmodes` is an
assumed number of modes in the distribution. The resulting
distribution can be constructed as
`Truncated(MixtureModel(Normal, sandcorn_parameters(…)), 0, Inf)`.
"""
function sandcorn_parameters(image      :: AbstractArray{Bool};
                             nmodes     :: Integer = 1,
                             ncloud     :: Integer = 100,
                             cutoff     :: Integer = 100,
                             iterations :: Integer = 15,
                             μ_bounds = (0.0,  40.0),
                             σ_bounds = (1e-3, 10.0),
                             w_bounds = (0.05, 1.0))
    μ_lo, μ_hi = μ_bounds
    σ_lo, σ_hi = σ_bounds
    w_lo, w_hi = w_bounds

    μ_lower = fill(μ_lo, nmodes)
    σ_lower = fill(σ_lo, nmodes)
    w_lower = fill(w_lo, nmodes)
    μ_upper = fill(μ_hi, nmodes)
    σ_upper = fill(σ_hi, nmodes)
    w_upper = fill(w_hi, nmodes)

    lower = vcat(μ_lower, σ_lower, w_lower)
    upper = vcat(μ_upper, σ_upper, w_upper)
    start = line.(lower, upper, rand(Float64, 3nmodes))

    opt = optimize(target_function(image, ncloud, cutoff), start,
                   ParticleSwarm(lower = lower, upper = upper),
                   Optim.Options(show_trace = true,
                                 show_every = 1,
                                 iterations = iterations))
    return opt |> Optim.minimizer |> array2dist
end


text:
using OpticSim
@info "Running representative workload"
# add stuff here #
Examples.autodrawrays()
Examples.hexapolarspotdiagramexample()
@info "Finished running representative workload"


text:
facts("Adding debianfiles") do
  context("Debian file in debdir") do
    path = mktempdir()
    lines = "hello", "world"
    try
      cd(path) do
        debian_file("myfile", lines...)
        @fact joinpath("Debian", "myfile") => isfile

        actual = joinpath("Debian", "myfile") |> readall |> x -> split(x, "\n")
        @fact actual => [lines..., ""]
      end
    finally
      rm(path; recursive=true)
    end
  end

  context("list of binaries from kwargs...") do
    @fact DebbyPacker.get_binaries("this") => [{:package => "this"}]

    actual = DebbyPacker.get_binaries("this", description="hello")
    @fact actual  => [{:package => "this", :description => "hello"}]

    # still one package, butw with different name
    actual = DebbyPacker.get_binaries("this", package="this-dev", description="hello")
    @fact actual  => [{:package => "this-dev", :description => "hello"}]

    # now two packages
    actual = DebbyPacker.get_binaries("this",
      description="hello", architecture="all",
      package="this-dev", description="world")
    expected = [
      {:package => "this", :description => "hello", :architecture => "all"},
      {:package => "this-dev", :description => "world"}
    ]
    @fact actual  => expected
  end

  context("control") do
    url = "file:///" * Pkg.dir("DebbyPacker")
    pack = DebbyPacker.Package(
      "DebbyPacker", DebbyPacker.GitSource(url, "5c894bf"),
      package="DebbyPacker-dev", description="this", architecture="all"
    )
    path = mktempdir()
    try
      cd(path) do
        control(pack)
        @fact joinpath("debian", "control") => isfile
        text = readall(joinpath("debian", "control"))
        @fact text => ismatch(r"Source: DebbyPacker")
        @fact text => ismatch(r"Priority: optional")
        @fact text => ismatch(r"Description: this")
        @fact text => ismatch(r"\n\nPackage: DebbyPacker-dev")
      end
    finally
      rm(path, recursive=true)
    end
  end
end

max_stars_repo_name: UCL/DebbyPacker

max_issues_repo_name: UCL/DebbyPacker

max_forks_repo_name: UCL/DebbyPacker


text:
# Native implementation of ode45 to check for speed.
include("Joint.jl")

function rk45(tEnd::Float64, tStart::Float64, x0::Vector{Float64}, p::Tuple{Vararg{Joint}}, f::Function; eps::Float64=1e-3)
    # eps: Tolerance, default value: 1e-3
    # To solve xdot = f(t,x)
    # p: Parameters

    tSim = Float64[]; push!(tSim,tStart)
    xSol = Float64[]; xSol = vcat(xSol,x0)
    h = 0.01 # Initial step size. Arbitrary
    len = length(x0) # Length of vector
    x = x0;
    t = tStart
    while t < tEnd
        k1 = h*f(t, x, p)
        k2 = h*f(t + h/4, x + k1/4, p)
        k3 = h*f(t + 3*h/8, x + 3/32*k1 + 9/32*k2, p)
        k4 = h*f(t + 12*h/13, x + 1932/2197*k1 - 7200/2197*k2 + 7296/2197*k3, p)
        k5 = h*f(t + h, x + 439/216*k1 - 8*k2 + 3680/513*k3 - 845/4104*k4, p)
        k6 = h*f(t + h/2, x - 8/27*k1 + 2*k2 - 3544/2565*k3 + 1859/4104*k4 - 11/40*k5, p)

        y1 = x + 25/216*k1 + 1408/2565*k3 + 2197/4104*k4 - k5/5
        y2 = x + 16/135*k1 + 6656/12825*k3 + 28561/56430*k4 - 9/50*k5 + 2/55*k6

        err = y1 - y2
        R = 1/h*broadcast(abs,err)
        δ = 0.84*(eps/norm(R,Inf))^0.25

        if R <= eps*ones(len)
            t = t + h
            x = y1
            xSol = vcat(xSol,x)
            push!(tSim,t)
            h = δ*h
        else
            h = δ*h
        end
    end
    return tSim, xSol
end

max_stars_repo_name: isrlab/Multibody-Dynamics

max_issues_repo_name: isrlab/Multibody-Dynamics

max_forks_repo_name: isrlab/Multibody-Dynamics


text:
function write_digital(name::String, value::Integer, dev::LJDevice=DEFAULT_LJDEVICE)
    LJM.eWriteName(dev.handle, name, UInt16(value)) |> errorcheck
end

function read_digital(name::String, dev::LJDevice=DEFAULT_LJDEVICE)
    value = Ref{Float64}()

    LJM.eReadName(dev.handle, name, value)

    return digits(UInt16(value[]), base = 2, pad = 8)
end

function read_digital(address::Integer, dev::LJDevice=DEFAULT_LJDEVICE)

    value = Ref{Float64}()

    LJM.eReadAddress(dev.handle, Cint(address), Cint(0), value)
    return digits(UInt16(value[]), base=2, pad = 8)
end


text:
#=
Module for code generation
=#
module CodeGenerator

export init_code_generator, finalize_code_generator, set_generation_target,
        generate_all_files, add_generated_file,
        # generate_main, generate_config, generate_prob, generate_mesh, generate_genfunction,
        # generate_bilinear, generate_linear, generate_stepper, generate_output,
        generate_code_layer, generate_assembly_loops
        #, generate_code_layer_surface, generate_code_layer_fv

import ..Femshop: JULIA, CPP, MATLAB, DENDRO, HOMG, CUSTOM_GEN_TARGET,
            SQUARE, IRREGULAR, UNIFORM_GRID, TREE, UNSTRUCTURED,
            CG, DG, HDG, FV,
            NODAL, MODAL, CELL, LEGENDRE, UNIFORM, GAUSS, LOBATTO,
            NONLINEAR_NEWTON, NONLINEAR_SOMETHING,
            EULER_EXPLICIT, EULER_IMPLICIT, CRANK_NICHOLSON, RK4, LSRK4, ABM4,
            DEFAULT_SOLVER, PETSC,
            VTK, RAW_OUTPUT, CUSTOM_OUTPUT,
            DIRICHLET, NEUMANN, ROBIN, NO_BC, FLUX,
            MSH_V2, MSH_V4,
            SCALAR, VECTOR, TENSOR, SYM_TENSOR, VAR_ARRAY,
            LHS, RHS,
            LINEMESH, QUADMESH, HEXMESH
import ..Femshop: Femshop_config, Femshop_prob, GenFunction, Variable, Coefficient
import ..Femshop: log_entry, printerr
import ..Femshop: config, prob, refel, mesh_data, grid_data, genfunctions, variables, coefficients,
        test_functions, linears, bilinears, indexers, time_stepper, language, gen_framework
import ..Femshop: SymExpression, SymEntity
import ..Femshop: CachesimOut, use_cachesim
import ..Femshop: custom_gen_funcs

genDir = "";
genFileName = "";
gen_file_extension = "";
comment_char = "";
block_comment_char = [""; ""];
headerText = "";
genfiles = [];
external_get_language_elements_function = nothing;
external_generate_code_layer_function = nothing;
external_generate_code_files_function = nothing;

# for custom targets
using_custom_target = false;
# Temporary placeholders for external code gen functions that must be provided.
# These are reassigned in set_custom_target()
function default_language_elements_function() return (".jl", "#", ["#=", "=#"]) end;
function default_code_layer_function(var, entities, terms, lorr, vors) return ("","") end;
function default_code_files_function(var, lhs_vol, lhs_surf, rhs_vol, rhs_surf) return 0 end;

# general code generator functions
include("code_generator_utils.jl");
include("generate_code_layer.jl");

# code gen functions for each solver type and target
include("generate_code_layer_cg_julia.jl");
include("generate_code_layer_dg_julia.jl");
include("generate_code_layer_fv_julia.jl");

# # target specific code gen functions
# include("generate_code_layer_dendro.jl");
# include("generate_code_layer_homg.jl");
# include("generate_code_layer_matlab.jl");
include("generate_code_layer_cachesim.jl");

# Surface integrals should be handled in the same place TODO
#include("generate_code_layer_surface.jl");

#Matlab
# include("generate_matlab_utils.jl");
# include("generate_matlab_files.jl");
# include("generate_homg_files.jl");
# #C++
# include("generate_cpp_utils.jl");
# include("generate_dendro_files.jl");

#### Note
# default Dendro parameters
# parameters = (5, 1, 0.3, 0.000001, 100);#(maxdepth, wavelet_tol, partition_tol, solve_tol, solve_max_iters)
####

function init_code_generator(dir, name, header)
    global gen_file_extension = ".jl";
    global comment_char = "#";
    global block_comment_char = ["#="; "=#"];
    global genDir = dir;
    global genFileName = name;
    global headerText = header;

    global external_get_language_elements_function = default_language_elements_function;
    global external_generate_code_layer_function = default_code_layer_function;
    global external_generate_code_files_function = default_code_files_function;
end

# Sets the functions to be used during external code generation
function set_generation_target(lang_elements, code_layer, file_maker)
    global external_get_language_elements_function = lang_elements;
    global external_generate_code_layer_function = code_layer;
    global external_generate_code_files_function = file_maker;
    global using_custom_target = true;
    global gen_file_extension;
    global comment_char;
    global block_comment_char;
    (gen_file_extension, comment_char, block_comment_char) = Base.invokelatest(external_get_language_elements_function);
end

function add_generated_file(filename; dir="", make_header_text=true)
    if length(dir) > 0
        code_dir = genDir*"/"*dir;
        if !isdir(code_dir)
            mkdir(code_dir);
        end
    else
        code_dir = genDir;
    end
    newfile = open(code_dir*"/"*filename, "w");
    push!(genfiles, newfile);
    if make_header_text
        generate_head(newfile, headerText);
    end

    return newfile;
end

function generate_all_files(var, lhs_vol, lhs_surf, rhs_vol, rhs_surf; parameters=0)
    if using_custom_target
        external_generate_code_files_function(var, lhs_vol, lhs_surf, rhs_vol, rhs_surf);
    end
end

function finalize_code_generator()
    for f in genfiles
        close(f);
    end
    log_entry("Closed generated code files.");
end

#### Utilities ####

function comment(file,line)
    println(file, comment_char * line);
end

function commentBlock(file,text)
    print(file, "\n"*block_comment_char[1]*"\n"*text*"\n"*block_comment_char[2]*"\n");
end

function generate_head(file, text)
    comment(file,"This file was generated by Femshop.");
    commentBlock(file, text);
end

# for writing structs to binary files
# format is | number of structs[Int64] | sizes of structs[Int64*num] | structs |
function write_binary_head(f, num, szs)
    Nbytes = 0;
    write(f, num);
    Nbytes += sizeof(num)
    for i=1:length(szs)
        write(f, szs[i])
        Nbytes += sizeof(szs[i])
    end
    return Nbytes;
end

# Write an array to a binary file.
# Return number of bytes written.
function write_binary_array(f, a)
    Nbytes = 0;
    for i=1:length(a)
        if isbits(a[i])
            write(f, a[i]);
            Nbytes += sizeof(a[i]);
        else
            Nbytes += write_binary_array(f,a[i]);
        end
    end
    return Nbytes;
end

# Assumes that the struct only has isbits->true types or arrays.
# Returns number of bytes written.
function write_binary_struct(f, s)
    Nbytes = 0;
    for fn in fieldnames(typeof(s))
        comp = getfield(s, fn);
        if isbits(comp)
            write(f, comp);
            Nbytes += sizeof(comp)
        else
            Nbytes += write_binary_array(f,comp);
        end
    end
    return Nbytes;
end

end # module


text:
import Example

include(joinpath(pkgdir(Example), "test", "runtests.jl"))