1
$\begingroup$

I'd like to ask you about the way to plot discontinuous function $\frac{2-x}{|x-2|}(x + 2)$.

What Wolfram Alpha produces:

enter image description here

"DIY" version is below. How to achieve similar effect in Mathematica?

enter image description here

$\endgroup$
4
$\begingroup$

Use Exclusions and Epilog.

Plot[(2 - x) (x + 2)/Abs[x - 2], {x, 0, 4},
 Exclusions -> {2},
 Epilog -> {Red, Text[○, #] & /@ {{2, 4}, {2, -4}}}]

or

Plot[f[x], {x, 0, 4},
 Exclusions -> {2},
 Epilog -> {Red, Text[○, #] & /@ {
     {2, Limit[f[x], x -> 2, Direction -> 1]},
     {2, Limit[f[x], x -> 2, Direction -> -1]}}}]

enter image description here

| improve this answer | |
$\endgroup$

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