Implicit plots using draw2d seem to have an offset, as can be shown using
draw2d(
ip_grid=[100,100],
ip_grid_in=[10,10],
implicit(
x+y=-1e-6,
x,-.2e-5,.2e-5,
y,-.2e-5,.2e-5
),
grid=true
);
and
draw2d(
ip_grid=[100,100],
ip_grid_in=[10,10],
implicit(
x+y=0,
x,-.2e-5,.2e-5,
y,-.2e-5,.2e-5
),
grid=true
);
Actually x and y are used in the correct fashion, but the rhs() of the implicit equation seems to be exaggerated by 1e-6.
The original report was by Michel Talon in the maxima-discuss thread "Problem with draw2d(implicit(...))" on 20200320.
Diff:
Found the 1e-6 in gnuplot.lisp/sample-data:
I believe the allowed tolerance is set to +1e-6/-0 there. But I would let an expert judge about this.
Hmmm... ...1e-6 is small, if one habitually talks about numbers from 1...10. But if one talks about Nanometers it is way too high. If one should make epsilon somehow auto-adapting or configurable, as a second step? Auto-adapting is kind of user-friendly. But normally any adaptive heuristics sooner or later will be fooled by a totally harmless-looking problem...
An experimental patch that I want some of the real mathematicians explain to me before it is applied, though.
Please do not apply this patch, you are mis-understanding the role of
epsilonin the code--it is a numeric threshold below which thefun-valis deemed to be zero.Your patch assumes that
fun-valis a float, but 3 lines below the code tests if(eq fun-val t)soexprshould be able to return a boolean.My preference would be make
epsilonan (optional?) argument toimplicit.Incidentally, there is no good, user-proof way to set
epsilon. As I showed here, replacingfbyf^(1/3)solves the problem Michel observed. The reason is simple: Michel's original example effectively plots the contourf=1e-6while my solution plotsf=1e-18. Since hisfvanishes to 4th order at (0,0), the contourf=1e-6is quite far fromf=0whilef=1e-18is much less so.Mario committed this code without comment, so let's wait to see if he wants to weigh in.
Closing this item as "won't fix" per comment from Leo B.