Skip to content

Instantly share code, notes, and snippets.

@halirutan
Created August 23, 2018 06:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save halirutan/bc1356810c3c09f248b53659af80e1e7 to your computer and use it in GitHub Desktop.
Save halirutan/bc1356810c3c09f248b53659af80e1e7 to your computer and use it in GitHub Desktop.

Two months ago, Albert Rich posted "What's the hardest integral Mathematica running Rubi can find?" here on the Wolfram Community. You might have also seen that I answered in detail and pointed out the things that could help to improve Rubi. While it appears nothing really happened afterward, this is far from reality. Since then, Albert and I have worked closely together to make Rubi more accessible. If you like to read about how this all started, let me invite you to read my latest blog-post about our collaboration. However, here, we want to share an update that should serve as an overview of what we have done to improve Rubi.

First of all, Rubi has got a new home under rulebasedintegration.org and Albert's old site will no longer be updated. On the new website, you will find information, installation instructions, and links to the source-code and test-suites.

Secondly, we created a Rubi Organization on GitHub that serves as the headquarters and will contain all code, notebooks, and test-suites nicely structured into several repositories. At the moment, we provide repositories for (1) the Mathematica package sources that also contain the notebooks with the integration rules, (2) the integration rules in human readable PDF format, and (3) the test-suite with the 70.000+ integration problems in different CAS languages that are used to validate and compare the capabilities of Rubi.

In addition to the transition to GitHub, we worked hard to improve the Rubi Mathematica package and fixed bugs in the integration rules along the way. The most obvious change for the users is the display of Rubi's integration steps that was completely reworked. Although installation, usage, and examples are given on the website, let me show you how easy it is to install and use the current version of Rubi in Mathematica 11.

PacletInstall["https://github.com/RuleBasedIntegration/Rubi/releases/download/4.16.0.3/Rubi-4.16.0.3.paclet"];

After that, Rubi is ready to be used

<< Rubi`
Int[(Sec[x]^2 + Sec[x]^2*Tan[x])/((2 - Tan[x])*Sqrt[1 + Tan[x]^3]), x]

Mathematica graphics

Inspecting the integration rules that were used to find the antiderivative is one of the great features of Rubi

Steps@Int[(Sec[x]^2 + Sec[x]^2*Tan[x])/((2 - Tan[x])*Sqrt[1 + Tan[x]^3]), x]

Mathematica graphics

Here, you see in red the rules that were used to transform the expressions and in blue the intermediate results. Each red rule can be expanded to see the rule number, which directly corresponds to the index of the Int-DownValue and more importantly, you can see the conditions that were required to make this rule the correct next transformation.

Mathematica graphics

In addition to the steps, Rubi can provide certain statistical properties of an integration

Stats[Int[(Sec[x]^2 + Sec[x]^2*Tan[x])/((2 - Tan[x])*Sqrt[1 + Tan[x]^3]), x]]

Mathematica graphics

One important measure there is the leaf-count of the found antiderivative because it directly reflects how simple or complex the found antiderivative is. As you can see above, the solution of Rubi has a leaf-count of 25, which is impressively small if you compare it to the result of Integrate in Mathematica 11.3

Integrate[(Sec[x]^2 + Sec[x]^2*Tan[x])/((2 - Tan[x])*Sqrt[1 + Tan[x]^3]), x]

Mathematica graphics

LeafCount[%]
(*  290 *)

You might be inclined to ask how you know Rubi's answer is correct if it is so different from the Mathematica result. Since deriving an expression is so much easier than finding an antiderivative, one direct method is to derive the solution and try to simplify it to the original input

expr = (Sec[x]^2 + Sec[x]^2*Tan[x])/((2 - Tan[x])*Sqrt[1 + Tan[x]^3]);
res = Int[expr, x];
FullSimplify[D[res, x]]

Mathematica graphics

Considering that the additional minus sign in front of the result comes from the negative of the (-2+Tan[x]) term in the denominator, we see easily that the original input is the same as the above expression. However, we could have simpliy used the following to see that the result is valid:

Simplify[D[res, x] - expr]
(* 0 *)

Tests like the above are one example of how the correctness of Rubi is checked when testing the large number of 70000+ test-cases. Others include that the result of Rubi is directly compared to know, optimal antiderivatives. Albert and I are currently working on publishing the functions that are used to validate Rubi.

If all that got you interested in Rubi, then check out its website or talk to us in our Gitter chat.

@AlbertRich
Copy link

AlbertRich commented Aug 23, 2018

Deleted

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment