Hello.
A just beginner question:
How can I do this transformation:
Cos[X_]^n -> ( (1+Cos[2*X])/2)^(n/2), if n is even Cos[X_]^n -> Cos[X]( (1+Cos[2X])/2)^((n-1)/2), if n is odd ?
Thanks in advance César Lozada
Try something like:
Fcos[x_, n_Integer?OddQ]:= definition odd Fcos[x_, n_Integer?EvenQ]:= definition even
I think Frank is suggesting using Condition with Rule, see the documentation for examples and don't forget to use "n_"
It might work, but if not, then your expression is being automatically transformed before the rule, you might consider wrapping the expression in Hold before the rule replacement. You can ReleaseHold after the rule replacement.
or use a construction something like
F[x] = Feven[x] * Boole[(-1)^n == 1] + Fodd[x] * Boole[(-1)^n == -1]
Do two function or rule definitions, one using EvenQ and the other using OddQ.