       odd behaviour in 2.2

• To: mathgroup at yoda.physics.unc.edu
• Subject: odd behaviour in 2.2
• From: wmm at chem.wayne.edu (Martin McClain)
• Date: Thu, 2 Sep 93 18:55:05 EDT

```Here is some new behaviour in 2.2 that seems like it needs professional
attention:

In:=
\$Version

Out=
Macintosh 2.2 (May 4, 1993)

In:=
Remove[nameRule,aName,mat,matSq] (*everything*)

Suppose there is a matrix you want to recognize by name:

In:=
nameRule=Sin^2 {{1,0},{0,1}}->aName

Out=
2                2
{{Sin , 0}, {0, Sin }} -> aName

Now generate the same matrix in a slightly different way:

In:=
mat = {{1,0},
{0,1}}//Sin;
matSq = mat.mat

Out=
2                2
{{Sin , 0}, {0, Sin }}

and test it to see if it is the named matrix:

In:=
matSq/.nameRule

Out=
2                2
{{Sin , 0}, {0, Sin }}

The nameRule did not work in 2.2, though this same script works well in
2.1, giving output "aName".
However, the nameRule can be made to work in 2.2 if you Expand:

In:=
Expand[matSq]/.nameRule

Out=
aName

Why did it work this time?  What is the difference?

In:=
matSq == Expand[matSq]

Out=
True

In:=
FullForm[matSq]

Out//FullForm=
List[List[Power[Sin, 2], 0], List[0, Power[Sin, 2]]]

In:=
FullForm[Expand[matSq]]

Out//FullForm=
List[List[Power[Sin, 2], 0], List[0, Power[Sin, 2]]]

They seem truly identical.  However, the pattern matcher uses SameQ, or ===
(the Bible, 2nd ed., p. 289). So try it:

In:=
matSq === Expand[matSq]

Out=
False

How come two things that look identical in FullForm come up False in SameQ,
and therefore in the pattern matcher?  They used to match in 2.1...

```

• Prev by Date: ToolTool
• Next by Date: Schur 5.1 Released