0
$\begingroup$

What I would like to do is manipulate and simplify trig functions as they appear often in my calculations.

What I would like to do is to use the double angle identities.

Here is what I have implemented.

doublesin[Sin[function_]] := 2 Sin[#/2] Cos[#/2] &@ function
doublecos[Cos[function_]] := 1 - 2 Sin[#/2]^2 &@ function

And to some extent, it works fine, but it is limited.

Here it is,

In[278]:= doublesin[Sin[2 a]]

Out[278]= 2 Cos[a] Sin[a]

In[279]:= Sin[2 b] // doublesin

Out[279]= 2 Cos[b] Sin[b]

In[288]:= doublecos[Cos[4 c]]

Out[288]= 1 - 2 Sin[2 c]^2

And here is where and how it fails,

In[289]:= Cos[4 c] Sin[4 a] // doublesin // doublecos

Out[289]= doublecos[doublesin[Cos[4 c] Sin[4 a]]]

In[291]:= Cos[4 c] Sin[4 a] // doublecos

Out[291]= doublecos[Cos[4 c] Sin[4 a]]

In my expressions, I have things that look like $\cos(4x) \sin(6x) + \cos(8x) \sin(10x) + \cdots$

Ideally, I would like something that works like the Factor,Simplify, etc commands. Apply the commands at the end of a long expression and act on all trig functions, whether they sit alone or as a product with other trig functions.

Thanks in advance.

$\endgroup$
4
  • 1
    $\begingroup$ TrigExpand, TrigReduce, TrigToExp, TrigFactor? $\endgroup$ Commented Feb 24, 2018 at 18:12
  • $\begingroup$ TrigToExp is not helpful for my purposes. TrigFactor and TrigReduce give trig functions with weird arguments. TrigExpand works fine, but the reason I want to implement these commands in a correct way, is to further reduce the trig function using power properties. $\endgroup$
    – user49048
    Commented Feb 24, 2018 at 18:17
  • $\begingroup$ I am just trying to prevent you from reinventing the wheel, you know... $\endgroup$ Commented Feb 24, 2018 at 18:22
  • $\begingroup$ Yes, I got it. I was just explaining what I wanted to do in general and why I want to implement something like that. $\endgroup$
    – user49048
    Commented Feb 24, 2018 at 18:33

1 Answer 1

1
$\begingroup$

Regardless of whether or not this is reinventing the wheel, a rule-based approach is probably the most productive here.

doublesin[f_] := f /. Sin[x_] :> 2 Sin[x/2] Cos[x/2];
doublecos[f_] := f /. Cos[x_] :> 1 - 2 Sin[x/2]^2;

This results in:

doublecos[doublesin[Cos[4 c] Sin[4 a]]]

2 (1 - 2 Sin[a]^2) Sin[2 a] (1 - 2 Sin[2 c]^2)

$\endgroup$
1
  • $\begingroup$ Thank you for that. Very helpful. Cheers!!! $\endgroup$
    – user49048
    Commented Feb 24, 2018 at 20:50

Your Answer

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