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

Understanding the local truncation error of an adaptive Runge Kutta integrator

I'm implementing an RKF4(5) integrator, and I can't figure out if my code is working and I don't understand local truncation error, or if my code isn't working. I apologize for the size of the code block, but the minimum reproducible example is…
2
votes
2 answers

Modeling the trajectory of the planet around the sun. Ellipse is not closing

I was trying to create the projection of planets around the sun. Using the RungeKutta I'm trying to project and create the matplotlib graph. However, the out ellipse is not closing. Could you please help me, where exactly I'm doing the mistake? Used…
2
votes
1 answer

runge kutta for system of elastic pendulum

I'm trying to solve the system with python:
2
votes
1 answer

solve_ivp error: 'Required step size is less than spacing between numbers.'

Been trying to solve the newtonian two-body problem using RK45 from scipy however keep running into the TypeError:'Required step size is less than spacing between numbers.' I've tried different values of t_eval than the one below but nothing seems…
Linus
  • 147
  • 4
  • 15
2
votes
1 answer

Implementing modular Runge-kutta 4th order method for a n-dimension system

i'm trying to make my runge-kutta 4th order code modular. I don't want to have to write and declare the code everytime I use it, but declare it in a .hpp and a .cpp file to use it separetely. But i'm having some problems. Generally I want to solve a…
Luguecos
  • 131
  • 1
  • 1
  • 9
2
votes
2 answers

will specifying time evaluate will override timestep select by RK45 method? (scipy.integrate.solve_ivp)

from https://docs.scipy.org/doc/scipy/reference/generated/scipy.integrate.solve_ivp.html with sol = scipy.integrate.solve_ivp(fun, t_span, y0, method='RK45', t_eval=None, dense_output=False, events=None, vectorized=False, **options) t_eval is…
M lab
  • 224
  • 1
  • 10
2
votes
1 answer

Solving 2nd order differential equations wrt this code

I cannot write the program which is solving 2nd order differential equation with respect to code I wrote for y'=y I know that I should write a program which turn a 2nd order differential equation into two ordinary differential equations but I don!t…
user519955
  • 121
  • 4
2
votes
0 answers

Implementing a Runge-Kutta 4 method for 3 body problem in Python

I'm trying to implement an RK4 method in Python to solve for the Sun, Earth and Jupiter system. This code works for Halley's comet, when I have 4 ODEs to solve instead of 8, I've tried extending my method to 8 ODEs but now I just keep getting a…
mitsterful
  • 21
  • 1
  • 2
2
votes
2 answers

Numerically solving Lotka-Volterra ODE in R

Disclaimer: Cross-post on Stack Computational Science Aim: I am trying to numerically solve a Lotka-Volterra ODE in R, using de sde.sim() function in the sde package. I would like to use the sde.sim() function in order to eventually transform this…
user213544
  • 2,046
  • 3
  • 22
  • 52
2
votes
1 answer

Solving the Lorentz model using Runge Kutta 4th Order in Python without a package

I wish to solve the Lorentz model in Python without the help of a package and my codes seems not to work to my expectation. I do not know why I am not getting the expected results and Lorentz attractor. The main problem I guess is related to how to…
2
votes
1 answer

Runge Kutta Algorithm using while loop

I am currently trying to get the Runge Kutta 4 Integration to work, but it outputs the following: Runge Kutta value: inf While it is supposed to give a value in the range of: Runge Kutta value: 8.476271005220534e+16 I used the following code, but…
Ian Ronk
  • 55
  • 2
  • 16
2
votes
3 answers

Runge-Kutta 4th order to solve 2nd order ODE using C++

I tried to write a code to solve a 2nd order ODE but somehow it did not work as I intended. the equation is 2y" + 5y' +3y = 0 ,y(0) = 3 and y'(0) = -4 The final answer will be y(x) = 3-4x << edit this is wrong therefore y(1) = -1 and y'(1) = -4 But…
Jamesbell
  • 23
  • 1
  • 5
2
votes
0 answers

Heat equation calculation gets unstable for different differentiation matrices

I would like to solve the heat equation in one dimension using the RK4-algorithm. Now I can either write the heat equation as d_t u = d_x(A d_x u) or d_t u = A d_x^2(u) with A a constant. I wanted to compare both methods, and thus wrote the…
arc_lupus
  • 3,942
  • 5
  • 45
  • 81
2
votes
1 answer

numpy.float64 error in my Runge-Kutta 4th-order method for a series of differential equations

This is a 4th order Runge-Kutta method I've made to eventually graph some differential equations. The goal is to create a 4 by 100,000x.1 array that gives me the value of x, y, dx, dy at every point in the timestep, so that I can graph any…
Jdubb
  • 39
  • 2
  • 6
2
votes
1 answer

RK4-method and Euler method working only for certain formulae

I tried to write an algorithm for solving the non-linear ODE dr/dt = r(t)+r²(t) which has (one possible) solution r(t) = r²(t)/2+r³(t)/3 For that I implemented both the euler method and the RK4 method in python. For error checking I used…
arc_lupus
  • 3,942
  • 5
  • 45
  • 81