$P(z)=0$ iff $Q(z)=0$, $P(z)=1$ iff $Q(z)=1$. Prove that $P(x)=Q(x)$ for all $x$

Assume $P(x)$ and $Q(x)$ are polynomials with complex coefficients with degree greater than or equal to $1$ such that $P(z)=0$ if and only if $Q(z)=0$, $P(z)=1$ if and only if $Q(z)=1$. Prove that $P(x)=Q(x)$ for all $x\in \mathbb{C}$.

I have no idea for this problem. The only thing I can say is $P(x)$ and $Q(x)$ share the same roots.

Thanks so much for any help.


Let $deg(P)=n>0$ and assume without loss of generality that $deg(Q) \leq deg(P)$. Consider the polynomial $R=(P-Q)P'$ ($P'$ denote the derivative of $P$). We have : $$deg(R)\leq 2n-1 $$

Now if $r$ is a root of multiplicity $k$ of $P$ then $r$ is a root of $P'$ of multiplicity $k-1$ and because $Q(r)=0$, $r$ is a root of $P-Q$. hence $r$ is a root of $R$ of multiplicity at least $k$. So the n zeros of $P$ produces at least $n$ zeros of $R$, when multiplicities are counted.

The same pattern can be applied to $P-1$, every root $r$ of multiplicity $k$ of $P-1$ is a root of $P-Q$ and a root of multiplicity $k-1$ of $(P-1)'=P'$. So the n zeros of $P-1$ produces at least another $n$ zeros of $R$ when multiplicities are counted. (the zeros of $P$ are all different with the zeros of $P-1$ it's obvious).

This means that $R$ has at least $2n$ roots and beacuse $deg(R)\leq 2n-1 $ we conclude that $R=0$ which implies $P=Q$.