# Rationals, irrationals and Continuity

Suppose we have a continuous real valued function $f(x)$ which takes the form of a polynomial for all rationals, i.e. $\exists$ $a_0, a_1, ..., a_n \in \mathbb R$ such that $$f(x)=a_0x^n+a_1x^{n-1}+ \cdots +a_{n-1}x+a_n \space \space \space \space \space \forall x \in \mathbb Q.$$ Now, with the help of continuity, can I conclude that $$f(x)=a_0x^n+a_1x^{n-1}+ \cdots +a_{n-1}x+a_n \space \space \space \space \space \forall x \in \mathbb R.$$ If yes, then how? I came to such a question while solving functional equations where it is possible to find the function for rationals from the given equation easily, whereas for irrationals it is quite difficult.

Take any real number $x$. Now, take a sequence $q_n$ that converges towards $x$ and look at the limit $$\lim_{k\rightarrow \infty} f(q_k)=\lim_{k\rightarrow\infty} a_0q_k^n + \dots +a_n = a_0x^n + \dots + a_n.$$ By continuity, this limit is equal to $f(x)$, proving what you need.