3

Is there any pre-established operator or function that is zero if any of its operands is zero, otherwise negative if any of its operands is negative, otherwise positive?

The sign is the most important thing here; the magnitude (in the non-zero case) could be anything from the largest absolute value to the product or sum of the absolute values of the operands.

I'm tempted to define such an operator in my work (neural network modelling), but I'd first like to be sure that none already exist.

If there is none, would it be common practice to pick an operator (eg. $\otimes$ or $\star$) and redefine it, or should I stick to function notation?

Damien
  • 131
  • 5
    RE: last paragraph: no, it's not common practice at all. Only do it if you want to thoroughly confuse your readers. – Najib Idrissi Sep 14 '15 at 12:38
  • This is a weird operator to define, because 0 has precedence over negatives and negatives have precedence over positives. It would be more natural for negatives to have precedence over zero which has precedence over positives. – Caleb Stanford Sep 14 '15 at 15:42

1 Answers1

9

You could define it as:

$$\left|x_1x_2\cdots x_n\right|\min(x_1,x_2,\dots,x_n)$$

If any are zero, it is zero. Otherwise, it is the same sign as the minimum of the $x_i$, so negative if any $x_i<0$ and positive otherwise.

This has the advantage that it is a continuous function.

I have never heard of such an operator with a name.

For a binary operator, you can write it as:

$$a\star b = \min(a^3b^2,a^2b^3)$$

I wouldn't re-use most operator symbols that are well-known, but you can use $\star$ or $\odot$ or plenty of others that have few common meanings. I'd prefer function notation, personally.

As noted in comments, in response to a question I asked in an earlier version of this comment, $$a\star b = \left|ab\right|\min(\mathrm{sgn}(a),\mathrm{sgn}(b))$$ is a continuous, commutative and associative operation of this sort.

Thomas Andrews
  • 177,126
  • 2
    Isn't $|ab| \min(\operatorname{sgn}(a), \operatorname{sgn}(b))$ such operator? Note that this is just $ab$ unless both of them are negative. – user87690 Sep 14 '15 at 13:08
  • Yeah, I think you're right. @user87690 I had a blind spot against using $\mathrm{sgn}(x)$ because it is discontinuous. – Thomas Andrews Sep 14 '15 at 13:12
  • 2
    How about denoting it something like $\def \np {\mathbin{\bar{\cdot}}} a \np b$ for “negativity preserving multiplication”? Since it is associative, one may write $x_1 \np x_2 \np \dotsb \np x_n$. – user87690 Sep 14 '15 at 13:18