function err = cum_range_error(position, x, y, tp_sr);

if length(position) == 4,
   err = sum((tp_sr'*position(4)/1500 - sqrt((x - position(1)).^2 + (y - position(2)).^2 + position(3)^2)).^2);
else
   err = sum((tp_sr' - sqrt((x - position(1)).^2 + (y - position(2)).^2 + position(3)^2)).^2);
end;