Let a system of differential equations has the following constraint:
$$\frac{d^2x}{dt^2}=f_x(t, x,\frac{dx}{dt})$$
$$\frac{d^2y}{dt^2}=f_y(t, y,\frac{dy}{dt})$$
if $$\frac{dx}{dt} > \frac{dy}{dt}$$
and
$$\frac{d^2x}{dt^2}=g_x(t, x,\frac{dx}{dt})$$
$$\frac{d^2y}{dt^2}=g_y(t, y,\frac{dy}{dt})$$
otherwise.
Obviously, There is a hard nonlinearity in this system of equations. Actually, when two rigid bodies collide, this kind of change in the governing equations may happen. The worst is that the condition is defined based on the "speeds" here, not on the "positions'.
Furthermore, in this case, the discontinuity is not in the right-hand side. But is in the dynamic of system itself.
The implicit numerical algorithms (for example: implicit Runge Kutta's) seem not to help here; Maybe, because they work with the end-point data of the time step and due to the conditional behavior of this system of equations, we cannot rely on the end-step data.
The question is: Is it possible to solve this system by the MATLAB ODE functions? If so, which algorithm is more reliable? Is it possible to feed the system of equations along with its condition entirely to the algorithm (as a odefunction) without any intervention?
Thanks in advance