Skip to main content
Specific problem addressed
Source Link
Jens
  • 97.9k
  • 7
  • 215
  • 510

Edit: application to the original equations

Here is how the above can be applied to the original equations in the question (after I fixed the copying errors):

eqs = {Derivative[2][x][t] + 
     l0 Sin[ϕ[
        t]] (Sin[θ[t]] (Derivative[1][θ][t]^2 + 
           Derivative[1][ϕ][t]^2) - 
        Cos[θ[t]] Derivative[2][θ][t]) - 
     l0 Cos[ϕ[
        t]] (2 Cos[θ[t]] Derivative[1][θ][
          t] Derivative[1][ϕ][t] + 
        Sin[θ[t]] Derivative[2][ϕ][t]) == 0, 
   Derivative[2][y][t] + 
     l0 Cos[θ[
        t]] (-2 Sin[ϕ[t]] Derivative[1][θ][
          t] Derivative[1][ϕ][t] + 
        Cos[ϕ[t]] Derivative[2][θ][t]) - 
     l0 Sin[θ[
        t]] (Cos[ϕ[t]] (Derivative[1][θ][t]^2 + 
           Derivative[1][ϕ][t]^2) + 
        Sin[ϕ[t]] Derivative[2][ϕ][t]) == 0, 
   l0 Cos[θ[t]] Derivative[1][θ][t]^2 + 
     Derivative[2][z][t] + 
     l0 Sin[θ[t]] Derivative[2][θ][t] == 0, 
   l0 (-g m Cos[θ[t]] - 
       l0 Cos[θ[t]] Sin[θ[t]] Derivative[1][ϕ][
          t]^2 + Cos[θ[
          t]] (-Sin[ϕ[t]] Derivative[2][x][t] + 
          Cos[ϕ[t]] Derivative[2][y][t]) + 
       Sin[θ[t]] Derivative[2][z][t] + 
       l0 Derivative[2][θ][t]) == 0, 
   l0 Sin[θ[
       t]] (2 l0 Cos[θ[t]] Derivative[1][θ][
         t] Derivative[1][ϕ][t] - 
       Cos[ϕ[t]] Derivative[2][x][t] - 
       Sin[ϕ[t]] Derivative[2][y][t] + 
       l0 Sin[θ[t]] Derivative[2][ϕ][t]) == 0};

{eqs2, {velocities}} = 
  Reap[eqs /. 
    Derivative[n_][f_][t] :> 
     Derivative[n - 1][Sow[Subscript[v, f], derivs]][t], derivs];

vs = DeleteDuplicates[velocities];

eqs3 = Map[#[t] == D[Last[#][t], t] &, vs];

TraditionalForm@TableForm[Join[eqs2, eqs3]]

eqs

This is the system of first-order equations which corresponds exactly to the second-order equations.

It's not clear from the question whether any further linearization is desired.

Edit: application to the original equations

Here is how the above can be applied to the original equations in the question (after I fixed the copying errors):

eqs = {Derivative[2][x][t] + 
     l0 Sin[ϕ[
        t]] (Sin[θ[t]] (Derivative[1][θ][t]^2 + 
           Derivative[1][ϕ][t]^2) - 
        Cos[θ[t]] Derivative[2][θ][t]) - 
     l0 Cos[ϕ[
        t]] (2 Cos[θ[t]] Derivative[1][θ][
          t] Derivative[1][ϕ][t] + 
        Sin[θ[t]] Derivative[2][ϕ][t]) == 0, 
   Derivative[2][y][t] + 
     l0 Cos[θ[
        t]] (-2 Sin[ϕ[t]] Derivative[1][θ][
          t] Derivative[1][ϕ][t] + 
        Cos[ϕ[t]] Derivative[2][θ][t]) - 
     l0 Sin[θ[
        t]] (Cos[ϕ[t]] (Derivative[1][θ][t]^2 + 
           Derivative[1][ϕ][t]^2) + 
        Sin[ϕ[t]] Derivative[2][ϕ][t]) == 0, 
   l0 Cos[θ[t]] Derivative[1][θ][t]^2 + 
     Derivative[2][z][t] + 
     l0 Sin[θ[t]] Derivative[2][θ][t] == 0, 
   l0 (-g m Cos[θ[t]] - 
       l0 Cos[θ[t]] Sin[θ[t]] Derivative[1][ϕ][
          t]^2 + Cos[θ[
          t]] (-Sin[ϕ[t]] Derivative[2][x][t] + 
          Cos[ϕ[t]] Derivative[2][y][t]) + 
       Sin[θ[t]] Derivative[2][z][t] + 
       l0 Derivative[2][θ][t]) == 0, 
   l0 Sin[θ[
       t]] (2 l0 Cos[θ[t]] Derivative[1][θ][
         t] Derivative[1][ϕ][t] - 
       Cos[ϕ[t]] Derivative[2][x][t] - 
       Sin[ϕ[t]] Derivative[2][y][t] + 
       l0 Sin[θ[t]] Derivative[2][ϕ][t]) == 0};

{eqs2, {velocities}} = 
  Reap[eqs /. 
    Derivative[n_][f_][t] :> 
     Derivative[n - 1][Sow[Subscript[v, f], derivs]][t], derivs];

vs = DeleteDuplicates[velocities];

eqs3 = Map[#[t] == D[Last[#][t], t] &, vs];

TraditionalForm@TableForm[Join[eqs2, eqs3]]

eqs

This is the system of first-order equations which corresponds exactly to the second-order equations.

It's not clear from the question whether any further linearization is desired.

Source Link
Jens
  • 97.9k
  • 7
  • 215
  • 510

Here is how to do it for a smaller working example:

eqs = {x''[t] == -y[t], y''[t] == x[t]};

{eqs2, {velocities}} = 
 Reap[eqs /. 
   Derivative[n_][f_][t] :> 
    Derivative[n - 1][Sow[Subscript[v, f], derivs]][t], derivs]

(*
==> {{Derivative[1][Subscript[v, x]][t] == -y[t], 
  Derivative[1][Subscript[v, y]][t] == x[t]}, {{Subscript[v, x], 
   Subscript[v, y]}}}
*)

eqs3 = Map[#[t] == D[Last[#][t], t] &, velocities]

(*
==> {Subscript[v, x][t] == Derivative[1][x][t], 
 Subscript[v, y][t] == Derivative[1][y][t]}
*)

solution = {x[t], y[t]} /. 
   First@NDSolve[
     Join[eqs2, 
      eqs3, {x[0] == 0, y[0] == 1, Subscript[v, x][0] == 1, 
       Subscript[v, y][0] == -1}], 
     Join[{x, y}, velocities], {t, 0, 10}];