Menu

#395 sign(sqrt(2)/2 - 1/sqrt(2)) => zero, pos, neg, or pnz

open
nobody
Lisp Core (456)
7
2006-07-10
2003-09-01
No

Depending on the values of fpprec and signbfloat,
sign(sqrt(2)/2 - 1/sqrt(2)) evaluates to zero, pos,
neg, or pnz.

(C1) display2d : false;

(D1) FALSE
(C2) a : sqrt(2)/2 - 1/sqrt(2);

(D2) SQRT(2)/2-1/SQRT(2)
(C3) for k : 20 thru 25 do (fpprec : k, print(k,sign(a)));

20 ZERO
21 POS
22 ZERO
23 POS
24 ZERO
25 NEG
(D3) DONE
(C4) sign(a), signbfloat : true;

(D4) NEG
(C5) sign(a), signbfloat : false;

(D5) PNZ

Here is another example -- this time sign(p) should
evaluate to pos.

(C7) p : exp(x) - sum(x^k/k!,k,0,15)$

(C8) p : subst(1/10000001,x,p)$

(C9) sign(p),signbfloat : true;

(D9) ZERO
(C10) sign(p),signbfloat : false;

(D10) PNZ
(C11) for k : 20 thru 25 do (fpprec : k, print(k,sign
(p)));

20 POS
21 NEG
22 NEG
23 ZERO
24 POS
25 ZERO
(D11) DONE
(C12)

Additionally, signbfloat isn't documented

(C17) describe("signbfloat");

(D17) FALSE

Barton

Discussion

  • Stavros Macrakis

    Logged In: YES
    user_id=588346

    About the specific case of sqrt(2)/2 - 1/sqrt(2), cf. bug
    721575 -- they should really simplify to a standard form and
    cancel. The general problem of using approximate arithmetic
    to check sign/is remains.

     
  • Robert Dodier

    Robert Dodier - 2006-07-10

    Logged In: YES
    user_id=501686

    The p : exp(x) - sum(x^k/k!,k,0,15)$ etc stuff is still
    present in 5.9.3cvs.

    Now sqrt(2)/2 - 1/sqrt(2) simplifies to 0, so that one has
    gone away.

    Incrementing the priority since sign problems are pervasive
    and important.

     
  • Robert Dodier

    Robert Dodier - 2006-07-10
    • labels: --> Lisp Core
    • priority: 5 --> 7
    • summary: sign(sqrt(2)/2 - 1/sqrt(2)) -> zero, pos, neg, or pnz --> sign(sqrt(2)/2 - 1/sqrt(2)) => zero, pos, neg, or pnz
     

Log in to post a comment.