2
$\begingroup$

hello!

I know that all my questions are about the same list of rules, but I'm still trying to understand the Wolfram Language logic... So, given the list of rules:

intermediateResult1 = {Subscript[Abx, 3, 5] -> 
   336.4317195415496826172`4.526896935319825, 
  Subscript[Abx, 4, 5] -> 358.7006528377532958984`4.554732167095748, 
  Subscript[Abx, 5, 5] -> 378.44673919677734375`4.578004767586344, 
  Subscript[Abx, 6, 5] -> 395.4161212444305419922`4.597054371666505, 
  Subscript[Aby, 1, 5] -> 36.781777392763615353`3.5656327116671127, 
  Subscript[Aby, 2, 5] -> 33.1913761270843679085`3.521025258796362, 
  Subscript[Aby, 3, 5] -> 32.4560489654541015625`3.5112956499036425, 
  Subscript[Aby, 4, 5] -> 33.5718250274658203125`3.5259749509535157, 
  Subscript[Aby, 5, 5] -> 35.5354518890380859375`3.5506618425494563, 
  Subscript[Aby, 6, 5] -> 37.34320068359375`3.57221153856355, 
  Subscript[Abx, 2, 1] -> 329.5073566436767578125`4.517865115179159, 
  Subscript[Abx, 2, 2] -> 327.6947731971740722656`4.51546951434628, 
  Subscript[Abx, 2, 3] -> 323.5337643623352050781`4.50991961085035, 
  Subscript[Abx, 2, 4] -> 317.9532122611999511719`4.502363216991488, 
  Subscript[Abx, 2, 6] -> 306.2719948891899548471`4.486107287302384, 
  Subscript[Aby, 2, 1] -> -45.9602017402648925781`3.662381926336777, 
  Subscript[Aby, 2, 2] -> -34.1088933944702148438`3.532867629683822, 
  Subscript[Aby, 2, 3] -> -12.6594895720481872559`3.1024161953723484, 
  Subscript[Aby, 2, 4] -> 11.9279458522796630859`3.076565658940116, 
  Subscript[Aby, 2, 6] -> 44.6705413808922457974`3.650021215899404, 
  Subscript[Abx, 3, 5] -> 336.4315013885498046875`4.5268966537094135, 
  Subscript[Abx, 4, 5] -> 358.7000494003295898437`4.5547314364872, 
  Subscript[Abx, 5, 5] -> 378.44620513916015625`4.578004154716907, 
  Subscript[Abx, 6, 5] -> 395.41620635986328125`4.597054465150702, 
  Subscript[Abz, 1, 5] -> 1.2710712253319798037`2.1041698872195984, 
  Subscript[Abz, 2, 5] -> -8.1248037660552654415`2.909812880500324, 
  Subscript[Abz, 3, 5] -> -2.6828441619873046875`2.428595446598665, 
  Subscript[Abz, 4, 5] -> 7.2073822021484375`2.8577775529853255, 
  Subscript[Abz, 5, 5] -> 11.15843963623046875`3.0476034683691697, 
  Subscript[Abz, 6, 5] -> -1.21844482421875`2.085805867472421, 
  Subscript[Abx, 2, 1] -> 329.45794677734375`4.51779998752455, 
  Subscript[Abx, 2, 2] -> 327.68582916259765625`4.51545766063914, 
  Subscript[Abx, 2, 3] -> 323.5235595703125`4.509905912265384, 
  Subscript[Abx, 2, 4] -> 317.94913482666015625`4.502357647559863, 
  Subscript[Abx, 2, 6] -> 306.2722103486594278365`4.4861075928243626, 
  Subscript[Abz, 2, 1] -> -7.56097412109375`2.87857775160733, 
  Subscript[Abz, 2, 2] -> -8.53708648681640625`2.9313096811589183, 
  Subscript[Abz, 2, 3] -> -10.927783966064453125`3.0385321007524007, 
  Subscript[Abz, 2, 4] -> -11.77996063232421875`3.071143839076471, 
  Subscript[Abz, 2, 6] -> 2.9972137859149370342`2.4767177215014726}

. As you can see, in the list there are some rules, that almost duplicate each other, for example Subscript[Abx, 3, 5] -> 336.43171954154968261724.526896935319825 and Subscript[Abx, 3, 5] -> 336.43150138854980468754.5268966537094135. We've got the difference between them of some value (and in the "program" that I have to create there will always be such a difference). My goal is to delete duplicates with given precision. I realized that with the following code: DeleteDuplicates[SetPrecision[intermediateResult1, 4]] and it works, but the function "SetPrecision" works with all the digits of the number as I understand, but I just need the function working with after point digits. For example, if the values of the rules will be about 10,000 (intermediateResult1 = {Subscript[Abx, 3, 5] -> 12336.431719 and the others will be of the same order) that way won't be useful... I know that there is a function SetAccuracy, but the code DeleteDuplicates[SetAccuracy[intermediateResult1, 4]] doesn't get the result as I need. Can you please explain me how to do it? Also I can imagine that there are fundamentally different ways to implement this (delete duplicates even if the values of the rules are different with certain accuracy).

$\endgroup$

1 Answer 1

4
$\begingroup$
intermediateResult2 = DeleteDuplicates[intermediateResult1,
   2*Abs[(Values[#1] - Values[#2])/((Values[#1] + Values[#2]))] < 
     10^-4 &];

Length /@ {intermediateResult1, intermediateResult2}

(* {40, 32} *)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.