rtoy / maxima

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

ldefint returns zero #2696

Open rtoy opened 3 weeks ago

rtoy commented 3 weeks ago

Imported from SourceForge on 2024-07-06 18:10:02 Created by willisbl on 2024-03-17 15:24:54 Original: https://sourceforge.net/p/maxima/bugs/4275


Rubbish:

(%i3)   ldefint(floor(x)*exp(x),x,2,3);
(%o3)   0

I think that the problem is that ldefint needs to check when sinint returns an integration nounform.

rtoy commented 3 weeks ago

Imported from SourceForge on 2024-07-06 18:10:03 Created by willisbl on 2024-03-17 17:44:41 Original: https://sourceforge.net/p/maxima/bugs/4275/#f8f4


Here is a proposed fix:

(defmfun $ldefint (exp var ll ul)
  (let (($logabs t) (ans (sinint exp var)) (a1) (a2))
    (cond ((among '%integrate ans)
             (ftake '%integrate exp var ll ul))
          (t 
            (setq a1 (toplevel-$limit ans var ul '$minus))
            (setq a2 (toplevel-$limit ans var ll '$plus))
            (when (member a1 '($inf $minf $infinity $und $ind) :test #'eq)
                (setq a1 (nounlimit ans var ul)))
             (when (member arg2 '($inf $minf $infinity $und $ind) :test #'eq)
                (setq a2 (nounlimit ans var ul)))
            ($expand (sub a1 a2))))))

With this code, I get

(%i9)   ldefint(floor(x)*exp(x),x,2,3);
(%o9)   integrate(%e^x*floor(x),x,2,3)

The ldefinit code assumes that the value returned by sinint is continuous. I think that's not always the case.

rtoy commented 3 weeks ago

Imported from SourceForge on 2024-07-06 18:10:07 Created by robert_dodier on 2024-03-17 17:54:15 Original: https://sourceforge.net/p/maxima/bugs/4275/#08ec


I dunno, it seems like the bug is in limit itself; it's return just the integrate noun instead of limit(integrate(...), ...). More about that in https://sourceforge.net/p/maxima/bugs/4273/.

I think fixing 4273 might also fix this one -- it might not, but anyway I think we should postpone changes to ldefint pending resolution of 4273.

rtoy commented 3 weeks ago

Imported from SourceForge on 2024-07-06 18:10:10 Created by willisbl on 2024-03-17 20:45:02 Original: https://sourceforge.net/p/maxima/bugs/4275/#ae24


Oh, I see, almost surely they are the same bugs.

But look at this--I think the limit variable is wrong. In this case the limit variable should be $x, but it's :g4915.

    ldefint(exp(x) * floor(x),x,5,9);
0> Calling (LIMIT ((%INTEGRATE SIMP) ((MTIMES SIMP) ((MEXPT SIMP) $%E $X) (($FLOOR SIMP) $X)) $X) #:G4915 $ZEROB THINK) 

< LIMIT returned ((%INTEGRATE SIMP) ((MTIMES SIMP) ((MEXPT SIMP) $%E $X) (($FLOOR SIMP) $X)) $X)

0> Calling (LIMIT ((%INTEGRATE SIMP) ((MTIMES SIMP) ((MEXPT SIMP) $%E $X) (($FLOOR SIMP) $X)) $X) #:G4942 $ZEROA THINK) 

< LIMIT returned ((%INTEGRATE SIMP) ((MTIMES SIMP) ((MEXPT SIMP) $%E $X) (($FLOOR SIMP) $X)) $X)    0