Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a 2D vector $v$, where each component is in the range -1 to +1.

I'd like a function $f(v, x)$, where x is a real number, and the result is a vector, such that each $component$ of the result is zero if abs($component$) < $x$ where $abs(x) < 1$.

share|cite|improve this question
Do you mean each component of $f$? Is the output of $f$ also a two-dimensional vector? And $x$ seems to be real number? – joriki Jul 27 '11 at 8:56
Sorry for not being clear. The output of $f$ should be a 2d vector. x is a real number that defines the range of values of each component of $v$ that will become zero. – George Duckett Jul 27 '11 at 9:12
If you're working in a C-ish language, you could either exploit the fact that Booleans are represented as 0 and 1 (mathematically, you're using an Iverson bracket), or you can use the inline conditional (condition) ? (if-true) : (if-false)... – J. M. Jul 27 '11 at 9:24
@J.M.: On a slight tangent, I've occasionally found myself using $(P\ \;?\ a : b)$ in a mathematical formula. It's a convenient notation in situations where $\scriptstyle \begin{cases}a & \text{if }P \\ b & \text{if not }P\end{cases}$ would be too bulky and Iverson brackets or $b + \mathbf 1_P\;(a-b)$ too obfuscatory. Of course, not being commonly used notation, one needs to explain what it means, but generally I've found that true for Iverson brackets too. – Ilmari Karonen Jul 27 '11 at 11:54
@Ilmari: Hah, yes. :) Sadly, Knuth's evangelizing for the Iverson brackets hasn't been spectacularly successful, but oh well... I guess whichever of piecewise notation, Iverson brackets, or C-ish constructs should you use depends on the audience. – J. M. Jul 27 '11 at 12:02
up vote 1 down vote accepted

The definition of such a function isn't very far from your verbal description.

I wouldn't bother formalizing it further, but if you must, you can define $f(u,v) = (g_x(u),g_x(v))$ where $ g_x(t) = \begin{cases} 0 & t < |x| \\ t & \mbox{otherwise} \end{cases} $

share|cite|improve this answer
...or in Iverson bracket form: $t[t\geq|x|]$. That can be rewritten as $t(1+|t-|x||/(t-|x|))/2$, but I see no advantage in rewriting it that way, except if for some reason you abhor the use of Iverson brackets... – J. M. Jul 27 '11 at 9:53

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.