1

How to make the segmentation function automatically draw the correct function image at the break point?

Through the above problem post solved the problem of software drawing solid line at the interval discontinuity point of the piecewise function.

f[x_] := 
 Which[0 < x < 2, Abs[x - 1], x > 2, 1/2   f[x - 2], x < 0, f[-x]]
Plot[f[x], {x, -1, 10}, Exclusions -> Range[2, 10, 2], 
 ExclusionsStyle -> Dashed]

enter image description here

Now there is a problem, at the endpoint of the piecewise interval, a certain image includes the point corresponding to the interval endpoint, and a certain image does not include the point corresponding to the interval endpoint, which should be identified as a circle in the image. But the software automatically identifies it as a solid point that can be taken.

How can we set up the software to automatically draw a circle at the point of the corresponding function image that can not be taken?

enter image description here

According to the correct image, the position of the red circle in the top image, i.e. the point where the interval endpoint is not reachable, should be marked as a circle. How to set up so that the software can automatically mark as a circle at this point?

csn899
  • 3,953
  • 6
  • 13

1 Answers1

3

sometimes it is easier to make custom solution than general one.

endPoint = 8;
xpoints = Range[0, endPoint, 2];
f[x_] := Which[0 <= x < 2, Abs[x - 1], x >= 2, 1/2    f[x - 2], x < 0, f[-x]];
ypoints = f[#] & /@ xpoints;
xypoints = Transpose[{xpoints, ypoints}];
p = {EdgeForm[{Black, Thick}], FaceForm[White]};
ep = {Sequence @@ p, Disk[#, Scaled[.01]] & /@ xypoints};
vlines = {Dashed, Line[{#, {#[[1]], 0}}] & /@ xypoints};
hlines = Line[{{-1, #[[2]]}, {endPoint, #[[2]]}}] & /@ xypoints;

Now

Plot[f[x], {x, -1, 10},
 Exclusions -> xpoints,
 ExclusionsStyle -> Dashed,
 ImageSize -> 400,
 Epilog -> {vlines, hlines, ep}, AspectRatio -> 1]

Mathematica graphics

Feel free to make adjustments as needed.

Nasser
  • 143,286
  • 11
  • 154
  • 359