MATLAB: 5th Order Runge Kutta

differential equationsMATLABoderunge kutta

Hey,
I've been looking at Runge Kutta methods and was wondering how we would write a 5th order runge kutta method. I've stumbled upon lot of work online about how to write to the 4th order but not the 5th?
I've been looking at the code below…
% It calculates ODE using Runge-Kutta 4th order method
% Author Ido Schwartz
% Originally available form: http://www.mathworks.com/matlabcentral/fileexchange/29851-runge-kutta-4th-order-ode/content/Runge_Kutta_4.m
% Edited by Amin A. Mohammed, for 2 ODEs(April 2016)
clc; % Clears the screen
clear all;
h=0.1; % step size
x = 0:h:1; % Calculates upto y(1)
y = zeros(1,length(x));
z = zeros(1,length(x));
y(1) = 3; % initial condition

z(1) = 1; % initial condition
% F_xy = @(t,r) 3.*exp(-t)-0.4*r; % change the function as you desire
F_xyz = @(x,y,z) z; % change the function as you desire
G_xyz = @(x,y,z) 6*y-z;
for i=1:(length(x)-1) % calculation loop
k_1 = F_xyz(x(i),y(i),z(i));
L_1 = G_xyz(x(i),y(i),z(i));
k_2 = F_xyz(x(i)+0.5*h,y(i)+0.5*h*k_1,z(i)+0.5*h*L_1);
L_2 = G_xyz(x(i)+0.5*h,y(i)+0.5*h*k_1,z(i)+0.5*h*L_1);
k_3 = F_xyz((x(i)+0.5*h),(y(i)+0.5*h*k_2),(z(i)+0.5*h*L_2));
L_3 = G_xyz((x(i)+0.5*h),(y(i)+0.5*h*k_2),(z(i)+0.5*h*L_2));
k_4 = F_xyz((x(i)+h),(y(i)+k_3*h),(z(i)+L_3*h)); % Corrected
L_4 = G_xyz((x(i)+h),(y(i)+k_3*h),(z(i)+L_3*h));
%k_5
%L_5
y(i+1) = y(i) + (1/6)*(k_1+2*k_2+2*k_3+k_4)*h; % main equation

z(i+1) = z(i) + (1/6)*(L_1+2*L_2+2*L_3+L_4)*h; % main equation
end
Anyone have any ideas in what the 5th order equations should be and how to implement it to this code?
Many Thanks Chris

Best Answer

E.g., 5th Order Runge-Kutta-Fehlberg coefficients can be found here: