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