2
$\begingroup$

I'm solving equations with many Cosines and Sines. And I want to convert all the Sines to Cosines using trigonometric formulas such as cos(x)=sin(x+pi/2). How can I do this?

$\endgroup$
  • $\begingroup$ Why you need it? Solve commands in mathematica isn't sensitive to such things. And Mathematica automatically treats sin(x+pi/2) as cos(x) unless you force unevaluated form by Hold[sin(x+pi/2)]. $\endgroup$ – funnyp0ny Dec 7 '14 at 15:33
  • 1
    $\begingroup$ Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Read the faq! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! $\endgroup$ – user9660 Dec 7 '14 at 15:34
  • 2
    $\begingroup$ Is this Question about the Software Mathematica? If so please complement your Question with Code. Else Mathematics satisfies your needs better. $\endgroup$ – user9660 Dec 7 '14 at 15:34
  • $\begingroup$ @funnypony Thank you. I need it because I am comparing equations solved by hand and by Mathematica. The solutions by hand are all Cosine based, but Mathematica automatically convert some Cosines to Sines. I expected there could be a function in Mathematica that converts all Sines to Cosines. I think that "Hold" can't be used in my case because I want to convert the Sines after the evaluation of the equations. $\endgroup$ – YongCheol Kwon Dec 8 '14 at 2:25
1
$\begingroup$

The main problem here is that Mathematica immediately converts terms such as Sin[x+π/2] to the more simpler Cos[x]. You have to prevent this from occurring. You could do that with Defer or in V10 with Inactivate:

Inactivate[ 
    Cos[p x + 2] Sin[z a + q] + Cos[x]^2/(Sin[a + b] - Cos[2 n]) /. Cos[x_] :> Sin[x + π/2], 
    Sin
]

Mathematica graphics

or, perhaps better (per comment of Bob Hanlon):

Cos[p*x + 2]*Sin[z*a + q] + Cos[x]^2/(Sin[a + b] - Cos[2*n]) /. Cos[x_] :> Inactive[Sin][x + Pi/2]

Mathematica graphics

(note that the inactive sines are printed in a gray style).

$\endgroup$
  • $\begingroup$ Or you can use Cos[p*x + 2]*Sin[z*a + q] + Cos[x]^2/(Sin[a + b] - Cos[2*n]) /. Cos[x_] :> Inactive[Sin][x + Pi/2] which leaves the original Sin functions active. $\endgroup$ – Bob Hanlon Dec 7 '14 at 17:43
  • $\begingroup$ @BobHanlon That may be better indeed if the OP wants to do something with them (though I don't have a clue what that might be) $\endgroup$ – Sjoerd C. de Vries Dec 7 '14 at 18:27
  • $\begingroup$ @BobHanlon Thank you for your answer. Your code doesn't work in my PC since I'm using V9. And I don't understand the syntax. Maybe I need more study in Mathematica. $\endgroup$ – YongCheol Kwon Dec 8 '14 at 2:31
  • $\begingroup$ With v9 you cannot use Inactive or Inactivate but as mentioned by @Sjoerd you can use Defer, i.e., expr = Cos[p*x + 2]*Sin[z*a + q] + Cos[x]^2/(Sin[a + b] - Cos[2*n]) /. Cos[x_] :> Defer[Sin][x + Pi/2]. To release the Defer you can use expr /. Defer -> Identity $\endgroup$ – Bob Hanlon Dec 8 '14 at 5:12

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.