Calculate Derivative while Runge Kutta

531 Views Asked by At

I am thinking about writing a C++ code to solve an ODE using Runge Kutta method. As you know, RK method calculates the state space vector $X'$ in a few mid-points and uses these mid-points for obtaining the next state. The problem that I am working on is not a simple

$$X'=f(X,t)$$

but it is a

$$X'=f(X,X',X'',t)$$

I want to know if I can use these calculated midpoints for calculation of $X'$ and $X''$ to avoid extra calculation?

note that: $X_i'$ does not depend to $i^{th}$ element of $X'$ but to the other elements of $X'$. So, no recursive dependency happens in the first order of the derivative.