If there are two 2nd order differential terms in the equations than getting the state-space formulation is not very difficult. That I have seen here for the 2nd order terms with two different variables.. But I am facing a typical problem. Another second-order differential term is a function of the first term and it has time-dependent coefficients.
Here I am mentioning the system of equations. $$\ddot{Y} + [A] Y + B \ddot{y_b} + C y_b = f(t)$$ $Y=[y_1 y_2 ..... y_n ]^T$ is a column vector of variables. Here $A$ is a coefficient matrix and $B, C$ are coefficient vectors with known values and $y_b$ is a scaller variable. It is given as, $y_b = G (y_n + \alpha y_n^3)cos(\Omega t)$ After substituting expression of $y_b$, the equation will have more than one 2nd order derivative term and they will have time dependent coefficients.
In such cases, transformation to state space is not possible, because of $Cos(\Omega t)$ is multiplied to the $\ddot {Y}$ terms. In addition to it becomes typically nonlinear also.
I have used Matlab function odeToVectorField(which does the state-space conversion automatically) and matlabFunction and then solved it using ode45. But, now I want to apply Runge Kutta 4th order or some other method, which can do faster simulation. Can someone help me to deal with this problem?