Let $a_{1}, \ldots, a_{n}$ be distinct and $b_{1}, \ldots, b_{n}$ be real numbers.

What are the polynomials such that $P\left(a_{i}\right)=b_{i}$ for all $i$?
There exists a unique polynomial $P_{0}$ (the Lagrange interpolating polynomial) such that $P_{0}\left(a_{i}\right)=b_{i}$ for all $i$ and $\operatorname{deg}\left(P_{0}\right) \leqslant n-1$. Now consider a polynomial $P$ that satisfies $P\left(a_{i}\right)=b_{i}$ for all $i$. Then $Q=P-P_{0}$ satisfies $Q\left(a_{i}\right)=0$ for all $i$, so there exists $R$ such that $Q=$ $R \prod_{i}\left(X-a_{i}\right)$, and $P=P_{0}+R \prod_{i}\left(X-a_{i}\right)$ with $R$ being any polynomial. Conversely, any polynomial of this form satisfies $P\left(a_{i}\right)=b_{i}$ for all $i$.