Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
1  
Would these help? 1 2 3 4 :) – drN Oct 10 '12 at 19:07
up vote 4 down vote accepted

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])
*)
share|improve this answer
1  
Slightly more compact: Solve[{Csc Sin == 1, Cos^2 + Sin^2 == 1, 1 == Cos Sec}, Csc, {Cos, Sin}] – J. M. Oct 11 '12 at 0:59
    
@J.M. Thanks. Updated with a little more general thing using yours – Dr. belisarius Oct 11 '12 at 13:43
    
Hmmm ... probably one should take in account the negative radicals to get the expressions for all quadrants. – Dr. belisarius Oct 11 '12 at 13:46
    
@Dr.belisarius -- I've added a new answer to partially address the issues with different quadrants – Simon May 19 at 4:54

Here's some code that can solve this problem that I wrote a while back for another question.

$TrigFns = {Sin, Cos, Tan, Csc, Sec, Cot};
(WRules = $TrigFns == (Through[$TrigFns[x]] /. x -> 2 ArcTan[t] // 
        TrigExpand // Together) // Thread);

invWRules = #[[1]] -> Solve[#, t, Reals] & /@ WRules;

convert[expr_, (trig : Alternatives @@ $TrigFns)[x_]] := 
 Block[{temp, t}, 
  temp = expr /. x -> 2 ArcTan[t] // TrigExpand // Factor;
  temp = temp /. (trig /. invWRules) // FullSimplify // Union;
  Or @@ temp /. trig -> HoldForm[trig][x] /. ConditionalExpression -> (#1 &)]

In the example provided in the question:

convert[Csc[x], Sec[x]] // ReleaseHold

$$-\frac{\sec (x)}{\sqrt{\sec (x)-1} \sqrt{\sec (x)+1}} \quad \Big|\Big|\quad \frac{\sec (x) \sqrt{\frac{\sec (x)+1}{\sec (x)-1}}}{\sec (x)+1} $$

These solutions cover both quadrants (although the result could be presented in a nicer form).
To check this, let's plot:

Plot[{Csc[x], -(Sec[x]/(Sqrt[-1 + Sec[x]] Sqrt[1 + Sec[x]])), (
  Sec[x] Sqrt[(1 + Sec[x])/(-1 + Sec[x])])/(1 + Sec[x])}, {x, 0, 2 Pi},
 PlotStyle -> {Blue, Dotted, Dashed}]

Plot of Csc rewritten in terms of Sc

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.