TITLE: Is a representation of $\operatorname{SL}_n$ defined over a field $k$ if its image is contained in $\operatorname{GL}_n(k)$?
QUESTION [14 upvotes]: Let $k$ be a subfield of $\mathbb{C}$ and let $f\colon \operatorname{SL}_n(\mathbb{C}) \rightarrow \operatorname{GL}_m(\mathbb{C})$ be an algebraic homomorphism such that $f(\operatorname{SL}_n(k)) \subset \operatorname{GL}_m(k)$.  Question: must $f$ be defined over $k$?  In other words, are the matrix entries of $f(x)$ polynomials in the entries of $x \in \operatorname{SL}_n(\mathbb{C})$ whose coefficients lie in $k$?
I'd also be interested in the question with $\operatorname{SL}_n$ replaced by other semisimple groups, but the above is the most important special case for what I am doing.

REPLY [15 votes]: Yes, and in fact something much more general is true  Let $X$ and $Y$ be affine varieties defined over a field $k$. If the $k$-points of $X$ are Zariski dense, $X$ is reduced, and $f: X_{\mathbb C} \to Y_{\mathbb C}$ sends $X(k)$ to $Y(k)$, then $f$ is defined over $k$.
This was inspired by comments of Martin Brandenburg, Jef L, Andy Putman, and Piotr Achinger.
Proof: First note that by embedding $Y$ in affine space, we may assume $Y = \mathbb A^n$. Second note that by viewing a map to $\mathbb A^n$ as an $n$-tuple of maps to $\mathbb A^1$, we may assume $Y =\mathbb A^1$. Thus $f$ is a polynomial function in $\mathbb C[X]$, and we want to check it lies in $k[X]$.
Because $\mathbb C[x]= k[X] \otimes_k \mathbb C$, we may write $f = \sum_{i=1}^n \alpha_i f_i$ where $\alpha_i \in \mathbb C$ and $f_i \in k[X]$. Without loss of generality, we may assume that $\alpha_1=1$ and that the $\alpha_i$ are $k$-linearly independent. (Add $1$ to the list of $\alpha_i$s, then for any linear relation, use that relation to remove whichever $\alpha_i$ is not $1$ and adjust the $f_i$s appropriately.)
Now for $x \in X(k)$, we have $f(x) = \sum_{i=1}^n \alpha_i f_i(x)$. Because the $\alpha_i$ are $k$-linearly independent, and $f(x)\in k$, this implies $f_i(x)=0$ for $i>1$. Then because $X(k)$ is Zariski dense, this implies $f_i=0$ for $i>1$, so $f=f_1 \in k[X]$. QED
The Zariski density can be checked for $SL_n$ using the birational map to affine space obtained by forgetting one entry, and for other semisimple groups using the Bruhat decomposition as suggested by Mikhail Borovoi.