28

How can I prevent Mathematica from using the "old fashioned" functions "Sec" and "Csc"?

In Germany these functions are "old fashioned" as they are not taught anymore at school.

Mr.Wizard
  • 271,378
  • 34
  • 587
  • 1,371
Klaus
  • 389
  • 3
  • 3
  • What do you mean by prevent? Why do you think sec csc are old fashioned –  Jul 02 '12 at 09:09
  • 1
    Those functions are no more "old fashioned" than logarithms and cotangents. –  Jul 02 '12 at 09:12
  • 21
    @Nunoxic: I don't know about the "old fashioned" bit, but I perhaps Klaus (like myself) would simply prefer seeing expressions like "$\frac{x + y}{\sin x \cos y}$" rather than "$(x+y)\csc x \sec y$". –  Jul 02 '12 at 09:17
  • 9
    @Siminore Your statement is not true. At least here in Germany, nowadays nobody will use Sec or Csc. –  Jul 02 '12 at 10:17
  • 3
    @Siminore: Csc, Sec are hardly much used in any parts of the world, at any level of school, not only in Germany. In Italy and Switzerland they are not used at all (they where mentioned once in the entire curriculum up to a M.Sc. at the Swiss Federal Institute of Technology, and they where not even taught in the USA when I was there), and hardly anyone uses them in the technics / physics. The reason being: they mostly worsen the readability of complex formula... Even though I know how to handle them, I hate them!! – Dieter Ernst Dec 01 '16 at 01:48
  • 5
    I want to add my voice to those who do not like Ccs and sec. Whenever I see them I have in my mind convert them to normal sin/cos. I wish Mathematica does not use them either. – Nasser Apr 07 '17 at 04:21
  • I totally agree, once you have cos, sin and tan (and their inverse functions) you do not need other symbols. 90% of mathematicians and physicists always have to go to check the exact def of Sec, Csc, Cot etc when they find one. – Quillo Jan 24 '24 at 11:12

3 Answers3

33

This is similar to my Log question and similar methods can be used.

$PrePrint = # /. {
     Csc[z_] :> 1 / Defer@Sin[z],
     Sec[z_] :> 1 / Defer@Cos[z]
  } &;

Example:

(x + y) Csc[x] Sec[y]
(x + y)/(Cos[y] Sin[x])
Mr.Wizard
  • 271,378
  • 34
  • 587
  • 1,371
  • why not close then? – rm -rf Jul 02 '12 at 13:42
  • @R.M well I meant similar in the generic sense. I see this as a closely related but at present different question, and someone may post an answer that goes much deeper than my simple one. Perhaps if that doesn't happen this question can be merged with mine and become a second example. – Mr.Wizard Jul 02 '12 at 14:07
  • 1
    This was useful. Some, like me, will want to extend this to Cot, as follows.

    $PrePrint = # /. { Csc[z_] :> 1 / Defer@Sin[z], Sec[z_] :> 1 / Defer@Cos[z], Cot[z_] :> Defer@Cos[z] / Defer@Sin[z] } &;

    – Rico Picone Mar 10 '15 at 03:10
10

Using the neat trick Chip showed in this answer:

SetSystemOptions["SimplificationOptions" -> "AutosimplifyTrigs" -> False];

TrigFactor[(x + y) Csc[x] Sec[y]]
   (x + y)/(Cos[y] Sin[x])

TrigFactor[Sec[t]^2]
   1/Cos[t]^2
J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
  • 1
    The AutosimplifyTrigs option is ignored by Simplify and FullSimplify, which still return Csc, Cot, Sec. Instead, Mr. Wizard solution works in that case too. – divenex May 25 '22 at 12:41
7

According to this MathGroup post, it's possible to get rid of the superfluous Csc and Sec by doing the following:

Unprotect[Csc, Sec];
Format[Csc[x_]] := HoldForm[1/Sin[x]];
Format[Sec[x_]] := HoldForm[1/Cos[x]];
Protect[Csc, Sec];

That old solution at least gives you the following:

Csc[t]

$\frac{1}{\sin(t)}$

Sec[t]

$\frac{1}{\cos(t)}$

but it still won't be able to print out

$\frac{1}{\cos^2(t)}$

if you type in Sec[t]^2. Instead you get

$\left(\frac{1}{\cos(t)}\right)^2$

But maybe that's OK for your taste. If not, then Mr. Wizard's solution is better because it does put the square in the denominator.

Jens
  • 97,245
  • 7
  • 213
  • 499
  • +1, this method is only one that worked for me actually since I was using print[] to print an expression with Csc. For example, Print[Csc[x]] and only this method will print 1/Sin[x] – Nasser Apr 07 '17 at 04:19