3
$\begingroup$

Why does TrigExpand[Cos[a+b]] return the familiar and expected

Cos[a] Cos[b] - Sin[a] Sin[b]

but TrigExpand[Cos[2 Pi n x + b]] return

Cos[b] Cos[n \[Pi] x]^2 - 2 Cos[n \[Pi] x] Sin[b] Sin[n \[Pi] x] - Cos[b] Sin[n \[Pi] x]^2?

I would have thought that Mathematica would group the terms into a single constant.

I can of course perform TrigExpand[Cos[a+b]] /. a -> 2 Pi n x,

but that seems rather inelegant.

$\endgroup$
1
  • 2
    $\begingroup$ From the Details section: TrigExpand splits up sums and integer multiples that appear in arguments of trigonometric functions, and then expands out products of trigonometric functions into sums of powers, using trigonometric identities when possible. $\endgroup$ Commented Jan 27, 2024 at 5:36

1 Answer 1

3
$\begingroup$

It is because of the 2. Compare

TrigExpand[Cos[a + b]] 

Mathematica graphics

With

 TrigExpand[Cos[2 a + b]] 

Mathematica graphics

This is because

TrigExpand[Cos[2 a]] 

gives

Mathematica graphics

Using your original expression, if you remove the 2 now you get what you expected

 TrigExpand[Cos[Pi n x + b]] 

Mathematica graphics

Having the 2 in there made it use that intermediate rule which caused the output to look completely different now. There is probably a way to turn off that rule for Cos[2 x] from expanding.

At the risk of breaking something internal, you can modify TrigReduce to change only the case when Cos[2 x] is in play:

Unprotect[TrigExpand]; TrigExpand[Cos[2*x_ + y_]] := Cos[2*x] Cos[y] - Sin[2*x] Sin[y] Protect[TrigExpand]; 

and now

TrigExpand[Cos[2 Pi n x + b]] 

Mathematica graphics

$\endgroup$
1
  • $\begingroup$ Oh. How interesting (and unintuitive). And it "works" when you try TrigExpand[Cos[2. Pi n x + b]] (note the 2.). Thanks ($\checkmark$). $\endgroup$ Commented Jan 27, 2024 at 6:03

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.