Re: Re: Replace and ReplaceAll -- simple application
- To: mathgroup at smc.vnet.net
- Subject: [mg106016] Re: [mg105982] Re: Replace and ReplaceAll -- simple application
- From: DrMajorBob <btreat1 at austin.rr.com>
- Date: Wed, 30 Dec 2009 04:15:13 -0500 (EST)
- References: <200912270006.TAA12080@smc.vnet.net> <hh72dp$kud$1@smc.vnet.net>
- Reply-to: drmajorbob at yahoo.com
I fully agree. We should be told that -I is an atom, hence it does NOT contain I as a part. a - I is NOT an atom, since we get a match in Cases[a - I, -I, {0, Infinity}] {-I} AtomQ[a - I] False yet 1 - I _is_ an atom, so Cases[1 - I, -I, {0, Infinity}] {} AtomQ[1 - I] True I don't know that this ever hinders me in practice, but the rationale escapes me. Bobby On Tue, 29 Dec 2009 00:18:40 -0600, AES <siegman at stanford.edu> wrote: > 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. ) > -- DrMajorBob at yahoo.com
- References:
- Replace and ReplaceAll -- simple application
- From: amannuc1 <Anthony.J.Mannucci@jpl.nasa.gov>
- Replace and ReplaceAll -- simple application