# How to switch Tan[x] for Sin[x]/Cos[x] without Mathematica changing the latter for the former? [duplicate]

When I ask Mathematica to do this:

(Sin[2 x] - Tan[2 x])/x^3 /. Tan[x_] -> Sin[x]/Cos[x]


It makes no change because Mathematica interprets Tan[x] as the same thing as Sin[x]/Cos[x]. Is it possible to force Mathematica to rewrite:

$$\frac{\sin(2x)-\tan(2x)}{x^3}$$

As:

$$\frac{\sin(2x)-\frac{\sin(x)}{\cos(x)}}{x^3}?$$

I know this has to do with evaluation control but I'm looking at the documentation and am not finding anything that resembles this. At the time, I know I could make this converting everything to string and using string substitutions but I guess this would be kinda cumbersome for my needs.

• (Sin[2 x] - Tan[2 x])/x^3 /. Tan[x_] -> HoldForm[Sin[x]/Cos[x]] ?
– Syed
Commented Apr 1, 2023 at 2:57
• @Syed This is really nice. I was trying some of these functions (Hold, HoldForm, etc) but wasn't sure where is the right place to apply them. I also found a "cheap" way, which is convert the functions I have like Cos[x] to cos[x], make whatever operations I need on it and then convert it back. Commented Apr 1, 2023 at 3:00

SetSystemOptions[