A mathematical evaluation is presented for the beam raster scanning mode of depth profiling with SIMS, combined with electronic gating of the detection system. A computer program was developed in which a former treatment of the influence of the crater edges is extended to arbitrary impurity profiles and which also accounts for neutral particles in the primary beam. It is shown that these neutrals have a dramatic effect on the obtained dynamic range and that the commonly used background subtraction technique does not necessarily lead to the correct profile. The simulation including neutrals shows good agreement with an experimentally measured profile. Finally, the influence of the crater edges and the choice of an appropriate structure for measuring depth resolution and outdiffusion are discussed.