function [v, va, Error]=Capacitorsec4(vs, R, C, tf, dt)
  v=0;
  
  for i=1: round(tf/dt)
    v=v+(vs-v)/(R*C)*dt;
  end
  va= vs*(1-exp(-tf/(R*C)));
  Error=v-va;
end
