# Implementing and Optimizing the Scaled Dot-Product Attention on Streaming
Dataflow

Gina Sohn<EMAIL_ADDRESS>Stanford UniversityStanfordUSA ,  Nathan
Zhang<EMAIL_ADDRESS>Stanford UniversityStanfordUSA and  Kunle
Olukotun<EMAIL_ADDRESS>Stanford UniversityStanfordUSA

(Date: April 2024)

###### Abstract.

Transformer models serve as the backbone of many state-of-the-art language
models, and most use the scaled dot-product attention (SDPA) mechanism to
capture relationships between tokens. However, the straightforward
implementation of SDPA has quadratic compute and memory complexity with
respect to the sequence length. On processor architectures such as GPUs and
TPUs, there is a robust body of prior work. However, little work has been
performed on non-processor architectures.In this work, we show how the
architecture and execution model of Streaming Dataflow Accelerators can help
tackle this challenge. We first define abstract hardware that adopts a
streaming execution model, and we implement a cycle-accurate simulator of the
abstract hardware using the Dataflow Abstract Machine simulation framework.
Second, we implement the naive SDPA algorithm on this abstract hardware and
show it requires linear $(O(N))$ intermediate memory. Third, we then modify
the naive algorithm, taking inspiration from prior processor-oriented works,
by reordering the multiplication and division operations. Finally, we map the
modified algorithm to abstract hardware, and confirm that the implementation
computes SDPA at full throughput while only using a constant amount $(O(1))$
of intermediate memory.

##  1\. Introduction

Transformer models (attention2017, ) are widely used for various language,
audio, and vision tasks. Over time, researchers have discovered that long
sequence lengths are essential to capturing long-range dependencies and
process high-resolution images (brown2020language, ; chowdhery2022palm, ;
openai2023gpt4, ). However, scaled dot-product attention (SDPA), the core
operation in most transformer models, has quadratic memory complexity with
respect to the sequence length. There has been a wide range of work to tackle
this challenge, such as approximate attention (kitaev2020reformer, ;
katharopoulos2020transformers, ; beltagy2020longformer, ), using alternative
mixing mechanisms (fu2024monarch, ; fu2022hungry, ), and optimizations to
reduce reads and writes between different levels in the memory hierarchy
(flashattention2022, ; dao2023flashattention, ). However, these works almost
uniformly targeted processor-like architectures such as CPUs, TPUs, and GPUs.

In this work, we will instead implement and optimize the attention algorithms
on streaming dataflow accelerators. Streaming dataflow accelerators are array
architectures of reconfigurable compute and memory units. As shown in Figure
1, its execution model spatially maps the operations in the computation graph
to hardware units by configuring the compute and memory units accordingly. It
then pipelines the execution between different operations. Some examples of
streaming dataflow accelerators include Coarse-grained Reconfigurable
Architectures (10.1145/3534933, ; carsello2022amber, ) and Reconfigurable
Dataflow Architectures (prabhakar2017plasticine, ; rucker2023revet, ). The
streaming dataflow paradigm provides several performance benefits. First, it
enables exploiting a high degree of parallelism due to dataflow execution and
deeply pipelined execution. Second, it requires less memory footprint and
bandwidth as operation fusion reduces off-chip memory accesses due to
intermediate data.

Figure 1. An abstract diagram of the architecture and execution model for
streaming dataflow accelerators

To elucidate how the streaming execution model can reduce the memory
complexity of the attention algorithm, we first define an abstract streaming
dataflow accelerator based on Parallel Patterns (parallelpatterns, ). We then
map the attention algorithm to the abstract hardware and show that the
implementation achieves linear memory complexity for intermediate data.
Lastly, we apply algorithmic changes inspired by prior work on other
architectures, and provide an implementation of SDPA that requires only a
constant amount of intermediate memory.

Node | Behavior
---|---
Map (f: func) |  Applies the function f to every element in the input stream
Reduce (n: Int) (init: T) (f: func) |  Reduces across n element in the input stream using the given function.
The output will be enqueued to the output stream after n elements are reduced. |
init is the initial value of the accumulator. |
MemReduce (n: Int) (init: Mem[T]) (f: func) | Similar to Reduce, but executes higher order reduction on memory elements
instead of scalar values. |
Repeat (n: Int) |  Repeats every scalar in the input stream n times.
Scan (n: Int) (init: T) (updt: func) (f: func) |  On every new input element, update the state using the updt function.
The state is initialized to the init value after scanning every n elements. |
On every input element, apply the function f and dequeue to the output stream. |
Table 1. The nodes in our abstract hardware based on Parallel Patterns.

##  2\. The Abstract Streaming Dataflow Hardware

Prior work has shown that Parallel Patterns can simplify the generation
process of optimized configurations for configurable hardware
(parallelpatterns, ; prabhakar2017plasticine, ; Koeplinger2018Spatial, ). Our
abstract hardware consists of nodes such as Map, Reduce, and Scan (Table 1).
Each node can be further lowered to a configuration of the physical compute
and memory units. To verify the functional correctness of the implementation
and confirm it uses a linear amount of intermediate memory without any
performance loss, we develop a cycle-accurate simulator for each node in the
abstract hardware using the Dataflow Abstract Machine simulation framework
(DAM, ).

Figure 2. Implementation of attention using Parallel Patterns. The depth of
the short FIFOs is set to 2, and the depth of the Long FIFO is set to $N+2$.
Each node can be mapped to a configuration of a set of compute and memory
units in a streaming dataflow hardware. Figure 3. Implementations of
algorithms using Parallel Patterns. (a) The attention algorithm using softmax
with scaling. (b) The attention algorithm with reordered division. (c) The
memory-free-attention algorithm.

##  3\. Standard Attention Implementation

Inside the Transformer model, three matrices $Q,K,$ and $V$ are generated
based on the input sequence and weights. Given that there are $N$ tokens in
the input sequence where each token is a $d$-wide vector, the shape of $Q,K,$
and $V$ is ${N\times d}$, and the attention algorithm can be expressed as
follows:

(1) $S=QK^{T},\hskip
8.0ptP=softmax(S)=\frac{e^{s_{ij}}}{\sum_{j}e^{s_{ij}}},\hskip 8.0ptO=PV$

The algorithm produces $N^{2}$-sized intermediate matrices $S$ and $P$,
leading to a time and memory complexity quadratic to the sequence length.
However, on a streaming execution model, it is possible to implement the same
algorithm to have a sub-quadratic, in other words, asymptotically lower,
memory complexity without any algorithmic changes. This starts from the
observation that the attention algorithm can be decomposed into row-wise
operations. Given that $\vec{q_{i}}$ is the i-th row of the $Q$ matrix,
Equation 1 can be decomposed into row-wise operations as follows
($\vec{s_{i}},\vec{p_{i}},\vec{o_{i}}$ are the i-th row of matrix $S,P,O$
respectively) :

(2) $\vec{s_{i}}=\vec{q_{i}}K^{T},\hskip
8.0pt\vec{p_{i}}=softmax(\vec{s_{i}})=\frac{e^{s_{ij}}}{\sum_{j}e^{s_{ij}}},\hskip
8.0pt\vec{o_{i}}=\vec{p_{i}}V$

The rows of matrix $Q$ can be streamed into compute units that execute the
operations in Equation 2, and the computation between different rows can be
pipelined. This has the effect of fusing operations to compute each row of the
output matrix $O$. Therefore, the memory complexity for intermediate data will
reduce to the required intermediate data to compute a _single_ row.

The mapping of the attention algorithm to our abstract hardware can be found
in Figure 2. We configure each node as shown in the figure and set the depth
of the short FIFOs to two and the long FIFO to $N+2$. We compare this with the
baseline, where all the FIFOs are set to have infinite depth (this will be the
peak throughput scenario). We confirmed that the implementation in Figure 2
only requires $O(N)$ intermediate memory while running in full throughput.
More detailed experiment results can be found in the case study in the
Dataflow Abstract Machine work (DAM, ).

##  4\. Memory-free Attention Implementation

By modifying the algorithm, we can further obtain an implementation that
requires a constant amount ($=O(1)$) of intermediate memory. In the previous
section, the reason why we need a $O(N)$-long FIFO is that there are two paths
from the second Map unit to the third Map unit with different latencies. The
path that contains a row-wise reduction produces the output only after
processing the last element in the row, and the following Map unit performs an
element-wise operation on the pair of inputs from each path. The other path
needs a deep FIFO that can contain the outputs from the second Map unit until
the reduction path produces its output to avoid deadlock. Therefore, when the
consumer performs an element-wise operation with the inputs from each path,
the two divergent paths should have matched latency to avoid introducing this
long FIFO.

This can be done by (1) reordering the division operation in softmax with the
following matrix multiplication based on the distributive law, (2) using the
running sum instead of the row-wise sum during the softmax operation, and (3)
rescaling by the difference between the old running sum and latest running sum
during the scalar reduction in softmax and the vector reduction in the matrix
multiplication. For this implementation, we use softmax with scaling
(flashattention2022, ; kitaev2020reformer, ; milakov2018online, ;
rabe2021n2memory, ), which is widely used in practice for better numerical
stability. The modified algorithm can be described as:

(3) $s_{ij}=\sum_{k}q_{ik}\cdot k_{kj}$

Given $\forall j<0\;\;m_{ij}=-\infty$, for all $i>0$:

(4) $\displaystyle m_{ij}=max(m_{i(j-1)},s_{ij})$
$\displaystyle\Delta_{ij}=e^{m_{i(j-1)}-m_{ij}}$ $\displaystyle
e_{ij}=e^{s_{ij}-m_{ij}}$

Given $\forall j<0\;\;r_{ij}=0$ and $\vec{l_{ij}}=\vec{0}$, for all $i>0$:

(5) $\displaystyle r_{ij}=r_{i(j-1)}\cdot\Delta_{ij}+e_{ij}$
$\displaystyle\vec{l_{ij}}=\vec{l}_{i(j-1)}\cdot\Delta_{ij}+e_{ij}\cdot\vec{v_{j}}$

(6) $\vec{o_{i}}=\frac{\vec{v}_{iN}}{r_{iN}}$

In the attention algorithm using softmax with scaling (Figure 3(a)), there are
two pairs of divergent paths with unbalanced latency due to the row-wise
reduction. The second pair of unbalanced paths are handled by reordering the
division operation in softmax and the matrix multiplication. As shown in
Figure 3(b), by making the matrix multiplication’s reduction happen in
parallel with the row-wise summation, it balances the latency of both paths
and eliminates the $O(N)$-long FIFO.

The first pair of unbalanced paths remaining in Figure 3(b) can be eliminated
using a running max instead of the row-wise max. As the following operations
are reductions, the difference between the latest running max and the running
max at the point when each element was accumulated can be adjusted by
rescaling the accumulated values. This, in turn, eliminates the deep FIFO by
converting the reduction operation into an element-wise scan operation.

The implementation in Figure 3(c) is simulated by configuring each node in our
simulator accordingly and setting the depth of the short FIFOs to two. This is
compared with the baseline, where all the FIFOs are set to have infinite depth
(this will be the peak throughput scenario). We confirmed that this
implementation only requires $O(1)$ intermediate memory to run in full
throughput. More detailed experiment results can be found in the case study in
the Dataflow Abstract Machine paper (DAM, ).

## References

  * [1] Iz Beltagy, Matthew E Peters, and Arman Cohan.  Longformer: The long-document transformer.  arXiv preprint arXiv:2004.05150, 2020.
  * [2] Tom Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared D Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, et al.  Language models are few-shot learners.  Advances in neural information processing systems, 33:1877–1901, 2020.
  * [3] Alex Carsello, Kathleen Feng, Taeyoung Kong, Kalhan Koul, Qiaoyi Liu, Jackson Melchert, Gedeon Nyengele, Maxwell Strange, Keyi Zhang, Ankita Nayak, et al.  Amber: A 367 gops, 538 gops/w 16nm soc with a coarse-grained reconfigurable array for flexible acceleration of dense linear algebra.  In 2022 IEEE Symposium on VLSI Technology and Circuits (VLSI Technology and Circuits), pages 70–71. IEEE, 2022.
  * [4] Aakanksha Chowdhery, Sharan Narang, Jacob Devlin, Maarten Bosma, Gaurav Mishra, Adam Roberts, Paul Barham, Hyung Won Chung, Charles Sutton, Sebastian Gehrmann, Parker Schuh, Kensen Shi, Sasha Tsvyashchenko, Joshua Maynez, Abhishek Rao, Parker Barnes, Yi Tay, Noam Shazeer, Vinodkumar Prabhakaran, Emily Reif, Nan Du, Ben Hutchinson, Reiner Pope, James Bradbury, Jacob Austin, Michael Isard, Guy Gur-Ari, Pengcheng Yin, Toju Duke, Anselm Levskaya, Sanjay Ghemawat, Sunipa Dev, Henryk Michalewski, Xavier Garcia, Vedant Misra, Kevin Robinson, Liam Fedus, Denny Zhou, Daphne Ippolito, David Luan, Hyeontaek Lim, Barret Zoph, Alexander Spiridonov, Ryan Sepassi, David Dohan, Shivani Agrawal, Mark Omernick, Andrew M. Dai, Thanumalayan Sankaranarayana Pillai, Marie Pellat, Aitor Lewkowycz, Erica Moreira, Rewon Child, Oleksandr Polozov, Katherine Lee, Zongwei Zhou, Xuezhi Wang, Brennan Saeta, Mark Diaz, Orhan Firat, Michele Catasta, Jason Wei, Kathy Meier-Hellstern, Douglas Eck, Jeff Dean, Slav Petrov, and Noah Fiedel.  Palm: Scaling language modeling with pathways, 2022.
  * [5] Tri Dao.  Flashattention-2: Faster attention with better parallelism and work partitioning.  arXiv preprint arXiv:2307.08691, 2023.
  * [6] Tri Dao, Dan Fu, Stefano Ermon, Atri Rudra, and Christopher Ré.  Flashattention: Fast and memory-efficient exact attention with io-awareness.  In Advances in Neural Information Processing Systems 35, 2022.
  * [7] Dan Fu, Simran Arora, Jessica Grogan, Isys Johnson, Evan Sabri Eyuboglu, Armin Thomas, Benjamin Spector, Michael Poli, Atri Rudra, and Christopher Ré.  Monarch mixer: A simple sub-quadratic gemm-based architecture.  Advances in Neural Information Processing Systems, 36, 2024.
  * [8] Daniel Y Fu, Tri Dao, Khaled K Saab, Armin W Thomas, Atri Rudra, and Christopher Ré.  Hungry hungry hippos: Towards language modeling with state space models.  arXiv preprint arXiv:2212.14052, 2022.
  * [9] Angelos Katharopoulos, Apoorv Vyas, Nikolaos Pappas, and François Fleuret.  Transformers are rnns: Fast autoregressive transformers with linear attention.  In International conference on machine learning, pages 5156–5165. PMLR, 2020.
  * [10] Nikita Kitaev, Lukasz Kaiser, and Anselm Levskaya.  Reformer: The efficient transformer.  In International Conference on Learning Representations, 2020.
  * [11] David Koeplinger, Matthew Feldman, Raghu Prabhakar, Yaqi Zhang, Stefan Hadjis, Ruben Fiszel, Tian Zhao, Luigi Nardi, Ardavan Pedram, Christos Kozyrakis, and Kunle Olukotun.  Spatial: A language and compiler for application accelerators.  In Proceedings of the 39th ACM SIGPLAN Conference on Programming Language Design and Implementation, 2018.
  * [12] Kalhan Koul, Jackson Melchert, Kavya Sreedhar, Leonard Truong, Gedeon Nyengele, Keyi Zhang, Qiaoyi Liu, Jeff Setter, Po-Han Chen, Yuchen Mei, Maxwell Strange, Ross Daly, Caleb Donovick, Alex Carsello, Taeyoung Kong, Kathleen Feng, Dillon Huff, Ankita Nayak, Rajsekhar Setaluri, James Thomas, Nikhil Bhagdikar, David Durst, Zachary Myers, Nestan Tsiskaridze, Stephen Richardson, Rick Bahr, Kayvon Fatahalian, Pat Hanrahan, Clark Barrett, Mark Horowitz, Christopher Torng, Fredrik Kjolstad, and Priyanka Raina.  Aha: An agile approach to the design of coarse-grained reconfigurable accelerators and compilers.  ACM Trans. Embed. Comput. Syst., 22(2), jan 2023.
  * [13] Maxim Milakov and Natalia Gimelshein.  Online normalizer calculation for softmax, 2018.
  * [14] OpenAI.  Gpt-4 technical report, 2023.
  * [15] Raghu Prabhakar, David Koeplinger, Kevin J. Brown, HyoukJoong Lee, Christopher De Sa, Christos Kozyrakis, and Kunle Olukotun.  Generating configurable hardware from parallel patterns.  In Proceedings of the Twenty-First International Conference on Architectural Support for Programming Languages and Operating Systems, ASPLOS ’16, page 651–665, New York, NY, USA, 2016. Association for Computing Machinery.
  * [16] Raghu Prabhakar, Yaqi Zhang, David Koeplinger, Matt Feldman, Tian Zhao, Stefan Hadjis, Ardavan Pedram, Christos Kozyrakis, and Kunle Olukotun.  Plasticine: A reconfigurable architecture for parallel paterns.  In Proceedings of the 44th Annual International Symposium on Computer Architecture, pages 389–402, 2017.
  * [17] Markus N Rabe and Charles Staats.  Self-attention does not need o(n2̂) memory.  2021\.
  * [18] Alexander Rucker, Shiv Sundram, Coleman Smith, Matthew Vilim, Raghu Prabhakar, Fredrik Kjolstad, and Kunle Olukotun.  Revet: A language and compiler for dataflow threads.  arXiv preprint arXiv:2302.06124, 2023.
  * [19] Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Ł ukasz Kaiser, and Illia Polosukhin.  Attention is all you need.  In Advances in Neural Information Processing Systems 30, 2017.
  * [20] Nathan Zhang, Rubens Lacouture, Gina Sohn, Qizheng Zhang, Fredrik Kjolstad, and Kunle Olukotun.  The dataflow abstract machine simulator framework.  In 2024 ACM/IEEE 44th Annual International Symposium on Computer Architecture (ISCA) (To Appear), 2024.


# Inflationary magnetogenesis with a self-consistent coupling function

Yu Li111 Corresponding author. School of Science, Dalian Maritime University,
Dalian 116026, China
<EMAIL_ADDRESS>Le-Yao Zhang  School of Science, Dalian Maritime
University, Dalian 116026, China
<EMAIL_ADDRESS>
###### Abstract

In this paper, we discuss the inflationary magnetogenesis scenario, in which
the coupling function is introduced to break the conformal invariance of
electromagnetic action. Unlike in conventional models, we deduce the Maxwell’s
equations under the perturbed FRW metric. We found that, the self-consistency
of the action depends on the form of the coupling function when the scalar
mode perturbations have been considered. Therefore, this self-consistency can
be seen as a restriction on the coupling function. In this paper, we give the
restrictive equation for coupling function then obtain the specific form of
the coupling function in a simple model. We found that the coupling function
depends on the potential of the inflaton and thus is model dependent. We
obtain the power spectrum of electric field and magnetic field in large-field
inflation model. We also found that the coupling function is a incresing
function of time during slow-roll era as most of inflationary magnetogenesis
models, it will lead to strong coupling problem. This issue is discussed
qualitatively by introducing a correction function during the preheating.

###### keywords:

Primordial magnetic field; inflationary magnetogenesis; cosmology
perturbations.

Received (Day Month Year)Revised (Day Month Year)

PACS Nos.:98.80.Cq.

##  1 Introduction

Observations indicate that the universe is magnetized on a wide range of
length scales[1, 2, 3, 4, 5, 6, 7]. The sources of these magnetic fields are
still unclear. There are two types of models that can be used to explain the
origin of these magnetic fields: astrophysical scenario [8, 9, 10, 11] and
primordial scenario(see Refs.[12, 13, 14, 15] for reviews). The former
believes that these magnetic fields originate from some astrophysical
processes. The origin of magnetic fields in galaxies and clusters can be
explained in such models. However, this type of models is difficult to explain
the origin of the magnetic fields in cosmic voids. The magnetic fields in the
cosmic voids are more like the origin of the early universe[5, 16, 17]. The
latter, i.e. primordia scenario, assumes that these large-scale magnetic
fields originated in the early stage of the universe.

One class of possible sources of the primordial magnetic fields are phase
transitions like electroweak phase transition [18, 19, 20] or the QCD
transtition [21, 22]. However, in these scenarios very tiny fields on galactic
scales obtain unless helicity is also generated, in which case one can have an
inverse cascade of energy to large scales[23, 24]. The other class of possible
sources of primordial magnetic field are inflationary magnetogenesis[25, 26,
27, 28, 29, 30, 31, 32, 33, 34, 35]. The inflation provides an ideal setting
for the generation of primordial large-scale field[25], therefore we focus on
the inflationary magnetogensis in this paper.

Due to the conformal invariance of the standard electromagnetic action and the
FRW metric is conformally flat, the electromagnetic field is not amplified
during the inflation era [36]. Therefore, in order to be able to generate
large scale magnetic fields by inflation, it is necessary to break this
conformal invariance[25, 26, 27, 37, 38, 39, 40, 41]. One way to do this is to
introduce a time-dependent coupling function $f^{2}(\phi)$ into the action
[26].

On the other hand, an effective way of linking theoretical models to
observations is to consider the effects of the existence of large-scale
magnetic fields on cosmological perturbations. While, cosmological
perturbations will also in turn affect the evolution of large-scale magnetic
fields. So the complete discussion should be to solve the evolution of
electromagnetic field and cosmological perturbation together. In other words,
it is necessary to consider the magentogenesis in inflation model in which
cosmological perturbations have been included.

Hovever, it is difficult to solve the equations which include all fields
(pertubations and electromagnetic field). There are two methods to discuss
this issue approximately. One way is to consider the magnetogenesis in
unperturbed FRW metric and discuss its backreaction on the perturbations e.g.
on CMB. Most of the current work is done in this way (see [42, 43, 44, 45] for
example). The other way, which is used in this paper, is to consider the
magnetogenesis in perturbed FRW metric and discuss the influence of
perturbations on the electromagnetic field.

As we will discuss in this paper, the existence of cosmological perturbations
restrict the form of the coupling function. Under the FRW background, the
introduction of the coupling function does not destroy the self-consistency of
the action, which means that the secondary constraint equation for
electromagnetic field $\vec{\nabla}\cdot\vec{E}=0$ is satisfied automatically.
However, if one consider the perturbed FRW background, this constraint
equation will be not a trivial equation. In this situation, we can treat this
equation as the restriction on the coupling function, i.e. the form of a self-
consistent coupling function $f(\phi)$ should satisfy this equation. The
purpose of this paper is to discuss the inflationary magnetogensis with this
self-consistent coupling function.

This paper is organized as follow: We deduce the Maxwell’s equations under the
perturbed FRW metric , and then get the restrict equation for $f(\phi)$ in
section 2 . We apply this restrict equation to slow-roll inflation in the end
of section 2 and obtain the power spectrum of electromagnetic field in large-
field inflation model in section 3 . We also discuss the backreaction in
section 3 and strong coupling problems in section 4 , the summary in the
section 5 .

##  2 Maxwell’s equations under perturbated FRW background

To get the restrict equation for $f(\phi)$, let us consider the FRW metric
with scalar mode of inhomogeneous perturbations in longitudinal gauge:

$\displaystyle ds^{2}$ $\displaystyle=$
$\displaystyle-(1+2\Phi)dt^{2}+a^{2}(t)(1-2\Phi)\delta_{ij}dx^{i}dx^{j}$ (1)
$\displaystyle=$ $\displaystyle
a^{2}(\eta)\left[-(1+2\Phi)d\eta^{2}+(1-2\Phi)\delta_{ij}dx^{i}dx^{j}\right]$
(2)

where $\Phi$ is Bardeen potential, $t$ is cosmic time and $\eta$ is conformal
time. The action of matter during inflation can be written as [26]:

$S=-\frac{1}{16\pi}\int
d^{4}x\sqrt{-g}\left[g^{\alpha\beta}g^{\mu\nu}f^{2}(\varphi)F_{\mu\alpha}F_{\nu\beta}\right]-\int
d^{4}x\sqrt{-g}\left[\frac{1}{2}g^{\mu\nu}\partial_{\mu}\varphi\partial_{\mu}\varphi+V(\varphi)\right]$
(3)

where $\varphi(t,{\bf x})=\phi(t)+\delta\phi(t,{\bf x})$ is the inflaton and
its perturbation.
$F_{\alpha\beta}=A_{\beta;\alpha}-A_{\alpha;\beta}=A_{\beta,\alpha}-A_{\alpha,\beta}$
is the electromagnetic field tensor, with $A_{\alpha}$ being the standard
electromagnetic 4-potential. $f(\varphi)$ is the coupling function which is
introduced to break the conformally invariant of the standard electromagnetic
action [26]. For the convenience of discussion, we expand the coupling
function as:

$f^{2}(\varphi)=f^{2}(\phi+\delta\phi)\approx\left[f(\phi)+\frac{df}{d\varphi}\Big{|}_{\phi}\delta\phi\right]^{2}\approx
f^{2}(\phi)\left[1+\mathcal{G}(\phi)\delta\phi\right]$ (4)

where

$\mathcal{G}(\phi)\equiv\frac{2}{f(\phi)}\frac{df}{d\varphi}\Big{|}_{\phi}$
(5)

It is worth to notice that $\mathcal{G}$ depend only on time or, in other
words, it is scale-independent.

In the model we discuss here, we treat the electromagnetic field as a “test”
field which means that $F_{\alpha\beta}$ do not affect the evolution of the
background ($a$ and $\phi$) and perturbations ($\Phi$ and $\delta\phi$), but
the background and perturbations can affect the evolution of electromagnetic
field.

The Maxwell’s equations can be obtain by using the action (3):

$\partial_{\rho}\left[\sqrt{-g}f^{2}(\varphi)g^{\sigma\mu}g^{\rho\nu}F_{\mu\nu}\right]=0$
(6)

For conformal time, the time component of Eq.(6) ($\sigma=0$) lead to:

$\partial_{i}\left[f^{2}(\phi)(1-2\Phi+\mathcal{G}\delta\phi)\delta^{ij}F_{0j}\right]=0$
(7)

In Minkowski spacetime, Eq.(7) is noting but $\vec{\nabla}\cdot\vec{E}=0$.
This is the secondary constraint equation for source-free electromagnetic
field (one can refer to Appendix E in [46]).We will see later, this equation
is trivial equation in FRW background and is non-trivial in perturbed
background.

The space component of Eq.(6) ($\sigma=i$) can also be obtain similarly:

$\displaystyle(1-2\Phi+\mathcal{G}\delta\phi)A^{\prime\prime}_{j}-(1+2\Phi+\mathcal{G}\delta\phi)\nabla^{2}A_{j}$
$\displaystyle+\left[\mathcal{G}\phi^{\prime}(1-2\Phi+\mathcal{G}\delta\phi)-2\Phi^{\prime}+\mathcal{G}^{\prime}\delta\phi+g\delta\phi^{\prime}\right]A^{\prime}_{j}$
$\displaystyle+(2\Phi_{,k}+\mathcal{G}\delta\phi_{,k})\delta^{k\ell}(A_{\ell,j}-A_{j,\ell})=0$
(8)

where $\nabla^{2}\equiv\delta^{k\ell}\partial_{k}\partial_{\ell}$ is Laplace
operator and ′ denote the derivative with respect to conformal time. For the
convenience of discussion, we assume that $A_{i}$ can be expressed as
perturbation expansion:

$A_{i}=A_{i}^{(0)}+A_{i}^{(1)}+A^{(2)}_{i}+\cdots$ (9)

where $O[A_{i}^{(0)}]\sim O[\Phi]$.

In this paper we adopt the Coulomb gauge:$A_{0}(\eta,{\bf
x})=0,~{}\partial_{j}A^{j}(\eta,{\bf x})=0$. Under this gauge, Maxwell’s
equations can be rewritten as:

$\partial_{i}\left\\{\mathcal{G}\delta\phi[A^{(0)}_{j}]^{\prime}-4\Phi[A^{(0)}_{j}]^{\prime}-2A^{(0)}_{j}\Phi^{\prime}\right\\}\delta^{ij}=0$
(10)

and

$\left\\{[A^{(0)}_{j}]^{\prime\prime}+\mathcal{G}\phi^{\prime}[A^{(0)}_{j}]^{\prime}-\nabla^{2}A^{(0)}_{j}\right\\}+\left\\{[A^{(1)}_{j}]^{\prime\prime}+\mathcal{G}\phi^{\prime}[A^{(1)}_{j}]^{\prime}-\nabla^{2}A^{(1)}_{j}\right\\}-Q_{j}^{(1)}=0$
(11)

where:

$\displaystyle Q_{j}^{(1)}$ $\displaystyle\equiv$
$\displaystyle(2\Phi-\mathcal{G}\delta\phi)\left\\{[A^{(0)}_{j}]^{\prime\prime}+\mathcal{G}\phi^{\prime}[A^{(0)}_{j}]^{\prime}-\nabla^{2}A^{(0)}_{j}\right\\}$
(12) $\displaystyle+$
$\displaystyle(2\Phi-\mathcal{G}\delta\phi)^{\prime}[A^{(0)}_{j}]^{\prime}+4\Phi\nabla^{2}A^{(0)}_{j}+\delta^{k\ell}(\mathcal{G}\delta\phi+2\Phi)_{,k}(A^{(0)}_{j,\ell}-A^{(0)}_{\ell,j})$

Notice that, all the order in the left of Eq.(11) should be zero, therefore
the space component of Maxwell equations lead to

$\displaystyle[A^{(0)}_{j}]^{\prime\prime}+\mathcal{G}\phi^{\prime}[A^{(0)}_{j}]^{\prime}-\nabla^{2}A^{(0)}_{j}$
$\displaystyle=$ $\displaystyle 0$ (13)
$\displaystyle~{}[A^{(1)}_{j}]^{\prime\prime}+\mathcal{G}\phi^{\prime}[A^{(1)}_{j}]^{\prime}-\nabla^{2}A^{(1)}_{j}$
$\displaystyle=$ $\displaystyle Q_{j}^{(1)}$ (14)

If scalar perturbations are not taken into account ($\Phi=\delta\phi=0$), then
time component of Maxwell’s equations Eq.(10) becomes a trivial equation, and
source term $Q_{j}^{(1)}$ vanish. One can choose the form of the coupling
function $f(\phi)$ (and $\mathcal{G}$) freely from the beginning and solve the
space component Eq.(13,14) directly. However, once the scalar perturbations
have been considered, Eq.(10) is no longer trivial. This means that not any
coupling function can make the theory self-consistent. The form of the
coupling function is to ensure that this constraint equation holds. Although
Eq.(10) is order $O[\Phi^{2}]$, it does not means that the restriction on
coupling function is order of perturbations. The trivial or non-trivial of
Eq.(10) is essentially different. This fact is not surprising. It is rooted in
the fact that the choice of Lagrangian density is not arbitrary and it needs
to satisfy self-consistent conditions[47].

From Eq.(10,13,14) one can see that, there are two aspects to the influence of
cosmological perturbations on electromagnetic fields:

  1. 1.

The perturbations restrict the form of coupling function by Eq.(10).

  2. 2.

The perturbations (and $A^{(0)}_{j}$) provide a source term $Q_{j}^{(1)}$ for
$A^{(1)}_{j}$.

An consistent discussion should be solving Eq.(10,13,14) together. However,
one can notice that, there is no $A^{(1)}_{j}$ in Eq.(10) and Eq.(13). This
means that we can solve Eq.(10,13) to obtain the $\mathcal{G}$ and
$A^{(0)}_{j}$ first, and then insert the $\mathcal{G}$ and $A^{(0)}_{j}$ into
Eq.(14) to get the solution of $A^{(1)}_{j}$.

Furthermore, the source term $Q_{j}^{(1)}$ in Eq.(14) is order $O[\Phi^{2}]$,
and then the $A^{(1)}_{j}$ will be more smaller than $A^{(0)}_{j}$. Therefore
in this paper, we only focus on the evolution of the main part of $A_{j}$,
i.e. $A_{j}^{(0)}$. In other words, we only focus on the influence (i) of
cosmological perturbations.

In fact, Eq.(13) is the same as the evolution equation of the electromagnetic
4-potential in the conventional model [41] besides the coupling function and
$A^{(0)}_{j}$ should satisfy the Eq.(10). We treat Eq.(10) as a restriction on
the form of the coupling function. One can choose a coupling function which
satisfy Eq.(10), then to solve the Eq.(13).

From Eq.(10), one can obtain that

$\mathcal{G}\delta\phi[A^{(0)}_{j}]^{\prime}-4\Phi[A^{(0)}_{j}]^{\prime}-2A^{(0)}_{j}\Phi^{\prime}=\mathbb{C}(\eta)$
(15)

where $\mathbb{C}(\eta)$ is the function of $\eta$. The choice of function
$\mathbb{C}(\eta)$ will affect the form of the coupling function.

In order to get the specific form of the coupling function, we consider the
slow-roll era of inflation first. During the slow-roll inflation, the super-
Hubble scale Fourier mode of Bardeen potential $\Phi_{k}$ satisfy[48, 49]

$\Phi^{\prime}_{k}=0,~{}~{}~{}~{}\Phi_{k}\approx\epsilon\mathcal{H}\frac{\delta\phi_{k}}{\phi^{\prime}}$
(16)

where $\epsilon\equiv-\dot{H}/H^{2}$ is slow-roll parameter, and dot denote
the derivative with respect to cosmic time. $\mathcal{H}\equiv a^{\prime}/a$
is conformal Hubble parameter and $\delta\phi_{k}$ is Fourier mode of
$\delta\phi$. If one consider the large scales only, then we have:

$\Phi^{\prime}\approx
0,~{}~{}~{}~{}\Phi\approx\epsilon\mathcal{H}\frac{\delta\phi}{\phi^{\prime}}$
(17)

Insert Eq.(17) into Eq.(15) one can get

$\mathcal{G}=4\frac{\epsilon\mathcal{H}}{\phi^{\prime}}+\frac{\mathbb{C}(\eta)}{\delta\phi[A^{(0)}_{j}]^{\prime}}$
(18)

From the Eq.(5), one can see that $\mathcal{G}$ is scale-independent,
therefore the second term in righthand of Eq.(18) should vanish, which means
that we should consider the models in which $\mathbb{C}(\eta)=0$. This
consideration give

$\mathcal{G}=4\frac{\epsilon\mathcal{H}}{\phi^{\prime}}$ (19)

Although the above discussion only considers the behavior at large scales, the
form of the $\mathcal{G}$ is scale-independent, so Eq.(19) holds at all
scales.

During the slow-roll inflation, the Klein-Gorden equation of $\phi$ is
$3H\dot{\phi}\approx-V_{,\phi}$. Note that the Friedmann equation in the slow-
roll inflation is $H^{2}\approx V/3$, then Eq.(19) change to

$\mathcal{G}=-2\frac{V_{,\phi}}{V}$ (20)

Using Eq.(5) one can get the form of coupling function $f(\phi)$ as:

$f(\phi)\propto\exp\left(-\int^{\phi}\frac{V_{,\phi}}{V}d\phi\right)\propto
V^{-1}$ (21)

Eq.(21) shows that the form of self-consistent coupling functiong depend on
the potential of inflaton. In other words, the form of the coupling function
is model dependent.

##  3 Power spectrum of electromagnetic field in large-field model

To obtain the power spectrum of electromagnetic field, we consider the large-
field inflation with polynomial potentials:

$V(\phi)=\Lambda^{4}\left(\frac{\phi}{\mu}\right)^{p}~{}~{}~{}~{}(p>0)$ (22)

where $\Lambda$ is the “height” of potential, corresponding to the vacuum
energy density during inflation, and $\mu$ is the “width” of the potential,
corresponding to the change in the field value $\Delta\phi$ during
inflation[49].

According to Eq.(21), the coupling function in this large-field model is

$f(\phi)\propto\phi^{-p}$ (23)

By using $\dot{\phi}\approx-V,_{\phi}/3H,~{}~{}3H^{2}\approx V$ during slow-
roll inflation one can have[50]:

$\ln\frac{a}{a_{i}}=-\frac{1}{2p}(\phi^{2}-\phi_{i}^{2})$ (24)

where $a_{i}$ and $\phi_{i}$ is the scale factor and value of inflaton at the
beginning of the inflation. And then the coupling function can be written as
the function of scale factor:

$f(a)\propto\left(-2p\ln\frac{a}{a_{i}}+\phi_{i}^{2}\right)^{-p/2}$ (25)

This form of $f(\phi)$ is different from conventional models (see [15] for
review). In these models, it is often assumed that the coupling function has a
power law form of scale factor. However, Eq.(25) shows that the form of the
self-consistent coupling function is not a power law form as in conventional
models. This means that the power-law-like coupling function does not satisfy
the self-consistent condition Eq.(15). This is the main difference between the
model we discuss here and the conventional models.

During slow-roll inflation era, the scale factor as the function of confomal
time $a(\eta)$ can be assumed as:

$a(\eta)=a_{i}\left|\frac{\eta}{\eta_{i}}\right|^{1+\beta}$ (26)

where $\eta_{i}$ is the conformal time when the inflation begin. The case
$\beta=-2$ corresponds to de Sitter space-time. During the inflation,
$\eta\rightarrow 0_{-}$. Insert Eq.(26) into Eq.(25) we have:

$f\propto\left[-2p(1+\beta)\ln\left|\frac{\eta}{\eta_{i}}\right|+\phi^{2}_{i}\right]^{-p/2}$
(27)

It is worth noting that the coupling function will diverges at the conformal
time

$|\eta_{\infty}|=|\eta_{i}|\exp\left[\frac{\phi^{2}_{i}}{2p(1+\beta)}\right]$
(28)

When $\eta=\eta_{\infty}$, $\phi=0$, which means that the slow roll phase has
been ended before $\eta_{\infty}$.

Insert Eq.(28) into Eq.(27) one can get:

$f\propto\left[2p(1+\beta)\ln\left|\frac{\eta_{\infty}}{\eta}\right|\right]^{-p/2}\propto\left[\ln\left|\frac{\eta_{\infty}}{\eta}\right|\right]^{-p/2}$
(29)

The next step is to solve Eq.(13) by using coupling function Eq.(27) or
Eq.(29). Before that, it is convenient to set $\mathcal{A}\equiv
a(\eta)f(\phi(\eta))A^{(0)}_{j}(\eta,k)$, where $A^{(0)}_{j}(\eta,k)$ is
Fourier mode of $A^{(0)}_{j}$. Eq.(13) can be written as[15]:

$\mathcal{A}^{\prime\prime}(\eta,k)+\left(k^{2}-\frac{f^{\prime\prime}}{f}\right)\mathcal{A}(\eta,k)=0$
(30)

At the beginning of inflation, $\eta\approx\eta_{i}$. This means
$f^{\prime\prime}/f\approx 0$ and the Eq.(30) change to

$\mathcal{A}^{\prime\prime}+k^{2}\mathcal{A}=0~{}~{}\Rightarrow~{}~{}\mathcal{A}\propto\exp(\pm
ik\eta)$ (31)

At small scale limit, the solution should be “negative frequency”[27]. In
order to satisfy the Wronskian condition[27], the solution of $\mathcal{A}$
should be

$\mathcal{A}=\frac{1}{\sqrt{2k}}\exp(-ik\eta)$ (32)

At the late time of inflation when $\eta\approx\eta_{\infty}$ we have

$\frac{f^{\prime\prime}}{f}\approx\frac{p}{2}\left(\frac{p}{2}+1\right)T^{-2}$
(33)

where $T\equiv|\eta_{\infty}|-|\eta|=\eta-\eta_{\infty}$, therefore $T<0$
during the slow-roll inflation. Notice that $dT=d\eta$, then the Eq.(30)
change to

$\frac{d^{2}}{dT^{2}}\mathcal{A}+\left[k^{2}-\frac{p}{2}\left(\frac{p}{2}+1\right)T^{-2}\right]\mathcal{A}=0$
(34)

The general solution of Eq.(34) is

$\mathcal{A}=(-kT)^{1/2}\left[C_{1}(k)J_{\nu}(-kT)+C_{2}(k)J_{-\nu}(-kT)\right]$
(35)

where $\nu\equiv(1+p)/2$.

When $|\eta|\gg|\eta_{\infty}|$, Eq.(35) should be approximated to Eq.(32).
While, when $|\eta|\gg|\eta_{\infty}|$, $T\approx\eta$, therefore Eq.(35) just
need to be approximated to

$\mathcal{A}=\frac{1}{\sqrt{2k}}\exp(-ikT)$ (36)

Eq.(36) can be used to determine the coefficient $C_{1},C_{2}$. We focus on
the behavior on large scale, so we take the large scale limit:
$-k\eta\rightarrow 0\Rightarrow-kT\rightarrow 0$. After ignoring the decay
term, we have:

$\mathcal{A}\approx k^{-1/2}c(\gamma)(-kT)^{1-\gamma}$ (37)

where

$c(\gamma)=\sqrt{\frac{\pi}{2^{3-2\gamma}}}\frac{\exp[i\pi(1+\gamma)/2]}{\Gamma(3/2-\gamma)\cos(\pi\gamma)}$
(38)

and $\gamma\equiv 1+p/2>1$. Therefore the power spectrum of magnetic field is

$\frac{d\rho_{B}}{dk}=\frac{1}{k}\frac{d\rho_{B}}{d\ln
k}=\frac{c^{2}(\gamma)}{2\pi^{2}k}H^{4}(k\eta)^{6-2\gamma}\left(1-\frac{\eta_{\infty}}{\eta}\right)^{2-2\gamma}$
(39)

The power spectrum of electric field can also be obtain:

$\frac{d\rho_{E}}{dk}=\frac{1}{k}\frac{d\rho_{E}}{d\ln
k}\approx\frac{d^{2}(\gamma)}{2\pi^{2}k}H^{4}(k\eta)^{4-2\gamma}\left(1-\frac{\eta_{\infty}}{\eta}\right)^{-2\gamma}$
(40)

where

$d(\gamma)=\frac{\sqrt{\pi}\exp[i\pi(1+\gamma)/2]}{2^{-\gamma+1/2}\Gamma(-\gamma+1/2)\cos(\pi\gamma)}$
(41)

From Eq.(39,40) we can see that the spectral index of magnetic power spectrum
is $n_{B}=6-2\gamma$ and the spectral index of electric power spectrum is
$n_{E}=4-2\gamma$. Therefore, scale invariant spectrum of magnetic field can
be got when $\gamma=3$ i.e. $p=4$. When $\gamma=2$ i.e. $p=2$ one can get the
scale invariant spectrum of electric field. If the magnetic field spectrum is
scale invariant ($\gamma=3$), the electric field spectrum is red.

Because of $\gamma>1$, it is can be seen from Eq.(39) and Eq.(40) that the
spectrum of magnetic and electric field will increase rapidly when
$\eta\rightarrow\eta_{\infty}$. This can cause backreaction problem.

However, as we discussed above, the slow-roll inflation will ended before
$\eta_{\infty}$. We assume that the moment when the slow-roll ends is
$\eta_{end}$, and the value of inflaton at this moment is $\phi_{end}$. Then
we can get approximately that

$\left|\frac{\eta_{\infty}}{\eta_{end}}\right|-1\approx\ln\left|\frac{\eta_{\infty}}{\eta_{end}}\right|=-\frac{\phi_{end}^{2}}{2p(1+\beta)}\equiv\mathcal{Y}$
(42)

Insert Eq.(42) into Eq.(39,40) one can estimate the power spectrum of magnetic
and electric field at the end of slow-roll inflation:

$\displaystyle\frac{d\rho_{B}}{d\ln k}\big{|}_{end}$ $\displaystyle\approx$
$\displaystyle\frac{c^{2}(\gamma)}{2\pi^{2}}H^{4}_{end}\left(\frac{k}{a_{end}H_{end}}\right)^{6-2\gamma}\mathcal{Y}^{2-2\gamma}$
(43) $\displaystyle\frac{d\rho_{E}}{d\ln k}\big{|}_{end}$
$\displaystyle\approx$
$\displaystyle\frac{d^{2}(\gamma)}{2\pi^{2}}H^{4}_{end}\left(\frac{k}{a_{end}H_{end}}\right)^{4-2\gamma}\mathcal{Y}^{-2\gamma}$
(44)

To avoid the backreaction problem, the energy density of electromagnetic field
can not exceed the energy density of the inflaton, this require that

$\frac{d\rho_{B}}{d\ln k}\big{|}_{end}+\frac{d\rho_{E}}{d\ln
k}\big{|}_{end}<\rho_{end}$ (45)

We focus on scale invariant spectrum of magnetic field, i.e. $\gamma=3,p=4$,
then Eq.(45) means

$\frac{H_{end}^{4}}{2\pi^{2}}\mathcal{Y}^{-6}d^{2}(\gamma)\left(\frac{k}{a_{0}H_{0}}\right)^{-2}\left(\frac{a_{0}H_{0}}{a_{end}H_{end}}\right)^{-2}<\frac{3}{8\pi}H^{2}_{end}M_{pl}^{2}$
(46)

The ratio $(a_{0}H_{0})/(a_{end}H_{end})$ can be estimated as[27]:

$\frac{a_{0}H_{0}}{a_{end}H_{end}}\approx 1.51\times
10^{-29}\frac{h}{R},~{}~{}~{}~{}~{}~{}(h\approx 0.72)$ (47)

where $R$ depend on the reheating phase, and for simple estimate one can chose
$R\approx\rho_{end}^{1/4}$ as in [27]. Insert these into Eq.(46) we can have

$\rho_{end}<\left(\phi_{end}M_{pl}^{1/3}\right)^{8}\times 10^{-42}$ (48)

If one require the $\rho_{end}$ should be satify the requirements of
nuleosynthesis ($\rho_{nuc}\approx 10^{-85}M_{pl}^{4}$), then

$\phi_{end}>10^{-43}M_{pl}^{4/3}$ (49)

This means that as long as the slow-roll era ends before the inflaton decays
too small, the backreaction problem can be avoided.

We also can estimate the present day value of magnetic field strength simply.
From Eq.(43) we know that the power spectrum of the model in this paper is
amplified by the factor $\mathcal{Y}^{2-2\gamma}$ compare with the
conventional model [15, 41]. This factor is independ on the scale factor. If
one assume the instant reheating, then the present day power spectrum of
magnetic field is also amplified by this factor.

While, this factor is depend on the detail of the inflation model,
specifically on $\phi_{end}$. For example, for scale invariant magnetic
pectrum, i.e. $V(\phi)\propto\phi^{4}$ , this factor is
$(8/\phi_{end}^{2})^{4}$. In $\phi^{4}$ inflation model, the slow-roll era
ends at $\phi_{end}\approx M_{pl}/2$ [51], and this factor change to
$(4/\pi)^{4}$. Therefore, the present day value of magnetic field strength is
amplified by $(4/\pi)^{2}\approx 1.6$ compare with the conventional model
[41]. This means that the magnetic field on coherence scale 1Mpc today is

$B_{0}\approx 8\times 10^{-10}G\left(\frac{H}{10^{-5}M_{pl}}\right)$ (50)

This result satisfy the lower bound of $\gamma$-ray observation $B\sim
10^{-15}G$ [5, 7].

Notice that the lower limit of $\phi_{end}$ is very small (see Eq.(49)), then
the magnitude of the $\mathcal{Y}$ factor has a large span. Therefore, we can
use $\phi_{end}$ as a tunable parameter of the model, and adjust the value of
it to make the predicted magnetic field strength of the model consistent with
today’s observations.

##  4 Strong coupling

As the last part of this paper, we will discuss the problem of strong coupling
qualitatively. From Eq.(27) we know that the coupling function is
monotonically increasing function during the slow-roll of inflation. This will
lead to the strong coupling problem which was first pointed out in [52]. To
avoid this problem, one can assume a decreasing coupling function during the
preheating era like in [33].

However, in this paper, we found that the coupling fucntion should satisfy the
Eq.(15). An attractive possibility is that this equation can lead to an
decrease coupling function after the slow-roll of inflation. Therefore it is
interesting to discuss the behavior of coupling function during the
preheating.

It should be noted that, Eq.(27) is satisfied only in slow-roll era. During
the preheating, the coupling function should be obtain by solving the
Eq.(13,15) together. One can eliminate the $A_{j}$ by combining Eq.(13,15) and
get

$\mathcal{D}_{1}h^{\prime}+\mathcal{D}_{2}h+\mathcal{D}_{3}h^{2}+\mathcal{D}_{4}=0$
(51)

where

$\displaystyle\mathcal{D}_{1}=\phi^{\prime 2}-2\mathcal{H}q$ (52)
$\displaystyle\mathcal{D}_{2}=4q\phi^{\prime
2}-8\mathcal{H}q^{2}-2\phi^{\prime}\phi^{\prime\prime}+2\mathcal{H}^{\prime}q+2\mathcal{H}q^{\prime}$
(53) $\displaystyle\mathcal{D}_{3}=-\phi^{\prime 2}+2\mathcal{H}q$ (54)
$\displaystyle\mathcal{D}_{4}=-4\phi^{\prime 2}q^{\prime}-\phi^{\prime
4}+4\mathcal{H}q\phi^{\prime 2}-4\mathcal{H}^{2}q^{2}$
$\displaystyle~{}~{}~{}~{}~{}~{}+8\phi^{\prime}\phi^{\prime\prime}q-8\mathcal{H}^{\prime}q^{2}$
(55) $\displaystyle
q\equiv\frac{\Phi}{\delta\phi}\phi^{\prime},~{}~{}h\equiv\mathcal{G}\phi^{\prime}=2\frac{f^{\prime}}{f}$
(56)

Eq.(51) is the equation that the coupling function needs to satisfy during the
preheating. On large scale, the Fourier mode of Bardeen potential and
perturbation of inflaton can be written as [53]

$\Phi_{k}=\mathcal{C}\left(1-\frac{H}{a}\int
adt\right),~{}~{}~{}\delta\phi_{k}\approx\mathcal{C}\dot{\phi}\left(a^{-1}\int
adt\right)$ (57)

Consider the case where the magnetic field is scale invarant $p=4$, which
means that we should consider the $\phi^{4}$ preheating. In this model of
preheating, $a\propto\sqrt{t}$ and the evolution of $\phi$ can be approximated
as [51]

$\phi\approx\frac{\tilde{\phi}}{a}\cos(0.8472\sqrt{\lambda}\tilde{\phi}\eta)$
(58)

For qualitative discussion, we assume

$\phi=\frac{1}{\eta}\cos\eta$ (59)

Figure 1: Coupling function during $\phi^{4}$ preheating with no correction.

The evolution curve of the coupling function given in the Fig.1. It can be
seen that the coupling function will increase during the preheating era. This
will lead to strong coupling problem.

In conventional models, one strategy to solve strong coupling problem is to
ansatz a decreasing coupling function during the preheating era directly as in
[33]. However, in the models we consider here, the coupling function should
satisfy Eq.(51), which means that the coupling function is model dependent. In
other words, to get the decreasing coupling function, we should modify the
preheating model.

We consider a toy model in which there are some modifications at the beginning
of $\phi^{4}$ preheating. As the preheating process goes on, the modificatons
will vanish and the preheating model will approximate to the $\phi^{4}$ model.

These modifications affect both the dynamics of background
$\phi,~{}\mathcal{H}...$ and perturbation $\Phi,~{}\delta\phi...$, and affect
the Eq.(51). We assume that the effect of these modifications of preheating
model change the Eq.(51) to

$\mathcal{D}_{1}\hat{h}^{\prime}+\mathcal{D}_{2}\hat{h}+\mathcal{D}_{3}\hat{h}^{2}+\mathcal{D}_{4}=0$
(60)

where

$\hat{h}(\eta)\equiv h(\eta)+r(\eta)$ (61)

and $r(\eta)$ is a decreasing function of $\eta$. In Eq.(60), the dynamics of
$\phi,\mathcal{H},\delta\phi,\Phi$ are the same as in $\phi^{4}$ model, which
means that we assume the modifications of preheating model equivalent to
introduce a correction function $r(\eta)$ in Eq.(51).

As the preheating proceeds, the correction function will tend to zero and
$\hat{h}\rightarrow h$, therefore $h$ will satisfy the Eq.(51) at late time of
preheating and the preheating model approximate to the $\phi^{4}$ model as we
assumed.

One simple choice of $r(\eta)$ is

$r(\eta)=\frac{1}{\eta^{n}}$ (62)

Notice that the form of $r(\eta)$ depend on the modifications of preheating
model, then the parameter $n$ can be seen as a parameter of preheating model.
This parameter can be choosen to avoid the strong problem.

Figure 2: Coupling function during $\phi^{4}$ preheating with different
correction functions.

The evolution of coupling function during preheating with different choices of
$r(\eta)$ are given in Fig.2. It can be seen that a decreasing coupling
function can be obtained by selecting the appropriate parameter n (i.g. $n=1$
in Fig.2), and then the strong coupling can be avoided.

##  5 Summary and discussion

In this paper, we discuss the inflationary magnetogenesis with a coupling
function which can keep the action to be self-consistent. This self-
consistence coming from the time component of Maxwell’s equation which is the
secondary constraint for electromagnetic field. Under the FRW metric, this is
a trival equation. However, once we consider the perturbed metric, this
equation become non-trival and can be seen as a restrict equation for coupling
function $f(\phi)$, see Eq.(10). Taking this as a starting point, we
calculated the power spectrum of the electric and magnetic fields in the
large-scale inflation model. We estimate the present day value of magnetic
field, and the result satisfy the lower bound of $\gamma$-ray observation.

We found that, the power spectrum obtained in this paper is multiplied by a
factor related to $\phi_{end}$ compared to the conventional model[15, 41].
This means that one can generate the required magnetic field by choosing a
suitable inflation model, or conversely use the magnetic field observed today
to limit $\phi_{end}$. This provides a possibility to use today’s large-scale
magnetic field strength to estimate the value of the inflaton field at the end
of the slow-roll.

On the other hand, to avoid the backreaction problem at the end of inflation,
the value of inflaton at the end of slow-roll era $\phi_{end}$ should have a
lower limit ($\sim 10^{-43}$)(see Eq.(49)). This lower limit is so small that
the upper limit of the factor $\mathcal{Y}$ can be large. This means that the
model discussed in this paper can generate a sufficiently strong magnetic
field without causing backreaction problem.

The strong coupling problem can also appear in the situation which is
discussed here. One way to solve the problem of strong coupling is to
introduce an decreasing coupling function in the preheating era. In this
paper, the coupling function is determined by Eq.(7) or Eq.(51) in preheating
era. Unfortunately these equations give an increasing coupling function. To
make the coupling function change to a decreasing function, it is necessary to
introduce a correction function in the early stage of preheating. So it is a
very interesting open topic to find a suitable preheating model in which the
coupling function can naturally be determined as an decreasing function.

## Acknowledgments

This work was supported by the Fundamental Research Funds for the Central
Universities of Ministry of Education of China under Grants No. 3132018242,
the Natural Science Foundation of Liaoning Province of China under Grant
No.20170520161 and the National Natural Science Foundation of China under
Grant No.11447198 (Fund of theoretical physics).

## References

  * [1] P. P. Kronberg, Rept. Prog. Phys. 57, 325 (1994).
  * [2] L. M. Widrow, Rev. Mod. Phys. 74, 775 (2002).
  * [3] R. Beck, Space Sci. Rev. 99, 243 (2001).
  * [4] T. E. Clarke, P. P. Kronberg and H. Boehringer, Astrophys. J. 547, L111 (2001).
  * [5] A. Neronov and I. Vovk, Science 328, 73 (2010).
  * [6] D. J. Stevenson, Space Sci. Rev. 152, 651 (2010).
  * [7] A. M. Taylor, I. Vovk and A. Neronov, Astron. Astrophys. 529, A144 (2011).
  * [8] K. Subramanian, D. Narasimha and S. M. Chitre, Mon. Not. R. Astron. Soc. 271, L15 (1994).
  * [9] R. M. Kularud, R. Cen, J. P. Ostriker and D. Ryu, Astrophys. J. 480, 481 (1997).
  * [10] N. Y. Gnedin, A. Ferrara and E. G. Zweibel, Astrophys. J. 539, 505 (2000).
  * [11] M. J. Rees, Astron. Nachr. 327, 395 (2006).
  * [12] D. Grasso and H. R. Rubinstein, Phys. Rept. 348, 163 (2001).
  * [13] R. Durrer and A. Neronov, Astron. Astrophys. Rev. 21, 62 (2013).
  * [14] A. Kandus, K. E. Kunze and C. G. Tsagas, Phys. Rep. 505, 1 (2011).
  * [15] K. Subramanian, Rep. Prog. Phys. 79, 076901 (2016).
  * [16] S. Archambault and et al, The Astrophysical Journal 835, 288 (2017).
  * [17] M. Ackermann and et al, The Astrophysical Journal Supplement Series 237, 32 (2018).
  * [18] T. Vachaspati, Phys. Lett. B 265, 258 (1991).
  * [19] G. Sigl, A. V. Olinto and K. Jedamzik, Phys. Rev. D 55, 4582 (1997).
  * [20] T. Vachaspati, Reports on Progress in Physics 84, 074901 (2021).
  * [21] L. S. Kisslinger, Phys. Rev. D 68, 043516 (2003).
  * [22] A. G. Tevzadze, L. Kisslinger, A. Brandenburg and T. Kahniashvili, Astrophys. J. 759, 54 (2012).
  * [23] A. Brandenburg, K. Enqvist and P. Olesen, Phys. Rev. D 54, 1291 (1996).
  * [24] R. Banerjee and K. Jedamzik, Phys. Rev. D 70, 123003 (2004).
  * [25] M. S. Turner and L. M. Widrow, Phys. Rev. D 37, 2743 (1988).
  * [26] B. Ratra, Astrophys. J. 391, L1 (1992).
  * [27] J. Martin and J. Yokoyama, J. Cosmol. Astropart. Phys. 01, 025 (2008).
  * [28] T. Kobayashi, J. Cosmol. Astropart. Phys. 14, 040 (2014).
  * [29] K. Atmjeet, I. Pahwa, T. R. Seshadri and K. Subramanian, Phys. Rev. D 89, 063002 (2014).
  * [30] L. Campanelli, Eur. Phys. J. C75, 278 (2015).
  * [31] G. Tasinato, J. Cosmol. Astropart. Phys. 15, 040 (2015).
  * [32] R. Sharma, S. Jagannathan, T. R. Seshadri and K. Subramanian, Phys. Rev. D 96, 083511 (2017).
  * [33] R. Sharma, K. Subramanian and T. R. Seshadri, Phys. Rev. D 97, 083503 (2018).
  * [34] T. Kobayashi and M. S. Sloth, Phys. Rev. D 100, 023524 (2019).
  * [35] T. Fujita and R. Durrer, Journal of Cosmology and Astroparticle Physics 2019, 008 (2019).
  * [36] L. Parker, Phys. Rev. Lett. 21, 562 (1968).
  * [37] A. D. Dolgov, Phys. Rev. D 43, 2499 (1993).
  * [38] M. Gasperini, M. Giovannini and G. Veneziano, Phys. Rev. Lett. 75, 3796 (1995).
  * [39] M. Giovannini, Phys. Rev. D 62, 123505 (2000).
  * [40] T. Fujita, R. Namba, Y. Tada and H. Tashiro, J. Cosmol. Astropart. Phys. 5, 054 (2015).
  * [41] K. Subramanian, Astron. Nachr. 331, 110 (2010).
  * [42] T. Kahniashvili, Phys. Rev. D 61, 043001 (2000).
  * [43] C. Caprini and R. Durrer, Phys. Rev. D 65, 023517 (2002).
  * [44] A. Mack, T. Kahniashvili and A. Kosowsky, Phys. Rev. D 65, 123004 (2002).
  * [45] R. Sharma, K. Subramanian and T. R. Seshadri, Phys. Rev. D 101, 103526 (2020).
  * [46] R. M. Wald, General Relativity (The University of Chicago Press, Chicago and London, 1984).
  * [47] J. E. Marsden and T. S. Ratiu, Introduction to Mechanics and Symmetry (Springer, New York, 1999).
  * [48] A. R. Liddle and D. H. Lyth, Cosmological Inflation and Large-Scale Structure (Cambridge University Press, 2000).
  * [49] A. Riotto, arXiv:hep-ph/0210162v2 (2017).
  * [50] V. F. Mukhanov, Physical Foundations of Cosmology (Cambridge Uinversity Press, 2005).
  * [51] F. Finelli and R. Brandenberger, Phys. Rev. Lett. 82, 1362 (1999).
  * [52] V. Demozzi, V. Mukhanov and H. Rubinstein, J. Cosmol. Astropart. Phys. 08, 025 (2009).
  * [53] V. F. Mukhanov, H. A. Feldman and R. H. Brandenberger, Phys. Rept. 215, 203 (1992).