From: Bill Rowe on
On 1/6/10 at 5:59 AM, fateman(a)cs.berkeley.edu (Richard Fateman)
wrote:

>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.

The argument isn't that Mathematica does the "right" thing.
"Right" is quite subjective here. The result Mathematic does
return for this example is clearly mathematically correct even
if it is not the desired result.

The real choice is either

(1) understand how Mathematica is designed and make use of that
to get the result you want or

(2) find another software package that works more like what you want.

Arguing Mathematic does either the "wrong thing" or the "right
thing" here is pointless.

>To me, the question is simply, by what programming technique
>can we make Mathematica do the truly expected thing. In this
>case, and I
>believe in every other case, a transformation of the rules will
>help. In particular, using the rule
>x-> -I Log[s] instead of Exp[x I] -> s.

>Is it possible that Mathematica could make this change? How could
>it possibly make such a transformation? (hint. Solve for variable s)

=46or me, I never want Mathematica designed in a way where it
tries to guess or otherwise divine my intention and do something
other than what I specifically told it to do via my input. I
totally detest any software that does that. Which is one of the
main reasons a greatly dislike Microsoft Word.

>For another example, x/5 /. 1/5->Fifth results in Fifth x but
>3/5 /. 1/5 -> Fifth is unchanged.

>Is it possible that Mathematica could do this consistently?

What is inconsistent here?

Mathematica internally evaluates 1/5 as Rational[1,5], x/5 as
Times[x, Rational[1,5]] and 3/5 as Rational[3,5]. In every case
Rational[1,5] is being replaced with Fifth. Mathematica behaves
in a consistent manner even though this is clearly not
immediately apparent to a new user.

Again, the choice is either understand this behavior and live
with it or find different software. There isn't any other
productive choice.

Any software package that comes close to approximating the
capability Mathematica offers has to make some set of design
decisions. It simply is not possible to make those decisions in
a manner that will please all potential users or not cause some
level of confusion to a new user. This level of capability will
always require significant learning on the part of any user to master.

So, the real choice is learn and understand the way Mathematica
works and live with it or find another software package more to
your likely. There is no other productive choice.


From: Noqsi on
On Jan 6, 3:59 am, Richard Fateman <fate...(a)cs.berkeley.edu> wrote:

>
> For example, Exp[I x] -Exp[- I x] /. Exp[I x] -> s should p=
robably
> result in s-1/s.
> In Mathematica, one gets s-E^(-Ix).

You're confusing two different kinds of "substitution". It is
extremely important to preserve the distinction.

>
> 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.

Or blame those who don't understand critical distinctions and want to
erase them.

>
> To me, the question is simply, by what programming technique can we make
> Mathematica do the truly expected thing.

Well, in this case it does what anybody who understands how Replace
works and what it's good for expects. If that's not the "truly
expected thing", I don't know what is.

> In this case, and I believe in every other case, a transformation of the
> rules will help. In particular, using the rule
> x-> -I Log[s] instead of Exp[x I] -> s.

Mathematica has a tool that can do what you want here:

Reduce[a == Exp[I x] - Exp[-I x] && Exp[I x] == s, {a}, {x}]
s != 0 && a == (-1 + s^2)/s

It's a bit fussier than perhaps you'd like, but that's mathematics for
you ;-)


From: Vince Virgilio on
On Jan 6, 5:59 am, Richard Fateman <fate...(a)cs.berkeley.edu> wrote:

SNIP

>
> What I would say is
>
> Because of the disparity in internal representations (see below) ,
> for replacements on parts of complex expressions, don't use /. ...
> use /. BetterRules[ ...]
>

This expects too much from ReplaceAll.

> or use transformation or selection programs such as Conjugate, Im, Re, .. .
>

Yes. Not unlike something Andrzej said elsewhere about
PolynomialReduce (others said similar as well).

SNIP

Vince Virgilio

(
Incidentally, my FullForm of x+4*I differs from yours, if I read yours
correctly:

In[1]:= x+4I//FullForm
Out[1]//FullForm= Plus[Complex[0,4],x]
)

From: David Bailey on
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

From: Richard Fateman on
Noqsi wrote:

>
> Mathematica has a tool that can do what you want here:
>
> Reduce[a == Exp[I x] - Exp[-I x] && Exp[I x] == s, {a}, {x}]
> s != 0 && a == (-1 + s^2)/s
>
> It's a bit fussier than perhaps you'd like, but that's mathematics for
> you ;-)
>
Reduce is a really neat program in Mathematica, one that I especially
admire since it was improved to work on more than polynomials.
Unfortunately, it won't work for I->-I, maybe because that is based on a
decision involving constants represented differently from expressions
that construct them. (David Bailey already pointed this out. Do people
get instantaneous unfiltered feed from this newsgroup??)

but also..
Bill Rowe said ...
"Again, the choice is either understand this behavior and live
with it or find different software. There isn't any other
productive choice."

Well, reporting something as a bug and hoping it will be fixed is
another choice.
And writing a version of the facility that does the right thing is
another choice. (Any takers?)

Either of these could be "productive".

Are Mathematica design decisions sacred or something?

RJF

First  |  Prev  |  Next  |  Last
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Prev: Persistent assumption
Next: Financial Data - Currencies