## #2449 cabs(expr) fails when expr is 0

None
closed
5
2013-01-07
2012-07-20
Raymond Toy
No

This came up on the mailing list discussion about rtest_trig failures on 2012-07-19. The issue is that commit 5ea6ff3 fixed an issue with polarform but introduces a new issue when the expression is zero, as determined by \$sign. Here is an example that causes it. It shows up with cmucl, but not other lisps. I assume with other lisps the expression doesn't evaluate to zero.

(%i1) expr: 0.983425555216359*%i/(0.839139579024831-1.171945144524351*%i) -.8680141428959249*%i +0.834650094344116/(0.839139579024831-1.171945144524351*%i)+.2176215618544027\$

(%i2) trace(sign)\$

(%i3) cabs(expr);

1 Enter ?sign
[0.983425555216359*%i/(0.839139579024831-1.171945144524351*%i)
-.8680141428959249*%i
+0.834650094344116/(0.839139579024831-1.171945144524351*%i)
+.2176215618544027]
1 Exit ?sign zero
(%o3) 0.983425555216359*%i/(0.839139579024831-1.171945144524351*%i)
-.8680141428959249*%i
+0.834650094344116/(0.839139579024831-1.171945144524351*%i)+.2176215618544027

(%i4) rectform(expr);
(%o4) 0.0

## Discussion

• Raymond Toy - 2012-08-02

Here's something more reproducible that doesn't depend on reading the floats to get precisely the correct values:

cabs(expand(subst(x = %i/2+1/2, cot(2*x) - (cot(x)^2-1)/(2*cot(x))))),numer;

Again, sign returns zero, but cabs doesn't return 0.0.

• Dan Gildea - 2013-01-07

Fixed in rpart.lisp.

• Dan Gildea - 2013-01-07
• status: open --> closed
• assigned_to: Dan Gildea
• milestone: --> None