I'm looking for a simple operation that returns $0$ if $n$ is less than $1$, but $1$ for anything greater than or equal to $1$. What does the trick?
-
2You will have a problem finding a nice function because it cannot be continuous. $f(n)=\dfrac{|n-1|+n-1}{2(n-1)}$ almost does it, but doesn't have a value at $n=1$ – David P Mar 01 '15 at 05:00
-
1There is no simpler way to describe the function that what you already have. – Winther Mar 01 '15 at 05:25
5 Answers
$f(n) = \begin{cases} 0 \text{ if $n$ < 1} \\ 1 \text{ if $n \geq 1$} \end{cases}$ is probably the function you want.
- 77,651
-
1@user666 What purpose are you intending this for? I would generally think that a piecewise definition is very much the right thing to do in this case. – Milo Brandt Mar 01 '15 at 05:22
-
@user666 I suspect from your comment that you misunderstand what a function is. The given expression represents a function. Perhaps are looking for an elementary function. – xnor Mar 01 '15 at 05:47
If you are okay including the $\operatorname{Floor}$ function then let
$$f(n)=\left\lfloor4\dfrac{\tan^{-1}(n)+\pi}{5\pi}\right\rfloor$$
Explanation: $-\dfrac{\pi}{2}< \tan^{-1}(n)<\dfrac{\pi}{2}$ for all $n$. We also notice that $\tan^{-1}$ is increasing, and $\tan^{-1}(1)=\dfrac{\pi}{4}$.
If $n\ge1$ then $1 \le 4\dfrac{\tan^{-1}(n)+\pi}{5\pi} \le \dfrac{6}{5}<2$, so $f(n)=1$.
If $n<1$ then $-\dfrac{\pi}{2}<\tan^{-1}(n) <\dfrac{\pi}{4}$ giving $\dfrac{2}{5} < 4\dfrac{\tan^{-1}(n)+\pi}{5\pi} < 1$. So $f(n)=0$.
- 12,320
$f(n) = \frac{1}{2}\left(\frac{|n - 1|}{n-1}+ 1\right)$
Sadly undefined at $n=1$, but if you only care about integer $n$, change the instances of "$n-1$" to "$n - \frac{1}{2}$".
- 17,979
This is a modification of the example by DavidP:
$$f(n) =\frac{|3^n-2|+3^n-2}{2(3^n-2)}$$
- 132,525
BRICfan's answer is perfectly correct, and is the standard way of defining your function. As others have pointed out, you can express this as an equation using things like the floor function, but these are really quite artificial and useless for practical purposes. Equations are just one way of expressing functions. In this case, a pretty useless way of expressing them.
You may be interested to know that there is a named function for (almost exactly) what you want, the Heaviside function (see http://en.wikipedia.org/wiki/Heaviside_step_function ). Your function is H(x-1) where H is the Heaviside function. It is defined in the same notation as BRICfan used, and is really just a shorthand for his answer. There is no simpler or more useful answer than BRICfan gave, all I am doing is providing a commonly accepted name for his answer.
- 839