Menu

#4410 'at' incorrectly returns 0 instead of error for 0/0

None
open
nobody
5
2025-01-27
2024-11-15
No

The same behavior mentioned in the question posted 10 years ago is also reproduce with the following code:

(%i4) f:(2xy)/ (x^2+y^2)$
f1:diff(f,x,1)$
f1:ratsimp(f1)$
at(f1, [x=0,y=0]);
(%o4) 0

Here is my build_info()
build_info(version="5.46.0",timestamp="2022-04-13 23:24:03",host="x86_64-w64-mingw32",lisp_name="SBCL",lisp_version="2.2.2",maxima_userdir="C:/Users/Usuario/maxima",maxima_tempdir="C:/Users/Usuario/AppData/Local/Temp",maxima_objdir="C:/Users/Usuario/maxima/binary/5_46_0/sbcl/2_2_2",maxima_frontend="wxMaxima",maxima_frontend_version="22.04.0_MSW")

1 Attachments

Discussion

  • Stavros Macrakis

    • labels: --> at, limit
     
  • Stavros Macrakis

    In Maxima, to multiply x and y, you need to write x*y. But I see that's what you're writing in the attachment.

    The answer about at is more subtle.

    In principle, to handle at on more than one variable, you need a multivariate limit, which is not necessarily the same as nested univariate limits. For example, limit(x/y) as x->0 and y->0 should be UND, but limit(limit(x*y,x,0),y,0) and limit(limit(x*y,y,0),x,0) are not equivalent to that.

    Unfortunately, Maxima does not have multidimensional limits.

    You might think that taylor(f1,[x,y],0,1) would give a more helpful answer, but alas it does not.

     
  • Robert Dodier

    Robert Dodier - 2024-11-17
    • labels: at, limit --> at, limit, simplification, psubst
    • summary: math stackexchange 870237 --> 'at' incorrectly returns 0 instead of error for 0/0
     
  • Robert Dodier

    Robert Dodier - 2024-11-17

    Documentation for at says that multiple substitutions are applied in parallel, and I see that psubstitute is called in the code (src/comm2.lisp). So far, so good.

    I see that psubstitute([x=0,y=0], x/y) returns 0 (incorrect) while psubstitute([x=0,y=0], y/x) triggers a divide by zero error (correct). So the order of arguments seems to make a difference.

    Tracing SIMPLIFYA (general expression simplifier), I see that 0*(0^-1) simplifies to 0 (incorrect). Indeed, just entering '(0*(0^-1)) at the input prompt yields 0.

    So at this point it looks to me that the problem is in the simplifier (SIMPTIMES specifically); when it encounters 0 it drops the rest of the expression and returns 0.

    I wouldn't be surprised if other variations of this bug have been encountered, although I don't know of any offhand.

     
    • Stavros Macrakis

      Yes, simptimes doesn't bother to simplify its other arguments if the first one is 0.
      This is the very first clause of simptimes.

       
  • Robert Dodier

    Robert Dodier - 2024-11-17

    Looks like https://sourceforge.net/p/maxima/bugs/4011/ describes the same bug.

     
  • David Scherfgen

    David Scherfgen - 2025-01-27

    Add this before (return res) in simptimes to simplify any remaining factors after encountering a zero factor:

    (unless z
      ;; A zero factor was found.
      ;; Before returning zero, simplify any remaining factors.
      ;; x*0*y*log(0)*z should not be simplified to 0, but trigger an error.
      (dolist (factor x) (simplifya factor nil)))
    

    Then we get the desired error message.
    It doesn't break any tests from the test suite.
    I'll ask for opinions on the mailing list.

     

Log in to post a comment.