oneshotlm
Compare all models on this prompt →

Double pendulum · glm-4.5-air

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.

⛨ sandboxed Open in new tab ↗
transcript · 4 messages
user

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.

assistant
thinking
The user wants me to create a single-page web app that simulates a chaotic double pendulum. The requirements are:

1. Everything in one file: index.html
2. CSS in a <style> tag
3. JS in a <script> 
4. No external resources or network requests
5. Use correct equations of motion for a double pendulum
6. Draw the arms
7. Draw a colorful fading trail of the tip

For a double pendulum, I need to implement the equations of motion. The double pendulum is a classic chaotic system with two coupled pendulums.

The equations of motion for a double pendulum are quite complex. I'll need to:

1. Set up the canvas
2. Define the physical parameters (masses, lengths, gravity, etc.)
3. Implement the differential equations for the double pendulum
4. Use numerical integration (like Runge-Kutta) to solve the equations
5. Draw the pendulum arms
6. Track and draw the trail of the second pendulum bob with fading colors

The equations of motion for a double pendulum are:
- θ1'' = [−g(2m1+m2)sin(θ1)−m2g sin(θ1−2θ2)−2sin(θ1−θ2)m2(θ2'²L2+θ1'²L1cos(θ1−θ2))] / [L1(2m1+m2−m2cos(2θ1−2θ2))]
- θ2'' = [2sin(θ1−θ2)(θ1'²L1(m1+m2)+g(m1+m2)cos(θ1)+θ2'²L2m2cos(θ1−θ2))] / [L2(2m1+m2−m2cos(2θ1−2θ2))]

Where:
- θ1, θ2 are the angles of the two pendulums
- L1, L2 are the lengths of the pendulum arms


- m1, m2 are the masses of the pendulum bobs
- g is gravitational acceleration
- ' denotes time derivative

I'll use the Runge-Kutta 4th order method to numerically integrate these complex differential equations. This approach will help me accurately simulate the chaotic motion of the double pendulum system.

I'll create a single-page web app that simulates a chaotic double pendulum with the correct physics equations. This will include a colorful fading trail effect.

write /tmp/ws/index.html (10956 bytes)
toolResult

Successfully wrote 10956 bytes to /tmp/ws/index.html

assistant
thinking
I've created a complete single-page web app that simulates a chaotic double pendulum. The implementation includes:

1. **Correct Physics**: Uses the proper equations of motion for a double pendulum with Runge-Kutta 4th order integration for numerical stability
2. **Visual Elements**: 
   - White pendulum arms
   - Red and colored pendulum bobs
   - Colorful fading trail that changes hue over time
3. **Interactive Features**:
   - Reset button to randomize initial conditions
   - Toggle trail button to show/hide the trail
   - Click to set custom initial positions
4. **Visual Effects**:
   - Trail with HSL color gradient that fades from purple to red
   - Slight fade effect on canvas for motion blur
   - Smooth animation with multiple physics steps per frame

The simulation demonstrates the chaotic nature of double pendulums - small changes in initial conditions lead to dramatically different trajectories over time. The colorful trail makes the chaotic motion visually apparent.

The file is self-contained with all CSS in style tags and JavaScript in script tags, no external dependencies.

I've created a complete chaotic double pendulum simulation in a single HTML file. The app features: **Physics**: Implements the correct equations of motion using Runge-Kutta 4th order integration for accurate chaotic behavior **Visual Features**: - White pendulum arms connecting the pivot to two colored bobs (red and cyan) - Colorful fading trail that creates a rainbow gradient effect as the pendulum moves - Slight motion blur effect for smooth visual appeal **Interactive Controls**: - Reset button to randomize initial conditions - Toggle trail button to show/hide the trail effect - Click anywhere on the canvas to set custom initial positions **Technical Details**: - Uses proper double pendulum differential equations - Multiple physics steps per frame for numerical stability - Trail system with aging and color gradients - Responsive canvas that adapts to window size The chaotic nature becomes apparent as the pendulum creates complex, unpredictable patterns. The colorful trail beautifully visualizes the sensitive dependence on initial conditions that makes the double pendulum a classic example of deterministic chaos.

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

modelglm-4.5-air
vendorZ.ai · GLM
harnesspi-agent
generated2026-08-01

EVALUATION

4/5 working

Double pendulum swings with a colorful fading trail; click resets position, drag alters trajectory dramatically.

Vision grade · anthropic/claude-sonnet-5

MEASUREMENTS

Raw readings from the capture, not a verdict — the grade above is the only judgement. Percentages are how much of the screen changed; the measure under-reports sparse motion on a dark background.

idle motion1.7%
on click3.6%
on drag3.3%
on wheel6.1%
on enter + space5.3%
on arrow keys4.9%
on w/a/s/d4.6%
frame spread20.5 / 255
console errors0
js errors none

METRICS

runtime55.0s
tokens in6.3k
tokens out3.9k
cached6.3k
cost / run$0.0034