Skip to content

Commit

Permalink
Solve more cases.
Browse files Browse the repository at this point in the history
  • Loading branch information
corywalker committed Apr 7, 2018
1 parent 550c689 commit 68c805f
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 13 deletions.
16 changes: 8 additions & 8 deletions expreduce/resources.go

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions expreduce/resources/arithmetic.m
Expand Up @@ -125,8 +125,8 @@
Verbatim[Times][beg___, a_Integer^m_Rational, a_Integer^n_Rational, end___] := beg*a^(m+n)*end;
Times[c : (Rational[_Integer, d_Integer] |
Complex[_Integer, Rational[_Integer, d_Integer]]),
Power[a_Integer, Rational[1, r_Integer]]] :=
Times[c*a, a^(1/r - 1)] /; (Mod[d, a] === 0 && a > 1)
Power[a_Integer, Rational[1, r_Integer]], rest___] :=
Times[c*a, a^(1/r - 1), rest] /; (Mod[d, a] === 0 && a > 1)
Sin[x_]*Cos[x_]^(-1)*rest___ := Tan[x]*rest;
Cos[x_]*Sin[x_]^(-1)*rest___ := Cot[x]*rest;
Attributes[Times] = {Flat, Listable, NumericFunction, OneIdentity, Orderless, Protected};
Expand Down Expand Up @@ -207,6 +207,7 @@
ESameTest[-(I/(2 Sqrt[3])), Times[-2/12 I,Sqrt[3]]],
ESameTest[-(I/(2 Sqrt[3])), Times[2/-12 I,Sqrt[3]]],
ESameTest[(3+(5 I)/4)/Sqrt[3], Times[1+5/12 I,Sqrt[3]]],
ESameTest[I/(2 Sqrt[3] a^2), (0+1/6*I)*3^(1/2)*a^(-2)],
], EKnownFailures[
ESameTest[-2^(1/3), (-2)*2^(-2/3)],
ESameTest[-2^(1+a), (-2)*2^(a)],
Expand Down
7 changes: 5 additions & 2 deletions expreduce/resources/simplify.m
Expand Up @@ -45,8 +45,11 @@
tryVal = FixedPoint[Replace[#, expandRules]&, e];
If[LeafCount[tryVal] < LeafCount[e], e = tryVal];
];
tryVal = ComplexExpand[e];
If[LeafCount[tryVal] < LeafCount[e], e = tryVal];
(*Avoid expressions containing expensive expressions to expand.*)
If[FreeQ[e, a_Plus^(b_Integer?((# >= 5) &))],
tryVal = ComplexExpand[e];
If[LeafCount[tryVal] < LeafCount[e], e = tryVal];
];
(* also need to try complexexpand to simplify cases like (-1)^(1/3) (1 + I Sqrt[3]) *)
e = Replace[e, Sqrt[inner_] :> Sqrt[FactorTerms[inner]]];
e
Expand Down
2 changes: 1 addition & 1 deletion expreduce/resources/solve.m
Expand Up @@ -280,7 +280,7 @@
fullSimplified = eqn // FullSimplify;
If[fullSimplified =!= eqn, Return[Solve[fullSimplified, var]]];

Print["Solve found no solutions"];
Print["Solve found no solutions for ", eqn, " for ", var];
SolveFailed
];
solveMultOrdered[eqns_List, vars_List] :=
Expand Down
2 changes: 2 additions & 0 deletions expreduce/resources/trig.m
Expand Up @@ -16,6 +16,7 @@
Sin[(5/2)*Pi] := 1;
Sin[Indeterminate] := Indeterminate;
Sin[ArcSin[a_]] := a;
Sin[ArcTan[1/2]] := 1/Sqrt[5];
Attributes[Sin] = {Listable, NumericFunction, Protected};

Cos::usage = "`Cos[x]` is the cosine of `x`.";
Expand All @@ -37,6 +38,7 @@
Cos[inner : Verbatim[Plus][Repeated[_*I]]] := Cosh[-I*inner // Distribute]
Cos[Indeterminate] := Indeterminate;
Cos[ArcCos[a_]] := a;
Cos[ArcTan[1/2]] := 2/Sqrt[5];
Attributes[Cos] = {Listable, NumericFunction, Protected};

Tan::usage = "`Tan[x]` is the tangent of `x`.";
Expand Down

0 comments on commit 68c805f

Please sign in to comment.