loading...
running...
How to use
Choose a preset or set the number and strength of the magnets, the friction and the height. The coloured background is the basin map: each pixel is coloured by the magnet a bob released at rest from that point would end on (brighter = settles sooner). Click anywhere on the map to release the bob there and watch it wander. Try: (1) Three magnets, click near a boundary and release twice 1 pixel apart; (2) Low friction versus Heavy friction to see the fractal dissolve; (3) One strong magnet and read the basin shares in the graph; (4) Force arrows to see the pull field. Drag to orbit, wheel to zoom. Space pauses, R resets the bob.
The frame, magnets, bob, string pivot and baseboard were modelled and baked in Blender; Three.js r160 integrates the same pendulum model as the 2D lab and paints the basin map onto the baseboard.
The science
A bob hangs on a long string above a table with N magnets. For small swings the bob moves in a plane, with position r = (x, y) measured from the point under the pivot (units are scaled so the ring of magnets has radius a):
r'' = -k r - c r' + ∑i Gi (mi - r) / (|r - mi|² + d²)p
k = g/L is the pendulum restoring rate (the string replaces a spring in the small-angle limit), c is viscous friction, d the height of the bob above the magnets (it keeps the pull finite) and p sets the force law: p = 3/2 is a monopole-like 1/r² pull, p = 5/2 a dipole-like 1/r⁴ pull. The force is conservative apart from friction, with potential
U(r) = ½ k |r|² - ∑i Gi / (2 (p-1)) · (|r - mi|² + d²)-(p-1), dE/dt = -c |r'|²
so with c > 0 every trajectory ends in one of the N potential wells, directly above a magnet. Which one is the interesting question. Release from rest at every pixel of the map and colour it by the magnet where the bob stops: that is the basin of attraction map. Near the centre the basins are wide wedges, but farther out the bob has enough energy to cross the ridges between the magnets several times before friction traps it, and the boundaries become fractal: zoom in and the three colours are interleaved at every scale. Two bobs that start 1e-4 apart (the violet twin) separate roughly exponentially during the wandering phase, then lock to different (or the same) magnets: that is sensitive dependence on initial conditions without any random numbers.
Effect of the parameters. More friction means shorter wandering and smoother, wider basins; weak friction gives long chaotic transients and thin filaments. A larger height d softens the magnets and merges the wells; a stronger magnet 1 expands its own basin at the expense of its neighbours. With strong gravity restoring k the bob never leaves the central region and one basin per magnet is almost a clean pie slice.
Numerics. Classical RK4 with step 0.005 for the live bob (0.03 for the map, where the force scale limits the step; the map's settling test is |v| < 0.025 within 0.45 a of a magnet, otherwise the nearest magnet after 80 time units). One map pixel is one release from rest at the pixel centre.
Checks. (1) With the magnets switched off the period must equal 2π/√k (six cycles, zero crossings with interpolation); (2) one magnet exactly under the pivot has the linearised frequency ω² = k + G d-2p, an independent analytic formula for small swings; (3) energy drift without friction over 32 time units; (4) for three identical magnets the 120 degree rotation maps the polar release grid onto itself, so the three basin shares must agree.
Simplifications. Planar small-angle motion (the 3D model lifts the bob on a sphere of radius L but integrates this same planar law); magnets are point-like sources with a softened core, not real finite dipoles with orientation; no air drag beyond linear friction and no eddy-current damping in the table. The numbers are dimensionless, the dynamics are qualitative-to-semiquantitative for a real desk toy.