Prompt training double pendulum implementation
Now I have full context. Here's the implementation plan:
Implementation Plan: "Prompt Training: Double Pendulum"
Libraries Check ✅
- No new libs needed. The double pendulum is naturally 2D, so we'll use the native Canvas API (no Three.js). Math rendering via existing
Mathcomponent (rehype-katex/remark-math).
Files to Create
src/components/DoublePendulumVisualization.astro— Interactive component- 2D Canvas rendering the pendulum arms, bobs, and trailing path
- Controls panel with sliders for:
L₁,L₂,m₁,m₂,θ₁,θ₂ - RK4 integrator (Euler is too unstable for this system)
- Trail of the second bob to reveal chaotic patterns
- Play/Pause & Reset buttons
- Dark theme styling matching Lorenz (background
#0a0a0f, cyan accents)
src/content/blog/double-pendulum.mdx— Blog post- Frontmatter: title, description, pubDate,
aiGenerated: true - Intro: what a double pendulum is, why it's chaotic
- Equations: Lagrangian-derived equations of motion (using
<Math>) - The interactive visualization with controls
- Python code example
- Discussion of sensitivity to initial conditions
- Frontmatter: title, description, pubDate,
Physics
The double pendulum uses Lagrangian mechanics with generalized coordinates (θ₁, θ₂). The equations of motion involve coupled second-order ODEs — we'll implement them as a 4-variable first-order system [θ₁, ω₁, θ₂, ω₂] integrated with RK4 at a small timestep.
Want me to proceed with the implementation?
Let me check the Math component and global styles to fully understand the patterns before writing code.
Good — KaTeX CSS is loaded globally. Now I have full context. Here's my todo list, then I'll implement step by step:
- ✅ Understand existing patterns (Lorenz component, blog post format, libs)
- Create
src/components/DoublePendulumVisualization.astro— Canvas + controls + RK4 physics - Create
src/content/blog/double-pendulum.mdx— Blog post content
Let me start with step 2 — the visualization component:
Now step 3 — the blog post:
Now let me build and verify:
Build succeeds. Let me deploy:
Everything built and deployed successfully. The new blog post is live at https://robertsoare.xyz/blog/double-pendulum/ with:
- 2D Canvas double pendulum simulation with RK4 integration
- 6 interactive sliders: L₁, L₂ (rod lengths), m₁, m₂ (masses), θ₁, θ₂ (starting angles)
- Play/Pause & Reset buttons — adjust sliders then press Reset to restart with new parameters
- Cyan trail on the lower bob showing the chaotic path
- Glowing bobs with size proportional to mass (red = upper, cyan = lower)
- Full blog content with Lagrangian equations, Python RK4 code, and chaos discussion