MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Replace and ReplaceAll -- simple application

  • To: mathgroup at smc.vnet.net
  • Subject: [mg105982] Re: Replace and ReplaceAll -- simple application
  • From: AES <siegman at stanford.edu>
  • Date: Tue, 29 Dec 2009 01:18:40 -0500 (EST)
  • Organization: Stanford University
  • References: <200912270006.TAA12080@smc.vnet.net> <hh72dp$kud$1@smc.vnet.net> <hh9vfo$1rk$1@smc.vnet.net>

In article <hh9vfo$1rk$1 at smc.vnet.net>,
 Richard Fateman <fateman at cs.berkeley.edu> wrote:

> Scot T. Martin wrote:
> > The problem is that "-1." is not "1".
 
> And furthermore, this bug has been declared a feature. And defended, 
> repeatedly.   Just as I does not occur in -I.
> It can be fixed, should be fixed, and has been fixed in other CAS.


I'll defer to Richard Fateman (and/or other computer algebra experts) as 
to whether this general behavior (!! especially with respect to -I  !!) 
is a bug that should be fixed, or a feature.

But if it's gonna be considered a feature in Mathematica, I'd strongly 
suggest that it should be strongly **featured** ­­ or, if you like, it 
should be warned about!! ­­ in the Mathematica documentation, especially 
at the more elementary levels of documentation, **so that ordinary users 
can't miss being warned about this unexpected behavior**  ^HH^H^H^H 
sorry, so that they can't miss being warned about "this feature".

For example, right after the first line of the Help for I, which says

      I  represents the imaginary unit Sqrt[-1]. 

there might be a warning line which says

      WARNING:  I is a number and not a symbol.  Attempting to replace
      or reverse the sign of I using a rule, such as  expr/.{I->-I) may 
      produce unexpected results if the expr contains -I.

(By the way, note the wording above:  "I represents", not "I is".)

There are a very large number of other places in the Mathematica 
documentation where emphasized WARNINGs like this would be helpful.

(I suppose there could even be optional warning messages that appear any 
time a cell executes a rule containing a number on the LHS of a 
ReplaceAll symbol.  And, the documentation for ReplaceAll could have an 
initial WARNING message that it is not just the kind of Global Search 
and Replace command that many ordinary users, familiar with many other 
word processing and software apps, might well think it is. )


  • Prev by Date: Re: Best way to do contractions (arbitrary Tables with a Sum)?
  • Next by Date: Re: Re[] function
  • Previous by thread: Re: Replace and ReplaceAll -- simple application
  • Next by thread: Re: Re: Replace and ReplaceAll -- simple application