Testing for continuity over a given domain

Is there any way to use Mathematica to test whether a function is continuous over a given domain?

-

This is likely to be very slow..

isDiscontinuous[f_, low_, high_] :=
Resolve[Exists[del, del > 0, ForAll[eps, eps > 0,
Exists[{x1, x2},
low <= x1 < x2 <= high && x2 - x1 < eps &&
Abs[f[x1] - f[x2]] > del]]]]


Here are simple examples.

ff[x_] := x^2 + x

isDiscontinuous[ff, -1, 2]

(* Out[334]= False *)

gg[x_] := Sign[x]

Resolve[isDiscontinuous[gg, -1, 2]]

(* Out[331]= True *)

-
doesn't seem to work for the Sin[x]/x example. – george2079 May 16 '14 at 15:24
@george2079 My guess is the underlying engine in the quantifier elimination is not happy with non-rational functions. – Daniel Lichtblau May 16 '14 at 15:51

We can call Wolfram|Alpha then use Reduce.

Let's say you want the discontinuities of Sin[x]/x + 1/(x-2) for -1 < x < 1.

First find all discontinuities:

all = ReleaseHold[WolframAlpha["discontinuities of Sin[x]/x + 1/(x-2)", {{"Result", 1}, "Output"}]]
(* x == 0 || x == 2 *)


then find the values in your domain:

Reduce[all && -1 < x < 1, x, Reals]
(* x == 0 *)


Pack this into a function:

Discontinuities[f_, x_, domain_:True] := Module[{str, all},

str = ToString[f, InputForm];
all = ReleaseHold[WolframAlpha["discontinuities of " <> str, {{"Result", 1}, "Output"}]];

If[MatchQ[all, _Missing], Return[False]];

Reduce[all && domain, x, Reals]
]

Discontinuities[Sin[x]/x + 1/(x-2), x, -1 < x < 1]
(* x == 0 *)

-

You can readily catch "some" discontinuities like this:

 Reduce[ Denominator[Together[ Sin[x]/x  + 1/(x - 2)]] == 0 ]


x == 0 || x == 2

Likely WolframAlpha applies a suite of such tests.

-