2
$\begingroup$

I manipulate equations which are trigonometric equations in mechanics. In theses equations, the custom is to use only Cos, Sin and Tan functions and not the secant and cosecant functions.

To prevent Mathematica’s use of these functions, I found this code in this forum:

$PrePrint = # /. {Csc[z_] :> 1/Defer@Sin[z],
                  Sec[z_] :> 1/Defer@Cos[z],
                  Cot[z_] :> Defer@Cos[z]/Defer@Sin[z]} &;

This code worked well until now.

But, at the moment, I need to made some substitutions in a expression and I can’t make it work.

Here the two rules that I want to use in my substitutions:

RègleCΦ = (Cos[Φ] -> Cos[η2] Cos[ψ2] + Sin[η2] Sin[θ2] Sin[ψ2])

RègleSΦ = (Sin[Φ] -> (-Cos[ψ2] Sin[η2] Sin[θ2] + Cos[η2] Sin[ψ2])/(Cos[η2] Cos[θ2] Cos[ϕ2] - Sin[θ2] Sin[ϕ2]))

Here is the equation where I want to conduct these substitutions :

(-((Cos[θ2] Cos[Φ] Sin[η2])/Sin[Φ]) == -Cos[ϕ2] Sin[θ2] - 
  Cos[η2] Cos[θ2] Sin[ϕ2]) /. {RègleCΦ, RègleSΦ}

The substitution doesn't work.

Can you help me to find a solution to conduct these substitutions?

A solution which keeps the same definitions of the rules would be great.

Note: when I obtained a ‘FullForm’ of the expression, I noticed that it contains some ‘Defer’ function. I wonder if my problem comes from this. But, I need to find a solution which allows me : 1) to prevent Mathematica from using secant and cosecant functions; and 2) to easily carry out substitutions in expressions or equations using rules.

Here the FullForm of the expression :

enter image description here

$\endgroup$
  • $\begingroup$ You should post the FullForm of the expression on which you are applying your rules, if you suspect that its form is part of the problem. Also, it appears to me that the secant and cosecant rules have little to do with your current question. $\endgroup$ – MarcoB Apr 29 '18 at 17:09
  • 2
    $\begingroup$ Csc and Sec are the worst thing that happened to mathematica's analytical processing. $\endgroup$ – Vsevolod A. Apr 29 '18 at 17:45
  • $\begingroup$ Possible duplicate: mathematica.stackexchange.com/questions/7799/… -- not to mention your own previous question, mathematica.stackexchange.com/questions/76625/… -- Have you tried SetSystemOptions[ "SimplificationOptions" -> "AutosimplifyTrigs" -> False] (from one of the answers to the first duplicate)? It "works" for me. $\endgroup$ – Michael E2 Apr 29 '18 at 20:02
  • $\begingroup$ @MichaelE2 Your comment is very helpful and the tip you have advised me SetSystemOptions[ "SimplificationOptions" -> "AutosimplifyTrigs" -> False] is a solution which works for me ! I let you add the answer to my post. Thank you $\endgroup$ – Bendesarts Apr 29 '18 at 21:08
4
$\begingroup$

From this answer by J.M.:

SetSystemOptions["SimplificationOptions" -> "AutosimplifyTrigs" -> False];

(-((Cos[θ2] Cos[Φ] Sin[η2])/ Sin[Φ]) ==
   -Cos[ϕ2] Sin[θ2] - Cos[η2] Cos[θ2] Sin[ϕ2]) /. {RègleCΦ, RègleSΦ}
(*
  -((Cos[θ2] Sin[η2] (Cos[η2] Cos[θ2] Cos[ϕ2] - 
          Sin[θ2] Sin[ϕ2]) (Cos[η2] Cos[ψ2] + 
          Sin[η2] Sin[θ2] Sin[ψ2]))/(-Cos[ψ2] Sin[η2] Sin[θ2] + 
        Cos[η2] Sin[ψ2])) == -Cos[ϕ2] Sin[θ2] - Cos[η2] Cos[θ2] Sin[ϕ2]
*)
$\endgroup$
  • $\begingroup$ in fact, now the substitutions are conducted. But, it seems "SetSystemOptions["SimplificationOptions" -> "AutosimplifyTrigs" -> False];" doesn't prevent MAthematica to use Sec and Csc functions. Have you other ideas to both prevent these functions and permit substitutions with cos and sin expressions ? $\endgroup$ – Bendesarts Apr 30 '18 at 20:32
  • $\begingroup$ I'm guess you mean that Simplify[1/Sin[x]] returns Csc[x] or even that entering Csc[x] does not immediately return 1/Sin[x]. These things are probably buried deep in code. I often just write two rules, one for sin and one for csc, and so forth. $\endgroup$ – Michael E2 Apr 30 '18 at 21:00
  • $\begingroup$ Exactly, it is what i mean. Can you write me the rules that you use? Thank you for you help. $\endgroup$ – Bendesarts May 1 '18 at 13:20
  • $\begingroup$ @Bendesarts Something like {Sin[whatever] -> expr, Csc[whatever] -> 1/expr} etc. Depends on the context. Sometimes {Sin -> s, Csc -> (1/s[#] &)}, or {_Sin -> s, _Csc -> 1/s} if the arguments are all the same. You can add assumptions like s^2 + c^2 == 1 if c replaced Cos[]. $\endgroup$ – Michael E2 May 1 '18 at 13:46

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.