Re: More /.{I->-1} craziness
- To: mathgroup at smc.vnet.net
- Subject: [mg106300] Re: More /.{I->-1} craziness
- From: David Bailey <dave at removedbailey.co.uk>
- Date: Thu, 7 Jan 2010 02:34:34 -0500 (EST)
- References: <200912300915.EAA17299@smc.vnet.net> <hhhmn8$o9t$1@smc.vnet.net> <hhkjc4$5ag$1@smc.vnet.net> <hhpl4j$9mf$1@smc.vnet.net> <421988.1262677154744.JavaMail.root@n11> <005001ca8e15$766e7bd0$634b7370$@net> <hi1qeg$enm$1@smc.vnet.net>
Richard Fateman wrote:
> I think it is interesting that the same issue came up in the design of
> another computer algebra system, years ago.
> That is, which objects are "atomic" and which are decomposable for
> purposes of substitution. And further,
> of those which are decomposable, how much cleverness should be applied
> during substitution
>
> For example, Exp[I x] -Exp[- I x] /. Exp[I x] -> s should probably
> result in s-1/s.
> In Mathematica, one gets s-E^(-Ix).
>
> can either
> (1) Make this come out s-1/s
> or
> (2) Argue that Mathematica already does the right thing, blame the user,
> blame the documentation, blame the nature of mathematics, claim that it
> is impossible to "read the user's mind" etc.
>
> To me, the question is simply, by what programming technique can we make
> Mathematica do the truly expected thing.
Notice that using the transformation rule Exp[I x] -> s (or f[x]->s in
general) in the way you require, involves inverting it to produce
x->g[s] for some g. In general g may not be unique, which is why the
following code generates a warning, but essentially does what you want
to do:
Solve[Eliminate[{ans == Exp[I x] - Exp[-I x], Exp[I x] == s}, {x}], ans]
Reduce (rather than Eliminate) yields a more mathematically precise
answer, but the result is considerably more clumsy.
Note also that ReplaceAll *can* be used to do mathematical operations
without complications provided the LHS of each rule is a variable (but
not a constant such as I, Pi, etc).
David Bailey
http://www.dbaileyconsultancy.co.uk