function [T,x] = RK4Pseudocode(int,x0,n)
% Main Runge-Kutta
%Input: Interval [ta,T], initial condition x0,  and number of steps n
%Output: the approximate solution x, at time T
% Example usage: [T,x]=RK4Pseudocode([1 1.5625],2,72);


ta = int(1);
T = int(2);
h = (T - ta)/n; %%step size h=(T-ta)/n
x = x0;
t = ta;
format long 

for j = 1:n
    K1 = h*xdot(t,x);
    K2 = h*xdot(t+h/2,x+K1/2);
    K3 = h*xdot(t+h/2,x+K2/2);
    K4 = h*xdot(t+h,x+K3);
    x = x + (K1 + 2*K2 + 2*K3 + K4)/6;
    t = t + h;

plot(t,x,'.','LineWidth',1,...
                'MarkerEdgeColor','k',...
                'MarkerFaceColor','g',...
                'MarkerSize',10);
hold all
end



function z = xdot(t,x)  %the RHS of the ODE
z = 2 + (x - t - 1)^2;
