Re: Re: Replace and ReplaceAll -- simple application
- To: mathgroup at smc.vnet.net
- Subject: [mg106083] Re: [mg106038] Re: Replace and ReplaceAll -- simple application
- From: Murray Eisenberg <murray at math.umass.edu>
- Date: Fri, 1 Jan 2010 05:33:31 -0500 (EST)
- Organization: Mathematics & Statistics, Univ. of Mass./Amherst
- References: <200912270006.TAA12080@smc.vnet.net> <hh72dp$kud$1@smc.vnet.net> <hh9vfo$1rk$1@smc.vnet.net> <200912290618.BAA02632@smc.vnet.net> <hhf5kg$go6$1@smc.vnet.net> <200912310814.DAA24681@smc.vnet.net>
- Reply-to: murray at math.umass.edu
That's an instructive example on the point being discussed. As you note,
R + I w L /. I -> -I
works "as expected". But so does:
I /. I -> -I
What does NOT work is either of:
R - I w L /. I -> -I
-I /. I -> -I
Each pair of results is consistent within itself, whereas the second
pair seems on first exposure to be inconsistent with the first pair.
Evidently a case of unwarranted generalization by the "naive" user,
worthy of further digging: how does ReplaceAll really work? (I say
"naive" here without intending any negative connotation!)
In my experience, eventually the same sort of dissonance will arise with
any system where one is using only heuristics to accomplish tasks rather
than the actual parsing/evaluation rules of the language. Not a moment
for grief or cause for complaint about inconsistencies, but rather an
opportunity for learning more.
Language designers might claim, "Well, that's just the way it is." But
that's really an inadequate response. Yes, one does eventually just
have to learn and accept the underlying principles and rules. Still,
there are interesting cognitive and pedagogical issues here (but NOT
issues of flawed language design).
But enough of "an I for an I" for today: time to celebrate the approach
of New Year!
P.S. I'm not sure what MathWorld is supposed to do with this: MathWorld
is about mathematics, not Mathematica; it just happens to have some
Mathematica code available. I would not at all expect MathWorld to
instruct me on using Mathematica.
AES wrote:
> In article <hhf5kg$go6$1 at smc.vnet.net>,
> Murray Eisenberg <murray at math.umass.edu> wrote:
>
> [Re the I -> -I problem in particular:]
>
> ... it's very tempting to note that these
> tFunc's contain nothing but purely real circuit elements (R's. L's and
> C's, or masses and spring constants, or whatever), and I.
>
> And a quick test confirms that the rule {a->-a} does what it's supposed
> to (whether or not a has a minus sign in front of it). Or, a quick test
> confirms that I->-I properly converts R + I w L into R - I w L. Why
> shouldn't it??? It just does what you'd expect a global find and
> replace to do, or what you'd do "by hand" -- right?
>
> Take a look at the Mathworld entries for "phasor" and "transfer
> function" and see how far down you'd have to dig to get an explicit
> warning that the previous paragraph is misleading. (And note that the
> entry for "Phasor" does not contain a "SEE ALSO:" for the term "Complex
> Conjugation", and the link to that term within the text does not -- so
> far as I can see -- give any hint the the rule I->-I will fail for an
> expression containing -I.)
--
Murray Eisenberg murray at math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower phone 413 549-1020 (H)
University of Massachusetts 413 545-2859 (W)
710 North Pleasant Street fax 413 545-1801
Amherst, MA 01003-9305