Function theory for the Dirac equation has grown substantially during the last several decades. The case of dimension four is special in two ways – it is a physical dimension and spinor fields can be identified with quaternionic functions of a quaternionic variable. Obtained results were applied to a wide spectrum of problems in mathematical physics. The first part contains a summary of basic facts from quaternionic analysis, including integral formulae for unbounded domains. The selection of topics is guided by their possible applications. Boundary problems for Maxwell equations in homogeneous media and the Dirac equation for a free particle are treated in the second part. The last part contains a discussion of Maxwell equations for inhomogeneous media, the Dirac equation with potentials, and a generalization of the Riccati equation to a nonlinear quaternionic equation. The book can be useful not only for mathematicians interested in the field but also for engineers (the book is based on a course given by the author to future engineers).