I make a big fuss that my calculus students provide a "continuity argument" to evaluate limits such as $\lim_{x \rightarrow 0} 2x + 1$, by which I mean they should tell me that $2x+1$ is a polynomial, polynomials are continuous on $(-\infty, \infty)$, and therefore $\lim_{x \rightarrow 0} 2x + 1 = 2 \cdot 0 + 1 = 1$.

All the examples they encounter where it is not correct to simply evaluate at $a$ when $x \rightarrow a$ fall into one of two categories:

  • The function is not defined at $a$.
  • The function is piecewise and expressly constructed to have a discontinuity at $a$.

I'd like to find a function $f$ with the following properties:

  • $f(a)$ exists
  • $f(a)$ is not (obviously) piecewise defined
  • $f(x)$ is not continuous at $a$
  • $f$ is reasonably familiar to a Calculus I student - trigonometry would be admissible, but power series would not (though they might still make for interesting reading)
  • 5
    $\begingroup$ I think that their is a deeper question here: what is a piecewise defined function? $\endgroup$ – Baby Dragon Jan 25 '14 at 23:48
  • $\begingroup$ So you are trying to "hide" a removable discontinuity $\endgroup$ – MPW Jan 26 '14 at 0:08
  • 4
    $\begingroup$ I don't understand why you call $f(x)=\frac{|x|}x$ an example (for $a=0$ I presume). Certainly $f(0)$ does not exist in this case (unless you extend the definition of $f$ piecewise). $\endgroup$ – Marc van Leeuwen Jan 26 '14 at 4:24
  • 3
    $\begingroup$ Note that using a limit or some other “advanced” structure is necessary to fulfill your requirements, since all available functions are either piecewise-defined or continuous and all “simple” operations (adding, multiplying, function composition) preserve continuity with the exception of division which causes definition gaps where the divisor is zero and preserves continuity otherwise. $\endgroup$ – Wrzlprmft Jan 27 '14 at 12:55
  • 1
    $\begingroup$ I posted a similar question today, and now I've posted the first paragraph of my question as an answer to this question. $\endgroup$ – Michael Hardy Jan 30 '14 at 22:43

10 Answers 10


A very easy way to construct a function that is piecewise without being "obviously piecewise" is functions defined in terms of limits:

$$f(x) = \lim_{a \to +\infty} \exp\left(-ax^2\right) = \begin{cases}1, & x = 0 \\ 0, & \text{otherwise}\end{cases}$$

This example has the advantage of being easily-comprehensible to beginning calculus students.


This problem relates to issues discussed by Weyl and embodied in the work of Brouwer on Intuistionist Mathematics. Here is a discussion:


Weyl stated "Above all, however, there can be no other functions at all on a continuum than continuous functions." After pointing out the absence of discontinuous functions on R, Weyl went on to say that: "When the old analysis allowed the formation of discontinuous functions, it thereby showed most clearly how far it is from grasping the essence of the continuum. What one calls nowadays a discontinuous function, consists in fact (and this also is basically a return to older intuitions) of a number of functions on separated continua."

Brouwer proved, in Intuitionist Mathematics, that a totally defined function on an interval is continuous.


How about $$ f(x) = \sup \bigl( \mathbb Z\cap (-\infty,x)\bigr) = \lceil x\rceil -1$$


$$ g(x) = \lim_{n\to\infty} \tan^{-1}(nx) = \begin{cases}\pi/2 & x>0 \\ 0 & x=0 \\ -\pi/2 & x< 0 \end{cases} $$


$$ h(x) = \limsup_{n\to\infty} \sin(nx\pi) = \begin{cases}0 & x \in \mathbb Z \\ 1 & x \notin \mathbb Q \\ \in(0,1] & \text{elsewhere} \end{cases}$$


$$ k(x) = \lim_{y\to+\infty} \frac1y \int_0^y \cos(xt) \, dt = \begin{cases} 1 & x=0 \\ 0 & x\ne 0 \end{cases}$$


$$ g(x) = \int_0^\infty \frac{x}{1+(xt)^2} \,dt = \begin{cases} \pi/2 & x > 0 \\ 0 & x=0 \\ -\pi/2 & x<0 \end{cases}$$


You can define $f_n(x)=x^n$ on $[0,1]$, and $f(x)=\lim_{n\to\infty} f_n(x)$. Then the discontinuity of $f$ at $1$ is a little tricky, as all the $f_n$ are continuous.


As I stare at a cube-shaped building whose side has length 100 meters, while walking westward parallel to its north wall at a location 100 meters north of the building, the distance to farthest point from me that I can see on the face of the building varies as my position changes. As I cross the line of the western wall, I can suddenly see the southwest corner of the buidling, so that distance as a function of my position has a jump discontinuity that arises naturally from geometry.


This is an interesting case showing why mathematicians should understand non-standard math like constructive math, even when we don't "believe it." It still helps us understand things about standard math.

There's a very deep reason why all the basic discontinuous functions are defined piecewise, or as limits.

It is known that in constructive mathematics, all functions are continuous.

But wait, you ask, what about simple piece-wise function such as:

$$f(x)=\begin{cases}0&x<0\\ 1&x\geq 0\end{cases}?$$

I mean, that looks constructive, but it is discontinuous.

It turns out $f$ is not constructive. That's because the test of whether $x<0$ is not computable. There is no computer program which takes a (computable) real number and returns whether that number is negative.

A computable real number is, roughly, a computer program which produces a Cauchy sequence of rational numbers (and the ability to have some idea how fast it converges.)

If $x=(x_n)$ and $y=(y_n)$ are computable real numbers, we define $x<y$ for such real numbers easily enough: $x<y$ if there exists a proof that $x_n<y_n$ for all but possibly finitely many $n.$

We define $x=y$ if we can prove that $x_n-y_n\to 0.$

Under this definition, there are real numbers that are not comparable. We simply can't tell if $x<y, x=y,$ or $x>y$ for some values $x,y.$


If there was a program that solved the general order problem for computable real numbers, you could solve the halting problem (by taking a program $P$ and producing the computable sequence

$$x_n=\begin{cases}0&\text{if $P$ does not halt by step $n$}\\ \frac{1}{N}&\text{if $P$ stops at step $N$ and $n\geq N$} \end{cases}$$

This is computably Cauchy - that is, given a rational $\epsilon>0$ we can compute an $M$ such that $|x_n-x_m|<\epsilon$ for $n,m\geq M.$)

(That is why we choose $\frac{1}{N}$ and not a constant.) The sequence converges to $0$ if the program doesn't halt, or $\frac{1}{N}.$

So if we could solve the whether $x=0$ or $x>0,$ we'd have a solution to the halting poblem.

This is why all the cases of discontinuous functions rely in either cases, or other non-constructive techniques, like point-wise limits of functions.

Note that some piecewise functions can be computed, but only if they are continuous. For example, if $x=(x_n)$ then $|x|=(|x_n|).$ That might seem circular, but the $|x_n|$ is the rational absolute value function, which is computable. Rational piecewise functions are computable (if the pieces are computable in the rationals.)


There's always $[x]$, and $\chi_S(x)$ for any proper subset $S$ of $\mathbb{R}$.

  • $\begingroup$ I would consider these to be at the same level of "piecewiseness" (and less familiar than) $|x|$. $\endgroup$ – Austin Mohr Jan 25 '14 at 23:45
  • 1
    $\begingroup$ If $[x]$ is the greatest integer function, I think that is in fact a pw defined function. Likewise of the characteristic function. $\endgroup$ – Baby Dragon Jan 25 '14 at 23:46
  • $\begingroup$ The limits of interest don't even exist here... $\endgroup$ – David Mitra Jan 25 '14 at 23:54
  • $\begingroup$ @DavidMitra: Indeed. My bad. $\endgroup$ – MPW Jan 26 '14 at 0:10
  • 1
    $\begingroup$ @BabyDragon: It can be written piecewise, but it needn't be. $[x]= \max\left( \mathbb{Z}\cap(-\infty,x]\right)$. $\endgroup$ – MPW Jan 26 '14 at 0:16

Note: I realize that this may not be the droid your looking for, but it is a droid.

I think that this depends on what one means by a piecewise defined function. I will take a stab at that question first. So let us start with a base set of functions (we may let the domain and codomain vary But insist that both be subsets of some big set, like $\mathbb{R}$) , which we will call $\mathcal{F}$. Then we will also have a set $\mathcal{O}$ which will be a set of operations (these operations [these operations may be partially defined] will typically be functions of the form $\mathcal{F}^n\to \mathcal{F}$, for varying $n$. We may then define $\widehat{\mathcal{F}}$ to be the smallest set of functions such that if $g:\mathcal{F}^n\to\mathcal{F}$ is in $\mathcal{O}$ and $$f_1,f_2,\cdots f_n\in\widehat{\mathcal{F}}$$ then $$g(f_1,f_2,\cdots f_n)\in\widehat{\mathcal{F}}.$$ We may then say that $\widehat{\mathcal{F}}$ is the set of functions (fully) defined by the pair $(\mathcal{F},\mathcal{O})$. Any function not in $\widehat{\mathcal{F}}$ may be defined in a piecewise manner (one piece for each point, provided we have all constant functions).

The question now is what are your sets, $(\mathcal{F},\mathcal{O})$. I would let the set $\mathcal{F}$ be the set

$$\{(x\mapsto any-constant),\mbox{ } (x\mapsto x),\mbox{ } (x\mapsto\sin x), \mbox{ }\\(x\mapsto e^x), \mbox{ }(x\mapsto \ln x)),\mbox{ }(x\mapsto \sin^{-1}x),\mbox{ }(x\mapsto \cos^{-1}x), \mbox{ other inverse trigs},\mbox{ }(x\mapsto\sqrt[n]{x}) \}$$ (one may add to this or take away at will).

Now the set $\mathcal{O}$ of operations is the following: $$\{(f,g\mapsto f+g), (f,g\mapsto fg),(f\mapsto\frac{1}{f}), (f,g\mapsto f\circ g) ,(f,g\mapsto f^g)\}$$ (the last rule could be tricky for negative values). Now given all of this the piece wise defined functions that you wanted to exclude such as $|x|$ cannot be excluded. Indeed, it may be the case that we can get all kinds of piecewise defined functions this way. If we add to our operations the ability to take certain point-wise limits we may obtain even more piece-wise defined functions.

  • $\begingroup$ Note that one might think that $x\mapsto\sqrt[n]{x}$ is redundant since one may try to write this as $e^{\frac{\ln x}{n}}$. As written this is only Ok for positive $x$, where $x\mapsto\sqrt[3]{x}$ is Ok for all $x$. $\endgroup$ – Baby Dragon Jan 26 '14 at 0:56

What about a derivative? Something like $\left(x^2 \sin \frac 1 x\right)'$. You have to extend the function to say $f(0)=0$, as it is not defined there, but they'll have to extend the derivative, which cannot be computed with the formula at $x=0$.

I also remember a limit I was given in my last calculus exam:

$$ \lim_{m \to \infty} \lim_{n \to \infty} (\cos^2 (m! x))^n $$

(Zero for the rational numbers, 1 for the irrational ones)


An interesting example of "natural discontinuity" that I know, is easy to absorb on any level and it comes from classical textbooks. It requires some basic imagination, however.

Textbooks usually start from defining the function, and then ask a student to prove some technical stuff about it. I prefer to start from the other way around.

Consider $(x,y,z)$-space. Take both $x$- and $y$- axes and exclude the origin. We want our function to go through them, so that whenever $x$ or $y$ equals $0$, $z$ equals $0$ as well.

Now, consider the diagonals $x+y=0$ and $x-y=0$ lifted above $(x,y)$-plane to $z=1$, and exclude the lifted origin $(0,0,1)$ from this construction. What happens if we want our continuous everywhere except for the origin function to go through these lines as well?

To help imagine that. A bisection by any vertical plane $y=c\neq0$ should be a continuous M-shaped function going through $(x,z)=(0,0)$ as well as $(x,z)=(\pm c,1)$. The closer is $c$ to $0$, the closer are the last two points to each other. Similarly, with bisection by any vertical $x$-plane.

When you move to origin from north, east, south or west along $x=0$ or $y=0$ you are always at the bottom of this "canyon" at sea-level height of $z=0$. However, when you are on one of the two diagonals moving, for example, from north-east, you are always on top of the range at height $z=1$.

Interestingly enough, such a function can be easily defined, for example, as follows: $$\frac{x^2y^2}{x^4+y^4},(x,y)\in\mathbb{R}-\{(0,0)\}$$

Now, without specifying the value at $(0,0)$ what should it be? Depending on what direction you are coming from, it can be any value within the whole interval. But in any case it will remain discontinuous.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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