1 Introduction

Quantum codes are used in quantum computation and quantum communication to lessen decoherence. It is well known that the standard quantum codes can be constructed from classical linear codes that must meet specific dual-containing condition [3]. The dual-containing condition limits that many linear codes with good performance can not produce quantum codes.

In 2002, Bowen [1] found that pre-shared entangle states between the sender and the receiver can increase both quantum and classical capacity for communication. In 2006, Brun et al. [2] showed that non-dual-containing quaternary linear codes can be applied to construct entanglement-assisted quantum error-correcting (EAQEC) codes. Later, a general coding scheme for creating binary EAQEC codes was developed, and many specific construction methods were put forward [11, 12, 18, 35]. In [9], the authors generalized these methods to an arbitrary finite field. Afterwards, many classes of non-binary EAQEC codes have been derived from classical linear codes such as constacyclic codes, linear complementary dual (LCD) codes, generalized Reed-Solomom (GRS) codes, extended GRS codes and Goppa codes (see [6, 7, 13, 14, 22, 23, 28, 31, 33]).

EA-quantum Singleton bound of EAQEC codes was proposed by Brun et al. in [2]. In 2016, Grassl [10] gave some examples of EAQEC codes and showed that the bound was not incomplete. In fact, this bound holds if \(d\le \frac{n+2}{2}\) [17]. Now, we present the bound as follows.

Theorem 1

[2, 10, 18] (EA-quantum Singleton bound) For any \([[n,k,d;c]]_q\) EAQEC code, if \(d\le \frac{n+2}{2}\), then \(n+c-k\ge 2(d-1)\), where \(0\le c\le n-1\).

An EAQEC code with \(d\le \frac{n+2}{2}\) achieves the EA-quantum Singleton bound, then it is called an entanglement-assisted quantum maximum distance separable (EAQMDS) code.

Constacyclic codes including cyclic codes and negacyclic codes have been applied extensively to construct EAQEC codes because they have good algebraic structure. In 2011, Li et al. [20, 21] proposed the decomposition of defining sets of cyclic codes and they obtained EAQMDS codes with large minimum distance. In [5, 24], the authors expanded the concept to general constacyclic codes, and many families of EAQMDS codes of length n dividing \(q^2+1\) or \(q^2-1\) were constructed. Lu et al. [27] constructed EAQMDS codes from constacyclic codes with special lengths by consuming one or four entanglement bits. Liu et al. [24] used constacyclic codes to get EAQMDS codes of length \(\frac{q+1}{r}(q-1)\), where \(3\le r\le 7\). In 2019, Qian et al. [29] derived a family of EAQEC codes with flexible parameters from cyclic codes. In the same year, Sari et al. [30] applied constacyclic codes of length \(\frac{q^2-1}{4}\) to construct EAQMDS codes. In 2020, Wang et al. [32] obtained a series of EAQEC codes of length \(\frac{q-1}{a}(q+1)\) from cyclic and negacyclic codes, and they turned out that the number of required entanglement bits can take almost all possible values. In 2022, Lu et al. [25, 26] constructed EAQMDS codes from cyclic codes with flexible parameters and large minimum distance.

In this work, we pay attention to EAQEC codes of length \(n=\frac{q^2-1}{r}\), where r is a positive divisor of \(q+1\). Most of these codes are new, and some of them have better performance than ones obtained in the literature [8, 24, 25, 27, 30]. The EAQEC codes in this paper are MDS if the minimum distance \(d\le \frac{n+2}{2}\). The paper is organized as follows. Some related basic knowledge and theorems are listed in Section 2. In Section 3, by characterizing the \(q^2\)-cyclotomic cosets modulo rn, some EAQEC codes with large minimum distance are provided. In Section 4, two classes of EAQMDS codes consuming one or two pairs of maximally entangled states with larger minimum distance are obtained. Section 5 compares EAQEC codes in this paper with the known ones.

2 Preliminaries

Let q be a prime power. Let \(\mathbb {F}_{q^2}\) denote the finite field with \(q^2\) elements, and \(\mathbb {F}_{q^2}^{*}\) denote the multiplicative group consisted of the nonzero elements of \(\mathbb {F}_{q^2}\). For each \(\alpha \in \mathbb {F}_{q^2}^{*}\), the conjugate of \(\alpha \) is defined by \(\bar{\alpha }=\alpha ^q\). Given two vectors \({\textbf {x}}=(x_1,x_{2},\ldots ,x_n), {\textbf {y}}=(y_1,y_{2},\ldots ,y_n)\in \mathbb {F}_{q^2}^n\), their Hermitian inner product is defined by

$$\begin{aligned} ({\textbf {x}},{\textbf {y}})_h=\sum _{i=1}^{n}\bar{x}_iy_{i}=\bar{x}_1y_1+\bar{x}_2y_2+\cdots +\bar{x}_ny_n. \end{aligned}$$

A linear code \(\mathcal {C}\) over \(\mathbb {F}_{q^2}\) of length n is a subspace of \(\mathbb {F}_{q^2}^{n}\). The Hermitian dual code of \(\mathcal {C}\) is

$$\begin{aligned} \mathcal {C}^{\perp _{h}}=\{{\textbf {x}}\in \mathbb {F}_{q^2}^n\mid ({\textbf {x,y}})_h=0, \text {for any {\textbf {y}}} \in \mathcal {C}\}. \end{aligned}$$

If \(\mathcal {C}^{\perp _{h}}\subseteq \mathcal {C}\), then \(\mathcal {C}\) is called a Hermitian dual-containing code.

Assume that \(\gcd (n,q)=1\). Let \(\lambda \in \mathbb {F}_{q^2}^*\) have order r, i.e., \(\text {ord}(\lambda )=r\). For each vector \((c_0,c_1,\ldots ,c_{n-1})\in \mathbb {F}_{q^2}^n\), a \(\lambda \)-constacyclic shift \(f_{\lambda }\) is denoted by

$$\begin{aligned} f_{\lambda }(c_0,c_1,\ldots ,c_{n-1})=(\lambda c_{n-1},c_{0},\ldots ,c_{n-2}). \end{aligned}$$

A linear code \(\mathcal {C}\) over \(\mathbb {F}_{q^2}\) of length n is a \(\lambda \)-constacyclic code if it is invariant under the \(\lambda \)-constacyclic shift \(f_{\lambda }\) on \(\mathbb {F}_{q^2}^n.\) By identifying a vector \(c=(c_{0},c_{1},\ldots ,c_{n-1})\) with a polynomial \(c(x)=c_{0}+c_{1}x+\cdots +c_{n-1}x^{n-1}\), a \(\lambda \)-constacyclic code \(\mathcal {C}\) over \(\mathbb {F}_{q^2}\) of length n is an ideal in \(\frac{\mathbb {F}_{q^2}[x]}{\langle x^{n}-\lambda \rangle }\). Note that \(\frac{\mathbb {F}_{q^2}[x]}{\langle x^{n}-\lambda \rangle }\) is a principal ideal ring. So, there is a monic divisor g(x) of \(x^{n}-\lambda \) in \(\mathbb {F}_{q^2}[x]\) such that \(\mathcal {C}=\langle g(x)\rangle \). The polynomial g(x) is called the generator polynomial and the dimension of \(\mathcal {C}\) is \(n-\deg (g(x))\).

Let m be the multiplicative order of \(q^2\) modulo rn. Then \(r n\mid (q^{2m}-1)\), and so \(n\mid (q^{2m}-1)\). Let \(\beta \) be a primitive rn-th root of unity in \(\mathbb {F}_{q^{2m}}\) and \(\xi =\beta ^{r }\in \mathbb {F}_{q^{2m}}\). Then \(\xi \) is a primitive n-th root of unity. Thus, \(\beta \xi ^{i}=\beta ^{1+r i}\), \(0\le i\le n-1\), are the roots of \(x^{n}-\lambda \). Denote \(\Gamma _{r n}=\{1+r i\mid 0\le i\le n-1\}\). The set

$$\begin{aligned}T=\{i\in \Gamma _{r n}\mid g(\beta ^{i})=0\} \end{aligned}$$

is called the defining set of \(\mathcal {C}\). The \(q^2\)-cyclotomic coset of i modulo rn is given by

$$\begin{aligned} C_{i}= \{iq^{2j}(\bmod ~r n)\mid j=0,1,\ldots ,m_{i}-1\}, \end{aligned}$$

where \(m_{i}\) is the smallest positive integer l such that \(iq^{2l}\equiv i(\bmod ~r n)\). Then, \(M_{s{}}(x)=\prod _{j\in C_{s}}(x-\beta ^{j})\) must be in \(\mathbb {F}_{q^2}[x]\) and is called the minimal polynomial of \(\beta ^{s}\) over \(\mathbb {F}_{q^2}\). If \(r n-qi\in C_i\), then \(C_i\) is skew symmetric, otherwise skew asymmetric. The skew asymmetric cosets \(C_i\) and \(C_{-qi}=C_{r n-qi}\) come in pair, and we denote such skew asymmetric pair as \((C_i,C_{-qi})\).

Assume that \(r\mid (q+1)\). Then the Hermitian dual codes of \(\lambda \)-constacyclic codes over \(\mathbb {F}_{q^2}\) are still \(\lambda \)-constacyclic. A \(\lambda \)-constacyclic code \(\mathcal {C}\) of length n over \(\mathbb {F}_{q^2}\) is a constacyclic BCH code with designed distance \(\delta \) (\(\delta \ge 2\)) if, for some \(b=1+r i\), its generator polynomial is

$$\begin{aligned} g(x)=\text {lcm}\left\{ M_b(x),M_{b+r}(x),\ldots ,M_{b+r(\delta -2)}(x)\right\} . \end{aligned}$$

For a constacyclic code, the minimum distance has the following bound.

Lemma 1

(BCH bound for constacyclic codes) [36] Let \(\mathcal {C}\) be a \(\lambda \)-constacyclic code over \(\mathbb {F}_{q^2}\) of length n. Let \(\text {ord}(\lambda )=r\) and \(\beta \) be a primitive rn-th root of unity. If the generator polynomial g(x) of  \(\mathcal {C}\) has the elements \(\{\beta ^{1+r i}\mid 0\le i\le \delta -2\}\) as the roots, then the minimum distance of \(\mathcal {C}\) is not less than \(\delta \).

Definition 1

[19] Let \(\lambda \in \mathbb {F}_{q^2}\) be a primitive r-th root of unity and \(r\mid (q+1)\). Let \(\mathcal {C}\) be a \(\lambda \)-constacyclic code over \(\mathbb {F}_{q^2}\) of length n with defining set T. Denote \(T_{ss}=-qT\cap T\) and \(T_{sas}=T\setminus T_{ss}\), where \(-qT=\{rn-qi\mid i\in T\}\). We call \(T=T_{ss}\cup T_{sas}\) is a decomposition of the defining set of \(\mathcal {C}\).

According to Definition 1, Liu et al. [24] gave the following lemma to calculate the number of needed ebits.

Lemma 2

[24] Let \(\mathcal {C}\) be a \(\lambda \)-constacyclic code over \(\mathbb {F}_{q^2}\) of length n with defining set T. Suppose that \(T=T_{ss}\cup T_{sas}\) is the decomposition of T. If \(\mathcal {C}\) has parameters \([n,n-|T|,d]\), then there is an \([[n,n-2|T| +|T_{ss}|,d;|T_{ss}|]]_{q}\) EAQEC code.

Throughout this paper, denote by [uv] a positive integers set, whose elements are not less than u and not bigger than v. Assume that \(u\equiv 1(\bmod ~r)\). Denote \([u,v]_r\subseteq [u,v]\) and \(s\equiv 1(\bmod ~r)\) with \(s\in [u,v]_r\). The following lemma is useful in the sequel.

Lemma 3

[24] Let r be a positive divisor of \(q+1\) and \(n=\frac{q^2-1}{r}\). For a given integer \(i_2\in \Gamma _{rn}\), \(i_2\) can be denoted by \(i_2=\alpha q-\beta \) for two proper integers \(1\le \alpha ,\beta \le q\). Then, there is an integer \(i_1\in \Gamma _{rn}\) such that \((C_{i_1},C_{i_2})\) is a skew asymmetric pair if and only if \(i_1=\beta q-\alpha .\)

3 EAQEC Codes with Large Minimum Distance

Let q be a prime power, and r be a positive divisor of \(q+1\). We take \(n=\frac{q^2-1}{r}\) and \(a=\frac{q+1}{r}\). In this section, we will construct new \([[n,n-2d+c+2,d;c]]_q\) EAQEC codes with \(1\le c\le 6r-4\) and \(\frac{q+3-a}{2}\le d\le \frac{5q-3}{2}\).

Lemma 4

Let r be an odd integer with \(r\mid (q+1)\), and let \(s_1\ge s_2>0\) be integers with \(s_1,s_2 \in \Gamma _{r n}\). Then \(C_{s_1}=-qC_{s_2}\) if and only if \(s_1\) and \(s_2\) satisfy one of the following forms:

when l is odd,

$$\begin{aligned} \left\{ \begin{array}{l} s_1=(\frac{rl-1}{2}+t)q-(\frac{rl-1}{2}-t),\\ s_2=(\frac{rl-1}{2}-t)q-(\frac{rl-1}{2}+t),\\ \end{array} \right. \end{aligned}$$
(1)

and when l is even,

$$\begin{aligned} \left\{ \begin{array}{l} s_1=(\frac{rl}{2}+t)q-(\frac{rl}{2}-t-1),\\ s_2=(\frac{rl}{2}-t-1)q-(\frac{rl}{2}+t),\\ \end{array} \right. \end{aligned}$$
(2)

where \(0\le t\le \lfloor \frac{rl-1}{2} \rfloor -1\) and \(1\le l\le 2a-1.\)

Proof

If \(C_{s_1}=-qC_{s_2}\), then \(s_1+qs_2\equiv 0(\bmod ~rn)\). Thus, \(s_1+s_2\equiv 0(\bmod ~q-1)\) and \(s_1-s_2\equiv 0(\bmod ~q+1)\). Then there are integers \(l_1,l_2\) such that

$$\begin{aligned} s_1+s_2=l_1(q-1) \ and \ s_1-s_2=l_2(q+1). \end{aligned}$$
(3)

Since \(s_1\equiv s_2 \equiv 1 (\bmod ~r)\) and \(q\equiv -1(\bmod ~r)\), then \( -2l_1\equiv l_1(q-1)=s_1+s_2\equiv 2(\bmod ~r)\). Then \(l_1\equiv -1(\bmod ~r)\) since r is odd. Thus there is an integer l such that \(l_1=rl-1.\) By (3), we get

$$\begin{aligned} {\left\{ \begin{array}{ll} s_1=\frac{rl-1+l_2}{2}q-\frac{rl-1-l_2}{2},\\ s_2=\frac{rl-1-l_2}{2}q-\frac{rl-1+l_2}{2}. \end{array}\right. } \end{aligned}$$

Since \(s_1,s_2\) are positive integers and r is odd, then \(l, l_2\) have different parities. Let \(t=\lfloor \frac{l_2}{2}\rfloor \). Based on the parity of l, we can get (1) and (2). From \(s_1\ge s_2\ge 1\) and \(1<s_1<q^2-1\), we have \(0\le t\le \lfloor \frac{rl-1}{2} \rfloor -1\) and \(1\le l\le 2a-1.\)

If \(s_1,s_2\) satisfy (1) and (2), then one can get \(C_{s_1}=-qC_{s_2}\) easily. This completes the proof.\(\square \)

Lemma 4 shows when r is odd, \(C_s\) is skew symmetric if and only if \(t=0\) and l is odd; if and only if \((q-1)\mid s\). By Lemmas 3 and 4, if \(s_1>s_2\) and \((C_{s_1},C_{s_2})\) is a skew asymmetric pair, \(s_2\) can be determined by \(s_1\) immediately. To be specific, set \(i_1=\frac{rl-1+l_2}{2}\) and \(i_2=\frac{rl-1-l_2}{2}\). If \(s_1=i_1q-i_2\), then \(s_2=i_2q-i_1\). Thus, we only give the value of \(s_1\) in the following discussions.

Lemma 5

Let \(r\ge 5\) be an odd divisor of \(q+1\) and \(a=\frac{q+1}{r}\ge 2\). Let \(\mathcal {C}\) be a \(\lambda \)-constacyclic code over \(\mathbb {F}_{q^2}\) of length n with defining set \(T=\bigcup _{i=0}^{d-2}C_{1+ri}\), where \(2\le d\le \frac{5q-3-a}{2}\). Let \(T=T{ss}\cup T{sas}\). For a fixed integer t with \(0\le t\le \frac{r-5}{2}\),

$$\begin{aligned} | T_{ss}| =\left\{ \begin{array}{lll} 1+2t, &{} { ~~\frac{q+3-a}{2}+at\le d\le \frac{q+1+a}{2}+at},\\ r-2, &{} { ~~q+2-2a\le d\le q},\\ r+2t, &{} { ~~q+1+at\le d\le q+a(t+1) },\\ 2r-3, &{} { ~~\frac{3}{2}(q+1-a)\le d\le \frac{3q-1-a}{2}},\\ 2r+4t, &{} {~~\frac{3q+3-a}{2}+at\le d\le \frac{3q-1+a}{2}+at \text { and } 0\le t\le \frac{r-3}{2}},\\ 4r-4, &{} {~~2q+1-a\le d\le 2q-1},\\ 4r+4t, &{} {~~2q+1+at\le d\le 2q-1+a(t+1) },\\ 6r-6, &{} {~~\frac{5q+3-3a}{2}\le d\le \frac{5q-3-a}{2},a\ge 3}. \end{array} \right. \end{aligned}$$
(4)

Proof

If \(0\le i\le \frac{5q-3-a}{2}-2\), then \(1\le 1+ri\le \frac{5r-1}{2}q-\frac{7r-1}{2}\). Denote the set \(L=\big [1,\frac{5r-1}{2}q-\frac{7r-1}{2}\big ]_r\). By Lemma 4, we can get the skew symmetric cyclotomic cosets \(C_s\) and skew asymmetric pairs \((C_{s_1},C_{s_2})\) satisfying \(s_1>s_2\) in L are contained in the following set

$$\begin{aligned} \Omega =\left\{ s_1,s_2: s_1, s_2 \,\text {satisfy}\,\, (1)~\text {or}\,\, (2), \text {for}~1\le l\le 4 \text { and } 0\le t\le \bigg \lfloor \frac{rl-1}{2}\bigg \rfloor -1\right\} . \end{aligned}$$

Denote the set \(\Omega \) by \(S_{l}\) when \(1\le l\le 4\). Then

$$\begin{aligned} S_1=\left\{ s_1=\left( \frac{r-1}{2}+t\right) q-\left( \frac{r-1}{2}-t\right) : 0\le t\le \frac{r-3}{2}\right\} \cup \left\{ s_2: 0\le t\le \frac{r-3}{2}\right\} . \end{aligned}$$

Assume that

$$\begin{aligned} S_{21}=\left\{ s_1=(r+t)q-(r-t-1): 0\le t\le \frac{r-3}{2} \right\} \cup \left\{ s_2: 0\le t\le \frac{r-3}{2} \right\} \end{aligned}$$

and

$$\begin{aligned} S_{22}=\left\{ s_1=\left( \frac{3r-1}{2}+t\right) q-\left( \frac{r-1}{2}+t\right) : 0\le t\le \frac{r-3}{2}\right\} \cup \left\{ s_2: 0\le t\le \frac{r-3}{2}\right\} . \end{aligned}$$

Then

$$\begin{aligned} S_2=\left\{ s_1=(r+t)q-(r-t-1): 0\le t\le r-2 \right\} \cup \left\{ s_2: 0\le t\le r-2 \right\} =S_{21}\cup S_{22}. \end{aligned}$$

Assume that

$$\begin{aligned} S_{31}=\left\{ s_1=\left( \frac{3r-1}{2}+t\right) q-\left( \frac{3r-1}{2}-t\right) : 0\le t\le \frac{r-3}{2} \right\} \cup \left\{ s_2: 0\le t\le \frac{r-3}{2} \right\} , \end{aligned}$$
$$\begin{aligned} S_{32}=\{(2r-1)q-r,rq-(2r-1)\}, \end{aligned}$$
$$\begin{aligned} S_{33}=\left\{ s_1=(2r+t)q-(r-t-1): 0\le t\le \frac{r-3}{2} \right\} \cup \left\{ s_2: 0\le t\le \frac{r-3}{2} \right\} , \end{aligned}$$

and

$$\begin{aligned} S_{34}=\left\{ s_1=\left( \frac{5r-1}{2}+t\right) q-\left( \frac{r-1}{2}-t\right) : 0\le t\le \frac{r-3}{2} \right\} \cup \left\{ s_2: 0\le t\le \frac{r-3}{2} \right\} . \end{aligned}$$

Then

$$\begin{aligned}&S_3&=\!\left\{ s_1=\!\left( \frac{3r\!-1}{2}\!+t\right) q\!-\left( \frac{3r-1}{2}\!-t\right) :0\!\le t\!\le \frac{3r-3}{2}\right\} \cup \left\{ s_2:0\!\le t\le \! \frac{3r-3}{2}\right\} \\{} & {} =\bigcup _{i=1}^{4}S_{3i}. \end{aligned}$$

Assume that

$$\begin{aligned} S_{41}=\left\{ s_1=(2r+t)q-(2r-t-1): 0\le t\le \frac{r-3}{2}\right\} \cup \left\{ s_2: 0\le t\le \frac{r-3}{2}\right\} , \end{aligned}$$

then

$$\begin{aligned} S_4\!=\!S_{41}\cup \left\{ s_1\!=(2r\!+\!t)q\!-(2r\!-t\!-1): \frac{r-1}{2}\!\le t\le \! 2r\!-\!2\right\} \cup \left\{ s_2 : \frac{r-1}{2}\!\le \! t\le \! 2r\!-\!2\right\} . \end{aligned}$$

In fact, we can get that the skew symmetric cyclotomic cosets \(C_{s}\) and skew asymmetric pairs \((C_{s_1},C_{s_2})\) satisfying \(s_1>s_2\) in L form the set \(S=S_1\cup S_2\cup S_{31}\cup S_{32}\cup S_{33}\cup S_{41}\).

For the sake of expressing clearly, let \(T_i\) and \(T_{ssi}\) substitute for the defining set T of \(\mathcal {C}\) and \(T_{ss}\) in the (i)-th case respectively, where \(1\le i\le 8\). Thus, in order to determine \(T_{ssi}\), we need to discuss \(T_i\cap S.\)

(1) For a fixed integer t with \(0\le t\le \frac{r-5}{2}\), assume that

$$\begin{aligned} T_{10}=\left[ 1, 1+r\left( \frac{q-1-a}{2}+at\right) \right] _r= \left[ 1,\left( \frac{r-1}{2}+t\right) q-\left( \frac{r-1}{2}-t\right) \right] _r, \end{aligned}$$

and

$$\begin{aligned} T_{11}=\left[ 1,1+r\left( \frac{q-3+a}{2}+at\right) \right] _r=\left[ 1,\left( \frac{r+1}{2}+t\right) q-\left( \frac{3r-1}{2}-t-1\right) \right] _r. \end{aligned}$$

If \(\mathcal {C}\) is a \(\lambda \)-constacyclic code with defining set \(T_1=\bigcup _{i=0}^{d-2}C_{1+ri}\), where \(\frac{q+3-a}{2}+at\le d\le \frac{q+1+a}{2}+at\), then \(T_{10}\subseteq T_{1}\subseteq T_{11}\) and \((T_{11}\setminus T_{10})\cap S=\emptyset \). Thus,

$$\begin{aligned}&T_{ss1}&=-qT_1\cap T_1=-qT_{10}\cap T_{10}\\{} & {} =\left\{ s_1=\left( \frac{r-1}{2}+t'\right) q-\left( \frac{r-1}{2}-t'\right) : 0\le t'\le t \right\} \cup \left\{ s_2: 0\le t'\le t \right\} . \end{aligned}$$

Thus, \(| T_{ss1}|=1+2t.\)

(2) Assume that

$$\begin{aligned} T_{20}=\left[ 1,1+r(q-2a)\right] _r=\left[ 1,(r-2)q-1\right] _r, \end{aligned}$$

and

$$\begin{aligned} T_{21}=[1,1+r(q-2)]_r=[1,rq-2r+1]_r \end{aligned}$$

If \(\mathcal {C}\) is a \(\lambda \)-constacyclic code with defining set \(T_2=\bigcup _{i=0}^{d-2}C_{1+ri}\), where \(q+2-2a\le d\le q\), then \(T_{20}\subseteq T_2\subseteq T_{21}\) and \((T_{21}\setminus T_{20})\cap S=\emptyset \). Thus, we can get \(T_{ss2}=-qT_2\cap T_2= -qT_{20}\cap T_{20}=S_1\). Thus, \(| T_{ss2}|=r-2.\)

(3) For a fixed integer t with \(0\le t\le \frac{r-5}{2}\), assume that

$$\begin{aligned} T_{30}=\left[ 1, 1+r(q-1+at)\right] _r=\left[ 1,(r+t)q-r+t+1\right] _r, \end{aligned}$$

and

$$\begin{aligned} T_{31}=\left[ 1,1+r(q+a(t+1)-2)\right] _r=\left[ 1, (r+t+1)q-2r+t+2\right] _r. \end{aligned}$$

If \(\mathcal {C}\) is a \(\lambda \)-constacyclic code with defining set \(T_3=\bigcup _{i=0}^{d-2}C_{1+ri}\), where \(q+1+at\le d\le q+a(t+1)\), then \(T_{30}\subseteq T_3\subseteq T_{31}\). Notice that \((T_{31}\setminus T_{30})\cap S=\emptyset \). Thus, we have

$$\begin{aligned}&T_{ss3}&=-qT_3\cap T_3= -qT_{30}\cap T_{30}\\{} & {} =T_{ss2}\cup \left\{ s_1=(r+t')q-(r-t'-1): 0\le t'\le t \right\} \cup \left\{ s_2: 0\le t'\le t \right\} . \end{aligned}$$

Thus, \(| T_{ss3}|=r-2+2(1+t)=r+2t.\)

(4) Assume that

$$\begin{aligned} T_{40}=\left[ 1,1+r\left( \frac{3}{2}(q+1-a)-2\right) \right] _r=\left[ 1,\frac{3(r-1)}{2}q-\frac{r+1}{2}\right] _r, \end{aligned}$$

and

$$\begin{aligned} T_{41}=\left[ 1,1+r\left( \frac{3q-1-a}{2}-2\right) \right] _r=\left[ 1, \frac{3r-1}{2}q-\frac{5r-1}{2}\right] _r. \end{aligned}$$

If \(\mathcal {C}\) is a \(\lambda \)-constacyclic code with defining set \(T_4=\bigcup _{i=0}^{d-2}C_{1+ri}\), where \(\frac{3}{2}(q+1-a)\le d\le \frac{3q-1-a}{2}\), then \(T_{40}\subseteq T_4\subseteq T_{41}\) and \((T_{41}\setminus T_{40})\cap S=\emptyset \). Thus,

$$\begin{aligned} T_{ss4}=-qT_4\cap T_4=-qT_{40}\cap T_{40}=T_{ss2}\cup S_{21}. \end{aligned}$$

Thus, \(| T_{ss4}|=r-2+2\cdot \frac{r-1}{2}=2r-3.\)

(5) For a fixed integer t with \(0\le t\le \frac{r-3}{2}\), assume that

$$\begin{aligned} T_{50}=\left[ 1,1+r\left( \frac{3q+3-a}{2}+at-2\right) \right] _r=\left[ 1,\left( \frac{3r-1}{2}+t\right) q-\left( \frac{r-1}{2}-t\right) \right] _r, \end{aligned}$$

and

$$\begin{aligned} T_{51}=\left[ 1,1+r\left( \frac{3q-1+a}{2}+at-2\right) \right] _r=\left[ 1, \left( \frac{3r+1}{2}+t\right) q-\left( \frac{5r-3}{2}-t\right) \right] _r. \end{aligned}$$

If \(\mathcal {C}\) is a \(\lambda \)-constacyclic code with defining set \(T_5=\bigcup _{i=0}^{d-2}C_{1+ri}\), where \(\frac{3q+3-a}{2}+at\le d\le \frac{3q-1+a}{2}+at\), then \(T_{50}\subseteq T_5\subseteq T_{51}\) and \((T_{51}\setminus T_{50})\cap S=\emptyset \). Let \(S_{22}'=\left\{ s_1=(\frac{3r-1}{2}+t')q-(\frac{r-1}{2}-t'): 0\le t'\le t\right\} \cup \left\{ s_2: 0\le t'\le t\right\} \) and \(S_{31}'=\left\{ s_1=(\frac{3r-1}{2}+t')q-(\frac{3r-1}{2}-t'): 0\le t'\le t\right\} \cup \left\{ s_2: 0\le t'\le t\right\} \). Then \(S_{22}'\subseteq S_{22} \) and \(S_{31}'\subseteq S_{31}\). Hence,

$$\begin{aligned}&T_{ss5}&=-qT_5\cap T_5=T_{ss2}\cup S_{22}'\cup S_{31}'. \end{aligned}$$

Thus, \(| T_{ss5}|=2r-3+2(t+1)+1+2t=2r+4t.\)

(6) Assume that

$$\begin{aligned} T_{60}=\left[ 1,1+r(2q-1-a)\right] _r=\left[ 1, (2r-1)q-r\right] _r, \end{aligned}$$

and

$$\begin{aligned} T_{61}=\left[ 1,1+r(2q-3)\right] _r=\left[ 1, (2r-1)q-r\right] _r. \end{aligned}$$

If \(\mathcal {C}\) is a \(\lambda \)-constacyclic code with defining set \(T_6=\bigcup _{i=0}^{d-2}C_{1+ri}\), where \(2q+1-a\le d\le 2q-1\), then \(T_{60}\subseteq T_6\subseteq T_{61}\) and \((T_{61}\setminus T_{60})\cap S=\emptyset \). This gives that

$$\begin{aligned} T_{ss6}=-qT_{6}\cap T_{6}=T_{ss4}\cup S_{22}\cup S_{31}\cup S_{32}. \end{aligned}$$

Thus, \(| T_{ss6}|=2r-3+2\frac{r-1}{2}+1+2\frac{r-3}{2}+2=4r-4.\)

(7) For a fixed integer t with \(0\le t\le \frac{r-5}{2}\), assume that

$$\begin{aligned} T_{70}=\left[ 1,1+r(2q-1+at) \right] _r=\big [1,(2r+t)q-r+t+1\big ]_r \end{aligned}$$

and

$$\begin{aligned} T_{71}=\left[ 1, 1+r( 2q-3+a(t+1))\right] _r=\left[ 1,(2r+t+1)q-3r+t+2\right] _r. \end{aligned}$$

If \(\mathcal {C}\) is a \(\lambda \)-constacyclic code with defining set \(T_{7}=\bigcup _{i=0}^{d-2}C_{1+ri}\), where \(2q+1+at\le d\le 2q-1+a(t+1)\), then \(T_{70}\subseteq T_{7}\subseteq T_{71}\) and \((T_{71}\setminus T_{70})\cap S=\emptyset \). Let \(S_{32}'=\left\{ s_1=(2r+t')q-(r-t'-1): 0\le t'\le t \right\} \cup \left\{ s_2: 0\le t'\le t \right\} \) and \(S_{41}'=\left\{ s_1=(2r+t')q-(2r-t'-1): 0\le t'\le t\right\} \cup \left\{ s_2: 0\le t'\le t\right\} \), then \(S_{32}' \subseteq S_{32}\) and \(S_{41}'\subseteq S_{41}\). By Lemma 4, we know

$$\begin{aligned}&T_{ss7}&=-qT_7\cap T_7=T_{ss3}\cup S_{32}'\cup S_{41}'. \end{aligned}$$

Thus, \(| T_{ss7}|=4r-4+4(t+1)=4r+4t.\)

(8) Assume that \(T_{80}=\left[ 1,1+r\frac{5q-1-3a}{2}\right] _r=\left[ 1,\frac{5r-3}{2}q-\frac{r+1}{2}\right] _r\). If \(\mathcal {C}\) is a \(\lambda \)-constacyclic code with defining set \(T_{8}=\bigcup _{i=0}^{d-2}C_{1+ri}\), where \(\frac{5q+3-3a}{2}\le d\le \frac{5q-3-a}{2} \text { and }a\ge 3\), then \(T_{80}\subseteq T_8\subseteq L\) and \(T_{ss8}=-qT_{8}\cap T_{8}=T_{ss6}\cup S_{33}\cup S_{41}.\) Thus, \(|T_{ss8}|=4r-4+4\cdot \frac{r-1}{2}=6r-6.\) This completes the proof.\(\square \)

By Lemmas 2 and 5, new EAQEC codes of length n with flexible parameters can be constructed from \(\lambda \)-constacyclic codes over \(\mathbb {F}_{q^2}\) of length n, as below.

Theorem 2

Let \(r\ge 5\) be an odd divisor of \(q+1\) and \(a=\frac{q+1}{r}\ge 2\). Then for a fixed integer t with \(0\le t\le \frac{r-5}{2}\), there are EAQEC codes with the following parameters

  1. (1)

    \([[n,n-2d+2t+3,d;1+2t]]_q\), where \(\frac{q+3-a}{2}+at\le d\le \frac{q+1+a}{2}+at\);

  2. (2)

    \([[n,n-2d+r,d;r-2]]_q\), where \(q+2-2a\le d\le q\);

  3. (3)

    \([[n,n-2d+r+2+2t,d;r+2t]]_q\), where \(q+1+at\le d\le q+a(t+1)\);

  4. (4)

    \([[n,n-2d+2r-1,d;2r-3]]_q\), where \(\frac{3}{2}(q+1-a)\le d\le \frac{3q-1-a}{2}\);

  5. (5)

    \([[n,n-2d+2r+2+4t,d;2r+4t]]_q\), where \(\frac{3q+3-a}{2}+at\le d\le \frac{3q-1+a}{2}+at\) and \(~~~~~~0\le t\le \frac{r-3}{2}\);

  6. (6)

    \([[n,n-2d+4r-2,d;4r-4]]_q\), where \(2q+1-a\le d\le 2q-1\);

  7. (7)

    \([[n,n-2d+4r+2+4t,d;4r+4t]]_q\), where \(2q+1+at\le d\le 2q-1+a(t+1)\);

  8. (8)

    \([[n,n-2d+6r-4,d;6r-6]]_q\), where \(\frac{5q+3-3a}{2}\le d\le \frac{5q-3-a}{2}\), \(a\ge 3\).

Remark 1

In fact, for \(r=3\), Lemma 5 and Theorem 2 hold true if the cases (2), (4), (6) and (8) are only considered.

Lemma 6

Let r be an even divisor of \(q+1\). Let \(s_1\ge s_2>0\) be integers with \(s_1,s_2 \in \Gamma _{r n}\). Then \(C_{s_1}=-qC_{s_2}\) if and only if

$$\begin{aligned} \left\{ \begin{array}{l} s_1=(\frac{rl}{2}+t)q-(\frac{rl}{2}-t-1),\\ s_2=(\frac{rl}{2}-t-1)q-(\frac{rl}{2}+t),\\ \end{array} \right. \end{aligned}$$
(5)

where lt are integers with \(0\le t\le \frac{rl}{2}-2\) and \(1\le l\le 2a-1.\)

Proof

Similar to Lemma 4, we can get \( -2l_1\equiv l_1(q-1)=s_1+s_2\equiv 2(\bmod ~r)\). Then \(l_1\equiv -1(\bmod ~\frac{r}{2})\). So there is an integer \(l'\) such that \(l_1=\frac{r}{2}l'-1.\) Then we can get

$$\begin{aligned} {\left\{ \begin{array}{ll} s_1=(\frac{\frac{r}{2}l'-1+l_2}{2})q-(\frac{\frac{r}{2}l'-1-l_2}{2}),\\ s_2=(\frac{\frac{r}{2}l'-1-l_2}{2})q-(\frac{\frac{r}{2}l'-1+l_2}{2}). \end{array}\right. } \end{aligned}$$

Since \(q\equiv -1(\bmod ~r)\), then \(s_1\equiv -\frac{r}{2}l'+1(\bmod ~ r)\) and \(s_2\equiv -\frac{r}{2}l'+1(\bmod ~ r)\). It follows that \(l'\) is even due to \(s_1\equiv s_2\equiv 1(\bmod ~r)\). Assume that \(l'=2l\) and \(t=\frac{l_2-1}{2}\), then the system (5) can be derived. Similar to Lemma 4 the ranges of t and l can be obtained. And the sufficiency can be verified easily. This completes the proof.\(\square \)

In fact, Lemma 6 gives a necessary and sufficient condition of two \(q^2\)-cyclotomic cosets modulo rn to be a skew asymmetric pair when r is even. And Lemma 6 shows when r is even, it is impossible that \(C_s\) is skew symmetric. If \(s_1>s_2\) and \((C_{s_1},C_{s_2})\) is a skew asymmetric pair, by Lemmas 3 and 6, \(s_2\) can be determined by \(s_1\) immediately. To be specific, set \(i_1=\frac{rl}{2}+t\) and \(i_2=\frac{rl}{2}-t-1\). If \(s_1=i_1q-i_2\), then \(s_2=i_2q-i_1\). Thus, we only give the value of \(s_1\) in the following discussions.

Lemma 7

Let \(r\ge 6\) be an even divisor of \(q+1\) and \(a=\frac{q+1}{r}>2\). Let \(\mathcal {C}\) be a \(\lambda \)-constacyclic code over \(\mathbb {F}_{q^2}\) of length \(n=\frac{q^2-1}{r}\) with defining set \(T=\bigcup _{i=0}^{d-2}C_{1+ri}\), where \(2\le d\le \frac{5q-3}{2}\). Let \(T=T_{ss}\cup T_{sas}\). For a fixed integer t with \(0\le t\le \frac{r}{2}-2\),

$$\begin{aligned} | T_{ss}| =\left\{ \begin{array}{lll} 2(t+1), &{} { ~~\frac{q+3}{2}+at\le d\le \frac{q+1}{2}+a(t+1)} \text { and }t\le \frac{r}{2}-3,\\ r-2, &{} { ~~q+2-2a\le d\le q},\\ r+2t, &{} { ~~q+1+at\le d\le q+a(t+1) },\\ 2r-2, &{} { ~~\frac{3}{2}(q+1)-a\le d\le \frac{3q-1}{2}},\\ 2r+4t+2, &{} {~~\frac{3q+3}{2}+at\le d\le \frac{3q-1}{2}+a(t+1)},\\ \ 4r-4, &{} {~~2q+1-a\le d\le 2q-1},\\ 4r+4t, &{} {~~2q+1+at\le d\le 2q-1+a(t+1)},\\ 6r-4, &{} {~~\frac{5q+3}{2}-a\le d\le \frac{5q-3}{2}, a\ge 3}. \end{array} \right. \end{aligned}$$
(6)

Proof

If \(0\le i\le \frac{5q-3}{2}-2\), then \(1\le 1+ri\le \frac{5r}{2}q-\frac{7r}{2}+1\). Denote the set \(M=\big [1,\frac{5r}{2}q-\frac{7r}{2}+1\big ]_r\). By Lemma 6, we know there do not exist skew symmetric cyclotomic cosets in M and we can get the skew asymmetric pairs \((C_{s_1},C_{s_2})\) satisfying \(s_1>s_2\) in M are contained in the following set

$$\begin{aligned} \Lambda =\left\{ s_1,s_2: s_1, s_2~\text {satisfy the system}~(5)~\text {with}~1\le l\le 4 \text { and } 0\le t\le \frac{rl}{2} -2\right\} . \end{aligned}$$

Denote the set \(\Lambda \) by \(S_{l}\) when \(1\le l\le 4\). Then

$$\begin{aligned} S_1=\left\{ s_1=\left( \frac{r}{2}+t\right) q-\left( \frac{r}{2}-t-1\right) : 0\le t\le \frac{r}{2}-2\right\} \cup \left\{ s_2: 0\le t\le \frac{r}{2}-2\right\} . \end{aligned}$$

Assume that

$$\begin{aligned} S_{21}=\left\{ s_1=(r+t)q-(r-t-1): 0\le t\le \frac{r}{2}-2 \right\} \cup \left\{ s_2: 0\le t\le \frac{r}{2}-2\right\} , \end{aligned}$$

and

$$\begin{aligned} S_{22}=\left\{ s_1=\left( \frac{3r}{2}+t\right) q-\left( \frac{r}{2}+t-1\right) : 0\le t\le \frac{r}{2}-2\right\} \cup \left\{ s_2: 0\le t\le \frac{r}{2}-2\right\} . \end{aligned}$$

Then

$$\begin{aligned}&S_2&=\left\{ s_1=(r+t)q-(r-t-1): 0\le t\le r-2 \right\} \cup \left\{ s_2: 0\le t\le r-2\right\} \\ {}{} & {} =S_{21}\cup S_{22}. \end{aligned}$$

Assume that

$$\begin{aligned} S_{31}=\left\{ s_1=\left( \frac{3r}{2}+t\right) q-\left( \frac{3r}{2}-t-1\right) : 0\le t\le \frac{r}{2}-2 \right\} \cup \left\{ s_2: 0\le t\le \frac{r}{2}-2\right\} , \end{aligned}$$
$$\begin{aligned} S_{32}=\left\{ (2r-1)q-r,rq-(2r-1)\right\} , \end{aligned}$$
$$\begin{aligned} S_{33}=\left\{ s_1=(2r+t)q-(r-t-1): 0\le t\le \frac{r}{2}-2 \right\} \cup \left\{ s_2: 0\le t\le \frac{r}{2}-2 \right\} \end{aligned}$$
$$\begin{aligned} S_{34}=\left\{ s_1=\left( \frac{5r}{2}+t\right) q-\left( \frac{r}{2}-t-1\right) : 0\le t\le \frac{r}{2}-2 \right\} \cup \left\{ s_2: 0\le t\le \frac{r}{2}-2 \right\} . \end{aligned}$$

Then

$$\begin{aligned}&S_3&=\left\{ s_1=\left( \frac{3r}{2}+t\right) q-\left( \frac{3r}{2}-t-1\right) : 0\le t\le \frac{3r}{2}-2\right\} \cup \left\{ s_2: 0\le t\le \frac{3r}{2}-2\right\} \\ {}{} & {} =\bigcup _{i=1}^{4}S_{3i}. \end{aligned}$$

Assume that

$$\begin{aligned} S_{41}=\left\{ s_1=(2r+t)q-(2r-t-1): 0\le t\le \frac{r}{2}-2\right\} \cup \left\{ s_2: 0\le t\le \frac{r}{2}-2\right\} , \end{aligned}$$

then

$$\begin{aligned} S_4\!=\!S_{41}\cup \left\{ s_1\!=\!(2r\!+\!t)q\!-\!(2r\!-\!t-1):\frac{r}{2}\!-\!1\!\le \! t\!\le \! 2r\!-\!2\right\} \cup \left\{ s_2:\frac{r}{2}\!-\!1\!\le \! t\!\le \! 2r\!-\!2\right\} . \end{aligned}$$

In fact, we can get the skew asymmetric pairs \((C_{s_1},C_{s_2})\) satisfying \(s_1>s_2\) in \(\Lambda \) form the set \(S=S_1\cup S_2\cup S_{31}\cup S_{32}\cup S_{33}\cup S_{41}\).

Using a similar method to the proof of Lemma 5, one can derive the value of \(| T_{ss}|\) in different cases.\(\square \)

By Lemmas 2 and 7, new EAQEC codes of length \(n=\frac{q^2-1}{r}\), where r is an even divisor of \(q+1\), can be constructed from \(\lambda \)-constacyclic codes over \(\mathbb {F}_{q^2}\) of length n as follows.

Theorem 3

Let \(r\ge 6\) be an even divisor of \(q+1\) and \(a=\frac{q+1}{r}>2\). Then for a fixed integer t with \(0\le t\le \frac{r}{2}-2\), there are EAQEC codes with the following parameters

  1. (1)

    \([[n,n-2d+2t+4,d;2(t+1)]]_q\), where \(\frac{q+3}{2}+at\le d\le \frac{q+1}{2}+a(t+1)\) and \(t\le \frac{r}{2}-3\);

  2. (2)

    \([[n,n-2d+r,d;r-2]]_q\), where \(q+2-2a\le d\le q\);

  3. (3)

    \([[n,n-2d+r+2+2t,d;r+2t]]_q\), where \(q+1+at\le d\le q+a(t+1)\);

  4. (4)

    \([[n,n-2d+2r,d;2r-2]]_q\), where \(\frac{3}{2}(q+1)-a\le d\le \frac{3q-1}{2}\);

  5. (5)

    \([[n,n-2d+2r+4+4t,d;2r+4t+2]]_q\), where \(\frac{3q+3}{2}+at\le d\le \frac{3q-1}{2}+a(t+1)\);

  6. (6)

    \([[n,n-2d+4r-2,d;4r-4]]_q\), where \(2q+1-a\le d\le 2q-1\);

  7. (7)

    \([[n,n-2d+4r+2+4t,d;4r+4t]]_q\), where \(2q+1+at\le d\le 2q-1+a(t+1)\);

  8. (8)

    \([[n,n-2d+6r-2,d;6r-4]]_q\), where \(\frac{5q+3}{2}-a\le d\le \frac{5q-3}{2}\), \(a\ge 3\).

Remark 2

In fact, for \(r=4\), Lemma 7 and Theorem 3 are ture in the cases (2),(4),(6) and (8).

4 EAQMDS Codes with \(c=1\) or 2

An \([[n,k,d;c]]_q\) EAQMDS code can encode k logical qudits into n physical qudits by using c pairs of maximally entangled states, and can correct up to \(\lfloor \frac{d-1}{2}\rfloor \) quantum errors. Thus, for fixed n and k, we wish that c would be smaller and d would be larger, in order to reduce the overhead in practice. In this section, two classes of EAQMDS codes consuming one or two pairs of maximally entangled states are obtained, whose minimum distances are larger than those in Theorems 2 and 3.

Lemma 8

Let r be an even divisor of \(q+1\) and \(a=\frac{q+1}{r}>2\). Let \(\mathcal {C}\) be a \(\lambda \)-constacyclic code of length \(n=\frac{q^2-1}{r}\) with defining set

$$\begin{aligned} T=\bigcup _{i=\frac{q+1}{2}-2a}^{k}C_{1+ri}, ~where~\frac{q+1}{2}-2a\le k\le q-2. \end{aligned}$$

Assume that \(T=T_{ss}\cup T_{sas}\), then

(1) \((C_{1+r\frac{q-1}{2}},C_{1+r(\frac{q-1}{2}-\frac{q+1}{r})})\) is a skew asymmetric pair;

(2) \(\mid T_{ss}\mid =2\) if \(\frac{q-1}{2}\le k\le q-2\).

Proof

Since \(-q(1+r\frac{q-1}{2})=-q(\frac{r}{2}q-(\frac{r}{2}-1))\equiv -\frac{r}{2}+(\frac{r}{2}-1)q=1+r(\frac{q-1}{2}-\frac{q+1}{r}) (\bmod ~rn)\), then \((C_{1+r\frac{q-1}{2}},C_{1+r(\frac{q-1}{2}-\frac{q+1}{r})})\) is a skew asymmetric pair.

If \(\frac{q+1}{2}-2a\le i\le q-2\), then \((\frac{r}{2}-2)q+\frac{r}{2}-1\le 1+ri\le rq-2r+1\). Denote the set \(\Lambda =\left[ (\frac{r}{2}-2)q+\frac{r}{2}-1,rq-2r+1\right] _r\), then \(T\subseteq \Lambda \). Assume that

$$\begin{aligned} S=\left\{ s_1:s_1=\left( \frac{r}{2}+t\right) q-\left( \frac{r}{2}-t-1\right) ,~0\le t\le \frac{r}{2}-2\right\} , \end{aligned}$$

obviously, \(S\subseteq \Lambda \). By Lemma 6, we know

$$\begin{aligned} -qS=\left\{ s_2:s_2=\left( \frac{r}{2}-t-1 \right) q-\left( \frac{r}{2}+t \right) ,~0\le t\le \frac{r}{2}-2 \right\} , \end{aligned}$$

and for fixed q and t, \(s_1>s_2\). If \(t=0\), then \(s_1=1+r\frac{q-1}{2}\) and \(s_2=1+r(\frac{q-1}{2}-\frac{q+1}{r})\in \Lambda \), and \((C_{s_1},C_{s_2})\) forms a skew asymmetric pair in \(\Lambda \). Now we consider the case \(1\le t\le \frac{r}{2}-2\). When \(t=1\), \(s_2\) is the maximum one in \(-qS\). And the value is \((\frac{r}{2}-2)q-(\frac{r}{2}+1)\), which is smaller than the smallest value \((\frac{r}{2}-2)q+\frac{r}{2}-1\) in \(\Lambda \). Hence, \(-qS\cap T=\big \{ 1+r(\frac{q-1}{2}-\frac{q+1}{r})\big \}\) if \(\frac{q-1}{2}\le k\le q-2\).

Let

$$\begin{aligned} M=\left[ \left( \frac{r}{2}-1\right) q-\left( q-\frac{r}{2}+1\right) ,\left( \frac{r}{2}-1\right) q-\frac{3r}{2}\right] _r, \end{aligned}$$
$$\begin{aligned} L_t=\left[ \left( \frac{r}{2}+t\right) q-\left( q-\frac{r}{2}-t\right) ,\left( \frac{r}{2}+t\right) q-\left( \frac{3r}{2}-t-1\right) \right] _r, \end{aligned}$$
$$\begin{aligned} N_1=\left[ (r-2)q-1+r,(r-1)q-r\right] _r~ \text {and}~N_2=\left[ rq-q,rq-(r-1)-r\right] _r, \end{aligned}$$

where \(0\le t\le \frac{r}{2}-2\). Assume that \(s_{(2,0)}=1+r(\frac{q-1}{2}-\frac{q+1}{r})\), then

$$\begin{aligned} \Lambda \setminus (S\cup \{s_{(2,0)}\})=\bigcup _{t=0}^{\frac{r}{2}-2}L_t\bigcup _{i=1}^{2} N_i\cup M \end{aligned}$$

and the intersections of \(M,~L_t,\) and \(N_i\) are empty. Next, we claim that \(-q(\Lambda \setminus (S\cup \{s_{(2,0)}\}))\cap T=\emptyset \). By Lemma 3, we can get

$$\begin{aligned} -qL_t=\left[ \left( \frac{3r}{2}-t-1\right) q-\left( \frac{r}{2}+t\right) ,\left( q-\frac{r}{2}-t\right) q-\left( \frac{r}{2}+t\right) \right] _r, \end{aligned}$$

where \(0\le t\le \frac{r-4}{2}\). When \(t=\frac{r-4}{2}\), the value of \((\frac{3r-1}{2}-t)q-(\frac{r-1}{2}+t)\) is the minimum, and it is equal to \((r+1)q-(r-2)\), which is bigger than the largest value \(rq-2r+1\) in \(\Lambda \). Thus \(-qL_t\cap T=\emptyset \). Again by Lemma 3, we have

$$\begin{aligned} -qM=\left[ \frac{3r}{2}q-\left( \frac{r}{2}-1\right) ,\left( q-\frac{r}{2}+1\right) q-\left( \frac{r}{2}-1\right) \right] _r, \end{aligned}$$
$$\begin{aligned} -qN_1=\left[ rq-(r-1),q-(r-2)\right] _r~ \text {and}~-qN_2=\left[ (2r-1)q-r,q^2-r\right] _r. \end{aligned}$$

And \(\frac{3r}{2}q-(\frac{r}{2}-1)\), \(rq-(r-1)\) and \((2r-1)q-r\) are bigger than the largest value \(rq-2r+1\) in \(\Lambda \). Hence, \(-qM\cap T=\emptyset \) and \(-qN_i\cap T=\emptyset ,~i=1,2\). Thus, \(-q(\Lambda \setminus (S\cup \{s_{(2,0)}\}))\cap T=\emptyset \), and \( T_{ss} =-qT\cap T=\left\{ 1+r\frac{q-1}{2},1+r(\frac{q-1}{2}-\frac{q+1}{r}) \right\} \) if \(\frac{q-1}{2}\le k\le q-2\). The desired result follows.\(\square \)

Theorem 4

Let r be an even divisor of \(q+1\), \(a=\frac{q+1}{r}>2\). Then there exists a q-ary \([[n,n-2d+4,d;2]]_q\) EAQMDS code, where \(2a+1\le d\le 2a+\frac{q-1}{2}\).

Proof

Let \(\lambda \in \mathbb {F}_{q^2}^*\) and \(\text {ord} (\lambda )=r\). Let \(\mathcal {C}\) be a \(\lambda \)-constacyclic code of length \(n=\frac{q^2-1}{r}\), with defining set \(T=\bigcup _{i=\frac{q+1}{2}-2a}^{k}C_{1+ri}\), where \(\frac{q+1}{2}-2a\le k\le q-2.\) Then there are \(k-\frac{q+1}{2}+2a+1\) consecutive integers in T and \(\mid T\mid =k-\frac{q+1}{2}+2a+1\) since \(\mid C_{1+ri}\mid =1\). By BCH bound for constacyclic codes, the minimum distance of \(\mathcal {C}\) is at least \(k-\frac{q+1}{2}+2a+2\). By the Singlton bound for linear codes, the parameters of \(\mathcal {C}\) is \([n, n-d+1,d].\) Using Lemmas 2 and 9, the desired results follow. \(\square \)

Lemma 9

Let r be an odd positive divisor of \(q+1\), and \(a=\frac{q+1}{r}>1\). Let \(\mathcal {C}\) be a \(\lambda \)-constacyclic code of length \(n=\frac{q^2-1}{r}\) with defining set

$$\begin{aligned} T=\bigcup _{i=\frac{r-3}{2}a}^{k}C_{1+ri}, ~where~\frac{r-3}{2}a\le k\le q-2. \end{aligned}$$

Assume that \(T=T_{ss}\cup T_{sas}\), then

(1) \(C_{1+r\frac{q-1-a}{2}}\) is skew symmetric,

(2) \(\mid T_{ss}\mid =1\) if \(\frac{q-1-a}{2}\le k\le q-2\).

Proof

Notice that \(-q(1+r\frac{q-1-a}{2})=-q(\frac{r-1}{2}(q-1))\equiv -\frac{r-1}{2}+\frac{r-1}{2}q=1+r\frac{q-1-a}{2} (\bmod ~rn)\), thus \(C_{1+r\frac{q-1-a}{2}}\) is skew symmetric.

If \(\frac{r-3}{2}a\le i\le q-2\), then \(\frac{r-3}{2}q+\frac{r-1}{2}\le 1+ri\le rq-2r+1\). Assume that \(\Omega =\big [\frac{r-3}{2}q+\frac{r-1}{2},rq-2r+1\big ]_r\), then \(T\subseteq \Omega \). Let

$$\begin{aligned} S=\left\{ s_1: s_1=\left( \frac{r-1}{2}+t\right) q-\left( \frac{r-1}{2}-t\right) ,0\le t\le \frac{r-3}{2}\right\} , \end{aligned}$$

It can be checked easily that \(S\subseteq \Omega \). By Lemma 4, we know

$$\begin{aligned} -qS=\left\{ s_2: s_2=\left( \frac{r-1}{2}-t \right) q-\left( \frac{r-1}{2}+t \right) ,0\le t\le \frac{r-3}{2}\right\} . \end{aligned}$$

For a fixed q, if \(t=0\), then \(s_1=s_2=1+r\frac{q-1-a}{2}\in \Omega \). Now we consider the case \(1\le t\le \frac{r-3}{2}\). If \(t=1\), \(s_2\) is the maximum in \(-qS\) and the value is \( \frac{r-3}{2}q-\frac{r+1}{2}\) which is smaller than the smallest value \(\frac{r-3}{2}q+\frac{r-1}{2}\) in \(\Omega \). Hence, \(-qS\cap T=\left\{ 1+r\frac{q-1-a}{2}\right\} \) if \(\frac{q-1-a}{2}\le k\le q-2\). Let the sets

$$\begin{aligned} L_t=\left[ \left( \frac{r-1}{2}+t\right) q-\left( q-\frac{r-1}{2}-t\right) ,\left( \frac{r-1}{2}+t\right) q-\left( \frac{3r-1}{2}-t\right) \right] _r, \end{aligned}$$
$$\begin{aligned} N_1=\big [(r-2)q-1+r,(r-1)q-r\big ]_r~ \text {and}~N_2=[rq-q,rq-(2r-1)]_r, \end{aligned}$$

where \(0\le t\le \frac{r-3}{2}\). Then \(\Omega \setminus S=\bigcup _{t=0}^{\frac{r-3}{2}}L_t\bigcup _{i=1}^{2} N_i\) and \(L_t\cap N_i=\emptyset \). Next, we claim that \(-q(\Omega \setminus S)\cap T=\emptyset \). By Lemma 3, we can get

$$\begin{aligned} -qL_t=\left[ \left( \frac{3r-1}{2}-t\right) q-\left( \frac{r-1}{2}+t\right) ,\left( q-\frac{r-1}{2}-t\right) q-\left( \frac{r-1}{2}+t\right) \right] _r, \end{aligned}$$

where \(0\le t\le \frac{r-3}{2}\). When \(t=\frac{r-3}{2}\), the value of \((\frac{3r-1}{2}-t)q-(\frac{r-1}{2}+t)\) is the minimum in the set \(-qL_t\), and is equal to \((r+1)q-(r-2)\), which is bigger than the largest value \(rq-2r+1\) in \(\Omega \). Thus, \(-qL_t\cap T=\emptyset \). Again by Lemma 3, we have

$$\begin{aligned} -qN_1=\big [rq-(r-1),q-(r-2)\big ]_r~ \text {and}~-qN_2=\big [(2r-1)q-r,q^2-r\big ]_r. \end{aligned}$$

Notice that \(rq-(r-1)\) and \((2r-1)q-r\) are bigger than the largest value of \(\Omega \). Thus, \(-qN_i\cap T=\emptyset ,~i=1,2\) and \(-q(\Omega \setminus S)\cap T=\emptyset \). Hence, \(\mid T_{ss}\mid =1\) if \(\frac{q-1-a}{2}\le k\le q-2\).\(\square \)

Theorem 5

Let r be an odd divisor of \(q+1\), \(a=\frac{q+1}{r}>1\). Then there exists a q-ary \([[n,n-2d+3,d;1]]_q\) EAQMDS code, where \(a+1\le d\le \frac{q-1+3a}{2}\).

Proof

Let \(\lambda \in \mathbb {F}_{q^2}^*\) and \(\text {ord} (\lambda )=r.\) Let \(\mathcal {C}\) be a \(\lambda \)-constacyclic code of length \(n=\frac{q^2-1}{r}\) with defining set \(T=\bigcup _{i=\frac{r-3}{2}a}^{k}C_{1+ri}\), where \(\frac{r-3}{2}a\le k\le q-2.\) Then there are \(k-\frac{r-3}{2}a+1\) consecutive integers in T and \(\mid T\mid =k-\frac{r-3}{2}a+1\) since \(\mid C_{1+ri}\mid =1\). By Lemma 1, the minimum distance of \(\mathcal {C}\) is not less than \(k-\frac{r-3}{2}a+2\). Then \(\mathcal {C}\) is an MDS code. Applying Lemmas 2 and 9, the desired results follow.\(\square \)

Table 1 EAQMDS codes of length \(n=\frac{q^{2}-1}{5}\) with \(5\mid (q +1)\)
Table 2 EAQMDS codes of length \(n=\frac{q^{2}-1}{6}\) with \(6\mid (q +1)\)
Table 3 EAQMDS codes of length \(n=\frac{q^{2}-1}{7}\) with \(7\mid (q +1)\)

5 Code Comparisons

In this paper, we have derived a family of EAQEC codes from constacyclic codes over \(\mathbb {F}_{q^2}\) of length \(n=\frac{q^2-1}{r}\), where r is a positive divisor of \(q+1\). Some standard quantum MDS codes with the same length have been obtained in [4, 15, 34], and their minimum distances are not greater than \(q +1\). The minimum distance of EAQEC codes in this paper is near by \(\frac{5q-3}{2}\). If \(d\le \frac{n+2}{2}\), our EAQEC codes are MDS. There are many results [8, 24, 25, 27, 30] about the EAQMDS codes of length \(\frac{q+1}{r}(q-1)\) for a certain r, our construction generalized almost known results with the same length. And our construction can produce many new EAQMDS codes with large minimum distance which are not covered in the literature.

Liu et al. [24] constructed EAQMDS codes of length \(\frac{q^2-1}{r}\) from \(\lambda \)-constacyclic codes, where \(3\le r\le 7\). For other positive divisors of \(q+1\), the EAQMDS codes in this paper are new. In addition, the minimum distances in their construction are not more than \(\frac{(r+1)(q+1)}{r} -1\). Thus, if \(\frac{(r+1)(q+1)}{r}\le d\le \min \left\{ \frac{5q-3-a}{2},\frac{n+2}{2}\right\} \) the EAQMDS codes in Theorems 2 and 3 are new.

Let q be an odd prime power. Recently, Lu et al. [25] constructed EAQMDS codes from cyclic codes of length \(\frac{q^2-1}{r}\), where \(r=3,5,7\). The upper limit of minimum distance is \(\frac{9q-6}{5}\) if \(r=5\), and \(\frac{11q-10}{7}\) if \(r=7\), which are all less than \(\frac{5q-3}{2}\). In Tables 1, 2 and 3, we compare some EAQMDS codes in this paper with these in [24, 25] when \(r=5,6\text { and }7\), respectively. It can be seen that our construction in Theorems 2 and 3 can produce more codes processing bigger minimum distance.

If q is an odd prime power and r is odd, Fan et al. [8] derived EAQMDS codes with parameters \([[\frac{q^2-1}{r},\frac{q^2-1}{r}-2d+r+2,d;r]]_q\), where \(\frac{(r-1)(q+1)}{r}+2\le d\le \frac{(r+1)(q+1)}{r}-2\). If r is even, the EAQMDS code in this paper are new. Obviously, \(\frac{5q-3}{2}>\frac{(r+1)(q+1)}{r}-2\). Thus, if \(d\le \frac{n+2}{2}\) our construction can produce much more EAQMDS codes with large minimum distance. In Table 5, we compare some EAQMDS codes from our construction with the known ones in [8, 24, 25].

Table 4 Some new EAQMDS codes with a few entanglement bits
Table 5 Some new EAQMDS codes and comparisons

In Theorems 4 and 5, we improved the minimum distance of EAQMDS codes with \(c=1\) or 2 in Theorems 2 and 3. In Table 4, we compare some EAQMDS codes which consume one or two pairs of maximally entangled states in Theorems 4 and 5 with these in Theorems 2 and 3. The minimum distance of EAQMDS codes in Theorems 4 and 5 is larger \(\frac{q+1}{r}\) than minimum distance of the standard quantum MDS codes in [34]. Let q be an odd prime power. In [27], the authors obtained EAQMDS codes with parameters \([[\frac{q^2-1}{r},\frac{q^2-1}{r}-2d+r+2,d;1]]_q\), where \(r=3,5,7 \text { and }\frac{q+1}{r}+1\le d\le \frac{(r+3)(q+1)}{2r}-1\). Our construction in Theorems 4 and 5 generalized this result. Many new EAQMDS codes could be derived from Theorem 4 if r is even, and Theorem 5 if q is even, or r is another odd divisor of \(q+1\).