Message Boards Message Boards

[GIF] Modular (Point orbit under the action of the modular group)

5 Replies

Very nice visualisation!

On two occassions:

Sort[...,  Norm[#1, 1] > Norm[#2, 1] &]

Could be sped up by:

SortBy[..., Norm[#, 1]&]

25% improved on my laptop...

In addition:

DeleteDuplicatesBy[SortBy[newpts, #[[2]] &], First]

Speeds it up another 10x times, 13x total or so...

Moral of the story: if you compare two the same things in Sort, DeleteDuplicates, Gather et cetera use SortBy, DeleteDuplicatesBy, GatherBy, et cetera. those are a lot faster because it evaluates the criterion only once on all the elements, sorts those (very fast) and reorders the original. While e.g Sort compares each PAIR again and again, reevaluating the criterion. Because in theory you could have an 'asymmetrical' comparison: e.g. SortBy[list,First[#1]>Last[#2]&] (quite uncommon but it happens sometimes!).

POSTED BY: Sander Huisman

enter image description here - another post of yours has been selected for the Staff Picks group, congratulations !

We are happy to see you at the top of the "Featured Contributor" board. Thank you for your wonderful contributions, and please keep them coming!

POSTED BY: Moderation Team

Oh wow, thank you! I didn't even know about SortBy and DeleteDuplicatesBy, but that's obviously the way to go.

Posted 4 years ago

Matrices in PSL(2,Z) must have determinant equal to 1, and it doesn't look like you're requiring this. The modular group action is discrete, while the points in your picture appear to accumulate.

I'm a big fan, by the way. I first saw your gifs on Ello, and I was happy to find that you use Mathematica and share your code!

POSTED BY: Elijah Fromm

Yes, you're quite right. I realized after the fact that I'm doing something much bigger than the modular group, but never went back and corrected the description.

And thanks! Nice to virtually meet you.

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract