text:
int_rules_1_1_3_2 = @theory begin

    #= ::Subsection::Closed:: =#
    #= 1.1.3.2*(c*x)^m*(a+b*x^n)^p =#
    @apply_utils Antiderivative((~(c') * ~x) ^ ~(m') * (~a1 + ~(b1') * (~x) ^ ~n) ^ ~p * (~a2 + ~(b2') * (~x) ^ ~n) ^ ~p, ~x) => Antiderivative((~c * ~x) ^ ~m * (~a1 * ~a2 + ~b1 * ~b2 * (~x) ^ (2 * ~n)) ^ ~p, ~x) <-- FreeQ([~a1, ~b1, ~a2, ~b2, ~c, ~m, ~n, ~p], ~x) && (EqQ(~a2 * ~b1 + ~a1 * ~b2, 0) && (IntegerQ(~p) || GtQ(~a1, 0) && GtQ(~a2, 0)))
    @apply_utils Antiderivative((~x) ^ ~(m') / (~a + ~(b') * (~x) ^ ~n), ~x) => log(RemoveContent(~a + ~b * (~x) ^ ~n, ~x)) / (~b * ~n) <-- FreeQ([~a, ~b, ~m, ~n], ~x) && EqQ(~m, ~n - 1)
    @apply_utils Antiderivative((~x) ^ ~(m') * (~a + ~(b') * (~x) ^ ~n) ^ ~p, ~x) => (~a + ~b * (~x) ^ ~n) ^ (~p + 1) / (~b * ~n * (~p + 1)) <-- FreeQ([~a, ~b, ~m, ~n, ~p], ~x) && (EqQ(~m, ~n - 1) && NeQ(~p, -1))
    @apply_utils Antiderivative((~x) ^ ~(m') * (~a1 + ~(b1') * (~x) ^ ~(n')) ^ ~p * (~a2 + ~(b2') * (~x) ^ ~(n')) ^ ~p, ~x) => ((~a1 + ~b1 * (~x) ^ ~n) ^ (~p + 1) * (~a2 + ~b2 * (~x) ^ ~n) ^ (~p + 1)) / (2 * ~b1 * ~b2 * ~n * (~p + 1)) <-- FreeQ([~a1, ~b1, ~a2, ~b2, ~m, ~n, ~p], ~x) && (EqQ(~a2 * ~b1 + ~a1 * ~b2, 0) && (EqQ(~m, 2 * ~n - 1) && NeQ(~p, -1)))
    @apply_utils Antiderivative((~x) ^ ~(m') * (~a + ~(b') * (~x) ^ ~n) ^ ~p, ~x) => Antiderivative((~x) ^ (~m + ~n * ~p) * (~b + ~a * (~x) ^ -(~n)) ^ ~p, ~x) <-- FreeQ([~a, ~b, ~m, ~n], ~x) && (IntegerQ(~p) && NegQ(~n))
    @apply_utils Antiderivative((~(c') * ~x) ^ ~(m') * (~a + ~(b') * (~x) ^ ~n) ^ ~p, ~x) => ((~c * ~x) ^ (~m + 1) * (~a + ~b * (~x) ^ ~n) ^ (~p + 1)) / (~a * ~c * (~m + 1)) <-- FreeQ([~a, ~b, ~c, ~m, ~n, ~p], ~x) && (EqQ((~m + 1) / ~n + ~p + 1, 0) && NeQ(~m, -1))
    @apply_utils Antiderivative((~(c') * ~x) ^ ~(m') * (~a1 + ~(b1') * (~x) ^ ~n) ^ ~p * (~a2 + ~(b2') * (~x) ^ ~n) ^ ~p, ~x) => ((~c * ~x) ^ (~m + 1) * (~a1 + ~b1 * (~x) ^ ~n) ^ (~p + 1) * (~a2 + ~b2 * (~x) ^ ~n) ^ (~p + 1)) / (~a1 * ~a2 * ~c * (~m + 1)) <-- FreeQ([~a1, ~b1, ~a2, ~b2, ~c, ~m, ~n, ~p], ~x) && (EqQ(~a2 * ~b1 + ~a1 * ~b2, 0) && (EqQ((~m + 1) / (2 * ~n) + ~p + 1, 0) && NeQ(~m, -1)))
    @apply_utils Antiderivative((~x) ^ ~(m') * (~a + ~(b') * (~x) ^ ~n) ^ ~p, ~x) => (1 / ~n) * Subst(Antiderivative((~x) ^ (Simplify((~m + 1) / ~n) - 1) * (~a + ~b * ~x) ^ ~p, ~x), ~x, (~x) ^ ~n) <-- FreeQ([~a, ~b, ~m, ~n, ~p], ~x) && IntegerQ(Simplify((~m + 1) / ~n))
    @apply_utils Antiderivative((~x) ^ ~(m') * (~a1 + ~(b1') * (~x) ^ ~n) ^ ~p * (~a2 + ~(b2') * (~x) ^ ~n) ^ ~p, ~x) => (1 / ~n) * Subst(Antiderivative((~x) ^ (Simplify((~m + 1) / ~n) - 1) * (~a1 + ~b1 * ~x) ^ ~p * (~a2 + ~b2 * ~x) ^ ~p, ~x), ~x, (~x) ^ ~n) <-- FreeQ([~a1, ~b1, ~a2, ~b2, ~m, ~n, ~p], ~x) && (EqQ(~a2 * ~b1 + ~a1 * ~b2, 0) && IntegerQ(Simplify((~m + 1) / (2 * ~n))))
    @apply_utils Antiderivative((~c * ~x) ^ ~m * (~a + ~(b') * (~x) ^ ~n) ^ ~p, ~x) => (((~c) ^ IntPart(~m) * (~c * ~x) ^ FracPart(~m)) / (~x) ^ FracPart(~m)) * Antiderivative((~x) ^ ~m * (~a + ~b * (~x) ^ ~n) ^ ~p, ~x) <-- FreeQ([~a, ~b, ~c, ~m, ~n, ~p], ~x) && IntegerQ(Simplify((~m + 1) / ~n))
    @apply_utils Antiderivative((~c * ~x) ^ ~m * (~a1 + ~(b1') * (~x) ^ ~n) ^ ~p * (~a2 + ~(b2') * (~x) ^ ~n) ^ ~p, ~x) => (((~c) ^ IntPart(~m) * (~c * ~x) ^ FracPart(~m)) / (~x) ^ FracPart(~m)) * Antiderivative((~x) ^ ~m * (~a1 + ~b1 * (~x) ^ ~n) ^ ~p * (~a2 + ~b2 * (~x) ^ ~n) ^ ~p, ~x) <-- FreeQ([~a1, ~b1, ~a2, ~b2, ~c, ~m, ~n, ~p], ~x) && (EqQ(~a2 * ~b1 + ~a1 * ~b2, 0) && IntegerQ(Simplify((~m + 1) / (2 * ~n))))
    @apply_utils Antiderivative((~(c') * ~x) ^ ~(m') * (~a + ~(b') * (~x) ^ ~n) ^ ~(p'), ~x) => Antiderivative(ExpandIntegrand((~c * ~x) ^ ~m * (~a + ~b * (~x) ^ ~n) ^ ~p, ~x), ~x) <-- FreeQ([~a, ~b, ~c, ~m, ~n], ~x) && IGtQ(~p, 0)
    @apply_utils Antiderivative((~x) ^ ~m * (~a + ~(b') * (~x) ^ ~n) ^ ~p, ~x) => ((~x) ^ (~m + 1) * (~a + ~b * (~x) ^ ~n) ^ (~p + 1)) / (~a * (~m + 1)) - ((~b * (~m + ~n * (~p + 1) + 1)) / (~a * (~m + 1))) * Antiderivative((~x) ^ (~m + ~n) * (~a + ~b * (~x) ^ ~n) ^ ~p, ~x) <-- FreeQ([~a, ~b, ~m, ~n, ~p], ~x) && (ILtQ(Simplify((~m + 1) / ~n + ~p + 1), 0) && NeQ(~m, -1))
    @apply_utils Antiderivative((~x) ^ ~m * (~a1 + ~(b1') * (~x) ^ ~n) ^ ~p * (~a2 + ~(b2') * (~x) ^ ~n) ^ ~p, ~x) => ((~x) ^ (~m + 1) * (~a1 + ~b1 * (~x) ^ ~n) ^ (~p + 1) * (~a2 + ~b2 * (~x) ^ ~n) ^ (~p + 1)) / (~a1 * ~a2 * (~m + 1)) - ((~b1 * ~b2 * (~m + 2 * ~n * (~p + 1) + 1)) / (~a1 * ~a2 * (~m + 1))) * Antiderivative((~x) ^ (~m + 2 * ~n) * (~a1 + ~b1 * (~x) ^ ~n) ^ ~p * (~a2 + ~b2 * (~x) ^ ~n) ^ ~p, ~x) <-- FreeQ([~a1, ~b1, ~a2, ~b2, ~m, ~n, ~p], ~x) && (EqQ(~a2 * ~b1 + ~a1 * ~b2, 0) && (ILtQ(Simplify((~m + 1) / (2 * ~n) + ~p + 1), 0) && NeQ(~m, -1)))
    @apply_utils Antiderivative((~(c') * ~x) ^ ~(m') * (~a + ~(b') * (~x) ^ ~n) ^ ~p, ~x) => (-((~c * ~x) ^ (~m + 1)) * (~a + ~b * (~x) ^ ~n) ^ (~p + 1)) / (~a * ~c * ~n * (~p + 1)) + ((~m + ~n * (~p + 1) + 1) / (~a * ~n * (~p + 1))) * Antiderivative((~c * ~x) ^ ~m * (~a + ~b * (~x) ^ ~n) ^ (~p + 1), ~x) <-- FreeQ([~a, ~b, ~c, ~m, ~n, ~p], ~x) && (ILtQ(Simplify((~m + 1) / ~n + ~p + 1), 0) && NeQ(~p, -1))
    @apply_utils Antiderivative((~(c') * ~x) ^ ~(m') * (~a1 + ~(b1') * (~x) ^ ~n) ^ ~p * (~a2 + ~(b2') * (~x) ^ ~n) ^ ~p, ~x) => (-((~c * ~x) ^ (~m + 1)) * (~a1 + ~b1 * (~x) ^ ~n) ^ (~p + 1) * (~a2 + ~b2 * (~x) ^ ~n) ^ (~p + 1)) / (2 * ~a1 * ~a2 * ~c * ~n * (~p + 1)) + ((~m + 2 * ~n * (~p + 1) + 1) / (2 * ~a1 * ~a2 * ~n * (~p + 1))) * Antiderivative((~c * ~x) ^ ~m * (~a1 + ~b1 * (~x) ^ ~n) ^ (~p + 1) * (~a2 + ~b2 * (~x) ^ ~n) ^ (~p + 1), ~x) <-- FreeQ([~a1, ~b1, ~a2, ~b2, ~c, ~m, ~n, ~p], ~x) && (EqQ(~a2 * ~b1 + ~a1 * ~b2, 0) && (ILtQ(Simplify((~m + 1) / (2 * ~n) + ~p + 1), 0) && NeQ(~p, -1)))
    @apply_utils Antiderivative((~x) ^ ~(m') * (~a + ~(b') * (~x) ^ ~n) ^ ~p, ~x) => With([k = GCD(~m + 1, ~n)], (1 / k) * Subst(Antiderivative((~x) ^ ((~m + 1) / k - 1) * (~a + ~b * (~x) ^ (~n / k)) ^ ~p, ~x), ~x, (~x) ^ k) <-- k != 1) <-- FreeQ([~a, ~b, ~p], ~x) && (IGtQ(~n, 0) && IntegerQ(~m))
    @apply_utils Antiderivative((~x) ^ ~(m') * (~a1 + ~(b1') * (~x) ^ ~n) ^ ~p * (~a2 + ~(b2') * (~x) ^ ~n) ^ ~p, ~x) => With([k = GCD(~m + 1, 2 * ~n)], (1 / k) * Subst(Antiderivative((~x) ^ ((~m + 1) / k - 1) * (~a1 + ~b1 * (~x) ^ (~n / k)) ^ ~p * (~a2 + ~b2 * (~x) ^ (~n / k)) ^ ~p, ~x), ~x, (~x) ^ k) <-- k != 1) <-- FreeQ([~a1, ~b1, ~a2, ~b2, ~p], ~x) && (EqQ(~a2 * ~b1 + ~a1 * ~b2, 0) && (IGtQ(2 * ~n, 0) && IntegerQ(~m)))
    @apply_utils Antiderivative((~(c') * ~x) ^ ~(m') * (~a + ~(b') * (~x) ^ ~n) ^ ~p, ~x) => ((~c * ~x) ^ (~m + 1) * (~a + ~b * (~x) ^ ~n) ^ ~p) / (~c * (~m + 1)) - ((~b * ~n * ~p) / ((~c) ^ ~n * (~m + 1))) * Antiderivative((~c * ~x) ^ (~m + ~n) * (~a + ~b * (~x) ^ ~n) ^ (~p - 1), ~x) <-- FreeQ([~a, ~b, ~c], ~x) && (IGtQ(~n, 0) && (GtQ(~p, 0) && (LtQ(~m, -1) && (Not(ILtQ((~m + ~n * ~p + ~n + 1) / ~n, 0)) && IntBinomialQ(~a, ~b, ~c, ~n, ~m, ~p, ~x)))))
    @apply_utils Antiderivative((~(c') * ~x) ^ ~(m') * (~a1 + ~(b1') * (~x) ^ ~n) ^ ~p * (~a2 + ~(b2') * (~x) ^ ~n) ^ ~p, ~x) => ((~c * ~x) ^ (~m + 1) * (~a1 + ~b1 * (~x) ^ ~n) ^ ~p * (~a2 + ~b2 * (~x) ^ ~n) ^ ~p) / (~c * (~m + 1)) - ((2 * ~b1 * ~b2 * ~n * ~p) / ((~c) ^ (2 * ~n) * (~m + 1))) * Antiderivative((~c * ~x) ^ (~m + 2 * ~n) * (~a1 + ~b1 * (~x) ^ ~n) ^ (~p - 1) * (~a2 + ~b2 * (~x) ^ ~n) ^ (~p - 1), ~x) <-- FreeQ([~a1, ~b1, ~a2, ~b2, ~c, ~m], ~x) && (EqQ(~a2 * ~b1 + ~a1 * ~b2, 0) && (IGtQ(2 * ~n, 0) && (GtQ(~p, 0) && (LtQ(~m, -1) && (NeQ(~m + 2 * ~n * ~p + 1, 0) && IntBinomialQ(~a1 * ~a2, ~b1 * ~b2, ~c, 2 * ~n, ~m, ~p, ~x))))))
    @apply_utils Antiderivative((~(c') * ~x) ^ ~(m') * (~a + ~(b') * (~x) ^ ~n) ^ ~p, ~x) => ((~c * ~x) ^ (~m + 1) * (~a + ~b * (~x) ^ ~n) ^ ~p) / (~c * (~m + ~n * ~p + 1)) + ((~a * ~n * ~p) / (~m + ~n * ~p + 1)) * Antiderivative((~c * ~x) ^ ~m * (~a + ~b * (~x) ^ ~n) ^ (~p - 1), ~x) <-- FreeQ([~a, ~b, ~c, ~m], ~x) && (IGtQ(~n, 0) && (GtQ(~p, 0) && (NeQ(~m + ~n * ~p + 1, 0) && IntBinomialQ(~a, ~b, ~c, ~n, ~m, ~p, ~x))))
    @apply_utils Antiderivative((~(c') * ~x) ^ ~(m') * (~a1 + ~(b1') * (~x) ^ ~n) ^ ~p * (~a2 + ~(b2') * (~x) ^ ~n) ^ ~p, ~x) => ((~c * ~x) ^ (~m + 1) * (~a1 + ~b1 * (~x) ^ ~n) ^ ~p * (~a2 + ~b2 * (~x) ^ ~n) ^ ~p) / (~c * (~m + 2 * ~n * ~p + 1)) + ((2 * ~a1 * ~a2 * ~n * ~p) / (~m + 2 * ~n * ~p + 1)) * Antiderivative((~c * ~x) ^ ~m * (~a1 + ~b1 * (~x) ^ ~n) ^ (~p - 1) * (~a2 + ~b2 * (~x) ^ ~n) ^ (~p - 1), ~x) <-- FreeQ([~a1, ~b1, ~a2, ~b2, ~c, ~m], ~x) && (EqQ(~a2 * ~b1 + ~a1 * ~b2, 0) && (IGtQ(2 * ~n, 0) && (GtQ(~p, 0) && (NeQ(~m + 2 * ~n * ~p + 1, 0) && IntBinomialQ(~a1 * ~a2, ~b1 * ~b2, ~c, 2 * ~n, ~m, ~p, ~x)))))
    @apply_utils Antiderivative((~x) ^ 2 / (~a + ~(b') * (~x) ^ 4) ^ (5 / 4), ~x) => ((~x * (1 + ~a / (~b * (~x) ^ 4)) ^ (1 / 4)) / (~b * (~a + ~b * (~x) ^ 4) ^ (1 / 4))) * Antiderivative(1 / ((~x) ^ 3 * (1 + ~a / (~b * (~x) ^ 4)) ^ (5 / 4)), ~x) <-- FreeQ([~a, ~b], ~x) && PosQ(~b / ~a)
    @apply_utils Antiderivative((~x) ^ ~m / (~a + ~(b') * (~x) ^ 4) ^ (5 / 4), ~x) => (~x) ^ (~m - 3) / (~b * (~m - 4) * (~a + ~b * (~x) ^ 4) ^ (1 / 4)) - ((~a * (~m - 3)) / (~b * (~m - 4))) * Antiderivative((~x) ^ (~m - 4) / (~a + ~b * (~x) ^ 4) ^ (5 / 4), ~x) <-- FreeQ([~a, ~b], ~x) && (PosQ(~b / ~a) && IGtQ((~m - 2) / 4, 0))
    @apply_utils Antiderivative((~x) ^ ~m / (~a + ~(b') * (~x) ^ 4) ^ (5 / 4), ~x) => (~x) ^ (~m + 1) / (~a * (~m + 1) * (~a + ~b * (~x) ^ 4) ^ (1 / 4)) - ((~b * ~m) / (~a * (~m + 1))) * Antiderivative((~x) ^ (~m + 4) / (~a + ~b * (~x) ^ 4) ^ (5 / 4), ~x) <-- FreeQ([~a, ~b], ~x) && (PosQ(~b / ~a) && ILtQ((~m - 2) / 4, 0))
    @apply_utils Antiderivative(sqrt(~(c') * ~x) / (~a + ~(b') * (~x) ^ 2) ^ (5 / 4), ~x) => ((sqrt(~c * ~x) * (1 + ~a / (~b * (~x) ^ 2)) ^ (1 / 4)) / (~b * (~a + ~b * (~x) ^ 2) ^ (1 / 4))) * Antiderivative(1 / ((~x) ^ 2 * (1 + ~a / (~b * (~x) ^ 2)) ^ (5 / 4)), ~x) <-- FreeQ([~a, ~b, ~c], ~x) && PosQ(~b / ~a)
    @apply_utils Antiderivative((~(c') * ~x) ^ ~m / (~a + ~(b') * (~x) ^ 2) ^ (5 / 4), ~x) => (2 * ~c * (~c * ~x) ^ (~m - 1)) / (~b * (2 * ~m - 3) * (~a + ~b * (~x) ^ 2) ^ (1 / 4)) - ((2 * ~a * (~c) ^ 2 * (~m - 1)) / (~b * (2 * ~m - 3))) * Antiderivative((~c * ~x) ^ (~m - 2) / (~a + ~b * (~x) ^ 2) ^ (5 / 4), ~x) <-- FreeQ([~a, ~b, ~c], ~x) && (PosQ(~b / ~a) && (IntegerQ(2 * ~m) && GtQ(~m, 3 / 2)))
    @apply_utils Antiderivative((~(c') * ~x) ^ ~m / (~a + ~(b') * (~x) ^ 2) ^ (5 / 4), ~x) => (~c * ~x) ^ (~m + 1) / (~a * ~c * (~m + 1) * (~a + ~b * (~x) ^ 2) ^ (1 / 4)) - ((~b * (2 * ~m + 1)) / (2 * ~a * (~c) ^ 2 * (~m + 1))) * Antiderivative((~c * ~x) ^ (~m + 2) / (~a + ~b * (~x) ^ 2) ^ (5 / 4), ~x) <-- FreeQ([~a, ~b, ~c], ~x) && (PosQ(~b / ~a) && (IntegerQ(2 * ~m) && LtQ(~m, -1)))
    @apply_utils Antiderivative((~x) ^ 2 / (~a + ~(b') * (~x) ^ 4) ^ (5 / 4), ~x) => -1 / (~b * ~x * (~a + ~b * (~x) ^ 4) ^ (1 / 4)) - (1 / ~b) * Antiderivative(1 / ((~x) ^ 2 * (~a + ~b * (~x) ^ 4) ^ (1 / 4)), ~x) <-- FreeQ([~a, ~b], ~x) && NegQ(~b / ~a)
    @apply_utils Antiderivative((~(c') * ~x) ^ ~(m') * (~a + ~(b') * (~x) ^ ~n) ^ ~p, ~x) => ((~c) ^ (~n - 1) * (~c * ~x) ^ ((~m - ~n) + 1) * (~a + ~b * (~x) ^ ~n) ^ (~p + 1)) / (~b * ~n * (~p + 1)) - (((~c) ^ ~n * ((~m - ~n) + 1)) / (~b * ~n * (~p + 1))) * Antiderivative((~c * ~x) ^ (~m - ~n) * (~a + ~b * (~x) ^ ~n) ^ (~p + 1), ~x) <-- FreeQ([~a, ~b, ~c], ~x) && (IGtQ(~n, 0) && (LtQ(~p, -1) && (GtQ(~m + 1, ~n) && (Not(ILtQ((~m + ~n * (~p + 1) + 1) / ~n, 0)) && IntBinomialQ(~a, ~b, ~c, ~n, ~m, ~p, ~x)))))
    #= Antiderivative(((~c')*(~x))^(~m')*(~u)^(~p)*(~v)^(~p),~x) :=  With([a=BinomialParts(u,x)((1)),b=BinomialParts(u,x)((2)),n= BinomialParts(u,x)((3))], c^(n-1)*(c*x)^(m-n+1)*u^(p+1)*v^(p+1)/(b*n*(p+1)) - c^n*(m-n+1)/(b*n*(p+1))*Antiderivative((c*x)^(m-n)*u^(p+1)*v^(p+1),x) <--  IGtQ(n,0) && m+1>n && Not(ILtQ((m+n*(p+1)+1)/n,0)) && IntBinomialQ(a,b,c,n,m,p,x)) <-- FreeQ(c,x) && BinomialQ(u*v,x) &&  LtQ(p,-1) =#
    @apply_utils Antiderivative((~(c') * ~x) ^ ~(m') * (~a1 + ~(b1') * (~x) ^ ~n) ^ ~p * (~a2 + ~(b2') * (~x) ^ ~n) ^ ~p, ~x) => ((~c) ^ (2 * ~n - 1) * (~c * ~x) ^ ((~m - 2 * ~n) + 1) * (~a1 + ~b1 * (~x) ^ ~n) ^ (~p + 1) * (~a2 + ~b2 * (~x) ^ ~n) ^ (~p + 1)) / (2 * ~b1 * ~b2 * ~n * (~p + 1)) - (((~c) ^ (2 * ~n) * ((~m - 2 * ~n) + 1)) / (2 * ~b1 * ~b2 * ~n * (~p + 1))) * Antiderivative((~c * ~x) ^ (~m - 2 * ~n) * (~a1 + ~b1 * (~x) ^ ~n) ^ (~p + 1) * (~a2 + ~b2 * (~x) ^ ~n) ^ (~p + 1), ~x) <-- FreeQ([~a1, ~b1, ~a2, ~b2, ~c], ~x) && (EqQ(~a2 * ~b1 + ~a1 * ~b2, 0) && (IGtQ(2 * ~n, 0) && (LtQ(~p, -1) && (~m + 1 > 2 * ~n && (Not(ILtQ((~m + 2 * ~n * (~p + 1) + 1) / (2 * ~n), 0)) && IntBinomialQ(~a1 * ~a2, ~b1 * ~b2, ~c, 2 * ~n, ~m, ~p, ~x))))))
    @apply_utils Antiderivative((~(c') * ~x) ^ ~(m') * (~a + ~(b') * (~x) ^ ~n) ^ ~p, ~x) => (-((~c * ~x) ^ (~m + 1)) * (~a + ~b * (~x) ^ ~n) ^ (~p + 1)) / (~a * ~c * ~n * (~p + 1)) + ((~m + ~n * (~p + 1) + 1) / (~a * ~n * (~p + 1))) * Antiderivative((~c * ~x) ^ ~m * (~a + ~b * (~x) ^ ~n) ^ (~p + 1), ~x) <-- FreeQ([~a, ~b, ~c, ~m], ~x) && (IGtQ(~n, 0) && (LtQ(~p, -1) && IntBinomialQ(~a, ~b, ~c, ~n, ~m, ~p, ~x)))
    @apply_utils Antiderivative((~(c') * ~x) ^ ~(m') * (~a1 + ~(b1') * (~x) ^ ~n) ^ ~p * (~a2 + ~(b2') * (~x) ^ ~n) ^ ~p, ~x) => (-((~c * ~x) ^ (~m + 1)) * (~a1 + ~b1 * (~x) ^ ~n) ^ (~p + 1) * (~a2 + ~b2 * (~x) ^ ~n) ^ (~p + 1)) / (2 * ~a1 * ~a2 * ~c * ~n * (~p + 1)) + ((~m + 2 * ~n * (~p + 1) + 1) / (2 * ~a1 * ~a2 * ~n * (~p + 1))) * Antiderivative((~c * ~x) ^ ~m * (~a1 + ~b1 * (~x) ^ ~n) ^ (~p + 1) * (~a2 + ~b2 * (~x) ^ ~n) ^ (~p + 1), ~x) <-- FreeQ([~a1, ~b1, ~a2, ~b2, ~c, ~m], ~x) && (EqQ(~a2 * ~b1 + ~a1 * ~b2, 0) && (IGtQ(2 * ~n, 0) && (LtQ(~p, -1) && IntBinomialQ(~a1 * ~a2, ~b1 * ~b2, ~c, 2 * ~n, ~m, ~p, ~x))))
    @apply_utils Antiderivative(~x / (~a + ~(b') * (~x) ^ 3), ~x) => (-1 / (3 * Rt(~a, 3) * Rt(~b, 3))) * Antiderivative(1 / (Rt(~a, 3) + Rt(~b, 3) * ~x), ~x) + (1 / (3 * Rt(~a, 3) * Rt(~b, 3))) * Antiderivative((Rt(~a, 3) + Rt(~b, 3) * ~x) / ((Rt(~a, 3) ^ 2 - Rt(~a, 3) * Rt(~b, 3) * ~x) + Rt(~b, 3) ^ 2 * (~x) ^ 2), ~x) <-- FreeQ([~a, ~b], ~x)
    #= Antiderivative((~x)^(~m')/((~a)+(~b')*(~x)^5),~x) :=  With([r=Numerator(Rt(a/b,5)), s=Denominator(Rt(a/b,5))], (-1)^m*r^(m+1)/(5*a*s^m)*Antiderivative(1/(r+s*x),x) + 2*r^(m+1)/(5*a*s^m)*Antiderivative((r*cos(m*pi/5)-s*cos((m+1)*pi/5)*x)/(r^2-1/ 2*(1+sqrt(5))*r*s*x+s^2*x^2),x) + 2*r^(m+1)/(5*a*s^m)*Antiderivative((r*cos(3*m*pi/5)-s*cos(3*(m+1)*pi/5)*x)/(r^ 2-1/2*(1-sqrt(5))*r*s*x+s^2*x^2),x)) <-- FreeQ([a,b],x) && IGtQ(m,0) &&  LtQ(m,4) && PosQ(a/b) =#
    #= Antiderivative((~x)^(~m')/((~a)+(~b')*(~x)^5),~x) :=  With([r=Numerator(Rt(-a/b,5)), s=Denominator(Rt(-a/b,5))], (r^(m+1)/(5*a*s^m))*Antiderivative(1/(r-s*x),x) + 2*(-1)^m*r^(m+1)/(5*a*s^m)*Antiderivative((r*cos(m*pi/5)+s*cos((m+1)*pi/5)*x)/( r^2+1/2*(1+sqrt(5))*r*s*x+s^2*x^2),x) + 2*(-1)^m*r^(m+1)/(5*a*s^m)*Antiderivative((r*cos(3*m*pi/5)+s*cos(3*(m+1)*pi/5)* x)/(r^2+1/2*(1-sqrt(5))*r*s*x+s^2*x^2),x)) <-- FreeQ([a,b],x) &&  IGtQ(m,0) && LtQ(m,4) && NegQ(a/b) =#
    @apply_utils Antiderivative((~x) ^ ~(m') / (~a + ~(b') * (~x) ^ ~n), ~x) => Module([r = Numerator(Rt(~a / ~b, ~n)), s = Denominator(Rt(~a / ~b, ~n)), k, u], u = Antiderivative((r * cos(((2k - 1) * ~m * pi) / ~n) - s * cos(((2k - 1) * (~m + 1) * pi) / ~n) * ~x) / ((r ^ 2 - 2 * r * s * cos(((2k - 1) * pi) / ~n) * ~x) + s ^ 2 * (~x) ^ 2), ~x); (-((-r) ^ (~m + 1)) / (~a * ~n * s ^ ~m)) * Antiderivative(1 / (r + s * ~x), ~x) + Dist((2 * r ^ (~m + 1)) / (~a * ~n * s ^ ~m), Sum(u, [k, 1, (~n - 1) / 2]), ~x)) <-- FreeQ([~a, ~b], ~x) && (IGtQ((~n - 1) / 2, 0) && (IGtQ(~m, 0) && (LtQ(~m, ~n - 1) && PosQ(~a / ~b))))
    @apply_utils Antiderivative((~x) ^ ~(m') / (~a + ~(b') * (~x) ^ ~n), ~x) => Module([r = Numerator(Rt(-(~a) / ~b, ~n)), s = Denominator(Rt(-(~a) / ~b, ~n)), k, u], u = Antiderivative((r * cos(((2k - 1) * ~m * pi) / ~n) + s * cos(((2k - 1) * (~m + 1) * pi) / ~n) * ~x) / (r ^ 2 + 2 * r * s * cos(((2k - 1) * pi) / ~n) * ~x + s ^ 2 * (~x) ^ 2), ~x); (r ^ (~m + 1) / (~a * ~n * s ^ ~m)) * Antiderivative(1 / (r - s * ~x), ~x) - Dist((2 * (-r) ^ (~m + 1)) / (~a * ~n * s ^ ~m), Sum(u, [k, 1, (~n - 1) / 2]), ~x)) <-- FreeQ([~a, ~b], ~x) && (IGtQ((~n - 1) / 2, 0) && (IGtQ(~m, 0) && (LtQ(~m, ~n - 1) && NegQ(~a / ~b))))
    @apply_utils Antiderivative((~x) ^ ~(m') / (~a + ~(b') * (~x) ^ ~n), ~x) => Module([r = Numerator(Rt(~a / ~b, ~n)), s = Denominator(Rt(~a / ~b, ~n)), k, u], u = Antiderivative((r * cos(((2k - 1) * ~m * pi) / ~n) - s * cos(((2k - 1) * (~m + 1) * pi) / ~n) * ~x) / ((r ^ 2 - 2 * r * s * cos(((2k - 1) * pi) / ~n) * ~x) + s ^ 2 * (~x) ^ 2), ~x) + Antiderivative((r * cos(((2k - 1) * ~m * pi) / ~n) + s * cos(((2k - 1) * (~m + 1) * pi) / ~n) * ~x) / (r ^ 2 + 2 * r * s * cos(((2k - 1) * pi) / ~n) * ~x + s ^ 2 * (~x) ^ 2), ~x); ((2 * (-1) ^ (~m / 2) * r ^ (~m + 2)) / (~a * ~n * s ^ ~m)) * Antiderivative(1 / (r ^ 2 + s ^ 2 * (~x) ^ 2), ~x) + Dist((2 * r ^ (~m + 1)) / (~a * ~n * s ^ ~m), Sum(u, [k, 1, (~n - 2) / 4]), ~x)) <-- FreeQ([~a, ~b], ~x) && (IGtQ((~n - 2) / 4, 0) && (IGtQ(~m, 0) && (LtQ(~m, ~n - 1) && PosQ(~a / ~b))))
    @apply_utils Antiderivative((~x) ^ ~(m') / (~a + ~(b') * (~x) ^ ~n), ~x) => Module([r = Numerator(Rt(-(~a) / ~b, ~n)), s = Denominator(Rt(-(~a) / ~b, ~n)), k, u], u = Antiderivative((r * cos((2 * k * ~m * pi) / ~n) - s * cos((2 * k * (~m + 1) * pi) / ~n) * ~x) / ((r ^ 2 - 2 * r * s * cos((2 * k * pi) / ~n) * ~x) + s ^ 2 * (~x) ^ 2), ~x) + Antiderivative((r * cos((2 * k * ~m * pi) / ~n) + s * cos((2 * k * (~m + 1) * pi) / ~n) * ~x) / (r ^ 2 + 2 * r * s * cos((2 * k * pi) / ~n) * ~x + s ^ 2 * (~x) ^ 2), ~x); ((2 * r ^ (~m + 2)) / (~a * ~n * s ^ ~m)) * Antiderivative(1 / (r ^ 2 - s ^ 2 * (~x) ^ 2), ~x) + Dist((2 * r ^ (~m + 1)) / (~a * ~n * s ^ ~m), Sum(u, [k, 1, (~n - 2) / 4]), ~x)) <-- FreeQ([~a, ~b], ~x) && (IGtQ((~n - 2) / 4, 0) && (IGtQ(~m, 0) && (LtQ(~m, ~n - 1) && NegQ(~a / ~b))))
    @apply_utils Antiderivative((~x) ^ 2 / (~a + ~(b') * (~x) ^ 4), ~x) => With([r = Numerator(Rt(~a / ~b, 2)), s = Denominator(Rt(~a / ~b, 2))], (1 / (2s)) * Antiderivative((r + s * (~x) ^ 2) / (~a + ~b * (~x) ^ 4), ~x) - (1 / (2s)) * Antiderivative((r - s * (~x) ^ 2) / (~a + ~b * (~x) ^ 4), ~x)) <-- FreeQ([~a, ~b], ~x) && (GtQ(~a / ~b, 0) || PosQ(~a / ~b) && (AtomQ(SplitProduct(SumBaseQ, ~a)) && AtomQ(SplitProduct(SumBaseQ, ~b))))
    @apply_utils Antiderivative((~x) ^ 2 / (~a + ~(b') * (~x) ^ 4), ~x) => With([r = Numerator(Rt(-(~a) / ~b, 2)), s = Denominator(Rt(-(~a) / ~b, 2))], (s / (2 * ~b)) * Antiderivative(1 / (r + s * (~x) ^ 2), ~x) - (s / (2 * ~b)) * Antiderivative(1 / (r - s * (~x) ^ 2), ~x)) <-- FreeQ([~a, ~b], ~x) && Not(GtQ(~a / ~b, 0))
    @apply_utils Antiderivative((~x) ^ ~(m') / (~a + ~(b') * (~x) ^ ~n), ~x) => With([r = Numerator(Rt(~a / ~b, 4)), s = Denominator(Rt(~a / ~b, 4))], (s ^ 3 / (2 * sqrt(2) * ~b * r)) * Antiderivative((~x) ^ (~m - ~n / 4) / ((r ^ 2 - sqrt(2) * r * s * (~x) ^ (~n / 4)) + s ^ 2 * (~x) ^ (~n / 2)), ~x) - (s ^ 3 / (2 * sqrt(2) * ~b * r)) * Antiderivative((~x) ^ (~m - ~n / 4) / (r ^ 2 + sqrt(2) * r * s * (~x) ^ (~n / 4) + s ^ 2 * (~x) ^ (~n / 2)), ~x)) <-- FreeQ([~a, ~b], ~x) && (IGtQ(~n / 4, 0) && (IGtQ(~m, 0) && (LtQ(~m, ~n - 1) && GtQ(~a / ~b, 0))))
    @apply_utils Antiderivative((~x) ^ ~m / (~a + ~(b') * (~x) ^ ~n), ~x) => With([r = Numerator(Rt(-(~a) / ~b, 2)), s = Denominator(Rt(-(~a) / ~b, 2))], (r / (2 * ~a)) * Antiderivative((~x) ^ ~m / (r + s * (~x) ^ (~n / 2)), ~x) + (r / (2 * ~a)) * Antiderivative((~x) ^ ~m / (r - s * (~x) ^ (~n / 2)), ~x)) <-- FreeQ([~a, ~b], ~x) && (IGtQ(~n / 4, 0) && (IGtQ(~m, 0) && (LtQ(~m, ~n / 2) && Not(GtQ(~a / ~b, 0)))))
    @apply_utils Antiderivative((~x) ^ ~m / (~a + ~(b') * (~x) ^ ~n), ~x) => With([r = Numerator(Rt(-(~a) / ~b, 2)), s = Denominator(Rt(-(~a) / ~b, 2))], (s / (2 * ~b)) * Antiderivative((~x) ^ (~m - ~n / 2) / (r + s * (~x) ^ (~n / 2)), ~x) - (s / (2 * ~b)) * Antiderivative((~x) ^ (~m - ~n / 2) / (r - s * (~x) ^ (~n / 2)), ~x)) <-- FreeQ([~a, ~b], ~x) && (IGtQ(~n / 4, 0) && (IGtQ(~m, 0) && (LeQ(~n / 2, ~m) && (LtQ(~m, ~n) && Not(GtQ(~a / ~b, 0))))))
    @apply_utils Antiderivative((~x) ^ ~m / (~a + ~(b') * (~x) ^ ~n), ~x) => Antiderivative(PolynomialDivide((~x) ^ ~m, ~a + ~b * (~x) ^ ~n, ~x), ~x) <-- FreeQ([~a, ~b], ~x) && (IGtQ(~m, 0) && (IGtQ(~n, 0) && GtQ(~m, 2 * ~n - 1)))
    @apply_utils Antiderivative(~x / sqrt(~a + ~(b') * (~x) ^ 3), ~x) => With([r = Numer(Rt(~b / ~a, 3)), s = Denom(Rt(~b / ~a, 3))], ((-((1 - sqrt(3))) * s) / r) * Antiderivative(1 / sqrt(~a + ~b * (~x) ^ 3), ~x) + (1 / r) * Antiderivative(((1 - sqrt(3)) * s + r * ~x) / sqrt(~a + ~b * (~x) ^ 3), ~x)) <-- FreeQ([~a, ~b], ~x) && PosQ(~a)
    @apply_utils Antiderivative(~x / sqrt(~a + ~(b') * (~x) ^ 3), ~x) => With([r = Numer(Rt(~b / ~a, 3)), s = Denom(Rt(~b / ~a, 3))], ((-((1 + sqrt(3))) * s) / r) * Antiderivative(1 / sqrt(~a + ~b * (~x) ^ 3), ~x) + (1 / r) * Antiderivative(((1 + sqrt(3)) * s + r * ~x) / sqrt(~a + ~b * (~x) ^ 3), ~x)) <-- FreeQ([~a, ~b], ~x) && NegQ(~a)
    @apply_utils Antiderivative((~x) ^ 2 / sqrt(~a + ~(b') * (~x) ^ 4), ~x) => With([q = Rt(~b / ~a, 2)], (1 / q) * Antiderivative(1 / sqrt(~a + ~b * (~x) ^ 4), ~x) - (1 / q) * Antiderivative((1 - q * (~x) ^ 2) / sqrt(~a + ~b * (~x) ^ 4), ~x)) <-- FreeQ([~a, ~b], ~x) && PosQ(~b / ~a)
    @apply_utils Antiderivative((~x) ^ 2 / sqrt(~a + ~(b') * (~x) ^ 4), ~x) => With([q = Rt(-(~b) / ~a, 2)], (1 / q) * Antiderivative(1 / sqrt(~a + ~b * (~x) ^ 4), ~x) - (1 / q) * Antiderivative((1 - q * (~x) ^ 2) / sqrt(~a + ~b * (~x) ^ 4), ~x)) <-- FreeQ([~a, ~b], ~x) && (LtQ(~a, 0) && GtQ(~b, 0))
    @apply_utils Antiderivative((~x) ^ 2 / sqrt(~a + ~(b') * (~x) ^ 4), ~x) => With([q = Rt(-(~b) / ~a, 2)], (-1 / q) * Antiderivative(1 / sqrt(~a + ~b * (~x) ^ 4), ~x) + (1 / q) * Antiderivative((1 + q * (~x) ^ 2) / sqrt(~a + ~b * (~x) ^ 4), ~x)) <-- FreeQ([~a, ~b], ~x) && NegQ(~b / ~a)
    @apply_utils Antiderivative((~x) ^ 4 / sqrt(~a + ~(b') * (~x) ^ 6), ~x) => With([r = Numer(Rt(~b / ~a, 3)), s = Denom(Rt(~b / ~a, 3))], (((sqrt(3) - 1) * s ^ 2) / (2 * r ^ 2)) * Antiderivative(1 / sqrt(~a + ~b * (~x) ^ 6), ~x) - (1 / (2 * r ^ 2)) * Antiderivative(((sqrt(3) - 1) * s ^ 2 - 2 * r ^ 2 * (~x) ^ 4) / sqrt(~a + ~b * (~x) ^ 6), ~x)) <-- FreeQ([~a, ~b], ~x)
    #= Antiderivative((~x)^4/sqrt((~a)+(~b')*(~x)^6),~x) :=  With([r=Numer(Rt(b/a,3)), s=Denom(Rt(b/a,3))], (1+sqrt(3))*r*x*sqrt(a+b*x^6)/(2*b*(s+(1+sqrt(3))*r*x^2)) - 3^(1/4)*s*x*(s+r*x^2)*sqrt((s^2-r*s*x^2+r^2*x^4)/(s+(1+sqrt(3))*r*x^ 2)^2)/ (2*r^2*sqrt(a+b*x^6)*sqrt(r*x^2*(s+r*x^2)/(s+(1+sqrt(3))*r*x^2)^2) )* Elliptic.E(acos((s+(1-sqrt(3))*r*x^2)/(s+(1+sqrt(3))*r*x^2)),(2+ sqrt(3))/4) - (1-sqrt(3))*s*x*(s+r*x^2)*sqrt((s^2-r*s*x^2+r^2*x^4)/(s+(1+sqrt(3))* r*x^2)^2)/ (4*3^(1/4)*r^2*sqrt(a+b*x^6)*sqrt(r*x^2*(s+r*x^2)/(s+(1+sqrt(3))* r*x^2)^2))* Elliptic.F(acos((s+(1-sqrt(3))*r*x^2)/(s+(1+sqrt(3))*r*x^2)),(2+ sqrt(3))/4)) <-- FreeQ([a,b],x) =#
    @apply_utils Antiderivative((~x) ^ 2 / sqrt(~a + ~(b') * (~x) ^ 8), ~x) => (1 / (2 * Rt(~b / ~a, 4))) * Antiderivative((1 + Rt(~b / ~a, 4) * (~x) ^ 2) / sqrt(~a + ~b * (~x) ^ 8), ~x) - (1 / (2 * Rt(~b / ~a, 4))) * Antiderivative((1 - Rt(~b / ~a, 4) * (~x) ^ 2) / sqrt(~a + ~b * (~x) ^ 8), ~x) <-- FreeQ([~a, ~b], ~x)
    @apply_utils Antiderivative((~x) ^ 2 / (~a + ~(b') * (~x) ^ 4) ^ (1 / 4), ~x) => (~x) ^ 3 / (2 * (~a + ~b * (~x) ^ 4) ^ (1 / 4)) - (~a / 2) * Antiderivative((~x) ^ 2 / (~a + ~b * (~x) ^ 4) ^ (5 / 4), ~x) <-- FreeQ([~a, ~b], ~x) && PosQ(~b / ~a)
    @apply_utils Antiderivative((~x) ^ 2 / (~a + ~(b') * (~x) ^ 4) ^ (1 / 4), ~x) => (~a + ~b * (~x) ^ 4) ^ (3 / 4) / (2 * ~b * ~x) + (~a / (2 * ~b)) * Antiderivative(1 / ((~x) ^ 2 * (~a + ~b * (~x) ^ 4) ^ (1 / 4)), ~x) <-- FreeQ([~a, ~b], ~x) && NegQ(~b / ~a)
    @apply_utils Antiderivative(1 / ((~x) ^ 2 * (~a + ~(b') * (~x) ^ 4) ^ (1 / 4)), ~x) => -1 / (~x * (~a + ~b * (~x) ^ 4) ^ (1 / 4)) - ~b * Antiderivative((~x) ^ 2 / (~a + ~b * (~x) ^ 4) ^ (5 / 4), ~x) <-- FreeQ([~a, ~b], ~x) && PosQ(~b / ~a)
    @apply_utils Antiderivative(1 / ((~x) ^ 2 * (~a + ~(b') * (~x) ^ 4) ^ (1 / 4)), ~x) => ((~x * (1 + ~a / (~b * (~x) ^ 4)) ^ (1 / 4)) / (~a + ~b * (~x) ^ 4) ^ (1 / 4)) * Antiderivative(1 / ((~x) ^ 3 * (1 + ~a / (~b * (~x) ^ 4)) ^ (1 / 4)), ~x) <-- FreeQ([~a, ~b], ~x) && NegQ(~b / ~a)
    @apply_utils Antiderivative(sqrt(~c * ~x) / (~a + ~(b') * (~x) ^ 2) ^ (1 / 4), ~x) => (~x * sqrt(~c * ~x)) / (~a + ~b * (~x) ^ 2) ^ (1 / 4) - (~a / 2) * Antiderivative(sqrt(~c * ~x) / (~a + ~b * (~x) ^ 2) ^ (5 / 4), ~x) <-- FreeQ([~a, ~b, ~c], ~x) && PosQ(~b / ~a)
    @apply_utils Antiderivative(sqrt(~c * ~x) / (~a + ~(b') * (~x) ^ 2) ^ (1 / 4), ~x) => (~c * (~a + ~b * (~x) ^ 2) ^ (3 / 4)) / (~b * sqrt(~c * ~x)) + ((~a * (~c) ^ 2) / (2 * ~b)) * Antiderivative(1 / ((~c * ~x) ^ (3 / 2) * (~a + ~b * (~x) ^ 2) ^ (1 / 4)), ~x) <-- FreeQ([~a, ~b, ~c], ~x) && NegQ(~b / ~a)
    @apply_utils Antiderivative(1 / ((~(c') * ~x) ^ (3 / 2) * (~a + ~(b') * (~x) ^ 2) ^ (1 / 4)), ~x) => -2 / (~c * sqrt(~c * ~x) * (~a + ~b * (~x) ^ 2) ^ (1 / 4)) - (~b / (~c) ^ 2) * Antiderivative(sqrt(~c * ~x) / (~a + ~b * (~x) ^ 2) ^ (5 / 4), ~x) <-- FreeQ([~a, ~b, ~c], ~x) && PosQ(~b / ~a)
    @apply_utils Antiderivative(1 / ((~(c') * ~x) ^ (3 / 2) * (~a + ~(b') * (~x) ^ 2) ^ (1 / 4)), ~x) => ((sqrt(~c * ~x) * (1 + ~a / (~b * (~x) ^ 2)) ^ (1 / 4)) / ((~c) ^ 2 * (~a + ~b * (~x) ^ 2) ^ (1 / 4))) * Antiderivative(1 / ((~x) ^ 2 * (1 + ~a / (~b * (~x) ^ 2)) ^ (1 / 4)), ~x) <-- FreeQ([~a, ~b, ~c], ~x) && NegQ(~b / ~a)
    @apply_utils Antiderivative(sqrt(~x) / sqrt(~a + ~(b') * (~x) ^ 2), ~x) => (-2 / (sqrt(~a) * (-(~b) / ~a) ^ (3 / 4))) * Subst(Antiderivative(sqrt(1 - 2 * (~x) ^ 2) / sqrt(1 - (~x) ^ 2), ~x), ~x, sqrt(1 - sqrt(-(~b) / ~a) * ~x) / sqrt(2)) <-- FreeQ([~a, ~b], ~x) && (GtQ(-(~b) / ~a, 0) && GtQ(~a, 0))
    @apply_utils Antiderivative(sqrt(~x) / sqrt(~a + ~(b') * (~x) ^ 2), ~x) => (sqrt(1 + (~b * (~x) ^ 2) / ~a) / sqrt(~a + ~b * (~x) ^ 2)) * Antiderivative(sqrt(~x) / sqrt(1 + (~b * (~x) ^ 2) / ~a), ~x) <-- FreeQ([~a, ~b], ~x) && (GtQ(-(~b) / ~a, 0) && Not(GtQ(~a, 0)))
    @apply_utils Antiderivative(sqrt(~c * ~x) / sqrt(~a + ~(b') * (~x) ^ 2), ~x) => (sqrt(~c * ~x) / sqrt(~x)) * Antiderivative(sqrt(~x) / sqrt(~a + ~b * (~x) ^ 2), ~x) <-- FreeQ([~a, ~b, ~c], ~x) && GtQ(-(~b) / ~a, 0)
    @apply_utils Antiderivative((~(c') * ~x) ^ ~m * (~a + ~(b') * (~x) ^ ~n) ^ ~p, ~x) => ((~c) ^ (~n - 1) * (~c * ~x) ^ ((~m - ~n) + 1) * (~a + ~b * (~x) ^ ~n) ^ (~p + 1)) / (~b * (~m + ~n * ~p + 1)) - ((~a * (~c) ^ ~n * ((~m - ~n) + 1)) / (~b * (~m + ~n * ~p + 1))) * Antiderivative((~c * ~x) ^ (~m - ~n) * (~a + ~b * (~x) ^ ~n) ^ ~p, ~x) <-- FreeQ([~a, ~b, ~c, ~p], ~x) && (IGtQ(~n, 0) && (GtQ(~m, ~n - 1) && (NeQ(~m + ~n * ~p + 1, 0) && IntBinomialQ(~a, ~b, ~c, ~n, ~m, ~p, ~x))))
    @apply_utils Antiderivative((~(c') * ~x) ^ ~m * (~a + ~(b') * (~x) ^ ~n) ^ ~p, ~x) => ((~c) ^ (~n - 1) * (~c * ~x) ^ ((~m - ~n) + 1) * (~a + ~b * (~x) ^ ~n) ^ (~p + 1)) / (~b * (~m + ~n * ~p + 1)) - ((~a * (~c) ^ ~n * ((~m - ~n) + 1)) / (~b * (~m + ~n * ~p + 1))) * Antiderivative((~c * ~x) ^ (~m - ~n) * (~a + ~b * (~x) ^ ~n) ^ ~p, ~x) <-- FreeQ([~a, ~b, ~c, ~m, ~p], ~x) && (IGtQ(~n, 0) && (SumSimplerQ(~m, -(~n)) && (NeQ(~m + ~n * ~p + 1, 0) && ILtQ(Simplify((~m + 1) / ~n + ~p), 0))))
    @apply_utils Antiderivative((~(c') * ~x) ^ ~m * (~a1 + ~(b1') * (~x) ^ ~n) ^ ~p * (~a2 + ~(b2') * (~x) ^ ~n) ^ ~p, ~x) => ((~c) ^ (2 * ~n - 1) * (~c * ~x) ^ ((~m - 2 * ~n) + 1) * (~a1 + ~b1 * (~x) ^ ~n) ^ (~p + 1) * (~a2 + ~b2 * (~x) ^ ~n) ^ (~p + 1)) / (~b1 * ~b2 * (~m + 2 * ~n * ~p + 1)) - ((~a1 * ~a2 * (~c) ^ (2 * ~n) * ((~m - 2 * ~n) + 1)) / (~b1 * ~b2 * (~m + 2 * ~n * ~p + 1))) * Antiderivative((~c * ~x) ^ (~m - 2 * ~n) * (~a1 + ~b1 * (~x) ^ ~n) ^ ~p * (~a2 + ~b2 * (~x) ^ ~n) ^ ~p, ~x) <-- FreeQ([~a1, ~b1, ~a2, ~b2, ~c, ~p], ~x) && (EqQ(~a2 * ~b1 + ~a1 * ~b2, 0) && (IGtQ(2 * ~n, 0) && (GtQ(~m, 2 * ~n - 1) && (NeQ(~m + 2 * ~n * ~p + 1, 0) && IntBinomialQ(~a1 * ~a2, ~b1 * ~b2, ~c, 2 * ~n, ~m, ~p, ~x)))))
    @apply_utils Antiderivative((~(c') * ~x) ^ ~m * (~a1 + ~(b1') * (~x) ^ ~n) ^ ~p * (~a2 + ~(b2') * (~x) ^ ~n) ^ ~p, ~x) => ((~c) ^ (2 * ~n - 1) * (~c * ~x) ^ ((~m - 2 * ~n) + 1) * (~a1 + ~b1 * (~x) ^ ~n) ^ (~p + 1) * (~a2 + ~b2 * (~x) ^ ~n) ^ (~p + 1)) / (~b1 * ~b2 * (~m + 2 * ~n * ~p + 1)) - ((~a1 * ~a2 * (~c) ^ (2 * ~n) * ((~m - 2 * ~n) + 1)) / (~b1 * ~b2 * (~m + 2 * ~n * ~p + 1))) * Antiderivative((~c * ~x) ^ (~m - 2 * ~n) * (~a1 + ~b1 * (~x) ^ ~n) ^ ~p * (~a2 + ~b2 * (~x) ^ ~n) ^ ~p, ~x) <-- FreeQ([~a1, ~b1, ~a2, ~b2, ~c, ~m, ~p], ~x) && (EqQ(~a2 * ~b1 + ~a1 * ~b2, 0) && (IGtQ(2 * ~n, 0) && (SumSimplerQ(~m, -2 * ~n) && (NeQ(~m + 2 * ~n * ~p + 1, 0) && ILtQ(Simplify((~m + 1) / (2 * ~n) + ~p), 0)))))
    @apply_utils Antiderivative((~(c') * ~x) ^ ~m * (~a + ~(b') * (~x) ^ ~n) ^ ~p, ~x) => ((~c * ~x) ^ (~m + 1) * (~a + ~b * (~x) ^ ~n) ^ (~p + 1)) / (~a * ~c * (~m + 1)) - ((~b * (~m + ~n * (~p + 1) + 1)) / (~a * (~c) ^ ~n * (~m + 1))) * Antiderivative((~c * ~x) ^ (~m + ~n) * (~a + ~b * (~x) ^ ~n) ^ ~p, ~x) <-- FreeQ([~a, ~b, ~c, ~p], ~x) && (IGtQ(~n, 0) && (LtQ(~m, -1) && IntBinomialQ(~a, ~b, ~c, ~n, ~m, ~p, ~x)))
    @apply_utils Antiderivative((~(c') * ~x) ^ ~m * (~a + ~(b') * (~x) ^ ~n) ^ ~p, ~x) => ((~c * ~x) ^ (~m + 1) * (~a + ~b * (~x) ^ ~n) ^ (~p + 1)) / (~a * ~c * (~m + 1)) - ((~b * (~m + ~n * (~p + 1) + 1)) / (~a * (~c) ^ ~n * (~m + 1))) * Antiderivative((~c * ~x) ^ (~m + ~n) * (~a + ~b * (~x) ^ ~n) ^ ~p, ~x) <-- FreeQ([~a, ~b, ~c, ~m, ~p], ~x) && (IGtQ(~n, 0) && (SumSimplerQ(~m, ~n) && ILtQ(Simplify((~m + 1) / ~n + ~p), 0)))
    @apply_utils Antiderivative((~(c') * ~x) ^ ~m * (~a1 + ~(b1') * (~x) ^ ~n) ^ ~p * (~a2 + ~(b2') * (~x) ^ ~n) ^ ~p, ~x) => ((~c * ~x) ^ (~m + 1) * (~a1 + ~b1 * (~x) ^ ~n) ^ (~p + 1) * (~a2 + ~b2 * (~x) ^ ~n) ^ (~p + 1)) / (~a1 * ~a2 * ~c * (~m + 1)) - ((~b1 * ~b2 * (~m + 2 * ~n * (~p + 1) + 1)) / (~a1 * ~a2 * (~c) ^ (2 * ~n) * (~m + 1))) * Antiderivative((~c * ~x) ^ (~m + 2 * ~n) * (~a1 + ~b1 * (~x) ^ ~n) ^ ~p * (~a2 + ~b2 * (~x) ^ ~n) ^ ~p, ~x) <-- FreeQ([~a1, ~b1, ~a2, ~b2, ~c, ~p], ~x) && (EqQ(~a2 * ~b1 + ~a1 * ~b2, 0) && (IGtQ(2 * ~n, 0) && (LtQ(~m, -1) && IntBinomialQ(~a1 * ~a2, ~b1 * ~b2, ~c, 2 * ~n, ~m, ~p, ~x))))
    @apply_utils Antiderivative((~(c') * ~x) ^ ~m * (~a1 + ~(b1') * (~x) ^ ~n) ^ ~p * (~a2 + ~(b2') * (~x) ^ ~n) ^ ~p, ~x) => ((~c * ~x) ^ (~m + 1) * (~a1 + ~b1 * (~x) ^ ~n) ^ (~p + 1) * (~a2 + ~b2 * (~x) ^ ~n) ^ (~p + 1)) / (~a1 * ~a2 * ~c * (~m + 1)) - ((~b1 * ~b2 * (~m + 2 * ~n * (~p + 1) + 1)) / (~a1 * ~a2 * (~c) ^ (2 * ~n) * (~m + 1))) * Antiderivative((~c * ~x) ^ (~m + 2 * ~n) * (~a1 + ~b1 * (~x) ^ ~n) ^ ~p * (~a2 + ~b2 * (~x) ^ ~n) ^ ~p, ~x) <-- FreeQ([~a1, ~b1, ~a2, ~b2, ~c, ~m, ~p], ~x) && (EqQ(~a2 * ~b1 + ~a1 * ~b2, 0) && (IGtQ(2 * ~n, 0) && (SumSimplerQ(~m, 2 * ~n) && ILtQ(Simplify((~m + 1) / (2 * ~n) + ~p), 0))))
    @apply_utils Antiderivative((~(c') * ~x) ^ ~m * (~a + ~(b') * (~x) ^ ~n) ^ ~p, ~x) => With([k = Denominator(~m)], (k / ~c) * Subst(Antiderivative((~x) ^ (k * (~m + 1) - 1) * (~a + (~b * (~x) ^ (k * ~n)) / (~c) ^ ~n) ^ ~p, ~x), ~x, (~c * ~x) ^ (1 / k))) <-- FreeQ([~a, ~b, ~c, ~p], ~x) && (IGtQ(~n, 0) && (FractionQ(~m) && IntBinomialQ(~a, ~b, ~c, ~n, ~m, ~p, ~x)))
    @apply_utils Antiderivative((~(c') * ~x) ^ ~m * (~a1 + ~(b1') * (~x) ^ ~n) ^ ~p * (~a2 + ~(b2') * (~x) ^ ~n) ^ ~p, ~x) => With([k = Denominator(~m)], (k / ~c) * Subst(Antiderivative((~x) ^ (k * (~m + 1) - 1) * (~a1 + (~b1 * (~x) ^ (k * ~n)) / (~c) ^ ~n) ^ ~p * (~a2 + (~b2 * (~x) ^ (k * ~n)) / (~c) ^ ~n) ^ ~p, ~x), ~x, (~c * ~x) ^ (1 / k))) <-- FreeQ([~a1, ~b1, ~a2, ~b2, ~c, ~p], ~x) && (EqQ(~a2 * ~b1 + ~a1 * ~b2, 0) && (IGtQ(2 * ~n, 0) && (FractionQ(~m) && IntBinomialQ(~a1 * ~a2, ~b1 * ~b2, ~c, 2 * ~n, ~m, ~p, ~x))))
    @apply_utils Antiderivative(~x / (~a + ~(b') * (~x) ^ 3) ^ (2 / 3), ~x) => With([q = Rt(~b, 3)], -(atan((1 + (2 * q * ~x) / (~a + ~b * (~x) ^ 3) ^ (1 / 3)) / sqrt(3))) / (sqrt(3) * q ^ 2) - log(q * ~x - (~a + ~b * (~x) ^ 3) ^ (1 / 3)) / (2 * q ^ 2)) <-- FreeQ([~a, ~b], ~x)
    @apply_utils Antiderivative((~x) ^ ~(m') * (~a + ~(b') * (~x) ^ ~n) ^ ~p, ~x) => (~a) ^ (~p + (~m + 1) / ~n) * Subst(Antiderivative((~x) ^ ~m / (1 - ~b * (~x) ^ ~n) ^ (~p + (~m + 1) / ~n + 1), ~x), ~x, ~x / (~a + ~b * (~x) ^ ~n) ^ (1 / ~n)) <-- FreeQ([~a, ~b], ~x) && (IGtQ(~n, 0) && (LtQ(-1, ~p, 0) && (NeQ(~p, -1 / 2) && IntegersQ(~m, ~p + (~m + 1) / ~n))))
    @apply_utils Antiderivative((~x) ^ ~(m') * (~a1 + ~(b1') * (~x) ^ ~n) ^ ~p * (~a2 + ~(b2') * (~x) ^ ~n) ^ ~p, ~x) => (~a1 * ~a2) ^ (~p + (~m + 1) / (2 * ~n)) * Subst(Antiderivative((~x) ^ ~m / ((1 - ~b1 * (~x) ^ ~n) ^ (~p + (~m + 1) / (2 * ~n) + 1) * (1 - ~b2 * (~x) ^ ~n) ^ (~p + (~m + 1) / (2 * ~n) + 1)), ~x), ~x, ~x / ((~a1 + ~b1 * (~x) ^ ~n) ^ (1 / (2 * ~n)) * (~a2 + ~b2 * (~x) ^ ~n) ^ (1 / (2 * ~n)))) <-- FreeQ([~a1, ~b1, ~a2, ~b2], ~x) && (EqQ(~a2 * ~b1 + ~a1 * ~b2, 0) && (IGtQ(2 * ~n, 0) && (LtQ(-1, ~p, 0) && (NeQ(~p, -1 / 2) && IntegersQ(~m, ~p + (~m + 1) / (2 * ~n))))))
    @apply_utils Antiderivative((~x) ^ ~(m') * (~a + ~(b') * (~x) ^ ~n) ^ ~p, ~x) => (~a / (~a + ~b * (~x) ^ ~n)) ^ (~p + (~m + 1) / ~n) * (~a + ~b * (~x) ^ ~n) ^ (~p + (~m + 1) / ~n) * Subst(Antiderivative((~x) ^ ~m / (1 - ~b * (~x) ^ ~n) ^ (~p + (~m + 1) / ~n + 1), ~x), ~x, ~x / (~a + ~b * (~x) ^ ~n) ^ (1 / ~n)) <-- FreeQ([~a, ~b], ~x) && (IGtQ(~n, 0) && (LtQ(-1, ~p, 0) && (NeQ(~p, -1 / 2) && (IntegerQ(~m) && LtQ(Denominator(~p + (~m + 1) / ~n), Denominator(~p))))))
    @apply_utils Antiderivative((~x) ^ ~(m') * (~a1 + ~(b1') * (~x) ^ ~n) ^ ~p * (~a2 + ~(b2') * (~x) ^ ~n) ^ ~p, ~x) => (~a1 / (~a1 + ~b1 * (~x) ^ ~n)) ^ (~p + (~m + 1) / (2 * ~n)) * (~a1 + ~b1 * (~x) ^ ~n) ^ (~p + (~m + 1) / (2 * ~n)) * (~a2 / (~a2 + ~b2 * (~x) ^ ~n)) ^ (~p + (~m + 1) / (2 * ~n)) * (~a2 + ~b2 * (~x) ^ ~n) ^ (~p + (~m + 1) / (2 * ~n)) * Subst(Antiderivative((~x) ^ ~m / ((1 - ~b1 * (~x) ^ ~n) ^ (~p + (~m + 1) / (2 * ~n) + 1) * (1 - ~b2 * (~x) ^ ~n) ^ (~p + (~m + 1) / (2 * ~n) + 1)), ~x), ~x, ~x / ((~a1 + ~b1 * (~x) ^ ~n) ^ (1 / (2 * ~n)) * (~a2 + ~b2 * (~x) ^ ~n) ^ (1 / (2 * ~n)))) <-- FreeQ([~a1, ~b1, ~a2, ~b2], ~x) && (EqQ(~a2 * ~b1 + ~a1 * ~b2, 0) && (IGtQ(2 * ~n, 0) && (LtQ(-1, ~p, 0) && (NeQ(~p, -1 / 2) && (IntegerQ(~m) && LtQ(Denominator(~p + (~m + 1) / (2 * ~n)), Denominator(~p)))))))
    @apply_utils Antiderivative((~x) ^ ~(m') * (~a + ~(b') * (~x) ^ ~n) ^ ~p, ~x) => -(Subst(Antiderivative((~a + ~b * (~x) ^ -(~n)) ^ ~p / (~x) ^ (~m + 2), ~x), ~x, 1 / ~x)) <-- FreeQ([~a, ~b, ~p], ~x) && (ILtQ(~n, 0) && IntegerQ(~m))
    @apply_utils Antiderivative((~x) ^ ~(m') * (~a1 + ~(b1') * (~x) ^ ~n) ^ ~p * (~a2 + ~(b2') * (~x) ^ ~n) ^ ~p, ~x) => -(Subst(Antiderivative(((~a1 + ~b1 * (~x) ^ -(~n)) ^ ~p * (~a2 + ~b2 * (~x) ^ -(~n)) ^ ~p) / (~x) ^ (~m + 2), ~x), ~x, 1 / ~x)) <-- FreeQ([~a1, ~b1, ~a2, ~b2, ~p], ~x) && (EqQ(~a2 * ~b1 + ~a1 * ~b2, 0) && (ILtQ(2 * ~n, 0) && IntegerQ(~m)))
    @apply_utils Antiderivative((~(c') * ~x) ^ ~m * (~a + ~(b') * (~x) ^ ~n) ^ ~p, ~x) => With([k = Denominator(~m)], (-k / ~c) * Subst(Antiderivative((~a + ~b * (~c) ^ -(~n) * (~x) ^ (-k * ~n)) ^ ~p / (~x) ^ (k * (~m + 1) + 1), ~x), ~x, 1 / (~c * ~x) ^ (1 / k))) <-- FreeQ([~a, ~b, ~c, ~p], ~x) && (ILtQ(~n, 0) && FractionQ(~m))
    @apply_utils Antiderivative((~(c') * ~x) ^ ~m * (~a1 + ~(b1') * (~x) ^ ~n) ^ ~p * (~a2 + ~(b2') * (~x) ^ ~n) ^ ~p, ~x) => With([k = Denominator(~m)], (-k / ~c) * Subst(Antiderivative(((~a1 + ~b1 * (~c) ^ -(~n) * (~x) ^ (-k * ~n)) ^ ~p * (~a2 + ~b2 * (~c) ^ -(~n) * (~x) ^ (-k * ~n)) ^ ~p) / (~x) ^ (k * (~m + 1) + 1), ~x), ~x, 1 / (~c * ~x) ^ (1 / k))) <-- FreeQ([~a1, ~b1, ~a2, ~b2, ~c, ~p], ~x) && (EqQ(~a2 * ~b1 + ~a1 * ~b2, 0) && (ILtQ(2 * ~n, 0) && FractionQ(~m)))
    @apply_utils Antiderivative((~(c') * ~x) ^ ~m * (~a + ~(b') * (~x) ^ ~n) ^ ~p, ~x) => (-1 / ~c) * (~c * ~x) ^ (~m + 1) * (1 / ~x) ^ (~m + 1) * Subst(Antiderivative((~a + ~b * (~x) ^ -(~n)) ^ ~p / (~x) ^ (~m + 2), ~x), ~x, 1 / ~x) <-- FreeQ([~a, ~b, ~c, ~m, ~p], ~x) && (ILtQ(~n, 0) && Not(RationalQ(~m)))
    @apply_utils Antiderivative((~(c') * ~x) ^ ~m * (~a1 + ~(b1') * (~x) ^ ~n) ^ ~p * (~a2 + ~(b2') * (~x) ^ ~n) ^ ~p, ~x) => (-1 / ~c) * (~c * ~x) ^ (~m + 1) * (1 / ~x) ^ (~m + 1) * Subst(Antiderivative(((~a1 + ~b1 * (~x) ^ -(~n)) ^ ~p * (~a2 + ~b2 * (~x) ^ -(~n)) ^ ~p) / (~x) ^ (~m + 2), ~x), ~x, 1 / ~x) <-- FreeQ([~a1, ~b1, ~a2, ~b2, ~c, ~m, ~p], ~x) && (EqQ(~a2 * ~b1 + ~a1 * ~b2, 0) && (ILtQ(2 * ~n, 0) && Not(RationalQ(~m))))
    @apply_utils Antiderivative((~x) ^ ~(m') * (~a + ~(b') * (~x) ^ ~n) ^ ~p, ~x) => With([k = Denominator(~n)], k * Subst(Antiderivative((~x) ^ (k * (~m + 1) - 1) * (~a + ~b * (~x) ^ (k * ~n)) ^ ~p, ~x), ~x, (~x) ^ (1 / k))) <-- FreeQ([~a, ~b, ~m, ~p], ~x) && FractionQ(~n)
    @apply_utils Antiderivative((~x) ^ ~(m') * (~a1 + ~(b1') * (~x) ^ ~n) ^ ~p * (~a2 + ~(b2') * (~x) ^ ~n) ^ ~p, ~x) => With([k = Denominator(2 * ~n)], k * Subst(Antiderivative((~x) ^ (k * (~m + 1) - 1) * (~a1 + ~b1 * (~x) ^ (k * ~n)) ^ ~p * (~a2 + ~b2 * (~x) ^ (k * ~n)) ^ ~p, ~x), ~x, (~x) ^ (1 / k))) <-- FreeQ([~a1, ~b1, ~a2, ~b2, ~m, ~p], ~x) && (EqQ(~a2 * ~b1 + ~a1 * ~b2, 0) && FractionQ(2 * ~n))
    @apply_utils Antiderivative((~c * ~x) ^ ~m * (~a + ~(b') * (~x) ^ ~n) ^ ~p, ~x) => (((~c) ^ IntPart(~m) * (~c * ~x) ^ FracPart(~m)) / (~x) ^ FracPart(~m)) * Antiderivative((~x) ^ ~m * (~a + ~b * (~x) ^ ~n) ^ ~p, ~x) <-- FreeQ([~a, ~b, ~c, ~m, ~p], ~x) && FractionQ(~n)
    @apply_utils Antiderivative((~c * ~x) ^ ~m * (~a1 + ~(b1') * (~x) ^ ~n) ^ ~p * (~a2 + ~(b2') * (~x) ^ ~n) ^ ~p, ~x) => (((~c) ^ IntPart(~m) * (~c * ~x) ^ FracPart(~m)) / (~x) ^ FracPart(~m)) * Antiderivative((~x) ^ ~m * (~a1 + ~b1 * (~x) ^ ~n) ^ ~p * (~a2 + ~b2 * (~x) ^ ~n) ^ ~p, ~x) <-- FreeQ([~a1, ~b1, ~a2, ~b2, ~c, ~m, ~p], ~x) && (EqQ(~a2 * ~b1 + ~a1 * ~b2, 0) && FractionQ(2 * ~n))
    @apply_utils Antiderivative((~x) ^ ~(m') * (~a + ~(b') * (~x) ^ ~n) ^ ~p, ~x) => (1 / (~m + 1)) * Subst(Antiderivative((~a + ~b * (~x) ^ Simplify(~n / (~m + 1))) ^ ~p, ~x), ~x, (~x) ^ (~m + 1)) <-- FreeQ([~a, ~b, ~m, ~n, ~p], ~x) && (IntegerQ(Simplify(~n / (~m + 1))) && Not(IntegerQ(~n)))
    @apply_utils Antiderivative((~x) ^ ~(m') * (~a1 + ~(b1') * (~x) ^ ~n) ^ ~p * (~a2 + ~(b2') * (~x) ^ ~n) ^ ~p, ~x) => (1 / (~m + 1)) * Subst(Antiderivative((~a1 + ~b1 * (~x) ^ Simplify(~n / (~m + 1))) ^ ~p * (~a2 + ~b2 * (~x) ^ Simplify(~n / (~m + 1))) ^ ~p, ~x), ~x, (~x) ^ (~m + 1)) <-- FreeQ([~a1, ~b1, ~a2, ~b2, ~m, ~n, ~p], ~x) && (EqQ(~a2 * ~b1 + ~a1 * ~b2, 0) && (IntegerQ(Simplify((2 * ~n) / (~m + 1))) && Not(IntegerQ(2 * ~n))))
    @apply_utils Antiderivative((~c * ~x) ^ ~m * (~a + ~(b') * (~x) ^ ~n) ^ ~p, ~x) => (((~c) ^ IntPart(~m) * (~c * ~x) ^ FracPart(~m)) / (~x) ^ FracPart(~m)) * Antiderivative((~x) ^ ~m * (~a + ~b * (~x) ^ ~n) ^ ~p, ~x) <-- FreeQ([~a, ~b, ~c, ~m, ~n, ~p], ~x) && (IntegerQ(Simplify(~n / (~m + 1))) && Not(IntegerQ(~n)))
    @apply_utils Antiderivative((~c * ~x) ^ ~m * (~a1 + ~(b1') * (~x) ^ ~n) ^ ~p * (~a2 + ~(b2') * (~x) ^ ~n) ^ ~p, ~x) => (((~c) ^ IntPart(~m) * (~c * ~x) ^ FracPart(~m)) / (~x) ^ FracPart(~m)) * Antiderivative((~x) ^ ~m * (~a1 + ~b1 * (~x) ^ ~n) ^ ~p * (~a2 + ~b2 * (~x) ^ ~n) ^ ~p, ~x) <-- FreeQ([~a1, ~b1, ~a2, ~b2, ~c, ~m, ~n, ~p], ~x) && (EqQ(~a2 * ~b1 + ~a1 * ~b2, 0) && (IntegerQ(Simplify((2 * ~n) / (~m + 1))) && Not(IntegerQ(2 * ~n))))
    @apply_utils Antiderivative((~x) ^ ~(m') * (~a + ~(b') * (~x) ^ ~n) ^ ~p, ~x) => ((~x) ^ (~m + 1) * (~a + ~b * (~x) ^ ~n) ^ ~p) / (~m + 1) - ((~b * ~n * ~p) / (~m + 1)) * Antiderivative((~x) ^ (~m + ~n) * (~a + ~b * (~x) ^ ~n) ^ (~p - 1), ~x) <-- FreeQ([~a, ~b, ~m, ~n], ~x) && (EqQ((~m + 1) / ~n + ~p, 0) && GtQ(~p, 0))
    @apply_utils Antiderivative((~x) ^ ~(m') * (~a1 + ~(b1') * (~x) ^ ~n) ^ ~p * (~a2 + ~(b2') * (~x) ^ ~n) ^ ~p, ~x) => ((~x) ^ (~m + 1) * (~a1 + ~b1 * (~x) ^ ~n) ^ ~p * (~a2 + ~b2 * (~x) ^ ~n) ^ ~p) / (~m + 1) - ((2 * ~b1 * ~b2 * ~n * ~p) / (~m + 1)) * Antiderivative((~x) ^ (~m + 2 * ~n) * (~a1 + ~b1 * (~x) ^ ~n) ^ (~p - 1) * (~a2 + ~b2 * (~x) ^ ~n) ^ (~p - 1), ~x) <-- FreeQ([~a1, ~b1, ~a2, ~b2, ~m, ~n], ~x) && (EqQ(~a2 * ~b1 + ~a1 * ~b2, 0) && (EqQ((~m + 1) / (2 * ~n) + ~p, 0) && GtQ(~p, 0)))
    @apply_utils Antiderivative((~c * ~x) ^ ~m * (~a + ~(b') * (~x) ^ ~n) ^ ~p, ~x) => (((~c) ^ IntPart(~m) * (~c * ~x) ^ FracPart(~m)) / (~x) ^ FracPart(~m)) * Antiderivative((~x) ^ ~m * (~a + ~b * (~x) ^ ~n) ^ ~p, ~x) <-- FreeQ([~a, ~b, ~c, ~m, ~n], ~x) && (EqQ((~m + 1) / ~n + ~p, 0) && GtQ(~p, 0))
    @apply_utils Antiderivative((~c * ~x) ^ ~m * (~a1 + ~(b1') * (~x) ^ ~n) ^ ~p * (~a2 + ~(b2') * (~x) ^ ~n) ^ ~p, ~x) => (((~c) ^ IntPart(~m) * (~c * ~x) ^ FracPart(~m)) / (~x) ^ FracPart(~m)) * Antiderivative((~x) ^ ~m * (~a1 + ~b1 * (~x) ^ ~n) ^ ~p * (~a2 + ~b2 * (~x) ^ ~n) ^ ~p, ~x) <-- FreeQ([~a1, ~b1, ~a2, ~b2, ~c, ~m, ~n], ~x) && (EqQ(~a2 * ~b1 + ~a1 * ~b2, 0) && (EqQ((~m + 1) / (2 * ~n) + ~p, 0) && GtQ(~p, 0)))
    @apply_utils Antiderivative((~(c') * ~x) ^ ~(m') * (~a + ~(b') * (~x) ^ ~n) ^ ~p, ~x) => ((~c * ~x) ^ (~m + 1) * (~a + ~b * (~x) ^ ~n) ^ ~p) / (~c * (~m + ~n * ~p + 1)) + ((~a * ~n * ~p) / (~m + ~n * ~p + 1)) * Antiderivative((~c * ~x) ^ ~m * (~a + ~b * (~x) ^ ~n) ^ (~p - 1), ~x) <-- FreeQ([~a, ~b, ~c, ~m, ~n], ~x) && (IntegerQ(~p + Simplify((~m + 1) / ~n)) && (GtQ(~p, 0) && NeQ(~m + ~n * ~p + 1, 0)))
    @apply_utils Antiderivative((~(c') * ~x) ^ ~(m') * (~a1 + ~(b1') * (~x) ^ ~n) ^ ~p * (~a2 + ~(b2') * (~x) ^ ~n) ^ ~p, ~x) => ((~c * ~x) ^ (~m + 1) * (~a1 + ~b1 * (~x) ^ ~n) ^ ~p * (~a2 + ~b2 * (~x) ^ ~n) ^ ~p) / (~c * (~m + 2 * ~n * ~p + 1)) + ((2 * ~a1 * ~a2 * ~n * ~p) / (~m + 2 * ~n * ~p + 1)) * Antiderivative((~c * ~x) ^ ~m * (~a1 + ~b1 * (~x) ^ ~n) ^ (~p - 1) * (~a2 + ~b2 * (~x) ^ ~n) ^ (~p - 1), ~x) <-- FreeQ([~a1, ~b1, ~a2, ~b2, ~c, ~m, ~n], ~x) && (EqQ(~a2 * ~b1 + ~a1 * ~b2, 0) && (IntegerQ(~p + Simplify((~m + 1) / (2 * ~n))) && (GtQ(~p, 0) && NeQ(~m + 2 * ~n * ~p + 1, 0))))
    @apply_utils Antiderivative((~x) ^ ~(m') * (~a + ~(b') * (~x) ^ ~n) ^ ~p, ~x) => With([k = Denominator(~p)], ((k * (~a) ^ (~p + Simplify((~m + 1) / ~n))) / ~n) * Subst(Antiderivative((~x) ^ (k * Simplify((~m + 1) / ~n) - 1) / (1 - ~b * (~x) ^ k) ^ (~p + Simplify((~m + 1) / ~n) + 1), ~x), ~x, (~x) ^ (~n / k) / (~a + ~b * (~x) ^ ~n) ^ (1 / k))) <-- FreeQ([~a, ~b, ~m, ~n], ~x) && (IntegerQ(~p + Simplify((~m + 1) / ~n)) && LtQ(-1, ~p, 0))
    @apply_utils Antiderivative((~x) ^ ~(m') * (~a1 + ~(b1') * (~x) ^ ~n) ^ ~p * (~a2 + ~(b2') * (~x) ^ ~n) ^ ~p, ~x) => With([k = Denominator(~p)], ((k * (~a1 * ~a2) ^ (~p + Simplify((~m + 1) / (2 * ~n)))) / (2 * ~n)) * Subst(Antiderivative((~x) ^ (k * Simplify((~m + 1) / (2 * ~n)) - 1) / (1 - ~b1 * ~b2 * (~x) ^ k) ^ (~p + Simplify((~m + 1) / (2 * ~n)) + 1), ~x), ~x, (~x) ^ ((2 * ~n) / k) / ((~a1 + ~b1 * (~x) ^ ~n) ^ (1 / k) * (~a2 + ~b2 * (~x) ^ ~n) ^ (1 / k)))) <-- FreeQ([~a1, ~b1, ~a2, ~b2, ~m, ~n], ~x) && (EqQ(~a2 * ~b1 + ~a1 * ~b2, 0) && (IntegerQ(~p + Simplify((~m + 1) / (2 * ~n))) && LtQ(-1, ~p, 0)))
    @apply_utils Antiderivative((~c * ~x) ^ ~m * (~a + ~(b') * (~x) ^ ~n) ^ ~p, ~x) => (((~c) ^ IntPart(~m) * (~c * ~x) ^ FracPart(~m)) / (~x) ^ FracPart(~m)) * Antiderivative((~x) ^ ~m * (~a + ~b * (~x) ^ ~n) ^ ~p, ~x) <-- FreeQ([~a, ~b, ~c, ~m, ~n], ~x) && (IntegerQ(~p + Simplify((~m + 1) / ~n)) && LtQ(-1, ~p, 0))
    @apply_utils Antiderivative((~c * ~x) ^ ~m * (~a1 + ~(b1') * (~x) ^ ~n) ^ ~p * (~a2 + ~(b2') * (~x) ^ ~n) ^ ~p, ~x) => (((~c) ^ IntPart(~m) * (~c * ~x) ^ FracPart(~m)) / (~x) ^ FracPart(~m)) * Antiderivative((~x) ^ ~m * (~a1 + ~b1 * (~x) ^ ~n) ^ ~p * (~a2 + ~b2 * (~x) ^ ~n) ^ ~p, ~x) <-- FreeQ([~a1, ~b1, ~a2, ~b2, ~c, ~m, ~n], ~x) && (EqQ(~a2 * ~b1 + ~a1 * ~b2, 0) && (IntegerQ(~p + Simplify((~m + 1) / (2 * ~n))) && LtQ(-1, ~p, 0)))
    @apply_utils Antiderivative((~(c') * ~x) ^ ~(m') * (~a + ~(b') * (~x) ^ ~n) ^ ~p, ~x) => (-((~c * ~x) ^ (~m + 1)) * (~a + ~b * (~x) ^ ~n) ^ (~p + 1)) / (~a * ~c * ~n * (~p + 1)) + ((~m + ~n * (~p + 1) + 1) / (~a * ~n * (~p + 1))) * Antiderivative((~c * ~x) ^ ~m * (~a + ~b * (~x) ^ ~n) ^ (~p + 1), ~x) <-- FreeQ([~a, ~b, ~c, ~m, ~n], ~x) && (IntegerQ(~p + Simplify((~m + 1) / ~n)) && LtQ(~p, -1))
    @apply_utils Antiderivative((~(c') * ~x) ^ ~(m') * (~a1 + ~(b1') * (~x) ^ ~n) ^ ~p * (~a2 + ~(b2') * (~x) ^ ~n) ^ ~p, ~x) => (-((~c * ~x) ^ (~m + 1)) * (~a1 + ~b1 * (~x) ^ ~n) ^ (~p + 1) * (~a2 + ~b2 * (~x) ^ ~n) ^ (~p + 1)) / (2 * ~a1 * ~a2 * ~c * ~n * (~p + 1)) + ((~m + 2 * ~n * (~p + 1) + 1) / (2 * ~a1 * ~a2 * ~n * (~p + 1))) * Antiderivative((~c * ~x) ^ ~m * (~a1 + ~b1 * (~x) ^ ~n) ^ (~p + 1) * (~a2 + ~b2 * (~x) ^ ~n) ^ (~p + 1), ~x) <-- FreeQ([~a1, ~b1, ~a2, ~b2, ~c, ~m, ~n], ~x) && (EqQ(~a2 * ~b1 + ~a1 * ~b2, 0) && (IntegerQ(~p + Simplify((~m + 1) / (2 * ~n))) && LtQ(~p, -1)))
    @apply_utils Antiderivative((~x) ^ ~(m') / (~a + ~(b') * (~x) ^ ~n), ~x) => With([mn = Simplify(~m - ~n)], (~x) ^ (mn + 1) / (~b * (mn + 1)) - (~a / ~b) * Antiderivative((~x) ^ mn / (~a + ~b * (~x) ^ ~n), ~x)) <-- FreeQ([~a, ~b, ~m, ~n], ~x) && (FractionQ(Simplify((~m + 1) / ~n)) && SumSimplerQ(~m, -(~n)))
    @apply_utils Antiderivative((~x) ^ ~m / (~a + ~(b') * (~x) ^ ~n), ~x) => (~x) ^ (~m + 1) / (~a * (~m + 1)) - (~b / ~a) * Antiderivative((~x) ^ Simplify(~m + ~n) / (~a + ~b * (~x) ^ ~n), ~x) <-- FreeQ([~a, ~b, ~m, ~n], ~x) && (FractionQ(Simplify((~m + 1) / ~n)) && SumSimplerQ(~m, ~n))
    @apply_utils Antiderivative((~c * ~x) ^ ~m / (~a + ~(b') * (~x) ^ ~n), ~x) => (((~c) ^ IntPart(~m) * (~c * ~x) ^ FracPart(~m)) / (~x) ^ FracPart(~m)) * Antiderivative((~x) ^ ~m / (~a + ~b * (~x) ^ ~n), ~x) <-- FreeQ([~a, ~b, ~c, ~m, ~n], ~x) && (FractionQ(Simplify((~m + 1) / ~n)) && (SumSimplerQ(~m, ~n) || SumSimplerQ(~m, -(~n))))
    @apply_utils Antiderivative((~(c') * ~x) ^ ~(m') * (~a + ~(b') * (~x) ^ ~n) ^ ~p, ~x) => (((~a) ^ ~p * (~c * ~x) ^ (~m + 1)) / (~c * (~m + 1))) * HypergeometricFunctions._₂F₁(-(~p), (~m + 1) / ~n, (~m + 1) / ~n + 1, (-(~b) * (~x) ^ ~n) / ~a) <-- FreeQ([~a, ~b, ~c, ~m, ~n, ~p], ~x) && (Not(IGtQ(~p, 0)) && (ILtQ(~p, 0) || GtQ(~a, 0)))
    #= Antiderivative(((~c')*(~x))^(~m')*((~a)+(~b')*(~x)^(~n))^(~p),~x) :=  (c*x)^(m+1)*(a+b*x^n)^(p+1)/(a*c*(m+1))*HypergeometricFunctions._₂F₁(1,(m+1)/n+p+ 1,(m+1)/n+1,-b*x^n/a) <-- FreeQ([a,b,c,m,n,p],x) && Not(IGtQ(p,0)) &&  Not(ILtQ(p,0) || GtQ(a,0)) =#
    @apply_utils Antiderivative((~(c') * ~x) ^ ~(m') * (~a + ~(b') * (~x) ^ ~n) ^ ~p, ~x) => (((~a) ^ IntPart(~p) * (~a + ~b * (~x) ^ ~n) ^ FracPart(~p)) / (1 + (~b * (~x) ^ ~n) / ~a) ^ FracPart(~p)) * Antiderivative((~c * ~x) ^ ~m * (1 + (~b * (~x) ^ ~n) / ~a) ^ ~p, ~x) <-- FreeQ([~a, ~b, ~c, ~m, ~n, ~p], ~x) && (Not(IGtQ(~p, 0)) && Not(ILtQ(~p, 0) || GtQ(~a, 0)))
    @apply_utils Antiderivative((~(c') * ~x) ^ ~(m') * (~a1 + ~(b1') * (~x) ^ ~n) ^ ~p * (~a2 + ~(b2') * (~x) ^ ~n) ^ ~p, ~x) => (((~a1 + ~b1 * (~x) ^ ~n) ^ FracPart(~p) * (~a2 + ~b2 * (~x) ^ ~n) ^ FracPart(~p)) / (~a1 * ~a2 + ~b1 * ~b2 * (~x) ^ (2 * ~n)) ^ FracPart(~p)) * Antiderivative((~c * ~x) ^ ~m * (~a1 * ~a2 + ~b1 * ~b2 * (~x) ^ (2 * ~n)) ^ ~p, ~x) <-- FreeQ([~a1, ~b1, ~a2, ~b2, ~c, ~m, ~n, ~p], ~x) && (EqQ(~a2 * ~b1 + ~a1 * ~b2, 0) && Not(IntegerQ(~p)))
    #= IntBinomialQ(a,b,c,n,m,p,x)*returns*True*iff*(c*x)^m*(a+b*x^n)^p  is*integrable*wrt*x*in*terms*of*non-hypergeometric*functions. =#IntBinomialQ((~a), (~b), (~c), (~n), (~m), (~p), (~x)) := IGtQ(p, 0) || RationalQ(m) && IntegersQ(n, 2*p) || IntegerQ((m + 1)/n + p) || (EqQ(n, 2) || EqQ(n, 4)) && IntegersQ(2*m, 4*p) || EqQ(n, 2) && IntegerQ(6*p) && (IntegerQ(m) || IntegerQ(m - p))
    @apply_utils Antiderivative((~(d') * ~x) ^ ~(m') * (~a + ~(b') * (~c * ~x) ^ ~n) ^ ~(p'), ~x) => (1 / ~c) * Subst(Antiderivative(((~d * ~x) / ~c) ^ ~m * (~a + ~b * (~x) ^ ~n) ^ ~p, ~x), ~x, ~c * ~x) <-- FreeQ([~a, ~b, ~c, ~d, ~m, ~n, ~p], ~x)
    @apply_utils Antiderivative((~(d') * ~x) ^ ~(m') * (~a + ~(b') * (~(c') * (~x) ^ ~q) ^ ~n) ^ ~(p'), ~x) => ((~d * ~x) ^ (~m + 1) / (~d * ((~c * (~x) ^ ~q) ^ (1 / ~q)) ^ (~m + 1))) * Subst(Antiderivative((~x) ^ ~m * (~a + ~b * (~x) ^ (~n * ~q)) ^ ~p, ~x), ~x, (~c * (~x) ^ ~q) ^ (1 / ~q)) <-- FreeQ([~a, ~b, ~c, ~d, ~m, ~n, ~p, ~q], ~x) && (IntegerQ(~n * ~q) && NeQ(~x, (~c * (~x) ^ ~q) ^ (1 / ~q)))
    @apply_utils Antiderivative((~(d') * ~x) ^ ~(m') * (~a + ~(b') * (~(c') * (~x) ^ ~q) ^ ~n) ^ ~(p'), ~x) => With([k = Denominator(~n)], Subst(Antiderivative((~d * ~x) ^ ~m * (~a + ~b * (~c) ^ ~n * (~x) ^ (~n * ~q)) ^ ~p, ~x), (~x) ^ (1 / k), (~c * (~x) ^ ~q) ^ (1 / k) / ((~c) ^ (1 / k) * ((~x) ^ (1 / k)) ^ (~q - 1)))) <-- FreeQ([~a, ~b, ~c, ~d, ~m, ~p, ~q], ~x) && FractionQ(~n)
    @apply_utils Antiderivative((~(d') * ~x) ^ ~(m') * (~a + ~(b') * (~(c') * (~x) ^ ~q) ^ ~n) ^ ~(p'), ~x) => Subst(Antiderivative((~d * ~x) ^ ~m * (~a + ~b * (~c) ^ ~n * (~x) ^ (~n * ~q)) ^ ~p, ~x), (~x) ^ (~n * ~q), (~c * (~x) ^ ~q) ^ ~n / (~c) ^ ~n) <-- FreeQ([~a, ~b, ~c, ~d, ~m, ~n, ~p, ~q], ~x) && Not(RationalQ(~n))
    @apply_utils Antiderivative((~x) ^ ~(m') * (~a + ~(b') * (~v) ^ ~n) ^ ~(p'), ~x) => With([c = Coefficient(~v, ~x, 0), d = Coefficient(~v, ~x, 1)], (1 / d ^ (~m + 1)) * Subst(Antiderivative(SimplifyIntegrand((~x - c) ^ ~m * (~a + ~b * (~x) ^ ~n) ^ ~p, ~x), ~x), ~x, ~v) <-- NeQ(c, 0)) <-- FreeQ([~a, ~b, ~n, ~p], ~x) && (LinearQ(~v, ~x) && IntegerQ(~m))
    @apply_utils Antiderivative((~u) ^ ~(m') * (~a + ~(b') * (~v) ^ ~n) ^ ~(p'), ~x) => ((~u) ^ ~m / (Coefficient(~v, ~x, 1) * (~v) ^ ~m)) * Subst(Antiderivative((~x) ^ ~m * (~a + ~b * (~x) ^ ~n) ^ ~p, ~x), ~x, ~v) <-- FreeQ([~a, ~b, ~m, ~n, ~p], ~x) && LinearPairQ(~u, ~v, ~x)
end

max_stars_repo_path: src/rules/1 Algebraic functions/1.1 Binomial products/1.1.3 General/1.1.3.2 (c x)^m (a+b x^n)^p.jl


text:
X, y = generateclassdata(ClassData(:tri, 5, 5, 5))
wt = wavelet(WT.haar)

# AsymmetricRelativeEntropy + TimeFrequency + BasisDiscriminantMeasure
f = LocalDiscriminantBasis(wt=wt, max_dec_level=4, top_k=5, n_features=5)
@test typeof(f) == LocalDiscriminantBasis
@test_nowarn fit_transform(f, X, y)
@test_nowarn fit!(f, X, y)
@test_nowarn transform(f, X)
Xc = transform(f, X)
@test size(Xc) == (5,15)
@test_nowarn inverse_transform(f, Xc)
X̂ = inverse_transform(f, Xc)
@test size(X̂) == (32, 15)

# SymmetricRelativeEntropy + TimeFrequency + FishersClassSeparability
f = LocalDiscriminantBasis(wt=wt, max_dec_level=4, dm=SymmetricRelativeEntropy(),
    dp=FishersClassSeparability(), top_k=5, n_features=5)
@test typeof(f) == LocalDiscriminantBasis
@test_nowarn fit_transform(f, X, y)
@test_nowarn fit!(f, X, y)
@test_nowarn transform(f, X)
Xc = transform(f, X)
@test size(Xc) == (5,15)
@test_nowarn inverse_transform(f, Xc)
X̂ = inverse_transform(f, Xc)
@test size(X̂) == (32, 15)

# LpDistance + TimeFrequency + RobustFishersClassSeparability
f = LocalDiscriminantBasis(wt=wt, max_dec_level=4, dm=LpDistance(),
    dp=RobustFishersClassSeparability(), top_k=5, n_features=5)
@test typeof(f) == LocalDiscriminantBasis
@test_nowarn fit_transform(f, X, y)
@test_nowarn fit!(f, X, y)
@test_nowarn transform(f, X)
Xc = transform(f, X)
@test size(Xc) == (5,15)
@test_nowarn inverse_transform(f, Xc)
X̂ = inverse_transform(f, Xc)
@test size(X̂) == (32, 15)

# HellingerDistance + ProbabilityDensity + BasisDiscriminantMeasure
f = LocalDiscriminantBasis(wt=wt, max_dec_level=4, dm=HellingerDistance(),
    en=ProbabilityDensity(), top_k=5, n_features=5)
@test typeof(f) == LocalDiscriminantBasis
@test_nowarn fit_transform(f, X, y)
@test_nowarn fit!(f, X, y)
@test_nowarn transform(f, X)
Xc = transform(f, X)
@test size(Xc) == (5,15)
@test_nowarn inverse_transform(f, Xc)
X̂ = inverse_transform(f, Xc)
@test size(X̂) == (32, 15)

# EarthMoverDistance + Signatures(equal weight) + BasisDiscriminantMeasure
f = LocalDiscriminantBasis(wt=wt, max_dec_level=4, dm=EarthMoverDistance(),
    en=Signatures(:equal), top_k=5, n_features=5)
@test typeof(f) == LocalDiscriminantBasis
@test_nowarn fit_transform(f, X, y)
@test_nowarn fit!(f, X, y)
@test_nowarn transform(f, X)
Xc = transform(f, X)
@test size(Xc) == (5,15)
@test_nowarn inverse_transform(f, Xc)
X̂ = inverse_transform(f, Xc)
@test size(X̂) == (32, 15)

# EarthMoverDistance + Signatures(pdf weight) + BasisDiscriminantMeasure
f = LocalDiscriminantBasis(wt=wt, max_dec_level=4, dm=EarthMoverDistance(),
    en=Signatures(:pdf), top_k=5, n_features=5)
@test typeof(f) == LocalDiscriminantBasis
@test_nowarn fit_transform(f, X, y)
@test_nowarn fit!(f, X, y)
@test_nowarn transform(f, X)
Xc = transform(f, X)
@test size(Xc) == (5,15)
@test_nowarn inverse_transform(f, Xc)
X̂ = inverse_transform(f, Xc)
@test size(X̂) == (32, 15)

# change number of features
@test_nowarn change_nfeatures(f, Xc, 5)
x = change_nfeatures(f, Xc, 5)
@test size(x) == (5, 15)
@test_logs (:warn, "Proposed n_features larger than currently saved n_features. Results will be less accurate since inverse_transform and transform is involved.") change_nfeatures(f, Xc, 10)
@test_throws ArgumentError change_nfeatures(f, Xc, 10)

ext: jl


text:
__precompile__
using PyPlot

struct Plotting
    settings::Settings;
    basis::Basis;
    xQuad::Array{Float64,1};
    x::Array{Float64,1}
    tEnd::Float64;
    q::Quadrature;

    function Plotting(settings::Settings,basis::Basis,quadrature::Quadrature,tEnd::Float64)
        new(settings,basis,quadrature.xi,settings.x,tEnd,quadrature);
    end
end

function PlotInX(obj::Plotting,s::Int,u::Array{Float64,3},xi::Array{Float64,1})
    Nq = obj.settings.Nq;
    Nx = obj.settings.Nx;
    NxFine = 1000;
    xFine = range(obj.settings.a,obj.settings.b,length =NxFine)

    uExact = zeros(NxFine);
    uPlot = zeros(Nx);

    # start plot
    fig, ax = subplots(figsize=(15, 8), dpi=100)#, facecolor='w', edgecolor='k') # dpi Aufloesung
    for k = 1:length(xi)
        for j = 1:Nx
            tmp = Eval(obj.basis,u[:,s,j],xi[k]);
            uPlot[j] = tmp[1];
        end
        #for j = 1:NxFine
            #uExact[j] = obj.settings.solutionExact(obj.tEnd,xFine[j],xi[k])[1];
        #end
        ax.plot(obj.x,uPlot, "r--", linewidth=2, label=L"$u_{N}$", alpha=0.6)
        #ax.plot(xFine,uExact, "k-", linewidth=2, label=L"$u_{ex}$", alpha=0.6)
    end
    #ylimMinus = -2.0;
    #ylimPlus = 15.0
    #ax[:set_ylim]([ylimMinus,ylimPlus])
    ax.set_xlim([obj.settings.a,obj.settings.b])
    ax.set_xlabel("x", fontsize=20);

end

function meshgrid(x, y)
    X = [i for i in x, j in 1:length(y)]
    Y = [j for i in 1:length(x), j in y]
    return X, Y
end

function PlotInXi(obj::Plotting,u::Array{Float64,2},index::Int,info::String)
    Nq = obj.settings.Nq;
    Nx = obj.settings.Nx;
    NxiFine = 500;
    xiFine = range(-1,1,length =NxiFine);
    uExact = zeros(NxiFine,NxiFine);
    uPlot = zeros(NxiFine,NxiFine);

    for k = 1:NxiFine
        for q = 1:NxiFine
            tmp = Eval(obj.basis,u[:,index],xiFine[k],xiFine[q]);
            uPlot[k,q] = tmp[1];

            uExact[k,q] = obj.settings.solutionExact(obj.tEnd,obj.settings.x[index],xiFine[k],xiFine[q])[1];;#obj.settings.solutionExact(obj.tEnd,obj.x[index],xiFine[k])[1];
        end
    end

    # start plot
    fig = figure(info,figsize=(9,8)) # Create a figure and save its handle
    ax = gca()
    xgrid, ygrid = meshgrid(xiFine, xiFine)
    surf(xgrid, ygrid, uPlot', cmap=ColorMap("viridis"), alpha=0.7)
    tick_params(labelsize=12)
    xlabel(L"\xi_1", fontsize=15)
    ylabel(L"\xi_2", fontsize=15)
    tight_layout()

    #PyPlot.savefig("results/PlotXi$(info)Nx$(Nx)N$(obj.settings.N)tEnd$(obj.settings.tEnd).png")

    fig = figure("Figure4c",figsize=(9,8)) # Create a figure and save its handle

    xgrid, ygrid = meshgrid(xiFine, xiFine)
    surf(xgrid, ygrid, uExact, rstride=2, cstride=2, cmap=ColorMap("viridis"), alpha=0.7)
    tick_params(labelsize=12)
    xlabel(L"\xi_1", fontsize=15)
    ylabel(L"\xi_2", fontsize=15)
    #ax.set_zlabel('u')
    tight_layout()
    plt.draw()
    #PyPlot.savefig("results/PlotXiExactX$(obj.settings.x[index]).png")
    #zlim(-0.5, 1.0)

end

function ComparePlotInXi(obj::Plotting,s::Int,u::Array{Float64,3},uL1::Array{Float64,3},v::Array{Float64,3},index::Int)
    Nq = obj.settings.Nq;
    Nx = obj.settings.Nx;
    NxiFine = 100;
    xiFine = range(-1,1,length=NxiFine)
    uExact = zeros(NxiFine);
    uPlot = zeros(NxiFine);
    uL1Plot = zeros(NxiFine);
    vPlot = zeros(NxiFine);

    # start plot
    fig, ax = subplots(figsize=(15, 8), dpi=100)#, facecolor='w', edgecolor='k') # dpi Aufloesung
    if s == 1
        title(L"$\rho$", fontsize=20)
    elseif s == 2
        title(L"$\rho v$", fontsize=20)
    else
        title(L"$\rho e$", fontsize=20)
    end
    for k = 1:NxiFine
        vVals = Eval(obj.basis,v[:,:,index],xiFine[k])'
        tmp = UKin(obj.closure,vVals[:,1]);
        vPlot[k] = tmp[s];
        tmp = Eval(obj.basis,u[:,s,index],xiFine[k]);
        uPlot[k] = tmp[1];
        tmp = Eval(obj.basis,uL1[:,s,index],xiFine[k]);
        uL1Plot[k] = tmp[1];
        data_rho,data_u,data_P,data_e = obj.settings.solutionExact(obj.tEnd,obj.x[index],xiFine[k]);
        if s == 1
            uExact[k] = data_rho[1];
        elseif s == 2
            uExact[k] = data_rho[1]*data_u[1];
        else
            uExact[k] = data_rho[1]*data_e[1];
        end
    end

    ax.plot(xiFine,uPlot, "r:", linewidth=2, label="SG", alpha=0.6)
    ax.plot(xiFine,uL1Plot, "g--", linewidth=2, label="L1", alpha=0.6)
    ax.plot(xiFine,vPlot, "b-.", linewidth=2, label="IPM", alpha=0.6)
    ax.plot(xiFine,uExact, "k-", linewidth=2, label="exact", alpha=0.6)
    ax.set_xlim([-1.0,1.0])
    ax.tick_params("both",labelsize=20)
    ax.set_xlabel(L"\xi", fontsize=20);
    ax.legend(loc="upper left", fontsize=20)
    PyPlot.savefig("results/PlotXiState$(s)Nx$(Nx)N$(obj.settings.N)tEnd$(obj.settings.tEnd)Sigma$(obj.settings.sigma).png")
end

function PlotExpectedValue(obj::Plotting,u::Array{Float64,2})
    Nq = obj.settings.Nq;
    Nx = obj.settings.Nx;
    NxFine = 1000;
    xFine = collect(range(obj.settings.a,obj.settings.b,length=NxFine))
    uExact = zeros(NxFine);
    varExact = zeros(NxFine);
    uPlot = zeros(Nx);
    varPlot = zeros(Nx);

    # start plot
    fig, ax = subplots(figsize=(15, 8), dpi=100)#, facecolor='w', edgecolor='k') # dpi Aufloesung

    for j = 1:Nx
        uVals = EvalAtQuad(obj.basis,u[:,j]);
        uPlot[j] = Integral(obj.q,uVals*0.25);
        varPlot[j] = Integral(obj.q,0.25*(uVals.-uPlot[j]).^2);
    end
    varMax = maximum(varPlot);
    expMax = maximum(uPlot);
    qFine = Quadrature(200,"Gauss")
    exactState = zeros(NxFine,qFine.Nq,qFine.Nq);
    for j = 1:NxFine
        for k = 1:qFine.Nq
            for l = 1:qFine.Nq
                exactState[j,k,l] = obj.settings.solutionExact(obj.tEnd,xFine[j],qFine.xi[k],qFine.xi[l])[1];
            end
        end
    end
    for j = 1:NxFine
        for k = 1:qFine.Nq
            for l = 1:qFine.Nq
                uExact[j] += exactState[j,k,l]*0.25*qFine.w[k]*qFine.w[l];
            end
        end
        for k = 1:qFine.Nq
            for l = 1:qFine.Nq
                varExact[j] += (exactState[j,k,l]-uExact[j])^2 * 0.25*qFine.w[k]*qFine.w[l];
            end
        end
    end
    ax.plot(obj.x,uPlot, "k--", linewidth=2, label=L"$E[u_{N}]$", alpha=0.6)
    ax.plot(xFine,uExact, "r-", linewidth=2, label=L"$E[u_{ex}]$", alpha=0.6)
    ylabel("Expectation Value", fontsize=20,color="red")
    ax2 = ax[:twinx]() # Create another axis on top of the current axis
    font2 = ["color"=>"blue"]
    ylabel("Standard deviation", fontsize=20,color="blue")
    ax2.plot(obj.x,sqrt.(varPlot), "k--", linewidth=2, label=L"$V[u_{N}]$", alpha=0.6)
    ax2.plot(xFine,sqrt.(varExact), "b-", linewidth=2, label=L"$V[u_{ex}]$", alpha=0.6)
    setp(ax2[:get_yticklabels](),color="blue") # Y Axis font formatting
    setp(ax[:get_yticklabels](),color="red")
    ax.set_xlim([obj.settings.a,obj.settings.b])
    ax.set_xlabel("x", fontsize=20);
    ax.tick_params("both",labelsize=20)
    ax2[:tick_params]("both",labelsize=20)
    fig[:canvas][:draw]() # Update the figure
    PyPlot.savefig("test.png")
end

function PlotExpectedValue(obj::Plotting,u::Array{Float64,2},v::Array{Float64,2},info::String="")
    Nq = obj.settings.Nq;
    Nx = obj.settings.Nx;
    NxFine = 1000;
    xFine = collect(range(obj.settings.a,obj.settings.b,length=NxFine))
    uExact = zeros(NxFine);
    varExact = zeros(NxFine);
    uPlot = zeros(Nx);
    varPlot = zeros(Nx);
    vPlot = zeros(Nx);
    varVPlot = zeros(Nx);

    # start plot
    fig, ax = subplots(figsize=(15, 8), dpi=100)#, facecolor='w', edgecolor='k') # dpi Aufloesung

    for j = 1:Nx
        uVals = EvalAtQuad(obj.basis,u[:,j]);
        uPlot[j] = Integral(obj.q,uVals*0.25);
        varPlot[j] = Integral(obj.q,0.25*(uVals.-uPlot[j]).^2);
        vVals = EvalAtQuad(obj.basis,v[:,j]);
        vPlot[j] = Integral(obj.q,vVals*0.25);
        varVPlot[j] = Integral(obj.q,0.25*(vVals.-vPlot[j]).^2);
    end
    varMax = maximum(varPlot);
    expMax = maximum(uPlot);
    qFine = Quadrature(200,"Gauss")
    exactState = zeros(NxFine,qFine.Nq,qFine.Nq);
    for j = 1:NxFine
        for k = 1:qFine.Nq
            for l = 1:qFine.Nq
                exactState[j,k,l] = obj.settings.solutionExact(obj.tEnd,xFine[j],qFine.xi[k],qFine.xi[l])[1];
            end
        end
    end
    for j = 1:NxFine
        for k = 1:qFine.Nq
            for l = 1:qFine.Nq
                uExact[j] += exactState[j,k,l]*0.25*qFine.w[k]*qFine.w[l];
            end
        end
        for k = 1:qFine.Nq
            for l = 1:qFine.Nq
                varExact[j] += (exactState[j,k,l]-uExact[j])^2 * 0.25*qFine.w[k]*qFine.w[l];
            end
        end
    end
    ax.plot(obj.x,uPlot, "g-.", linewidth=2, label=L"DLRA$_9$", alpha=1.0)
    ax.plot(obj.x,vPlot, "m:", linewidth=2, label=L"unconventional DLRA$_9$", alpha=1.0)
    ylabel("Expectation", fontsize=20,color="red")
    ax.plot(xFine,uExact, "r-", linewidth=2, alpha=0.5)
    ax2 = ax[:twinx]() # Create another axis on top of the current axis
    ylabel("Standard deviation", fontsize=20,color="blue")
    ax2.plot(obj.x,sqrt.(varPlot), "g-.", linewidth=2, label="SG", alpha=1.0)
    ax2.plot(obj.x,sqrt.(varVPlot), "m:", linewidth=2, label="DLRA", alpha=1.0)
    #ax2[:set_position](new_position) # Position Method 2
    setp(ax2[:get_yticklabels](),color="blue") # Y Axis font formatting
    setp(ax[:get_yticklabels](),color="red")
    ax2.plot(xFine,sqrt.(varExact), "b-", linewidth=2, alpha=0.5)
    #ylimMinus = -0.5;
    #ylimPlus = 16.0
    #ax[:set_ylim]([ylimMinus,ylimPlus])
    ax.set_xlim([obj.settings.a,obj.settings.b])
    ax.set_xlabel("x", fontsize=20);
    ax.legend(loc="upper right", fontsize=20)
    ax.tick_params("both",labelsize=20)
    ax2.tick_params("both",labelsize=20)
    fig.canvas.draw() # Update the figure
    PyPlot.savefig("results/ExpectedValueVar2D$(info)Nx$(Nx)N$(obj.settings.N)tEnd$(obj.settings.tEnd)r$(obj.settings.r)lambda$(s.lambda).png")
end

function PlotExpectedValue(obj::Plotting,u::Array{Float64,2},v::Array{Float64,2},w::Array{Float64,2},info::String="",figlabel::String="")
    Nq = obj.settings.Nq;
    Nx = obj.settings.Nx;
    NxFine = 1000;
    xFine = collect(range(obj.settings.a,obj.settings.b,length=NxFine))
    uExact = zeros(NxFine);
    varExact = zeros(NxFine);
    uPlot = zeros(Nx);
    varPlot = zeros(Nx);
    vPlot = zeros(Nx);
    varVPlot = zeros(Nx);
    wPlot = zeros(Nx);
    varWPlot = zeros(Nx);

    # start plot
    fig = figure(figlabel,figsize=(15, 8), dpi=100)#, facecolor='w', edgecolor='k') # dpi Aufloesung
    ax = gca()
    for j = 1:Nx
        uVals = EvalAtQuad(obj.basis,u[:,j]);
        uPlot[j] = Integral(obj.q,uVals*0.25);
        varPlot[j] = Integral(obj.q,0.25*(uVals.-uPlot[j]).^2);
        vVals = EvalAtQuad(obj.basis,v[:,j]);
        vPlot[j] = Integral(obj.q,vVals*0.25);
        varVPlot[j] = Integral(obj.q,0.25*(vVals.-vPlot[j]).^2);
        wVals = EvalAtQuad(obj.basis,w[:,j]);
        wPlot[j] = Integral(obj.q,wVals*0.25);
        varWPlot[j] = Integral(obj.q,0.25*(wVals.-wPlot[j]).^2);
    end
    varMax = maximum(varPlot);
    expMax = maximum(uPlot);
    qFine = Quadrature(200,"Gauss")
    exactState = zeros(NxFine,qFine.Nq,qFine.Nq);
    for j = 1:NxFine
        for k = 1:qFine.Nq
            for l = 1:qFine.Nq
                exactState[j,k,l] = obj.settings.solutionExact(obj.tEnd,xFine[j],qFine.xi[k],qFine.xi[l])[1];
            end
        end
    end
    for j = 1:NxFine
        for k = 1:qFine.Nq
            for l = 1:qFine.Nq
                uExact[j] += exactState[j,k,l]*0.25*qFine.w[k]*qFine.w[l];
            end
        end
        for k = 1:qFine.Nq
            for l = 1:qFine.Nq
                varExact[j] += (exactState[j,k,l]-uExact[j])^2 * 0.25*qFine.w[k]*qFine.w[l];
            end
        end
    end
    if info == "noFilter"
        ax.plot(obj.x,uPlot, "k--", linewidth=2, label=L"SG$_{100}$", alpha=1.0)
        ax.plot(obj.x,vPlot, "g-.", linewidth=2, label=L"DLRA$_{9}$", alpha=1.0)
        ax.plot(obj.x,wPlot, "m:", linewidth=2, label=L"unconventional DLRA$_{9}$", alpha=1.0)
    else
        ax.plot(obj.x,uPlot, "k--", linewidth=2, label=L"fSG$_{100}$", alpha=1.0)
        ax.plot(obj.x,vPlot, "g-.", linewidth=2, label=L"fDLRA$_{9}$", alpha=1.0)
        ax.plot(obj.x,wPlot, "m:", linewidth=2, label=L"unconventional fDLRA$_{9}$", alpha=1.0)
    end

    ylabel("Expectation", fontsize=20,color="red")
    ax.plot(xFine,uExact, "r-", linewidth=2, alpha=0.5)
    ax2 = ax[:twinx]() # Create another axis on top of the current axis
    ylabel("Standard deviation", fontsize=20,color="blue")
    ax2.plot(obj.x,sqrt.(varPlot), "k--", linewidth=2, label="SG", alpha=1.0)
    ax2.plot(obj.x,sqrt.(varVPlot), "g-.", linewidth=2, label="DLRA", alpha=1.0)
    ax2.plot(obj.x,sqrt.(varWPlot), "m:", linewidth=2, label="unconventional DLRA", alpha=1.0)
    #ax2[:set_position](new_position) # Position Method 2
    setp(ax2[:get_yticklabels](),color="blue") # Y Axis font formatting
    setp(ax[:get_yticklabels](),color="red")
    ax2.plot(xFine,sqrt.(varExact), "b-", linewidth=2, alpha=0.5)
    #ylimMinus = -0.5;
    #ylimPlus = 16.0
    #ax[:set_ylim]([ylimMinus,ylimPlus])
    ax.set_xlim([obj.settings.a,obj.settings.b])
    ax.set_xlabel("x", fontsize=20);
    ax.legend(loc="upper right", fontsize=20)
    ax.tick_params("both",labelsize=20)
    ax2.tick_params("both",labelsize=20)
    fig.canvas.draw() # Update the figure
    #PyPlot.savefig("results/ExpectedValueVar2D$(info)Nx$(Nx)N$(obj.settings.N)tEnd$(obj.settings.tEnd)r$(obj.settings.r)lambda$(s.lambda).png")
end

function CompareExpectedValue(obj::Plotting,s::Int,u::Array{Float64,3},uL1::Array{Float64,3},v::Array{Float64,3},x)
    Nq = obj.settings.Nq;
    Nx = length(x);
    NxFine = 1000;
    xFine = range(obj.settings.a,obj.settings.b,length=NxFine)
    uExact = zeros(NxFine);
    varExact = zeros(NxFine);
    uPlot = zeros(Nx);
    varPlot = zeros(Nx);
    vPlot = zeros(Nx);
    varVPlot = zeros(Nx);
    uL1Plot = zeros(Nx);
    varL1Plot = zeros(Nx);

    # start plot
    fig, ax = subplots(figsize=(15, 8), dpi=100)#, facecolor='w', edgecolor='k') # dpi Aufloesung
    if s == 1
        title(L"$\rho$", fontsize=20)
    elseif s == 2
        title(L"$\rho v$", fontsize=20)
    else
        title(L"$\rho e$", fontsize=20)
    end

    for j = 1:Nx
        uPlot[j] = u[1,s,j];
        varPlot[j] = u[2:end,s,j]'u[2:end,s,j];
        uL1Plot[j] = uL1[1,s,j];
        varL1Plot[j] = uL1[2:end,s,j]'uL1[2:end,s,j];
        uVals = UKin(obj.closure,EvalAtQuad(obj.basis,v[:,:,j]));
        vPlot[j] = IntegralVec(obj.q,uVals[:,s]*0.5);
        varVPlot[j] = IntegralVec(obj.q,0.5*(uVals[:,s]-uPlot[j]).^2);
    end
    varMax = maximum(varPlot);
    expMax = maximum(uPlot);

    qFine = Quadrature(300,"Gauss")
    exactState = zeros(NxFine,qFine.Nq);
    for k = 1:qFine.Nq
        #data_rho,data_u,data_P,data_e = analytic_sod(obj.tEnd,obj.settings.x0,obj.settings.rhoL,obj.settings.pL,obj.settings.uL,obj.settings.rhoR,
        #                                obj.settings.pR,obj.settings.uR,obj.settings.gamma,xFine);
        data_rho,data_u,data_P,data_e = obj.settings.solutionExact(obj.tEnd,xFine,qFine.xi[k]);
        if s == 1
            exactState[:,k] = data_rho;
        elseif s == 2
            exactState[:,k] = data_rho.*data_u;
        else
            exactState[:,k] = data_rho.*data_e;
        end
    end
    for j = 1:NxFine
        uExact[j] = IntegralVec(qFine, exactState[j,:]*0.5,-1.0,1.0);
        varExact[j] = IntegralVec(qFine, (exactState[j,:].-uExact[j]).^2*0.5,-1.0,1.0)
    end

    ax.plot(x,uPlot, "y--", linewidth=2, label="SG", alpha=1.0)
    ax.plot(x,uL1Plot, "k-.", linewidth=2, label="L1", alpha=1.0)
    ax.plot(x,vPlot, "g-", linewidth=2, label="IPM", alpha=1.0)
    ylabel("Expectation", fontsize=20,color="red")
    ax.plot(xFine,uExact, "r:", linewidth=2, alpha=1.0)
    ax2 = ax[:twinx]() # Create another axis on top of the current axis
    ylabel("Standard deviation", fontsize=20,color="blue")
    ax2.plot(x,sqrt.(varPlot), "y--", linewidth=2, label="SG", alpha=1.0)
    ax2.plot(x,sqrt.(varL1Plot), "k-.", linewidth=2, label="SG", alpha=1.0)
    ax2.plot(x,sqrt.(varVPlot), "g-", linewidth=2, label="IPM", alpha=1.0)
    #ax2[:set_position](new_position) # Position Method 2
    setp(ax2[:get_yticklabels](),color="blue") # Y Axis font formatting
    setp(ax[:get_yticklabels](),color="red")
    ax2.plot(xFine,varExact, "b:", linewidth=2, alpha=1.0)
    #ylimMinus = -0.5;
    #ylimPlus = 16.0
    #ax[:set_ylim]([ylimMinus,ylimPlus])
    ax.set_xlim([obj.settings.a,obj.settings.b])
    ax.set_xlabel("x", fontsize=20);
    ax.legend(loc="upper right", fontsize=20)
    ax.tick_params("both",labelsize=20)
    ax2[:tick_params]("both",labelsize=20)
    fig[:canvas][:draw]() # Update the figure
    PyPlot.savefig("results/PlotXiState$(s)Nx$(Nx)N$(obj.settings.N)tEnd$(obj.settings.tEnd)Sigma$(obj.settings.sigma).png")
end

function PlotExactSolution(obj::Plotting,s::Int,xi::Float64)
    NxFine = 1000;
    xFine = range(obj.settings.a,obj.settings.b,length=NxFine)
    uExact = zeros(NxFine);
    for j = 1:NxFine
        data_rho,data_u,data_P,data_e = obj.settings.solutionExact(obj.tEnd,xFine[j],xi);
        uExact[j] = data_rho[1];
    end
    fig, ax = subplots(figsize=(15, 8), dpi=100)
    ax.plot(xFine,uExact, "r-", linewidth=2, alpha=0.6)
end

function L2Error(obj::Plotting,u::Array{Float64,2},t::Float64)
    Nx = obj.settings.Nx;
    x = obj.settings.x;
    error = 0;
    for j = 1:Nx
        error = error + obj.settings.dx*Integral(obj.q, xi-> 0.5*( obj.settings.solutionExact(t,x[j],xi)-Eval(obj.basis,u[j,:],xi)).^2,-1.0,1.0)
    end
    return sqrt(error);
end

function L1Error(obj::Plotting,u::Array{Float64,2},t::Float64)
    Nx = obj.settings.Nx;
    x = obj.settings.x;
    error = 0;
    for j = 1:Nx
        error = error + obj.settings.dx*Integral(obj.q, xi-> 0.5*abs.( obj.settings.solutionExact(t,x[j],xi)-Eval(obj.basis,u[j,:],xi)),-1.0,1.0)
    end
    return error;
end

function L2ErrorExpVar(obj::Plotting,u::Array{Float64,2})
    Nx = obj.settings.Nx;
    x = obj.settings.x;
    errorExp = 0.0;
    errorVar = 0.0;
    Exp = 0.0;
    Var = 0.0;

    qFine = Quadrature(200,"Gauss")
    exactState = zeros(Nx,qFine.Nq,qFine.Nq);
    uExact = zeros(Nx);
    varExact = zeros(Nx);
    for j = 1:Nx
        for k = 1:qFine.Nq
            for l = 1:qFine.Nq
                exactState[j,k,l] = obj.settings.solutionExact(obj.tEnd,x[j],qFine.xi[k],qFine.xi[l])[1];
            end
        end
        for k = 1:qFine.Nq
            for l = 1:qFine.Nq
                uExact[j] += exactState[j,k,l]*0.25*qFine.w[k]*qFine.w[l];
            end
        end
        for k = 1:qFine.Nq
            for l = 1:qFine.Nq
                varExact[j] += (exactState[j,k,l]-uExact[j])^2 * 0.25*qFine.w[k]*qFine.w[l];
            end
        end
    end

    for j = 1:Nx
        uVals = EvalAtQuad(obj.basis,u[:,j]);
        expN = Integral(obj.q,uVals*0.25);
        varN = Integral(obj.q,0.25*(uVals.-expN).^2);
        expEx = uExact[j];
        varEx = varExact[j];
        errorExp = errorExp + obj.settings.dx*(expEx-expN)^2;
        errorVar = errorVar + obj.settings.dx*(varEx-varN)^2;

        Exp = Exp + obj.settings.dx*(expEx)^2;
        Var = Var + obj.settings.dx*(varEx)^2;
    end
    return sqrt(errorExp)/Exp,sqrt(errorVar)/Var;
end

function L1ErrorExpVar(obj::Plotting,u::Array{Float64,2},t::Float64)
    Nx = obj.settings.Nx;
    x = obj.settings.x;
    errorExp = 0.0;
    errorVar = 0.0;
    for j = 1:Nx
        expN = u[j,1];
        varN = u[j,2:end]'u[j,2:end];
        expEx = Integral(obj.q, xi-> obj.settings.solutionExact(obj.tEnd,x[j],xi)*0.5,-1.0,1.0)
        varEx = Integral(obj.q, xi-> (obj.settings.solutionExact(obj.tEnd,x[j],xi)-expEx).^2*0.5,-1.0,1.0);
        errorExp = errorExp + obj.settings.dx*abs(expEx-expN);
        errorVar = errorVar + obj.settings.dx*abs(varEx-varN);
    end
    return errorExp,errorVar;
end


text:
export iauEceq06
"""
Transformation from ecliptic coordinates (mean equinox and ecliptic
of date) to ICRS RA,Dec, using the IAU 2006 precession model.

This function is part of the International Astronomical Union's
SOFA (Standards of Fundamental Astronomy) software collection.

Status:  support function.

Given:
   date1,date2 double TT as a 2-part Julian date (Note 1)
   dl,db       double ecliptic longitude and latitude (radians)

Returned:
   dr,dd       double ICRS right ascension and declination (radians)

   1. The TT date date1+date2 is a Julian Date, apportioned in any
   convenient way between the two arguments.  For example,
   JD(TT)=2450123.7 could be expressed in any of these ways,
   among others:

         date1          date2

      2450123.7           0.0       (JD method)
      2451545.0       -1421.3       (J2000 method)
      2400000.5       50123.2       (MJD method)
      2450123.5           0.2       (date & time method)

   The JD method is the most natural and convenient to use in
   cases where the loss of several decimal digits of resolution
   is acceptable.  The J2000 method is best matched to the way
   the argument is handled internally and will deliver the
   optimum resolution.  The MJD method and the date & time methods
   are both good compromises between resolution and convenience.

   2. No assumptions are made about whether the coordinates represent
   starlight and embody astrometric effects such as parallax or
   aberration.

   3. The transformation is approximately that from ecliptic longitude
   and latitude (mean equinox and ecliptic of date) to mean J2000.0
   right ascension and declination, with only frame bias (always
   less than 25 mas) to disturb this classical picture.

Called:
   iauS2c       spherical coordinates to unit vector
   iauEcm06     J2000.0 to ecliptic rotation matrix, IAU 2006
   iauTrxp      product of transpose of r-matrix and p-vector
   iauC2s       unit vector to spherical coordinates
   iauAnp       normalize angle into range 0 to 2pi
   iauAnpm      normalize angle into range +/- pi

This revision:  2016 February 9

SOFA release 2018-01-30

Copyright (C) 2018 IAU SOFA Board.  See notes at end.
"""

# void iauEceq06(double date1, double date2, double dl, double db,
#                double *dr, double *dd)

function iauEceq06(date1::Real, date2::Real, dl::Real, db::Real)
   # Initialize function return variables
   ref_dr = Ref{Float64}(0.0)
   ref_dd = Ref{Float64}(0.0)

   ccall((:iauEceq06, libsofa_c), Cvoid,
         (Cdouble, Cdouble, Cdouble, Cdouble,
         Ref{Cdouble}, Ref{Cdouble}),
         convert(Float64, date1), convert(Float64, date2),
         convert(Float64, dl), convert(Float64, db),
         ref_dr, ref_dd)

   return ref_dr[], ref_dd[]
end


text:
using Potree

struct BinPoints
	x::Int32
	y::Int32
	z::Int32
	r::Int32
	g::Int32
	b::Int32
	a::Int32
end

function Base.read!(io::IO, ::Type{BinPoints})
    BinPoints(convert(Int32, (read(io,UInt8))),convert(Int32, (read(io,UInt8))),convert(Int32, (read(io,UInt8))),convert(Int32, (read(io,UInt8))),convert(Int32, (read(io,UInt8))),convert(Int32, (read(io,UInt8))),convert(Int32, (read(io,UInt8))))
end
fname = "C:/Users/Alessio/Documents/PotreeDirectory/pointclouds/scale_1.8/data/r/r40.bin"
fnamel = "C:/Users/Alessio/.julia/dev/Potree/potree/stairsLAS(v1.7)/data/r/r40.las"
io = open(fname, "r");

# while !eof(io)
#     hcat(points, read!(io, BinPoints))
# end

while !eof(io)
	@show read(io, UInt32)
	@show read(io, UInt32)
	@show read(io, UInt32)
	@show read(io, UInt8)
	@show read(io, UInt8)
	@show read(io, UInt8)
	@show read(io, UInt8)
end

@show las2larpoints(fnamel)
@show las2color(fnamel)

close(io)


text:
#=

  Euler #5 in Julia.

  Problem 5
  """
  2520 is the smallest number that can be divided by each of the numbers
  from 1 to 10 without any remainder.

  What is the smallest number that is evenly divisible by all of the numbers
  from 1 to 20?
  """

  This Julia program was created by Hakan Kjellerstrand, hakank@gmail.com
  See also my Julia page: http://www.hakank.org/julia/

=#

include("Euler.jl")

# 0.00000113s
function euler5a()
    a = 1
    for i in 2:20
        a = lcm(a,i)
    end
    return a
end

#
# 0.00000113s
function euler5b()
    return reduce(lcm,2:20)
end

#
function euler5c()
    return lcm(2:20)
end

run_euler(euler5a)
# run_euler(euler5b)
# run_euler(euler5c)

max_stars_repo_name: Wikunia/hakank

max_issues_repo_name: Wikunia/hakank

max_forks_repo_name: Wikunia/hakank


text:
# Plots and tables of the validation runs for Svalbard
using Missings, DataFrames, Measures
using Plots, StatPlots

saveyes = true
scaleyes = true

include("load-validation.jl")
#######
# Table helpers
include("../mustache-tables.jl")
#######
#
# use median absolute deviation MAD https://en.wikipedia.org/wiki/Median_absolute_deviation

function proc_validation(region,
                         out_fit, out_test, out_test_fitgls)
    # mean ice thicknesses
    scales = Dict(3=>235,
                  4=>172,
                  7=>210,
                  11=>68)
    scale = scaleyes ? scales[region] : 1

    fit_MAD = OrderedDict()
    fit_meanerr = OrderedDict()
    for ft in keys(out_fit)
        fit_MAD[ft] = [o[:abserr_h][:median] for o in out_fit[ft] if o isa Dict]./scale
        fit_meanerr[ft] = [o[:err_h][:mean] for o in out_fit[ft] if o isa Dict]./scale
    end

    test_MAD = OrderedDict()
    test_meanerr = OrderedDict()
    for k in keys(out_test)
        test_MAD[k] = [o[:abserr_h][:median] for o in out_test[k] if o isa Dict]./scale
        test_meanerr[k] = [o[:err_h][:mean] for o in out_test[k] if o isa Dict]./scale
    end

    test_fitgls_MAD = OrderedDict()
    test_fitgls_meanerr = OrderedDict()
    for k in keys(out_test_fitgls)
        test_fitgls_MAD[k] = [o[:abserr_h][:median] for o in out_test_fitgls[k] if o isa Dict]./scale
        test_fitgls_meanerr[k] = [o[:err_h][:mean] for o in out_test_fitgls[k] if o isa Dict]./scale
    end

    return fit_MAD, fit_meanerr, test_MAD, test_meanerr, test_fitgls_MAD, test_fitgls_meanerr
end

function plot_whiskers(labels, data::Vector; kwargs...)
    @assert length(labels)==length(data)

    labels = vcat([fill(l, length(d)) for (l,d) in zip(labels,data)]...)
    dat = vcat(data...)
    boxplot(labels, dat; sorted=false, label="", kwargs...)
end
function plot_whiskers(data::Associative; kwargs...)
    labels = map(string, keys(data))
    plot_whiskers(labels, collect(values(data)))
#     labels = vcat([fill(string(k), length(v)) for (k,v) in data]...)
#     dat = vcat(collect(values(data))...)
# #    dat = hcat([v[1:72] for v in  values(data)]...)
#     boxplot(labels, dat; kwargs...)
end

function plot_supplement(region,
                         fit_MAD, fit_meanerr, test_MAD, test_meanerr, test_fitgls_MAD, test_fitgls_meanerr)

    # labels = ["F:lh-", "F:lhv", "F:l-v", "F:l--", "P:---" , "P:lh-", "P:l-v",
    #           "P:lhv", "PF:---", "PF:lhv"]
    labels = ["C:lh-", "C:lhv", "C:l-v", "C:l--", "V:l--;\n  ---" , "V:l--;\n  lh-", "V:l--;\n  l-v",
              "V:l--;\n  lhv", "V:l-v;\n  ---", "V:l-v;\n  lhv"]

    p1 = plot_whiskers(labels, collect(values(merge(fit_MAD, test_MAD))),
                       xtickfontfamily="monospace", ylabel="norm. MAD (m)");

    fs = 20
    if region==7
        plot!([4,4],[-0.1,2.2], lc=:black, lw=2, label="", ls=:dash)
        annotate!(0.25, 350, text("A", fs))
    elseif region==11
        plot!([4,4],[-0.1,2.4], lc=:black, lw=2, label="", ls=:dash, ylims=(-0.1,2.4))
        annotate!(0.25, 120, text("A", fs))
    elseif region==4
        plot!([4,4],[-0.1,2.75], lc=:black, lw=2, label="", ls=:dash) #, ylims=(-5,150))
        annotate!(0.25, 120, text("A", fs))
    elseif region==3
        plot!([4,4],[-0.1,2.1], lc=:black, lw=2, label="", ls=:dash) #, ylims=(-5,150))
        annotate!(0.25, 120, text("A", fs))
    end

    p2 = plot_whiskers(labels, collect(values(merge(fit_meanerr, test_meanerr))),
                       ylabel="norm. ME (m)", xtickfontfamily="monospace");

    if region==7
        plot!([4,4],[-1.1,2.2], lc=:black, lw=2, label="", ls=:dash)
        annotate!(0.25, 350, text("B", fs))
    elseif region==11
        plot!([4,4],[-2,2.1], lc=:black, lw=2, label="", ls=:dash, ylims=(-2,2.1))
        annotate!(0.25, 100, text("B", fs))
    elseif region==4
        plot!([4,4],[-1.1,2.4], lc=:black, lw=2, label="", ls=:dash) #, ylims=(-105,120))
        annotate!(0.25, 100, text("B", fs))
    elseif region==3
        plot!([4,4],[-2,1.9], lc=:black, lw=2, label="", ls=:dash) #, ylims=(-105,120))
        annotate!(0.25, 100, text("B", fs))
    end

    plot!([0.4,9.6],[0,0], lc=:black, lw=1, label="", ls=:dash, alpha=0.5)

    p = plot(p1,p2, layout=grid(2,1), size=(700,700))

    saveyes && savefig("figs/all_error-$(VAWTools.int2str2(region)).png")
    saveyes && savefig("figs/all_error-$(int2str2(region)).pdf")
    return p
end

############
# For paper make the plot easier by showing less
############

# Following https://github.com/JuliaPlots/StatsPlots.jl/pull/192#issuecomment-430239298 and @macroexpand
# gives
# StatPlots.add_label([], boxplot, xlabels, yvalues, group=grouplabels)

# labels = OrderedDict("F:lh-" =>1,
#                      "F:lhv" => 2,
#                      "F:l-v" => 3,
#                      "F:l--" => 4,
#                      "P:---"  => 5,
#                      "P:lh-" => 6,
#                      "P:l-v" => 7,
#                      "P:lhv" => 8,
#                      "PF:---" => 9,
#                      "PF:lhv" => 10]

function plot_validation(region,
                         fit_MAD, fit_meanerr, test_MAD, test_meanerr, test_fitgls_MAD, test_fitgls_meanerr;
                         saveyes=saveyes)
    # (index into data, xlabel (fit-type), group (prior-type)
    labels = [(2, "lhv", "calibration"),
              (4, "l--", "calibration"),
              (3, "l-v", "calibration"),
              (8, "l--", "validation"),
              (10, "l-v", "validation")]

    # make long form
    data_MAD = collect(values(merge(fit_MAD, test_MAD)))
    data_ME = collect(values(merge(fit_meanerr, test_meanerr)))
    datas_MAD = Float64[]
    datas_ME = Float64[]
    groups = String[]
    xlabs = String[]
    for (i, x, g)  in labels
        len = length(data_MAD[i])
        @assert len==length(data_ME[i])
        append!(datas_MAD, data_MAD[i])
        append!(datas_ME, data_ME[i])
        append!(groups, fill(g, len))
        append!(xlabs, fill(x, len))
    end
    p1  = StatPlots.add_label([], boxplot, xlabs, datas_MAD, group=groups, sorted=false, xgrid=false,
                              xtickfontsize=14, ytickfontsize=12, guidefontsize=14);

    fs = 20
    fs_reg = 12
    left, right = 0.3, 2.8
    ss = ((0.0,2.25), (-1.5, 2.2))
    if region==3
        annotate!(left, scaleyes ? ss[1][2]*0.75 : 260, text("A", fs), ylabel="norm. MAD ()",ylims=ss[1], legend=:topleft, title="  Arctic Canada N. (03)") # three outliers ylims=(-10/scale,350/scale)
    elseif region==4
        annotate!(left, scaleyes ? ss[1][2]*0.9 : 320, text("B", fs), ylims=ss[1], legend=false, title="  Arctic Canada S. (04)")
    elseif region==7
        annotate!(left, scaleyes ? ss[1][2]*0.9 :370, text("C", fs), ylims=ss[1], legend=false, title="Svalbard (07)")
    elseif region==11
        annotate!(left, scaleyes ? ss[1][2]*0.9 :130, text("D", fs), ylims=ss[1], legend=false, title="  Central Europe (11)")  # one outlier , ylims=(-10/scale,155/scale)
    end

    p2 = StatPlots.add_label([], boxplot, xlabs, datas_ME, group=groups, sorted=false, xgrid=false,
                             legend=false, xtickfontsize=14, ytickfontsize=12,
                             guidefontsize=14);

    if region==03
        annotate!(left, scaleyes ? ss[2][2]*0.85 :260, text("E", fs), ylabel="norm. ME ()", ylims=ss[2], legend=false) # two outliers, ylims=(-300/scale,300/scale)
    elseif region==04
        annotate!(left, scaleyes ? ss[2][2]*0.85 :300, text("F", fs), ylims=ss[2], legend=false)
    elseif region==7
        annotate!(left, scaleyes ? ss[2][2]*0.85 :350, text("G", fs), ylims=ss[2], legend=false)
    elseif region==11
        annotate!(left, scaleyes ? ss[2][2]*0.85 :100, text("H", fs), ylims=ss[2], legend=false) # one outlier ylims=(-105/scale,140/scale)
    end
    # zero line
    plot!([0.4,2.8],[0,0], lc=:black, lw=1, label="", ls=:dash, alpha=0.5, right_margin=3.0mm, top_margin=3.0mm);

    label_region = if region==7
        "\nSvalbard (07)"
    elseif region==11
        "\nC. Europe (11)"
    elseif region==3
        "\nA. Canada N. (03)"
    elseif region==4
        "\nA. Canada S. (04)"
    end

    #plot!(twinx(p2), [NaN], [NaN], ylabel=label_region, grid=false, showaxis=false, legend=false)

    # # region
    # p3 = plot()
    # t = text("Svalbard (07)", fs_reg)
    # t.font.rotation = pi/2
    # annotate!(right+0.2, 100, t)

    fac=1.0
    p = plot(p1,p2, layout=grid(2,1)) #, size=(fac*300,fac*600));

    saveyes && savefig("figs/select-errors-$(VAWTools.int2str2(region)).png")
    saveyes && savefig("figs/select-errors-$(VAWTools.int2str2(region)).pdf")

    return p
end

if ~isdefined(:data_regions)
    data_regions = [load_validation(rs) for rs in ["03", "04", "07", "11"]]
    proc_regions = [proc_validation(rs, data...) for (rs,data) in zip([3, 4, 7, 11], data_regions)]
end

ps = []
for (r,pr) in zip([3, 4, 7, 11], proc_regions)
    push!(ps, plot_validation(r, pr...; saveyes=false))
end

plot(ps..., layout=grid(1,4), size=(1000, 600))
saveyes && savefig("figs/select-errors-all-regions.png")
saveyes && savefig("figs/select-errors-all-regions.pdf")

for (r,pr) in zip([3, 4, 7, 11], proc_regions)
    plot_supplement(r, pr...)
end


text:
using Test
using CDCS

# Dual:
# max x
# [1 x
#  y 1] ⪰ 0
# which is transformed by SeDuMi into
# max x
# [    1   (x+y)/2
#  (x+y)/2     1  ] ⪰ 0
# Which is unbounded with the unbounded the ray (1, -1).
@testset "Semidefinite Programming example" begin
    @testset "Bounded" begin
        # We add y ≥ 0 to make it bounded, Now the optimal solution is `(2, 0)`
        # with the matrix [1 1
        #                  1 1] of eigenvalues (0, 2).
        A = -[0.0 0.0 0.0 1.0 0.0
              1.0 0.0 1.0 0.0 0.0]
        b = [1.0, 0.0]
        c = [0.0, 1.0, 0.0, 0.0, 1.0]
        primal, dual, z, info = cdcs(Matrix(A'), b, c, CDCS.Cone(0, 1, [], [2]),
                                     verbose=0)
        @test primal ≈ [1, 1, -1, -1, 1] atol=1e-3
        @test dual ≈ [2.0, 0.0] atol=1e-3
        @test z ≈ [0, 1, 1, 1, 1] atol=1e-3
        @test info["problem"] == 0.0
    end
    @testset "Unbounded" begin
        A = -[0.0 0.0 1.0 0.0
              0.0 1.0 0.0 0.0]
        b = [1.0, 0.0]
        c = [1.0, 0.0, 0.0, 1.0]
        primal, dual, z, info = cdcs(Matrix(A'), b, c, CDCS.Cone(0, 0, [], [2]),
                                     verbose=0)
        @test primal == [Inf, -Inf, -Inf, Inf]
        @test dual == [Inf, -Inf]
        @test z == [Inf, -Inf, -Inf, Inf]
        @test info["problem"] == 1.0
    end
end


text:
################################################################################
#
#   plotting of LTGroundstate objects
#
################################################################################

function plotLTGroundstateKSpace(
    gs :: LTGroundstate,
    bz :: BZ,
    ;
    plot_color_valid = "b",
    plot_color_invalid = "r",
    plot_invalid :: Bool = true,
    figsize :: Tuple = (6,6),
    showPlot :: Bool = true,
    save_filename :: String = "NONE",
    constraint :: Float64 = 1e-5
    ) where {R, BZ<:AbstractBrillouinZone{R}}

    ###########################
    #   INITIAL SETTINGS
    ###########################

    # configure plot environment
    rc("font", family="serif")

    # create a new figure
    fig = figure(figsize=figsize)

    ###########################
    #   PLOT BRILLOUIN ZONE
    ###########################

    plot(bz)

    ###########################
    #   PLOT POINTS
    ###########################

    # scatter the points
    cv              = gs.constraint_values
    ks              = gs.k_vectors
    N_points        = length(cv)
    d_spatial       = size(ks)[2]
    invalid_indices = collect(1 : N_points)[cv .>= constraint]
    valid_indices   = collect(1 : N_points)[cv  .< constraint]

    # if option plot_invalid == true plot invalid points
    if plot_invalid
        if length(invalid_indices) > 0
            if d_spatial == 2
                scatter(
                [ks[i, 1] for i in invalid_indices],
                [ks[i, 2] for i in invalid_indices],
                color = plot_color_invalid,
                label = "constraint NOT fullfilled"
                )
            elseif d_spatial == 3
            scatter3D(
                [ks[i, 1] for i in invalid_indices],
                [ks[i, 2] for i in invalid_indices],
                [ks[i, 3] for i in invalid_indices],
                color = plot_color_invalid,
                label = "constraint NOT fullfilled"
                )
            end
        end
    end

    # always plot valid points
    if length(valid_indices) > 0
        if d_spatial == 2
            scatter(
            [ks[i, 1] for i in valid_indices],
            [ks[i, 2] for i in valid_indices],
            color = plot_color_valid,
            label = "constraint fullfilled"
            )
        elseif d_spatial == 3
        scatter3D(
            [ks[i, 1] for i in valid_indices],
            [ks[i, 2] for i in valid_indices],
            [ks[i, 3] for i in valid_indices],
            color = plot_color_valid,
            label = "constraint fullfilled"
            )
        end
    end

    # add a legend
    legend()

    ###########################
    #   CONFIGURE AXIS & TITLE
    ###########################

    # set the title
    title("E_min = $(gs.E_min)")

    # equal axis
    gca()[:set_aspect]("equal")

    ###########################
    #   FINISH THE PLOT
    ###########################

    # tighten the layout
    tight_layout()

    # save the plot
    if save_filename != "NONE"
    # make sure the directory exists
    if contains(save_filename, "/")
        # get the containing folder
        folder = save_filename[1:findlast(save_filename, '/')]
        # build the path to that folder
        mkpath(folder)
    end
    # save the plot
    savefig(save_filename)
    end

    # maybe show the plot
    if showPlot
    show()
    end

    # return the figure object
    return fig

end


text:
fname = joinpath(dirname(@__FILE__), "../data", "test.bsa")

dips = read_bsa(fname)

@test size(dips) == (2,)