This book, in the broadest sense, is an application of quantum mechanics and statistical mechanics to the field of magnetism. Under certain well described conditions, an immensely large number of electrons moving in the solid will collectively produce permanent magnetism. Permanent magnets are of fundamental interest, and magnetic materials are of great practical importance as they provide a large field of technological applications. The physical details describing the many electron problem of magnetism are presented in this book on the basis of the density functional approximation. The emphasis is on realistic magnets, for which the equations describing properties of the many electron problem can only be solved by using computers. The significant recent and continuing improvements are, to a very large extent, responsible for the progress in this field. Along with an introduction to the density functional theory, the book describes representative computational methods and detailed formulas for physical properties of magnets which include among other things the computation of magnetic ordering temperatures, the giant magneto-resistance, magneto-optical effects, weak ferromagnetism, the anomalous Hall and Nernst effects, and novel quasiparticles, such as Weyl fermions and magnetic skyrmions.