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

Runge-Kutta 4th Order error approximation for varied time-steps

from __future__ import division import numpy as np import matplotlib.pyplot as plt def f(x, t): #function return -x def exact(t): #exact solution return np.exp(-t) def Rk4(x0, t0, dt): #Runge-Kutta Fourth Order Error …
infinitylord
  • 175
  • 7
2
votes
1 answer

Numerical stability of ODE system

I have to perform a numerical solving of an ODE system which has the following form: du_j/dt = f_1(u_j, v_j, t) + g_1(t)v_(j-1) + h_1(t)v_(j+1), dv_j/dt = f_2(u_j, v_j, t) + g_2(t)u_(j-1) + h_2(t)u_(j+1), where u_j(t) and v_j(t) are complex-valued…
2
votes
1 answer

Efficient use of Functions as Arguments

I would like to implement a generic Runge-Kutta step function in Julia language. In Python I can just pass a function as one of the arguments that this RK4 function gets as input. Is there a performance penalty if I do it like that in Julia? My…
Ohm
  • 2,312
  • 4
  • 36
  • 75
2
votes
1 answer

4th Order Runga Kutta Method - Diffusion equation - Image analysis

This is a question of speed. I'm trying to solve a diffusion equation which has three behavior states where: Lambda == 0 equilibrium Lambda > 0 max diffusion Lambda < 0 min diffusion Bottleneck is the else statement in the diffusion operator…
William Baker Morrison
  • 1,642
  • 4
  • 21
  • 33
2
votes
1 answer

Pendulum integration. Overflow. Python

I wrote a code for calculating the velocity and force of a pendulum using 4th order Runge-Kutta integration, unfortunately I cannot run it since I get this error: 30: RuntimeWarning: overflow encountered in double_scalars th2 = th[j+1] +…
Estefy
  • 424
  • 2
  • 6
  • 20
2
votes
1 answer

Runge-Kutta code not converging with builtin method

I am trying to implement the runge-kutta method to solve a Lotka-Volterra systtem, but the code (bellow) is not working properly. I followed the recomendations that I found in other topics of the StackOverflow, but the results do not converge with…
user3369932
  • 87
  • 1
  • 9
2
votes
2 answers

Python: Fourth Order Runge-Kutta Method

from math import sin from numpy import arange from pylab import plot,xlabel,ylabel,show def answer(): print('Part a:') print(low(x,t)) print('First Graph') print('') def low(x,t): return 1/RC * (V_in - V_out) a = 0.0 b =…
kassidylynnk
  • 21
  • 1
  • 2
2
votes
3 answers

Using Runge-Kutta to solve coupled differential equations

I have a system of coupled equations: the hydrostatic equilibrium equation, the mass continuity equation, and an equation of state of the ideal gas. These are, in mathematical grammer, \frac{dP}{dr}=- \rho*g, where \rho is the density and g is the…
inquiries
  • 385
  • 2
  • 7
  • 20
2
votes
1 answer

Need help fixing my implementation of RK4

I'd appreciate it if someone more experienced on implementation would help me to spot my logical flaw in my current code. For the past couple of hours I've been stuck with the implementation and testing of various step sizes for the following RK4…
Spaced
  • 231
  • 1
  • 14
2
votes
3 answers

Howto pass a function to a function in Python?

I am a beginner/intermediate in Python. I have coded a 4th-order Runge-Kutta method (RK4) into Python. It is basically solving a pendulum, but that is not the point here. I want to improve the RK4 method in the following way: I want to be able to…
seb
  • 2,251
  • 9
  • 30
  • 44
2
votes
1 answer

2D rigid body physics using runge kutta

Does anyone know any c++/opengl sourcecode demos for 2D rigid body physics using runge kutta? I want to build a physics engine but I need some reference code to understand better how others have implemented this.
Kachinsky
  • 573
  • 1
  • 7
  • 20
1
vote
3 answers

Runge Kutta in C for Lorenz equation

i'm trying to compute the Lorenz system using Runge Kutta method, but i can't find where my code have an error. When I run it, the system goes to a static point and i should obtain a butterfly (the Lorenz attractor). I think it's something on the…
PerroNoob
  • 843
  • 2
  • 16
  • 36
1
vote
1 answer

N-Body Problem - Is my application of Runge-Kutta fourth order method for simulating the motion of the planets in the solar system correct?

When i set my timestep to dt = 3600*24 (1 day in secs) and run my simulation for 365 steps,I would expect Earth to make one full rotation around the sun. However the result is not even close to a quarter orbit. The number of steps I need to make one…
Fergie
  • 11
  • 3
1
vote
0 answers

Why my plot cannot show sigmoid graph? Whereas I already input to the function

Hello I am confused with my code in MATLAB. I am use Runge-Kutta orde 4th. Why my plot cannot show sigmoid whereas I already input the sigmoid function into my code. Please somebody can explain how to fix it. This is my code. clc;clear; %input…
Cindy
  • 19
  • 3
1
vote
1 answer

Python: Finding energy levels and plotting wavefunction of harmonic potential using RungeKutta numerical method

To make this problem simpler, I have changed the code to plot only 1 graph that plots the wavefunction against the position and also prints the energy level values for a harmonic potential for any n value. I KNOW that the energy levels are correct,…
Kasattack
  • 11
  • 2