# How to automatically transform Abs[Cos[x]]Sec[x] to Sign[Cos[x]]?

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]]?

• 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 – mattiav27 Mar 19 at 8:59
• If this term came out of a call to Simplify or FullSimplify, take a look at TransformationFunctions. – Chip Hurst Mar 19 at 11:39
• 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. – Michael E2 Mar 19 at 13:02
• Not a great way to do it: Block[{Cos = Hold[Cos], Sec = 1/Hold[Cos][#] &}, ReleaseHold@FullSimplify[Abs[Cos[x]] Sec[x]]] – Michael E2 Mar 19 at 13:07
• To extend @Chip's comment: Try TransformationFunctions -> {Automatic, # /. Sec[t_] :> 1/(Abs[Cos[t]] Sign[Cos[t]]) &} – Michael E2 Mar 19 at 13:16