@Anixx The 3-year old Wolfram Community article "Rubi - The Rule-based Integrator for Mathematica" you reference gives just one example integral on which Mathematica 11.3 is inferior to that returned by Rubi.
Before you say "Mathematica 13 now gives the same results as Rubi" you need to wait and see how Mma 13 performs on the rest of the 1000's of problems in the integration test-suite Nasser uses.
Int[(a_./x)^p_,x_Symbol] :=-a*(a/x)^(p-1)/(p-1) /;FreeQ[{a,p},x] && Not[IntegerQ[p]]
The above gives an integration rule. It says for an integrand of the form (symbol/x)^p
its anti derivative is what it shows on the RHS. The stuff after /;
gives conditions on arguments for this to apply.
It says this rule applies when p
is NOT an integer and when a
and p
are free of the integration variable x
. The small DOT next to a
is to allow 1
there. For example if you type the above, now you can do Int[(1/x)^(1/3),x]
and it will return 3/(2 (1/x)^(2/3))
but if you have typed Int[(1/x)^3,x]
then it will not have matched the rule, since p
is an integer here. You can also type Int[(n/x)^(1/3),x]
and it will return (3 n)/(2 (n/x)^(2/3))
. And if you type Int[(1/x)^(x/3),x]
then it will not match, so the rule will not be applied, since p
now has x
in it. So it is NOT free of x
.
To translate all this to Python, one would need to know Mathematica pattern matching and know Python pretty well also. As for how to do this in Python, that will be a question for the Python forum.
Simplify
, PossibleZeroQ
implementation...
@AlbertRich Thanks. That works. Do you know why when I print the rules using the following, it shows always as Removed[Int]
in there and not just Int
? Here is an example
$LoadShowSteps = False;
<< Rubi`
BeginPackage["Rubi`"];
Begin["`Private`"];
Do[
Print[InputForm[DownValues[Int][[n]]]]
,
{n, 1, 1}(*Length[DownValues[Int]]}*)
]
Which gives
HoldPattern[Removed["Int"][(u_.)*((a_) + (b_.)*(x_)^(n_.))^(p_.), x_Symbol]] :> Removed["Int"][u*(b*x^n)^p, x] /; FreeQ[{a, b, n, p}, x] && EqQ[a, 0]
Now I remove this as follows
BeginPackage["Rubi`"];
Begin["`Private`"];
Do[
res = InputForm[DownValues[Int][[n]]];
res = ToString[ReleaseHold[res]];
res = StringReplace[res, "Defer[Removed[\"Int\"]]" -> "Int"];
res = StringReplace[res, "Removed[\"Int\"]" -> "Int"];
Print[res]
,
{n, 1, 1}(*Length[DownValues[Int]]}*)
]
Which gives
Int[(u_.)*((a_) + (b_.)*(x_)^(n_.))^(p_.), x_Symbol] :>
Int[u*(b*x^n)^p, x] /; FreeQ[{a, b, n, p}, x] && EqQ[a, 0]
Starting from clean Kernel did not help. The Removed[Int]
is always there. It is not big deal as I can remove it, this is for just printing the rules, but I wondered why it happens.
You can't get closed form antiderivative. You could find approximate series solution.
(a x^2)/2 - (a^3 x^4)/12 + (a^5 x^6)/60 - (a^7 x^8)/315 + (
13 a^9 x^10)/25200 - (47 a^11 x^12)/598752 + (
15481 a^13 x^14)/1362160800 - (3947 a^15 x^16)/2554051500 + (
451939 a^17 x^18)/2273570208000 - (
23252857 a^19 x^20)/950352346944000 + (
186846623 a^21 x^22)/64568056512960000 - (
831520891 a^23 x^24)/2524611009656736000 + (
1108990801 a^25 x^26)/30644204599008000000 - (
143356511198507 a^27 x^28)/37217815504359602112000000 + (
920716137922619 a^29 x^30)/2312821392056632416960000000 +
C[1]
Here is a plot comparing the derivative of the above antiderivative above with the integrand showing good agreement. More terms gives better agreemeent.
ode = y'[x] == Sin[Sin[a*x]];
antiderivative = AsymptoticDSolveValue[ode, y[x], {x, 0, 30}]
Plot[Evaluate[{Sin[Sin[a*x]], D[antiderivative, x]} /. a -> 1], {x, -3, 3}]
The following Issue was recently posted on the Rubi's GitHub repository:
I posted the following response:
Yes, Rubi 4 is currently undergoing a major redesign that will significantly expand the class of mathematical expressions it can integrate, produce simpler antiderivatives, and provide more elegant derivations. Also it is necessary to perfect Rubi 4 before compiling its pattern matching rules into an if-then-else decision tree for the next release of Rubi.
I'm working fulltime on what has turned out to be a massive project. It's driven by my figuring out the math required to integrate expressions symbolically. I will release a new version of Rubi 4 as-soon-as it's perfected to my satisfaction. But it's impossible to predict when that will be, given the creative nature of this open-ended work.
Albert