home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   sci.math.symbolic      Symbolic algebra discussion      10,432 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 9,117 of 10,432   
   Richard Fateman to Nasser M. Abbasi   
   Re: How should software compare complex    
   24 Jul 16 16:58:46   
   
   From: fateman@cs.berkeley.edu   
      
   On 7/24/2016 3:48 PM, Nasser M. Abbasi wrote:   
   > I tried this on Maple, Mathematica, MuPad (part of Matlab) and Matlab.   
   >   
   > Asked for maximum of I and 1.0, where I=sqrt(-1).   
   >   
   >   
   I suppose someone found a use for that comparison in Matlab.   
   Mathematically it is, as you realize, bogus, since the complex   
   numbers do not form an ordered field.   
      
   However,  consider this example.   
   You (perhaps unwittingly) are computing with a number   
   that is the sum of two nearly equal values but of opposite sign.   
     Z=X+Y is very close to zero but because of errors, Z might be positive   
   or negative. In your ignorance of the actual situation, you   
   believe that Z is either 0 or positive, and so you do not   
   hesitate to compute W= 1+sqrt(Z).  which you believe to be   
   a real number, close to 1.  Instead it is complex.  When you   
   compare W to some actual real number, what would you like to do?   
   Maybe what Matlab does, which is to treat W as approximately 1.   
      
   but then what if you compute W=-1+sqrt(Z), which you believe to   
   be a real number, close to -1. According to your note, Matlab   
   compares W as though it were approximately +1.   
      
   So what to do.   A symbolic system could do one of a number of   
   things.   
     1. Something more or less bogus like Matlab.   
     2. Give an error message   
   and stop computing (perhaps wait for a user to supply an answer?   
   perhaps berate the user in some way by appealing to the Algebra   
   course he/she never took?)   
     3. Leave the expression unevaluated as max(W,V).   
   (hoping that it might perhaps be multiplied by zero and not matter???)   
     4. Exercise some judgment of the form  "the imaginary part is down   
   in the roundoff, let's keep computing." One way to handle this   
   is to drop it, make a note of the occurrence and alert the user at the   
   end of the computation that a certain number of such transformations   
   were done.  E.g. plotting a mathematically real function f(x) which   
   numerically turns out to have some tiny imaginary parts.   
     5. Make it possible to do any of the choices above, or maybe   
   some others?   
      
   Maxima does 3  by default, but could be instructed to do any of   
   the other choices by modifying the simplification of max().   
      
   Mathematica gives a warning message, but then does 3.  You   
   can redefine Max in Mathematica if you first Unprotect it.   
      
   There are presumably contexts in which Matlab's choice is   
   just the right thing, and if you don't fit in that context,   
   you shouldn't use max().   
      
   RJF   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca