The origin of large-scale magnetic fields is one of the most puzzling topics in cosmology and astrophysics. It is assumed that the observed magnetic fields result from the amplification of an initial field produced in the early Universe. If these fields really were present before the recombination era, these could have some effects on big bang nucleosynthesis (BBN) and electroweak baryogenesis process, and it would leave imprints in the temperature and polarization anisotropies of the cosmic microwave background (CMB). In this chapter, we analyze the effects of a background primordial magnetic field (PMF) on the CMB anisotropies and how we can have sight the mechanisms of generation of these fields through these features. We start explaining briefly why primordial magnetic fields are interesting to cosmology, and we discuss some theoretical models that generate primordial magnetic fields. Finally, we will show the statistics used for describing those fields, and by using CLASS and Monte Python codes, we will observe the main features that these fields leave on the CMB anisotropies.
- primordial magnetic fields
- early universe
Magnetic fields are ubiquitous in the Universe. Even if the origin of these fields is under debate, it is assumed that observed fields were originated from cosmological or astrophysical seed fields and then amplified during the structure formation via some astrophysical mechanism . If these fields really were present before the recombination era, these could have some effects on big bang nucleosynthesis (BBN) and electroweak baryogenesis process and leave imprints in the temperature and polarization anisotropies of the cosmic microwave background (CMB) . Since PMFs affect the evolution of cosmological perturbations, these fields might imprint significant signals on the CMB temperature and polarization patterns and produce non-Gaussianities (NG) . As a matter of fact, PMFs introduce scalar, vector, and tensor perturbations that affect the CMB in many ways. For instance, the scalar mode generates magnetosonic waves which influence the acoustic peaks and change the baryon fraction; vector mode contributes notably in scales below the Silk damping, and tensor mode induces gravitational waves that affect large angular scales [4, 5]. Further, helical PMFs produce parity-odd cross correlation which would not arise in the standard cosmological scenario [6, 7]. Recently, enough CMB experiments like Planck and Polarbear have presented new limits on the amplitude of PMFs using temperature and polarization measurements that offer the possibility of investigating the nature of PMFs, and it is expected with future CMB polarization experiments like CMB-S4 and Simons Observatory, among others, to improve significantly the constraints to the helicity of PMFs and NG and to be able to provide a new insight into the early Universe .
2. A primordial origin
Cosmological scenarios describe the generation of magnetic fields in the early Universe (so-called primordial magnetic field), approximately prior to or during recombination, i.e., . At the same time, cosmological scenarios can be classified into two categories: inflationary and post-inflationary magnetogenesis. The first scenario generates PMFs correlated on very large scales during inflation, although the breaking of conformal invariance of the electromagnetic action is needed in order to obtain the suitable seed field. Besides, these kinds of models also suffer from some problems such as backreaction and the strong coupling . On the other hand, post-inflationary scenarios consider PMFs created after inflation via either cosmological phase transitions or during the recombination era (Harrison’s mechanism) . However, these will lead to a correlation scale smaller than the Hubble radius at that epoch; thus a suitable field cannot be generated unless we consider another dynamical effect, for instance, helicity, which under certain conditions produces transference of energy from small to large scales required to explain the observational large-scale magnetic fields . We will briefly summarize some models and properties of the cosmological scenarios.
As mentioned earlier, inflation provides an interesting scenario for the generation of PMFs with large coherence scales. Let us start with the standard free electromagnetic (EM) action, given by [2, 10]
where is conformally invariant and being the vector potential. By making a conformal transformation of the metric given by , the determinant and the contravariant metric change as
and the factors cancel out the action; thus the action of the free EM is invariant under conformal transformations. Since the FLRW models are conformally flat, i.e., , being the Minkowski metric, one can transform the electromagnetic wave equation into its flat version [2, 11]. Therefore, it is not possible to amplify the EM field fluctuations, and this leads to an adiabatic decay of the EM field as with the expansion of the Universe. Hence, inflamagnetogenesis requires the breaking of conformal invariance of the EM action in order to amplify EM waves from vacuum fluctuations [12, 13, 14]. A multitude of possibilities have been considered for this purpose, and some of them are illustrated in the action
This action usually contains the standard EM terms coupled to scalar fields () like the inflaton or dilaton, being its potential [11, 15]; coupling to curvature invariants () or a particular class of theories ; coupling to a pseudo-scalar field like the axion () with a mass scale , charged scalar fields () , and the presence of a constant that leads to a magnetic field with a net helicity ; here is totally antisymmetric tensor in four dimensions with . It is well known that, to create magnetic fields during inflation, the conformal invariance of the standard electrodynamics must be broken. One of the first models of inflamagnetogenesis was introduced by Ratra , where he proposed a conformal-breaking coupling between the scalar field (the inflaton) and the electromagnetic field. Many other mechanisms have been proposed following the same philosophy, and several conditions were obtained in order to explain the observed large-scale magnetic fields. However, serious obstacles arise in those mechanisms such as the strong-coupling problem where the theory becomes uncontrollable ; the backreaction problem in which an overproduction of the electric fields spoils inflation , and the curvature perturbation problem that enunciates the generation of both scalar and tensor curvature perturbations from PMFs would yield results in conflict with CMB observations . More complete treatments of this subject can be found in Refs. [2, 9, 22, 23, 24].
2.2. Cosmological phase transitions
In the early Universe, there have been at least two phase transitions: the cosmological QCD phase transition (∼250 MeV) and electroweak phase transition ( GeV) . If these are first-order transitions, the Universe goes through an out of equilibrium process that generates bubble nucleation. As the Universe cools below the critical temperature, bubbles nucleate and grow, the walls of these bubbles collide with the others generating turbulence, and then dynamo mechanism creates and amplifies magnetic fields from this violent process that are concentrated later in the bubble walls . Calculations of generation of magnetic fields during QCD phase transitions have been carried out by several authors [26, 27, 28]. Some cosmological phase transitions could generate uncorrelated magnetic fields given by 
and as we can see, PMFs generated by these mechanisms lead to a coherence length of the field smaller than the Hubble scale at that epoch, and weaker fields on galactic scales are obtained. However, the presence of helical fields can undergo processes of inverse cascade that transfers power from small to large scales, and thus, the result will be strong fields on very large scales .
2.3. Harrison’s mechanism
Other alternative for the production of PMFs arises during the radiation era in regions that have nonvanishing vorticity. The first attempt at such a model was done by Harrison ; there, magnetic fields are created through vorticity generated by the velocity difference in the fluids present. For a formal derivation of the mechanism, see Refs. [31, 32, 33]. At temperatures larger than the electron mass, the interactions among protons, electrons, and photons are strong, and they are locked together. This means that all the system has the same angular velocity and seed fields cannot be generated. For temperatures below eV, electrons and photons are tightly coupled through Thomson scattering, while the coupling between protons and photons is weak in this stage. Protons and electrons are still tightly coupled through Coulomb scattering, and so, the photon fluid drags the protons in its motion. Therefore, the difference of mass between electrons and protons will lead to non-zero electron and proton fluid angular velocities that give rise to currents and magnetic fields. Matarrese et al.  found that for comoving scales of Mpc, the amplitude of PMFs generated via this mechanism is around of G today. This value of the magnetic field generated by the differential rotational velocity of charged particles is much smaller than those signals observed in clusters of galaxies. Now, if an initial vorticity is present during this epoch, magnetic fields may serve as seed for explaining the galactic fields; however, in the early Universe, the vorticity decays rapidly due to the expansion of the Universe, and therefore, this mechanism cannot work efficiently .
3. Magnetic spectra and correlation functions
Two models have been proposed to model PMFs. The first one consists in describing PMFs as an homogeneous field such that B2 is the local density of the field and where we must require an anisotropic background (like Bianchi VII) to allow the presence of this field. Comparing those models with CMB quadrupole data, Barrow et al.  reported an amplitude of PMFs of G, and there they used the most general flat and open anisotropic cosmologies containing expansion rate and three-curvature anisotropies. However, they found that PMFs amplitude constraints are stronger than those imposed by nucleosynthesis, and therefore, this description hardly agrees with other cosmological probes. On the other hand, PMFs can also be described by a stochastic test field where B2 would be related to the average density of the field instead. This description does not break neither isotropy nor homogeneity of the background Universe; hence, this scheme allows to have a PMF model concordant to the current constraints. In consequence, we will consider a stochastic primordial magnetic field (PMF) generated in the very early Universe which could have been produced during inflation (noncausal field) or after inflation (causal field) throughout the chapter. The PMF power spectrum which is defined as the Fourier transform of the two-point correlation can be written as
where is a projector onto the transverse plane1, is the 3D Levi-Civita tensor, and and are the symmetric/antisymmetric parts of the power spectrum and represent the magnetic field energy density and absolute value of the kinetic helicity, respectively :
We assume that power spectrum scales as a simple power law
We usually parametrize the fields through a convolution with a 3D-Gaussian window function smoothed over a sphere of comoving radius , , with . We also define as the comoving PMF strength scaled to the present day on :
and we define as the comoving kinetic helical PMF strength scaled to the present day on :
with being the gamma function. Then, we obtain the amplitudes as follows:
The most general case of the power spectrum for magnetic fields can be studied, if we assume that it is non-zero for , being km an infrared cutoff and kD an ultraviolet cutoff corresponding to damping scale of the field written as 
an additional constraint is found for these fields
In the case where and , we define the maximal helicity condition. We will also parametrize the infrared cutoff by a single constant parameter :
which in the case of inflationary scenarios would correspond to the wave mode that exits the horizon at inflation epoch and, for causal modes, would be important when this scale is larger than the wave number of interest (as claimed by Kim et al. ). Thus, this infrared cutoff would be important in order to constrain PMF parameters and magnetogenesis models [37, 38, 39, 40]. Eq. (15) gives only a useful mathematical representation to constrain these cutoff values via cosmological datasets (for this case, the parameter space would be given by ), and therefore we want to point out that the latter expression does not state any physical relation between both wave numbers. In [38, 39], they showed constraints on the maximum wave number kD as a function of nB via big bang nucleosynthesis (BBN), and they considered the maximum and minimum wave numbers as independent parameters. In fact, in  they found out that the integration scheme used for calculating the spectrum and bispectrum of PMFs is exactly the same if we parametrize km as seen in (15) or if we consider as independent parameters.
Thus the inclusion of km is done only for studying at a phenomenological level, and its effects on the CMB are shown in more detail in [3, 41]. At background level, we need only the energy density of the PMF which is given by ; therefore, by using Eqs. (8) and (9), we get (for the spatial dependence)
Here, only the non-helical term contributes to the energy density of the PMF in the Universe. In Ref. , this equation is also reported, and we will study in more detail their effects on the CMB later. In order to study the impact of PMFs on cosmological perturbations, we start writing the magnetic energy momentum tensor (EMT)
where we can see that EMT of PMFs is quadratic in the fields . Due to the high conductivity in the primordial Universe, the electric field is suppressed, and the magnetic one is frozen into the plasma, and consequently we have that . Then, the spatial part of magnetic field EMT in Fourier space is given by
and the two-point correlation tensor related to the spatial dependence (18) gives
where we can apply the Wick theorem because the stochastic fields are Gaussianly distributed
On the other hand, the equations for the adimensional energy density of magnetic field and spatial part of the electromagnetic energy momentum tensor respectively written in Fourier space are given as
where we express each component of the energy momentum tensor in terms of photon energy density , with being its present value2. We can also see that using the previous definition, the EMT can be written as . Since the spatial EMT is symmetric, we can decompose this tensor into two scalars (, ), one vector (), and one tensor () components:
where we use Eqs. (5) and (20). In this work, we are only focused on the scalar mode of the PMfs. To determine the effect on cosmic perturbations, it is necessary to compute the scalar correlation functions of PMFs using the projector operators:
where the angular functions are defined as
The above relations and properties were obtained using the xAct software , and they agree with those reported in [35, 47]. Given these results, we are able to analyze the effects of PMFs on CMB by adding the previous contributions to the CMB angular power spectrum. Indeed, some authors [42, 50, 51, 52, 53] have added the above spectrum relations in Boltzmann codes like CAMB  or CMBeasy , while other authors [4, 5, 56, 57] have analyzed the effects of these fields through approximate solutions.
Using the integration scheme for the Fourier spectra reported in , we obtain the solution for the magnetic spectra for different contributions. In Figures 1 and 2, we show the total contribution for in the maximal helical case for several spectral indices and values of α. Here we can see that for , the spectrum is red while for the biggest contribution comes from large wave numbers. In Figure 3, the scalar part of the anisotropic stress and the effect of an IR cutoff on its spectrum are displayed.
4. Effects of the background PMFs on the CMB
The presence of energy density of the background PMF increases total radiation-like energy density and modifies the standard dynamics of the background Universe producing considerable effects on the primary temperature fluctuations of the CMB. In this section, we will study the effects of background PMF on the CMB following the early work discussed in Ref. . First, the total energy density and pressure are now written as and , respectively (being the components of matter in the standard model of cosmology), modifying the solution of the Friedmann’s equation:
where G is the gravitational constant and with the conformal time. In order to study the effects of PMFs on the CMB, we include a background magnetic density given by Eq. (16) into the Boltzmann code CLASS . As first shown by Ref. , the speed of sound in baryon fluid is described by , where is the speed of sound without magnetic field 
and is the total energy density. Also, including this modification in the thermodynamic structure in the CLASS code, we obtain the spectrum of CMB temperature anisotropies shown in Figure 4. Here we can observe the effects of different parameters enclosed in Eq. (16) on the CMB spectrum. With a PMF in the primordial plasma, the time of matter-radiation density equality () increases enhancing the amplitude of all peaks because there is not enough time to be suppressed for the cosmic expansion. However, the contrast between odd and even peaks is reduced because it further depends on () corresponding to the balance between gravity and the total radiation pressure . Secondly, an important effect of PMFs comes from increasing in sound speed cs. In fact, the peak location depends on the angle , where is the physical sound horizon at decoupling and is the angular diameter distance at decoupling 
The angular diameter distance depends on the late history after decoupling (), whereas physical sound horizon is further affected by the value of cs. By adding PMFs to the primordial plasma, we increase the effective speed of sound which in turn increases the angle of the location of peaks, boosting the peaks to small (this can be understood geometrically using ), i.e., shifting the acoustic peaks to the left as we see in Figure 5a. Finally, since the value of the total radiation energy density is larger with PMFs, the gravitational potentials decay more quickly after their wavelengths become smaller than the sound horizon (see Figure 5a).
In summary, accounting for a background PMF in our model modifies the shape of the temperature power spectrum significantly for large multipolar numbers, that is, the Sachs-Wolfe (SW), Doppler, and early integrated Sachs-Wolfe (EISW) contributions are quite affected by the magnetic field. This fact can be noticed in Figure 5b, where we plot the features of PMFs () for several contributions of the CMB spectrum. Since the late integrated Sachs-Wolfe (LISW) comes from interactions of the photons after last scattering, PMFs do not play a sizable role in this contribution. On the other hand, the EISW signal is shifted to small because modes related to entered to sub-horizon scales earlier than if they had done without PMFs. This boost is also seen in the SW where the acoustic peak positions are shifted to larger scales. For , odd Doppler peaks are enhanced with respect to the ratio of baryon and radiation content ; hence, PMFs produce suppression in the amplitude for odd peaks, while the even ones remain unaltered. These features are illustrated in Figure 5b.
In Figure 6 we show the bidimensional and triangle plots of the MCMC with one magnetic parameter and some of the CDM model. We derived the constraints on the spectral index of PMF: B = 1nG, kD = 100 Mpc−1, and at 95% confidence level. Therefore, cosmological datasets (BAO data 2015 and with Planck simulated data 2013) strongly favor invariant scale fields driven by inflationary scenarios. In order to derive the constraints with current data on this kind of PMFs, we performed a MCMC analysis using the Monte Python code .
5. Magnetic contribution to CMB anisotropies
Since PMFs affect the evolution of cosmological perturbations, these fields might leave significant signals on the CMB. Basically, PMFs add three contributions to the temperature and polarization of the CMB spectra, such as the scalar, vector, and tensor, which have been deeply studied [4, 56, 62, 63]. For the scalar contribution, the shape of the temperature anisotropy (TT mode) presents an increase on large scales, and it also shifts the acoustic peaks via fast magnetosonic waves; nevertheless the main effect of the scalar mode lies on large multipolar numbers, since the primary CMB is significantly suppressed by the Silk damping in these scales [4, 5]. Next, the vector contribution leaves an indistinguishable signal, because in standard cosmology, vector contributions decay with time and do not affect the CMB anisotropies considerably . Further, vector mode peaks where primary CMB is suppressed by Silk damping and so dominates over the scalar ones in small scales . Vector modes are also very interesting in the polarization spectra; in particular, they induce B modes with amplitudes slightly larger than any other contribution, allowing us to constrain better PMFs in the next CMB polarization experiments .
Finally, tensor modes induce gravitational wave perturbations that lead to CMB temperature and polarization anisotropies on large angular scales, and the passive tensor modes (produced by the presence of PMFs before neutrino decoupling) generate the most significant magnetic contributions, so those modes become relevant to study the nature of PMFs [48, 65, 66]. Moreover, if helical PMFs are presented before recombination, they affect drastically the parity-odd CMB cross correlations implying a strong feature of parity violation in the early Universe . Using the total angular momentum formalism introduced by , the angular power spectrum of the CMB temperature anisotropy is given as
where are the scalar, vector, and tensor perturbation modes and . Here are the temperature fluctuation multipolar moments, and represent the polarization of electric and magnetic type, respectively. In large scales, one can neglect the contribution on CMB temperature anisotropies by ISW effect in the presence of a PMF . Therefore, considering just the fluctuation via PMF perturbation, the temperature anisotropy multipole moment for becomes 
where is the value of scalar factor at decoupling, G is the gravitational constant, and is the spherical Bessel function. Substituting the last expression in (34) with , the CMB temperature anisotropy angular power spectrum is given by
Here, for our case, we should integrate only up to since it is the range where energy density power spectrum is not zero. The result of the angular power spectrum induced by scalar magnetic perturbations given by (36) is shown in Figure 7. There, we plot the in order to compare our results with those found by . We calculate the angular power spectrum of CMB in units of . One of the important features of the CMB power spectrum (scalar mode) with PMFs is that the distortion is proportional to strength of PMF and decreases with the spectral index and we must expect its greatest contribution at low multipoles.
5.1. Infrared cutoff in the CMB spectra
Studying the effect of this lower cutoff of CMB spectra, we can constrain PMF generation models. Figure 8 shows the effects of PMFs on the scalar mode of CMB spectra. Here we did a comparison between the Cls with a null cutoff with respect to Cls generated by values of cutoff different from zero. The horizontal solid line shows the comparison with , , and ; no difference in effectiveness was found between these values. The dashed lines report a significant difference of the Cls for values of , , and . It is appropriate to remark that power spectrum of causal fields is a smooth function in the k-space without any sharp cutoff coming from the original mechanism; now, given the parametrization introduced here, we notice from Figure 7 in  that for very small, the calculations agree with previous work. It can be thought as contribution of the super horizon modes is negligible, and one would expect that scales as , for instance. Also, one of the characteristics of this dependence is the existence of a peak; indeed, for large values of , the peak moves to left as we see, for instance, with where the peak is in while for the peak is shifted to .
In this chapter, we worked on the assumption that in the early Universe, a weak magnetic field was created. This PMF is parametrized by its strength and smoothing length , and in accordance with the generation process, it also depends on , , and the spectral index . Now, if this seed is indeed presented during recombination, it prints a signal in the pattern on CMB spectra, signal that depends on the aforementioned variables. Here we have computed the power spectrum in the CMB radiation sourced by this primordial field, and we observed how the shape of this spectrum changes given different values of the magnetic parameters. This means that, by constraining the value of these magnetic parameters via CMB observations, we can have some clue about the mechanism which produced this field. We have also studied the magnetic field at the background level and a first order at the perturbation theory. In the first case, we observed how the presence of PMFs can enhance the speed of sound of the plasma and the time of matter-radiation density equality, producing an increase in the amplitude of the acoustic peaks and shift them to small multipolar numbers. Other important effect of PMFs at the background level is the faster decay of the gravitational potentials when they enter to the sound horizon; this effect could be seen in the subsequent formation of the large-scale structure. Secondly, at first order in the perturbation theory, the scalar mode in the magnetic field produces an increase in the Sachs-Wolfe, although the effect could not be seen observationally due to small effect compared with the primary signal. We also found how the value of the parameters related to B and ns changes the shape of the power spectrum, and by increasing km the peaks related to the ratio between with and without IR cutoff are shifted to large angles. Moreover, in scenarios like inflation, the effect of infrared cutoff might not be ignored (for a deeper discussion see ); thus, the feature of this signal will be useful for constraining PMF inflation generation models. In fact, this km is important for studying the evolution of density perturbations and peculiar velocities due to primordial magnetic fields and effects on BBN [37, 68, 69]. Additionally, the power spectrum generated by magnetic fields is blue for and red for , which means that for causal fields (), the signal printed in the CMB spectrum is weak, while for noncausal fields , the signal is more strong, being () the maximal value for the field corresponding to a scale invariant spectrum. Therefore, cosmological data are more favorable to noncausal PMFs () as we can see in the Figure 6. In conclusion, the study of PMFs and their effects on different cosmological datasets, mainly in CMB, will provide new insight into the physics at the early Universe and could explain the actual origin of the cosmic magnetic fields.
Conflict of interest
The authors declare that there is no conflict of interest.
- This projector has the property P lm k ̂ m = 0 with k ̂ = k k .
- The dimensional energy density of magnetic field showed here is written with different notation in  Ω B ≡ B 2 8 π a 4 ρ γ and in [7, 44] Δ B ≡ B 2 8 π a 4 ρ γ .