Let's say we have a function $f(x)=\dfrac{2^x-2}{x-1}$. The graph of the function in Mathematica looks like this:

plot of the function

The function in question is obviously not continuous at $x=1$, but that doesn't show in the plot.

Is there an option to make Mathematica draw a hole at those points where a function is discontinuous, and if so, can I make this the default option?

  • 4
    $\begingroup$ If you define it to be equal to its limit, it is in fact continuous in 1. The left and right limits exist and are equal. $\endgroup$
    – Szabolcs
    Commented Jul 12, 2015 at 21:22
  • 1
    $\begingroup$ You could tell MMA manually where it is also Plot[f[x], {x, -10, 10}, Exclusions -> {x == 1}, ExclusionsStyle -> {Disk[], PointSize -> 0.015}] $\endgroup$
    – Julian
    Commented Jul 12, 2015 at 21:23
  • 1
    $\begingroup$ FunctionDomain can be useful to try to detect points like these. Generally, I don't think there's a good automatic and reliable way to detect such points though. $\endgroup$
    – Szabolcs
    Commented Jul 12, 2015 at 21:26
  • 3
    $\begingroup$ @Cristopher "But f(1) is not defined" <-- it is not a good idea to treat Mathematica as a mathematician. Computer algebra systems will readily simplify things such as ((x - 1) (x - 2))/(x - 1) and won't care about the fact that technically that function should be undefined at x==1. Trying to handle these details would make them much too impractical and probably slow. The conclusion is: it is up to you do decide whether you consider that function defined at x==1 or not, in the strict mathematical sense, and keep this in mind during symbolic manipulations. Mathematica will ignore ... $\endgroup$
    – Szabolcs
    Commented Jul 12, 2015 at 22:02
  • 1
    $\begingroup$ Related, possible duplicates: (6), (5770), (11361) $\endgroup$
    – Michael E2
    Commented Jul 13, 2015 at 17:11

1 Answer 1


You can combine parts of @Julian comment and @Szabolcs comment in the original post to have it marked automatically.

f[x_] := (2^x - 2)/(x - 1)

Plot[f[x], {x, -10, 10}, 
 Exclusions -> {Reduce[! FunctionDomain[f[x], x]]}, 
 ExclusionsStyle -> {Disk[], PointSize -> 0.015`}]

enter image description here

The inequalities that are returned by FunctionDomain negated to get the region not in the function's domain. The Reduce is used to combine inequalities where needed. Exclusions prevents points in the region from being plotted and ExclusionsStyle marks the points.

Hope this helps.


Try it with Manipulate.

 Plot[h[x], {x, -10, 10}, 
  Exclusions -> {Quiet@Reduce[! FunctionDomain[h[x], x]]}, 
  ExclusionsStyle -> {Disk[], PointSize -> 0.015`}, 
  PlotRange -> {{-10, 10}, Automatic}],
 {{c, 1}, -9.5, 9.5},
 Initialization :> {h[x_] := (2^x - 2)/(x - c);},
 TrackedSymbols :> {c}]
  • $\begingroup$ Nice! Thank you very much :) Thanks everyone who commented, too. $\endgroup$
    – Cristopher
    Commented Jul 13, 2015 at 1:51
  • 2
    $\begingroup$ Just a comment on ExclusionsStyle -> {Disk[], PointSize -> 0.015}: Disk[] doesn't do anything here, this might as well be ExclusionsStyle -> {None, PointSize -> 0.015}. The first items sets the style of the inside of the exclusion and the second one sets the boundaries, check e.g. Plot[HeavisideTheta[x - 1], {x, 0, 2}, ExclusionsStyle -> {Green, Directive[Red, PointSize[0.02]]}]. Here the inside is infinitely small so it's not visible. $\endgroup$
    – Szabolcs
    Commented Jul 13, 2015 at 6:10
  • $\begingroup$ Now tweak the style to draw a hollow circle in the same color as the graph, instead of a solid black dot, and you'll have a +1 from this Mathematica newbie. :) $\endgroup$ Commented Jul 13, 2015 at 8:47
  • $\begingroup$ @IlmariKaronen See the answer, mathematica.stackexchange.com/a/5779, by Jens for the solution you request. $\endgroup$
    – Michael E2
    Commented Jul 13, 2015 at 17:09

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