Mathematica often simplifies trigonometric expressions, for example replacing $\sin(\frac{\pi}{4})$ with $\frac{1}{\sqrt{2}}$, or replacing $\cos(\frac{3\pi}{8})$ with $\sin(\frac{\pi}{8})$. I'd like to know how to disable this functionality, leaving everything in the form in which it was entered. Is this possible, and how much granularity is there? Can it all be blanket disabled, or do I have to disable individual relationships? And is there any difference between the first simplification, from a trig function to a real number, and the second, where a trig function is replaced with another? Can I disable one and not the other? etc.


You may consider Inactivate:

Inactivate[Sin[Pi/4], Sin]

(*Out: Inactive[Sin][Pi/4]*)

You might also explicitly replace the trig functions with Inactive versions temporarily (this gives you very granular control):

Block[{Sin = Inactive[Sin], Cos = Inactive[Cos]},
  {Sin[Pi/4] Cos[3 Pi/8]}

(* Out: {Cos[(3 Pi)/8] Sin[Pi/4]} *)

Mathematica graphics

Applying Activate to any expression containing inactive items will give you back the usual behavior.

| improve this answer | |

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.