1
$\begingroup$

I am plotting the following:

Plot[Evaluate[
  Table[Piecewise[{{Abs[x]*Sqrt[Log[x^2] + 2 i], 
      x < -Exp[-i]}, {Abs[x]*Sqrt[Log[x^2] + 2 i], x > Exp[-i]}}, 
    None], {i, -2, 3, 1}]], {x, -3, 3}, 
 PlotRange -> {Automatic, {0, 1}}]

What I am getting is this: enter image description here

The two lines closest to the y axis are interrupted. Why? And why the plot line starts further and further away from zero as one increases the i? The one sided limits are clear and the function tends to zero... Now, if I only print a single branch there are no interruptions.

Plot[Evaluate[
  Table[Piecewise[{{Abs[x]*Sqrt[Log[x^2] + 2 i], 
      x < -Exp[-i]}, {Abs[x]*Sqrt[Log[x^2] + 2 i], x > Exp[-i]}}, 
    None], {i, 1, 1, 1}]], {x, -3, 3}, 
 PlotRange -> {Automatic, {0, 1}}]

enter image description here

Note, my piecewise definition might be wrong, I was trying to tell mathematica that for $|x|<e^{-i}$ the function is not defined, if I don't include the None portion, Mathematica keeps connecting the points $-e^{-i}$ and $e^{-i}$ with a line at $y=0$ which is wrong and this was the only way that I was able to find to prevent this behaviour.

$\endgroup$
7
  • $\begingroup$ There are no gaps in version 13.2 Windows 10 $\endgroup$ Jan 20, 2023 at 19:26
  • $\begingroup$ Plot[Evaluate[ Table[Piecewise[{{Abs[x]*Sqrt[Log[x^2] + 2 i], x < -Exp[-i]}, {Abs[x]*Sqrt[Log[x^2] + 2 i], x > Exp[-i]}}, None], {i, -2, 3, 1}]], {x, -9, 9}, PlotRange -> {{-9, 9}, {0, 10}}, ScalingFunctions -> {None, None}] $\endgroup$
    – Syed
    Jan 20, 2023 at 19:31
  • $\begingroup$ @Syed Still gaps, I am on 13.1 Linux. $\endgroup$
    – atapaka
    Jan 20, 2023 at 19:32
  • $\begingroup$ i.stack.imgur.com/1EhxQ.png is what I see on v12.2.0 on Win7-x64. $\endgroup$
    – Syed
    Jan 20, 2023 at 19:37
  • $\begingroup$ I can confirm the same behaviour on macos the same version. $\endgroup$
    – atapaka
    Jan 20, 2023 at 19:42

1 Answer 1

1
$\begingroup$

This shows that the gaps come from discontinuities in one function being applied to other functions in the Plot. You can use Exclusions -> None to remove them, or plot each function individually.

gl = Table[
     Piecewise[{{Abs[x]*Sqrt[Log[x^2] + 2 i], 
        x < -Exp[-i]}, {Abs[x]*Sqrt[Log[x^2] + 2 i], x > Exp[-i]}}, 
      None], {i, -2, 3, 1}] // 
    Map[SolveValues[FunctionDiscontinuities[#, x], x] &] // N // 
  Apply@Union
(*
{-7.38906, -2.71828, -1., -0.367879, -0.135335, -0.0497871, \
0.0497871, 0.135335, 0.367879, 1., 2.71828, 7.38906}
*)

Plot[Evaluate[
  Table[Piecewise[{{Abs[x]*Sqrt[Log[x^2] + 2 i], 
      x < -Exp[-i]}, {Abs[x]*Sqrt[Log[x^2] + 2 i], x > Exp[-i]}}, 
    None], {i, -2, 3, 1}]], {x, -3, 3}, 
 PlotRange -> {Automatic, {0, 1}}, 
 GridLines -> {gl, None}(*,Exclusions->None*)]

enter image description here

$\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.