# Checking for discontinuities

There was an older post about checking the continuity of a function but the routines in the reply don't seem to work for my function. Hence the new post. If I have a function

If[x<0,x+1,x^2+2]


can Mathematica spit out where the discontinuity is? TIA!

• Prior to v12.2, the most likely place to look is at the transition point: Equal @@ (Limit[f[x], x -> 0, Direction -> #] & /@ {"FromBelow", "FromAbove"}) Dec 24, 2020 at 15:04

Better is convert If function to Piecewise.FunctionDiscontinuities works only on MMA 12.2.0.You can execute this function on Wolfram Cloud.,you must only sign in.

FunctionDiscontinuities[Piecewise[{{x + 1, x < 0}}, x^2 + 2], x]
(*x==0*)


Of course FunctionDiscontinuities[If[x < 0, x + 1, x^2 + 2], x] works too,but give some errors.

• Just to add, PiecewiseExpand[If[x < 0, x + 1, x^2 + 2]] will do the required conversion on your behalf. Dec 24, 2020 at 13:16
• @J.M.'sdiscontentment .Oh yes thanks. Dec 24, 2020 at 13:19
• This works, thanks. But is there a way to execute the same in Mathematica 12.0? Dec 24, 2020 at 15:14
• @123infinity no, only works on MMA 12.2.0 or higher. Dec 24, 2020 at 21:16

FunctionPropertiesSingularities has been around for a while and works in V12.0, which the OP seemed once to want. It's undocumented, and I don't know how to fully explain. It returns discontinuities in the form {equation, condition}. (This is an acceptable syntax to pass to the Exclusions option of many solvers.)

disc = FunctionPropertiesSingularities[
If[x < 0, x + 1, x^2 + 2],
{x},
{"BRANCHCUTS", "DEFCUTS",
"POLES", "ESSENTIAL", "IGNORE", "PWMINMAX"}]

(*  {{}, {{-x == 0, True}, {x == 0, True}}, {}, {}, {}}  *)

DeleteDuplicates[
Join @@ Simplify[disc]
]

(*  {{x == 0, True}}  *)


It handles multivariate functions as well:

FunctionPropertiesSingularities[
Log[x - y], {x, y}, {"BRANCHCUTS", "DEFCUTS", "POLES", "ESSENTIAL",
"IGNORE", "PWMINMAX"}]

(*  {{{Im[x - y] == 0, Re[x - y] <= 0}}, {}, {}, {}, {}}  *)
`