- #1
RandomGuy88
- 406
- 6
Hi,
I am having a problem implementing 4th Order Runge Kutta (RK4) to solve a non linear ODE.
dy/dt = B(t) - A(t)*y(t)^2 where the coefficients A(t) and B(t) are specific to the problem I am working on.
For the test case I am running I specify a sinusoidal signal and from this signal I calculate A(t) and B(t). While the magnitudes of these coefficients are functions of time they are not functions of the frequency of the sinusoidal function I am specify. I am sure you are all familiar with the algorithm but having it will help me explain.
y(i+1) = y(i) + h/6*(k1 + 2k2 + 2k3 + k4)
k1, k2, k3 and k4 are functions of A(t), B(t) and y(t). As I mentioned above the coefficients A and B are not functions of the frequency of the sinusoid so the values of k1, k2, k3 and k4 are also not functions of the frequency.
My problem is that the values of the k coefficients are quite large. So when I use a high frequency signal the large values of k are compensated by the very small value of h so that the second term on the right hand side h/6*(k1 ...) is the same order of magnitude as y(i). If the frequency is small then I would think I could use a larger timestep h but the k coefficients are still very large so h/6*(k1 ...) >> y(i) and the method is unstable.
Is there anything I can do other than just using a very small time step for the low frequency cases? Perhaps some way of scaling the coefficients? Or should I just use a different method? It just seems wrong that for a lower frequency I need a smaller time step.
Thanks for your help.
I am having a problem implementing 4th Order Runge Kutta (RK4) to solve a non linear ODE.
dy/dt = B(t) - A(t)*y(t)^2 where the coefficients A(t) and B(t) are specific to the problem I am working on.
For the test case I am running I specify a sinusoidal signal and from this signal I calculate A(t) and B(t). While the magnitudes of these coefficients are functions of time they are not functions of the frequency of the sinusoidal function I am specify. I am sure you are all familiar with the algorithm but having it will help me explain.
y(i+1) = y(i) + h/6*(k1 + 2k2 + 2k3 + k4)
k1, k2, k3 and k4 are functions of A(t), B(t) and y(t). As I mentioned above the coefficients A and B are not functions of the frequency of the sinusoid so the values of k1, k2, k3 and k4 are also not functions of the frequency.
My problem is that the values of the k coefficients are quite large. So when I use a high frequency signal the large values of k are compensated by the very small value of h so that the second term on the right hand side h/6*(k1 ...) is the same order of magnitude as y(i). If the frequency is small then I would think I could use a larger timestep h but the k coefficients are still very large so h/6*(k1 ...) >> y(i) and the method is unstable.
Is there anything I can do other than just using a very small time step for the low frequency cases? Perhaps some way of scaling the coefficients? Or should I just use a different method? It just seems wrong that for a lower frequency I need a smaller time step.
Thanks for your help.