|
23 | 23 | Subst::usage = "Subst[expn1,var,expn2] substitutes <expn2> for <var> in <expn1>."; |
24 | 24 | Step::usage = "Step[Int[expn, var]] displays the first step in the integration of <expn> with respect to <var> and returns the intermediate result."; |
25 | 25 | Steps::usage = "Steps[Int[expn, var]] displays all the steps in the integration of <expn> with respect to <var> and returns the antiderivative."; |
26 | | -Stats::usage = "Stats[Int[expn, var]] prints statistical information of the integration before returning the antiderivative <expn> with respect to <var>." <> |
27 | | - "It consists of (a) the number of steps used to integrate, (b) the number of distinct rules used, (c) is the leaf count size of the input," <> |
| 26 | +Stats::usage = "Stats[Int[expn, var]] prints statistical information of the integration before returning the antiderivative <expn> with respect to <var>. " <> |
| 27 | + "It consists of (a) the number of steps used to integrate, (b) the number of distinct rules used, (c) is the leaf count size of the input, " <> |
28 | 28 | "(d) the leaf count size of the antiderivative, and (e) the rule-to-size ratio of the integration (i.e. the quotient of (b) and (c))."; |
29 | 29 |
|
30 | 30 | $RubiVersion::usage = "$RubiVersion shows the currently loaded version of Rubi."; |
31 | 31 | RubiRule::usage = "RubiRule is a symbolic wrapper that is used when displaying integration steps."; |
32 | 32 | RubiIntermediateResult::usage = "RubiIntermediateResult is a symbolic wrapper that is used when displaying integration steps."; |
33 | | -RubiStats::usage = "RubiStats is a symbolic wrapper that contains statistical information about an integration." <> |
34 | | - "It consists of (a) the number of steps used to integrate, (b) the number of distinct rules used, (c) is the leaf count size of the input," <> |
| 33 | +RubiStats::usage = "RubiStats is a symbolic wrapper that contains statistical information about an integration. " <> |
| 34 | + "It consists of (a) the number of steps used to integrate, (b) the number of distinct rules used, (c) is the leaf count size of the input, " <> |
35 | 35 | "(d) the leaf count size of the antiderivative, and (e) the rule-to-size ratio of the integration (i.e. the quotient of (b) and (c))."; |
36 | | -RubiPrintInformation::usage = "RubiPrintInformation is an option to Steps and Stats that prints information if set to True and returns as a list otherwise."; |
| 36 | +RubiPrintInformation::usage = "RubiPrintInformation is an option to Steps and Stats that prints information if set to True and returns as a list otherwise. " <> |
| 37 | + "For Steps only: RubiPrintInformation can also be set to TeXForm or TraditionalForm to produce a stylized step-by-step solution; " <> |
| 38 | + "issues a message when set to anything other than True, False, TeXForm or TraditionalForm, but returns the steps as a list nevertheless."; |
37 | 39 | RubiClearMemoryImages::usage = "RubiClearMemoryImages[] deletes the memory files that are created for each system to speed-up the loading time of the package. " <> |
38 | 40 | "The memory files are recreated during the next loading of the Rubi package."; |
39 | 41 |
|
|
95 | 97 |
|
96 | 98 | Unprotect[Int]; Clear[Int]; Clear[Unintegrable]; Clear[CannotIntegrate]; |
97 | 99 |
|
| 100 | +(*auto-highlighting for Int[]*) |
| 101 | +SyntaxInformation[Int]={"LocalVariables"->{"Integrate",{2,2}}}; |
| 102 | +(*Formatted display of Subst*) |
| 103 | +Subst /: MakeBoxes[HoldPattern@Subst[expr_,src_,tar_], TraditionalForm] := RowBox@{UnderscriptBox[StyleBox["subst.", FontSize -> Medium], RowBox[{MakeBoxes[src, TraditionalForm], ":\[Rule]", MakeBoxes[tar, TraditionalForm]}]], MakeBoxes[expr, TraditionalForm]} |
| 104 | + |
98 | 105 | (* The order of loading the rule-files below is crucial to ensure a functional Rubi integrator! *) |
99 | 106 | LoadRules[$utilityPackage]; |
100 | 107 | LoadRules[{"9 Miscellaneous", "9.1 Integrand simplification rules"}]; |
|
338 | 345 | Options[Steps] = { |
339 | 346 | RubiPrintInformation -> True |
340 | 347 | }; |
| 348 | +SyntaxInformation[Steps] = {"ArgumentsPattern" -> {_, OptionsPattern[]}, "OptionNames" -> ToString /@ First /@ Options[Steps]}; (* front end examination for Options*) |
341 | 349 | Int::wrngUsage = "Wrong usage of the `1` function. Please use `1`[Int[expr, x]]."; |
| 350 | +Steps::wrngOpt = "Value of option `1` is not recognized. Acceptable specifications are `2`."; |
| 351 | +Steps[fpar___, Null, epar___] := Steps[fpar, Default[Steps, Length[{epar}]+1], epar] (*allow writing Steps[Int[expr],,opts]; cf. https://mathematica.stackexchange.com/questions/95407/skipping-middle-optional-arguments*) |
342 | 352 | Steps[Int[expr_, x_], opts : OptionsPattern[]] := Steps[Int[expr, x], $IterationLimit, opts]; |
343 | 353 | Steps[Int[expr_, x_], n_Integer, OptionsPattern[]] := Module[{result, steps}, |
344 | 354 | If[$LoadShowSteps =!= True, |
|
356 | 366 | n - 1 |
357 | 367 | ] |
358 | 368 | ]; |
359 | | - If[OptionValue[RubiPrintInformation] === True, |
360 | | - PrintRubiSteps[steps]; |
361 | | - result, |
362 | | - {steps, result} |
| 369 | + Switch[OptionValue[RubiPrintInformation], |
| 370 | + True, |
| 371 | + PrintRubiSteps[steps]; result, |
| 372 | + False, |
| 373 | + {steps, result}, |
| 374 | + TeXForm, (*not actually used, but is good as an option name*) |
| 375 | + With[{TeX2Str = Convert`TeX`ExpressionToTeX(*ToString@*TeXForm is also OK*)}, |
| 376 | + {steps, result} |
| 377 | + // Flatten // Most |
| 378 | + // Cases[RubiIntermediateResult[x_]:>"=&"<>(TeX2Str[HoldForm @@ x])<>"\\\\"] |
| 379 | + // {"\\begin{aligned}", TeX2Str@HoldForm@Int[expr, var], Sequence @@ #, "\\end{aligned}"} & |
| 380 | + // StringReplace[{"\\, d" <> ToString[var] -> "\\, \\mathrm{d}" <> ToString[var], "\\int" -> "\\displaystyle \\int"}] |
| 381 | + // StringRiffle], |
| 382 | + TraditionalForm, |
| 383 | + Grid[{"\[LongEqual]", TraditionalForm@#}& /@ |
| 384 | + Cases[Flatten@First@{steps, result}, |
| 385 | + RubiIntermediateResult[x_] :> HoldForm@@x |
| 386 | + ] // Prepend[{"",TraditionalForm@HoldForm@Int[expr,var]}], |
| 387 | + Alignment -> Left], |
| 388 | + _, |
| 389 | + Message[Steps::wrngOpt, |
| 390 | + RubiPrintInformation -> OptionValue[RubiPrintInformation], |
| 391 | + First /@ Options[Steps] |
| 392 | + ]; {steps, result} |
363 | 393 | ] |
364 | 394 | ] /; Head[x] === Symbol && If[TrueQ[n > 0], True, Message[Steps::negSteps]; False]; |
365 | 395 | Steps[___] := (Message[Int::wrngUsage, Steps]; $Failed); |
|
0 commit comments