2
$\begingroup$

I have a long expression having terms that go in squares like Sin[x]^2 and Sin[x/2]^2 and so on... I would like to rewrite my expression such that only Cosines occur (naturally Cos[x]^2 since all the trigs come in squares in my expression). How can I do that?

$\endgroup$
3
  • $\begingroup$ I doubt there's a way to do this simply. You'd essentially have to go through all possible ways to represent Sin[x]^2 and choose the ones specifically which only have Cosine terms, which is a problem in itself cause you'd have to tell Mathematica to "ignore" constant terms like 1 in 1-Cos[x]^2. That expression has full form Plus[1,Times[-1,Power[Cos[x],2]]], so I really doubt you can have Mathematica choose out the things you want. $\endgroup$ Nov 29, 2015 at 3:35
  • $\begingroup$ It's hard to tell from your question what the best approach might be, since we don't have a good example expression, but perhaps a simple approach might actually work, something like Expand@expr /. Sin[x_]^2 :> 1 - Cos[x]^2 // Expand. Again, it depends on the complexity of your expression, but perhaps it's a start. $\endgroup$
    – march
    Nov 29, 2015 at 3:45
  • $\begingroup$ OK @march I'll give that a try $\endgroup$ Nov 29, 2015 at 3:50

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.