function [E,Error]=ElasticSec3(k,dx,xf)
  E=0;
  x=0;
  for i=1: round(xf/dx)
    x=x+dx;
    E=E+k*x*dx;
  end
  Error=E-1/2*k*xf^2;
end
