/
rubi_loader.m
122 lines (77 loc) · 3.64 KB
/
rubi_loader.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
(* ::Package:: *)
(* ::Title:: *)
(*Rubi (Rule-Based Integrator) Package*)
(* Clone https://github.com/corywalker/rubi into the root dir of Expreduce. *)
BeginPackage["Rubi`"]
Int::usage =
"Int[expn,var] returns the antiderivative (indefinite integral) of <expn> with respect to <var>.
Int[list,var] returns a list of the antiderivatives of the elements of <list> with respect to <var>.";
IntShowSteps::usage = "IntShowSteps[expn,var] shows all the rules and intermediate steps required to integrate <expn> with respect to <var>, and returns Null.";
Dist::usage = "Dist[expn1,expn2,var] distributes <expn1> over <expn2>.";
Subst::usage = "Subst[expn1,var,expn2] substitutes <expn2> for <var> in <expn1>.";
ShowSteps::usage = "If ShowSteps is True and the ShowSteps package has been loaded, integration steps are displayed.";
$StepCounter::usage = "If the ShowSteps package has been loaded and $StepCounter is an integer, it is incremented each time an integration rule is applied.";
$RuleColor::usage = "$RuleColor is the color used to display rules when showing integration steps. The default rule color is red."
$ConditionColor::usage = "$ConditionColor is the color used to display application conditions when showing integration steps. The default condition color is blue."
sin::usage = "Inert sine function";
cos::usage = "Inert cosine function";
tan::usage = "Inert tangent function";
cot::usage = "Inert cotangent function";
sec::usage = "Inert secant function";
csc::usage = "Inert cosecant function";
Begin["`Private`"]
(*LoadRules[filename_String] :=
Module[{object},
object=PrintTemporary["Loading "<>filename<>".m..."];
Get[NotebookDirectory[]<>filename<>".m"];
NotebookDelete[object];
Null]*)
LoadRules[filename_String] := (
Print["Loading "<>filename<>".m..."];
loadRes = Get["__res__/rubi/"<>filename<>".m"];
If[loadRes === $Failed, Print["Loading failed!"]];
)
Unprotect[Int]; Clear[Int];
SetAttributes [Int, {Listable}];
ShowSteps = Global`$LoadShowSteps===True;
Print["Loading Rubi integration suite by Albert Rich."];
(*LoadRules["ShowStep routines"];*)
LoadRules["Integration Utility Functions"];
LoadRules["9.1 Integrand simplification rules"];
LoadRules["1.1.1 Linear binomial products"];
LoadRules["1.1.3 General binomial products"];
LoadRules["1.2.1 Quadratic trinomial products"];
LoadRules["1.2.2 Quartic trinomial products"];
LoadRules["1.2.3 General trinomial products"];
LoadRules["1.2.4 Improper trinomial products"];
LoadRules["1.1.4 Improper binomial products"];
LoadRules["1.3 Miscellaneous algebraic functions"];
LoadRules["9.3 Piecewise linear functions"];
LoadRules["2 Exponentials"];
LoadRules["3 Logarithms"];
LoadRules["4.1 Sine"];
LoadRules["4.2 Tangent"];
LoadRules["4.3 Secant"];
LoadRules["4.4 Miscellaneous trig functions"];
LoadRules["5 Inverse trig functions"];
LoadRules["6 Hyperbolic functions"];
LoadRules["7 Inverse hyperbolic functions"];
LoadRules["8 Special functions"];
LoadRules["9.2 Derivative integration rules"];
LoadRules["9.4 Miscellaneous integration rules"];
FixIntRules[];
(*If[Global`$LoadShowSteps===True, StepFunction[Int]];*)
Protect[Int];
End [];
EndPackage [];
(*Helper debug functions in global context.*)
printDownValues[args_, sym_] :=
Print /@ Map[{#, MatchQ[args, #]} &,
Map[List @@ (#[[1]][[1]]) &, DownValues[sym]]];
isPartialMatch[args_, dv_] := MatchQ[args, List @@ (dv[[1]][[1]])];
isFullMatch[args_, dv_, sym_] :=
Replace[args, dv /. sym -> List] =!= args;
printPartitalMatchingDownValues[args_, sym_, n_] :=
Select[DownValues[sym], isPartialMatch[args, #] &, n];
printMatchingDownValues[args_, sym_, n_] :=
Select[DownValues[sym], isFullMatch[args, #, sym] &, n];