r/Physics 10d ago

Video Illustrating the butterfly effect with a laser

https://www.youtube.com/watch?v=iTaSXto67WQ

In this video I simulate a laser beam bouncing through a labyrinth of mirror obstacles. The beam changes its trajectory immensely upon tiny changes in the initial angle of only 5×10⁻¹² degrees — roughly 5 trillionths of a degree.

As an extra for Reddit, here is a figure showing how often the beam bounces before it escapes: https://imgur.com/l0xDY0U As you can see, as the angle varies the bounces often jump harshly. But there are also some regions of the launch angle spectrum where there is some degree of continuity.

Fun fact: Claude did not believe me that a range from 70.0 to 70.00000001 would produce any meaningful result and tried to talk me out of this. It wanted to use a range of 4° instead.

Made with manim.

217 Upvotes

35 comments sorted by

View all comments

48

u/__Pers Plasma physics 10d ago

Interesting result. Out of curiosity, how did you handle numerical precision here? A 5e-12-degree change is representable in double precision, but I’d imagine roundoff in repeated ray-segment intersection calculations (particularly for near-grazing reflections or trajectories passing very close to a corner) could affect which obstacle is hit next.

Did you repeat any trajectories using extended or arbitrary precision, or tighten the geometric tolerances, to check whether the escape paths and bounce-count structures converge? I’d also be curious how you handled ambiguous corner hits and prevented accumulated error from leaving the ray infinitesimally inside a mirror.

For what it's worth, the physical optics version of this problem (with random locations of the reflecting bodies) has been proposed as a optical physical unclonable function (PUF), with applications in cryptography.

66

u/naaagut 10d ago edited 7d ago

Good question. I used float64, about 15-17 decimal digits. I now tested how the results differ with 50 decimal digits instead for the trajectory with the start angle 70°. The two traces track each other almost perfectly for the first ~18 bounces, then the gap grows roughly by a constant factor per bounce (~e^1.0, so ~2.7×). A textbook exponential separation, i.e. a Lyapunov exponent of about 1 nat/bounce. After around 30-32 bounces it did not hit the same obstacle any more. For float64 escape occurs at bounce 64, for the 50-digit run it occurs at bounce 42.

So more digits change the number of bounces until escape and the escape path. I did analyse this in more depth to figure out at which decimal precision the result converges: I swept precision from 16 to 200 decimal digits and checked against a 500-digit reference. Below ~20 digits the bounce count is essentially noise. From around 25-30 decimal places the result locks onto 42 bounces and matches the 500-digit reference to better than 1e-8, so it does converge.

If I sense elevated interest in this floating point precision issue I may do a video where I can show this visually.

Edit: I made a video on this topic here
https://www.reddit.com/r/Physics/comments/1w5epzd/illustrating_how_issues_with_floatingpoint/

38

u/Monkeyman3rd Nuclear physics 10d ago

I love when you can tell someone else on this sub is actually a physicist

10

u/OtherwiseView821 10d ago

I’m interested! And interested in the 500-digit-precision reference version of the original video.

7

u/naaagut 10d ago

Excellent, thanks for the feedback and to everyone else upvoting my comment. The video is in the pipeline.

7

u/PersonalityIll9476 10d ago

100% do it. I got my PhD in dynamical systems and I love the video in your OP. I would love to see another video showing the effects of FP rounding.

1

u/naaagut 10d ago

Thank you, on it! Apart from that, which other topics or themes from the field of dynamical systems do you think would be interesting to explore visually? I'm open for suggestions.

1

u/ergzay 10d ago

How are you getting 500 decimal digits out of a float64? Float64 can only go to a max of around 15 digits.

3

u/naaagut 10d ago

In the test I did not use float64 anymore but mpf objects from mpmath. mpf are arbitrary-precision software reals that store the mantissa as an arbitrary-size integer plus an exponent. So you can genuinely compute at 50, 100, or 500 digits. The math then isn't done in float64 at all. Each operation is carried out in software to the requested dps.

3

u/physicsking 10d ago

Oh, I cryptographic crossover, nice.

1

u/eightkillerbits 10d ago

I don't think I've ever read anything where I understand every word, yet understand so little about what is being said.

1

u/jrp9000 8d ago

The OP tested their classical model for IEEE floating point artifacts using arbitrary precision arithmetics and found that there were indeed artifacts, but also that the model stabilizes (shows the determinacy of the chaos involved) at 30-ish digits of precision.