function res = spring_pendulum(t,x)

g = 1; % gravity
k = 100; % spring force
l = 5; % length of spring
d = 1000; % damping


res = zeros(4,1);

res(1) = x(3);
res(2) = x(4);

nx = sqrt(x(1)^2 + x(2)^2);

res(3) = -k*(1-l/nx)*x(1)-d*(x(1)*x(3)+x(2)*x(4))*x(1)/nx^2;
res(4) = -k*(1-l/nx)*x(2)-g-d*(x(1)*x(3)+x(2)*x(4))*x(2)/nx^2;
