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

Why do I get run time error Reference at undefined variable?

I am using the Runge-Kutta 4th order method to integrate the motion of a point like satellite. The compilation of the program is OK. But when I try to run it Run time error 112 Reference at undefined variable,array element or function result…
-1
votes
1 answer

RK45 code w an error that says "index 50 is out of bounds for axis 0 with size 50"

Here is my code: import numpy as np import time import matplotlib as plt def fun1(t,y): f=np.exp(-6*t) return (f) def RK45Classic(h,f,t,yold): k1=h*f(t,yold) k2=h*f(t+h/2,yold+k1/2) k3=h*f(t+h/2,yold+k2/2) …
-1
votes
1 answer

Is there a better way to tidy this chuck of code? It is the Runge-Kutta 4th order with 4 ODEs

def xpos(x,y,t): #dx/dt = v_x return vx def ypos(x,y,t): #dy/dt = v_y return vy def xvel(x,y,t): #dv_x/dt = -GMx/r^3 return -G*M*x/((x)**2 + (y)**2)**1.5 def yvel(x,y,t): # dv_y/dt = -GMy/r^3 return -G*M*y/((x)**2 +…
-1
votes
1 answer

midpoint rule for matlab

Hello I was asked to create a matlab code for the midpoint rule. What I have is the code for eulers method, so I have to make some modifications, but I am struggling to do it I have the following function H = heun(f,a,b,ya,M) h = (b-a)/M; T =…
-1
votes
1 answer

python two coupled second order ODEs Runge Kutta 4th order

I am a beginner in python. I have a problem with 2 ODEs that are second order and they are coupled. I want to solve it with Runge Kutta 4th order. I have made 2 matrices.[A] and [B] that V' = A*C + B . But I couldn't get the answer. Can anyone help…
-1
votes
1 answer

Solving Lorenz equation using RK-4 in C++

I wrote the code to solve Lorenz equations using RK-4 method in C++. I have to plot the attractor plot and I have some difficulty in solving the 3 first order coupled differential equation using RK-4 method. Here is my code: /* Solving 3 coupled…
-1
votes
1 answer

Python 3.x Runge Kutta simple orbit

I am in the early stages of creating a program to plot orbits using the Runge-Kutta method, and would like to plot the orbit in 2D, however, no matter what the initial conditions are, i get a straight line. I have seen a similar question but it…
-1
votes
1 answer

system of equation Runge-Kutta 4th order for system of equation using matlab

I need to do matlab code to solve the system of equation by using Runge-Kutta method 4th order but in every try i got problem and can't solve the derivative is (d^2 y)/dx^(2) +dy/dx-2y=0 , h=0.1 Y(0)=1 , dy/dx (0)=-2 {clear all, close all,…
Hussam
  • 13
  • 1
  • 5
-1
votes
1 answer

Runge-Kutta 4 plot time range not limited by tmax

I am trying to solve an ODE using the 4th order Runge Kutta method. The problem is that the defined tmax in my code does not seem to affect the time range of the plot. Changing tmax only affects the curve of the plot. Instead the time range is…
trop
  • 35
  • 1
  • 8
-1
votes
1 answer

Runge Kutta 4 in C++ for Lorenz system

Can someone find the error in my code ? It work ok in the special dots , but the tolerance doesn't fit to the method. My Errorstepper is pretty simple , so i don't think that the problem in it. Please help. #include #include
-1
votes
1 answer

why the numerical result is different (RK45)?

this is the test for equation differential using runge-kutta45: f(x,y)= (-5*x - y/5)^1/8 + 10 why the numerical result is different? I used : function Rk_JL() f(x,y)= (-5*x - y/5)^1/8 + 10 tspan = 0:0.001:n y0 = [0.0, 1.0] return ODE.ode45(f,…
-1
votes
1 answer

explicitly solving ODEs using RK4

My two first order differentials are as follows y1' = -sin(y0) + (gamma)*cos(y0)sin(beta * x) and y0' = y1 where (theta)'' = y, (theta)' = y1, theta = y0 My original equation was (((d^2)*theta)/dt^2)=-sin(theta)+(gamma)cos(theta)sin(Bx) How…
darren
  • 47
  • 1
  • 9
-1
votes
1 answer

System of ODEs using Runge-kutta fourth order in Python

I am writing a python program to solve 2x2 system of First Order Differential Equations given both initial conditions. My code: from math import * import numpy as np np.set_printoptions(precision=6) ## control numpy's decimal output :) form1 =…
Xrobot
  • 1
  • 4
-1
votes
1 answer

Why am I receiving the error that I am multiplying by non-int type 'float'?

I am having problems with my code which is a Runge Kutta algorithm to numerically solve for a harmonic oscillator. Unfortunately, I am receiving an error that says I can't multiply sequence by non-int of type float. Considering this code is nearly…
-1
votes
2 answers

Lotka-Volterra equations(predator prey) using Runge-Kutta in Python

I am trying to write a program using the Lotka-Volterra equations for predator-prey interactions. Solve Using ODE's: dx/dt = a*x - B*x*y dy/dt = g*x*y - s*y Using 4th order Runge-Kutta method I need to plot a graph showing both x and y as a…
Ryan M.
  • 63
  • 1
  • 5
1 2 3
24
25