Paste two lines into any page, use it from React, play it in a terminal, put a GIF in a README, or hand the Agent prompt to your coding agent. Every tab follows the look you pick above.
// npm install ascii-magic-art
import { useEffect, useRef } from "react";
import { play } from "ascii-magic-art/runtime/player.js";
import * as piece from "ascii-magic-art/pieces/double-pendulum.js";
export function DoublePendulum() {
const ref = useRef(null);
// play() draws the piece on a canvas in your look and returns stop(), which React runs on unmount
useEffect(() => play(ref.current, piece), []);
return <pre ref={ref} style={{ fontSize: 10, fontFamily: "Menlo, Consolas, monospace" }} />;
}
npx ascii-magic-art double-pendulum
<!-- Export the GIF below in the look you picked, commit it, then: -->
<p align="center">
<img src="assets/double-pendulum.gif" alt="Double Pendulum, animated ASCII art" width="720">
</p>
Add the animated ASCII art piece "double-pendulum" (Double Pendulum) from ASCII Magic to this project.
1. Load the script once, in the browser only (in SSR frameworks such as Next.js, load it on the client):
<script type="module" src="https://www.ascii-magic.com/ascii/ascii.js"></script>
2. Put the piece where it fits best, such as the hero, a loading state, an empty state or the 404 page:
<ascii-art piece="double-pendulum"></ascii-art>
3. Keep a real heading or text next to it (the art is decoration), and size it with the size attribute or CSS.
Preview and options: https://www.ascii-magic.com/ascii/double-pendulum
Rules for coding agents: https://www.ascii-magic.com/ascii/use/ai-coding-agents
Export
Pause on the frame you like, pick a look, then download it at an exact size.
This double pendulum is a hand-coded ASCII animation of one of the simplest chaotic systems in physics: one pendulum hanging from the end of another. Both arms start raised high, swing under gravity and flip over the top of the pivot, while the lower bob paints a glowing trail that fades from white through blue to violet. Within each run its path never settles into a repeating loop, which is exactly what makes it chaotic.
Use it to show chaos instead of only describing it. Below is a plain-English explanation of why two linked arms behave so wildly, how this animation is computed and drawn, and every way to put it to work: one tag on a web page, a terminal command, a GIF for a README, video for slides and wallpaper exports. It is MIT licensed, so lessons, talks and commercial projects are all fine.
Why a double pendulum is chaotic
A single pendulum is the classic picture of regular motion: it swings back and forth with a steady beat you could predict far into the future. Hang a second pendulum from the first bob and that predictability falls apart. The arms are joined in the middle, so each one pushes and pulls the other at every moment, and neither can keep its own rhythm.
The result is chaos in the scientific sense, the behavior people call the butterfly effect. Nothing is random: the same start always gives the same path. But any error in the start, however small, grows with every swing, so long-range prediction fails in practice. Chaos also needs energy. Gentle swings near the bottom stay fairly regular; released from high up, as here, the pendulum turns wild within a few swings.
The equations of motion fit in a few lines but have no neat formula for the answer, so a computer works the motion out one small time step at a time. Four ideas explain why double pendulum chaos looks the way it does:
Two linked arms: there are two angles to track instead of one, and each arm's motion depends on the other.
Energy trading: the upper arm can almost stop while the lower one whips around, then the roles reverse.
Flips over the top: with enough energy either arm can swing right over the pivot, and which way it goes hangs on tiny details.
Sensitive dependence on starting conditions: two releases that differ by a hair begin together, then drift apart until their paths have nothing in common.
Inside this double pendulum simulation
The piece models an ideal double pendulum: equal arms, equal bobs, Earth gravity of 9.81 meters per second squared and no friction or air drag, so the swing never runs down. Both arms start at rest and raised high, the upper one about 135 degrees from hanging straight down and the lower one about 158 degrees, then let go.
The whole state is four numbers: two angles and two angular speeds. The RK4 method, a standard fourth-order integrator, advances them in steps of 1/240 of a second, eight steps for every frame at 30 fps. The steps follow the animation clock rather than the screen, so the path is the same on any device, and the total energy barely drifts over a run.
The trail remembers the last 900 positions of the lower bob, a little under four seconds of motion. The newest stretch is solid white blocks; older stretches step down to lighter shade characters as the color cools through cyan and blue to violet and deep purple. It is drawn oldest first, so fresh path always sits on top where it crosses an older loop.
Every 24 seconds the trail clears and the pendulum is released again from the same pose. With nothing random in the model, it replays exactly the same run each time: deterministic chaos in miniature. Change a starting angle in the code by a millionth of a radian and the two runs match at first, then part ways completely before the 24 seconds are up.
Around the trail, each 72 by 34 character frame holds:
A faint lab grid of dots and thin lines in dark navy, centered on the pivot.
Rods of small pale dots hanging from a white pivot block, and two chunky bobs, orange above and coral red below.
A readout of both angles, a1 and a2, in degrees, which jumps between 180 and minus 180 each time an arm passes over the top.
Sideways distances doubled because character cells are about twice as tall as they are wide, so the arms keep their length whichever way they point.
Embed it, export it or play it in a terminal
On a web page, attributes tune the embed. speed="0.5" halves the pace for talking a class through a single swing, and size and bg set the character size and background. The trail and bobs are made of shade blocks, so the looks redraw them while the grid, rods and readout keep their shape: Halftone dots turn the trail into dots that shrink as it ages, Binary suits a computing theme, chars takes your own characters, and mono drops the color.
Each way to use the pendulum has a ready snippet or button on this page:
Web page: load <script type="module" src="https://www.ascii-magic.com/ascii/ascii.js"></script> once, then add <ascii-art piece="double-pendulum"> with its closing tag. It draws on a canvas, weighs a few KB, plays only while it is on screen and holds a still frame for visitors who prefer reduced motion.
React: copy the piece file and its small helper into your project, and the component in the React tab draws each frame as text.
Terminal: npx --yes ascii-magic-art double-pendulum plays it in a terminal in color. Add --frame for one still frame or --seconds=3 to stop after three seconds.
README: download the GIF, commit it to your repository and paste the snippet from the README tab. More tips live in Animated ASCII art for a GitHub README.
GIF and video: export a GIF, or MP4 or WebM video at 1920x1080 by default with a 4K option. Exports begin at the moment shown in the player, so pause where the trail looks best.
Wallpapers and social sizes: PNG presets for desktop 4K and 1080p, phone, thumbnail, social preview, banner, square and story formats. For ideas, see ASCII art wallpapers for desktop and phone.
Copy as text: copies the current frame as plain text for docs, chat or a code comment.
Where a chaos theory animation fits
Physics lessons. The double pendulum is the classic first example of chaos, and watching it move lands the idea faster than a page of algebra. Pair it with the Pendulum Wave piece for contrast: there, small differences in length build an orderly pattern that comes back on schedule. The Falling Sand piece and the other physics simulations in Motion Lab cover more ground, and Science & Learning adds teaching pieces from other subjects.
Talks and slides. Chaos is a handy picture for any talk about forecasting, risk or complex systems. A video export drops into any slide app, and ASCII art for slides and presentations explains when a GIF is the better choice.
Hero backgrounds. The dark grid and glowing trail suit a dark hero section on a science, data or engineering site. Match bg to your page, slow it with speed so a headline stays readable, and it pauses on its own once a visitor scrolls past.
READMEs and wallpapers. A GIF of the pendulum tells visitors at a glance that a repository is about simulation, numerical methods or physics. For a wallpaper, pause on a frame with a long, looping trail and export a PNG at the size you need. The full ASCII library holds about 734 pieces in 24 categories.
A double pendulum is a pendulum with a second pendulum hanging from the end of the first, so two arms swing from a single pivot. The arms push and pull on each other through the middle joint, which makes it one of the simplest physical systems that can behave chaotically. That is why it turns up in so many physics classes and simulations.
Q. Why is a double pendulum so chaotic?
It is chaotic because its motion is extremely sensitive to where it starts. The two linked arms keep trading energy, and with enough energy either arm can flip over the top, so a difference too small to measure grows with every swing. Soon two nearly identical releases follow completely different paths, even though the rules are exact.
Q. What is the butterfly effect in a pendulum?
It is the way a tiny change in a chaotic pendulum's starting position grows into a completely different motion later on. The name comes from the idea that the flap of a butterfly's wings could, in principle, change the weather weeks later. For a chaotic system whose path is itself shaped like a pair of wings, see the Lorenz Butterfly piece.
Q. Is the motion of a chaotic pendulum random?
No, a chaotic pendulum follows exact rules with no randomness at all. Start it twice from precisely the same position and it traces precisely the same path, which is why this piece can replay the same run every 24 seconds. It only seems random because any real start carries tiny errors, and chaos magnifies them until prediction fails.
Q. Does this pendulum animation ever repeat?
Yes, it restarts every 24 seconds from the same raised position, so the same run plays on a loop. Within each run the lower bob never settles into a repeating orbit, and both arms swing over the top of the pivot several times. The trail clears at every restart, so each cycle begins on a clean grid.
Q. How is this pendulum simulation calculated?
It solves the standard equations of motion for an ideal double pendulum with RK4, a fourth-order integration method, in steps of 1/240 of a second. The model has two equal arms, two equal bobs, Earth gravity and no friction. The last 900 positions of the lower bob are kept to draw the fading trail behind it.
Q. Is this simulation accurate enough for a physics class?
It is accurate enough to show how a double pendulum behaves, but it is an animation, not a lab instrument. It uses the textbook ideal model, solved with a careful step method, and leaves out friction, air drag and the mass of the rods. A real pendulum on a desk slows down and takes its own path, so use this to explain chaos rather than to take measurements.
Q. How do I embed a double pendulum animation on my website?
Add the library script tag once, then place <ascii-art piece="double-pendulum"> with its closing tag where the pendulum should swing. The HTML tab on this page has both lines ready to copy. The element plays only while it is on screen and holds a still frame for reduced motion, and attributes such as speed="0.5" or look="dots" slow it down or redraw it in halftone dots.
Q. Can I play the pendulum animation in a terminal?
Yes, the piece plays in a terminal in color with one command, which you can copy from the Terminal tab on this page. Add --frame to print a single still frame, --seconds=3 to stop after three seconds, or --look=dots to draw it in halftone dots. It makes a lively welcome for a shell or a live demo.
Q. How do I add a chaotic pendulum GIF to a README?
Download the GIF from this page, commit it to your repository, then paste the snippet from the README tab, which shows the image centered at 720 pixels wide. READMEs cannot run scripts, so a GIF is the reliable way to show motion there. Pause first on a moment you like, because the export starts from the frame in the player.
Q. Where can I find a chaos theory animation for a presentation?
You can use this one: it exports as MP4 or WebM video at 1920x1080, with a 4K option for large screens. A video file plays offline in any slide app, and a GIF works where a deck only accepts images. Pause on the moment you want the clip to begin, since exports start there. For more tips, see ASCII art for slides and presentations.
Q. Can I use this pendulum animation in a commercial project?
Yes, every piece in the library is MIT licensed, so you can use it in personal and commercial work, from course sites to product pages and videos. Credit is appreciated but not required. The source code is on this page too, so you can read exactly how the pendulum is integrated and drawn before you use it.
MIT licensed and open source on GitHub. It imports one small helper file, kit.js. This is the animation itself: what gets drawn in every frame. The look you pick is applied on top by the player, like a filter, so this file stays the same in every look while the snippets above change with it. Edit it to change the animation; see the docs to make your own.