Consider the FizzBuzz programming challenge:
Output the numbers [1, 100], replacing numbers divisible by 3 with "Fizz", numbers divisible by 5 with "Buzz", and numbers divisible by both 3 and 5 with "FizzBuzz".
The case selection can be seen as a function with the domain $[1, 100]$ mapping to values in four non-overlapping intervals; $A$, $B$, $C$, $D$,
$$ f(n) = \begin{cases} \text{something}\in A, & \text{if $3 \mid n ~\land~ 5 \not\mid n$} \\ \text{something}\in B, & \text{if $3 \not\mid n ~\land~ 5 \mid n$} \\ \text{something}\in C, & \text{if $3 \mid n ~\land~ 5 \mid n$} \\ \text{something}\in D, & \text{otherwise} \\ \end{cases} $$
Such a function can be trivially found with e.g. polynomial interpolation by letting each interval contain only a single number.
However, how does one find such a function that is as "simple" as possible? "Simple" is a bit vague, but in the case of a polynomial the number of terms would be a good measure.
Are there any other ways to construct such a function (without using cases)? Preferable a so "simple" function as possible.
Using number theory, you can say:
$$f(n)=n^{4}\bmod {15}$$ going to $$A=\{10\},B=\{6\},C=\{0\},D=\{1\}$$
If you want something more "continuous," you could take, for example, $$f(n)=2\cos (2\pi n/3)-\cos(2\pi n/5)$$
$$A=[1.65,2.85],B=[-2,-2], C=[1,1], D=[-1.31,0]$$
The best approach is to use trig functions, since $f$ is inherently periodic.
A discrete Fourier transform gives us an "exact" function:
$$f(n)=\frac{13}{15}+\frac{2}{5}\left(\cos 2\pi n/5+\cos 4\pi n/5\right)+\frac{4}{3}\cos(2\pi n/3)$$ Then we get $A=\{2\},B=\{1\},C=\{3\},D=\{0\}.$ You can expand those to make them intervals.