Skip to content

Commit

Permalink
Properly handle integer exponents of I.
Browse files Browse the repository at this point in the history
  • Loading branch information
corywalker committed Sep 18, 2017
1 parent 587751f commit e867a03
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 45 deletions.
4 changes: 3 additions & 1 deletion examples/test_rubi.m
@@ -1,6 +1,8 @@
(*testproblems = ReadList["/Users/cwalker32/Code/gocode/src/github.com/corywalker/expreduce/test_rubi/test_rubi.m"];*)
(*testproblems = DeleteCases[testproblems, Null];*)
testproblems = ReadList["/Users/cwalker32/Downloads/test.m"][[1]];
(*testproblems = ReadList["/Users/cwalker32/Downloads/test.m"][[1]];*)
(*testproblems = ReadList["/Users/cwalker32/Downloads/easy_probs.m"][[1]];*)
testproblems = ReadList["/Users/cwalker32/Downloads/easier_probs.m"][[1]];
Print[Length[testproblems]];

testi = 1;
Expand Down
10 changes: 10 additions & 0 deletions expreduce/evalstate.go
Expand Up @@ -137,12 +137,22 @@ func (es *EvalState) Init(loadAllDefs bool) {
es.MarkSeen("System`Stub")
es.MarkSeen("System`$Failed")

es.MarkSeen("System`Cosh")
es.MarkSeen("System`Sinh")
es.MarkSeen("System`Tanh")

es.MarkSeen("System`Sec")
es.MarkSeen("System`Sech")
es.MarkSeen("System`Csc")
es.MarkSeen("System`Csch")
es.MarkSeen("System`Cot")
es.MarkSeen("System`Coth")
es.MarkSeen("System`ArcSin")
es.MarkSeen("System`ArcSinh")
es.MarkSeen("System`ArcCos")
es.MarkSeen("System`ArcCosh")
es.MarkSeen("System`ArcTan")
es.MarkSeen("System`ArcTanh")

for _, defSet := range GetAllDefinitions() {
for _, def := range defSet.Defs {
Expand Down
64 changes: 32 additions & 32 deletions expreduce/resources.go

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions expreduce/resources/power.m
Expand Up @@ -55,6 +55,11 @@
Power[Rational[a_,b_], -1] := Rational[b,a];
Power[Rational[a_,b_], e_?Positive] := Rational[a^e,b^e];
Power[Power[x_, y_Rational], -1] := Power[x, -y];
I^e_Integer := Switch[Mod[e, 4],
0, 1,
1, I,
2, -1,
3, -I];
Attributes[Power] = {Listable, NumericFunction, OneIdentity, Protected};
Tests`Power = {
ESimpleExamples[
Expand Down Expand Up @@ -209,6 +214,12 @@
(*TODO: actually use Complex atom type*)
I::usage = "`I` is the imaginary number representing `Sqrt[-1]`.";
Attributes[I] = {Locked, Protected, ReadProtected};
Tests`I = {
ESimpleExamples[
ESameTest[-1, I^2],
ESameTest[1, I^4]
]
};

possibleExponents[n_Integer, m_Integer] :=
Flatten[Permutations /@ ((PadRight[#, m]) & /@
Expand Down
26 changes: 14 additions & 12 deletions expreduce/resources/rubi_loader.m
Expand Up @@ -61,6 +61,8 @@
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"];
Expand All @@ -79,18 +81,18 @@


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"];*)
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[];*)
Expand Down

0 comments on commit e867a03

Please sign in to comment.