RuleBasedIntegration / Rubi

Rubi for Mathematica
http://rulebasedintegration.org
MIT License
225 stars 22 forks source link

Put the most performant or restricting conditions/predicates at the start of an `And[...]` expression? #21

Closed axkr closed 5 years ago

axkr commented 5 years ago

In this line:

https://github.com/RuleBasedIntegration/Rubi/blob/6ea8d532dddd6f13cfd8763ba1319df36f2ddf73/Rubi/IntegrationRules/1%20Algebraic%20functions/1.1%20Binomial%20products/1.1.1%20Linear/1.1.1.7%20P(x)%20(a%2Bb%20x)%5Em%20(c%2Bd%20x)%5En%20(e%2Bf%20x)%5Ep%20(g%2Bh%20x)%5Eq.m#L8

can we have the expression LtQ[p*q, 0] as first expression of the And[...] expression?

    LtQ[p*q, 0] && FreeQ[q, x] && PolyQ[Px, x] && PolyQ[Qx, x] && EqQ[PolynomialRemainder[Px, Qx, x], 0] && IntegerQ[p]

In general can we have the most performant or restricting conditions/predicates at the start of an And[...] expression after the /; operator?

AlbertRich commented 5 years ago

Yes, the order an integration rule's application conditions are performed is not entirely fixed. However, determing which condition provides the most bang-for-the-buck is extremely hard to determine in general.

For example, the FreeQ, PolyQ, and IntegerQ conditions in your example are quick and easy to perform. They eliminate vast swaths of integrands, making application of the remaining conditions unnecessary. Also, the condition LtQ[p*q, 0] can be hard to determine for arbitrary p and q. Knowing that p is an integer and q is free of x greatly simplifies that determination.

I seriously doubt trying to determine the optimal ordering of the application conditions of Rubi's 6500+ rules would be worth the effort.