I've recently been playing with some performance tuning over a seemingly simple construction where I build a 2D array of Sin[x*y]
for {x, y}∈Interval[{0, 2π}, {0, 2π}]
.
I think it's also a good example of how vastly different results one can get depending on how efficiently the operation is performed.
Here's the operation in the simplest/least efficient way I could think up:
Table[N@Sin[x*y],
{x, 0, 2π, π/250},
{y, 0, 2π, π/250}
]; // RepeatedTiming // First
2.01
Now, how can we speed this up? (or slow it down in non-intuitive ways)
For reference, the best I managed to get was 0.0011
but all answers are good answers, especially if they provide analysis of how they speed up/slow down the problem.
Also feel free to cut down on the number of points 250
was simply most evocative.