# Solving trig identities in specific terms

How would you solve a problem like "write csc(x) in terms of sec(x)" in Mathematica? The best I can get is "True."

http://math.stackexchange.com/questions/167935/write-cscx-in-terms-of-secx

I'm asking in order to better understanding of Mathematica, and as a way to verify I'm solving my trig identities correctly. It's been a while since I've done identities, and I'm trying to brush off the cobwebs before its too late. I was told that I'll need this skill later on in Calculus.

-
Would these help? 1 2 3 4 :) –  drN Oct 10 '12 at 19:07

Just playing tricks:

Cases[Join @@ Solve[{csc == 1/sin, sec == 1/cos, cos cos + sin sin == 1}, {csc, sin, cos}],
HoldPattern[csc -> _]]
(*
->{csc -> -(sec/Sqrt[-1 + sec^2]), csc -> sec/Sqrt[-1 + sec^2]}
*)


Edit

More generally (by using @J.M's suggestion below):

trigExpress[expr_, inTerms_] :=
Module[
{set = {sin, cos, tan, sec, csc},
rels = {csc sin == 1, cos^2 + sin^2 == 1, 1 == cos sec, tan == sin/cos}},
oneInTermsOf[one_, of_] := Solve[rels, {one}, Complement[set, {one, of}]];
allIntermsOf[of_] :=       Flatten[oneInTermsOf[#, of] & /@ Complement[set, {of}]];
Expand@FullSimplify[expr /. allIntermsOf[inTerms]]
]


so:

trigExpress[(sin + cos)/tan, sec]
(*
-> 1/sec - 1/(sec Sqrt[-1 + sec^2])
*)

-
Slightly more compact: Solve[{Csc Sin == 1, Cos^2 + Sin^2 == 1, 1 == Cos Sec}, Csc, {Cos, Sin}] –  Guess who it is. Oct 11 '12 at 0:59
@J.M. Thanks. Updated with a little more general thing using yours –  belisarius Oct 11 '12 at 13:43
Hmmm ... probably one should take in account the negative radicals to get the expressions for all quadrants. –  belisarius Oct 11 '12 at 13:46