When providing counter-examples for various things in Calculus, we often utilise piecemeal functions because we can easily 'construct' something 'pathological' by doing that.

Somebody asked me

"To determine if a function is discontinuous or not, can't we just either see if its piecewise defined or if there are any fractions? If the function ISN'T piecewise defined or has any fractions (with x's in the denominator), then wouldn't it always be continuous then?"

I realised that I couldn't think of a counter example immediately, and I still cannot think of one now! Does there exist such a thing at an elementary level?

  • $\begingroup$ By the way, what do you mean by "piecewise defined", exactly? $\endgroup$ – A.P. Mar 29 '15 at 12:31
  • $\begingroup$ I mean that it is a function defined in a way such that it 'glues' two non-equal functions together. So $y=|x|$ is piece-wise since it 'glues' $y=x$ and $y=-x$. $\endgroup$ – Trogdor Mar 29 '15 at 12:37

@A.P.'s answer seems to be this: the set of functions "generated by" piecewise-defined ones is large enough (if you allow many pieces) to encompass all functions. So all functions are piecewise defined, and so all have the potential to be disconcontinuous according to OP's scheme.

I think that this logic is backwards. Rather we want to ask: for a small set of "generating" functions (polynomials, sines, cosines, log, exp, perhaps a few others) and a small set of generating "rules" (addition, subtraction, products, composition, others?), does the set of functions so generated consist entirely of continuous functions?

Stated in this form, the answer is "yes", at least in a limited sense.

Claim: The set of functions generated by finitely many combinations of basic functions consists entirely of functions that are continuous on their domain, where "basic" functions are polynomials, sines, cosines, log, exp, and "combinations" include addition, subtraction, multiplication, and composition.

The proof is straightforward induction: a combination of 1 of any of the functions above is continuous. Suppose that every combination of $n$ of them is continuous, and that $f$ is a combination of $n+1$ of them. Then $f = g \star h$, where $h$ is a combination of $n$ basic functions, and hence continuous, and $g$ is a basic function, and hence continuous, and $\star$ represents one of the combination operations. But the sum, difference, and product of continuous functions is a continuous function on the intersection of their domains, and a composition $p \circ q$ is continuous on $q^{-1}(D)$, where $D$ is the domain of $p$.

Note that the "closure" of this generated set -- functions defined by infinite compositions or sums, etc. -- might well contain non-continuous functions, as @sintetico's example of the square wave demonstrates.

One last question concerns the tangent. Many folks have said it's just $sin/cos$, and therefore a quotient. I think it's also (maybe) reasonable to define $$ \arctan(x) = \int_0^x \frac{1}{1+t^2} ~dt, $$ observe that $\arctan$ is strictly increasing and differentiable, and therefore has a differentiable inverse that we can call $\tan$.

Of course, this only defines $\tan$ on the interval $-\pi/2 < x < \pi/2$, and this function is, indeed, continuous on its domain. But in general, if you allow "inversion" among the "generating operations", the question becomes somewhat more subtle, esp. in the matter of defining the domain of the inverse precisely.

  • $\begingroup$ My point is simply that the OP's question, as stated, isn't well posed. It is good to point out that we can positively answer a similar, yet different, question. $\endgroup$ – A.P. Mar 29 '15 at 14:30
  • 2
    $\begingroup$ I think it's almost well posed, given some charity from the reader. OP asks "[To check a function], can't we just either see if it's piecewise defined or if there are any fractions?" If we slightly alter that, we get "To check a function, can't we see if there's a description of with with no fractions or piecewise definitions?" That's still tough -- too hard to look through all representations, but we can revise to "To check a function given by a representation is continuous, can we just verify that the representation has no fractions or pieces?" Yes: that's sufficient, but not necessary. $\endgroup$ – John Hughes Mar 29 '15 at 15:46

It all depends on how you define "piecewise defined". If you consider a function to be piecewise defined if its domain is a union of finitely (or even countably) many intervals $D = I_1 \cup \dotsb \cup I_k$ and $$ f(x) = f_i(x) \text{ if } x \in I_i $$ then a counterexample would be the Dirichlet function (the characteristic function of the rationals in the reals). An even more exotic one would be Conway's base 13 function.

If, instead, you allow $D$ to be the union of uncountably then every function $\Bbb{R} \to \Bbb{R}$ is piecewise defined, because $\{x\}$ is an interval for every $x \in \Bbb{R}$.

Addendum: My point is that the OP's question, as stated, isn't well posed. As John Huges suggests, we could instead answer the slightly different, but more formal, question: "Given a set $X$ of continuous functions and a set $C$ of 'combinators', is every function obtained by recursively applying (with a possible finiteness restriction) elements of $C$ to elements of $X$ continuous?"

  • 2
    $\begingroup$ Some may say that the existence of the absolute values essentially makes it piecewise defined. $\endgroup$ – Trogdor Mar 29 '15 at 12:10
  • $\begingroup$ @Trogdor: My edited answer should be more clear. $\endgroup$ – A.P. Mar 29 '15 at 12:48

I think there are many examples of discontinuous functions which are not rational functions (with $x$ at the denominator). Some examples are the logarithm function $f(x)=\log x$, which is not continuous at $x=0$, and the tangent function $f(x)=\tan x$, which is discontinuous at $x=\pi/2, 3\pi/2,\ldots,n\pi+\pi/2$. Also the cotangent, the secant, the cosecant are discontinuous (although you may object that this trigonometric functions are "fractions" in some way, for example $\tan x={\sin x}/{\cos x}$). A more advanced example is the square wave function, defined as

$$ f(x) = \frac{4}{\pi} \sum_{k=1}^\infty {\sin{\left(2\pi (2k-1) \omega t \right)}\over(2k-1)} {} = \frac{4}{\pi}\left(\sin(2\pi \omega t) + {1\over3}\sin(6\pi \omega t) + {1\over5}\sin(10\pi \omega t) + \cdots\right) $$

which is an infinite sum of continuous functions (the sines) and is discontinuous at $x=0, \pi, 2\pi, \cdots, n\pi$. I am sure there are many other examples, these are the first that came into my mind.

Edit: The function $f(x)=\frac{\mathrm{d}}{\mathrm{d} x}|x|$ is also discontinuous at $x=0$, and is not defined in terms of fractions.

Anyway, one can say that a finite sum or a finite product of continuous functions is still a continuous function. For this reason, every polynomial function is continuous, every finite sum of sines or cosines is continuous, etc. As a counterexample, rational functions cannot be written in general as a sum of continuous functions, and are therefore in general not continuous.


There is some problem regarding the definition of continuity respect to the domain of the function. Generally, one says that a function is continuous if it is continuous in the closure of the domain, i.e., the domain together with all its limits points. In fact, without this additional requirement, one can argue that the rational function $1/x$ is continuous, since it is continuous in its domain $\mathbb{R}-\{0\}$.

Improved and general statement: Any function obtained as a combination of sums, products, compositions of a finite number of functions which are continuous (in the closure of their domains), is a continuous function (in the closure of its domain). The same statement can be made if one substitutes the word "continuous" with the word "smooth", or "analytical".

Rational functions like $1/x$ are not continuous in the closure of their domains, and neither is the logarithm function, not the tangent, cotangent, secant, etc. On the other side, polynomials, sine, cosines, exponentials, etc are continuous functions (in the closure of the domain), and therefore any function finitely derived from these, is itself continuous (in the closure).

  • $\begingroup$ I'm with you on $\log(x)$, but I think that $\tan(x) = \frac{\sin(x)}{\cos(x)}$ counts as "defined using fractions". $\endgroup$ – A.P. Mar 29 '15 at 12:30
  • $\begingroup$ Just regarding your first point when you said that the logarithm is not continuous at $x=0$. I was under the impression that continuity is determined purely within the domain of the function? So I would have thought that the log function is thus continuous as its domain is $x>0$. I'm not too sure about the tan example since it can be expressed as a sine over a cosine. Can you think of a finitely defined example? I understand the square wave function, but it is an infinitely defined function, which I feel is ' cheating' because the limiting case is a piece-wise defined function. $\endgroup$ – Trogdor Mar 29 '15 at 12:31
  • $\begingroup$ @Trogdor: If continuity was defined only within the domain of a function, then $\frac{1}{x}$ would be continuous... $\endgroup$ – A.P. Mar 29 '15 at 12:32
  • $\begingroup$ So does that mean that the definition of continuity is that the domain must be all real $x$? $\endgroup$ – Trogdor Mar 29 '15 at 12:35
  • $\begingroup$ @Trogdor: I stand corrected: the function $\frac{1}{x}$ is continuous on $D = (-\infty,0)\cup(0,+\infty)$ and it doesn't make sense to ask if it is continuous on $\Bbb{R}$ because it isn't defined at $0$. On the other hand, the function defined as $f(x) = \frac{1}{x}$, $f(0) = 0$... $\endgroup$ – A.P. Mar 29 '15 at 13:34

Consider the function: $$f(x)=\lim_{n\to \infty} \arctan(nx)$$

If $x>0$ the function equals $\displaystyle\frac{\pi}{2}$.

If $x<0$ the function equals $-\displaystyle\frac{\pi}{2}$.

If $x=0$ the function equals $0$.

There are no fractions and the function isn't defined piecewise (there is a limit, though.) But it is discontinuous at $x=0$


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.