Amplitude equations are derived that describe the spatiotemporal dynamics of cardiac alternans during periodic pacing of one- [B. Echebarria and A. Karma, Phys. Rev. Lett. 88, 208101 (2002)] and two-dimensional homogeneous tissue and one-dimensional anatomical reentry in a ring of homogeneous tissue. These equations provide a simple physical understanding of arrhythmogenic patterns of period-doubling oscillations of action potential duration with a spatially varying phase and amplitude, as well as explicit quantitative predictions that can be compared to ionic model simulations or experiments. The form of the equations is expected to be valid for a large class of ionic models but the coefficients are derived analytically only for a two-variable ionic model and calculated numerically for the original Noble model of Purkinje fiber action potential. In paced tissue, this theory explains the formation of "spatially discordant alternans" by a linear instability mechanism that produces a periodic pattern of out-of-phase domains of alternans. The wavelength of this pattern, equal to twice the spacing between nodes separating out-of-phase domains, is shown to depend on three fundamental length scales that are determined by the strength of cell-to-cell coupling and conduction velocity (CV) restitution. Moreover, the patterns of alternans can be either stationary, with fixed nodes, or traveling, with moving nodes and hence quasiperiodic oscillations of action potential duration, depending on the relative strength of the destabilizing effect of CV restitution and the stabilizing effect of diffusive coupling. For the ring geometry, we recover the results of Courtemanche, Glass, and Keener [Phys. Rev. Lett. 70, 2182 (1993)] with two important modifications due to cell-to-cell diffusive coupling. First, this coupling breaks the degeneracy of an infinite-dimensional Hopf bifurcation such that the most unstable mode of alternans corresponds to the longest quantized wavelength of the ring. Second, the Hopf frequency, which determines the velocity of the node along the ring, depends both on the steepness of CV restitution and the strength of this coupling, with the net result that quasiperiodic behavior can arise with a constant conduction velocity. In both the paced geometries and the ring, the onset of alternans is different in tissue than for a paced isolated cell. The implications of these results for alternans dynamics during two-dimensional reentry are briefly discussed.