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

How can I express that if an expression evaluates to a negative number, I assign it a value of zero? Is it possible to do this without repeating the function twice?

Here is an example

$$f(\vec{\phi})=\begin{cases} f(\vec{\phi}) & \text{for}\; f(\vec{\phi}) \gt 0 \\\ 0 & \text{for}\; f(\vec{\phi})\lt 0. \end{cases}$$

share|cite|improve this question
up vote 4 down vote accepted

It sounds like you are looking for $f^+(x) = \frac{f(x) + |f(x)|}{2}$. Positive values will evaluate to $f(x)$, but negative values will be taken to $0$, but this also repeats the expression so I hope that you were merely looking to avoid a piecewise definition.

share|cite|improve this answer
+1: Further, see – Shai Covo Feb 28 '11 at 23:19
In particular, note that $f^ + (x) = \max \{ f(x),0 \}$. – Shai Covo Feb 28 '11 at 23:34

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.