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

Defining variables explicitly vs accessing arrays

I am implementing the Runge-Kutta-Fehlberg method with adaptive step-size (RK45). I define and call my Butcher tableau in a notebook with module FehlbergTableau using StaticArrays export A, B, CH, CT A = @SVector [ 0 , 2/9 , 1/3 , 3/4 ,…
QuantumBrick
  • 249
  • 1
  • 8
3
votes
1 answer

Implementing the 3/8 Runge Kutta in Python with a 2nd order ODE

I want to solve the equation y'' + 5y' + 6y = cos(t). Since this is 2nd order, I first created a system of first order ODEs where dy/dt = z = f(t,y,z) and dz/dt = cos(t) - 5z - 6y = g(t,y,z). I'm a novice with python, and unsure how exactly to…
3
votes
1 answer

Runge-Kutta fourth order method. Integrating backwards

I am using a Runge-Kutta fourth order method to solve numerically the usual equation of motion of a background scalar field in curved spacetime with a quartic potential: $\phi^{''}=-3\left(1+\frac{H^{'}}{3H}\right)\phi^{'}-\lambda\phi^3/H^2$, $'$…
user10367182
3
votes
1 answer

Lotka Volterra with Runge Kutta not desired precision

Population over time (should be the same height at every peak I've programmed a code to simulate a mice and fox population using Runge-Kutta 4th order. But the result is not as wanted to be.. each peak should nearly be at same height I don't think…
Yves Boutellier
  • 1,286
  • 9
  • 19
3
votes
1 answer

Large differences in execution time between MATLAB and R

I'm trying to implement a really simple 4th order Runge-Kutta Method, for solving the ODE y'=f(x,y). I've implemented the algorithm in both R and MATLAB (see below), but for some reason it takes a few minutes to run in MATLAB and a few milliseconds…
Hafez
  • 33
  • 2
3
votes
1 answer

Values for chaotic scattering simulation do not match with the base case

My first post on Stack Overflow, be gentle. I wrote a code to follow the position on the x,y plane of a particle of mass M on a potential V(r) described by a four-dimensional system of equations of motion M(dv/dt)=-grad V(r), dr/dt=v, Which…
spenam
  • 33
  • 3
3
votes
0 answers

Translating for loop to matricial form

I have created the following code to implement the Runge-Kutta RK4 method: import numpy as np u = np.zeros((steps+1, 3)) u[0] = u0.copy() i=0 h6=h/6 for step in range(steps): k1 = f(u[i]) k2 = f(u[i] + (k1/2)*h) k3 = f(u[i]…
D1X
  • 5,025
  • 5
  • 21
  • 36
3
votes
1 answer

Satellite position computation using Runge-Kutta 4

my issue is related to Runge-Kutta 4 (RK4) method and the correct iteration steps required for the state vector of an orbiting satellite. The below code (in Python) describes the motion based on the description as per this link…
pymat
  • 1,090
  • 1
  • 23
  • 45
3
votes
1 answer

Trying to solve second order DE through Euler and Runge_Kutta method

I am trying to solve a spring-mass problem with both Euler and Range-Kutta method and compare the plots. I have written functions for both Euler and Runge-Kutta but after calling the function to my problem , it seems my plot is not showing any data.…
bhjghjh
  • 889
  • 3
  • 16
  • 42
3
votes
1 answer

Runge Kutta problems in JS

I'm attempting a Runge-Kutta implementation for a mass on a spring in Javascript and visualizing it with D3. The purpose is to compare it to Forward Euler and comment on the differences. My FE works fine and plots fine, but the Runge-Kutta is…
Will Luce
  • 1,781
  • 3
  • 20
  • 33
3
votes
3 answers

Runge Kutta method in python

These are the functions I have written: def rk4(f, t0, y0, h, N): t = t0 + arange(N+1)*h y = zeros((N+1, size(y0))) y[0] = y0 for n in range(N): xi1 = y[n] f1 = f(t[n], xi1) xi2 = y[n] + (h/2.)*f1 f2 =…
newpythonuser
  • 133
  • 3
  • 3
  • 7
3
votes
1 answer

Runge Kutta approximation Bessel function, second order differential equation

I'm trying to approximate the Bessel function with Runge-Kutta. I'm using RK4 here cause I don't know what the equations are for RK2 for a system of ODEs.....Basically it's not working, or at least it's not working very well, I don't know…
GeneralPancake
  • 535
  • 2
  • 6
  • 15
3
votes
1 answer

Adaptive time step for Runge-Kutta method ode45 in deSolve

I want to use the explicit Runge-Kutta method ode45 (alias rk45dp7) from the deSolve R package in order to solve an ODE problem with variable step size. According to the deSolve documentation, it is possible to use adaptive or variable time steps…
atreju
  • 965
  • 6
  • 15
  • 36
2
votes
3 answers

Scanf_s warning? Skips User Inputs (topics: Runge-Kutta, Epidemic Simulation)

This is my first post and I have to admit, I am terrible at programming. I am that guy in the class that works his tail off, but can never seem to grasp programming as well as the rest of my classmates. So please be nice, I will try to explain my…
2
votes
1 answer

Why does the numeric error in my implementation of Runge-Kutta not decrease like N^a?

I'm trying to determine how many steps it takes for the Runge-Kutta Method ("RK4") to be within 0.01% of the exact solution of an ordinary differential equation. I'm comparing this to the Euler method. Both should result in a straight line on a…
Dominik
  • 782
  • 7
  • 27
1
2
3
24 25