# Is it possible to simplify a trigonometric expression only in terms of $\cos (u)$ OR $\sin (u)$?

I want to expand the following expression into powers of $\cos(u)$ only:

a1 + a2 Cos[2 u] + a3 Cos[4 u] + a4 Cos[6 u]


The answer that I want (and which I found by hand) is :

(a1 + a3 - a2 - a4) + (2 a2 - 8 a3 + 18 a4) Cos[u]^2 + (8 a3 - 48 a4) Cos[u]^4 + (32 a4) Cos[u]^6


As you see it contains only powers of $\cos (u)$. But when I use the TrigExpand, which is supposed to simplify the expression into powers of trigonometric functions, it gives this:

1 + a2 Cos[u]^2 + a3 Cos[u]^4 + a4 Cos[u]^6 - a2 Sin[u]^2 - 6 a3 Cos[u]^2 Sin[u]^2
- 15 a4 Cos[u]^4 Sin[u]^2 + a3 Sin[u]^4 + 15 a4 Cos[u]^2 Sin[u]^4 - a4 Sin[u]^6


Is it possible to make TrigExpand to simplify only in terms of $\cos (u)$ or $\sin (u)$? (or maybe using another command instead of TrigExpand)

By the way, It is my first work done in Mathematica.

-
Could use post-process the TrigExpand with PolynomialReduce in order to exchange one trig in favor of the other. In[8]:= PolynomialReduce[TrigExpand[expr], Sin[u]^2 + Cos[u]^2 - 1, Cos[u]][[2]] Out[8]= a1 + a2 + a3 + a4 - 2 a2 Sin[u]^2 - 8 a3 Sin[u]^2 - 18 a4 Sin[u]^2 + 8 a3 Sin[u]^4 + 48 a4 Sin[u]^4 - 32 a4 Sin[u]^6 – Daniel Lichtblau Jun 6 '14 at 14:14

expr = a1 + a2 Cos[2 u] + a3 Cos[4 u] + a4 Cos[6 u];

(expr // TrigExpand) /. Sin[x_] -> (1 - Cos[x]^2)^(1/2) // Collect[#, Cos[_]] &


a1 - a2 + a3 - a4 + (2 a2 - 8 a3 + 18 a4) Cos[ u]^2 + (8 a3 - 48 a4) Cos[u]^4 + 32 a4 Cos[u]^6

(expr // TrigExpand) /. Cos[x_] -> (1 - Sin[x]^2)^(1/2) // Collect[#, Sin[_]] &


a1 + a2 + a3 + a4 + (-2 a2 - 8 a3 - 18 a4) Sin[ u]^2 + (8 a3 + 48 a4) Sin[u]^4 - 32 a4 Sin[u]^6

-
Thanks. Can you explain a little what the code does? – user215721 Jun 6 '14 at 13:32
After TrigExpand, ReplaceAll is used with a trig identity to remove undesired trig functions, then like terms are collected. In Mathematica, highlight a function or operator then press F1 for additional information. – Bob Hanlon Jun 6 '14 at 13:45

Some alternative approaches can be found in How to expand tan(x+y) as normal form. Here is my answer from that link, applied to your expression:

expr = a1 + a2 Cos[2 u] + a3 Cos[4 u] + a4 Cos[6 u];

Simplify[TrigExpand[expr /. u -> ArcSin[a]]] /. a -> Sin[u]

(*
==> a1 + a2 + a3 + a4 - 2 a2 Sin[u]^2 - 8 a3 Sin[u]^2 -
18 a4 Sin[u]^2 + 8 a3 Sin[u]^4 + 48 a4 Sin[u]^4 - 32 a4 Sin[u]^6
*)


You can also add

Collect[%, Sin[u]]
(*
==> a1 + a2 + a3 + a4 + (-2 a2 - 8 a3 - 18 a4) Sin[
u]^2 + (8 a3 + 48 a4) Sin[u]^4 - 32 a4 Sin[u]^6
*)

-
{"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 1, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "url": "http://mathematica.stackexchange.com/questions/49251/is-it-possible-to-simplify-a-trigonometric-expression-only-in-terms-of-cos-u", "fetch_time": 1455256069000000000, "content_mime_type": "text/html", "warc_filename": "crawl-data/CC-MAIN-2016-07/segments/1454701163438.83/warc/CC-MAIN-20160205193923-00035-ip-10-236-182-209.ec2.internal.warc.gz", "warc_record_offset": 149526337, "warc_record_length": 18119, "token_count": 983, "char_count": 2566, "score": 3.84375, "int_score": 4, "crawl": "CC-MAIN-2016-07", "snapshot_type": "longest", "language": "en", "language_score": 0.5484052300453186, "file_path": "/sailhome/yjruan/project/latent-lm/data/processed/finemath-4plus/finemath-4plus/train-00042-of-00064.parquet"}