How to pass a hard coded differential equation through Runge-Kutta 4

后端 未结 1 1253
庸人自扰
庸人自扰 2021-01-18 01:24

I\'m trying to implement Runge-Kutta for example problems dy/dt = y - t^2 + 1 and dy/dt = t * y + t^3 in C# and I cannot seem to get the output I\'m expecting. I have spli

相关标签:
1条回答
  • 2021-01-18 01:46

    You are doing a classical error in the RK4 implementation: Having two variants to position the multiplication with dt to choose from, you are using both.

    It is either

    k2 = dt*f(t+0.5*dt, y+0.5*k1)
    

    or

    k2 = f(t+0.5*dt, y+0.5*dt*k1)
    

    and analogously in the other lines of the algorithm.

    0 讨论(0)
提交回复
热议问题