16
$\begingroup$

I'm writing some mathematical equations that describe some computations in my program and it's pretty important that it's written correctly. At one point, it clamps or truncates a value, $x$, into the range $[0, 1]$.

How would i best denote this in official mathematical notation? My best attempt so far is $$ \operatorname{max}(0, \operatorname{min}(x, 1)) $$ But is $\operatorname{min}$ and $\operatorname{max}$ even allowed?

Also, i made the observation that it is also the median value, so could maybe something like this be written? $$ \operatorname{med}(0, x, 1) $$

$\endgroup$
5
  • $\begingroup$ $\operatorname{med}(0,x,1) \:$ is quite clever. $\;\;\;$ $\endgroup$
    – user57159
    May 10, 2013 at 23:41
  • $\begingroup$ @Ricky Demer Is it valid though? Could other people understand it without explanation? $\endgroup$
    – Detheroc
    May 10, 2013 at 23:47
  • 1
    $\begingroup$ Using the median is clever, but it just adds additional work for the reader. Just use $\max$ and $\min$. "Official" should really be replaced with "well-defined." However, I think most people will recognize $\max$ and $\min$ and you probably need not define either of those functions. $\endgroup$
    – parsiad
    May 10, 2013 at 23:53
  • $\begingroup$ Alternatively, write out three more letters for $\:\operatorname{median}(0,x,1)\;$. $\;\;\;$ $\endgroup$
    – user57159
    May 10, 2013 at 23:57
  • $\begingroup$ $x-\lfloor x \rfloor$ floor function. $\endgroup$ Nov 18, 2019 at 5:20

1 Answer 1

15
$\begingroup$

There's no such thing as one "official mathematical notation". There are a bunch of basic conventions that most authors follows, and each field has its own special ways of expressing things. The best advice is usually to follow what other people in your field are doing. I.e., if there are publications which deal with algorithms similar to the one you've written, I'd check to see what notation those use.

If there's no precedent that you can follow, try to pick a notation which is easy to understand and doesn't put unnecessary burden on the reader. For example, while it's correct that the median of $\{0,x,1\}$ is $x$ clamped to $[0,1]$, most people will probably stare at that for a while before they realize what's going on. $\max(0,\min(x,1))$ is much better - most people will instantly recognize that as a clamping operation.

If you use a particular operation like clamping a lot, it'd probably be best to simply define your own syntax for expressing it. One idea would be overload the syntax used to restrict functions to a certain subset of their domain, which is $\left.f\right|_D$. You could similarly define $\left.x\right|_{[a,b]}$ to mean $x$ restricted to the set $[a,b]$. If you do that, make sure though that you define it cleary at the beginning, and maybe repeat the definition the first few times you use it.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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