Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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|improve this question
add comment

1 Answer 1

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|improve this answer
1  
+1: Further, see en.wikipedia.org/wiki/Positive_and_negative_parts –  Shai Covo Feb 28 '11 at 23:19
2  
In particular, note that $f^ + (x) = \max \{ f(x),0 \}$. –  Shai Covo Feb 28 '11 at 23:34
add comment

Your Answer

 
discard

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.