From: Murray Eisenberg on
OK, so what, in an earlier post today, I suggested needed to be said in
the docs is said there, although not in quite so direct a form ("What
you see is not what is acted upon", as stated by Alexander Elkins).

The issue, it seems, is how and when one finds such principles in the
docs. Presumably the Virtual Book that's part of the Documentation
Center would readily lead one to that tutorial. And it's there, to be
sure -- but not so easy to find:

Core Language > Patterns > Patterns for some Common Types of Expressions

Part of the difficulty in finding such things in the Documentation
Center may be the granularity of the documentation (as contrasted with
the now-defunct, printed "The Mathematica Book" -- if I may be permitted
to beat a dead horse).

Norbert P. wrote:
>
> ... as you can read in tutorial/
> PatternsForSomeCommonTypesOfExpression:
> "Especially for some common kinds of expressions, the standard
> output format used by Mathematica is not particularly close to the
> full internal form. But it is the internal form that you must use in
> setting up patterns. "

--
Murray Eisenberg murray(a)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

From: Richard Fateman on
Leonid Shifrin wrote:
....

>
> I think that there are not many more objects in Mathematica which are as
> tricky as <I> or Infinity in terms of pattern-matching.


I agree.
That's why it can be fixed.

Here's a beginning of a short list for the "we're not just talking
syntactic replacement-- version of substitution":

If the user says -i --> i, then do Complex[a_,-b_] -> Complex[a,b].
If the user says x^2 --> y, then do x^(-2)-> 1/y also.

I assume this list can be enlarged somewhat, and could even be left
open-ended by user option of some sort. [e.g. should x^2--> y also
change x^3 to x*y? or to y^(3/2) or ....]

.....

> It would perhaps be nice if such
> cases were more systematically documented, but they have nothing to do with
> bugs,

You are right if you mean "bug in Mathematica implementation of
intended design" (this is not such a bug).

But there is another concept:
"bug in Mathematica design, contrary to reasonable mathematical expectation"
(this IS such a bug).

From: Noqsi on
On Jan 1, 3:39 am, Richard Fateman <fate...(a)cs.berkeley.edu> wrote:
> Leonid Shifrin wrote:
>
> ...
>
>
>
> > I think that there are not many more objects in Mathematica which are a=
s
> > tricky as <I> or Infinity in terms of pattern-matching.
>
> I agree.
> That's why it can be fixed.
>
> Here's a beginning of a short list for the "we're not just talking
> syntactic replacement-- version of substitution":
>
> If the user says -i --> i, then do Complex[a_,-b_] -> Complex[=
a,b].
> If the user says x^2 --> y, then do x^(-2)-> 1/y also.
>
> I assume this list can be enlarged somewhat, and could even be left
> open-ended by user option of some sort. [e.g. should x^2--> y also
> change x^3 to x*y? or to y^(3/2) or ....]

No! The language should not attempt to outsmart the user. What you're
proposing would be the nastiest sort of bug, changing simple,
predictable behavior into something that would play out in
incomprehensible ways. Syntactic replacement is very, very useful and
should not be polluted by attempts to read the user's mind.

The principle here has always been "You want to see what a rule will
really do? Look at FullForm." Perhaps the documentation should
highlight this better, but this behavior is NOT A BUG.

From: Leonid Shifrin on
Regarding this issue, I think I entirely agree with what David Bailey and
other people said: I don't consider replacement rules as a mathematical tool
for end users, but rather as an inner layer of Mathematica, which is also
exposed for flexibility / convenience and intended primarily to be used by
the more advanced users. In this way, they can implement some missing
functionality themselves at their own risk without the need to wait for a
new Mathematica release. It is stated in the documentation that rule
substitution is purely syntax-based, and therefore not guaranteed to always
make sense.

I don't see how this by itself makes the design inconsistent: either you are
the end-user without advanced Mathematica skills and then you have to stick
to the built-in commands like Conjugate designed specifically to deal with
the problem (complex conjugation here), or you use the lower-level tools
like replacement rules but then you are on your own - the system will
blindly do the replacements according to the syntax of your rules, and it is
then your responsibility to use them correctly. What I would agree with is
that the documentation could have made this borderline more clear-cut. But I
don't think that this is a problem on the level of design.

Regards,
Leonid



On Fri, Jan 1, 2010 at 2:39 AM, Richard Fateman <fateman(a)cs.berkeley.edu>wrote:

> Leonid Shifrin wrote:
> ...
>
> >
> > I think that there are not many more objects in Mathematica which are as
> > tricky as <I> or Infinity in terms of pattern-matching.
>
>
> I agree.
> That's why it can be fixed.
>
> Here's a beginning of a short list for the "we're not just talking
> syntactic replacement-- version of substitution":
>
> If the user says -i --> i, then do Complex[a_,-b_] -> Complex[a,b].
> If the user says x^2 --> y, then do x^(-2)-> 1/y also.
>
> I assume this list can be enlarged somewhat, and could even be left
> open-ended by user option of some sort. [e.g. should x^2--> y also
> change x^3 to x*y? or to y^(3/2) or ....]
>
> ....
>
> > It would perhaps be nice if such
> > cases were more systematically documented, but they have nothing to do
> with
> > bugs,
>
> You are right if you mean "bug in Mathematica implementation of
> intended design" (this is not such a bug).
>
> But there is another concept:
> "bug in Mathematica design, contrary to reasonable mathematical
> expectation"
> (this IS such a bug).
>
>

From: Andrzej Kozlowski on

On 31 Dec 2009, at 17:18, Leonid Shifrin wrote:

> I think that there are not many more objects in Mathematica which are as
> tricky as <I> or Infinity in terms of pattern-matching.

Another obvious case that can be included is Rational, e.g.

Head[2/3]

Rational

Head[Unevaluated[2/3]]

Times

Head[a/b]

Times

AtomQ[2/3]

True

AtomQ[a/b]

False

Rational works essentially the same way as Complex.

It's perfectly consistent, fully justified, and certainly will never be changed.

Andrzej Kozlowski



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