\section{Introduction}
Let $\mathbb{F}_q$ be the finite field with $q=p^s$ elements, where $p$ is an odd prime.
An important class of curves over finite fields is the class of  Artin-Schreier curves. That are given by the equation $y^q-y=f(x)$ for some $f(x)\in \mathbb{F}_q[x]$.  These curves have been extensively studied in several contexts, e.g. \cite{COS, Coulter, FP, H,  Van}. This type of curve can be generalized for several variables, i.e.,  the hypersurfaces of Artin-Schreier  of the form $y^q-y=f(X)$, with $f(X) \in \mathbb{F}_q[X]\setminus\{0\}$ and $X=(x_1,\dots,x_r)$. Information about the number of affine rational points of algebraic hypersurfaces over finite fields has many applications in coding theory, cryptography, communications and related areas, e.g. \cite{Aubry, GO,Stepanov,Van}.

The first aim of this paper is to determine the number of $\mathbb{F}_{q^n}$-rational points of  the  Artin-Schreier curve $\mathcal C_{i}$ given by
\[\mathcal C_i: y^q-y = x(x^{q^i}-x) -\lambda\]
where $i \in \mathbb N$ and $\lambda \in \mathbb{F}_{q^n}$. We denote  by $N_n(\mathcal C_{i})$ the number of $\mathbb{F}_{q^n}$-rational points of $\mathcal C_{i}$.

For $i\in\mathbb N$, we define $Q_i$ the map
\begin{align*}
Q_i : \mathbb{F}_{q^n} &\to \mathbb{F}_q\\
 \alpha & \mapsto \mathrm{Tr}(\alpha(\alpha^{q^i}-\alpha)-\lambda),
\end{align*}
and $N_n(Q_i)$  denotes the number of zeroes of $Q_i$ in $\mathbb{F}_{q^n}$. Hilbert’s Theorem 90 implies that
\[N_n(\mathcal C_{i}) = q \cdot N_n(Q_i).\]
Therefore, we observe that  determine $N_n(\mathcal C_{i})$ is equivalent to calculate $N_n(Q_i)$.
Details about this fact can be found in \cite{A1,A2,OS}.

The number of $\mathbb{F}_{q^n}$-rational points of Artin-Schreier curves have been studied for many authors. For instance, in \cite{Wolf1} Wolfmann determined the number of rational points of the curve defined over $\mathbb{F}_{q^k}$ given by the equation $y^q-y=ax^s+b,$ where $a\in\mathbb{F}_{q^k}^*$, $b\in\mathbb{F}_{q^k}$, $k$ is even and special integers $s.$ In \cite{Coulter}, Coulter determined the number of $\mathbb{F}_q$-rational points of the curve $y^{p^n}-y=ax^{p^{\alpha}+1}+L(x)$, where $a\in\mathbb{F}_q^*$, $L(x)$ is a $\mathbb{F}_{p^t}$-linearized polynomial and $t=\gcd(n,s)$ divides $d=\gcd(\alpha,s)$. In \cite{COS}, the authors determined the number of $\mathbb{F}_{q^m}$-rational points of the curve $y^{q^n}- y = \gamma x^{q^h+1} - \alpha$ in suitable cases, for positive integers $h, n, m$ with $n$ dividing $m$ and arbitrary $\gamma,a\in\mathbb{F}_{q^m} (\gamma\neq 0)$ . In \cite{BrocheroOliveira} we determine $N_n(C_i)$ in the case where $\gcd(n,p)=1$.

Using an alternative method, that consists in determine the number of solutions of the quadratic form $Q_i$ using appropriates permutation matrices,  in this paper we compute the number $N_n(\mathcal C_i)$ without the condition over $\gcd(n,p)$ and  also determine conditions for the Artin-Schreier curve $C_i$ to be maximal or minimal with respect the Hasse-Weil bound.

The second goal of this paper is to determine the number of $\mathbb{F}_{q^n}$-rational points of the affine  Artin-Schreier hypersurface $\mathcal H_r$  given by
\begin{equation} \label{hr}
\mathcal H_r: y^q- y = \sum_{j=1}^r a_jx_j(x_j^{q^{i_j}}-x_j)- \lambda,
\end{equation}
where $a_j\in\mathbb{F}_q^*$ and $0< i_j< n$ for $1\le j\le r$. We denote by $N_n(\mathcal H_r)$ the number of $\mathbb{F}_{q^n}$-rational points of the hypersurface $\mathcal H_r$.
The well-known Weil bound assures us that
\begin{equation}\label{cota}
|N_n(\mathcal H_r)-q^{rn}| \le (q-1)\prod_{j=1}^r q^{i_j}q^{\frac{nr}2}= (q-1)q^{\frac{nr+2I}2},
\end{equation}
where $I = \sum_{j=1}^r i_j$.
The hypersurface $\mathcal H_r$ is called $\mathbb{F}_{q^n}$-maximal ($\mathbb{F}_{q^n}$-minimal) if $N_n(\mathcal H_r)$ attains the upper (lower) bound given in Equation \eqref{cota}. In this paper, we provide necessary and sufficient conditions to this bound  be attained.  In the literature, we do not have a complete description on the number of rational points for  Artin-Schreier hypersurfaces, as well as when this type of hypersurface attains the bound given in \eqref{cota} or another bounds.

From the results about the curve $\mathcal C_i$, we can explicitly determine the number of rational points $N_n(\mathcal H_r)$ and the conditions to obtain the maximality or minimality of this hypersurface.

This paper is organized as follows. Section $2$ provides background material and preliminary results. In Section 3 we compute the number of $\mathbb{F}_{q^n}$- rational points of the  Artin-Schreier curves $C_i$ and provide necessary and sufficient conditions on these curves to be maximal or minimal. In Section $4$ we determine the number of $\mathbb{F}_{q^n}$-rational points of the hypersurfaces $\mathcal H_r$ given by the equation \eqref{hr} and find explicit  conditions on these hypersurfaces to be maximal or minimal.

\section{Preliminary results}

Throughout this paper, we denote by $\psi$ and $\tilde \psi $ the canonical additive characters of $\mathbb{F}_{q^n}$ and $\mathbb{F}_q$ respectively. The quadratic character of $\mathbb{F}_q$ is denoted by $\chi$. The trace function $\mathrm{Tr}$ of $\mathbb{F}_{q^n}$ over $\mathbb{F}_q$ is given by
\begin{align*}
\mathrm{Tr}:  \mathbb{F}_{q^n} \to & \, \mathbb{F}_q\\
x \mapsto &  \, x+x^q+\cdots + x^{q^{n-1}}.
\end{align*}
We denote by $\tau$ the function
 $\tau = \begin{cases}
	1& \text{ if } p \equiv 1 \pmod 4;\\
	i & \text{ if } p \equiv 3 \pmod 4.
	\end{cases}$

 In order to determine the number of rational points of $\mathcal C_{i}$, we associate to this curve the quadratic form  $\mathrm{Tr}(x(x^{q^i}-x))$. Fixing a basis of $\mathbb{F}_{q^n}$ over $\mathbb{F}_q$, we provide its associate matrix and the dimension of its radical. In order to do that, we recall the following definitions.
 \begin{definition}
Let $Q:\mathbb{F}_{q^n} \to \mathbb{F}_q $ be a quadratic form. The symmetric bilinear form $B:\mathbb{F}_{q^n}\times \mathbb{F}_{q^n}\to \mathbb{F}_q$ associated to  $Q$ is
$$B(\alpha,\beta) = \frac{1}2\left(Q(\alpha+\beta) -Q(\alpha)-Q(\beta)\right).$$
The radical of the quadratic form $Q: \mathbb{F}_{q^n} \to \mathbb{F}_q$  is the $\mathbb{F}_q$-subspace
\[\text{rad}(Q) = \{\alpha \in \mathbb{F}_{q^n} : B(\alpha, \beta) = 0 \text{ for all } \beta\in \mathbb{F}_{q^n} \}.\]
Moreover  $Q $ is a non-degenerate form if $\text{rad}(Q) = \{0\}$.
\end{definition}

Let $\mathcal B=\{v_1,\dots, v_n\}$ be a basis of $\mathbb{F}_{q^n}$ over $\mathbb{F}_q$. The $n \times n$ matrix $A=(a_{ij})$ defined by
$$a_{ij}= \begin{cases} Q(v_i),& \text{if $i=j$,}\\
\frac 12(Q(v_i+v_j)-Q(v_i)-Q(v_j)),& \text{if $i\ne j$},
\end{cases}
$$
is the {\em associated matrix} of the quadratic form $Q$ over the basis $\mathcal B$. In particular, the dimension of  $\text{rad}(Q)$  is equal to $n- rank (A).$

Let $Q_1: \mathbb{F}_q^m \to \mathbb{F}_q$ and $Q_2 : \mathbb{F}_q^n\to \mathbb{F}_q$ be quadratic forms where $m \ge n$. Let $U$ and $V$ be associated matrix of $Q_1$ and $Q_2$, respectively. We say that $Q_1$ is equivalent to $Q_2$ if there exists $M \in GL_m(\mathbb{F}_q)$ such that
\[M^T UM =\left(
\begin{array}{c|c}
V & 0 \\ \hline
 0 & 0
\end{array}\right)\in M_m(\mathbb{F}_q),\]
where $ GL_m(\mathbb{F}_q)$ denotes the group of $m\times m$ invertible matrices over $\mathbb{F}_q$ and $M_m(\mathbb{F}_q)$ denotes the set of $m\times m $ matrices over $\mathbb{F}_q$.
Furthermore, $Q_2 $ is a {\em reduced form} of $Q_1$ if $\text{rad}(Q_2)= \{0\}. $

The following theorem is a well-known result about the number of the solutions of quadratic forms over finite fields.

\begin{theorem}[\cite{LiNi}, Theorems $6.26$ and $6.27$] \label{sol}
Let $Q$ be a quadratic form over $\mathbb{F}_{q^n}$, where $q$ a power of an odd prime. Let $B_Q$ be the bilinear symmetric form associated to  $Q$,  $v = \dim( \text{rad}(B_Q))$ and $\tilde Q$ a reduced nondegenerate quadratic form equivalent to $Q$.  Set  $S_{\alpha}  = |\{ x \in \mathbb{F}_{q^n}| Q(x) = \alpha\}|$ and  let $\Delta$ be the determinant of the quadratic form $\tilde Q$.   Then
\begin{enumerate}[(i)]
\item If  $n+v$ is even
\begin{equation} \label{casopar}
S_{\alpha} =
 \left\{
\begin{array}{ll}
q^{n-1} +Dq^{(n+v-2)/2}(q-1) \quad &\text{ if } \alpha = 0,\\
 q^{n-1} - Dq^{(n+v-2)/2} \quad &\text{ if } \alpha \neq 0,
\end{array}\right.

\end{equation}
where $D = \chi((-1)^{(n-v)/2}\Delta)$.

\item If $n+v$ is odd
\begin{align} \label{casoimpar}
S_{\alpha} = \left\{
\begin{array}{ll}
q^{n-1}  \quad &\text{ if } \alpha = 0,\\
q^{n-1} + Dq^{(n+v-1)/2} \quad &\text{ if } \alpha \neq 0.
\end{array}\right.
\end{align}
where $D = \chi((-1)^{(n-v-1)/2}\alpha\Delta)$.
\end{enumerate}
In particular $D \in \{-1,1\}.$
\end{theorem}

The following lemma associates quadratic forms and characters sums and will be useful for our results. It can be obtained from Theorem \ref{sol} by a straightforward computation.

\begin{lemma}\label{soma}
Let $H$ be a $n\times n$ non null symmetric matrix over $\mathbb{F}_q$ and $l = \text{rank}(H)$. Then there exists $M \in \text{GL}_n(\mathbb{F}_q)$ such that $D = MHM^T$ is a diagonal matrix, i.e., $D = \text{diag}(a_1,a_2, \dots, a_l, 0,\dots,0)$ where $a_i \in \mathbb{F}_q^*$ for all $i=1,\dots,l$. For the quadratic form
\[F: \mathbb{F}_q^n \to \mathbb{F}_q , \quad F(X) = XHX^T \quad (X = (x_1, \dots, x_n) \in \mathbb{F}_q^n), \]
it follows that
$$\sum_{X \in \mathbb{F}_{q^n}} \tilde\psi\big(F(X)\big)= (-1)^{l(s+1)}\tau^{ls}\chi(\delta)q^{n-l/2},$$
where $\delta = a_1 \cdots a_l$.
\end{lemma}

We end this section with some basics definitions and results on Gauss sums.
\begin{definition}
Let $\Psi$ be an additive character of $\mathbb{F}_q$ and $\Phi$ a multiplicative character  of $\mathbb{F}_q^*$. The Gauss sum of $\Psi $ and $\Phi$ is defined by
\[G(\Psi,\Phi) = \sum_{x \in \mathbb{F}_q^*} \Psi(x)\Phi(x).\]
\end{definition}

\begin{theorem}\cite[Theorem 5.15]{LiNi}\label{gaussdois}
	Let $\chi$ be the quadratic character of $\mathbb{F}_q^*$. Then
	$$G(\tilde\psi,\chi)=-(-\tau)^{s}\sqrt{q}.$$
\end{theorem}

\section{The curve $y^q-y=x(x^{q^i}-x)-\lambda$}

In \cite{BrocheroOliveira} we compute the number $N_n(\mathcal C_1)$ when
$\gcd(n,p)=1$. In this section we employ a method that allows us to compute the number $N_n(\mathcal C_i)$ when $p$ divides $n$.
Let us denote by  $\mathcal B=\{\beta_1, \dots, \beta_n\}$ be a basis of $\mathbb{F}_{q^n}$ over $\mathbb{F}_q$ and
\begin{equation}\label{B}
B =\begin{psmallmatrix}
\beta_1 & \beta_1^q &\cdots  &\beta_1^{q^{n-1}} \\
\beta_2 & \beta_2^q & \cdots & \beta_2^{q^{n-1}} \\
\vdots & \cdots & \ddots & \vdots \\
\beta_n & \beta_n^q & \cdots & \beta_n^{q^{n-1}}
\end{psmallmatrix}.
\end{equation}
 We use this matrix as a tool to  associate  $N_n(\mathcal C_{i})$   with the number of $\alpha \in \mathbb{F}_{q^n}$ such that
\begin{equation} \label{Tra1}
\mathrm{Tr} (\alpha(\alpha^{q^i} -\alpha)) = \mathrm{Tr}(\lambda).
\end{equation}
Recall that  $N_n(Q_i)$ denotes the number of solutions of $\mathrm{Tr}(\alpha(\alpha^{q^i} -\alpha))=\mathrm{Tr}(\lambda)$ with $\alpha \in \mathbb{F}_{q^n}$. From Hilbert's Theorem $90$ we have that
$$ N_n(\mathcal C_{i}) = q N_n(Q_i).$$
The following proposition associates $\mathrm{Tr}(x^{q^i+1}-x^2-\lambda)$ with  a quadratic form.

\begin{proposition}\label{pr2}
Let $f(x) = x^{q^i+1}-x^2-\lambda$, where $\lambda \in \mathbb{F}_{q^n}$. The number of solutions of $\mathrm{Tr}(f(x))=0$ in $\mathbb{F}_{q^n}$ is equal to the number of solutions in $\mathbb{F}_q^n$  of the quadratic form
\[(x_1 \,\, x_2 \,\, \cdots \,\, x_n) A  \begin{pmatrix}
x_1\\
x_2 \\
\vdots \\
x_n
\end{pmatrix} = \mathrm{Tr}(\lambda), \] where   $A = (a_{j,l})$ is the $n\times n$ matrix defined by  the relations $a_{j,l} =   \frac{1}{2} \mathrm{Tr}(\beta_j^{q^i}\beta_l +\beta_l^{q^i} \beta_j -2\beta_j\beta_l).$
\end{proposition}

\begin{proof}
Let  $x = \sum_{j=1}^{r} \beta_jx_j$. The equation  $\mathrm{Tr}(f(x)) =0$ is equivalent to
\begin{equation} \label{tra}
\sum_{k=0}^{n-1} f(x)^{q^k} = 0.
\end{equation}
We have
\begin{align*}
\sum_{k=0}^{n-1} f(x)^{q^k}  & = \sum_{k=0}^{n-1}\Bigl( \sum_{j=1}^{n} \beta_j x_j\Bigr)^{q^k} \Bigl( \sum_{l=1}^{n} (\beta_l^{q^i}-\beta_l) x_l \Bigr)^{q^k}-\mathrm{Tr}(\lambda)\\
&= \sum_{j,l=1}^{n} \Bigl( \sum_{i=0}^{n-1} \beta_j^{q^k}(\beta_l^{q^{i+k}}-\beta_l^{q^k})\Bigr) x_jx_l -\mathrm{Tr}(\lambda).
\end{align*}
The Equation  \eqref{tra} assures us that \(\displaystyle\sum_{j,l=1}^{n} \left( \sum_{k=0}^{n-1} \beta_j^{q^k}(\beta_l^{q^{i+k}}-\beta_l^{q^k})\right) x_jx_l = \mathrm{Tr}(\lambda).\) Simetrizing this expression, we note that

 $$  \frac{1}{2}\displaystyle   \sum_{k=0}^{n-1} \beta_j^{q^k}\beta_l^{q^k}(\beta_l^{q^{i+k}-q^k}+\beta_j^{q^{i+k}-q^k}-2)= \frac{1}2 \mathrm{Tr}\big(\beta_j^{q^i}\beta_l+\beta_l^{q^i}\beta_j-2\beta_j\beta_l \big)=a_{j,l}, $$
 and the result follows.
\end{proof}

The matrix $A$ in Proposition \ref{pr2} can be rewritten as
\[A = \frac{1}{2} (A_1+A_2+A_3),\]
where  $A_1 = (\mathrm{Tr}(\beta_j^{q^i}\beta_l))_{j,l}$,  $A_2 = (\mathrm{Tr}(\beta_j\beta_l^{q^i}))_{j,l}$ and $A_3 = (\mathrm{Tr}(\beta_j\beta_l))_{j,l}$.
If $\mathcal P$  is the $n\times n$ cyclic permutation matrix defined by
\[\mathcal P =  \begin{psmallmatrix}
0&1&0& \cdots & 0\\
0&0&1& \cdots &0 \\
\vdots& \cdots & \ddots & \cdots &\vdots\\
0&0&0& \cdots &1\\
1&0&0& \cdots & 0
\end{psmallmatrix},\]
 from the fact that $\mathcal{P}^{-1} = \mathcal P^T,$ it follows that $A_1 = B\left(\mathcal{P}^i\right)^{^{\ }_T}B^T,\,  A_2 = B\left(\mathcal{P}^i\right) B^T$ and $ A_3 = BB^T$. Therefore  $A = \frac{1}{2} BM_{n,i}B^T$ where

\[M_{n,i} = \left(\mathcal{P}^i\right)^{^{\ }_T}-2 Id +\mathcal{P}^i, \]
and the matrix $M_{n,i}=(m_{k,l})$ is given by
\[m_{k,l} = \begin{cases}
-2 & \text{ if }k=l;\\
1 & \text{ if } |k-l| = i;\\
0 & \text{  otherwise, }
\end{cases}\]
with the convection that we enumerate the rows and columns  of the matrix from $0$ to $n-1$, so $0\le k,l \le n-1$.

Since $B$ is  invertible, in order to determine the number of solutions of the quadratic form defined by $A$ it is enough to determine the rank of $M_{n,i}$ and the determinant of a reduced  matrix of  $M_{n,i}$.

In order to find these invariants of $M_{n,i}$, first we consider the case $i=1$.

\subsection{The case $i=1$.}

 The following proposition determines the rank of $M_{n,1}$ and the determinant of one of its reduced matrix.
\begin{proposition}\label{det}
The rank  of the $n\times n$ matrix $M_{n,1} = \mathcal P^T-2 Id +\mathcal P$ over $\mathbb{F}_{q}$ is given by
\[\text{rank } M_{n,1} = \left\{
\begin{array}{ll}
n-1 \quad \text{ if } \gcd(n,p) = 1;\\
n-2  \quad \text{ if } \gcd(n,p) = p.
\end{array}\right.\]

Let $M_{n,1}'$ denote the principal submatrix of $M_{n,1}$ constructed from the first rank$(M_{n,1})$ rows and columns, then $M_{n,1}'$ is a reduced matrix of $M_{n,1}$ and
\[ \det M_{n,1}' = \left\{
\begin{array}{ll}
 (-1)^{n-1}n \quad &\text{ if } \gcd(n,p) = 1;\\
(-1)^{n-1}  \quad& \text{ if } \gcd(n,p) = p.
\end{array}\right.  \]
\end{proposition}

\begin{proof}
Let us denote by $M_n$ the matrix  $$M_n=
\begin{psmallmatrix}
-2 & 1 & 0 &   \ldots   & 0 & 0 & 0\\
1& -2&1& \ldots & 0 & 0& 0\\
0&1&-2& \ldots & 0 & 0&0\\
\vdots & \vdots &   \vdots &\ddots& \vdots&\ddots & \vdots \\
0& 0& 0 &  \ldots & -2&1 &0\\
0& 0& 0 &  \ldots & 1&-2 &1\\
0 & 0 & 0 &  \ldots &0&1&-2\\
\end{psmallmatrix}.$$
We note that $M_{n,1}=M_n+R_n$, where $R_n=(r_{i,j})$ with $r_{i,j} = \begin{cases}
1 & \text{ if } (i,j) \in\{(1,n),(n,1)\}\\
0 & \text{ otherwise. }
\end{cases}$
If we put   $$\displaystyle U=\begin{psmallmatrix}
1 & 0 & 0 &   \ldots   & 0 & 0 \\
0& 1&0& \ldots & 0 & 0\\
\vdots & \vdots &   \vdots &\ddots& \vdots & \vdots \\
0& 0& 0 &  \ldots & 1&0 \\
1 & 1 & 1 &  \ldots &1&1\\
\end{psmallmatrix}$$
 then
 $$UM_{n,1}U^T=\begin{psmallmatrix}
-2 & 1 & 0 &  \ldots   & 0 & 0 & 0\\
1& -2&1& \ldots & 0 & 0& 0\\
0&1&-2& \ldots & 0 & 0&0\\
\vdots &  \ddots & \vdots &\ddots&\vdots&\ddots & \vdots \\
0& 0& 0 &  \ldots & -2&1 &0\\
0& 0& 0 &  \ldots & 1&-2 &0\\
0 & 0 & 0 &   \ldots&0&0&0 \\
\end{psmallmatrix} = \left(
\begin{array}{c|c}
M_{n-1}  & 0 \\ \hline
 0 & 0
\end{array}\right).$$

We claim that   $L_{n-1} =  \det M_{n-1} = (-1)^{(n-1)}n$ for $n>1$.
In order to prove this, we expand the determinant of $M_{n-1} $ by the first row and  obtain the recursive relation
\begin{equation}\label{mh}
 L_{n-1}   =  -2  L_{n-2}- L_{n-3} \text{ for all } n\ge 4.
\end{equation}
This implies that the sequence $\{L_n\}_{n\ge2}$ satisfies a recurrence relation  \eqref{mh} with associated characteristic polynomial given by $z^2+2z+1=(z+1)^2$, which has $-1$ as a double root. Therefore $L_{n-1} = A(-1)^n + B(-1)^n n$, where $A,B \in \mathbb{F}_q$. Since $ L_2 = 3 $ and $ L_3 = -4 $,  we conclude that $A=0$ e $B=-1$ and consequently $ L_{n-1} = (-1)^{(n-1)}n$, as we wanted.

Furthermore, if   $\gcd(n,p)=1$, it follows that  $L_{n-1} = (-1)^{(n-1)} n \neq 0$ and then the rank of  $M_{n-1}$ is $n-1$. This implies that the rank of $M_{n,1}$ is also $n-1$.

In the case $\gcd(n,p)=p$, defining $V$ as
$$\displaystyle V=\begin{psmallmatrix}
1 & 0 & 0 &   \ldots   & 0& 0 & 0 & 0 \\
0& 1&0& \ldots & 0& 0 & 0& 0\\
\vdots & \vdots &   \vdots &\ddots& \vdots& \vdots & \vdots & \vdots \\
0& 0& 0 &  \ldots &1& 0&0&0 \\
0& 0& 0 &  \ldots &0& 1&0&0 \\
1 & 2 & 3 &  \ldots&n-3 & \frac {n-4}2&-1&0\\
0 & 0 & 0 &  \ldots &0&0&0&1\\
\end{psmallmatrix},$$ we observe that $V$ is invertible and
$$VUM_{n,1}U^TV^T
=\left(
\begin{array}{c|c}
M_{n-2}  & 0\quad 0 \\ \hline
 \begin{array}{c}0 \cdots 0\\ 0 \cdots 0\end{array}& \begin{array}{cc}
 n&0\\
 0&0
 \end{array}
\end{array}\right).$$

Therefore $L_{n-2} = (-1)^{n-2}(n-1) \neq 0$ and the rank of $M_{n,1}$ is $n-2$, from where the result follows.
\end{proof}
The following definition will be useful to determine $N_n(C_i)$.

\begin{definition}
For each  $\alpha \in \mathbb{F}_q$ we define
\[\varepsilon_{\alpha} = \begin{cases}
q-1 & \text{ if } \alpha =0; \\
-1 & \text{ otherwise.} \\
\end{cases}
\]
\end{definition}

By Theorem \ref{sol}  and  Proposition \ref{det} we have the following theorem.
\begin{theorem}\label{m1}
Let $\lambda \in \mathbb{F}_{q^n}$ and $n$ a positive integer. The number $N_n(\mathcal C_{1})$ of affine rational points   in $\mathbb{F}_{q^n}^2$  of the curve determined by the equation  $y^q-y=x^{q+1}-x^2-\lambda$ is
\[N_n(\mathcal C_1)= \left\{
\begin{array}{llll}
 q^{n}+  \chi(2(-1)^{\frac{n}2}n\mathrm{Tr}(\lambda))q^{(n+2)/2} \quad & \text{ if } \gcd(n,p) = 1 \text{ and } n \text{ is even;}\\
 q^{n}+ \varepsilon_{\mathrm{Tr}(\lambda)} \chi((-1)^{(n-1)/2}n)q^{(n+1)/2}  \quad &\text{ if } \gcd(n,p) = 1 \text{ and } n \text{ is odd;}\\
q^{n}+\varepsilon_{\mathrm{Tr}(\lambda)} \chi((-1)^{n/2}) q^{(n+2)/2} \quad &\text{ if } \gcd(n,p) = p \text{ and } n\text{ is even;}\\
q^{n}  +\chi(2(-1)^{\frac{n-3}2}\mathrm{Tr}(\lambda))q^{(n+3)/2}\quad &\text{ if } \gcd(n,p) = p \text{ and } n \text{ is odd.}
\end{array}\right.\]
\end{theorem}
This theorem allows us to determine when $\mathcal C_{1}$ is minimal or maximal with respect  the Hasse-Weil bound,  as we show in  the following corollary.
\begin{theorem}
Consider the curve  $\mathcal C_1$ given by
\[\mathcal C_1 : y^q -y = x^{q+1}-x^2-\lambda.\]
Then $\mathcal C_1$ is minimal if and only if one of the following holds
\begin{itemize}
\item $\mathrm{Tr}(\lambda) =0$,  $2p$ divides $n$ and $q\equiv 1 \pmod 4$;
\item $\mathrm{Tr}(\lambda) =0$,  $4p$ divides $n$ and $q\equiv 3 \pmod 4$.
\end{itemize}
Moreover, $\mathcal C_1$ is maximal if and only if $\mathrm{Tr}(\lambda) =0,$ $2p$ divides $n$ and $q \equiv 3 \pmod 4.$
\end{theorem}
\begin{proof}
The result follows from Theorem \ref{m1} and the fact that the genus of $\mathcal C_1$ is $g= \frac{q(q-1)}2$.
\end{proof}

\subsection{The curve $y^q-y=x(x^{q^i}-x)-\lambda$ with $i\ge1$.}

\begin{proposition}\label{det2}
Let $i,n$ be integers such that $0<i< n$. Set  $d= \gcd(i,n)$ and $ l = \frac{n}d$. The rank  of the $n\times n$ matrix $M_{n,i}$ is $n-d$ if $n=2i$ and, otherwise we have that
\[\text{rank } M_{n,i} = \left\{
\begin{array}{ll}
n-d\quad &\text{ if } \gcd(n,p) = 1;\\
 n-2d \quad &\text{ if } \gcd(n,p) = p.
\end{array}\right.\]

In addition, the matrices
\begin{equation}\label{diagonal}
\tilde M_{n,i}=\left(
\begin{array}{c|c|c|c}
M_{l,1}  & 0&0 & 0 \\ \hline
 0& M_{l,1}&0&0\\ \hline
 \vdots & \cdots & \ddots& \vdots\\ \hline
 0&0&0& M_{l,1}\\
 \end{array}\right) \quad \text{ and } \quad
 \tilde M'_{n,i}=\left(
\begin{array}{c|c|c|c}
M'_{l,1}  & 0&0 & 0 \\ \hline
 0& M'_{l,1}&0&0\\ \hline
 \vdots & \cdots & \ddots& \vdots\\ \hline
 0&0&0& M'_{l,1}\\
 \end{array}\right)
 \end{equation}
 are an equivalent matrix and a reduced matrix of $M_{n,i}$, respectively, where $\tilde M'_{l,1}$ is as the matrix given in Proposition \ref{det}.

The determinant of the matrix $\tilde M_{n,i}$ is $(-1)^{i}2^i$ if $n=2i$ and, otherwise we have that
\[ \det \tilde M'_{n,i} = \left\{
\begin{array}{ll}
 (-1)^{n-d}l^d \quad &\text{ if } \gcd(n,p) = 1;\\
 (-1)^{n-2d}(l-1)^d \quad& \text{ if } \gcd(n,p) = p.
\end{array}\right.  \]
\end{proposition}
\begin{proof}
For convenience, we enumerate the rows and columns of the matrix $M_{n,i}$ from $0$ to $n-1$.
Suppose that $n$ is even and $i = \frac{n}2$. In this case, the matrix $M_{n,i}$ is given by
\[a_{k,l} = \begin{cases}
-2 &\text{ if } k=l,\\
2 &\text{ if } k-l \equiv 0 \pmod {\frac{n}2},\\
0 &\text{ otherwise. }
\end{cases}\]
Let us denote $D_{n/2}=2Id_{n/2}$, where $Id_{n/2}$ is the $\frac{n}2\times \frac{n}2$ identity matrix. We have that
\[M_{n,n/2} = \left(\begin{array}{c|c}
-D_{n/2}&D_{n/2}\\ \hline
D_{n/2}& -D_{n/2} \\
\end{array}\right) \text{ that is equivalent to } \left(\begin{array}{c|c}
D_{n/2}&0\\ \hline
0& 0 \\
\end{array}\right).\]
Therefore
\[\text{ rank } M_{n,\frac{n}2} = \frac{n}2=i \quad \text{ and } \quad \text{ det } \tilde M'_{n, \frac{n}2} = (-2)^{\frac{n}2}=(-2)^i\neq 0.\]

This proves the case $n=2i$. For the other cases, firstly we show that it is enough to consider  the case where $i=d$. After that, we will obtain a block diagonal matrix composed by $d$ matrices of the form $M_{l,1}$, where $n=ld.$

We observe that any permutation $\rho:\mathbb Z_n \to \mathbb Z_n$ defines a natural action over $\mathbb{F}_q^n$, given by the following map
$$\begin{matrix}
\rho: & \mathbb{F}_q^n &\to& \mathbb{F}_q^n\\
& (v_0, \dots, v_{n-1})& \mapsto& (v_{\rho(0)}, \dots, v_{\rho(n-1)}).
\end{matrix}$$
This action is associated to an invertible matrix $M_{\rho}$ such that
\[M_{\rho} \left(\begin{matrix}
v_0\\\vdots\\v_{n-1}
\end{matrix}\right) =\left(\begin{matrix}
v_{\rho(0)}\\\vdots\\v_{\rho(n-1)}.
\end{matrix}\right) \]
Conversely, for any permutation matrix $R$, there exists a permutation $\rho': \mathbb Z_n \to \mathbb Z_n$ such that $M_{\rho'} = R.$ We observe that $\mathcal P^i$ determines the permutation
$$\begin{matrix}\pi_i:& \mathbb Z_n & \to & \mathbb Z_n \\
&z & \mapsto & z+i.
\end{matrix}$$

 Let us consider the map  \begin{align*}
\sigma:  \mathbb Z_n &\to \mathbb Z_n\\
a & \mapsto ai
 \end{align*}
where $a \in \mathbb Z_n$ is an element of $\mathbb Z_n$ satisfying that $\gcd(a,n)=1$. Since $a$ and $n$ are relatively prime, $\sigma$ is a permutation.  In addition, $\sigma$ induces a matrix $M_{\sigma}$ and the matrix $M_{\sigma} \mathcal P^i  M_{\sigma}^{-1}$ determines a permutation of $\mathbb Z_n$ given by
\begin{align*}
\sigma \circ \pi_i \circ \sigma^{-1} (z) & = \sigma(\pi_i(\sigma^{-1}(z)))\\
& =  \sigma(\pi_i(a^{-1}z))\\
&=\sigma(a^{-1}z+i)\\
& = z+ai.
\end{align*}

We know that the congruence $ai \equiv u\pmod n$ has a solution if $d$ divides $u$. Then, since $d = \gcd(i,n)$, there exists $a \in\mathbb Z_n$ such that $\sigma \circ \pi_i \circ \sigma^{-1}(z) = z+\gcd(i,n)$. This shows that, without loss of generality, we can replace  $i$ by  $d.$

For each $z\in [0,n-1]$, from the Euclidean Division Algorithm, there exist unique integers $r,s$ with  $0\le s \le l-1$ and $0\le r \le d-1$ such that $z= sd+r$. Let us consider the  map
\begin{equation}
\begin{matrix}
\varphi:&  \mathbb Z_n  &\to & \mathbb Z_n\\
&sd+r &\mapsto&  s+lr.
\end{matrix}
\end{equation}
\textbf{Claim:} The map $\varphi$ is a permutation of the elements of $\mathbb Z_n$.  Let us suppose, that there exist distinct elements $z_1,z_2 \in \mathbb Z_n$ such $\varphi(z_1) = \varphi(z_2)$. By the Euclidean Division, there exist $0\le s_1,s_2\le l-1$ and $0\le r_1,r_2\le d-1$ with $z_1=s_1d+r_1$ and $z_2 = s_2d+r_2$. Then
\[\varphi(s_1d+r_1) =  \varphi(s_2d+r_2) \Leftrightarrow s_1+lr_1=s_2+lr_2 \Leftrightarrow s_1-s_2=l(r_2-r_1).\]
Since $0\le s_1,s_2 \le l-1$, the latter implies that $s_1=s_2=0$ and $r_1=r_2=0$.  But this  contradicts the fact that $z_1\neq z_2 $.  Therefore  $\varphi$ is a permutation.

We will use $\varphi$ to permutate the rows and columns of $\mathcal P^d - 2Id + \left(\mathcal{P}^d\right)^{^{\ }_T}$ in order to obtain the diagonal blocks matrix $\tilde M_{n,i}$
 with $d$ blocks. Recall that, the matrix $\left(\mathcal{P}^d\right)^{^{\ }_T} -2 Id +\mathcal P^d$ is given by $$a_{k,j} = \begin{cases}
-2 & \text{ if } k=j;\\
1 & \text{ if } |k-j|=d;\\
0 & \text{ otherwise. } \\
\end{cases}$$
We obtain that $\varphi \circ \pi_d \circ \varphi^{-1}$ defines a permutation $\theta: \mathbb Z_n\to \mathbb Z_n$ given by
\begin{align*}
\theta(z) = \varphi \circ \pi_d \circ \varphi^{-1}(z) & = \varphi \circ \pi_d (\varphi^{-1}(s+rl))\\
& = \varphi \circ \pi_d (sd+r)\\
& = \varphi ((s+1)d+r)\\
& = (s+1) + rl,
\end{align*}
where $z=sl+r$ with $0\le s \le l-1$ and $0\le r \le d-1$.
We  know that   $$M_{\varphi}\left(\bigl(\mathcal{P}^d\bigr)^{^{\ }_T} -2 Id +\mathcal P^d\right)M_{\varphi}^{-1}= \tilde M_{n,d}.$$
In order to do this, we show that the product of the permutation matrix $M_{\varphi}$ for $\left(\left(\mathcal{P}^d\right)^{^{\ }_T} -2 Id +\mathcal P^d\right)$ and $M_{\varphi}^{-1}$ takes the non-null entries of $M_{n,d}$ in the non-null entries of $\tilde M_{n,d}$.
In the case $k=j$, writing $k=s+rl$ with $0\le s\le l-1$ and $0\le r\le d-1$, we have that
\[ \theta(a_{k,k}) = a_{(s+1)+rl,(s+1)+rl}=a_{\theta(k),\theta(k)},\]
this implies that the new matrix until have $a_{k,k} = -2$.

If $a_{k,k+d} =1$, $k=s+rl$ with $0\le s\le l-1$ and $0\le r\le d-1$, we have that
\[ \theta(a_{k,k+d}) = a_{(s+1)+rl,(s+2)+rl} = a_{\theta(k),\theta(k+d)},\]
therefore we have  $a_{k,k+1}=1$ viewing the indices module $l$.
For $a_{k+d,k}=1$ is the same procedure, using the fact that $a_{k+d,k}$ is the entries transpose of $a_{k,k+d}$. The other entries are null and their images are also null. Therefore, we obtain the matrix in  Equation \eqref{diagonal}.

Using Proposition \ref{det} and the fact that the matrix $M_{n,i}$ is  a block diagonal matrix with $d$ blocks equal to the  matrix $M_{l,1}$, we determine the rank of $M_{n,i}$  and the determinant of the reduce matrix $\tilde M'_{n,i}$ of $M_{n,i}$. Consequently
 \[\text{ rank } M_{n,i} = \left\{\begin{array}{ll}
(l-1)d = n-d\quad \text{ if } \gcd(n,p) = 1;\\
 (l-2)d =n-2d \quad \text{ if } \gcd(n,p) = p,
\end{array}\right.\]
and

\[ \det \tilde M_{n,i} = \left\{
\begin{array}{ll}
 \left((-1)^{l-1}l\right)^d  = (-1)^{n-d}l^d\quad &\text{ if } \gcd(n,p) = 1;\\
 \left((-1)^{l-1}\left(l-1\right)\right)^d  = (-1)^{n-2d}(l-1)^d \quad& \text{ if } \gcd(n,p) = p.
\end{array}\right.  \]

\end{proof}

From Proposition \ref{pr2} we have that the matrix associated to the quadratic form $\mathrm{Tr}(cx(x^{q^i}-x))$ is
\[A= \frac{c}2B(\mathcal{P}^T-2Id+\mathcal{P})B^T\] where  $B$ is given in Equation \eqref{B}.
Proposition \ref{det2} implies  the following result.

\begin{corollary}\label{b1}
Let $c \in \mathbb{F}_q^*$ and  let $i$ be an integer such that $0<i<n$. Set $d=\gcd(i,n)$ and $l = \frac{n}d$. The rank of the $n\times n$ matrix $A= \frac{c}2B(\left(\mathcal{P}^i\right)^{^{\ }_T} -2 Id +\mathcal P^i)B^T$  is given by
\[\text{rank } A = \begin{cases}
n-d & \text{ if } \gcd(n,p)=1;\\
n-2d & \text{ if } \gcd(n,p)=p.
\end{cases}\]
Let $A'$ be a reduced matrix of $A$. Then
\[\chi(\det(A')) =  \begin{cases}
\chi((-2c)^{n-d}l^d) & \text{ if } \gcd(n,p)=1;\\
\chi((-2c)^{n-d}(l-1)^d) & \text{ if } \gcd(n,p)=p.
\end{cases}\]

\end{corollary}

By Theorem \ref{sol}  and  Propositions \ref{pr2} and \ref{det2} we have the following theorem.
\begin{theorem}\label{mm}
Let $n,i$ be integers such that $0<i<n$ and put $d= \gcd(i,n)$ and $ l = \frac{n}d$.  If $n=2i$, the number $N_n(\mathcal C_{i})$ of affine rational points   in $\mathbb{F}_{q^n}^2$  of the curve determined by the equation  $y^q-y=x^{q^i+1}-x^2-\lambda$ is
\[N_n(\mathcal C_{i})= \left\{
\begin{array}{llll}
 q^{n}+  \chi((-1)^{(i+1)/2}\mathrm{Tr}(\lambda)) q^{(3i+1)/2}\quad & \text{ if } i \text{ is odd;}\\
 q^{n}+ \varepsilon_{\mathrm{Tr}(\lambda)} \chi((-1)^{i/2}) q^{3i/2} \quad &\text{ if } i  \text{  is even.}\\
\end{array}\right.\]
If $n\neq 2i$, the number of affine rational points of $\mathcal C_i$ is
\[N_n(\mathcal C_{i})= \left\{
\begin{array}{llll}
 q^{n}+ \chi(2(-1)^{(n-d+1)/2}\mathrm{Tr}(\lambda) l^d) q^{(n+d+1)/2} \quad & \text{ if } \gcd(n,p) = 1 \text{ and } n+d \text{ is odd;}\\
 q^{n}+ \varepsilon_{\mathrm{Tr}(\lambda)} \chi((-1)^{(n-d)/2}l^d) q^{(n+d)/2} \quad &\text{ if } \gcd(n,p) = 1  \text{ and $n+d$ is even;}\\
q^{n}+  \chi(2(-1)^{(n+1)/2}\mathrm{Tr}(\lambda)(l-1)^d) q^{(n+2d+1)/2}  \quad &\text{ if } \gcd(n,p) = p \text{ and } n \text{ is odd;}\\
q^{n}+ \varepsilon_{\mathrm{Tr}(\lambda)} \chi((-1)^{n/2}(l-1)^d)q^{(n+2d)/2} \quad &\text{ if } \gcd(n,p) = p \text{ and } n\text{ is even.}\\
\end{array}\right.\]
\end{theorem}

\begin{remark}
The curve
$\mathcal C_{i}$ has genus $g = \frac{(q-1)q^i}2$.
The Hasse-Weil bound of $\mathcal C_{i}$ is given by
\[|N_n(\mathcal C_{i})-q^n|\le (q-1)q^{\frac{n+2i}2}. \]
\end{remark}
Using Theorem \ref{mm}, we can determine the conditions when the curve $\mathcal C_i$ is maximal (or minimal) with respect the Hasse-Weil bound.
\begin{theorem}
Let $n,i$ be integers such that $0<i<n$, set $d= \gcd(i,n)$ and $ l = \frac{n}d$. The curve
$$\mathcal C_{i}: y^q-y = x(x^{q^i}-x)-\lambda$$ is maximal if and only if $\mathrm{Tr}(\lambda)=0$, $2p$ divides $n$, $i$ divides $n$ and $(-1)^{n/2}(l-1)^d$ is  a square in $\mathbb{F}_q$.
The curve $\mathcal C_i$ is minimal if and only if $\mathrm{Tr}(\lambda)=0$, $2p$ divides $n$, $i$ divides $n$ and $(-1)^{n/2}(l-1)^d$ is not a square in $\mathbb{F}_q$.
\end{theorem}

\section{The number of affine rational points of the hypersufarce $y^q-y = \sum_{j=1}^r a_jx_j(x_j^{q^{i_j}}-x_j)-\lambda$}

 Let us denote $\mathcal H_r$ the hypersufarce
$$\mathcal H_r : y^q-y = \sum_{j=1}^r a_jx_j(x_j^{q^{i_j}}-x_j)-\lambda,$$
where $a_j \in \mathbb{F}_q^*$ and $0<i_j<n$ for $j\in\{1,\dots,r\}$.  We know from  Theorem $5.4$ in \cite{LiNi}  that $$\sum_{c\in\mathbb{F}_{q^n}} \psi(uc) =\begin{cases}
0 & \text{ if } u \neq 0;\\
q^n & \text{ if } u = 0.
\end{cases}$$
We can use this fact to compute the number $N_{n}(\mathcal H_r)$,
 \begin{align}\label{AA1} \nonumber
 q^n N_{n}(\mathcal H_r) & = \sum_{c \in \mathbb{F}_{q^n}} \sum_{x_1 \in \mathbb{F}_{q^n}} \cdots \sum_{x_r\in \mathbb{F}_{q^n}} \sum_{y\in \mathbb{F}_{q^n}} \psi\left(c\left( \sum_{j=1}^r a_jx_j(x_j^{q^{i_j}}-x_j)-y^q+y-\lambda\right)\right)\\ \nonumber
& =q^{(r+1)n}  + \sum_{c \in \mathbb{F}_{q^n}^*} \sum_{x_1 \in \mathbb{F}_{q^n}} \cdots \sum_{x_r\in \mathbb{F}_{q^n}} \psi\left(c\left( \sum_{i=1}^r a_jx_j(x_j^{q^{i_j}}-x_j)-\lambda\right)\right) \sum_{y\in \mathbb{F}_{q^n}} \psi\left(c\left( -y^q+y\right)\right) \\ \nonumber
& = q^{(r+1)n}  + \sum_{c \in \mathbb{F}_{q^n}^*} \psi(-c\lambda) \prod_{j=1}^r  \sum_{x_j \in \mathbb{F}_{q^n}}\psi\left(c\left(  a_jx_j(x_j^{q^{i_j}}-x_j)\right)\right) \sum_{y\in \mathbb{F}_{q^n}} \psi\left(c\left( -y^q+y\right)\right) \\ \nonumber
& = q^{(r+1)n}  + \sum_{c \in \mathbb{F}_{q^n}^*} \psi(-c\lambda) \prod_{j=1}^r \sum_{x_j \in \mathbb{F}_{q^n}}\psi\left(c\left( a_j x_j(x_j^{q^{i_j}}-x_j)\right)\right) \sum_{y\in \mathbb{F}_{q^n}} \psi\left(y\left( -c^{q^{n-1}}+c\right)\right).\\
 \end{align}

We observe that $$\displaystyle \sum_{y\in \mathbb{F}_{q^n}} \psi\left(y\left( -c^{q^{n-1}}+c\right)\right) = \begin{cases}
q^n&  \text{ if } c^{q^{n-1}}-c =0;\\
0 & \text{otherwise}.\\
\end{cases}$$
Since   $c^{q^{n-1}}-c =0$ if and only if $c \in \mathbb{F}_{q^{n-1}}$,   we conclude that the inner sum in \eqref{AA1} has non null terms  only if $c \in \mathbb{F}_q. $ Therefore, we have that
\begin{align} \label{AA2}
N_{n}(\mathcal H_r) = q^{rn} + \sum_{c \in \mathbb{F}_q^*} \tilde\psi(-c\mathrm{Tr}(\lambda))\prod_{j=1}^r\sum_{x_j \in \mathbb{F}_{q^n}} \psi\left(ca\left(  x_j(x_j^{q^{i_j}}-x_j)\right)\right) .
\end{align}

The following theorem gives  explicit formulas for $N_n(\mathcal H_r)$.
\begin{theorem}\label{th1}
Let $\mathcal H_r: y^q-y = \sum_{j=1}^r a_jx_j(x_j^{q^{i_j}}-x_j)-\lambda$ with $\lambda \in \mathbb{F}_{q^n}$, $a_j \in \mathbb{F}_q$ and $0<i_j<n$. We denote $d_j= \gcd(i_j,n)$, $D=\sum_{j=1}^r d_j$,   $l_j=\frac{n}{d_j}$, $L_1 = l_1^{d_1}\cdots l_r^{d_r}$,  $L_2 = (l_1-1)^{d_1}\cdots (l_r-1)^{d_r}$, $A_1= a_1\cdots a_r$ and $A_2= a_1^{d_1}\cdots a_r^{d_r}$. The number $N_{n}(\mathcal H_r)$ of affine rational points of $\mathcal H_r$ in $\mathbb{F}_{q^n}^{r+1}$ is
\[N_{n}(\mathcal H_r) = \begin{cases}
q^{rn} +\tau^{s(nr-D)}\varepsilon_{\mathrm{Tr}(\lambda)}\chi(A_1^{nr}A_2^{-1}L_1)q^{\frac{nr+D}2} & \text{ if } \gcd(n,p)=1, nr-D \text{ is even};\\
q^{rn} + \tau^{s(rn-D+1)}\chi(2\mathrm{Tr}(\lambda)A_1^{nr}A_2^{-1}L_1)q^{\frac{nr+D+1}2} & \text{ if } \gcd(n,p)=1, nr-D \text{ is odd};\\
q^{rn} +  \tau^{s(rn-2D)}\varepsilon_{\mathrm{Tr}(\lambda)}\chi(L_2)q^{\frac{nr+2D}2}& \text{ if } \gcd(n,p)=p, nr \text{ is even};\\
q^{rn} +\displaystyle \tau^{s(rn-2D+1)}\chi(2\mathrm{Tr}(\lambda)a_1L_2)q^{\frac{nr+2D+1}2} & \text{ if } \gcd(n,p)=p, nr \text{ is odd}.\\
\end{cases}\]
\end{theorem}
\begin{proof}
From Equation \eqref{AA2} we have that
\[N_{n}(\mathcal H_r) = q^{rn} + \sum_{c \in \mathbb{F}_q^*} \tilde\psi(-c\mathrm{Tr}(\lambda))\prod_{j=1}^r\sum_{x_j \in \mathbb{F}_{q^n}} \psi\left(ca_j\left(  x_j(x_j^{q^{i_j}}-x_j)\right)\right).\]
By Lemma \ref{soma} and Proposition \ref{b1}, we obtain that $N_{n}(\mathcal H_r)= q^{rn} +N_{\mathcal H_r}  $ where
\begin{align*}\label{e1} \nonumber
N_{\mathcal H_r} &  ={\footnotesize \begin{cases}
  \displaystyle\sum_{c \in \mathbb{F}_q^*}\tilde\psi(-c\mathrm{Tr}(\lambda))\prod_{j=1}^r \left((-1)^{(s+1)(n-d_j)}\tau^{s(n-d_j)} \chi\left((-2ca_j)^{(n-d_j)}l_j^{d_j}\right)q^{\frac{n+d_j}2}\right)&\text{ if } \gcd(n,p)=1;\\
  \displaystyle\sum_{c \in \mathbb{F}_q^*}\tilde\psi(-c\mathrm{Tr}(\lambda))\prod_{j=1}^r \left((-1)^{(s+1)(n-2d_j)}\tau^{s(n-2d_j)} \chi\left((-2ca_j)^{(n-2d_j)}(l_j-1)^{d_j}\right)q^{\frac{n+2d_j}2}\right) & \text{ if } \gcd(n,p)=p.\\
\end{cases}}\\
&  ={\small \begin{cases}
  \displaystyle(-1)^{(s+1)(rn-D)}\tau^{s(nr-D)}\sum_{c \in \mathbb{F}_q^*}\tilde\psi(-c\mathrm{Tr}(\lambda))  \chi\left((-2c)^{nr-D}A_1^{nr}A_2^{-1}L_1\right)q^{\frac{nr+D}2}&\text{ if } \gcd(n,p)=1;\\
  \displaystyle(-1)^{rn(s+1)}\tau^{s(rn-2D)}\sum_{c \in \mathbb{F}_q^*}\tilde\psi(-c\mathrm{Tr}(\lambda)) \chi\left((-2c)^{nr}A_1^{nr}A_2^{-2}L_2\right)q^{\frac{nr+2D}2} & \text{ if } \gcd(n,p)=p.\\
\end{cases}}\\
\end{align*}
We split the proof into the following cases.
\begin{enumerate}[1)]
\item $\gcd(n,p)=1$ and $nr-D$ is  even.
\begin{align*}
N_{\mathcal H_r}& = \displaystyle\tau^{s(nr-D)}q^{\frac{(nr+D)}2}\chi(A_1^{nr}A_2^{-1}L_1)\sum_{c \in \mathbb{F}_q^*}\tilde\psi(-c\mathrm{Tr}(\lambda))  \\
& = \tau^{s(nr-D)}\varepsilon_{\mathrm{Tr}(\lambda)}\chi(A_1^{nr}A_2^{-1}L_1)q^{\frac{nr+D}2}.
\end{align*}

\item $\gcd(n,p)=1$ and $nr-D$ is odd.
\begin{align*}
N_{\mathcal H_r}&=  \displaystyle(-1)^{(s+1)}\tau^{s(rn-D)}\chi(A_1^{nr}A_2^{-1}L_1)q^{\frac{nr+D}2}\sum_{c \in \mathbb{F}_q^*}\tilde\psi(-c\mathrm{Tr}(\lambda))  \chi\left(-2c\right)\\
& = \begin{cases}\displaystyle
(-1)^{(s+1)}\tau^{s(rn-D)}\chi(A_1^{nr}A_2^{-1}L_1)q^{\frac{nr+D}2}\sum_{c \in \mathbb{F}_q^*}\chi\left(-2c\right)& \text{ if } \mathrm{Tr}(\lambda) = 0\\
\displaystyle(-1)^{(s+1)}\tau^{s(rn-D)}q^{\frac{nr+D}2}\chi(2\mathrm{Tr}(\lambda)A_1^{nr}A_2^{-1}L_1)\sum_{c \in \mathbb{F}_q^*}\tilde\psi(-c\mathrm{Tr}(\lambda))  \chi\left(-c\mathrm{Tr}(\lambda)\right) & \text{ if } \mathrm{Tr}(\lambda) \neq 0
\end{cases}\\
& =  \begin{cases}\displaystyle
0& \text{ if } \mathrm{Tr}(\lambda) = 0\\
\displaystyle(-1)^{(s+1)}\tau^{s(rn-D)}q^{\frac{nr+D}2}\chi(2\mathrm{Tr}(\lambda)A_1^{nr}A_2^{-1}L_1)G(\tilde\psi,  \chi) & \text{ if } \mathrm{Tr}(\lambda) \neq 0
\end{cases}\\
& =  \tau^{s(rn-D+1)}\chi(2\mathrm{Tr}(\lambda)A_1^{nr}A_2^{-1}L_1)q^{\frac{nr+D+1}2}.
\end{align*}

\item $\gcd(n,p)=p$ and $nr$ is even.
\begin{align*}
N_{\mathcal H_r} &=  \displaystyle\tau^{s(rn-2D)}\chi(A_1^{nr}L_2)q^{\frac{nr+2D}2}\sum_{c \in \mathbb{F}_q^*}\tilde\psi(-c\mathrm{Tr}(\lambda))  \\
& = \tau^{s(rn-2D)}\varepsilon_{\mathrm{Tr}(\lambda)}\chi(L_2)q^{\frac{nr+2D}2}.
\end{align*}

\item $\gcd(n,p)=p$ and $nr$ is odd.
\begin{align*}
N_{\mathcal H_r} &=   \displaystyle(-1)^{s+1}\tau^{s(rn-2D)}\chi(A_1L_2)q^{\frac{(nr+2D)}2}\sum_{c \in \mathbb{F}_q^*}\tilde\psi(-c\mathrm{Tr}(\lambda)) \chi\left((-2c\right)\\
& =  \begin{cases}
 \displaystyle (-1)^{s+1}\tau^{s(rn-2D)}\chi(A_1L_2)q^{\frac{nr+2D}2}\sum_{c \in \mathbb{F}_q^*}\chi\left(-2c\right) & \text{ if } \mathrm{Tr}(\lambda) =0 \\
 \displaystyle (-1)^{s+1}\tau^{s(rn-2D)}\chi(2\mathrm{Tr}(\lambda)A_1L_2)q^{\frac{nr+2D}2}\sum_{c \in \mathbb{F}_q^*}\tilde\psi(-c\mathrm{Tr}(\lambda))\chi\left((-c\mathrm{Tr}(\lambda)\right) & \text{ if } \mathrm{Tr}(\lambda) \neq0
\end{cases}\\
&=  \begin{cases}
 0 & \text{ if } \mathrm{Tr}(\lambda) =0 \\
 \displaystyle (-1)^{s+1}\tau^{s(rn-2D)}q^{\frac{nr+2D}2}\chi(2\mathrm{Tr}(\lambda)A_1L_2)G(\tilde \psi, \chi) & \text{ if } \mathrm{Tr}(\lambda) \neq0
\end{cases}\\
& =  \displaystyle \tau^{s(rn-2D+1)}\chi(2\mathrm{Tr}(\lambda)A_1L_2)q^{\frac{nr+2D+1}2}.\\
\end{align*}
\end{enumerate}
\end{proof}

The well-known Weil bound tells us that
\[\left|N_n(\mathcal H_r) - q^{nr}\right|\le (q-1) \prod_{j=1}^r q^{i_j} q^{nr/2} = (q-1)q^{\frac{rn+2I}2},\]
where $I = \sum_{j=1}^r i_j. $  By Theorem \ref{th1} this bound can be attend if and only if we are in the case $\gcd(n,p)=p, nr$ is even and $\mathrm{Tr}(\lambda)=0$. Using this fact, we obtain the following result, that assures us when the hypersurface $\mathcal H_r$ is maximal or minimal.

\begin{theorem}\label{HW}
Let $\mathcal H_r: y^q-y = \displaystyle\sum_{j=1}^r a_jx_j(x_j^{q^{i_j}}-x_j)-\lambda$ with $\lambda \in \mathbb{F}_{q^n}$, $a_j \in \mathbb{F}_q^*$ and $0<i_j<n$. Let $d_j = \gcd(n,i_j)$, $D=\sum_{j=1}^r d_j$, $l_j=\frac{n}{d_j}$ for $1\le j\le r$ and $L_2= (l_1-1)^{d_1} \cdots (l_r-1)^{d_r}$.

The hypersurface $\mathcal H_r$ attains the upper Weil bound if and only if one of the following holds
\begin{itemize}
\item $\mathrm{Tr}(\lambda) =0$, $\gcd(n,p)=p$, $nr$ is even, $d_j=i_j$ for all $1\le j\le r$, $(nr-2D)s \equiv 0 \pmod 4$ and $\chi(L_2) =1;$
\item  $\mathrm{Tr}(\lambda) =0$, $\gcd(n,p)=p$, $nr$ is even, $d_j=i_j$ for all $1\le j\le r$, $(nr-2D)s \equiv 2 \pmod 4$ and $\chi(L_2) =-1.$
\end{itemize}

The hypersurface $\mathcal H_r$ attains the lower bound if and only if one of the following holds
\begin{itemize}
\item $\mathrm{Tr}(\lambda) =0$, $\gcd(n,p)=p$, $nr$ is even, $d_j=i_j$ for all $1\le j\le r$, $(nr-2D)s \equiv 2 \pmod 4$ and $\chi(L_2) =1;$
\item  $\mathrm{Tr}(\lambda) =0$, $\gcd(n,p)=p$, $nr$ is even, $d_j=i_j$ for all $1\le j\le r$, $(nr-2D)s \equiv 0 \pmod 4$ and $\chi(L_2) =-1.$
\end{itemize}

\end{theorem}

\begin{example}
Let $q=5^2$, $n=60$. We consider the Artin-Schreier hypersurface given by
\[\mathcal H: y^q-y = x_1(x_1^{q^3}-x_1)+x_2(x_2^{q^4}-x_2)+x_3(x_3^{q^6}-x_3).\]
Following the notation of Theorem \ref{HW}, we have that $i_1=d_1=3, i_2=d_2=4, i_3=d_3=6$, $l_1=20, l_2=15, l_3=10$ and $L_2=19^3\cdot 15^4\cdot 10^6$. Moreover, $\chi(L_2) = \chi(19) = 1$ and $(nr-2D)s \equiv (180-26)\cdot 2 \equiv 0 \pmod 4 $.

It follows from Theorem \ref{HW} that $\mathcal H$ is $\mathbb F_{q^{60}}$-maximal.
\end{example}


\section{Introduction \label{sec:intro}}

Many of iron-based superconductors, which include pnictides and chalcogenides, have high critical temperatures $T_c>50$~K allowing to refer to them as high-$T_c$ superconductors. The basic element is always a square lattice of Fe, though in some cases with orthorhombic distortions, surrounded by As or P in pnictides and by Se, Te, or S in chalcogenides~\cite{y_kamihara_08,SadovskiiReview2008,IzyumovReview2008,MazinReview,PaglioneReview,JohnstonReview,WenReview,StewartReview}. Weakly doped pnictides are antiferromagnetic metals. Though there is no ultimately accepted microscopic mechanism of superconductivity, the most promising candidate is the spin fluctuation mechanism of Cooper pairing~\cite{HirschfeldKorshunov2011,ChubukovReview2012,Korshunov2014eng,Hirschfeld2016}. It is tightly connected with the topology of the Fermi surface comprised of several sheets, namely, with the existence of hole and electron Fermi pockets for a wide range of doping concentrations $x$. Fermi surface, as well as states near the Fermi level, are formed by the iron $d$-orbitals and consists of two hole pockets near the $\Gamma=(0,0)$ point and two electron pockets centered at $(\pi,0)$ and $(0,\pi)$ points of the two-dimensional Brillouin zone corresponding to one Fe per unit cell. Proximity of the wave vector related to the scattering between particles at electron and hole sheets to the nesting wave vector $\mathbf{Q}$ results in strong antiferromagnetic fluctuations with the maximum of the spin susceptibility near $\mathbf{Q}$ that equal to $(\pi,0)$ or $(0,\pi)$. There is a qualitative and sometimes even quantitative agreement between the Fermi surface calculated within the density functional theory (DFT) and the one measured via quantum oscillations and by the angle-resolved photoemission spectroscopy (ARPES)~\cite{Kordyuk}. Absence of the insulating state in the undoped case points toward the moderate nature of the electronic correlations in such a multiorbital system~\cite{Anisimov2008eng,Kroll2008}. Iron magnetic moment differs from one family of Fe-based materials to another with the smallest value of $\sim 0.3\mu_B$ in LaFeAsO~\cite{KlaussKorshunov2008} to $\sim 3.3\mu_B$ in K$_2$Fe$_4$Se$_5$~\cite{Gretarsson2011}. This issue was discussed as originating from the effect of correlations~\cite{Haule2009,Hansmann2010,Toschi2012}. The concept of Hund's metal was put forward~\cite{Haule2009} to emphasize the role of Hund's exchange $J$ in the physics of Fe-based materials. In particular, the irreducible vertex corrections beyond the random phase approximation (RPA) for the magnetic susceptibility were calculated~\cite{Hansmann2010,Toschi2012} and compared to the neutron scattering experiments~\cite{Liu2012}. However, the RPA approach also gives reasonable results when compared to various experiments in the normal and superconducting states~\cite{HirschfeldKorshunov2011,Korshunov2014eng} thus providing the natural starting point for studying the low-energy physics of itinerant electrons in iron-based superconductors.

Different mechanisms of superconductivity result in specific symmetries and structures of the gap in iron-based materials~\cite{HirschfeldKorshunov2011}. In the spin fluctuation theory of pairing within the RPA and in the functional renormalization group (fRG) approach, the leading superconducting instability in a wide range of dopings is characterized by the extended $s$-wave gap having the opposite signs on hole and electron Fermi surface pockets~\cite{HirschfeldKorshunov2011,Korshunov2014eng,Mazin2008,Graser2009,Kuroki2008,Chubukov2008,MaitiKorshunovPRL2011,MaitiKorshunovPRB2011,Classen2017}. The corresponding gap structure belongs to the $A_{1g}$ representation of the tetragonal symmetry group and is called $s_{\pm}$ state. On the other hand, orbital fluctuations results in the $s_{++}$ state with the gap having the same sign on all Fermi surface sheets~\cite{Kontani}. Therefore, by determining the gap structure, one can deduce the microscopic mechanism of superconductivity. In this respect, inelastic neutron scattering plays a special role since the imaginary part of the dynamical spin susceptibility $\chi(\mathbf{q},\omega)$ measured there carries information about the gap structure in the superconducting state. That is, the sign-changing $s_\pm$ gap leads to the formation of the spin resonance peak at or near the commensurate antiferromagnetic wave vector $\mathbf{q} = \mathbf{Q}$ connecting Fermi surface sheets with different signs of gaps on them~\cite{KorshunovEreminResonance2008,Maier2008,Maier2009}. In simple models, the peak appears at frequencies $\omega_R < 2\Delta$, where $\Delta$ is the gap magnitude. At present, the well defined peak was observed in neutron scattering on all iron-based superconductors for $T < T_c$ near the wave vector $\mathbf{Q}$, see, e.g., Refs.~\onlinecite{ChristiansonBKFA,ChristiansonBFCA,QiuFeSeTe,Park,Babkevich,Inosov2010,ArgyriouKorshunov2010,LumsdenReview,Castellan2011,Dai2015}.

However, by introducing an additional damping of quasiparticles and by adjusting parameters, one can attain the appearance of a peak in the spin susceptibility in the $s_{++}$ state at frequencies above $2\Delta$~\cite{Onari2010,Onari2011}. Therefore, to determine whether the observed peak is the true spin resonance one has to explore the effect of different details of the superconducting state on it and deduce some criterion. Previously, the characteristic feature of the spin resonance in the case of unequal gaps on hole and electron pockets were established~\cite{KorshunovPRB2016,KorshunovJMMM2017} -- in the presence of larger and smaller gaps, $\Delta_L$ and $\Delta_S$, the criterion is the condition for the spin resonance frequency, $\omega_R \leq \Delta_L+\Delta_S$. Comparison of data from the neutron scattering on the peak frequency and data from various techniques on gap magnitudes leads to the conclusion that in most cases the observed peak fulfills the condition and, therefore, indicates the $s_\pm$ gap structure~\cite{KorshunovPRB2016,KorshunovJMMM2017}. However, the role of the gap anisotropy in the formation of the spin resonance peak is still an open question. For example, results of ARPES~\cite{Shimojima2011} and Andreev spectroscopy~\cite{Abdel-Hafiez2014,Kuzmicheva2016,Kuzmicheva2017} demonstrate anisotropy of the larger gap as large as 30\% in pnictides. On the qualitative level, the question was discussed in Ref.~\onlinecite{Maiti2011}; however, within the very simple four-band model and without a particular recipe for comparison to the experimental data. Here I consider the effect of the gap anisotropy on the dynamical spin susceptibility and the spin resonance within the realistic five-orbital model from Ref.~\onlinecite{Graser2009}. Two approaches to the gap structure are used. One is phenomenological with the model gap function that is parameterized to reflect the general form of the experimentally observed and the theoretically obtained gap. Due to some freedom in the choice of parameters and ability to vary them, this approach allows us  to analyze basic effects of the gap anisotropy on the spin resonance peak. The other approach employs self-consistent calculation of the gap function within the spin fluctuation theory of pairing. Spin resonance peak is then calculated and compared to the results with the model gap. Obtained results lead to the adjustment of the condition $\omega_R \leq \Delta_L+\Delta_S$ that would allow us to make a comparison of experimental data on the peak frequency and gaps to answer the question on whether the observed peak is the true spin resonance originating from the $s_\pm$ state.

The paper is organized as follows. In Section~\ref{sec:model}, the model and the approaches are presented. Results for the spin susceptibility for the model gap function are given in Section~\ref{sec:resultsmodelgap} and the magnetic response for the gap calculated within the spin fluctuation theory of pairing is shown in Section~\ref{sec:resultscalcgap}. Concluding remarks and the brief analysis of the experimental data are given in Section~\ref{sec:conclusion}.

\section{Model and approximations \label{sec:model}}

I use here a Hamiltonian $H = H_0 + H_{int}$ consisting of the tight-binding model $H_0$~\cite{Graser2009} and an on-site Coulomb (Hubbard) multiorbital interaction $H_{int}$. Hamiltonian $H_0$ is based on the DFT band structure for LaFeAsO~\cite{Cao2008} and it includes five iron $d$-orbitals ($d_{xz}$, $d_{yz}$, $d_{xy}$, $d_{x^2-y^2}$, $d_{3z^2-r^2}$),
\begin{equation}
 H_0 = \sum_{\mathbf{k} \sigma} \sum_{l l'} \left[ t_{l l'}(\mathbf{k}) + \epsilon_{l} \delta_{l l'} \right] d_{\mathbf{k} l \sigma}^\dagger d_{\mathbf{k} l' \sigma},
 \label{eq:H0}
\end{equation}
where $d_{\mathbf{k} l \sigma}^\dagger$ is the annihilation operator for an electron with momentum $\mathbf{k}$, spin $\sigma$, and orbital index $l$. Hopping matrix elements $t_{l l'}(\mathbf{k})$ and one-electron energies $\epsilon_{l}$ are given in Ref.~\onlinecite{Graser2009}. Fermi surface consists of two hole pockets, $\alpha_1$ and $\alpha_2$, near the $\Gamma$ point and two electron pockets, $\beta_1$ and $\beta_2$, centered at $(\pi,0)$ and $(0,\pi)$ points of the one-Fe Brillouin zone. Here I consider the case of small electron doping with $x=0.05$.

Interaction part $H_{int}$ has the following form~\cite{Graser2009,Kuroki2008,Castallani1978,Oles1983},
\begin{eqnarray}
H_{int} &=& U \sum_{f, m} n_{f m \uparrow} n_{f m \downarrow} + U' \sum_{f, m < l} n_{f l} n_{f m} \nonumber\\
  && + J \sum_{f, m < l} \sum_{\sigma,\sigma'} d_{f l \sigma}^\dag d_{f m \sigma'}^\dag d_{f l \sigma'} d_{f m \sigma} \nonumber\\
  && + J' \sum_{f, m \neq l} d_{f l \uparrow}^\dag d_{f l \downarrow}^\dag d_{f m \downarrow} d_{f m \uparrow}.
\label{eq:Hint}
\end{eqnarray}
where $n_{f m} = n_{f m \uparrow} + n_{f m \downarrow}$, $n_{f m \sigma} = d_{f m \sigma}^\dag d_{f m \sigma}$ is the number of particles operator at site $f$, $U$ and $U'$ are intra- and interorbital Hubbard repulsions, $J$ is the Hund's exchange, and $J'$ is the pair hopping.
To limit a number of free parameters in the theory, let us assume the spin-rotational invariance (SRI) that adds two constraints, $U'=U-2J$ and $J'=J$. There are still two parameters to be determined, $U$ and $J$. Their values crucially depend on the orbital basis of the model. For example, constrained DFT gives $U=3.5$~eV and $J=0.8$~eV for the full set of Fe-$d$ and As-$p$ orbital set ($p-d$ model for LaFeAsO), while for the model that includes only $d$-orbitals, it gives $U=0.75$~eV and $J=0.51$~eV~\cite{Anisimov2008eng}. Another approach, constrained RPA (cRPA), results in $U=2.69$~eV and $J=0.79$~eV~\cite{Aichhorn2009,Aichhorn2011} or in $U=1.97$~eV and $J=0.77$~eV~\cite{Roekeghem2016} for the full set of $d$- and $p$-orbitals with excluded Coulomb interaction at the $p$-orbitals ($d-dp$ model). The same cRPA for the $d$-only orbital set gives
$U=2.2-3.3$~eV and $J=0.3-0.6$~eV~\cite{Miyake2008,Nakamura2008}. Such a dependence on the number of orbitals is due to the spatial extent of Wannier functions that are used to construct the matrix elements of the Coulomb interactions. As a general trend, a limited number of orbitals results in the smaller values of Hubbard parameters. For the five-orbital model studied here, the large values of $U$, greater than $\approx 1.5$~eV, results in the divergence of the spin susceptibility, i.e. the magnetic instability. Since the undoped LaFeAsO exhibits stripe antiferromagnetic order at low temperatures, the choice of parameters that provide closeness to the magnetic instability is reasonable. Therefore in what follows, I set $U=1.4$~eV. As for the Hund's exchange, it is taken to be $J=0.1-0.2$~eV. The $J/U$ ratio for the lower boundary, $J/U \approx 0.07$, is comparable to the widely discussed Hund's metal proposal for Fe-based materials with $J/U=0.35/4 \approx 0.08$~\cite{Haule2009}, while for the upper boundary, $J/U \approx 0.14$ is comparable with the cRPA ratio for the $d$-only orbital set, $J/U=0.43/2.92 \approx 0.14$~\cite{Miyake2008}.

Matrix elements of the transverse component of the spin susceptibility are equal to~\cite{Korshunov2014eng}
\begin{eqnarray} \label{eq:chipmmu}
 \chi^{ll',mm'}_{(0)+-}(\mathbf{q},\Omega) &=& -T \sum_{\mathbf{p},\omega_n, \mu,\nu} \left[ \varphi^{\mu}_{\mathbf{p} m} {\varphi^*}^{\mu}_{\mathbf{p} l} G_{\mu \uparrow}(\mathbf{p},\omega_n) \right.\nonumber\\
 &\times& G_{\nu \downarrow}(\mathbf{p}+\mathbf{q},\Omega+\omega_n) \varphi^{\nu}_{\mathbf{p}+\mathbf{q} l'} {\varphi^*}^{\nu}_{\mathbf{p}+\mathbf{q} m'} \nonumber\\
 &+& {\varphi^*}^{\mu}_{\mathbf{p} l} {\varphi^*}^{\mu}_{-\mathbf{p} m'} F^\dag_{\mu \uparrow}(\mathbf{p},\omega_n) \nonumber\\
 &\times& \left. F_{\nu \downarrow}(\mathbf{p}+\mathbf{q},\Omega-\omega_n) \varphi^{\nu}_{\mathbf{p}+\mathbf{q} l'} \varphi^{\nu}_{-\mathbf{p}-\mathbf{q} m} \right],
\end{eqnarray}
where $\Omega$ and $\omega_n$ are bosonic and fermionic Matsubara frequencies, $G$ and $F$ are normal and anomalous (Gor'kov) Green's functions, $\mu$ and $\nu$ are band indices, $\varphi^{\mu}_{\mathbf{k} m}$ are matrix elements of orbital-to-band transformation, so that $d_{\mathbf{k} m \sigma} = \sum\limits_{\mu} \varphi^{\mu}_{\mathbf{k} m} b_{\mathbf{k} \mu \sigma}$. Here, $b_{\mathbf{k} \mu \sigma}$ is the electron annihilation operator in the band representation, where Green's function is diagonal with respect to band indices, $G_{\mu \sigma}(\mathbf{k},\omega_n) = 1 / \left( {\mathrm{i}}\omega_n - \varepsilon_{\mathbf{k}\mu\sigma} \right)$.

Here I use two approaches to the superconducting state. The first one is phenomenological -- the gap function is chosen to simulate results of calculations and experimental findings, both of which are generally similar. Parameters of the gap function are treated as free, so one can model various situations including ones with the different sets of interaction parameters. In this case, the gap function belonging to the $A_{1g}$ representation of the tetragonal symmetry group and entering the anomalous Green's function is defined as
\begin{equation} \label{eq:delta}
 \Delta_{\mathbf{k} \mu} = \Delta_{\mu}^{0} + \Delta_{\mu}^{1} \left(\cos k_x + \cos k_y \right)/2.
\end{equation}
Here, parameter $\Delta_{\mu}^{1}$ controls changes of gap amplitude in the band $\mu$, while $\Delta_{\mu}^{0}$ controls the gap magnitude for zero amplitude (we refer to it later as the `zero-amplitude gap magnitude').
The simplest possible $s_{++}$ state takes place for $\Delta_{\mu}^{1} = 0$ and $\Delta_{\mu}^{0} = \Delta_{\mu'}^{0}$, and the simplest state of the $s_\pm$-type can be obtained taking $\Delta_{\alpha_{1,2}}^{0} = -\Delta_{\beta_{1,2}}^{0}$. The specific feature of the FS topology in pnictides is that due to the shift of $k_x$ or $k_y$ by $\pi$ with respect to $(0,0)$ point, the gap on electron pockets will have a local, i.e., with respect to pocket's center, $d$-wave symmetry~\cite{MaitiKorshunovPRB2011}.

The other approach to the superconducting state is to perform the spin fluctuation calculation of the gap function. I follow the procedure from Refs.~\onlinecite{Graser2009,Kemper2010,Korshunov2014eng}: calculate spin and charge susceptibilities in the RPA and combine them into the Cooper vertex entering the linearized gap equation. The latter is solved to obtain the eigenfunction $g(\mathbf{k})$, which is the gap function, and the eigenvalue $\lambda$; the leading instability corresponds to the largest $\lambda$.

Below, all parameters of gaps are in units of $\Delta_0$ taken to be 5~meV in our calculations. Since all gaps have $A_{1g}$ symmetry and should not change upon the $\pi/2$ rotation, gaps on electron pockets $\beta_1$ and $\beta_2$ should be the same. Thus, $\Delta_{\beta_1}^{0,1} = \Delta_{\beta_2}^{0,1}$, which we denote simply as $\Delta_\beta^{0,1}$.

To calculate the spin response, the RPA is used with the local Coulomb interaction $H_{int}$. Sum of the corresponding ladder diagrams that include electron-hole bubble in the matrix form, $\hat\chi_{(0)+-}(\mathbf{q},\omega)$, result in the following expression for the matrix of the RPA spin susceptibility~\cite{Korshunov2014eng}:
\begin{eqnarray}
 \hat\chi_{+-}(\mathbf{q},\Omega) = \left[\hat{I} - \hat{U}_s \hat\chi_{(0)+-}(\mathbf{q},\Omega)\right]^{-1} \hat\chi_{(0)+-}(\mathbf{q},\Omega),
\label{eq:chi_s_sol}
\end{eqnarray}
where $\hat{I}$ and $\hat{U}_s$ are the unit and interaction matrices, respectively, in the orbital basis. Explicit form of the latter is given in Ref.~\onlinecite{Graser2009}. In the next section I present results for the physical susceptibility $\chi_{+-}(\mathbf{q},\Omega) = \frac{1}{2} \sum_{l,m} \chi^{ll,mm}_{+-}(\mathbf{q},\Omega)$ that was analytically continued to the real frequency axis $\omega$ (${\mathrm{i}}\Omega \to \omega + {\mathrm{i}}\delta$, $\delta \to 0+$).

The mechanism of the spin resonance peak formation in the superconducting state with the sign-changing gap is quite transparent~\cite{KorshunovEreminResonance2008}. Since $\chi_{(0)+-}(\mathbf{q},\omega)$ describes particle-hole excitations and since all excitations at frequencies less than about twice the gap magnitude are absent in the superconducting state, $\mathrm{Im}\chi_{(0)+-}(\mathbf{q},\omega)$ becomes finite only above this frequency value. The anomalous Green's functions entering Eq.~(\ref{eq:chipmmu}) give rise to the anomalous coherence factors, $\left[1 - \frac{\Delta_\mathbf{k} \Delta_{\mathbf{k}+\mathbf{q}}}{E_{\mathbf{k}} E_{\mathbf{k}+\mathbf{q}}}\right]$. If $\Delta_\mathbf{k}$ and $\Delta_{\mathbf{k}+\mathbf{q}}$ have the same sign, as it is for the $s_{++}$ state, the coherence factors vanish leading to a gradual increase of the spin susceptibility with increasing frequency for $\omega > \omega_c$ with $\omega_c = \min \left(|\Delta_\mathbf{k}| + |\Delta_{\mathbf{k}+\mathbf{q}}| \right)$. For the $s_\pm$ state, vector $\mathbf{q} = \mathbf{Q}$ connects Fermi surfaces with different signs of the gap, $\mathrm{sgn} {\Delta_\mathbf{k}} \neq \mathrm{sgn} {\Delta_{\mathbf{k}+\mathbf{q}}}$, resulting in the finite coherence factors that leads to a jump in the imaginary part of $\chi_{(0)+-}$ at $\omega_c$.
For a certain set of interaction parameters entering the matrix $\hat{U}_s$, this results in a divergence of $\mathrm{Im}\chi_{+-}(\mathbf{Q},\omega)$~(\ref{eq:chi_s_sol}). The corresponding peak at a frequency $\omega_R \leq \omega_c$ is the true spin resonance. Since gaps entering the expression for $\omega_c$ correspond to bands separated by the wave vector $\mathbf{q}$, we can call $\omega_c$ the indirect or effective gap. That's the reason why in the case of unequal gaps in different bands, $\Delta_L$ and $\Delta_S$, connected by the wave vector $\mathbf{Q}$, we have $\omega_c = \Delta_L + \Delta_S$~\cite{KorshunovPRB2016}.

\section{Results for the model gap function \label{sec:resultsmodelgap}}

In this Section, Coulomb parameters are chosen to be $U=1.4$~eV and $J=0.15$~eV; the rest are constrained by the SRI.

\begin{figure}
\begin{center}
 \includegraphics[width=1.0\columnwidth]{fig_FeAs5orb_A1g_Delta_angle_spm_sExt}
 \includegraphics[width=1.0\columnwidth]{fig_FeAs5orb_s_pm_sExt_ImChi_set10_FSbig}
 \caption{(Color online) Top: Angular dependencies of gaps on hole ($\alpha_{1,2}$) and electron ($\beta_{1,2}$) Fermi surface pockets for the $s_\pm$ and the $s_{ext}$ states. Bottom: Frequency dependencies of imaginary parts of the corresponding spin susceptibilities at the wave vector $\mathbf{Q}$, as well as the normal state (non-SC) spin response. Inset: Magnitudes of gaps on the Fermi surface for the $s_{ext}$ state and the wave vector $\mathbf{Q}$.}
\label{fig:spmsext}
\end{center}
\end{figure}

Gap angular dependencies on electron and hole sheets and the corresponding frequency dependencies of imaginary parts of spin susceptibilities at the wave vector $\mathbf{Q}$ for two extended $s$-wave symmetries, namely, $s_\pm$ and $s_{ext}$ states~\cite{Graser2009}, are shown in Fig.~\ref{fig:spmsext}. The former one is the widely discussed, fully gapped $s_\pm$ state with a small gap angular dependence on each Fermi surface pocket, $\Delta_{\mathbf{k} \mu} = \Delta_{\mu} \cos(k_x) \cos(k_y)$ with $\Delta_{\alpha_1,\beta}=3$ and $\Delta_{\alpha_2}=1$. In this state, the spin resonance peak is formed at frequencies lower than $\Delta_{\beta}+\Delta_{\alpha_2}$~\cite{KorshunovPRB2016}, see the lower panel of Fig.~\ref{fig:spmsext}. The $s_{ext}$ state corresponds to such a strong anisotropy on electron pockets, that the gap becomes sign-changing there and develops a nodal structure. The latter is clearly seen in the inset of Fig.~\ref{fig:spmsext}, where the gap magnitude on the Fermi surface is shown. Parameters in Eq.~(\ref{eq:delta}) were set to be: $\Delta_{\mu}^{0}=0$, $\Delta_{\alpha_1}^{1}=3$, $\Delta_{\alpha_2}^{1}=1$, $\Delta_{\beta}^{1}=30$. The spin resonance is absent in this case since only near-nodal states with a tiny gap on electron pockets $\beta_{1,2}$ contribute to the susceptibility at the wave vector $\mathbf{Q}$, as seen in the inset in Fig.~\ref{fig:spmsext}. Therefore, the discontinuous jump in $\mathrm{Im}\chi_{(0)+-}$ required for the formation of the spin resonance appears at vanishingly small frequencies and the RPA spin response gets only a small boost compared to the normal state, see Fig.~\ref{fig:spmsext}. This is similar to the case of $d_{x^2-y^2}$ gap symmetry where the spin resonance is absent at the commensurate wave vector~\cite{KorshunovEreminResonance2008}. Of course, the spin resonance may appear at the incommensurate wave vector different from $\mathbf{Q}$, see the discussion in Ref.~\onlinecite{Maier2009}.

\begin{figure}
\begin{center}
 \includegraphics[width=1.0\columnwidth]{fig_FeAs5orb_A1g_Delta_angle_set1}
 \includegraphics[width=1.0\columnwidth]{fig_FeAs5orb_A1g_set1_ImChi_set10}
 \caption{Top: Angular dependencies of gaps for several $A_{1g}$-type states with the fixed gap anisotropy on hole pockets and varying zero-amplitude gap magnitude on electron pockets. Bottom: Corresponding frequency dependencies of $\mathrm{Im}\chi_{+-}(\mathbf{Q},\omega)$, as well as the spin response in the normal (non-SC), $s_\pm$, and $s_{ext}$ states.}
\label{fig:A1gSet1}
\end{center}
\end{figure}

\begin{figure}
\begin{center}
 \includegraphics[width=1.0\columnwidth]{fig_FeAs5orb_A1g_Delta_angle_set2}
 \includegraphics[width=1.0\columnwidth]{fig_FeAs5orb_A1g_set2_ImChi_set10}
 \caption{Top: Angular dependencies of gaps for several $A_{1g}$-type states with the fixed zero-amplitude gap magnitude and varying gap anisotropy on electron pockets. The case when $\Delta_{\beta}^{0}$ is shifted while $\Delta_{\beta}^{1}$ kept minimal is also shown. Bottom: Frequency dependence of $\mathrm{Im}\chi_{+-}(\mathbf{Q},\omega)$ for these states, as well as for the normal and the $s_\pm$ states.}
\label{fig:A1gSet2}
\end{center}
\end{figure}

Most superconducting solutions in the spin fluctuation theory of pairing having the $A_{1g}$ symmetry are characterized by gaps with the weak angular dependence on hole pockets and a significant anisotropy on electron Fermi surface sheets~\cite{MaitiKorshunovPRB2011}. To model such a situation, I set the amplitude and the anisotropy of gaps on the hole pockets in Eq.~(\ref{eq:delta}) to be $\Delta_{\alpha_1}^{0}=1$, $\Delta_{\alpha_1}^{1}=0$, $\Delta_{\alpha_2}^{0}=-16.4$, $\Delta_{\alpha_2}^{1}=20$. This gives the constant gap on the inner hole pocket $\alpha_1$ and a weak anisotropy on the outer hole pocket $\alpha_2$. At the same time, the gap on $\alpha_1$ is approximately three times the gap on $\alpha_2$. This case is shown in Figs.~\ref{fig:A1gSet1}-\ref{fig:A1gSet2} and in~\onlinecite{PRBSuppl}.

First, I fix the gap anisotropy on electron pockets by setting $\Delta_{\beta}^{1}=16$ and vary the zero-amplitude magnitude, $\Delta_{\beta}^{0}$, of the gap there. The result is shown in Fig.~\ref{fig:A1gSet1}. Once the average gap on electron pockets have the same sign as on hole pockets (the case of $\Delta_{\beta}^{0}=1$), the resonance condition, $\Delta_{\mathbf{k}} = -\Delta_{\mathbf{k}+\mathbf{Q}}$, is not fulfilled and the spin resonance is absent. For the opposite signs of gaps at the wave vector $\mathbf{Q}$, the spin resonance forms and its frequency is as higher as larger the absolute value of the zero-amplitude gap magnitude on electron pockets.

Second, I change the gap anisotropy on electron pockets by varying $\Delta_{\beta}^{1}$ while the zero-amplitude gap magnitude is fixed, $\Delta_{\beta}^{0}=-2$. Results are shown in Fig.~\ref{fig:A1gSet2}. Experimentally observed gap anisotropy of 30\%~\cite{Shimojima2011,Abdel-Hafiez2014,Kuzmicheva2017} approximately corresponds to the case of $\Delta_{\beta}^{1}=4$ shown here. Evidently, decrease of the gap anisotropy leads to the increase of the spin resonance frequency. The same figure illustrates what happens when $\Delta_{\beta}^{0}$ is shifted to higher energies for the minimal amplitude shown. As expected, the spin resonance peak shifts to higher frequencies. Obviously, decrease of the spin resonance frequency with increasing the gap amplitude originates from the decrease of the effective gap at the wave vector $\mathbf{Q}$ entering the dynamical spin susceptibility. Decrease of the peak frequency is accompanied by the loss of its intensity due to the diminished spectral weight in agreement with the results of Ref.~\onlinecite{Maiti2011}.

\section{Results for the calculated gap function \label{sec:resultscalcgap}}

\begin{figure}
\begin{center}
 \includegraphics[width=1.0\columnwidth]{fig_Delta_set18}
 \includegraphics[width=1.0\columnwidth]{fig_FeAs5orb_SFset18_ImChi_set10_FSbig}
 \caption{(Color online) Top: Angular dependencies of gaps on hole ($\alpha_{1,2}$) and electron ($\beta_{1,2}$) Fermi surface pockets calculated within the spin fluctuation pairing theory (SF gap) and obtained by fitting the parameters of Eq.~(\ref{eq:delta0123}). Bottom: Frequency dependencies of imaginary parts of the spin susceptibilities at the wave vector $\mathbf{Q}$ in the normal state (non-SC), for the model $s_\pm$ state, and for the SF gap. Magnitudes of the latter on the Fermi surface and the wave vector $\mathbf{Q}$ are shown in the inset.
 The SF gap was normalized by $\tilde\Delta_0=50$~meV to compare with our model results.}
\label{fig:SFset18}
\end{center}
\end{figure}

The linearized gap equation within the spin fluctuation theory of pairing was solved and the gap function $g(\mathbf{k})$ and the corresponding eigenvalue $\lambda$ were obtained. For $U=1.4$~eV, $J=0.1$, $0.15$, and $0.2$~eV, the leading instability is the $A_{1g}$ gap that can be parameterized as
\begin{eqnarray} \label{eq:delta0123}
 \Delta_{\mathbf{k} \mu} &=& \Delta_{\mu}^{0} + \Delta_{\mu}^{1} \left(\cos k_x + \cos k_y \right)/2 + \Delta_{\mu}^{2} \cos k_x \cos k_y \nonumber\\
 &+& \Delta_{\mu}^{3} \left(\cos 2k_x + \cos 2k_y \right)/2.
\end{eqnarray}
Two other instabilities has $d_{x^2-y^2}$ and $d_{xy}$ gap symmetries. For $U=1.4$~eV and $J=0.1$~eV as an example, $\lambda=0.24$, $0.19$, and $0.08$ corresponds to the $A_{1g}$ gap, $d_{x^2-y^2}$ gap, and $d_{xy}$ gap, respectively. Increase of $J$ doesn't change this hierarchy, see~\onlinecite{PRBSuppl} for details. In general, the observed situation is typical for iron-based superconductors and was extensively discussed within the leading angular harmonics approximation (LAHA)~\cite{MaitiKorshunovPRL2011,MaitiKorshunovPRB2011}.

In the following, we call the obtained $A_{1g}$ gap the SF gap. The resulting gap angular dependence for $U=1.4$~eV and $J=0.15$~eV is shown in Fig.~\ref{fig:SFset18}. It was fitted by the functional form~(\ref{eq:delta0123}) and the following parameters were obtained (only nonzero values in units of $\Delta_0$ are presented): $\Delta_{\alpha_1}^0=-23.76$, $\Delta_{\alpha_1}^3=26$, $\Delta_{\alpha_2}^0=-4.76$, $\Delta_{\alpha_1}^3=6$, $\Delta_{\beta}^0=6.99$, $\Delta_{\beta}^1=-15.5$, $\Delta_{\beta}^3=-10$.

Spin response for the gap function with the aforementioned parameters is shown in Fig.~\ref{fig:SFset18}. $\mathrm{Im}\chi_{+-}$ in the $s_\pm$ state is also shown there for comparison. The spin resonance peak appears in both cases, but at lower frequencies for the SF gap because of the smaller effective gap at the wave vector $\mathbf{Q}$. Note the similarity between the spin response for the SF gap and for the model gap with $\Delta_{\beta}^0=-1.6$ and $\Delta_{\beta}^1=16$ shown in Fig.~\ref{fig:A1gSet1}. The similarity stems again from the fact that the spin response at the wave vector $\mathbf{Q}$ is governed by the effective gap at the same wave vector. Therefore, even for the different functional forms of the gaps, (\ref{eq:delta}) and (\ref{eq:delta0123}), their comparable values at $\mathbf{Q}$ lead to the similarity in $\mathrm{Im}\chi_{+-}$.

\begin{figure}
\begin{center}
 \includegraphics[width=1.0\columnwidth]{fig_FeAs5orb_SFsets_ImChi_sets}
 \caption{(Color online) Frequency dependence of imaginary part of the spin susceptibility at the wave vector $\mathbf{Q}$ in the normal state (non-SC), for the SF gap, and for the model $s_\pm$ state. Susceptibilities are shown for different sets of interaction parameters.}
\label{fig:SFsets}
\end{center}
\end{figure}

Now we discuss the interaction dependence of the spin resonance peak. Hubbard repulsion was chosen to be $U=1.4$~eV so that the system is on the verge of the magnetic instability; slight increase of it results in the spin susceptibility divergence. Therefore, the spin response in this case is very pronounced. To see what happens near the point with $J=0.15$~eV, $\mathrm{Im}\chi_{+-}$ was calculated for $J=0.1$~eV and $J=0.2$~eV. Since the SF gap structure doesn't change much for the mentioned values of Hund's exchange, the gap parameters are fixed to be the same as for $U=1.4$~eV and $J=0.15$~eV. The results for the SF gap and for the $s_\pm$ gap are shown in Fig.~\ref{fig:SFsets}. Apparently, the peak shifts to lower frequencies and becomes higher and sharper with the increase of $J$. This trend is similar for both the SF and the model $s_\pm$ gaps. Such a behavior is due to the structure of the RPA susceptibility denominator. As was discussed above, in accordance  with the Kramers-Kronig relations, the jump in $\mathrm{Im}\chi_{(0)+-}(\mathbf{Q},\omega)$ at $\omega_c$ leads to a logarithmic singularity in the real part of the susceptibility. Sice the divergence condition determining the spin resonance peak is $\hat{U}_s \hat\chi_{(0)+-}(\mathbf{q},\omega) = \hat{I}$, see Eq.~(\ref{eq:chi_s_sol}), the position of the peak is determined by the interaction matrix elements $\hat{U}_s$ and the behavior of $\mathrm{Re}\chi_{(0)+-}(\mathbf{Q},\omega)$ near the logarithmic singularity. The relation between these two quantities determines $\omega_R$. Here I vary $J$ thus effectively changing $\omega_R$. Increase of interaction parameters decreases $\hat{U}_s^{-1}$ and the divergence can take place for smaller values of $\mathrm{Re}\chi_{(0)+-}(\mathbf{Q},\omega)$. The latter appears at lower frequencies, thus $\omega_R$ shifts towards zero. That is exactly what is seen in Fig.~\ref{fig:SFsets}.

\section{Conclusions \label{sec:conclusion}}

\begin{table}
\caption{\label{tab} Comparison of peak energies in inelastic neutron scattering, $\omega_{INS}$, and larger and smaller gaps, $\Delta_L$ and $\Delta_S$, in various Fe-based superconductors. Values of frequencies and gaps are given in meV. Here $*$, $**$, and $\dag$ marks gaps extracted from Andreev experiments, BCS fit of $H_{c1}(T)$, and tunneling spectra, respectively; otherwise, gaps are from ARPES. Here, ``$?$'' marks the ``expected'' value of $\omega_{INS}$ (according to value for nearest doping) in a material for which the measurement is absent. If the peak frequency and gaps satisfy condition $\omega_{INS} \leq \min(\Delta_L)+\min(\Delta_S)$, frequency is written in \DLS{bold face}, and if they satisfy condition $\omega_{INS} \leq 2\min(\Delta_L)$, \DLL{italic} is used.}
\begin{tabular}{cccccc}
\hline
\hline
\centering{Material} & $T_c$ (K) & $\omega_{INS}$ & $\min(\Delta_L)$, $\min(\Delta_S)$\\
\hline
BaFe$_{1.9}$Co$_{0.1}$As$_2$ & 19 & \DLS{7.3}-\DLL{9.3}~\cite{Wang2016} & 5.0, 4.0~\cite{Wang2016} \\
BaFe$_{1.866}$Co$_{0.134}$As$_2$ & 25 & \DLS{7.0-8.0}~\cite{Wang2016} & 6.5, 4.6~\cite{Wang2016} \\
BaFe$_{1.81}$Co$_{0.19}$As$_2$ & 19 & \DLS{7.5-9.5}~\cite{Wang2016} & 5.6, 4.6~\cite{Wang2016} \\
BaFe$_{1.85}$Co$_{0.15}$As$_2$ & 25 & \DLS{7.7}-\DLL{10.0}~\cite{Inosov2010,Park} & 6.0, 3.8~\cite{Terashima2009} \\
BaFe$_{1.85}$Co$_{0.15}$As$_2$ & 25.5 & \DLS{9.5?} & 5.6, 4.0~\cite{Kawahara2010} \\
BaFe$_{1.8}$Co$_{0.2}$As$_2$ & 24.5 & \DLS{9.5?} & 8.2, 3.8$*$~\cite{Tortello2010} \\
\hline
Ba$_{0.6}$K$_{0.4}$Fe$_2$As$_2$ & 38 & \DLS{13-14}~\cite{ChristiansonBKFA,Castellan2011,Shan2012} & 10.0, 5.0~\cite{Ding2008} \\
Ba$_{0.6}$K$_{0.4}$Fe$_2$As$_2$ & 38 & \DLL{13-14}~\cite{ChristiansonBKFA,Castellan2011,Shan2012} & 8.0, 4.0~\cite{Wray2008} \\
Ba$_{0.6}$K$_{0.4}$Fe$_2$As$_2$ & 38 & \DLL{13-14}~\cite{ChristiansonBKFA,Castellan2011,Shan2012} & 8.0, 2.0~\cite{Zhang2010,Shimojima2011} \\
Ba$_{0.6}$K$_{0.4}$Fe$_2$As$_2$ & 38 & \DLL{13-14}~\cite{ChristiansonBKFA,Castellan2011,Shan2012} & 8.4, 3.2$\dag$~\cite{Shan2012} \\
Ba$_{0.6}$K$_{0.4}$Fe$_2$As$_2$ & 35 & \DLL{14.8}-15.2~\cite{Castellan2011} & 7.5, 5~\cite{Zhao2008ARPES} \\
Ba$_{0.6}$K$_{0.4}$Fe$_2$As$_2$ & 37.5 & \DLL{14.8-15.2}~\cite{Castellan2011} & 8.5, 1.7$**$~\cite{Ren2008} \\
Ba$_{0.65}$K$_{0.35}$Fe$_2$As$_2$ & 34 & 12.2-13.5~\cite{Castellan2011} & 5.7, 1.4$*$~\cite{Abdel-Hafiez2014} \\
Ba$_{1-x}$K$_{x}$Fe$_2$As$_2$ & 32 & \DLL{14.9-15.3}~\cite{Castellan2011} & 7.8, 1.1~\cite{Evtushinsky2009,Evtushinsky2009NJP} \\
\hline
FeSe & 8 & \DLS{4}~\cite{Wang.nmat4492} & 3.5, 2.5$\dag$~\cite{Kasahara.PNAS.111.16309} \\
FeSe & 8 & \DLL{4}~\cite{Wang.nmat4492} & 2.4, 0.6$*$~\cite{Ponomarev2013} \\
\hline
LiFeAs & 18 & \DLS{4}-12~\cite{Taylor.PhysRevB.83.220514} & 4.7, 2.5~\cite{Borisenko.PhysRevLett.105.067002,Borisenko.symmetry-04-00251,Umezawa.PhysRevLett.108.037002} \\
LiFeAs & 18 & \DLS{4}-12~\cite{Taylor.PhysRevB.83.220514} & 5.1, 0.9$*$~\cite{Kuzmichev2012,Kuzmichev2013} \\
LiFeAs & 18 & \DLS{4}-12~\cite{Taylor.PhysRevB.83.220514} & 5.2, 2.3$\dag$~\cite{Chi.PhysRevLett.109.087002,Hanaguri.PhysRevB.85.214505,Nag.srep27926} \\
\hline
NaFe$_{0.935}$Co$_{0.045}$As & 18 & \DLS{7}~\cite{Zhang.PhysRevLett.111.207002} & 4.5, 4.0~\cite{Zhang.PhysRevLett.111.207002,Ge.PhysRevX.3.011020} \\
NaFe$_{0.935}$Co$_{0.045}$As & 18 & \DLS{6.7-6.9}~\cite{Zhang.PhysRevB.88.064504} & 6.0, 5.0~\cite{Liu.PhysRevB.84.064519} \\
NaFe$_{0.95}$Co$_{0.05}$As & 18 & \DLS{7?} & 6.0, 5.0~\cite{Liu.PhysRevB.84.064519} \\
\hline
CaKFe$_4$As$_4$ & 18 & \DLS{12.5}~\cite{Iida2017} & 10.0, 6.0~\cite{Mou2016} \\
\hline
\hline
\end{tabular}
\end{table}

Within the five-orbital model for iron-based materials, I considered the question on what happens to the spin resonance when the anisotropy of the gap changes. By using both model gap function and the one calculated via the spin fluctuation theory of pairing, it is shown that the spin resonance peak forms for most of the superconducting solutions originating from the spin fluctuation approach to the pairing and having the $A_{1g}$ symmetry, including the $s_\pm$ state. The peak frequency is as higher as larger the zero-amplitude gap magnitude on electron pockets. On the contrary, the increase of the anisotropy leads to the decrease of the peak frequency that is connected with the decrease of the effective gap at the scattering wave vector $\mathbf{Q}$.

As for the experimental verification of the spin resonance appearance, the condition for the spin resonance frequency $\omega_R$ in the case of the anisotropic gaps $\Delta_{L,S}$ becomes $\omega_R \leq \min(\Delta_L)+\min(\Delta_S)$. If all values entering here fulfills this condition, then the observed peak is the true spin resonance. Otherwise, a calculation involving the details of the band structure and superconducting gap is required to make a definite conclusion. I collected available experimental data in Table~\ref{tab}. Note the data for Co-doped materials and a recently discovered CaKFe$_4$As$_4$ fall into the first category and, therefore, demonstrate presence of the $s_\pm$-type gap. Other materials require more efforts from both theoretical and experimental sides to (1) extract precise values of gaps and peak energies and (2) perform calculations for particular band and gap structures.

Additional information can be gained from the temperature dependence of the resonance peak. Since the peak frequency $\omega_R$ is determined by the amplitude of gaps, and the gaps decrease with temperature while approaching $T_c$, $\omega_R(T)$ should also scale with $\Delta_{L,S}(T)$. Simultaneous measurement of the temperature dependence of gaps and peak frequency is highly desirable for understanding of the spin resonance details.

\begin{acknowledgements}
I would like to thank I. Eremin, S.A. Kuzmichev, and T.E. Kuzmicheva for useful discussions. This work was supported in part by Presidium of RAS Program for the Fundamental Studies No. 12, Gosbudget program No. 0356-2017-0030, and Foundation for the advancement of theoretical physics and mathematics ``BASIS''.
\end{acknowledgements}


\section{Introduction}
Boolean satisfiability is a well known NP-complete problem that serves as the basis for many computationally hard tasks. Some of these applications, such as formal software verification and data mining, are well served by solvers which are capable of finding more than one satisfying assignment of variables, or even all such solutions \cite{toda2015implementing}. Quantum annealing (QA) has been applied to the solution of weighted max 2-SAT problems \cite{santra2014max,bian2010teaching}, the construction of SAT filters \cite{douglass2015constructing}, SAT variants \cite{roy2016mapping}, and frustrated loop problems inspired by SAT \cite{hen2015probing,king2015performance}. QA hardware operates by performing many annealing (solving) cycles, returning a potential solution sample for each cycle \cite{johnson2011quantum,bian2010teaching}. We seek to discover whether quantum annealers could provide an advantage in finding multiple solutions to satisfiability problems.

We first provide a construction for posing satisfiability problems to quantum annealing hardware solvers in Section \ref{sec_sat_penalty}. Section \ref{sec_mixedsat} defines our problem set, and Section \ref{sec_results} details the results of our quantum and classical solution sampling comparision.

\section{Cascading-OR SAT penalty functions}
\label{sec_sat_penalty}

Satisfiability problems in general consist of a conjunction of disjunctive clauses. The conjunction can be achieved on quantum annealing hardware by summing terms representing individual clauses, so we will focus here on defining the disjunctive clause Hamiltonian penalty functions, which we denote $H_k$, with $k$ the number of variables in each clause. The clauses are built using a cascading-OR construction, which requires $2(k-1)$ qubits per clause. It should be noted that the resulting clauses are not directly embeddable on QA hardware graphs. No direct embeddings are proposed here, primarily due to the fact that many clauses share variables, and by the time this is taken into account in building the Hamiltonian, a heuristic embedding algorithm for the problem as a whole will still be required. The overhead of heuristic embedders for QA hardware graphs is of course an entire line of research on its own.

We begin our construction with two building blocks. The first is
\begin{equation}
H_2(x1,x2) = -\sigma^z_{x1} - \sigma^z_{x2} + \sigma^z_{x1}\otimes\sigma^z_{x2} ,
\end{equation}
the ground states of which represent the states for which $x1\vee x2$ evaluates to true, i.e. the states for which the $2$-SAT clause is satisfied. We also define an "OR with output" penalty function
\begin{equation}
H_{OR}(x1,x2,z) = \sigma^z_{x1} + \sigma^z_{x2} - 2\sigma^z_z + \sigma^z_{x1}\otimes\sigma^z_{x2} - 2\sigma^z_{x1}\otimes\sigma^z_{z} - 2\sigma^z_{x2}\otimes\sigma^z_{z} ,
\end{equation}
which has as its ground states the states where  $x1 \vee x2 = z$, the crucial difference being that the correct state of the OR output is included in the penalty function. By substituting the output bit $z$ from the OR function for $x1$ in $H_2$, we can easily construct $H_3$:
\begin{align}
H_3 &= H_{OR}(x1,x2,z1) + H_2(z1,x3)\\
&= (\sigma^z_{x1} + \sigma^z_{x2} - 2\sigma^z_{z1} + \sigma^z_{x1}\otimes\sigma^z_{x2} - 2\sigma^z_{x1}\otimes\sigma^z_{z1} - 2\sigma^z_{x2}\otimes\sigma^z_{z1}) - \sigma^z_{z1}  - \sigma^z_{x3} + \sigma^z_{z1}\otimes\sigma^z_{x3} ,
\end{align}
where the part of the equation in parenthesis represents $H_{OR}$ applied to $x1$ and $x2$, with its output $z1$ cascaded into one of the qubits in $H_2$. Note that the term $\sigma^z_{z1}$ appears twice in the equation because it is shared between $H_{OR}$ and $H_2$, so the collected term would be $-3\sigma^z_{z1}$. See Figure \ref{blocks_figure} for diagrams of the basic penalty functions we have introduced.

\begin{figure}
\centering
\begin{subfigure}{0.45\textwidth}
	\includegraphics[width=0.5\textwidth]{H2.png}
	\caption{2-SAT penalty}
\end{subfigure}
\begin{subfigure}{0.45\textwidth}
	\includegraphics[width=0.5\textwidth]{HOR.png}
	\caption{OR with output penalty}
\end{subfigure}
\caption{Building blocks for cascading-OR penalty functions.}
\label{blocks_figure}
\end{figure}

Penalty functions $H_k$ of any size can be built inductively by extending this methodology. Start with a valid $H_{k-1}$, choose any of the qubits which directly represent problem variables (shown in above equations as $xi$), and substitute the output qubit of $H_{OR}$ into its place. The size of the penalty function grows by $2$ qubits because we are putting three in the place of one. Because we can choose any problem variable qubit, we can define multiple equivalent $H_k$ penalty functions depending on which substitution we use. Figure \ref{options_figure} shows several possible constructions of $H_3$ and $H_4$ penalty functions.

\begin{figure}
\centering
\begin{subfigure}{0.45\textwidth}
	\includegraphics{H3_1.png}
	\caption{Option 1 for 3-SAT penalty}
\end{subfigure}
\begin{subfigure}{0.45\textwidth}
	\includegraphics{H3_2.png}
	\caption{Option 2 for 3-SAT penalty}
\end{subfigure}
\begin{subfigure}{0.5\textwidth}
	\includegraphics{H4_1.png}
	\caption{Option 1 for 4-SAT penalty}
\end{subfigure}
\begin{subfigure}{0.5\textwidth}
	\includegraphics{H4_2.png}
	\caption{Option 2 for 4-SAT penalty}
\end{subfigure}
\caption{Options for $H_3$ and $H_4$. The penalty function can take different forms depending on which logical variable qubits are extended by $H_{OR}$; these forms become more varied as $k$ increases and the decision tree widens.}
\label{options_figure}
\end{figure}

\section{Mixed SAT}
\label{sec_mixedsat}

The test problem set for this study consists of a group of mixed SAT problems which contain clauses of diverse lengths (as compared to the standard 3-SAT, in which each clause involves three variables). The test set was tailored to be feasible on the D-Wave 2X generation of quantum annealers. We ran $123$ instances with $n=30$ on a $1098$ qubit QA chip, taking $1000$ solution samples for each instance and parameter setting at an annealing time of $20$ microseconds per sample. These instances were a subset of a larger set of mixed SAT instances which was generated randomly, then downselected based on number of solutions (less than a million) and embeddability of the resulting penalty function on hardware.

\section{Results}
\label{sec_results}

\subsection{Timing metrics}
We considered two timing metrics for the quantum annealer results. The first, core annealing time, is important because it captures the key physics of the computation. The quantum annealer calculates the satisfying assignment by performing an adiabatic quantum evolution from a known original hardware state to the unknown problem solution. This process is the \textit{core anneal}, and is the key difference between quantum annealers and classical hardware. By separating the core anneal time from other hardware times, we get an idea of the essential limits on this type of computation.

We also present results using wallclock time for the quantum annealer. This includes, among many things, programming time, thermalization time (so the chip can cool down after programming), core annealing time, readout time, and postprocessing time. The wallclock time is how long we have to wait for results from the current generation of quantum annealers. However, there is reason to believe that many of the elements within the wallclock time will be subject to engineering improvement in the near term.

\subsection{Classical comparison}
We used a recently published classical ALL-SAT solver \cite{toda2015implementing} to count the solutions for each problem and establish a timing baseline. Toda and Soh programmed several ALL-SAT modifications to MiniSAT, a well known single-solution SAT solver. We used the version that performed best in their benchmarks. The optimality of this solver for ALL-SAT problems in general and mixed SAT in particular is not established, but it is the current state of the art. All times shown for the classical solver are wallclock times. The solver timestamped each solution, so we have granular timing data as to when each solution was found.

\subsection{Core annealing time}
When only core annealing time is considered, most instances in the problem set initially find solutions faster than the classical solver. In Figure \ref{fig_instance_2_anneal}, the classical and quantum curves for time to find distinct solutions are shown. The quantum annealer initially finds solutions much more quickly, but slows in the rate at which it finds new solutions, allowing the classical curve to cross under it. Figure \ref{fig_crossover} shows these crossover points for the entire instance set. We find an initial quantum advantage in the tens of solutions for most instances. It is relevant to note that the sets of solutions found by the classical and quantum solvers at the crossover point have low overlap (see Figure \ref{fig_overlap} for details).

\begin{figure}
\centering
\includegraphics[width=\textwidth]{instance_2_curves.pdf}
\caption{Rate of solution finding for classical and quantum solvers. This plot is for an instance with one of the larger initial solution finding advantages compared to the classical alternative. The shapes of the curves are consistent across all instances in the problem set.}
\label{fig_instance_2_anneal}
\end{figure}

\begin{figure}
\centering
\includegraphics[width=\textwidth]{crossover_scatter.pdf}
\caption{Crossover points between classical and quantum solution finding rates. Each point represents one problem instance and shows the location of the crossover we see for a single problem in Figure \ref{fig_instance_2_anneal}. Error bars represent the resolution of the timing data.}
\label{fig_crossover}
\end{figure}

\begin{figure}
\centering
\includegraphics[width=\textwidth]{answer_overlap_hist.pdf}
\caption{Overlap between classical and quantum solution sets at crossover. Bars indicate the number of problem instances with a given fraction of solutions appearing in both the classical and quantum partial solution sets at the crossover point.}
\label{fig_overlap}
\end{figure}

\subsection{Wallclock time}
When all quantum processor activities are accounted for, and we compare quantum wallclock to classical wallclock time, the initial advantage disappears. Figure \ref{fig_instance_2_wallclock} shows the same instance as Figure \ref{fig_instance_2_anneal}, but with the quantum wallclock rather than core anneal time. The quantum curve is immediately at a disadvantage and never crosses the lower classical time curve. This is true for all instances in the set we studied.

\begin{figure}
\centering
\includegraphics[width=\textwidth]{instance_2_curves_wallclock.pdf}
\caption{Wallclock rate of solution finding for classical and quantum solvers. This is the same problem instance shown in Figure \ref{fig_instance_2_anneal}, with the quantum curve measured in wallclock rather than core annealing time. Any quantum advantage is lost.}
\label{fig_instance_2_wallclock}
\end{figure}

\subsection{Solution sampling}
Quantum annealers solve problems by sampling from the low energy state space of the penalty function, so it is natural to consider the application of quantum annealers as solution samplers for problems of interest. In particular, we were interested in whether quantum annealers could provide more variety in the answer set than classical solvers, particularly because the quantum penalty function can be subjected to trivial spin reversal transformations or parameter settings that leave the identity of the ground state solutions the same but change the physics of the solving process \cite{ronnow2014defining,pudenz2016parameter}. To measure the diversity of the solution set, we look at the Hamming distance between neighboring solution samples (Figure \ref{fig_hamming_neighbor}). We find that the classical solver is both more consistent in the distribution of solutions and finds solutions that are more widely separated in Hamming distance.

\begin{figure}
\centering
\includegraphics[width=\textwidth]{instance_44_Hamming_from_neighbor_5.pdf}
\caption{Hamming distance between neighboring solutions. The solutions for a typical problem instance are displayed here in the order they were returned from each solver. Each point represents the Hamming distance of the current solution from the one that came before it. Blue circles represent solutions from the classical solver. All other colors and shapes represent solutions from the quantum annealer, each type of marker indicating one trivial spin reversal transformation (SRT) of the problem's penalty function. All spin reversals on the quantum annealer behave consistently, but the distance between adjacent classical solutions is both higher and more consistent than the quantum solver can produce.}
\label{fig_hamming_neighbor}
\end{figure}

\section{Conclusions}
Quantum annealers have the potential to assist in finding multiple solutions to mixed satisfiability problems, but in their current form are not ready for the task. The advantage in time for finding an initial set of solution samples seen when only core annealing time is considered and the low overlap between the quantum and classical crossover solution sets points to a potential future role for a quantum solver as a helper to a classical solver. Indeed, it might be possible to run the quantum solver to crossover with the classical solver, apply a spin reversal transformation, and run the quantum solver again to find another set of solutions. However, with current quantum annealing technology, the overhead timing factors included in the wallclock time destroy any advantage.