Complex exponential squared does not equal sinusoid squared? I just noticed this today and I'm a bit confused by it.
If we represent cos(x) as the real part of exp(ix), then I always thought that we could then say that cos(x)^2 is equal to the real part of exp(ix)exp(ix)=exp(2*i*x).  However, this clearly cannot be correct, as the real part of exp(2*i*x) is actually cos(2*x), which of course is not equal to cos(x)^2.
So what rule am I violating here when I try to represent cos(x)^2 as exp(2*ix)?  Why can't I just say cos(x)^2 is equal to the real part of exp(ix)exp(ix)=exp(2*i*x)?
I know I'm going wrong somewhere but can't see where.  Thanks!

You are not violating a rule, rather, you are making up a rule which does not exist.  You are assuming that the real part of $z^2$ is (the real part of $z$), squared.  But in fact if we write $z=a+ib$ then
$$z^2=a^2-b^2+2iab\ ,\quad \Re(z^2)=a^2-b^2$$
while
$$\Re z=a\ ,\quad (\Re z)^2=a^2\ ,$$
and these are not equal (except in the special case $b=0$).
