I would like to avoid multiplying explicitely by the denominator, because I'm working with huge fractions.
Consider
f[x_,y_] := Cos[x - y]/(Sin[x] Cos[y])+ 1/Sin[x];
Mathematica transforms this into Csc[x] + Cos[x - y] Csc[x] Sec[y] which I'd like to avoid: my goal is precisely to get rid of the singularities. So I used
$PrePrint = # /. {Csc[z_] :> 1/Defer@Sin[z], Sec[z_] :> 1/Defer@Cos[z]} &;
but then Together[f[x,y]] does not put f with a common denominator, and Numerator just returns f[x,y].
So how can I get the numerator of f[x,y]? It should be Cos[x - y] + Cos[y].
$Post,$PrePrint, etc. just use the appropriate transformation rule, e.g.g = # /. {Csc[z_] :> 1/Defer@Sin[z], Sec[z_] :> 1/Defer@Cos[z]} &;andf[x,y] // g // Together // Numerator– LLlAMnYP Nov 02 '16 at 18:35h[x_,y_] = f[x,y] // g // Together // Numerator, thenh[1.1,2.2]does not evaluateCos[2.2]because ofDefer. So I changedgtog = # /. {Csc[z_] :> 1/Hold@Sin[z], Sec[z_] :> 1/Hold@Cos[z]} &;and definedh[x_,y_] = f[x,y] // g // Together // Numerator // Releasehold. It's seems to work, do you see any problem with that? – anderstood Nov 02 '16 at 18:52$Postresults in nestedTimes[..., Times[...]]expressions that are cleaned up only when displayed. It's hard to say, whether you'll run into more similar problems for more complicated expressions. Try it out with your actual use case and report back if you run into further problems. – LLlAMnYP Nov 03 '16 at 07:41