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
2
votes
1 answer

How to use Numba to optimize stochastic Runge-Kutta?

I am trying to optimize a stochastic differential equation. What it means for me is that I have to solve a set of Mmax independent differential equations. For that task I use Numba, but I have the feeling I am doing it wrong, as even if I do not get…
J.Agusti
  • 161
  • 11
2
votes
0 answers

How to implement the 4th order Runge-Kutta method with a constraint on a derivative?

I am trying to solve a set of two 2nd order differential equations using the 4th order Runge-Kutta method. For this purpose, I have rewritten the two 2nd order equations into four 1st order equations, so that the problem gets reduced to solving four…
2
votes
1 answer

Which is faster in C? Allocating a fixed sized array on the stack many times, or allocating it once on the heap and accessing it many times?

I'm learning C by myself using real-world examples. Given my background (physics) I'm implementing a 4th order Runge-Kutta method. I have a function which performs a single RK4 step with arbitrary input ODE system and timestep. When calculating…
Martin
  • 121
  • 1
  • 9
2
votes
1 answer

Using 4th order Runge Kutta to solve the 2nd order differential equation of a damped oscillator

So im tasked with using the 4th order Runge Kutta Meathod to solve the 2nd order differential equation of a damped occilator. my function for the runge-kutta meathod looks as such def RungeKutta(f,y0,x): y=np.zeros((len(x),len(y0))) …
peter
  • 23
  • 4
2
votes
1 answer

Drawing Poincare Section using Python

I was about to plot a Poincare section of the following DE, which is quite meaningful to have a periodic potential function V(x) = - cos(x) in this equation. After calculating the solution using RK4 with time interval dt = 0.001, the one that…
2
votes
1 answer

Plotting the results of the differential equation plotted suing RK4 method

I have a code for the solution of the Lane-Emden equation which is giving correct values after solving but when I plot those lists using matplotlib, I am getting blank images and not correct plots. import numpy as np import matplotlib.pyplot as…
2
votes
1 answer

Long double precision error saturation in RK integrator

I'm trying to write an integrator which uses long doubles for very high precision. I know that my system architecture has long double support, but for some reason, the precision of my integrator maxes out at 16 significant digits. Here's some code…
David
  • 424
  • 3
  • 16
2
votes
1 answer

Solving 3 coupled nonlinear differential equations using 4th order Runge Kutta in python

I am trying to plot orbits of a charged particle around a Reissner–Nordström blackhole(Charged blackhole). I have three 2nd order differential equations as well as 3 first order differential equations. Due to the nature of the problem each…
2
votes
2 answers

(MATLAB/C++) Is it possible to pass functions as arguments to C++ MEX functions?

I have only been working with mex functions for a couple of weeks, and am now working on writing a Runge-Kutta, 4th order solver as a C++ mex function. I am wondering whether it is possible to take a function as an input. Effectively, it would be…
TGreenhill
  • 23
  • 3
2
votes
1 answer

How to solve Lorenz 96 model using Runge–Kutta method?

I have written the below code to solve Lorenz 96 model using Runge–Kutta method, but the results are not reliable as can be seen in the below figure: The correct relationship between three variables is as follows: How can I modify the code to…
2
votes
2 answers

Runge-Kutta : error while solving a second order differential equation

I am trying to solve a third order non linear differential equation. I have tried to transform it and I've obtained this problem which is a second order problem: I am trying to implement a fourth order Range-Kutta algorithm in order to solve it by…
2
votes
1 answer

Julia:Calculation time of Runge Kutta method

I'm trying to calculate a matrix-form ODE, i.e., (∂/∂t)ψ = -iHψ ,where ψ is a vector and H is a (time-independent) matrix. I have two problems. 1. Difference of calculation time between DifferentialEquations.jl and Runge Kutta code I calculated the…
yosuga
  • 341
  • 1
  • 10
2
votes
2 answers

How to calculate movement of pendulum?

I am trying to make a simple simulation of pendulum using Runge–Kutta fourth-order method. I am using p5.js. Usually it calculates the angles properly but sometimes it just starts spinning randomly etc. I have no idea how to resolve this issue it…
half0man
  • 21
  • 4
2
votes
1 answer

Matlab - take gradient of a matrix at any arbitrary point

I am trying to implement Runge-Kutta's 4th order integration method in matlab on a 2-d matrix (x, y). The matrix contains a height value (float) at each point. The idea is place a particle in the matrix and watch it's path as it gets 'pushed'…
Aaron
  • 1,693
  • 4
  • 26
  • 40
2
votes
1 answer

Unexpectedly low error for a numerical integrator with certain equations of motion

I have an RKF7(8) integrator whose output I've verified with several simple test functions. However, when I use it on the equation of motion I'm interested in, the local truncation errors are suddenly very small. For a timestep of around 1e-1, my…
1 2
3
24 25