Re: Extensive replacement of trigonometric functions

*To*: mathgroup at smc.vnet.net*Subject*: [mg125125] Re: Extensive replacement of trigonometric functions*From*: Alexei Boulbitch <Alexei.Boulbitch at iee.lu>*Date*: Thu, 23 Feb 2012 05:44:59 -0500 (EST)*Delivered-to*: l-mathgroup@mail-archive0.wolfram.com

Thank you, Andr=E9s. Your suggestion is undoubtfully useful for my immediate need of formula visualization, but -more generally- I was looking for a way to direct Mathematica transformations toward some specific desired functions. For example, in this case I would like that simplification process produces Cos functions rather than Sin functions in order to recognize similarities with other expressions. In this case, whenever I try to elaborate an expression such Cos[\[Theta] + \[Alpha]] with \[Alpha] number strictly greater than \[Pi]/4, it will convert to Sin[\[Pi]/2-\[Alpha] - \[Theta]], and I want to avoid this. Anyway, your suggestion is useful, so thank you indeed. Mauro Il 18/02/2012 12:32, andres ha scritto: > So, you don't want Mathematica to evaluate the expression -Cos[\ > [Theta] + (2 \[Pi])/3]? > Since -Cos[\[Theta] + (2 \[Pi])/3] = Sin[\[Theta] + \[Pi]/6], I assume > you want to format the output for visualization purposes, because both > expressions will give the same results. If this is the case, I would > take two approaches: either apply a Hold to the rhs of the rule, or > I'd use a rule of the type Sin[\[Theta]_ + \[Pi]/6] :> -cos[\[Theta] + > (2 \[Pi])/3], so that the inexistent function "cos" keeps unevaluated. > If then you want to evaluate the expression you can release the Hold > or define cos[\[Theta]_] := Cos[\[Theta]]. > Hope it helps. > Andr=E9s > > > > On Feb 17, 6:29 am, Mauro<pi... at hotmail.com> wrote: >> Hello to everybody. >> >> I have this problem: I would like to replace in a long expression all >> the occurrences of: >> >> Sin[\[Theta]_ + \[Pi]/6] and Sin[\[Theta]_ - \[Pi]/6] >> >> with respectively: >> >> -Cos[\[Theta] + (2 \[Pi])/3] and Cos[\[Theta] - (2 \[Pi])/3] >> >> (which actually are the same thing). >> Regretfully, the application of the rules: >> >> Sin[\[Theta]_ + \[Pi]/6] -> -Cos[\[Theta] + (2 \[Pi])/3] >> Sin[\[Theta]_ - \[Pi]/6] -> Cos[\[Theta] - (2 \[Pi])/3] >> >> results in a flop, since sine functions stubbornly appear again! >> >> Can you help me? >> >> Thank you in advance >> >> Mauro > > Hi, Mauro The form you want to achieve you cannot reach in Mathematica, since it simplifies the final expression according to a built-in complexity function. Mathematica "understands" complexity not like you. Various aspects of this problem has been many times discussed here, you may want to look up the archive. You may change the complexity definition, but it is difficult to find such a definition that would lead to the expression you want to get and seems to typically take more time than to work out a special trick. Instead there are few ways around. What to choose depends upon your aim: what do you need to do with these expressions further? This is not clear from your post. One way has been already proposed to you (see above). Another may be to introduce new variables like the following: s1=Solve[\[Theta]+(2 \[Pi])/3==\[CurlyPhi]1,\[Theta]][[1]] s2=Solve[\[Theta]-(2 \[Pi])/3==\[CurlyPhi]2,\[Theta]][[1]] {\[Theta]->1/3 (-2 \[Pi]+3 \[CurlyPhi]1)} {\[Theta]->1/3 (2 \[Pi]+3 \[CurlyPhi]2)} Sin[\[Theta]+\[Pi]/6] /.s1//Simplify -Cos[\[CurlyPhi]1] Sin[\[Theta]-\[Pi]/6] /.s2//Simplify Cos[\[CurlyPhi]2] Then you work with [\[CurlyPhi] and substitute its value on the very last step. The Presentation package of David Park offers another possibility enabling you to make such an operation among others. What to choose depends upon your aim. One thing seems clear: there is no operator in Mathematica that would do it for you without any thinking and in one click. Have fun, Alexei Alexei BOULBITCH, Dr., habil. IEE S.A. ZAE Weiergewan 11, rue Edmond Reuter L-5326 Contern, LUXEMBOURG Office phone : +352-2454-2566 Office fax: +352-2454-3566 mobile phone: +49 151 52 40 66 44 e-mail: alexei.boulbitch at iee.lu<mailto:alexei.boulbitch at iee.lu>

**Dynamically finding distances and angles between user-specified points**

**Re: Kolmogorov Smirnov in two or more dimensions is in Mathematica 8.0.4**

**Re: Extensive replacement of trigonometric functions**

**Re: Extensive replacement of trigonometric functions**