1

I have 4 functions

\begin{align} f_1(x) &= x \text{ mod } 1\\ f_2(x) &= x \text{ mod } 3 \\ f_3(x) &= x \text{ mod } 4 \\ f_4(x) &= x \text{ mod } 12\\ \end{align}

for $x \in [0,\infty) $

I want to create a function $g(x)$ that counts the number of zeroes at $x$ for those four functions.

For example, $x=6$ would have

\begin{align} f_1(6) &= 0\\ f_2(6) &= 0 \\ f_3(6) &= 2 \\ f_4(6)& = 6 \\ \end{align}

Since only two of these are zero, then $g(6) = 2$

Another example is $x=24$

\begin{align} f_1(24) &= 0\\ f_2(24) &= 0 \\ f_3(24) &= 0 \\ f_4(24)& = 0\\ \end{align}

Since all four of these are 0, then $g(24) = 4$

If $x =0.5$, then

\begin{align} f_1(0.5) &= 0.5 \\ f_2(0.5)& = 0.5 \\ f_3(0.5) &= 0.5\\ f_4(0.5) &= 0.5 \\ \end{align}

Since none of these are zero, then $g(0.5)=0$

How can I define $g(x)$ elegantly?

Inelegant method I've found

One inelegant way I thought of was basically count them for each possible value.

\begin{align} g(0)& = 4 \\ g(1) &= 1 \\ g(2)& = 1\\ g(3)& = 2 \\ g(4)& = 2 \\ g(5)& = 1\\ g(6)& = 2 \\ g(7)& = 1\\ g(8)& = 2\\ g(9) &= 2 \\ g(10) &= 1\\ g(11)& = 1\\ \end{align}

Then for any $x$, I could do $g(x \text{ mod } 12)$ and it would either match one of these or else $g(x) = 0$.

This gives me the correct result. However, this seems very inelegant and I'm hoping for a nicer solution.

2 Answers2

0

For non-integers $x$, $g(x)=0$ clearly.

If $x$ is an integer not divisible by both $3$ and $4$, we have $f_1(x)=0$, but the values of $f_2(x),f_3(x),f_4(x)$ is not zero. (Try to figure why by yourself) So $g(x)=1$ in this case.

If $x$ is an integer divisible by $3$ but not $4$, $f_1(x)=f_2(x)=0$ and the values of $f_3(x),f_4(x)$ are not zero. (Why?) So $g(x)=2$ in this case.

If $x$ is an integer divisible by $4$ but not $3$, $f_1(x)=f_3(x)=0$ and the values of $f_2(x),f_4(x)$ are not zero. (Why?) So $g(x)=2$ in this case.

If $x$ is an integer divisible by both $3$ and $4$, then it is divisible by $12$. (Why?) So $f_1(x)=f_2(x)=f_3(x)=f_4(x)=0$, so $g(x)=4$ in this case.

Culver Kwan
  • 2,785
0

After some reflexion, the best answer I came up with was

$$g(x) = \sum_{i=1}^{4} \mathbb{I}_{\lbrace f_i(x)=0\rbrace}$$

where $\mathbb{I}$ is the indicator function.

I still feel like there must be a more elegant way to do this, but this one at least is simple.

  • You can simplify it very slightly to $(\mathbb{I}1+\mathbb{I}_3)(\mathbb{I}_1+\mathbb{I}_4)$ because $\mathbb{I}_1=\mathbb{I}_1^2$ and $\mathbb{I}{12}=\mathbb{I}_3\cdot\mathbb{I}_4$. If you restrict yourself to integer inputs only, it becomes $(1+\mathbb{I}_3)(1+\mathbb{I}_4)$. – Jaap Scherphuis Jan 11 '21 at 08:59