# Model Constrained Systems as DAEs

#### Derive the governing equations using Newton's second law of motion, and .

 In[1]:= Xdeqns = {m x''[t] == (\[Lambda][t]/l) x[t], m y''[t] == (\[Lambda][t]/l) y[t] - m g};

#### Express the fixed length of the pendulum rod as an algebraic constraint.

 In[2]:= Xaeqns = {x[t]^2 + y[t]^2 == l^2};

#### The pendulum is released from the horizontal position with a vertical velocity of 1.

 In[3]:= Xics = {x[0] == 1, y[0] == 0, x'[0] == 0, y'[0] == 1};

#### Specify the physical parameters for the pendulum system.

 In[4]:= Xparams = {g -> 9.81, m -> 1, l -> 1};

#### Solve the high-index DAE and visualize the system.

 In[5]:= XpendulumSol = First[NDSolve[{deqns, aeqns, ics} /. params, {x, y, \[Lambda]}, {t, 0, 15}, Method -> {"IndexReduction" -> Automatic}]];
 In[6]:= XShow[{ParametricPlot[ Evaluate[{x[t], y[t]} /. pendulumSol], {t, 0, 15}, PlotStyle -> {DotDashed}], Graphics[{{Red, Line[{{0, 0}, {0.5, -Sqrt[3]/2}}]}, {Blue, Disk[{0.5, -Sqrt[3]/2}, 0.1]} }]}, ImageSize -> Medium]
 Out[6]=