2
$\begingroup$

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!

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

2 Answers 2

6
$\begingroup$

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*)

For more info see here.

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

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

FunctionProperties`Singularities 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 = FunctionProperties`Singularities[
  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:

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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