Double pendulum · qwen3-coder
Output generated Cost / run $0.0039 Runtime 39.3s
Prompt for this run
Simulate a chaotic double pendulum on a canvas using the correct equations of motion, drawing the arms and a colorful fading trail of the tip.
TAKE IT TO CODE
A single self-contained HTML file — copy it and open in any browser, or reuse the prompt with your own pi-agent run.
RUN
METRICS
Transcript · 4 messages
Simulate a chaotic double pendulum on a canvas using the correct equations of motion, drawing the arms and a colorful fading trail of the tip.
I'll create a chaotic double pendulum simulation with the correct physics equations, colorful trail, and canvas visualization. Here's the complete solution:
index.html (11252 bytes)Successfully wrote 11252 bytes to index.html
I've created a complete chaotic double pendulum simulation with the following features: 1. **Accurate Physics**: - Implemented the correct equations of motion for a double pendulum using Hamiltonian mechanics - Used the Runge-Kutta 4th order method (RK4) for numerical integration - Proper conversion between generalized coordinates and Cartesian coordinates 2. **Visual Elements**: - Colorful fading trail that shows the path of the pendulum tip - Two masses connected by rods with distinct colors - Smooth animation with trail persistence effect 3. **Interactive Controls**: - Sliders to adjust masses and rod lengths - Reset button to restart with slightly randomized initial conditions - Real-time parameter adjustments 4. **Design**: - Dark theme with glowing pendulum - Responsive layout - Informative description of the physics The simulation demonstrates chaotic behavior where small changes in initial conditions lead to dramatically different outcomes. The colorful trail helps visualize this complex motion pattern. To run it, simply open the index.html file in any modern browser. You can adjust the parameters using the sliders to see how they affect the pendulum's motion.