Note: In the context of this question, when I say "polynomial", I mean a single variable polynomial with coefficients in $\mathbb{R}$ and one that has $\mathbb{R}$ as the domain and codomain.
Question: Prove that there exists no polynomial $p$ such that $p(\sin(\theta))=\cos(\theta)\forall\theta\in I,$ where $I$ is some non-empty interval of $\mathbb{R}.$
My Attempt: For the sake of contradiction, let such a polynomial exist. Then, define $g(x):=p(x)^2+x^2-1.$ Since $p$ is a polynomial, it follows that $g$ is too. Now, for all $a\in I, g(\sin(a))=0.$ Since the interval is non-empty, this occurs infinitely many times. By the fundamental theorem of algebra, any polynomial that is zero infinitely many times must be zero identically. Hence, $g(x)=0\forall x\in\mathbb{R}.$ This means that $p(x)=±\sqrt{1-x^2}\forall x\in\mathbb{R}.$ Now, $\sqrt{2}\in\mathbb{R},$ but $p(\sqrt{2})=±i\notin\mathbb{R}.$ This is in contradiction with the fact that the codomain of $p$ is $\mathbb{R}.$ Hence, the initial assumption about the existence of such a polynomial we made must be false. This shows that no such polynomial exists.
Is my argument right? I fear I've made some conceptual error that invalidates my entire proof. Can this statement be proven in a different way?
If $x= \sin t$ and $P(x)= \cos t$ then by the Chain Rule $P'(x) \cos t= -\sin t$ so $P'(x) P(x)=-x$ for some interval of values for $x$. But the degrees of the polynomials on left and right cannot match unless that degree is 1. What happens then?