# Is there a particular notation for a function confined in a set?

For example $f:\mathbb{R}\to\mathbb{R}$ is a function. How to simply express a correspondent function $g:\mathbb{Q}\to\mathbb{R}$ such that $g(x)=f(x)$, $\forall x\in\mathbb{Q}$?

-

Other notations could also be

$$g=f\mid \mathbb Q$$ and $$g=f\mid_{\mathbb Q}$$

In general if we restrict a function $f$ to a set $A$ we may write

$$f\mid A\text{ or } f\mid_A$$

(apart from Asaf's notation)

In reply to the comment: It is called an extension of $f$. "Let $f\colon X \to Y$ be a function and $A$ and $B$ be sets such that $X\subseteq A$ and $Y\subseteq B$. An extension of $f$ to $A$ is a function $g\colon A \to B$ such that $f(x)=g(x)$ for all $x\in X$. Alternatively, $g$ is an extension of $f$ to $A$ if $f$ is the restriction of $g$ to $X$". The TeX was missing so I pasted here

-
What is it called when I go the other way around? “Expansion”? – Voldemort Oct 6 '12 at 23:45
See above. ${}$ – Pedro Tamaroff Oct 6 '12 at 23:55

This is known as the restriction of $f$ to $\mathbb Q$. The common notation is: $$f\upharpoonright_{\mathbb Q}\colon\mathbb Q\to\mathbb R$$

-
Or my preferred version, $f\upharpoonright\Bbb Q$. – Brian M. Scott Oct 7 '12 at 9:17