Abstract. We present a numerical algorithm to solve the micromagnetic equations based on tangential-plane minimization for the magnetization update and a homothethic-layer decomposition of outer space for the computation of the demagnetization field. As a first application, detailed results on the flower-vortex transition in the cube of Micromagnetic Standard Problem number 3 are obtained, which confirm, with a different method, those already present in the literature, and validate our method and code. We then turn to switching of small cubic or almost-cubic particles, in the single-domain limit. Our data show systematic deviations from the Stoner-Wohlfarth model due to the non-ellipsoidal shape of the particle, and in particular a non-monotone dependence on the particle size.Mathematics Subject Classification. 65L60, 78M10, 82D40.