4 A Random Search Algorithm for Encoding Optimiza- tion It is easy to check that Hence A complete encoding optimization procedure for a [[ n, k, d ]] standard code becomes impossi- ble when n + k becomes large. Hence we consider a random search algorithm for the encoding optimization procedure in this section. We define the weight enumerator of the set N ( S ′ ) − S ′ I as f ( x ) = ∑ n i $_{=0}$a$_{i}$ x $^{i}$, where a$_{i}$ is the number of elements of weight i in N ( S ′ ) − S ′ $_{I}$. Suppose H ′ is a simplified check matrix of the EAQEC code corresponding to S ′ . Then we define a merit function m : H ′ ↦→ R by where b = ⌊ n + $^{c}$−$^{k}$− 2 2 ⌋ is an upper bound on the minimum distance for the given parameters n, k, c . This merit function was chosen to try to maximize the number of correctable errors in the set of likely errors for a typical memoryless channel; but of course, other merit functions could be chosen. The random search algorithm for encoding optimization is as follows: 30 1) Apply Wilde’s encoding circuit algorithm to a given check matrix H$_{0}$ to obtain the en- coding operator U$_{E}$ . 2) Apply U$_{E}$ to the simplified check matrix (13) and the simplified logical matrix (16), and m ( H ′ ) = b ∑ i =1 a$_{i}$, 2 c ( n + $^{k}$−c ) ≤ 2 2 $^{ck}$N ( r, c ) ≤ ( r c ) 2 c ( n + $^{k}$−c $^{)}$. 2 c ( $^{r}$−c ) ≤ N ( r, c ) ≤ ( r c ) 2 c ( $^{r}$−c $^{)}$.