## Written for Octave 2.9
## Octave script for solving dx/dt=v, dv/dt=-x-v/5
## with the Runge-Kutta method (implemented in rk4.m).

## The right-hand side of the equation dX/dt=f(t,X(t)):
function ret = f(t,X); ret = [X(2),-X(1)-X(2)/5]; endfunction

## rk4('name of dx/dt function', [time interval], [init.data], timestep)
[T,X]=rk4('f',[0,50],[-2,0],0.1);
## T: moments of time; X(:,1), X(:,2): values of x, v at these moments of time

plot(X(:,1),X(:,2));
print('fig.eps','-deps')

