43
$\begingroup$

A friend of mine had a simple question (at least to state) that I thought I would share: can you, without the use of indicator functions, find a(n) (elementary) function that satisfies

\begin{cases} f(n) = 1,& n \in \mathbb N \\ f(0) = 0. \end{cases}

I have been trying and playing around with trigonometric functions but the periodicity keeps bugging me with the zero on these attempts. I have not found a solution myself yet!

$\endgroup$
  • 1
    $\begingroup$ What is the domain of the function supposed to be? $\endgroup$ – f'' May 31 '16 at 21:17
  • $\begingroup$ I suppose the way it was stated to me, $\mathbb N$, but I have been working in the reals. I do not think the initial intend was to go beyond that. $\endgroup$ – Therkel May 31 '16 at 21:19
  • 5
    $\begingroup$ No need to restrict $n$ to positive integers, as $~ g(n)=f(n^2) ~$ could replace any $f(n)$ that works $\endgroup$ – humn Jun 1 '16 at 2:22
  • 1
    $\begingroup$ The real question is, is 0 a natural number ? $\endgroup$ – julien2313 Jun 1 '16 at 13:46
  • 1
    $\begingroup$ @DmitryRubanovich Read the linked article about elementary functinos. In essense, it's arithmetic operations (+ – × ÷), exponentials, logarihtms and solutions to algebraic equations (such as $n$th roots), and any functions that can be expressed by a combination of these. $\endgroup$ – Frxstrem Jun 4 '16 at 17:41

11 Answers 11

76
$\begingroup$

No discontinuities, no stretching the definition of elementary functions, even works for negative integers:

$\frac{1}{2} (\cos{(2^{(x^2)}\pi)}+1)$

The key insight was to

construct a function that is a multiple of 2 for most integers, but not 0. $2^x$ satisfies this for positive integers, then $2^{(x^2)}$ makes that work for negative as well.

$\endgroup$
  • 3
    $\begingroup$ This is a neat answer, but why does it have forty-four votes while $\sin(\pi x)/(\pi x)$ has five? :\ $\endgroup$ – DanielSank Jun 2 '16 at 6:46
  • 17
    $\begingroup$ @DanielSank it might have something to do with the fact that that function is not defined for x = 0 $\endgroup$ – Olorin Jun 2 '16 at 13:08
  • $\begingroup$ I am not at all competent enough to award the 'accepted answer' to anyone but the highest voted answer (i.e. the one the community liked the most), although my personal favorite is the one by @humn (collaborated with @Etoplay) for its simplistic nature. I absolutely loved the creativity all across the board! $\endgroup$ – Therkel Jun 2 '16 at 21:00
67
$\begingroup$

Neater version, thanks to Etoplay. (“Just put the abs below the fraction. ...”)

$ \kern9em \llap{\color{black}{ f(n) ~~ = }} ~~~ \dfrac{ n }{ |n{-}1| + 1 } $

$ \kern9em \llap{\color{black}{ f(0) ~~ = }} ~~~ \dfrac{ 0 }{ |0{-}1| + 1 } ~~=~~ \dfrac0{1{+}1} \color{black}{~~=~~0} $

$ \kern9em \llap{\color{black}{ f \, ( \, n{=}1,2,3,\ldots\, ) ~~ = }} ~~~~ \dfrac{n}{ n{-}1 + 1 } ~~~=~~~~\, \dfrac{n}{n} \color{black}{\,~~~=~~1} $

(Can be made to work for all integers by replacing $n$ with $|n|$ in the formula, and for almost all reals — all but $~ 0 < |n| < \epsilon \,$— by replacing $1$ with an arbitrarily small $\epsilon$.)

Original solution, taking $\mathbb N$ to mean 1,2,3,... and acknowledging $~ |x| = \sqrt{x^2} ~$ as an elementary function:

$ \kern5em \color{black}{ f(n)~=~ } \dfrac{ |3n{-}1| - 1 }{ 3n{-}2 } $

$ \kern5em \color{black}{ f(0)~=~~~ } \dfrac{ |0{-}1| - 1 }{ 0-2 } ~~~=~~ \dfrac{1-1}{-2} \color{black}{~~=~~0} $

$ \color{black}{ f(n{=}1,2,3,\ldots)~=~ } \dfrac{ (3n{-}1) - 1 }{ 3n-2 } ~~=~~ \dfrac{3n-2}{3n-2} \color{black}{~~=~~1} $

(This came from an intuition for $~ n{-}\frac12 ~$ that surprisingly trespassed $0/0$ for $~ n=1$. Haven't yet thought of a neat variation that works for all reals, such as $~ n = \frac23 ~$ and $~ 0 \ne n < \frac13 ~$ in this case.)

$\endgroup$
  • 2
    $\begingroup$ Just put the abs below the fraction. You then have $\frac{2x}{|2x-1|+1}$ $\endgroup$ – Etoplay Jun 1 '16 at 9:57
  • 2
    $\begingroup$ Why we allow abs function? abs is defined conditionally. By allowing functiones defined conditionally we can also use any conditional as well... $\endgroup$ – Luis Masuelli Jun 1 '16 at 16:58
  • 4
    $\begingroup$ @LuisMasuelli abs is not defined conditionally; as described in the answer above, it can be defined as √ x^2 (pardon my lack of fancy markdown) $\endgroup$ – Tin Man Jun 1 '16 at 20:06
  • 2
    $\begingroup$ @Amadeus9$\sqrt{x^2}$$\sqrt{x^2}$ $\endgroup$ – EKons Jun 2 '16 at 18:06
  • 1
    $\begingroup$ @Amadeus9 It's actually LaTeX (rendered by MathJax), not Markdown. (I thought the names might help you with learning the syntax. ;) ) $\endgroup$ – jpmc26 Jun 2 '16 at 22:03
55
$\begingroup$

I think this one is the shortest and simplest so far:

$\frac{1}{2}((-1)^{2^x}+1)$

If you want it to work with negative values of $x$, just

change $x$ to $x^2$ in the formula.

P.S. I just noticed this is very similar to @Joe K's formula, but avoids using trigonometry. Basically

replacing $\cos(2^{x}\pi)$ with $(-1)^{2^{x}}$.

$\endgroup$
27
$\begingroup$

Although there has been some discussion about this:

$0^0$ equals $1$. The Google calculator agrees with me.

If that's the case, then the function is:

$f(n) = 0^{0^n}$ satisfies all conditions, because $0^n$ with $n > 0$ will always equal 0.

$\endgroup$
  • 15
    $\begingroup$ I'm not entirely convinced that $0^x$ is actually an elementary function; the linked Wikipedia page is ambiguous, but if you take exponentiation as "including the function $e^x$" or "satisfying $\frac{d}{dx}a^x = c\cdot a^x$, then $0^x$ is not elementary if you take $0^0=1$." $\endgroup$ – Milo Brandt May 31 '16 at 23:26
  • 22
    $\begingroup$ $0^0$ is not equal to $1$. It is an indeterminate form. $\endgroup$ – Arcturus Jun 1 '16 at 2:05
  • 8
    $\begingroup$ I don't think there's really a "correct answer" to the question of whether $0^0$ is defined or not. Some authors define it, and for those authors, it is defined; other authors do not define it, and for those authors, it is undefined. The question of whether or not it should be defined is something else. $\endgroup$ – Tanner Swett Jun 1 '16 at 2:34
  • 5
    $\begingroup$ Link about $0^0$: "The discussion of 0^0 is very old. [...] Consensus has recently been built around setting the value of 0^0 = 1." $\endgroup$ – hvd Jun 1 '16 at 7:48
  • 6
    $\begingroup$ $f(n) = 1 - 0^n$ could be considered simpler than $0^{0^n}$ and accomplishes the same purpose. However, it's the same key idea as this answer. $\endgroup$ – Paul Sinclair Jun 1 '16 at 16:43
15
$\begingroup$

$f(n) = 1 - 0^n$
$0^0 = 1$, $0^n$ for any positive $n$ is $0$.

$\endgroup$
  • 1
    $\begingroup$ Nope: limit of 0^n for n = 0 is 0 $\endgroup$ – Simon Buchan Jun 2 '16 at 2:07
  • 6
    $\begingroup$ @SimonBuchan Limit of function in point is not always equal to value of function in that point. Truth is that actual value of 0/0 is undefined, but it is often considered to be 1 for sake of several disciplines. Fun fact: limit of n^n for n = 0 is 1. $\endgroup$ – Revolver_Ocelot Jun 2 '16 at 11:04
  • 1
    $\begingroup$ See the comments on this similar answer for a discussion of whether $0^0=1$. $\endgroup$ – Kevin - Reinstate Monica Jun 2 '16 at 17:42
  • $\begingroup$ @Revolver_Ocelot: yep, that is why I explictly stated which limit of 0^0 is relavant here, and it's 0^n (actually, 0 is only the limit from above, but w/e). 0^0 is actually "indeterminate", i.e. has multiple possible values depending on context. Your typo of 0/0 is actually similar: for n -> 0, n/0 is undefined, n/n = 1, 0/n = 0. $\endgroup$ – Simon Buchan Jun 3 '16 at 2:41
  • 1
    $\begingroup$ @SimonBuchan - This isn't a problem about limits at all. It is the value of the function itself, not limits, that is needed here. While not universally accepted, defining $0^0 = 1, 0^n = 0$ when $n > 0$ is a widely-used convention with hundreds of years of precedence. Whether you agree with it is an argument for a different place. Business Cat's answer works perfectly under that convention. $\endgroup$ – Paul Sinclair Jun 3 '16 at 23:24
10
$\begingroup$

I don't know if it can be accepted as the function is non defined in $0$, but as you probably know

$${\sin \pi x \over \pi x}$$ is $0$ for each $x \in \mathbb{N}$

and

its limit for $x \rightarrow 0$ is $1$.

So:

$$1-{\sin \pi x \over \pi x}$$

could be a solution.

$\endgroup$
  • 3
    $\begingroup$ But strictly speaking, the function is undefined at x = 0. $\endgroup$ – 200_success Jun 1 '16 at 17:12
  • 1
    $\begingroup$ You could use $$f(x) = 1 - \lim_{t \to x} \frac{\sin \pi t}{\pi t}$$ instead. $\endgroup$ – Umberto P. Jun 1 '16 at 21:28
  • $\begingroup$ Or just use $\mathop{\mathrm{sinc}}(\pi x)$. $\endgroup$ – user1502 Jun 2 '16 at 3:52
  • $\begingroup$ This is the best answer. It's far simpler than the currently most upvoted answers. $\endgroup$ – DanielSank Jun 2 '16 at 7:00
  • 5
    $\begingroup$ If we're taking 0/0 then we may as well just allow n/n and define 0/0 as 0 $\endgroup$ – Inazuma Jun 3 '16 at 9:52
7
$\begingroup$

There is a Sign Function that you can use it like this:

$f(n) = |\mbox{sgn}(n)|$

$\endgroup$
  • $\begingroup$ That isn't an elementary function. $\endgroup$ – f'' Jun 1 '16 at 6:59
  • 2
    $\begingroup$ @f'' As I know sgn(x) is as elementary as abs(x) or |x| and cos(x), and from OP's question (elementary) is optional ;). $\endgroup$ – shA.t Jun 1 '16 at 7:56
  • 4
    $\begingroup$ If allowed to use abs, sign should also be allowed $\endgroup$ – Luis Masuelli Jun 1 '16 at 17:02
  • 2
    $\begingroup$ Once you learn peano arithmetic you know the sign function is elementary. Incidentally this function is differentiable everywhere. (derivative at zero is twice the dirac delta function). $\endgroup$ – Joshua Jun 1 '16 at 17:42
  • $\begingroup$ If you resort to dirac, it is not elementary. In the best case you use a limit for the dirac's delta. $\endgroup$ – Luis Masuelli Jun 1 '16 at 20:41
5
$\begingroup$

Anyone who has studied the maths behind the Discrete Fourier Transform should be able to figure out this one

Firstly we take the function that is 0 everywhere except where it is 1 at $n = 0$, then subtract it from 1

$f(n) = 1 - \operatorname{sinc} n = 1 - \frac{\sin \pi n}{\pi n}$

$\endgroup$
  • 4
    $\begingroup$ Not elementary, Mr Watson $\endgroup$ – Hagen von Eitzen Jun 1 '16 at 9:28
  • $\begingroup$ I thought trig was fair game? $\endgroup$ – 小太郎 Jun 1 '16 at 9:36
  • $\begingroup$ @小太郎: Well, if you're allowed exponentials and imaginary numbers, I think this is still doable... $\endgroup$ – Phil H Jun 1 '16 at 10:44
  • 2
    $\begingroup$ This is undefined at zero $\endgroup$ – miniBill Jun 1 '16 at 15:21
  • 2
    $\begingroup$ The sinc function is in fact defined to be 1 at 0, since that's its limiting value $\endgroup$ – 小太郎 Jun 1 '16 at 15:47
2
$\begingroup$

$$f(x)= \left\lceil\frac{x}{1+x}\right\rceil$$

$\endgroup$
  • 1
    $\begingroup$ This is not elementary unfortunately. $\endgroup$ – Puzzle Prime Jun 1 '16 at 12:01
  • 1
    $\begingroup$ @PuzzlePrime I just wanna say, I like your username :P $\endgroup$ – Mr Pie Dec 16 '18 at 7:37
1
$\begingroup$

$\underset{\epsilon \to 0}{\lim} \frac{x^2}{x^2 + \epsilon}$

$\endgroup$
  • 5
    $\begingroup$ Taking limits is not elementary $\endgroup$ – Hagen von Eitzen Jun 1 '16 at 9:28
  • 2
    $\begingroup$ True. Though, for any particular value of epsilon, the function almost satisfies the requirements. $\endgroup$ – Owen Jun 1 '16 at 13:30
1
$\begingroup$

$\tanh(cn)$; where $c$ is large (i.e. 1E5) will give the desired answer numerically.

You can square it if you need the negative integers to also give +ve unity.

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.