Menu

#3619 Implicit plot using draw2d() has an offset of -1e-6

None
wont-fix
nobody
5
2020-04-06
2020-03-21
No

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.

Discussion

  • Gunter Königsmann

    • summary: Implicit plot using draw2d() has an offset of -16-e --> Implicit plot using draw2d() has an offset of -1e-6
     
  • Gunter Königsmann

    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -24,4 +24,6 @@
         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.
    
     
  • Gunter Königsmann

    Found the 1e-6 in gnuplot.lisp/sample-data:

    (defun sample-data (expr xmin xmax ymin ymax sample grid)
      (let* ((xdelta (/ (- xmax xmin) ($first grid)))
         (ydelta (/ (- ymax ymin) ($second grid)))
         (epsilon #+gcl (float 1/1000000) #-gcl 1e-6))
    

    I believe the allowed tolerance is set to +1e-6/-0 there. But I would let an expert judge about this.

     
  • Gunter Königsmann

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

     
  • Gunter Königsmann

    An experimental patch that I want some of the real mathematicians explain to me before it is applied, though.

     
  • Leo Butler

    Leo Butler - 2020-03-22

    Please do not apply this patch, you are mis-understanding the role of epsilon in the code--it is a numeric threshold below which the fun-val is deemed to be zero.
    Your patch assumes that fun-val is a float, but 3 lines below the code tests if (eq fun-val t) so expr should be able to return a boolean.

    My preference would be make epsilon an (optional?) argument to implicit.

    Incidentally, there is no good, user-proof way to set epsilon. As I showed here, replacing f by f^(1/3) solves the problem Michel observed. The reason is simple: Michel's original example effectively plots the contour f=1e-6 while my solution plots f=1e-18. Since his f vanishes to 4th order at (0,0), the contour f=1e-6 is quite far from f=0 while f=1e-18 is much less so.

    Mario committed this code without comment, so let's wait to see if he wants to weigh in.

     
  • Robert Dodier

    Robert Dodier - 2020-04-06
    • labels: --> draw, implicit, share packages
    • status: open --> wont-fix
     
  • Robert Dodier

    Robert Dodier - 2020-04-06

    Closing this item as "won't fix" per comment from Leo B.

     

Log in to post a comment.

MongoDB Logo MongoDB