This is a follow-up question to this question.
I generated a list by substituting the results of a solve[] routine and set:
sln=expression /.Solve[...];
list= SetAccuracy[N[sln],2]]
You can find the FullForm[list] further down. I was trying to parition this list into sublists with equal norms.
If you evaluate Map[Norm, list] you get {0, 1.6, 0.6, 0.6, 1.6, 1.6, 0.6, 0.6, 1.6, 0.6, 1.6} There are three sets of values for the norms.
I tried
GatherBy[SortBy[list, Norm], Norm]
and
SplitBy[SortBy[list, Norm], Norm]
And they give me different results. However, if my list2 was a list of numbers inputted by hands without any explicit accuracy, the two expressions yield equal results.
- What is different about
SplitBy[]andGatherby[]that causes this? - How do accuracy and precision interplay in numerical results?
For reproduciblity purposes, I am quoting FullForm version of list variable that I performed the tests with:
FullForm[list]= \!\(
TagBox[
StyleBox[
RowBox[{"List", "[",
RowBox[{
RowBox[{"List", "[",
RowBox[{"0``2.", ",", "0``2."}], "]"}], ",",
RowBox[{"List", "[",
RowBox[{"0.5`1.6989700043360187", ",",
"0.86602540378443859658830206171842291951`1.93753063169585"}],
"]"}], ",",
RowBox[{"List", "[",
RowBox[{"0.5`1.6989700043360187", ",",
RowBox[{"-",
"0.86602540378443859658830206171842291951`1.93753063169585"}]\
}], "]"}], ",",
RowBox[{"List", "[",
RowBox[{
RowBox[{"-", "1.`2."}], ",", "0``2."}], "]"}]}], "]"}],
ShowSpecialCharacters->False,
ShowStringCharacters->True,
NumberMarks->True],
FullForm]\)
and
GatherBy[SortBy[a, Norm], Norm] == SplitBy[SortBy[a, Norm], Norm]
returns False.
list = SetAccuracy[{1, 1, 1.01, 1.01, 1.02, 1.02}, 2]why doesGather[list]give a different result fromSplit[list]– Simon Woods Feb 14 '16 at 13:45