Code Snippets Mathematica

Short texts Mathematica 🧑‍💻 Code snippets Mathematica ✍️ Reading lists Mathematica 👀

CommutatorPlot.mathematica

CommutatorPlot[group_, ticks_] := Module[ {}, els = GroupElements[group]; n = Length[els]; (* Initial sorting of elements provides a good approximation for \ sorting by conjugacy class, and provides a sorting for the conjugacy classes themselves *) CycleLengths[c_] := Sort[Length /@ c[[1]]]; els = SortBy[GroupElements[group], Function[g, {CycleLengths[g], g}]]; (* Calculating and sorting by conjugacy classes *) […]

sansu1177a.m

In[]:= AbsoluteTiming[ ans = Sum[Binomial[13 – 2 k, k], {k, 1, 4}]] Out[]= {0.0000335, 87}

Covid19 slope

worlddata = Import[“https://covid.ourworldindata.org/data/owid-covid-data.csv”]; font = “Helvetica Neue”; angle = Pi/4; pos0 = {0, 0}; radius = Log[10]/Pi; slopepos[val_, h_] := pos0 + {Cos[angle]*val + h*Sin[angle], (-Sin[angle])*val + h*Cos[angle]} line[x_, val_] := With[{angle = (val/Log[10])*Pi}, {{x[[1]] + radius*Cos[-angle + Pi/4], x[[2]] + radius*Sin[-angle + Pi/4]}, {x[[1]] – radius*Cos[-angle + Pi/4], x[[2]] – radius*Sin[-angle + Pi/4]}}]; tag […]