def With1890(v, x, u): if isinstance(x, (int, Integer, float, Float)): return False a = D(u, x) b = D(v, x) if And(NonzeroQ(-a * v + b * u), PosQ(a * b)): return True return False
def piecewise_linear(rubi): pattern1 = Pattern( Integral(u_**WC('m', S(1)), x_), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda x, u: PiecewiseLinearQ(u, x)), ) def With1(x, m, u): c = D(u, x) return Subst(Int(x**m, x), x, u) / c rule1 = ReplacementRule(pattern1, lambda x, m, u: With1(x, m, u)) rubi.add(rule1) pattern2 = Pattern( Integral(v_ / u_, x_), CustomConstraint(lambda x, v, u: PiecewiseLinearQ(u, v, x)), CustomConstraint(lambda v, b, x, u, a: NonzeroQ(-a * v + b * u))) def With2(x, v, u): a = D(u, x) b = D(v, x) return b * x / a - (-a * v + b * u) * Int(1 / u, x) / a rule2 = ReplacementRule(pattern2, lambda x, v, u: With2(x, v, u)) rubi.add(rule2) pattern3 = Pattern( Integral(v_**n_ / u_, x_), CustomConstraint(lambda x, v, u: PiecewiseLinearQ(u, v, x)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda n: Unequal(n, S(1))), CustomConstraint(lambda v, b, n, x, u, a: NonzeroQ(-a * v + b * u))) def With3(x, n, v, u): a = D(u, x) b = D(v, x) return -(-a * v + b * u) * Int(v** (n + S(-1)) / u, x) / a + v**n / (a * n) rule3 = ReplacementRule(pattern3, lambda x, n, v, u: With3(x, n, v, u)) rubi.add(rule3) pattern4 = Pattern( Integral(S(1) / (u_ * v_), x_), CustomConstraint(lambda x, v, u: PiecewiseLinearQ(u, v, x)), CustomConstraint(lambda v, b, x, u, a: NonzeroQ(-a * v + b * u))) def With4(x, v, u): a = D(u, x) b = D(v, x) return -a * Int(1 / u, x) / (-a * v + b * u) + b * Int( 1 / v, x) / (-a * v + b * u) rule4 = ReplacementRule(pattern4, lambda x, v, u: With4(x, v, u)) rubi.add(rule4) pattern5 = Pattern( Integral(S(1) / (u_ * sqrt(v_)), x_), CustomConstraint(lambda x, v, u: PiecewiseLinearQ(u, v, x)), CustomConstraint(lambda v, b, u, a: NonzeroQ(-a * v + b * u) & PosQ( (-a * v + b * u) / a))) def With5(x, v, u): a = D(u, x) b = D(v, x) return S(2) * ArcTan(sqrt(v) / Rt( (-a * v + b * u) / a, S(2))) / (a * Rt((-a * v + b * u) / a, S(2))) rule5 = ReplacementRule(pattern5, lambda x, v, u: With5(x, v, u)) rubi.add(rule5) pattern6 = Pattern( Integral(S(1) / (u_ * sqrt(v_)), x_), CustomConstraint(lambda x, v, u: PiecewiseLinearQ(u, v, x)), CustomConstraint(lambda v, b, u, a: NonzeroQ(-a * v + b * u) & NegQ( (-a * v + b * u) / a))) def With6(x, v, u): a = D(u, x) b = D(v, x) return -S(2) * atanh(sqrt(v) / Rt( (a * v - b * u) / a, S(2))) / (a * Rt((a * v - b * u) / a, S(2))) rule6 = ReplacementRule(pattern6, lambda x, v, u: With6(x, v, u)) rubi.add(rule6) pattern7 = Pattern( Integral(v_**n_ / u_, x_), CustomConstraint(lambda x, v, u: PiecewiseLinearQ(u, v, x)), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Less(n, S(-1))), CustomConstraint(lambda v, b, n, x, u, a: NonzeroQ(-a * v + b * u))) def With7(x, n, v, u): a = D(u, x) b = D(v, x) return -a * Int(v**(n + S(1)) / u, x) / (-a * v + b * u) + v**( n + S(1)) / ((n + S(1)) * (-a * v + b * u)) rule7 = ReplacementRule(pattern7, lambda x, n, v, u: With7(x, n, v, u)) rubi.add(rule7) pattern8 = Pattern( Integral(v_**n_ / u_, x_), CustomConstraint(lambda x, v, u: PiecewiseLinearQ(u, v, x)), CustomConstraint(lambda n: Not(IntegerQ(n))), CustomConstraint(lambda v, b, n, u, a: NonzeroQ(-a * v + b * u))) def With8(x, n, v, u): a = D(u, x) b = D(v, x) return v**(n + S(1)) * Hypergeometric2F1( S(1), n + S(1), n + S(2), -a * v / (-a * v + b * u)) / ((n + S(1)) * (-a * v + b * u)) rule8 = ReplacementRule(pattern8, lambda x, n, v, u: With8(x, n, v, u)) rubi.add(rule8) pattern9 = Pattern( Integral(S(1) / (sqrt(u_) * sqrt(v_)), x_), CustomConstraint(lambda x, v, u: PiecewiseLinearQ(u, v, x)), CustomConstraint( lambda v, b, u, a: PosQ(a * b) & NonzeroQ(-a * v + b * u))) def With9(x, v, u): a = D(u, x) b = D(v, x) return S(2) * atanh(sqrt(u) * Rt(a * b, S(2)) / (a * sqrt(v))) / Rt(a * b, S(2)) rule9 = ReplacementRule(pattern9, lambda x, v, u: With9(x, v, u)) rubi.add(rule9) pattern10 = Pattern( Integral(S(1) / (sqrt(u_) * sqrt(v_)), x_), CustomConstraint(lambda x, v, u: PiecewiseLinearQ(u, v, x)), CustomConstraint( lambda v, b, u, a: NegQ(a * b) & NonzeroQ(-a * v + b * u))) def With10(x, v, u): a = D(u, x) b = D(v, x) return S(2) * ArcTan(sqrt(u) * Rt(-a * b, S(2)) / (a * sqrt(v))) / Rt(-a * b, S(2)) rule10 = ReplacementRule(pattern10, lambda x, v, u: With10(x, v, u)) rubi.add(rule10) pattern11 = Pattern( Integral(u_**m_ * v_**n_, x_), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda x, v, u: PiecewiseLinearQ(u, v, x)), CustomConstraint(lambda n, m: ZeroQ(m + n + S(2))), CustomConstraint(lambda m: NonzeroQ(m + S(1))), CustomConstraint(lambda v, b, n, m, u, a: NonzeroQ(-a * v + b * u))) def With11(x, n, v, u, m): a = D(u, x) b = D(v, x) return -u**(m + S(1)) * v**(n + S(1)) / ((m + S(1)) * (-a * v + b * u)) rule11 = ReplacementRule(pattern11, lambda x, n, v, u, m: With11(x, n, v, u, m)) rubi.add(rule11) pattern12 = Pattern( Integral(u_**m_ * v_**WC('n', S(1)), x_), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda x, v, u: PiecewiseLinearQ(u, v, x)), CustomConstraint(lambda m: NonzeroQ(m + S(1))), CustomConstraint(lambda n, m: (NegativeIntegerQ(m) & Not(IntegerQ( n))) | (PositiveIntegerQ(n) & Not(IntegerQ(m))) | ( LessEqual(n, m) & PositiveIntegerQ(n, m) ) | (Greater(n, S(0)) & Less(m, S(-1)) & RationalQ(m, n) & Not( IntegerQ(m + n) & Less(m + n + S(2), S(0)) & (FractionQ(m) | GreaterEqual(m + S(2) * n + S(1), S(0)))))), CustomConstraint(lambda v, b, n, x, m, u, a: NonzeroQ(-a * v + b * u))) def With12(x, n, v, u, m): a = D(u, x) b = D(v, x) return -b * n * Int(u**(m + S(1)) * v**(n + S(-1)), x) / ( a * (m + S(1))) + u**(m + S(1)) * v**n / (a * (m + S(1))) rule12 = ReplacementRule(pattern12, lambda x, n, v, u, m: With12(x, n, v, u, m)) rubi.add(rule12) pattern13 = Pattern( Integral(u_**m_ * v_**WC('n', S(1)), x_), CustomConstraint(lambda x, v, u: PiecewiseLinearQ(u, v, x)), CustomConstraint(lambda n, m: NonzeroQ(m + n + S(2))), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda n, m: NonzeroQ(m + n + S(1))), CustomConstraint(lambda n, m: Not( PositiveIntegerQ(m) & (Not(IntegerQ(n)) | Less(S(0), m, n)))), CustomConstraint( lambda n, m: Not(IntegerQ(m + n) & Less(m + n + S(2), S(0)))), CustomConstraint(lambda v, b, n, x, m, u, a: NonzeroQ(-a * v + b * u))) def With13(x, n, v, u, m): a = D(u, x) b = D(v, x) return -n * (-a * v + b * u) * Int(u**m * v**(n + S(-1)), x) / ( a * (m + n + S(1))) + u**(m + S(1)) * v**n / (a * (m + n + S(1))) rule13 = ReplacementRule(pattern13, lambda x, n, v, u, m: With13(x, n, v, u, m)) rubi.add(rule13) pattern14 = Pattern( Integral(u_**m_ * v_**n_, x_), CustomConstraint(lambda x, v, u: PiecewiseLinearQ(u, v, x)), CustomConstraint(lambda n, m: NonzeroQ(m + n + S(1))), CustomConstraint(lambda n: Not(RationalQ(n))), CustomConstraint(lambda n: SumSimplerQ(n, S(-1))), CustomConstraint(lambda v, b, n, x, m, u, a: NonzeroQ(-a * v + b * u))) def With14(x, n, v, u, m): a = D(u, x) b = D(v, x) return -n * (-a * v + b * u) * Int(u**m * v**(n + S(-1)), x) / ( a * (m + n + S(1))) + u**(m + S(1)) * v**n / (a * (m + n + S(1))) rule14 = ReplacementRule(pattern14, lambda x, n, v, u, m: With14(x, n, v, u, m)) rubi.add(rule14) pattern15 = Pattern( Integral(u_**m_ * v_**n_, x_), CustomConstraint(lambda x, v, u: PiecewiseLinearQ(u, v, x)), CustomConstraint(lambda n, m: NonzeroQ(m + n + S(2))), CustomConstraint(lambda m: RationalQ(m)), CustomConstraint(lambda m: Less(m, S(-1))), CustomConstraint(lambda v, b, n, x, m, u, a: NonzeroQ(-a * v + b * u))) def With15(x, n, v, u, m): a = D(u, x) b = D(v, x) return b * (m + n + S(2)) * Int(u**(m + S(1)) * v**n, x) / ( (m + S(1)) * (-a * v + b * u)) - u**(m + S(1)) * v**(n + S(1)) / ( (m + S(1)) * (-a * v + b * u)) rule15 = ReplacementRule(pattern15, lambda x, n, v, u, m: With15(x, n, v, u, m)) rubi.add(rule15) pattern16 = Pattern( Integral(u_**m_ * v_**n_, x_), CustomConstraint(lambda x, v, u: PiecewiseLinearQ(u, v, x)), CustomConstraint(lambda m: Not(RationalQ(m))), CustomConstraint(lambda m: SumSimplerQ(m, S(1))), CustomConstraint(lambda v, b, n, x, m, u, a: NonzeroQ(-a * v + b * u))) def With16(x, n, v, u, m): a = D(u, x) b = D(v, x) return b * (m + n + S(2)) * Int(u**(m + S(1)) * v**n, x) / ( (m + S(1)) * (-a * v + b * u)) - u**(m + S(1)) * v**(n + S(1)) / ( (m + S(1)) * (-a * v + b * u)) rule16 = ReplacementRule(pattern16, lambda x, n, v, u, m: With16(x, n, v, u, m)) rubi.add(rule16) pattern17 = Pattern( Integral(u_**m_ * v_**n_, x_), CustomConstraint(lambda x, v, u: PiecewiseLinearQ(u, v, x)), CustomConstraint(lambda m: Not(IntegerQ(m))), CustomConstraint(lambda n: Not(IntegerQ(n))), CustomConstraint(lambda v, b, n, m, u, a: NonzeroQ(-a * v + b * u))) def With17(x, n, v, u, m): a = D(u, x) b = D(v, x) return u**m * v**(n + S(1)) * (b * u / (-a * v + b * u))**( -m) * Hypergeometric2F1(-m, n + S(1), n + S(2), -a * v / (-a * v + b * u)) / (b * (n + S(1))) rule17 = ReplacementRule(pattern17, lambda x, n, v, u, m: With17(x, n, v, u, m)) rubi.add(rule17) pattern18 = Pattern( Integral(u_**WC('n', S(1)) * log(x_ * WC('b', S(1)) + WC('a', S(0))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda x, u: PiecewiseLinearQ(u, x)), CustomConstraint(lambda x, u: Not(LinearQ(u, x))), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Greater(n, S(0))), ) def With18(x, n, b, u, a): c = D(u, x) return -Int(u**n, x) - c * n * Int( u**(n + S(-1)) * (a + b * x) * log(a + b * x), x) / b + u**n * (a + b * x) * log(a + b * x) / b rule18 = ReplacementRule(pattern18, lambda x, n, b, u, a: With18(x, n, b, u, a)) rubi.add(rule18) pattern19 = Pattern( Integral( u_**WC('n', S(1)) * (x_ * WC('b', S(1)) + WC('a', S(0)))**WC('m', S(1)) * log(x_ * WC('b', S(1)) + WC('a', S(0))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda x, u: PiecewiseLinearQ(u, x)), CustomConstraint(lambda x, u: Not(LinearQ(u, x))), CustomConstraint(lambda n: RationalQ(n)), CustomConstraint(lambda n: Greater(n, S(0))), CustomConstraint(lambda m: NonzeroQ(m + S(1))), ) def With19(x, n, b, u, a, m): c = D(u, x) return -Int(u**n * (a + b * x)**m, x) / (m + S(1)) - c * n * Int( u**(n + S(-1)) * (a + b * x)** (m + S(1)) * log(a + b * x), x) / (b * (m + S(1))) + u**n * ( a + b * x)**(m + S(1)) * log(a + b * x) / (b * (m + S(1))) rule19 = ReplacementRule(pattern19, lambda x, n, b, u, a, m: With19(x, n, b, u, a, m)) rubi.add(rule19) return rubi
def integrand_simplification(rubi): pattern1 = Pattern( Integral((a_ + x_**WC('n', S(1)) * WC('b', S(1)))**WC('p', S(1)) * WC('u', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda a: ZeroQ(a))) rule1 = ReplacementRule(pattern1, lambda p, b, u, a, x, n: Int(u * (b * x**n)**p, x)) rubi.add(rule1) pattern2 = Pattern( Integral( (a_ + x_**WC('j', S(1)) * WC('c', S(1)) + x_**WC('n', S(1)) * WC('b', S(1)))**WC('p', S(1)) * WC('u', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda n, j: ZeroQ(j - S(2) * n)), CustomConstraint(lambda a: ZeroQ(a))) rule2 = ReplacementRule( pattern2, lambda j, b, p, u, a, x, n, c: Int( u * (b * x**n + c * x**(S(2) * n))**p, x)) rubi.add(rule2) pattern3 = Pattern( Integral((x_**WC('j', S(1)) * WC('c', S(1)) + x_**WC('n', S(1)) * WC('b', S(1)) + WC('a', S(0)))**WC( 'p', S(1)) * WC('u', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda n, j: ZeroQ(j - S(2) * n)), CustomConstraint(lambda b: ZeroQ(b))) rule3 = ReplacementRule( pattern3, lambda j, b, p, u, a, x, n, c: Int(u * (a + c * x**(S(2) * n))**p, x)) rubi.add(rule3) pattern4 = Pattern( Integral((x_**WC('j', S(1)) * WC('c', S(1)) + x_**WC('n', S(1)) * WC('b', S(1)) + WC('a', S(0)))**WC( 'p', S(1)) * WC('u', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda n, j: ZeroQ(j - S(2) * n)), CustomConstraint(lambda c: ZeroQ(c))) rule4 = ReplacementRule( pattern4, lambda j, b, p, u, a, x, n, c: Int(u * (a + b * x**n)**p, x)) rubi.add(rule4) pattern5 = Pattern( Integral((v_ * WC('a', S(1)) + v_ * WC('b', S(1)) + WC('w', S(0)))**WC( 'p', S(1)) * WC('u', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda x, v: NFreeQ(v, x))) rule5 = ReplacementRule( pattern5, lambda p, b, v, u, a, x, w: Int(u * (v * (a + b) + w)**p, x)) rubi.add(rule5) pattern6 = Pattern(Integral(Pm_**p_ * WC('u', S(1)), x_), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda x, Pm: PolyQ(Pm, x)), CustomConstraint(lambda p: Not(RationalQ(p))), CustomConstraint(lambda p: RationalQ(p))) rule6 = ReplacementRule(pattern6, lambda u, x, p, Pm: Int(Pm**p * u, x)) rubi.add(rule6) pattern7 = Pattern(Integral(a_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda a, x: FreeQ(a, x))) rule7 = ReplacementRule(pattern7, lambda a, x: a * x) rubi.add(rule7) pattern8 = Pattern( Integral(a_ * (b_ + x_ * WC('c', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda a, c, b, x: FreeQ(List(a, b, c), x))) rule8 = ReplacementRule( pattern8, lambda a, c, b, x: a * (b + c * x)**S(2) / (S(2) * c)) rubi.add(rule8) pattern9 = Pattern(Integral(-u_, x_)) rule9 = ReplacementRule(pattern9, lambda u, x: I * Int(u, x)) rubi.add(rule9) pattern10 = Pattern(Integral(u_ * Complex(S(0), a_), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda a: EqQ(a**S(2), S(1)))) rule10 = ReplacementRule(pattern10, lambda u, a, x: Int(u, x) * Complex(I, a)) rubi.add(rule10) pattern11 = Pattern(Integral(a_ * u_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda a, x: FreeQ(a, x))) rule11 = ReplacementRule(pattern11, lambda u, a, x: a * Int(u, x)) rubi.add(rule11) pattern12 = Pattern(Integral(u_, x_), CustomConstraint(lambda u: SumQ(u))) rule12 = ReplacementRule(pattern12, lambda u, x: IntSum(u, x)) rubi.add(rule12) pattern13 = Pattern( Integral(v_**WC('m', S(1)) * (b_ * v_)**n_ * WC('u', S(1)), x_), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda m: IntegerQ(m))) rule13 = ReplacementRule( pattern13, lambda b, v, u, m, x, n: b**(-m) * Int(u * (b * v)**(m + n), x)) rubi.add(rule13) pattern14 = Pattern( Integral((v_ * WC('a', S(1)))**m_ * (v_ * WC('b', S(1)))**n_ * WC('u', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda m: Not(IntegerQ(m))), CustomConstraint(lambda n: PositiveIntegerQ(n + S(1) / 2)), CustomConstraint(lambda m, n: IntegerQ(m + n))) rule14 = ReplacementRule( pattern14, lambda b, v, u, m, a, x, n: a**(m + S(1) / 2) * b** (n + S(-1) / 2) * sqrt(b * v) * Int(u * v**(m + n), x) / sqrt(a * v)) rubi.add(rule14) pattern15 = Pattern( Integral((v_ * WC('a', S(1)))**m_ * (v_ * WC('b', S(1)))**n_ * WC('u', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda m: Not(IntegerQ(m))), CustomConstraint(lambda n: NegativeIntegerQ(n + S(-1) / 2)), CustomConstraint(lambda m, n: IntegerQ(m + n))) rule15 = ReplacementRule( pattern15, lambda b, v, u, m, a, x, n: a**(m + S(-1) / 2) * b** (n + S(1) / 2) * sqrt(a * v) * Int(u * v**(m + n), x) / sqrt(b * v)) rubi.add(rule15) pattern16 = Pattern( Integral((v_ * WC('a', S(1)))**m_ * (v_ * WC('b', S(1)))**n_ * WC('u', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda m: Not(IntegerQ(m))), CustomConstraint(lambda n: Not(IntegerQ(n))), CustomConstraint(lambda m, n: IntegerQ(m + n))) rule16 = ReplacementRule( pattern16, lambda b, v, u, m, a, x, n: a**(m + n) * (a * v)**(-n) * (b * v)**n * Int(u * v**(m + n), x)) rubi.add(rule16) pattern17 = Pattern( Integral((v_ * WC('a', S(1)))**m_ * (v_ * WC('b', S(1)))**n_ * WC('u', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda m: Not(IntegerQ(m))), CustomConstraint(lambda n: Not(IntegerQ(n))), CustomConstraint(lambda m, n: Not(IntegerQ(m + n)))) rule17 = ReplacementRule( pattern17, lambda b, v, u, m, a, x, n: a**(-IntPart(n)) * b**IntPart(n) * (a * v)**(-FracPart(n)) * (b * v)**FracPart(n) * Int(u * (a * v)**(m + n), x)) rubi.add(rule17) pattern18 = Pattern( Integral((a_ + v_ * WC('b', S(1)))**WC('m', S(1)) * (c_ + v_ * WC('d', S(1)))**WC('n', S(1)) * WC('u', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda a, c, b, d: ZeroQ(-a * d + b * c)), CustomConstraint(lambda m: IntegerQ(m)), CustomConstraint(lambda b, a, x, d, n, c: Not(IntegerQ(n)) | SimplerQ( c + d * x, a + b * x))) rule18 = ReplacementRule( pattern18, lambda b, v, u, m, a, x, d, n, c: (b / d)**m * Int(u * (c + d * v)**(m + n), x)) rubi.add(rule18) pattern19 = Pattern( Integral((a_ + v_ * WC('b', S(1)))**m_ * (c_ + v_ * WC('d', S(1)))**n_ * WC('u', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda a, c, b, d: ZeroQ(-a * d + b * c)), CustomConstraint(lambda b, d: PositiveQ(b / d)), CustomConstraint(lambda m, n: Not(IntegerQ(m) | IntegerQ(n)))) rule19 = ReplacementRule( pattern19, lambda b, v, u, m, a, x, d, n, c: (b / d)**m * Int(u * (c + d * v)**(m + n), x)) rubi.add(rule19) pattern20 = Pattern( Integral((a_ + v_ * WC('b', S(1)))**m_ * (c_ + v_ * WC('d', S(1)))**n_ * WC('u', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda a, c, b, d: ZeroQ(-a * d + b * c)), CustomConstraint(lambda m, n, b, d: Not( IntegerQ(m) | IntegerQ(n) | PositiveQ(b / d)))) rule20 = ReplacementRule( pattern20, lambda b, v, u, m, a, x, d, n, c: (a + b * v)**m * (c + d * v)**(-m) * Int(u * (c + d * v)**(m + n), x)) rubi.add(rule20) pattern21 = Pattern( Integral( (v_ * WC('a', S(1)))**m_ * (v_**S(2) * WC('c', S(1)) + v_ * WC('b', S(1))) * WC('u', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda m: RationalQ(m)), CustomConstraint(lambda m: LessEqual(m, S(-1)))) rule21 = ReplacementRule( pattern21, lambda b, v, u, m, a, x, c: Int(u * (a * v)**(m + S(1)) * (b + c * v), x) / a) rubi.add(rule21) pattern22 = Pattern( Integral( (a_ + v_ * WC('b', S(1)))**m_ * (v_**S(2) * WC('C', S(1)) + v_ * WC('B', S(1)) + WC('A', S(0))) * WC('u', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda A, x: FreeQ(A, x)), CustomConstraint(lambda B, x: FreeQ(B, x)), CustomConstraint(lambda C, x: FreeQ(C, x)), CustomConstraint(lambda b, A, B, a, C: ZeroQ(A * b**S(2) - B * a * b + C * a**S(2))), CustomConstraint(lambda m: RationalQ(m)), CustomConstraint(lambda m: LessEqual(m, S(-1)))) rule22 = ReplacementRule( pattern22, lambda b, v, u, A, B, m, a, x, C: Int( u * (a + b * v)** (m + S(1)) * Simp(B * b - C * a + C * b * v, x), x) / b**S(2)) rubi.add(rule22) pattern23 = Pattern( Integral((a_ + x_**WC('n', S(1)) * WC('b', S(1)))**WC('m', S(1)) * (c_ + x_**WC('q', S(1)) * WC('d', S(1)))**WC('p', S(1)) * WC('u', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda n, q: ZeroQ(n + q)), CustomConstraint(lambda p: IntegerQ(p)), CustomConstraint(lambda a, c, b, d: ZeroQ(a * c - b * d)), CustomConstraint(lambda m, n: Not(IntegerQ(m) & NegQ(n)))) rule23 = ReplacementRule( pattern23, lambda q, p, b, u, m, a, x, d, n, c: (d / a)**p * Int(u * x**(-n * p) * (a + b * x**n)**(m + p), x)) rubi.add(rule23) pattern24 = Pattern( Integral((a_ + x_**WC('n', S(1)) * WC('b', S(1)))**WC('m', S(1)) * (c_ + x_**j_ * WC('d', S(1)))**WC('p', S(1)) * WC('u', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda n, j: ZeroQ(j - S(2) * n)), CustomConstraint(lambda m, p: ZeroQ(m + p)), CustomConstraint(lambda a, c, b, d: ZeroQ(a**S(2) * d + b**S(2) * c)), CustomConstraint(lambda a: PositiveQ(a)), CustomConstraint(lambda d: NegativeQ(d))) rule24 = ReplacementRule( pattern24, lambda p, b, j, u, m, a, x, d, n, c: (-b**S(2) / d)**m * Int(u * (a - b * x**n)**(-m), x)) rubi.add(rule24) pattern25 = Pattern( Integral((a_ + x_**S(2) * WC('c', S(1)) + x_ * WC('b', S(1)))**WC( 'p', S(1)) * WC('u', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda a, c, b: ZeroQ(-S(4) * a * c + b**S(2))), CustomConstraint(lambda p: IntegerQ(p))) rule25 = ReplacementRule( pattern25, lambda p, b, u, a, x, c: Int( S(2)**(-S(2) * p) * c**(-p) * u * (b + S(2) * c * x)**(S(2) * p), x)) rubi.add(rule25) pattern26 = Pattern( Integral( (a_ + x_**n_ * WC('b', S(1)) + x_**WC('n2', S(1)) * WC('c', S(1))) **WC('p', S(1)) * WC('u', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda n, n2: ZeroQ(-S(2) * n + n2)), CustomConstraint(lambda a, c, b: ZeroQ(-S(4) * a * c + b**S(2))), CustomConstraint(lambda p: IntegerQ(p))) rule26 = ReplacementRule( pattern26, lambda n2, p, b, u, a, x, n, c: c** (-p) * Int(u * (b / S(2) + c * x**n)**(S(2) * p), x)) rubi.add(rule26) pattern27 = Pattern( Integral( (d_ + x_ * WC('e', S(1))) * (x_**S(2) * WC('c', S(1)) + x_ * WC('b', S(1)) + WC('a', S(0)))** WC('p', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda d, x: FreeQ(d, x)), CustomConstraint(lambda e, x: FreeQ(e, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda e, c, b, d: ZeroQ(-b * e + S(2) * c * d))) rule27 = ReplacementRule( pattern27, lambda p, b, a, x, d, e, c: d * Subst( Int(x**p, x), x, a + b * x + c * x**S(2)) / b) rubi.add(rule27) pattern28 = Pattern( Integral( (x_**WC('p', S(1)) * WC('a', S(1)) + x_**WC('q', S(1)) * WC('b', S(1)))**WC('m', S(1)) * WC('u', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda q, x: FreeQ(q, x)), CustomConstraint(lambda m: IntegerQ(m)), CustomConstraint(lambda q, p: PosQ(-p + q))) rule28 = ReplacementRule( pattern28, lambda q, p, b, u, m, a, x: Int( u * x**(m * p) * (a + b * x**(-p + q))**m, x)) rubi.add(rule28) pattern29 = Pattern( Integral( (x_**WC('p', S(1)) * WC('a', S(1)) + x_**WC('q', S(1)) * WC('b', S(1)) + x_**WC('r', S(1)) * WC('c', S(1)))**WC('m', S(1)) * WC('u', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda q, x: FreeQ(q, x)), CustomConstraint(lambda r, x: FreeQ(r, x)), CustomConstraint(lambda m: IntegerQ(m)), CustomConstraint(lambda q, p: PosQ(-p + q)), CustomConstraint(lambda r, p: PosQ(-p + r))) rule29 = ReplacementRule( pattern29, lambda q, r, p, b, u, m, a, x, c: Int( u * x**(m * p) * (a + b * x**(-p + q) + c * x**(-p + r))**m, x)) rubi.add(rule29) pattern30 = Pattern( Integral(x_**WC('m', S(1)) / (a_ + x_**n_ * WC('b', S(1))), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda m, n: ZeroQ(m - n + S(1)))) rule30 = ReplacementRule( pattern30, lambda b, m, a, x, n: log(RemoveContent(a + b * x**n, x)) / (b * n)) rubi.add(rule30) pattern31 = Pattern( Integral(x_**WC('m', S(1)) * (a_ + x_**n_ * WC('b', S(1)))**p_, x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda m, n: ZeroQ(m - n + S(1))), CustomConstraint(lambda p: NonzeroQ(p + S(1)))) rule31 = ReplacementRule( pattern31, lambda p, b, m, a, x, n: (a + b * x**n)**(p + S(1)) / (b * n * (p + S(1)))) rubi.add(rule31) pattern32 = Pattern( Integral( x_**WC('m', S(1)) * (a1_ + x_**WC('n', S(1)) * WC('b1', S(1)))**p_ * (a2_ + x_**WC('n', S(1)) * WC('b2', S(1)))**p_, x_), CustomConstraint(lambda a1, x: FreeQ(a1, x)), CustomConstraint(lambda b1, x: FreeQ(b1, x)), CustomConstraint(lambda a2, x: FreeQ(a2, x)), CustomConstraint(lambda b2, x: FreeQ(b2, x)), CustomConstraint(lambda m, x: FreeQ(m, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda b2, b1, a1, a2: ZeroQ(a1 * b2 + a2 * b1)), CustomConstraint(lambda m, n: ZeroQ(m - S(2) * n + S(1))), CustomConstraint(lambda p: NonzeroQ(p + S(1)))) rule32 = ReplacementRule( pattern32, lambda p, a1, b2, m, x, a2, n, b1: (a1 + b1 * x**n)**(p + S(1)) * (a2 + b2 * x**n)**(p + S(1)) / (S(2) * b1 * b2 * n * (p + S(1)))) rubi.add(rule32) ''' pattern33 = Pattern(Integral(Qm_*(Pm_**WC('n', S(1))*WC('b', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda x, Pm: PolyQ(Pm, x)), CustomConstraint(lambda Qm, x: PolyQ(Qm, x)), ) def With33(p, b, a, x, n, Qm, Pm): m = Expon(Pm, x) if Equal(Expon(Qm, x), m + S(-1)) & ZeroQ(-Qm*m*Coeff(Pm, x, m) + Coeff(Qm, x, m + S(-1))*D(Pm, x)): return Coeff(Qm, x, m + S(-1))*Subst(Int((a + b*x**n)**p, x), x, Pm)/(m*Coeff(Pm, x, m)) print("Unable to Integrate") rule33 = ReplacementRule(pattern33, lambda p, b, a, x, n, Qm, Pm : With33(p, b, a, x, n, Qm, Pm)) rubi.add(rule33) pattern34 = Pattern(Integral(Qm_*(Pm_**WC('n', S(1))*WC('b', S(1)) + Pm_**WC('n2', S(1))*WC('c', S(1)) + WC('a', S(0)))**WC('p', S(1)), x_), CustomConstraint(lambda a, x: FreeQ(a, x)), CustomConstraint(lambda b, x: FreeQ(b, x)), CustomConstraint(lambda c, x: FreeQ(c, x)), CustomConstraint(lambda n, x: FreeQ(n, x)), CustomConstraint(lambda p, x: FreeQ(p, x)), CustomConstraint(lambda n, n2: ZeroQ(-S(2)*n + n2)), CustomConstraint(lambda x, Pm: PolyQ(Pm, x)), CustomConstraint(lambda Qm, x: PolyQ(Qm, x)), ) def With34(n2, p, b, a, x, n, Qm, c, Pm): m = Expon(Pm, x) if Equal(Expon(Qm, x), m + S(-1)) & ZeroQ(-Qm*m*Coeff(Pm, x, m) + Coeff(Qm, x, m + S(-1))*D(Pm, x)): return Coeff(Qm, x, m + S(-1))*Subst(Int((a + b*x**n + c*x**(S(2)*n))**p, x), x, Pm)/(m*Coeff(Pm, x, m)) print("Unable to Integrate") rule34 = ReplacementRule(pattern34, lambda n2, p, b, a, x, n, Qm, c, Pm : With34(n2, p, b, a, x, n, Qm, c, Pm)) rubi.add(rule34) pattern35 = Pattern(Integral(Pq_**m_*Qr_**p_*WC('u', S(1)), x_), CustomConstraint(lambda m: PositiveIntegerQ(m)), CustomConstraint(lambda p: NegativeIntegerQ(p)), CustomConstraint(lambda Pq, x: PolyQ(Pq, x)), CustomConstraint(lambda Qr, x: PolyQ(Qr, x)), ) def With35(Qr, p, u, Pq, m, x): gcd = PolyGCD(Pq, Qr, x) if NonzeroQ(gcd + S(-1)): return Int(gcd**(m + p)*u*PolynomialQuotient(Pq, gcd, x)**m*PolynomialQuotient(Qr, gcd, x)**p, x) print("Unable to Integrate") rule35 = ReplacementRule(pattern35, lambda Qr, p, u, Pq, m, x : With35(Qr, p, u, Pq, m, x)) rubi.add(rule35) pattern36 = Pattern(Integral(Pq_*Qr_**p_*WC('u', S(1)), x_), CustomConstraint(lambda p: NegativeIntegerQ(p)), CustomConstraint(lambda Pq, x: PolyQ(Pq, x)), CustomConstraint(lambda Qr, x: PolyQ(Qr, x)), ) def With36(Qr, p, u, Pq, x): gcd = PolyGCD(Pq, Qr, x) if NonzeroQ(gcd + S(-1)): return Int(gcd**(p + S(1))*u*PolynomialQuotient(Pq, gcd, x)*PolynomialQuotient(Qr, gcd, x)**p, x) print("Unable to Integrate") rule36 = ReplacementRule(pattern36, lambda Qr, p, u, Pq, x : With36(Qr, p, u, Pq, x)) rubi.add(rule36) ''' return rubi