Skip to content

DiffSim: Projectile control demo🔗

This interactive demo shows how differentiable simulation can be used to solve inverse problems in projectile motion. Click on targets to see how the optimal launch parameters are calculated!

Interactive Projectile Motion with Differential Programming

Interactive Projectile Motion with Differential Programming

Adjust parameters to hit the target, or use automatic differentiation to optimize the trajectory. The AI uses Adam optimizer with proper convergence criteria to prevent oscillation.

Target Distance
40.0 m
Landing Distance
-- m
Error Distance
-- m
Loss Function
--
Optimization Step
0
Gradient Norm
--

Mathematical Framework & Optimization

1. Analytical Projectile Motion:
x(t) = v₀ cos(θ) × t
y(t) = v₀ sin(θ) × t - ½gt²
Time of flight: T = 2v₀sin(θ)/g, Range: R = v₀²sin(2θ)/g
2. Loss Function & Gradients:
L = (x_final - x_target)²
∇L = [∂L/∂θ, ∂L/∂v₀]
Computed via finite differences: ∂L/∂p ≈ [L(p+ε) - L(p)]/ε
3. Adam Optimizer with Convergence Criteria:
m_t = β₁m_{t-1} + (1-β₁)∇L (momentum)
v_t = β₂v_{t-1} + (1-β₂)(∇L)² (adaptive learning)
θ_new = θ - α × m̂_t / (√v̂_t + ε)
Stops when: |∇L| < 0.01 OR loss < 0.1 OR loss increase detected
Projectile Trajectory
Optimization Progress