There is a kernel function Internal`ToEquivalenceClass.I don't know how to use it.There are some right example right to run

Internal`ToEquivalenceClass[{1, 2, 3}]

(* {1, 2, 3} *)

(* 9 *)

Internal`ToEquivalenceClass[{1, 2., 3}, 9]
(* {1, 2., 3} *)

But the Internal`ToEquivalenceClass[{1, 2., 3}, {5, 6}] will give a error information

And we can find a option of it.

Internal`ToEquivalenceClass // Options

{Heads -> True}

Can anybody the usage and the intention about this function?


closed as off-topic by Daniel Lichtblau, MarcoB, LCarvalho, Jason B., Öskå Jul 10 '17 at 19:39

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "The question is out of scope for this site. The answer to this question requires either advice from Wolfram support or the services of a professional consultant." – Daniel Lichtblau, MarcoB, LCarvalho, Jason B., Öskå
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 4
    $\begingroup$ Umm...it is in Internal` context. $\endgroup$ – Daniel Lichtblau Jul 9 '17 at 14:39
  • 1
    $\begingroup$ You demonstrate that you are clueless about what the function does, so why do you want to use it? And if you don't want to use it, but are just curious about it, why should we spend our time trying to find out for you? As Daniel Lichtblau points out, it is the Internal context; not meant for users. $\endgroup$ – m_goldberg Jul 9 '17 at 15:20
  • 1
    $\begingroup$ @m_goldberg,Daniel Lichtblau I have opened a discuss in Meta.SE here.If most people think I should not take such topic.I will delete it and stop to talk these undocumented question. $\endgroup$ – yode Jul 9 '17 at 15:54
  • 8
    $\begingroup$ @m_goldberg This question is like one my earlier questions about an undocumented function, driven purely out of curiosity. My opinion is that this is a perfectly fine question, should not be closed, and that others can benefit from it in the future. $\endgroup$ – QuantumDot Jul 9 '17 at 17:40
  • $\begingroup$ @QuantumDot. That's a perfectly valid opinion, but mine happens to be different. $\endgroup$ – m_goldberg Jul 9 '17 at 17:53

Internal`ToEquivalenceClass[expr, tol] is used to replace floating point numbers in an expression with their equivalence class representatives according to the specified tolerance.

For an example, using machine precision, consider

nums = {0.33000000000000004, 0.33000000000000007, 0.33000000000000010};

The first two numbers are equivalent under the default tolerance which allows a difference in the last binary digit

Gather[nums, Function[Abs[#1 - #2] < 2^-53]] // InputForm

(* {{0.33, 0.33000000000000007}, {0.3300000000000001}} *)

so Internal`ToEquivalenceClass[nums] which is the same as

Internal`ToEquivalenceClass[nums, N[Log[10, 2]]]


(* {0.33000000000000007, 0.33000000000000007, 0.3300000000000002} *)

As the tolerance increases, the equivalence classes become larger: if another bit of tolerance is allowed, all three numbers are considered equivalent

Internal`ToEquivalenceClass[nums, N[Log[10, 2^2]]] // InputForm

(* {0.33000000000000007, 0.33000000000000007, 0.33000000000000007} *)
  • $\begingroup$ As your answer,it is same the function Internal`CompareNumeric here.Though I think this result is little unexpected.. $\endgroup$ – yode Jul 10 '17 at 17:17

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