I have a set of trig equations, c1,c2,c3 are constants, I excepted the result is
c1 c2 c3 r^2 + (c1^2 + c2^2 + c3^2 - 1) r + c1 c2 c3 == 0
but following code worked so slow, is there a faster method do this?
Eliminate[{
c1 == Cos[a] Sin[b],
c2 == Cos[b] Sin[c],
c3 == Cos[c] Sin[a],
r== Tan[a] Tan[b] Tan[c]}, {a, b, c}]
Answer
Can be made much more efficient if you replace the trigonometric stuff with explicit algebraic variables. This will involve clearing denominators and also augmenting with more algebraic expressions that enforce the basic trig identities.
eqns = {c1 == Cos[a] Sin[b], c2 == Cos[b] Sin[c], c3 == Cos[c] Sin[a],
r == Tan[a] Tan[b] Tan[c]};
e2 = Apply[Subtract, eqns, {1}];
e3 = e2 /. {Cos[a_] :> c[a], Sin[a_] :> s[a], Tan[a_] :> s[a]/c[a]};
vars = Variables[e3];
newe = Map[#^2 + s[#[[1]]]^2 - 1 &, Cases[vars, c[_]]];
allexprs = Numerator[Together[Join[e3, newe]]];
elims = Cases[vars, _c | _s];
keep = Complement[vars, elims];
elim = Eliminate[allexprs == 0, elims]
(* Out[75]= c3^2 r + c1 c2 c3 (1 + r^2) == (1 - c1^2 - c2^2) r *)
I often find it easier to use GroebnerBasis rather than Eliminate.
Timing[gb = GroebnerBasis[allexprs, keep, elims]]
(* Out[73]= {0.133516, {c1 c2 c3 - r + c1^2 r + c2^2 r + c3^2 r +
c1 c2 c3 r^2}} *)
Comments
Post a Comment