! APMonitor Modeling Language
! http://www.apmonitor.com

! Pendulum - Index 0 DAE = ODE
Model pend0
  Parameters
    m = 1
    g = 9.81
    s = 1
  End Parameters

  Variables
    x = 0
    y = -s
    v = 1
    w = 0
    lam = m*(1+s*g)/2*s^2
  End Variables

  Equations
    $lam = (-4*lam*(x*v+y*w) - 1.5*g*m*w)/(x^2+y^2)
    $x = v
    $y = w
    m*$v = -2*x*lam
    m*$w = -m*g - 2*y*lam
  End Equations
End Model