# How to express a 2nd order ODE as 1st order ODE's? [duplicate]

Is there a built-in function that expresses a 2nd order ODE as 1st order ODE's? If not, how can one decouple a 2nd ODE to a first-order one using Mathematica?

I couldn't find it here: Why is NDSolve solving in term of two 1st order ODE slower than 2nd order?

• Dec 3 '19 at 15:30
• @Michael E2 Thanks! Dec 3 '19 at 16:41
• Dec 3 '19 at 20:27

## 1 Answer

Using NonlinearStateSpaceModel

fode = NonlinearStateSpaceModel[m y''[t] + c y'[t] + k y[t] == f[t], {y[t], y'[t]}, f[t], {}, t]


To extract the parts

With[{res = NonlinearStateSpaceModel[fode, {x1[t], x2[t]}] // Normal},
ApplySides[MatrixForm@*Transpose@*List, D[res[[2]], t] == res[[1, 1]]]]


• the NonlinearStateSpaceModel is really neat, thanks! But this raises the question: How come I couldn't find it in the documentation while searching for a built-in function that converts an ODE to a first-order system? Dec 4 '19 at 15:36