Out of some simplification, the term Abs[Cos[x]]Sec[x] appears.

How can I make the code automatically transform Abs[Cos[x]]Sec[x] to Sign[Cos[x]]?

  • $\begingroup$ he problem seems to be that Cos[Pi/2]=0 and herefore the Sec is infinite. You have to exclude Pi/2 from the domain $\endgroup$ – mattiav27 Mar 19 '19 at 8:59
  • 1
    $\begingroup$ If this term came out of a call to Simplify or FullSimplify, take a look at TransformationFunctions. $\endgroup$ – Chip Hurst Mar 19 '19 at 11:39
  • $\begingroup$ FullSimplify[Abs[f[x]]/f[x]] works, so I suspect it's the autosimplification of 1/Cos[x] to Sec[x] -- or, rather, that Sec[x] is not treated like 1/Cos[x] in all transformations. $\endgroup$ – Michael E2 Mar 19 '19 at 13:02
  • $\begingroup$ Not a great way to do it: Block[{Cos = Hold[Cos], Sec = 1/Hold[Cos][#] &}, ReleaseHold@FullSimplify[Abs[Cos[x]] Sec[x]]] $\endgroup$ – Michael E2 Mar 19 '19 at 13:07
  • 1
    $\begingroup$ To extend @Chip's comment: Try TransformationFunctions -> {Automatic, # /. Sec[t_] :> 1/(Abs[Cos[t]] Sign[Cos[t]]) &} $\endgroup$ – Michael E2 Mar 19 '19 at 13:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.