Summary. A numerical method is established to solve the problem of minimizing a nonquasiconvex potential energy. Convergence of the method is proved both in the case on its own and in the case when it is combined with a weak boundary condition. Numerical examples are given to show that the method, especially when applied together with a continuation method and some other numerical techniques, is not only successful and efficient in solving problems with laminated microstructures but also capable of computing more complicated microstructures.