5

I need a function that returns $0$ if the given number is negative, and otherwise doesn't change the number.

Example: $$y(-5)=0,\ y(-2)=0,\ y(0)=0,\ y(3)=3,\ y(2566)=2566.$$

Does such a function exist?

rubik
  • 9,344
lopata
  • 319

3 Answers3

14

You can take for example $$\frac{|x|+x}{2}.$$ You can construct similar examples.

10

Just use

$$f(x) = \max\{x,0\}$$

This way it's clear what your function do

Tryss
  • 14,310
3

Exotic: $0^{\sqrt{x^2}-x}\cdot x$.

Michael Hoppe
  • 18,103
  • 3
  • 32
  • 49