# How to determine if a function is continuous?

I wish to write code for Riemann-Stieltjes integrals in Mathematica.

A necessary condition for the theorem to hold is that the function must be continuous. The domain of the function is a closed real interval containing infinitely many points, so I can't check continuity at each and every point.

I wish to know if there are any built-in functions in Mathematica that determine if a function is continuous or not. Or if there is any function that returns point of singularities of function?

• Mathematica's support for non-smooth functions is not ideal. For example, D[g[x, y], x, y, x] returns `Derivative[2, 1][g][x, y], even though these are not in general the same (though they are in the presence of certain smoothness requirements). mathematica.stackexchange.com/questions/32872/… is related. Aug 19, 2015 at 7:11
• What is "the theorem"? Aug 19, 2015 at 14:48
• Assuming function g has continuous derivative, Riemann Stieltjes integral of any function f with respect to g is same as Riemann integral of function f*g' (i.e. f times derivative of g). Thus I need to check continuity of derivative before I use the theorem. Aug 19, 2015 at 15:07
• Can you give a specific example of defining in Mathematica the sort of function $g$ you want to test? Aug 28, 2015 at 15:44
• We have been discussing the question before in the context of definite Integrate. Here continuity of the indefinite integral is required to be able to apply the fundamental theorem of calculus. But I don't remember the location of the discussion. I would take a pragmatic approach. To begin with let's assume the function is a given function of one variable in Mathematica. Simply plot it to see if it looks continuous or not in the chosen interval. Suppose you see a jump somewhere. You can then determine the parameters of the jump (location and extent) numerically to a high precision. Aug 28, 2015 at 19:06

## 2 Answers

The new FunctionContinuous[] function in 12.2 is a step in this direction:

FunctionContinuous[Sin[x], x]
True

FunctionContinuous[Tan[x], x]
False

{FunctionContinuous[Sqrt[x], x], FunctionContinuous[{Sqrt[x], 0 < x < ∞}, x]}
{False, True}

A related function is FunctionDiscontinuities[]:

FunctionDiscontinuities[Tan[x], x]
Cos[x] == 0

FunctionDiscontinuities[Gamma[x], x]
Sin[π x] == 0 && x <= 0

I think this is impossible, i.e there's no way to know if an arbitrary function is continuous unless you are given some additional information about the function. Otherwise a function is just a black box. If you function is made up of only known functions, you could check for Piecewise and check at the interface between definitions for instance, but this doesn't prove anything

• "Impossible" is a strong word. There are theorem provers made with Mathematica, so ... Aug 28, 2015 at 14:42
• We we discussing the question before in the context of IntegrateFirst of all Aug 28, 2015 at 18:50
• Impossible is indeed a strong word, perhaps I should have said very difficult in general Aug 30, 2015 at 1:49