# What exactly happens when adding a Blank after a built-in function used in the rules of ReplaceAll?

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?

-
As a starting point towards understanding what's happening (in addition to Rojo's explanation): ponder on why 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]. –  Ｊ. Ｍ. Oct 29 '12 at 5:39
Cos[2 x] matches this pattern, _[2 _]
Now, you name the head Sin (bad practice :P), and the internal blank, x and transform that to 2 "the head"["the argument"] Cos["the argument"]. In this case, the head is Cos so the result becomes 2 Cos[x] Cos[x] which is 2 Cos[x]^2