Message Boards Message Boards

Rubi - The Rule-based Integrator for Mathematica

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 responded in detail, and pointed out a few things that could help improve Rubi (Rule-based integrator). 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 and user-friendly. If you would like to learn how our productive collaboration evolved, let me invite you to read my latest blog-post. 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 its old website 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 for all things Rubi. It contains all Rubi's code, notebooks, and test-suites nicely structured into several repositories. At the moment, we provide repositories for the

  • loadable package files and notebook source files defining over 6700 integration rules,
  • PDF files displaying the rules in human-readable mathematical notation alongside the Mathematica code, and
  • test-suite files containing over 71000 integration problems and their solutions.

The integration test files are available in the syntax used by 4 popular computer algebra systems (Mathematica, Maple, Maxima, and Axiom). The test-suite can be used to compare Rubi's results with other symbolic integrators, including Mathematica's Integrate function.

In addition to the transition to GitHub, we recently released version 4.16.0.3 of Rubi which significantly expands the class of expressions the system can integrate. But the most noticeable change for users is the completely reworked display of the rules and intermediate steps Rubi uses to integrate expressions. Although installation, usage, and examples are given on Rubi's website, let me show you how easy it is to install and run Rubi 4.16.0.3 using Mathematica 11.3:

The command

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

installs the Rubi-4.16.0.3 paclet on your computer. After that, to load Rubi into Mathematica all you have to do is issue the Get command

<< Rubi`

Then to integrate an expression with respect to a variable, use Rubi's Int command similar to Mathematica's Integrate command. For example, evaluating

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

returns the antiderivative (a.k.a. the indefinite integral)

Mathematica graphics

Rubi's unique ability to display the steps it uses to integrate expressions is a great feature of the system. For example, the Steps command

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

displays

Mathematica graphics

Here, in red are the rules used to integrate the expression, and in blue are the intermediate results. Each rule can be expanded to show the rule number, which directly corresponds to the index of the rule in Int's list of DownValues. More importantly, you can see the conditions that have to be satisfied so the rule can be applied.

Mathematica graphics

Rubi's Stats command provides statistics about the integration. For example,

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

displays

Mathematica graphics

The leaf-count size of an antiderivative is a crude measure of its complexity. As you can see, Rubi's antiderivative for this integral has a leaf-count of 25. Now compare Rubi's antiderivative with that produced by Mathematica 11.3 for the same integral:

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

Mathematica graphics

LeafCount[%]
(*  290 *)

Note that not only is Mathematica's result more than 11 times the size of Rubi's, it unnecessarily involves elliptic integral functions and the imaginary unit.

Skeptics might be inclined to ask if Rubi's dramatically simpler result is actually a valid antiderivative. Since symbolic differentiation is much easier than integration, antiderivatives can be verified correct by seeing if its derivative equals the original integrand as follows:

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

Mathematica graphics

As you can see Mathematica easily verifies Rubi's antiderivative correct, but has a hard time verifying its own antiderivative correct...

Albert and I are working on publishing the program used to thoroughly test each new version of Rubi before being released. The test program ensures Rubi's result equals the optimal antiderivative for the over 71000 problems in the test-suite. And yes, the optimal antiderivatives have all been verified correct by differentiation.

Of course, the optimal antiderivatives stored in the test-suite are actually just the simplest ones found so far. If you should find a substantially simpler antiderivative than the one in the test-suite, please report it so the test-suite can be made even harder on Rubi!

If all that has got you interested in joining Rubi's community of users, check out its website or talk to us in our Gitter chatroom.

POSTED BY: Patrick Scheibe
4 Replies

enter image description here - Congratulations! This post is now a Staff Pick as distinguished by a badge on your profile! Thank you, keep it coming!

POSTED BY: Moderation Team

Terrific. And yet another reason why the teaching of calculus MUST change.

POSTED BY: Seth Chandler

Update

We released version 4.16.0.4 recently which comes with one significant improvement: It saves the Rubi package as an MX file after the first load. This reduces the loading time for all subsequent calls to <<Rubi` drastically. On my machine, the first loading of the package took about 85 seconds. Loading the Rubi after this first run takes not more than 0.4 seconds. That is excellent news for users that regularly rely on Rubi.

I decided to build the MX files on the users' machine and not distribute them. The reason is simple: Rubi works on Mathematica 7-11.3 and MX files depend on the version and the operating system. However, users of Rubi don't have to care about these details. They merely load Rubi, and the creation and loading of the MX files is done automatically.

POSTED BY: Patrick Scheibe

How to cite Rubi

If you want to cite Rubi in your scientific work, you can now refer to the official paper in the Journal of Open Source Software we have prepared in the last 2 months.

DOI

The BibTeX entry is

@article{Rich2018,
  doi = {10.21105/joss.01073},
  url = {https://doi.org/10.21105/joss.01073},
  year  = {2018},
  month = {dec},
  publisher = {The Open Journal},
  volume = {3},
  number = {32},
  pages = {1073},
  author = {Albert Rich and Patrick Scheibe and Nasser Abbasi},
  title = {Rule-based integration: An extensive system of symbolic integration rules},
  journal = {Journal of Open Source Software}
}
POSTED BY: Patrick Scheibe
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract