Plotting piecewise functions maple

728 Views Asked by At

How would I plot the following equation in maple?

$$f(x) = \begin{cases} 1, & \text{if } x\in\mathbb{Q}, \\ 0, & \text{if } x\notin \mathbb{Q}. \end{cases}$$

1

There are 1 best solutions below

0
On BEST ANSWER

You can't really, as the commenters said. The graph of this function exists in the Platonic universe of ideas, but it cannot exist in our physical Universe. As a corollary, Maple is unable to show it to you.

Here is something you can do to catch the passing shadow of this function on the wall of our cave. The function $f$ is the pointwise limit of the following kind: $$f(x) = \lim_{n\to\infty} \lim_{m\to\infty} (\cos(2\pi n! x))^{2m}$$

Take large $n,m$ and increase numpoints in the plot command:

n:=10; m:=500;
plot(cos(2*Pi*n!*x)^(2*m),x=-1..1,numpoints=10000);

approximation to Dirichlet