Menu

#3715 draw3d with variables x[1], x[2] not working

None
closed
nobody
5
2022-05-25
2021-02-13
b606
No

Hi,
I am running into an issue I did not have before : draw3d does not seem to recognize x[i] in an expression as variables for explicit 3d plots (See below for a test session, f and g are the same functions). Do I miss something here in order to make the input cell %i5 work? (Renaming all variables in my real codes is a no go.)

Test session

kill(all);
load(draw);
g:x^2+y^2-4*x*y;
draw3d(explicit(g,x,-5,5,y,-5,5),xlabel="x1",ylabel="x2");
f:x[1]^2+x[2]^2-4*x[1]*x[2];
draw3d(explicit(f,x[1],-5,5,x[2],-5,5));

The draw3d with g works but not the second one with f

Error message (tested in maxima console)

draw3d (explicit): non defined variable in term x
                                                                                                                                                         2

My system is an up to date debian buster :

apt policy wxmaxima maxima
wxmaxima:
  Installé : 19.01.2-1
  Candidat : 19.01.2-1
 Table de version :
 *** 19.01.2-1 500
        500 http://deb.debian.org/debian buster/main amd64 Packages
        100 /var/lib/dpkg/status
maxima:
  Installé : 5.42.1-1
  Candidat : 5.42.1-1
 Table de version :
 *** 5.42.1-1 500
        500 http://deb.debian.org/debian buster/main amd64 Packages
        100 /var/lib/dpkg/status
Note: bug also reported at https://github.com/wxMaxima-developers/wxmaxima/issues/1490

Discussion

  • Robert Dodier

    Robert Dodier - 2021-02-15

    Here is a one-line patch -- if you wish you can apply this to your local copy.

    diff --git a/share/draw/gnuplot.lisp b/share/draw/gnuplot.lisp
    index 20a0a503f..492be79fa 100644
    --- a/share/draw/gnuplot.lisp
    +++ b/share/draw/gnuplot.lisp
    @@ -1828,7 +1828,7 @@
              ($numer t)
              (count -1)
              ncols result)
    
    -    (when (not (subsetp (rest ($listofvars fcn)) (list par1 par2)))
    +    (when (not (subsetp (rest ($listofvars fcn)) (list par1 par2) :test #'alike1))
                 (let ((items (rest ($listofvars fcn))) (item 'nil))
                  ;; Search for the item in sublist that is the undefined variable
                  (while items
    

    Looks like other tests for undefined variables need to be fixed up as well ...

    I will work on this but it may be a week or so until I push a commit for the bug fix.

    If it ever worked, my guess is that's because of Lisp implementation-specific behavior in SUBSETP when the test is not specified.

     
  • b606

    b606 - 2021-02-15

    Thank you very much for the patch. I have not tested it yet but you are right. Other functions in draw have the same problem (region, etc.) I am looking forward your bug fix.
    Best regards.

     
  • Leo Butler

    Leo Butler - 2021-02-15

    I can confirm the bug is in git HEAD. The fix is simple and I will push
    the commit shortly.

    Leo

     
  • Leo Butler

    Leo Butler - 2021-02-16
     
  • Leo Butler

    Leo Butler - 2021-02-16

    Fixed in commit b6bf72f70d3. I added a bunch of tests to check it works for all the relevant access points in draw.

    Robert, I didn't see your comments til I came to close the bug report. I used like because that is used in nset.lisp to test equality. Is there a reason to prefer alike1?

     
    • Robert Dodier

      Robert Dodier - 2022-05-25

      Leo, I'm looking at this again after a long interval, sorry for the delay. About LIKE vs ALIKE1, in general I think it's appropriate to use Maxima functions instead of ostensibly similar Lisp functions, since then the results are more nearly likely to conform to Maxima user's expectations. Maxima is(a = b) is implemented by ALIKE1, so testing ALIKE1 is (I hope) the same as testing via "=". There are probably cases in which two expressions pass ALIKE but fail LIKE.

       
  • Robert Dodier

    Robert Dodier - 2021-02-28
    • status: open --> closed
     
  • Robert Dodier

    Robert Dodier - 2021-02-28

    Fixed by commit b6bf72. Thanks to Leo B.

     

Log in to post a comment.

MongoDB Logo MongoDB