Questions tagged [runge-kutta]

Runge–Kutta methods are an important family of implicit and explicit iterative methods, which are used in temporal discretization for the approximation of solutions of ordinary differential equations.

In numerical analysis, the Runge–Kutta methods (German pronunciation: [ˌʁʊŋəˈkʊta]) are an important family of implicit and explicit iterative methods, which are used in temporal discretization for the approximation of solutions of ordinary differential equations. These techniques were developed around 1900 by the German mathematicians C. Runge and M. W. Kutta.

Wikipedia definition about Runge-Kutta

379 questions
1
vote
2 answers

How to change object in for loop each time loop is run

I'm trying to keep the detail to the minimum of what is relevant in this question, but I'll certainly expand on anything that makes my post clearer. I'm pretty new to C++ so forgive me for what's perhaps an obvious question, I couldn't even…
user142340
  • 137
  • 1
  • 1
  • 4
1
vote
1 answer

ODE placement in an ODE system give different results

I have the following code: def multirk4(funcs, x0, y0, step, xmax): n = len(funcs) table = [[x0] + y0] f1, f2, f3, f4 = [0]*n, [0]*n, [0]*n, [0]*n while x0 < xmax: y1 = [0]*n for i in range(n): f1[i] = funcs[i](x0,…
1
vote
2 answers

Runge-Kutta (RK4) in Haskell, type system issue

I'm trying to implement 4th order Runge-Kutta in Haskell, but I find it difficult to use the Haskell type system for this task. Can someone help? I wish to change the 'State' and 'DState' types into typeclasses in the following code: data State =…
tero
  • 153
  • 4
1
vote
1 answer

Error with Runge-Kutta 4th order integrator

I've been working on a 4th Order Runge-Kutta solver, and am having some difficulties. I've written the solver based on the article on gafferongames, but when I run a small contained example, the errors I'm getting are far far worse than what I was…
Will P
  • 192
  • 1
  • 9
1
vote
2 answers

Runge-Kutta (RK4) derivative in C++

Hello I created a small simulation of movement in C++. There are material points that move and bounce when hit the spheres I wanted to demonstrate to students differences beetwen Euler, Runge-Kutta and MidPoint methods. But I did a mistake somewhere…
Yoda
  • 17,363
  • 67
  • 204
  • 344
1
vote
2 answers

Fourth-order Runge–Kutta method (RK4) collapses after a few iterations

I'm trying to solve: x' = 60*x - 0.2*x*y; y' = 0.01*x*y - 100* y; using the fourth-order Runge-Kutta algorithm. Starting points: x(0) = 8000, y(0) = 300 range: [0,15] Here's the complete function: function [xx yy time r] = rk4_m(x,y,step) A = 0; B…
Grzegorz Piwowarek
  • 13,172
  • 8
  • 62
  • 93
1
vote
1 answer

Writing Runge-Kutta ODE solver using gsl

It's been some time since I did any C/c++, but I wanted to write an ODE solver using the gsl library to solve the following ODE set $$ u'(r)=up(r)$$ $$ up'(r)=-(2*(r-1)/(r*(r-2)))*up(r)-((r*r/((r-2)*(r-2)))-(2/r*(r-2)))*u(r) $$ so in the gsl…
fpghost
  • 2,834
  • 4
  • 32
  • 61
0
votes
1 answer

Runge-Kutta-4th-order solution of 3 ODEs MATLAB

Lorenz equations are as follows: Lorenz Equations Parameter values: sigma = 10, b = 8/3, and r = 28. Employ initial conditions of x = y = z = 5 and integrate from t = 0 to 20. For this case, we will use the fourth-order RK method to obtain solutions…
0
votes
0 answers

Performing RK4 between two cluster

I have a simulated data of charged particles in a magnetic field. I have selected clusters, each cluster contains a set of points(x,z) and I want to perform RK4 between the first and second clusters and fill the positions in a histogram. I have…
0
votes
0 answers

Stuck with decimal.InvalidOperation problem

I am trying to solve a system of non linear differential equations by the RK4 method. One of my parameter in that equations is a very small number on the order of 10^{-121} thus to work with more precision I am using Decimal package. But I am stuck…
0
votes
1 answer

Why the RK4 method is not conserving the energy in such an unusual way?

Firstly I precise that I know that the RK4 method is not preserving energy. Though the energy should decrease with slow oscillations, when in my problem such an usual behavior is not seen as i will explain. I want to simulate a double pendulum using…
zgit
  • 11
  • 3
0
votes
2 answers

Avoiding ZeroDivisionError for Runge-Kutta 4(5) solver

I am trying to create a Runge-Kutta 4(5) solver to solve the differential equation y' = 2t with the initial condition y(0) = 0.5. This is what I have so far: def rk45(f, u0, t0, tf=100000, epsilon=0.00001, debug=False): h = 0.002 u = u0 …
JS4137
  • 314
  • 2
  • 11
0
votes
1 answer

How to solve first order system of differential equations using Euler and Runge-Kutta method in Matlab?

I am currently working on Matlab code to solve a second-order differential equation. From there, I convert the equation into a system of two first-order differential equations. I am unsure how solve the system of equations with the initial values…
0
votes
0 answers

Runge Kutta k-vectors in boost

When solving a system of ODEs with boost::odeint, I can have control of every iteration in time by using the stepper.do_step function. This way, I can store u(t). I'm working on an algorithm that requires storing the k-vectors of an s-stage…
0
votes
1 answer

Runge-Kutta curve fitting extremely slow

I am currently trying to do a regression of a function calculated via a RK4 method performed on a non-linear Volterra integral of the second kind. The problem I found is that the code is extremely slow, for 1 call of the curve_fit function (fitt),…