Open tornaria opened 2 years ago
The problem seems to be that the plot routine occasionally decides there is a pole at x = 0
, so it fills the gap in the graph with a vertical dashed gray line. This is hard to see because the extra line is on top of the y-axis. To see the effect more easily, you can run the following code:
while True:
f(x) = (floor(x)+0.5) / (1-(x-0.5)^2)
P = plot(f(x - 1), (x, -2.5, 4.5), detect_poles='show',
exclude=[-2..4], ymin=-5, ymax=5)
if "13" in str(P):
bad_plot = P
break
show(bad_plot)
If your experience is the same as mine, the graph will include a vertical dashed line from (1, -2/3)
to (1, 2/3)
. (I didn't do any statistics, but the bad plot seems to happen once every few hundred tries.)
So this doesn't seem to be the same problem as #29954. Instead, it seems we need to make detect_poles
smarter.
bump to 9.6
Replying to @DaveWitteMorris:
Instead, it seems we need to make
detect_poles
smarter.
I agree. The routine for detecting poles computes the slope between consecutive plot points. In this example, the slope at the discontinuity is just very close to the threshold value, so sometimes a pole is detected there (I am a bit surprised this is not deterministic).
A simple attempt would be to increase the threshold a bit. Also, the detection determines the slope only in absolute terms, not relatively – probably it would be good to consider the y-range as well. For example, scaling your example by 10 always replicates the problem:
sage: f(x) = (floor(x)+0.5) / (1-(x-0.5)^2)
sage: plot(10*f(x - 1), (x, -2.5, 4.5), detect_poles='show', exclude=[-2..4], ymin=-50, ymax=50)
Launched png viewer for Graphics object consisting of 13 graphics primitives
Looks similar to #29954.
Component: doctest framework
Issue created by migration from https://trac.sagemath.org/ticket/33129