As some of you might know, I'm working with Albert Rich to improve the accessibility of his Rubi package for rule-based integration. I'm almost done with a first version that contains several improvements, but for the current task, I'd like to ask for input from the community.

One major strength of Rubi is that it can provide all steps and intermediate results of an integration. This, however, was a bit broken since the intermediate output was not overwritten when you evaluate an integration again. I reworked this completely and now the big question is how to format rules and intermediate results in the most stunning way.

A "step" can either be a RubiRule or a RubiIntermediateResult and I get them as

RubiRule[conditionString,
         HoldComplete[leftHandSide],
         HoldComplete[rightHandSide],
         ruleNumber]

RubiIntermediateResult[HoldComplete[expression]]

The conditionString and the ruleNumber is not always there, but often we have this information.

Question: Who can come up with the most stunning display of these two types of expressions? Go crazy with Style, Panel, Grid, etc. but in the end, we need a nice looking output for both types.

I have prepared a small notebook that contains an example list of steps in the last portion of the Reap result. This notebook is not meant to be evaluated since you obviously don't have my development version of Rubi.m, but you can use the output that I provided to implement and test pretty-printing for RubiRule and RubiIntermediateResult.

Import["http://halirutan.github.io/Mathematica-SE-Tools/decode.m"]["http://i.stack.imgur.com/K0wqL.png"]

At the moment, it looks like this in Rubi

output

  • 1
    Looks like Rubi.m file is missing. – Anjan Kumar Jun 13 at 9:28
  • Is it possible to get the conditions as expressions, rather than strings? – Lukas Lang Jun 13 at 9:29
  • @AnjanKumar Yes, it is missing because this version currently only available on my machine. I wanted to give people a complete list of Rubi steps which you can just copy from the output that is also in the notebook. I'm making this clear again in the question. – halirutan Jun 13 at 9:31
  • @LukasLang At the moment not. The code which creates this string is from Albert and didn't want to throw everything overboard. So I re-used his complete code of extracting conditions, rules, and results and simply changed the code so that these expressions are not printed but returned. The condition string contains "If" and "let" which is created in deeply nested code that inspects the DownValues of the definitions for Rubi's Int function. I didn't dare to touch this for now. – halirutan Jun 13 at 9:35
  • @halirutan Ok, fair enough – Lukas Lang Jun 13 at 9:37

To give you an idea of what I had in mind, I created something that I don't hate completely. Working with Grid, Column is a pain when you want to align and size everything to your needs, but it does the job.

img

Intermediate results can be copied by clicking on them. Here is the code that was used as a basis for the above (I changed some small things later). The final list was wrapped in Column and I riffled some down-arrows in between.

Format[RubiIntermediateResult[HoldComplete[expr_]]] :=
 Tooltip[
  Button[
   Deploy@Panel[Row[
      {Style["Intermediate Result:", "Label", Gray],
       Style[HoldForm[expr], ColorData[99, 2]]
       }, Spacer[10]],
     FrameMargins -> 5
     ], CopyToClipboard[Defer[expr]], Appearance -> None], 
  "Click to copy as input"
  ]

Format[RubiRule[cond_, HoldComplete[lhs_], HoldComplete[rhs_], 
   rule_: "General"]] :=
 Deploy@Panel[
   Grid[{
     {
      Style["Rubi Rule:", "Label", Gray],
      Style[rule, "Label"]},
     {
      Style["Condition:", "Label", Gray],
      Style[If[cond === "", "None", cond], ColorData[99, 3]]
      },
     {
      Style["Transformation:", "Label", Gray],
      Row[{
        Style[TraditionalForm@HoldForm[lhs], ColorData[99, 1]],
        Style["\[DoubleLongRightArrow]", 14, ColorData[99, 1]],
        Style[TraditionalForm@HoldForm[rhs], ColorData[99, 1]]
        }, Spacer[10], Alignment -> Center
       ]
      }
     },
    Alignment -> {{Right, Left}, {Center, Center, Center}},
    Spacings -> {1, 1},
    Dividers -> {False, {2 -> LightGray, 3 -> LightGray}}
    ]
   ]

Update

Although no one posted a solution, I got feedback and was able to partially include it. I discussed things with Albert and we decided to a simple left/right scheme. I took the suggestion from Kuba to make the rules closable and show only the transformation rule initially. With the help of the answers here, I was able to make the layout render in the same font size as the rest! Thank you for that.

If you like, you can try it out yourself. People with Mathematica version 11.3 can install Rubi directly from GitHub

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

$LoadShowSteps = True;
<< Rubi`
Steps@Int[((125 - x^3)^(1/3))^2, x]

Mathematica graphics

The suggestion of @b3m2a1 went into the display of the integration statistics which uses a BoxForm`ArrangeSummeryBox

Mathematica graphics

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.