({{, (RefLink[SameTest, paclet:ref/SameTest]) 
is an option whose setting gives a pairwise comparison function to determine whether expressions should be considered the same.}})

OpenersNotesSection(Spacer1)Details

(RefLink[SameTest, paclet:ref/SameTest])->f specifies that f[(Subscript[e, 1]),(Subscript[e, 2])] should be evaluated whenever it is necessary to determine whether pairs of expressions (Subscript[e, 1]), (Subscript[e, 2]) should be considered the same.

OpenersPrimaryExamplesSection(Spacer1)Examples  (7)

OpenersExampleSection0(Spacer1)Basic Examples  (2)

Union of a set of integers:

Union[{0,3,2,4,2,0,2,-5,2,0}]

Union considering comparison modulo 3:

Union[{0,3,2,4,2,0,2,-5,2,0},SameTest->(Mod[#1,3]==Mod[#2,3]&)]

Find a fixed point to a tolerance:

FixedPointList[#/2+1/#&,1.,SameTest->(Abs[#1-#2]<10^-4&)]

OpenersExampleSection1(Spacer1)Scope  (5)

Union of a set of machine-precision numbers:

Union[{0.,(10.^(-13)),2.,2.-(10^(-13)),2.+3 (10^(-15)),(10.^(-14))}]

Union treating roundoff errors of order (10^(-12)) as zeros:

Union[{0.,(10.^(-13)),2.,2.-(10^(-13)),2.+3 (10^(-15)),(10.^(-14))},SameTest->(Abs[#1-#2]≤(10^(-12))&)]

Alternately, use (RefLink[Chop, paclet:ref/Chop]):

Union[{0.,(10.^(-13)),2.,2.-(10^(-13)),2.+3 (10^(-15)),(10.^(-14))},SameTest->(Chop[#1-#2,(10^(-12))]==0&)]

Intersection of two sets of integers:

Intersection[{0,3,5,2},{0,2,5}]

Intersection considering comparison modulo 3:

Intersection[{0,3,5,2},{0,2,5},SameTest->(Mod[#1-#2,3]==0&)]

This matrix is antihermitian for a positive real x, but (RefLink[AntihermitianMatrixQ, paclet:ref/AntihermitianMatrixQ]) gives (RefLink[False, paclet:ref/False]):

m={{I,Exp[Log[I x]]},{I x,2I}};

AntihermitianMatrixQ[m]

Use the option (RefLink[SameTest, paclet:ref/SameTest]):

AntihermitianMatrixQ[m,SameTest->(Simplify[#1-#2,x>0]==0&)]

This matrix is symmetric for a positive real x, but (RefLink[SymmetricMatrixQ, paclet:ref/SymmetricMatrixQ]) gives (RefLink[False, paclet:ref/False]):

m={{1,Log[x^2]},{2 Log[x],2}};

SymmetricMatrixQ[m]

Use the option (RefLink[SameTest, paclet:ref/SameTest]):

SymmetricMatrixQ[m,SameTest->(Simplify[#1-#2,x>0]==0&)]

This matrix is unitary for a positive real x, but (RefLink[UnitaryMatrixQ, paclet:ref/UnitaryMatrixQ]) gives (RefLink[False, paclet:ref/False]):

m={{1,Exp[x I]},{Cos[x]-I Sin[x],-1}}/(Sqrt[2]);

UnitaryMatrixQ[m]

Use the option (RefLink[SameTest, paclet:ref/SameTest]):

UnitaryMatrixQ[m,SameTest->(Simplify[#1-#2,x>0]==0&)]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[SameQ, paclet:ref/SameQ])  ▪  (RefLink[FixedPoint, paclet:ref/FixedPoint])  ▪  (RefLink[Union, paclet:ref/Union])  ▪  (RefLink[Intersection, paclet:ref/Intersection])  ▪  (RefLink[AntisymmetricMatrixQ, paclet:ref/AntisymmetricMatrixQ])  ▪  (RefLink[AntihermitianMatrixQ, paclet:ref/AntihermitianMatrixQ])  ▪  (RefLink[Complement, paclet:ref/Complement])  ▪  (RefLink[HermitianMatrixQ, paclet:ref/HermitianMatrixQ])  ▪  (RefLink[NormalMatrixQ, paclet:ref/NormalMatrixQ])  ▪  (RefLink[OrthogonalMatrixQ, paclet:ref/OrthogonalMatrixQ])  ▪  (RefLink[SymmetricMatrixQ, paclet:ref/SymmetricMatrixQ])  ▪  (RefLink[UnitaryMatrixQ, paclet:ref/UnitaryMatrixQ])  ▪  (RefLink[ZeroTest, paclet:ref/ZeroTest])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Systematic Testing & Verification, paclet:guide/SystematicTestingAndVerification])}, {▪(RefLinkPlain[Matrix Predicates, paclet:guide/MatrixPredicates])}})}})