1
$\begingroup$

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}$

1 Answers 1

4

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.

  • 2
    In particular, note that $f^ + (x) = \max \{ f(x),0 \}$.2011-02-28