Million Magnet Simulation: Mathematica vs Python vs OpenGL

preview_player
Показать описание
Follow me on twitter at GoldPlatedGoof

0:00:00 Start
0:01:27 Going over the math
0:03:53 Mathematica on the CPU
0:05:55 Broadcasting in NumPy
0:11:30 Shadertoy/OpenGL
0:15:19 Farewell
Рекомендации по теме
Комментарии
Автор

Mathematica has non-linear neural network functionality which can utilize the GPU. That, as well as FunctionCompile, could drastically speed it up.

Laff
Автор

Amazing stuff! I wish I'd seen the live stream.

I"ve been missing your streams ever since the start of 2022...not by choice though. I hope to make next Wednesday.

kenhaley
Автор

This is epic though, especially the openGL one.

jojojorisjhjosef
Автор

Few very simple tricks to speed up this python code.
Replace divisions with multiplications. Especially that divide by 6 in that for loop.. Precompute 1/6 outside the loop and instead multiply by 1/6th.

Replace powers with multiplications.. Where possible ofcourse.. E.g. Instead of writing x**2, write x * x
Python is not a compiled language (well some IDEs can compile but not jupyter) so simple performance improvements like this will not be automatically done by a compiler.

Replace multiplications with addition or bit shifting. If you want to do 2 * x just write x + x it will be faster (especially in a loop as small gains stack up in loops) and in a situation where x is an integer you can use x << 1 to multiply by 2 and this is slightly faster than adding.

If I think of more improvements, hopefully better ones than this list.

And I will benchmark these changes and post a reply to this comment with the performance gain.. Which probably won't be much but these are nice to know improvements.

ssquarkgaming
Автор

Why doesn't this have one million views?

ekamperi
Автор

I will never understand why so many respected people who use python work in jupyter.

jojojorisjhjosef
Автор

Are you the math genius i have been looking for?

fatfingersman