Well, this question is just for curiosity, personally I never use ReplaceAll like this:
Cos[2 x] /. Sin_[2 x_] -> 2 Sin[x] Cos[x]
(* => 2 Cos[x]^2 *)
How to explain the result?
|
Well, this question is just for curiosity, personally I never use
How to explain the result? |
|||
|
It's quite simple, but you made it look confusing because of your naming
Now, you name the head |
|||||||
|
MatchQ[Cos[2 x], Sin_[2 x_]]returns the result it indeed returns... also, consider the similarities between what you have and the following snippet:Cos[2 x] /. f_[2 x_] -> 2 f[x] Cos[x]. – J. M.♦ Oct 29 '12 at 5:39