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.

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

for example if I wanted to create a function f which takes any input number x and always return 1 but returns 0 when x equals 5


share|cite|improve this question
5 have it already: $$f(x)=\begin{cases}1&,\;\;x\neq 5\\{}\\0&,\;\;x=5\end{cases}$$ – DonAntonio Dec 19 '13 at 21:25
If you don't want to define it piecewise, $f(x)=\lceil \tanh^2 (x-a)\rceil$ will be $0$ at $a$ and $1$ everywhere else. – L. F. Dec 19 '13 at 21:26
The function which is $0$ at $t=0$, $-1$ if $t\lt 0$, and $1$ for $t\gt 0$ has a standard name, the signum function sgn. So we can use $\text{sgn}(|x-5|)$ or $(\text{sgn}(x-5))^2$. – André Nicolas Dec 19 '13 at 21:36

If you dont need $f$ to be continious then declare a picewise function which is 1 for all x exept from 5

share|cite|improve this answer

$$f(x) = \begin{cases}1, \quad x\neq 5\\0, \quad x=5\end{cases}$$

share|cite|improve this answer

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.