I have a vector $v \in \mathbb{R}^n$ and I am searching for a mathematical notation for a function that returns $1$ if at least one of the vector's elements is $0$ and $0$ otherwise. The analogue function for a set $S$ would be: $$ f = \begin{cases} 1 & \text{if } 0 \in S \\ 0 & \text{if } 0 \notin S \end{cases} $$ However I am struggling to find a similar notation for a vector. In particular, how do I write: "If any element in $v$ is $0$"?
5 Answers
It's best to write it in words: $$ f(v) = \begin{cases} 1&\text{when at least one component of $v$ is zero}\\ 0&\text{otherwise}. \end{cases} $$ This is perfectly valid mathematical notation. Using symbols doesn't make it better than using words. With words you can say directly what you want to say instead of taking an unnecessary detour.
If someone insists on using symbols (in order for the function to be implementable on a machine), you can replace "when at least one component of $v$ is zero" by "$0\in\{v_1,\dots,v_n\}$". That's still readable, but I think the version in words is best for communicating with people.
If $\prod_{i=1}^nv_i=0$, then $f(v)=1$ otherwise $f(v)=0$. For a compact representation, you can use the indicator function $\mathbf 1_E$ of an event $E$. Define the event $E$ to be the event that $\prod_{i=1}^n v_i=0$. Then $$f(v)=\mathbf 1_E$$
-
8$\begingroup$ I wasn't sure I believed Joonas Ilmavirta's answer until I read this one. $\endgroup$ Mar 29, 2018 at 18:07
-
2$\begingroup$ For slightly greater obscurity, use one of the notations for the Dirac delta function : $\delta_{\prod_{i=1}^n v_i}$. Or further, the Dirac measure $\delta_0( \{ v_1, \dots, v_n \} )$. Of course, explaining either of these is at least as complicated as just writing what one means... $\endgroup$ Mar 30, 2018 at 4:14
I agree with @Joonas Ilmavirta that it's probably better to write it in words.
Nevertheless, one can talk about the support of a vector, namely, $$\operatorname{supp}(v)=\{i\in[n]\, |\, v_i \neq 0\},$$ where $[n]=\{1,\ldots,n\}$. This is a widely accepted terminology.
In particular, $$\text{"If any element of $v$ is $0$"}$$ becomes $$\text{"If $\operatorname{supp}(v)\neq [n]$"}$$
-
$\begingroup$ In that case, you would probably want to write the two cases in a different order. If the first case contains "$\neq$" and the second one is "otherwise", it feels a little wrong. $\endgroup$ Mar 28, 2018 at 14:10
-
$\begingroup$ @JoonasIlmavirta I am not sure to understand what you mean $\endgroup$– SurbMar 28, 2018 at 14:24
-
1$\begingroup$ I was unclear. The point was that if you substitute your statement to the formula I gave, you get$$f(v) = \begin{cases} 1&\text{when supp($v$)${}\neq[n]$}\\ 0&\text{otherwise}. \end{cases}$$It would be more natural to flip these and say that the function is zero when the support is $[n]$ and one otherwise. But it's not really an important point. (And you got my +1 for pointing out the support of a vector.) $\endgroup$ Mar 28, 2018 at 14:27
-
$\begingroup$ @JoonasIlmavirta (You got my +1 too :). In fact, I agree with with you but then, as you said, either we flip the definition of $f$ or we flip the definition of support. The first solution depends on OP and the second is likely a bad idea. $\endgroup$– SurbMar 28, 2018 at 14:30
There is a distinction between a vector and its coordinates. A vector doesn't have elements; while vectors are often represented by a tuple of numbers, those numbers are simply the projection of the vector onto various axes, not the "elements". Just because one of the coordinates is zero, that doesn't mean 0 is "in" v, it just means that one of the axes you chose is perpendicular to v. If you want to know whether a tuple contains zero, one way is to take the product; the product of a tuple containing zero will be zero. There is a term "sign function" (not to be confused with "sine") that returns zero if x = 0, -1 if x<0, and 1 if x>0. So if we denote the projection onto the ith axis with $\pi_i$, then
$f(\textbf{v}) = 1-|sgn(\prod_{i=1}^n \pi_i(\textbf{v}))|$
You could also write it as
$f= 1_{\{\textbf{u} : \exists i :\pi_i(\textbf{u})=0\}}$
Explanation:
$\{\textbf{u} : \exists i :\pi_i(\textbf{u})0\}$ means "The set of vectors for which at least one projection function results in zero when applied to the vector".
The notation $1_S$ represents a function that gives 1 if the argument is in the set S, and 0 otherwise. So $1_{\{\textbf{u} : \exists i :\pi_i(\textbf{u})=0\}}$ gives 1 if any of the coordinates are zero, and 0 otherwise.
Note that this depends on what the $\pi_i$ are; that is, what coordinate system you pick will affect whether there are any zeros in the vector's representation.
You might be interested in the $0$-norm, defined here as $\|\cdot\|_0 : \mathbb{R}^n \to \mathbb{R}$ given by
$$\|(x_1, \ldots, x_n)\|_0 = \text{ number of nonzero entries $x_i$} = \sum_{x_i \ne 0} 1$$
In this context, your function is given by
$$f = \chi_{\|\cdot\|_0^{-1}(\{0, 1, \ldots, n-1\})}$$
where $\chi_{\|\cdot\|_0^{-1}(\{0, 1, \ldots, n-1\})}$ is the indicator function of the set $$\|\cdot\|_0^{-1}(\{0, 1, \ldots, n-1\}) = \{x \in \mathbb{R}^n : \|x\|_0 \le n-1\} = \{(x_1, \ldots, x_n) \in \mathbb{R}^n : x_i = 0 \text{ for some } i\}$$
You can write it even shorter:
$$f(x) = \operatorname{sign}(n-\|x\|_0)$$
-
$\begingroup$ It's also the taxicab norm derived from the trivial absolute value on $\mathbb R$. $\endgroup$ Mar 28, 2018 at 19:51
-
-
2$\begingroup$ Yes, not what I would call the usual absolute value ;) $\endgroup$ Mar 28, 2018 at 19:54