Billiard in a von Koch snowflake fractal
Вставка
- Опубліковано 13 лип 2024
- Welcome to snowflake week! With winter approaching in the northern hemisphere, there will be a few von Koch snowflake fractal simulations in the next days.
Mathematical billiards describe the frictionless motion of a point particle inside a domain, with perfect reflections on the sides. The trajectory of the particle is the same as for a light ray in a room with perfect mirrors. When the domain has a fractal boundary, it is not at all obvious that a billiard can be defined, because one cannot define a tangent vector to the boundary. It is possible, however, to use polygonal boundaries approximating the fractal one more and more closely. A classical example of this is the von Koch snowflake: staring from an equilateral triangle, one adds, at each step, new equilateral triangles in the middle of each side.
This simulation shows 6 different levels of approximation of a von Koch snowflake:
Level 0: 0:00
Level 1: 0:42
Level 2: 1:24
Level 3: 2:06
Level 4: 2:48
Level 5: 3:30
For each level, 10 000 particles start in different directions from the middle point. They change color whenever they are reflected on the boundary. To avoid numerical problems, the corners have been replaced by very small absorbing circles, slightly decreasing the number of particles as time goes on.
Such a simulation was wished by a viewer quite a while ago, and at that time I did not see an easy way of coding it. But since then, I have improved my code, in particular by using a feature of C called structures, which make it possible to code these more complicated boundaries without too much effort.
Render time: 7 minutes 41 seconds
Color scheme: Viridis by Nathaniel J. Smith, Stefan van der Walt and Eric Firing
github.com/BIDS/colormap
Music: "Still Not Rite" by Noir et Blanc Vie@NoirEtBlancVie
Current version of the C code used to make these animations: github.com/nilsberglund-orlea...
www.idpoisson.fr/berglund/sof...
Some outreach articles on mathematics:
images.math.cnrs.fr/_Berglund...
(in French, some with a Spanish translation) - Наука та технологія
These are so enjoyable to watch even though I have no idea what's going on. Many simulation videos on UA-cam have convinced me to get into recreational programing so I can some day make similar animated simulations myself.
You definitely should, it can be very satisfying.
Include learn how to play a string based instrument. My brains go (fill in ypurself) when I learned to visualize the sound waves. 😇🎶
honestly, this is a great illustration of how soundproofing works to prevent coherent echoes from returning to a microphone
Though there seem to still be resonances, or are they only due to the short duration?
@@cmilkauit creates many small vibrations with different phases that fight with each other to decide the total phase and destroy each other
Surprising that the cut "wavefronts" unite into a wavefront occasionally
The triangle did not have any cuts. I'm wondering if cuts only occur in non-convex shapes.
@@janpirklbauer5006 I would like to see a simulation like that with waves hitting each other. It really shows how echo can be reduced in a room with lots of obstacles or rough walls.
Interesting seeing waves appear to approach particles as the detail becomes more precise
That was a JOY to watch. Thanks very much. Shared with my Psychedelic groups.
Glad you enjoyed it! And thanks for sharing.
Hey, what's your psychedelic group?
@@nuttynoah5342The Mushroom Friends
Thanks for making your cores crunch the numbers for our enjoyment! I've really appreciated seeing the results.
My pleasure!
level 5 is awesome! I would have the last freeze frame at 4:08-4:09. that’s when the geometry in the center is most distinct and beautiful 🙏🏼
There is so much ephemeral structure with the higher fractal orders, that the video could do with slowing down as the complexity grows, in order to appreciate all of the transient forms. I would love to see higher resolution or interpolated versions of this. Beautiful stuff, thank you.
You can use YT's built in speed controls
My favorite simulation with particles so far
we need more fractal billiards. this is incredible!
More to come, this is von Koch snowflake week! :)
It's trippy. I don't know what else you could gain from this
Color me mesmerised!
Organized chaos. Tickles my brain in a wonderful way.
This is like the opposite of when engineers play certain frequencies on a large speaker to make shapes out of sand.
The simulation is so clean. Bravo.
Level 3-5 was absolutely spectacular.
Unusually beautiful.
This is so cool. Very interesting 4-cycle in the last one between the center & the parts of the curve nearest the center. Please please do this exact same video with an actual wave model!!
Several variants are scheduled for the next days :)
These have given me deep insight for visualizing the nature of our universe
I would love to see the same using waves instead of particles, though the particle simulation looks awesome
A wave simulation in a snowflake is scheduled for tomorrow :)
@@NilsBerglund You are spoiling us! This was too fun!
I find it so fascinating that the end of level 5 shows that there might be no real chaos and randomness in reality and space. And maybe also from a quantum physics aspect.
What if all fields are just excited like we see here in this very small scale?
The randomness or "noise" we theorize in quantum fields or measure in physics are just reflections and refractions in space billions of years old and constantly reflected and refracted by matter/submatter billions of years old, starting at the big bang.
Of course it feels like noise and randomness on a human scale.
But maybe my idea here it total bs because I have a wrong concept of these things...
I need this as my screen-saver
Very appropriate music for the content!
Reminds me its Friday today and I need to get incredibly high
So it’s basically circle in a triangle, but every minute makes it level up and get more… snowflaky, & the more snow flaky it gets, the more crazy the circle gets.
That's it, pretty much.
Awesome
About halfway through the video, the video quality: *Ight imma head out*
Still looks absolutely amazing though!
I want to see what the limit of the billiards as the depth approaches infinity looks like, but even if it _is_ well-defined, I don't expect it to be efficiently computable (or even computable at all, perhaps).
I suspect indeed that there is no well-defined limit. There is another forthcoming simulation supporting that conjecture.
@@NilsBerglund looking forward to it!
I'm getting Amiga paint flashbacks
something disconcerting about seeing the waves stop being continuous at 0:43... i can't really recall any other billiards simulations with hard concave (convex?) edges like that
I could meditate on those caleidoscopic patterns for hours...
The masculine urge to calculate Lyapunov exponents
I’m glad that I found your channel! Pure artwork! Please, keep up the good work… 🙂
Jag ’’måste’ bara fråga; är du svensk?
Thanks, will do! I have swedish origins, and relatives there, but never lived in Sweden.
Best described as trippy
sitting in the bathtub while watching this .relaxing xd
Wonder what would happen if after all balls change color for the first time you swap the border for the next iteration of the fractal
Oh wow
Curious, after enough time, does the system ever return to its original state of a circle of particles, then repeat? Or does it always have this symmetrical messiness?
Since there are finitely many particles, a result known as Poincaré recurrence says that the system will eventually come as close as one wants to any possible state. But the time to see this grows very fast with the required precision. It may be a bit smaller for a computer simulation on finitely many pixels like here, but still quite long.
@@NilsBerglund nice answer - so how long is "quite long"? Like 10 to some ridiculous power that dwarves the age of the universe og what scale are we talking?
Something like that, yes. Say the image has one million pixel, with only 2 colors. Then the number of possible states is 2 raised to the power 1 million, which is just unimaginably huge. A deterministic map on that space has to repeat after this number of iterations. The period may be smaller, but for a chaotic map it is likely to be quite large nonetheless.
I wonder what happen if you tried to see average energy but there is two superposed fractals
So I assume a level infinity snow flow flake would be pitch black as it traps all the light and nothing ever came to the center again?
Could you do a version where the circle is not a discrete set of points but, say, a spline? The discontinuities in the koch curve are differential points so technically all those partial curves should be connected. If you smooth over the discontinuation then it should still be connected but would produce some approximation. E.g., I guess if you had about 10^100 more points for your circle it would approximate better.
It looks like it might go towards some fractal solution on the inside as well, which makes sense.
I'm especially curious how an averaged energy of wave version of this will do here
That one is scheduled in a few days :)
Very based!
What if you did a billiard but only showed the most recent colour at any given moment. I wonder if that would look cool, maybe not with this shape because itd just be contant flickering, but with a simpler shape i think it might be interesting.
I love what you do,
How long did it take to render level 5?
Can you make one with Waves that lose speed and energy when they get redirected by bouncing of the walls?
Thanks! Level 5 did not take much more time because the boundary is computed once and for all. So maybe a few seconds instead of a fraction of a second to compute that.
Non-reflecting boundary conditions are rather tricky to implement, even more so for complicated boundaries. What is not hard to do is to make the exterior refracting, see ua-cam.com/video/1w6QKmGvW-Q/v-deo.html
Best tune so far! by Noir et Blanc Vie
I discovered that artist in the previous video, very nice music indeed.
Just wondering-- are these simulations part of a research project or are they just for fun?
These are mostly for fun. Some simulations on this channel do have connections with my research work, though. For instance those on the Allen-Cahn equation and on the FitzHugh-Nagumo SPDE. I also used to work on billiards for my master thesis.
I wonder, do you actually simulate only one twelfth of these and then mirror and rotate the picture, or do you simulate the whole thing? Using the symetry should get an order of magnitude speed up.
If the initial state has the same symmetry, as is the case here, you can indeed do that. But the code is fast enough without using that trick. In that way, it works for any initial condition. Also, it gives you a "reality check" of the simulation to see whether the symmetry is preserved as it should be.
On the highest levels, the particles seem to swarm like dancing ants.
can we take a moment appreciate the sound design?
You have to thank the artists providing these tracks for that :)
I wonder how long a particle could get "stuck" in the infinite detail of the edges in the limit case -- could it stay on the outskirts forever without getting sent back in? There's certainly enough detail, but I'm not sure if the angles would allow it or not.
There may be some periodic trajectories that remain confined close to the boundary. Trajectories coming from the center, however, should come back with probability one, for reasons having to to with conservation of energy and reversibility.
@@NilsBerglund probability 1 does not mean there are no exceptions. It just means that the set of trajectories that doesn't return has measure 0.
That is right, of course. This would be the case for trajectories on the stable manifold of a periodic one remaining close to the boundary.
I wonder what's it's behavior in the limit? Is there any pattern that holds for any number of fractal iterations
This question has been asked by mathematicians, see arxiv.org/abs/0912.3948 for some results in this direction.
Very nice. If this fractal would be of level infinity, would the weave be sucked completely without any reflection? (theoretically)
I don't think so, because there are results on families of periodic trajectories that exist at every level. See the article arxiv.org/abs/0912.3948 mentioned in the description of the video ua-cam.com/video/YF8kJJhDgBc/v-deo.html
I don't know what proportion of trajectories would be trapped. Arguments based on reversibility would suggest that these have measure zero.
So could this mean a fractal surface is ideal for dampening sound?
Yes, indeed. See also the video ua-cam.com/video/LTsCx2T-4hA/v-deo.html and a few others in the playlist ua-cam.com/play/PLAZp3rbgWLo2dIeEYz8KP2TW-Yvq8TFLx.html
There is a line break whenever the initial line hits a concave surface
The general rule is that if the angle divides 180°, such as 60° in the convex corners here, the line does not break. For all other angles, it does.
Hi Nils, I tried downloading your code, building it and recreate the video. What is happening when I try to set 1080p resolution? That's working but creating a strange, not well defined, band on the side of the window. I guess it is also the reason why most of your videos are in 720p max, isn't it?
Thank you for sharing, regards.
Thanks for trying the code. I also noticed the band on the side, but did not investigate further so far. It might be due to the function write_tiff in the file sub_part_billiard.c, which creates a .tif file from the simulation window. It is a piece of code I got from someone else, and never tried to change. If you find any workaround, thanks for letting me know.
I tried reading the code today but was not that easy. I mix what is graphics related and physics related and have no clear big view. One thing easy to test though is doubling the pixels, instead of going to 1080p go to 1440p (WINHEIGHT 1440, WINWIDTH 2560). This is a "NO-stretch" operation and it is enough to eliminate the band on the side. Maybe you have already done this and know what the wrong result is. So now I know that it just need to be "centered" during tiff creation.
I really would like to understand more about this, if you want we could have a weekend meeting and maybe try to debug together. Moving your channel to 1440p would be fun! Let me know.
Thanks. I still have quite a lot of teaching for next couple weeks, but will have more time afterwards. I suggest you get in touch via GitHub then.
Given time t, you tell me a configuration. Is it possible to do the reverse? I give you back a configuration and you give time elapsed? There's multiple or no solutions, right? Assuming same initial conditions here.
There is a one-to-one map between the state at time 0 and time t, so you can invert it. Just have all particles make a U-turn, keeping their speed. See ua-cam.com/video/SOtzBvNUd2A/v-deo.html
However, when the system is unstable, small errors will grow quickly and make time-reversal hard in practice.
Could you pls try colouring the line segments according to their length? Pleeeze?
The segments representing particles all have the same length here. For a color coding of trajectory lengths, see ua-cam.com/video/Xa0lZLIGlPU/v-deo.html
@@NilsBerglund I don't understand. There's an expanding circle initially. After some time, it touches a Koch curve at some points and splits into discrete segments, or joins with other segments. I'm trying to say that using the segment length would be an interesting way to colour code them. Anyways, great work!!
Ok, I understand. I was actually thinking of other simulations than this one, which use discrete particles instead of an expanding circle.
Question, could you compute particle density plots for these? The reason I ask is that I am a quantum physicist and I am wondering if there is localization, classical physics can tell use something about the wave function
I suppose one can do something like this: replace each particle by a Gaussian centered at its position, with a small variance, then add all these Gaussians. A technical term for this would be "convolute the empirical distribution with a Gaussian kernel". This was suggested by another viewer a while ago, for a different simulation.
I don't know how computationally costly this is, but may try at some point and post the result if it works.
@@NilsBerglund BTW, excellent simulations 👍
@@NilsBerglund what is wrong with the simple approach of taking a small window and calculating the number of particles inside it relative to the whole snowflake? Is there something wrong with that ?
You can do that, but the resolution of the resulting image may not be so great. You will have to take a window that is large enough to contain more than just a dozen particles or so, or the resulting density map will fluctuate strongly in space and time. But if the window is too large, the density map will look quite pixelized. The same problem arises when making histograms. Maybe taking a sliding window helps, or using a sufficiently large number of particles.
@@NilsBerglund Niels, the reason I asked this is I am a quantum physicist and was looking at this same system a few years ago, never solved it. BC became intractable. My interest is if the boundaries can cause localization, (Like Anderson Localization) . Just curious. Really impressed with you computational skill 👍
how do you make this stuff?
These are coded in C, there is a link to my GitHub page in the description.
@@NilsBerglund Thanks so much for putting it out there!
as we say;
in level infinity we might see the full cloud
Such lovely patterns, like a kaleidoscope, becoming gradually more complex. One could use these as a starting point for all sorts of arty design projects, from painting to embroidery -- and beyond.
Thanks so much for doing this and sharing it; I find lots of your work very beautiful indeed. 👌👌👌👌👌
Just looking for a logo for my futuristic Cyberpunk company
Can I see in higher dimensions? There is an illusion I can here.
Have You thought about doing this in third(3) dimension?
There are several challenges in doing 3d: computations for the collisions are somewhat more involved, making the rendering slower, and you also have to think about how to represent 3d space graphically without everything just being a mess. Maybe I'll get there sometime.
@@NilsBerglund do it in a limited cubic space with ability of spectator to watch from outside of that cube and ability to make 2d cross sections at different angles
Was hoping for snooker to be honest.
*What was in my coffee*
do this again but use a wave
Coming up, tomorrow :)
Very nice, I find it cool how the more layers you add, the more sooner it becomes noisy.
Would you be able to do a series of billiards of increasing X-pointed stars? For example, 5, 10, 20, 50, 100, etc? It’d be interesting to see the same chaotic behaviour occur
Perhaps some older animations such as ua-cam.com/video/IZ1FACWK8ZQ/v-deo.html give you an idea of what happens for star shapes. Of course there are alternative ways of defining stars. It wouldn't be too hard to include new shapes like that in my code, once one has a formula for the positions of vertices.
@@NilsBerglund Yeah that video was also very interesting. I really would have liked to have seen something like that but starting from the centre.
I wonder if this has any practical use? Seems pretty either way.
Sound proofing? Wave erosion?
I wonder how much of the original intensity gets "trapped" in the outer region. I'd be curious to see a visualization of intensity as a function of radius and how it evolves over time for the different shapes.
There are some forthcoming wave simulations that will make it easier to see that.
thats not builliard
Mathematicians have a quite general view of what they call a billiard...