#2528 imagpart/carg/parg/... wrong when var is declared both real and complex

None
closed
nobody
None
5
2013-02-09
2013-01-02
No

declare(rrcc,real)$ declare(rrcc,complex)$
imagpart(rrcc) => imagpart(rrcc) <<< should be 0
carg(rrcc^2+1) => atan2(...) <<< should be rrcc^2+1

In other words, when something is declared both real and complex, it presumably should be treated as real (the intersection of the reals and the complexes). But it is not.

What is less clear is whether featurep(rrcc,complex) should be true (which it curently is).

Discussion

  • Rupert Swarbrick

    How about the attached for an "obvious" fix?

    Re the featurep question, I think it should be true, but the way we declare symbols real or complex in Maxima is just a bit weird: x is considered real if featurep(x, real) (inclusive) or if not(featurep(x, complex)). Or at least that's my mental model. domain:complex and the like seem like workarounds that ignore the fact that most of Maxima assumes a symbol it hasn't seen before is real.

    Testsuite runs fine. I've tried to follow the seemingly standard "o ..." notation in the commit message.

     
  • Rupert Swarbrick

    I've committed the patch posted here, and now:

    (%i1) declare(rrcc,real)$ declare(rrcc,complex)$
    
    (%i3) [imagpart(rrcc), carg(rrcc^2+1)];
    (%o3)                               [0, 0]
    

    Thinking again about the rest of the bug, I think that featurep (rrcc,
    complex) should probably return false: after all, the flag is used to
    tell Maxima that it shouldn't assume that rrcc is real. But it is!

    Anyway, that should probably be discussed on the mailing list, so I'll
    make a post there in a minute. As the code currently stands,

    (%i4) featurep(rrcc, complex);
    (%o4)                                true
    
     
  • Rupert Swarbrick

    Mailing list question posted. For anyone coming upon this bug in the future, the post should hopefully be archived at http://thread.gmane.org/gmane.comp.mathematics.maxima.general/41081.

     
    • Rupert Swarbrick

      I guess I agree with the responses from Stavros and Robert at the thread above. Since there's nothing left of this bug, I'm closing it.

       
  • Rupert Swarbrick

    • status: open --> closed
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks