Program for graphing special functions, such as $f(x)=\begin{cases}1,&\text{if }x\in\mathbb Q\\ 0,&\text{if }x\notin\mathbb Q\end{cases}$

42 Views Asked by At

My question is based on the fact that if there is any special program, that allows to graph certain peculiar functions such as the following, $$f(x)=\begin{cases} 1, & \text{ if } x\in\mathbb Q; \\ 0, & \text{ if } x\notin \mathbb Q. \end{cases}$$ Or, $$g(x)=\begin{cases} 0, & \text{ if } x\in(\mathbb R\setminus \mathbb Q)\cup \{0\}, \\ 1/q & \text{ if } x=p/q,\ \gcd(p,q)=1,\ p\neq 0. \end{cases}$$