|
From: Raymond T. <toy...@gm...> - 2025-11-12 14:59:23
|
On 11/9/25 7:37 AM, Raymond Toy wrote: > On 11/9/25 4:52 AM, Barton Willis wrote: > >> * >> Is this with the very latest version? I modified the simplifier >> for cabs just a day or two ago. >> >> >> Yes, I did this with a current build—one that uses >> |def-simplifier| for |cabs: | >> >> (%i2) 'cabs(x*y); >> >> 0> Calling (SIMP-%CABS ((%CABS) ((MTIMES SIMP) $X $Y)) 1 NIL) >> <0 SIMP-%CABS returned ((MABS SIMP) ((MTIMES SIMP) $X $Y)) >> (%o2) abs(x y) >> >> Maxima 5.47 also has this bug. > > Here is an updated cabs simplifier. This passes the testsuite and > fixes the above error. I'm not convinced this is the right thing to > do, though. I think for this to work, you also have to comment out the > defmfun $cabs. > I cleaned the simplifier up a bit and think I'll commit the change. It doesn't cause any regressions in the test suite and does fix the bug above. I'm still not sure it's the right thing, but it does make it consistent with just about all the other simplifiers, so that's a win. > |(def-simplifier cabs (z) (flet (($cabs (xx) (cabs xx))) (let ((sgn > nil)) (cond ((member (setq sgn ($csign z)) '($complex $imaginary)) > (cond ((complex-number-p ($expand z) 'bigfloat-or-number-p) ($cabs z)) > (t ($cabs z)))) ((eq sgn '$zero) 0) ((member sgn '($pos $pz)) z) ((eq > sgn '$neg) (mul -1 z)) (t ($cabs z)))))) | > > This could use a bit of cleanup as well. > > ​ ​ |