1 of 3

Here's a solution based on Weierstrass substitution. Since you did not seem to care about branch cuts of the formula in your question, I shall also be careless with them in my answer!

convert[expr_, (trig : Cos | Sin | Tan | Cot | Csc | Sec)[x_]] :=
Module[{temp, t},
temp = expr /. x -> 2 ArcTan[t] // TrigExpand // Factor;
temp = temp /. t -> Switch[trig,
Cos, Sqrt[1 - t]/Sqrt[1 + t], Sec, Sqrt[1 - 1/t]/Sqrt[1 + 1/t],
Sin, (Sqrt[1 - t^2] + 1)/t,   Csc, (Sqrt[1 - 1/t^2] + 1)/(1/t),
Tan, (Sqrt[1 + t^2] - 1)/t,   Cot, (Sqrt[1 + 1/t^2] - 1)/(1/t)];
temp /. t -> HoldForm[trig][x] // Apart // FullSimplify
]


Note the HoldForm at the end - otherwise things like 1/Sin[x] would be automatically rewritten as Csc[x].

Testing against the examples given in your question:

In[2]:= convert[Sin[x], Cos[x]]
Out[2]= Sqrt[1 - Cos[x]^2]

In[3]:= convert[Cos[x], Sin[x]]
Out[3]= - Sqrt[1 - Sin[x]^2]

In[4]:= convert[Cos[x]/Sin[x], Tan[x]]
Out[4]= 1/Tan[x]


Finally, we can examine the validity of the answers using something like

testconvert[expr_, (trig : Cos | Sin | Tan | Cot | Csc | Sec)[x_]] :=
Reduce[expr == ReleaseHold[convert[expr, trig[x]]] && 0 <= x < 2 Pi, x, Reals]


Then, for example

In[10]:= convert[Cos[x] Sin[x], Sec[x]] // ReleaseHold
testconvert[Cos[x] Sin[x], Sec[x]]

Out[10]= Cos[x] Sqrt[1 - Cos[x]^2]

Out[11]= 0 <= x <= Pi || x == (3 Pi)/2

 answered Jan 21 '12 at 12:25 Simon 6,08713258