rtoy / maxima

A Clone of Maxima's repo
Other
0 stars 0 forks source link

asksign(x*cos(y) - x) --> "Is 1 zero or nonzero?" with assume(x > 0) #3616

Open rtoy opened 4 months ago

rtoy commented 4 months ago

Imported from SourceForge on 2024-07-08 10:24:19 Created by robert_dodier on 2020-11-15 05:54:31 Original: https://sourceforge.net/p/maxima/bugs/3677


Maxima 5.44.0 + SBCL 2.0.9 on macOS.

(%i1) assume (x > 0);
(%o1)                               [x > 0]
(%i2) asksign (x*cos(y) - x);
Is 1 zero or nonzero?
nz;
(%o2)                                 pos

Without assume(x > 0), there's a different bug; see #3676.

Relevant bit of the stack trace:

16: (MREAD-NOPROMPT #<SYNONYM-STREAM :SYMBOL SB-SYS:*STDIN* {1000038673}> NIL)
17: (RETRIEVE ((MTEXT) "Is " 1 " zero or nonzero?") NIL)
18: (ENSURE-SIGN 1 $ZNZ T)
19: (ASKSIGN1 ((MPLUS . #1=(SIMP)) (#2=(MTIMES . #1#) -1 $X) (#2# $X ((%COS . #1#) $Y))))
20: (ASKSIGN01 ((MPLUS . #1=(SIMP)) (#2=(MTIMES . #1#) -1 $X) (#2# $X ((%COS . #1#) $Y))))
21: ($ASKSIGN-IMPL ((MPLUS . #1=(SIMP)) (#2=(MTIMES . #1#) -1 $X) (#2# $X ((%COS . #1#) $Y))))

Looks like ASKSIGN1 has decided to call ENSURE-SIGN about whether 1 is zero or nonzero. Not sure what's going on there.

rtoy commented 4 months ago

Imported from SourceForge on 2024-07-08 10:24:21 Created by robert_dodier on 2020-11-15 05:59:37 Original: https://sourceforge.net/p/maxima/bugs/3677/#7661


Incidentally this bug report was inspired by https://trac.sagemath.org/ticket/30816 , where the problematic expression is:

(%i1) assume(x1 > 0, x2 > 0, notequal(cos(y), 0));
(%o1)                [x1 > 0, x2 > 0, notequal(cos(y), 0)]
(%i4) integrate (sqrt(x1^2 - 2*x1*x2*cos(y) + x2^2), x1);
Is 1 zero or nonzero?
nz;
(%o4) (-(x2^2*cos(y)^2*log(2*sqrt((-2*x1*x2*cos(y))+x2^2+x1^2)
                            -2*x2*cos(y)+2*x1))
 /2)
 +(x2^2*log(2*sqrt((-2*x1*x2*cos(y))+x2^2+x1^2)-2*x2*cos(y)+2*x1))/2
 -(x2*cos(y)*sqrt((-2*x1*x2*cos(y))+x2^2+x1^2))/2
 +(x1*sqrt((-2*x1*x2*cos(y))+x2^2+x1^2))/2

which can be simplified to

(%i5) asksign (4*x2^2*cos(y)^2-4*x2^2);
Is 1 zero or nonzero?
nz;
(%o5) pos
rtoy commented 4 months ago

Imported from SourceForge on 2024-07-08 10:24:24 Created by robert_dodier on 2020-11-15 05:59:55 Original: https://sourceforge.net/p/maxima/bugs/3677/#6a33