Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have some numerical code involving complex numbers representing points on a plane. Some of these are equal but not identical, ie

{Exp[2 Pi I (-1./10)], ..., Exp[2 Pi I (9./10)]}

I want to make (the equivalent of) a dictionary mapping each to its coordinate in the list (because using Position repeatedly would take too long). But both Downvalues and matching rules (with a Dispatch table) match based on the form of the expression rather than its value (and Hash hashes based on the form of the expression as well).
Eg, if

{a == b, a===b}
==> {True, False}

f[a] = 1; {f[a], f[b]}
{1, f[b]}

Is there some way to associate the points with their position (with faster than O(n) lookup) based on their value? I feel like there should also be some way to do it using rounding, but I haven't gotten it to work.

share|improve this question
Hello Zaq. I believe a similar question has been asked before. (I shall look for it.) One possibility is to use Round (with a second parameter) to quantize your data. – Mr.Wizard May 16 '14 at 20:17
Not a duplicate, but related: (15907). And this is the one I think I was remembering: (1072) -- also not an exact duplicate, but quite close. – Mr.Wizard May 16 '14 at 20:18

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.