TransWikia.com

How to prevent TrigReduce auto evaluating Sin and Cos

Mathematica Asked by cqd123123 on July 28, 2021

Mathematica automatically evaluates Sin and Cos when TrigReduce is applied. For example, TrigReduce[Cos[2*t]*Cos[2*t]] results in 1/2 (1 + Cos[4 t]). In my application I would like TrigReduce to keep the Sin and Cos as is. I’d like to have 1/2 (Cos[0 t] + Cos[4 t]) as the output of the preceding example. I tried to use Inactivate, but that seems to prevent TrigReduce from working as well.

One Answer

There is one way:

    expr1 = Cos[2*t]^2 /. Cos[2 t]^2 :> Cos[(2 + x)*t]*Cos[2 t]

(*  Cos[2 t] Cos[t (2 + x)]   *)

Then

expr2 = TrigReduce@expr

(*   1/2 (Cos[2 t - t (2 + x)] + Cos[2 t + t (2 + x)])  *)

Now we can simplify the subexpressions under the Cos sighs, and replace tx by HoldForm[0] and x - by 0:

MapAt[Simplify, expr2, {{2, 1, 1}, {2, 2, 1}}] /. 
  t x -> HoldForm[0] /. x -> 0

yielding

enter image description here

I have no idea how your other terms look like. Therefore, I cannot garanty that it will work for the whole your complex expression. However, you can try to invent something along this line.

Please do not forget that HoldForm[0] cannot be operated by Mma functions. If you need to further operate with the result, apply first ReleaseHold.

Have fun!

Answered by Alexei Boulbitch on July 28, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP