At a crude level, the evaluator that does the `TrigExpand`

can be emulated by a `FixedPoint`

or `ReplaceRepeated`

. If we want to see the steps behind this particular kind of evaluation, it seems possible that a simple substitute for the built-in `TrigExpand`

can be implemented based on `FixedPointList`

instead of `FixedPoint`

, to keep track of the steps. Here is a simple attempt to do that:

```
SetAttributes[expansionStep, HoldAll]
expansionStep[expr_] :=
Expand@ReleaseHold[
Hold[expr] /. {Tan[x_] :> Sin[x]/Cos[x], Cot[x_] :> Cos[x]/Sin[x],
Sec[x_] :> 1/Cos[x],
Csc[x_] :> 1/Sin[x]} /. {Cos[
HoldPattern[Times[n_?EvenQ, x__]]] :> (Cos[n/2 x]^2 -
Sin[n/2 x]^2),
Sin[HoldPattern[Times[n_?EvenQ, x__]]] :>
2 Cos[n/2 x] Sin[n/2 x]}]
trigExpandSteps[expr_] :=
DeleteDuplicates[FixedPointList[expansionStep, expr]]
```

I really implemented only two trig relations here, based on expanding $\sin(2x)$ and $\cos(2x)$. These are applied repeatedly. But to get away with only these two rules, I have to make sure all trig expressions are first converted to sines and cosines. This requires working with held expressions because *Mathematica* has the annoying habit of simplifying perfectly good sines and cosines into ugly $\csc$, $\sec$, and also the less ugly but equally unwanted $\tan$ and $\cot$ functions. So at each step, I first "standardize" the current expression into sines and cosines only, within a `Hold`

. Then I apply the trig identities and allow the result to be `Expand`

ed. This is done iteratively in `FixedPointList`

until the expression no longer changes.

And here are some tests:

```
trigExpandSteps[Cos[4 x]]
```

$\left\{\cos (4 x),\\\cos ^2(2 x)-\sin ^2(2 x),\\\sin
^4(x)+\cos ^4(x)-6 \sin ^2(x) \cos ^2(x)\right\}$

```
trigExpandSteps[Sin[4 x]]
```

$\left\{\sin (4 x),\\2 \sin (2 x) \cos (2 x),\\4 \sin (x)
\cos ^3(x)-4 \sin ^3(x) \cos (x)\right\}$

```
trigExpandSteps[Tan[4 x]]
```

$\left\{\tan (4 x),\\\frac{2 \sin (2 x) \cos (2 x)}{\cos
^2(2 x)-\sin ^2(2 x)},\\\frac{4 \sin (x) \cos
^3(x)}{\left(\cos ^2(x)-\sin ^2(x)\right)^2-4 \sin
^2(x) \cos ^2(x)}-\frac{4 \sin ^3(x) \cos
(x)}{\left(\cos ^2(x)-\sin ^2(x)\right)^2-4 \sin
^2(x) \cos ^2(x)}\right\}$

3Internally

`TrigExpand`

is converting to complex exponentials, expanding, and converting back. So a "show steps" capability would need to do it differently, e.g. via the trig sum/product laws. Which is not a bad thing at all, I just wanted to point out that it would differ from the internal workings of`TrigExpand`

. – Daniel Lichtblau – 2015-01-11T20:18:43.5372

See this answer about step by step of integral

– xyz – 2015-01-13T02:59:06.693