# Which ODE solver should I use for finding second derivative?

I was going to do the recursive least square algorithm in Xcos but I having some trouble to find the second derivative. The results of the second derivative differ a lot depending which solver I use.

First of all, I want to compute the $y(t)$ output of this transfer function:

$$G(s) = \frac{Y(s)}{U(s)} = \frac{K}{as^2 + bs + 1}$$

Where:

$$Y(s)[as^2 + bs + 1] = U(s)[K]$$ $$Y(s)as^2 + Y(s)bs + Y(s)1 = U(s)K$$ $$ay''(t) + by'(t) + y(t) = Ku(t)$$ $$y(t) = Ku(t) - ay''(t) - by'(t)$$

Unknows are: $K$, $a$ and $b$

But let's assume that I know them. Then I set up this simulation. Where $K=5$, $a=2$, $b=3$. I use Runge-Kutta 4(5).

The result is:

Where the green line is $y(t)$ (transfer function output) and black is the computed $y(t)$. Not successful at all. I change to Dormand-Prince 4(5). The result is: I use Implicit Runge-Kutta 4(5) Question:

Which solver should I use?

It works if I do this in OpenModelica. But the problem is that OpenModelica is not for control engineering, only simulation of dynamical systems using dynamical blocks of complete blocks.

Here is the answer.

I choose Runge-Kutta 4(5) with this setup: Change the du/dt block to s-laplace block. And the result is: 