.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "api/gallery/chaos/billiards/plot_extreme_sensitivity.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_api_gallery_chaos_billiards_plot_extreme_sensitivity.py: Extreme Sensitivity: a Slightly Truncated Circle ===================================================== A billiard particle moves in a straight line and reflects specularly off its boundary, :math:`\mathbf{v}' = \mathbf{v} - 2(\mathbf{v}\cdot\mathbf{n}) \,\mathbf{n}`. The circular billiard (boundary :math:`x^2+y^2=r^2`) is *exactly* integrable: :math:`\sin\phi` -- the sine of the angle of incidence at each bounce -- is conserved forever, so two rays launched a hair's breadth apart stay a hair's breadth apart forever too. Slicing off even a tiny flat chord (turning it into a :class:`~physicskit.chaos.systems.billiards.TruncatedCircleBilliard` of boundary parameter ``cut``) destroys this completely. This example launches two rays :math:`10^{-8}` radians apart into a circle truncated by a chord just 5% of the radius deep -- barely different from a perfect circle by eye -- and watches them track each other indistinguishably for dozens of bounces before a single grazing hit near the chord sends them down completely different paths. .. GENERATED FROM PYTHON SOURCE LINES 19-29 .. code-block:: Python import matplotlib.pyplot as plt from physicskit.chaos.systems.billiards import CircleBilliard, TruncatedCircleBilliard from physicskit.chaos.visualizers import ( animate_billiard_divergence, billiard_trajectory_divergence, plot_billiard_divergence, ) .. GENERATED FROM PYTHON SOURCE LINES 30-36 A perfect circle never diverges ------------------------------------- As a baseline, launch the same pair of nearly-identical rays into an *untruncated* circle: because ``sin(phi)`` is exactly conserved, their separation is exactly preserved too, bounce after bounce -- no exponential growth, no sensitivity, because there is no chaos to be sensitive to. .. GENERATED FROM PYTHON SOURCE LINES 36-40 .. code-block:: Python circle = CircleBilliard(radius=1.0) _, separation_circle = billiard_trajectory_divergence(circle, pos=circle.sample_interior_point(), vel=(0.2, 0.0), delta_0=1e-8, n_bounces=100) print(f"Perfect circle: separation after 100 bounces = {separation_circle[-1]:.3e} (started at 1e-08)") .. rst-class:: sphx-glr-script-out .. code-block:: none Perfect circle: separation after 100 bounces = 1.000e-08 (started at 1e-08) .. GENERATED FROM PYTHON SOURCE LINES 41-45 Animation: two rays, one tiny chord ------------------------------------------ Watch the reference (blue) and perturbed (red) rays bounce together, overlapping so closely they look like a single ray, until they don't. .. GENERATED FROM PYTHON SOURCE LINES 45-53 .. code-block:: Python billiard = TruncatedCircleBilliard(radius=1.0, cut=0.001) pos = billiard.sample_interior_point() vel = (0.2, 0.0) anim = animate_billiard_divergence(billiard, pos, vel, delta_0=1e-8, n_bounces=100, trail=25) plt.show() .. container:: sphx-glr-animation .. raw:: html .. GENERATED FROM PYTHON SOURCE LINES 54-58 To save the animation to a file instead of (or in addition to) displaying it interactively, use e.g.:: anim.save("extreme_sensitivity_animation.gif", writer="pillow", fps=25) .. GENERATED FROM PYTHON SOURCE LINES 60-67 Quantifying it: exponential divergence --------------------------------------------- ``ln(separation / delta_0)`` climbs in a distinctive staircase -- flat stretches where both rays are still circling together far from the chord, punctuated by jumps each time one (and then, soon after, the other) ray grazes it -- before saturating once the two rays are effectively uncorrelated, at the scale of the table itself. .. GENERATED FROM PYTHON SOURCE LINES 67-71 .. code-block:: Python fig, ax, lam = plot_billiard_divergence(billiard, pos, vel, delta_0=1e-8, n_bounces=100) ax.set_title(f"{ax.get_title()} (cut = {billiard.cut})") plt.show() .. image-sg:: /api/gallery/chaos/billiards/images/sphx_glr_plot_extreme_sensitivity_002.png :alt: TruncatedCircleBilliard trajectory divergence (cut = 0.001) :srcset: /api/gallery/chaos/billiards/images/sphx_glr_plot_extreme_sensitivity_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 5.959 seconds) .. _sphx_glr_download_api_gallery_chaos_billiards_plot_extreme_sensitivity.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_extreme_sensitivity.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_extreme_sensitivity.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_extreme_sensitivity.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_