# Quantum Circuit-Width Reduction through Parameterisation and Specialisation
## 7 Applying Circuit Transformations to a Quantum Integer Divider
### Design 3: Parameterised Divider  
Figure 16 shows a top-level overview of the third design of for a quantum circuit implementation of quantum integer division. For this Design 3, the qubits represent the following:  
\[\begin{array}{rcl}|out3|out2|out1|out0\rangle&:&n\text{ qubits defining output}\\ |test\rangle&:&\text{qubit defining comparator result}\\ |q4d^{\prime}|q3d^{\prime}|q2d^{\prime}|q1d^{\prime}|q0d^{\prime}\rangle&:&(n+ 1)\text{-qubit representation of divisor}\\ &&\text{in 2's complement representation}\\ |q3i|q2i|q1i|q0i\rangle&:&n\text{-qubit representation of dividend}\\ |c\rangle&:&\text{`carry' qubit in modulo adder}\\ |qin2|qin1|qin0\rangle&:&n-1\text{ qubits used to create the 7-qubit}\\ &&\text{dividend along with }|q3i|q2i|q1i|q0i\rangle\]  
Therefore, the required number of qubits as a function of \(n\) can be written as,  
\[n+1+(n+1)+n+1+(n-1)=4n+2\]  
Figure 15: Quantum integer divider design 2: top-level overview of quantum circuit implementation of quantum integer division. Example shown for 4-qubit representation of dividend, divisor, and output. The quantum circuit implementation of \(C\) and \(Sub\) same as in Design 1.  
showing that the quantum circuit width remains the same as compared with Design 1 and Design 2. The definition of the divisor qubits in terms of 2's complement means that the comparator circuit used in Design 1 and Design 2 cannot be used. Instead, an alternative comparator circuit taking the qubits defining the divisor using 2's complement is required. One possible way to create such a comparator is shown in Figure 17, where the original circuit following the design of [PERSON] et al. [33] is modified such that the divisor qubits are transformed from 2's complement representation at input on the left-hand side of the circuit to the regular representation. At the end of the comparator step, the transformation to return to 2's complement representation for divisor qubits is performed. As can be seen from Figure 17, the additional steps introduced related to 2's complement conversions add further complexity to the circuit, and therefore making the circuit-width transformation outlined in Figures 12-14 for the original form of the comparator even more challenging to automate. This further supports the approach outlined next, where this type of reduction is circumvented. In Design 3, the key ideas underpinning the automation of qubit reduction-by-specialisation are introduced:  
* For the comparator \(C\) and \(U(C)\), the original implementation is replaced by an alternative, parameterised quantum circuit implementation where divisor qubits acts as specialisation parameters;  
Figure 16: Quantum integer divider Design 3: top-level overview of quantum circuit implementation of quantum integer division. Example shown for 4-qubit representation of dividend, divisor, and output. Based on parameterised quantum circuit implementation of \(C\), \(U(C)\), and \(Sub\). Figure 17: 4-qubit comparator based on design of [PERSON] et al. [33] reworked to have divisor quantum state in terms of 2’s complement. * For the subtractor \(Sub\), the original implementation is replaced by an alternative, parameterised quantum circuit implementation where divisor qubits acts as specialisation parameters;
* Design 3 also stores divisor qubits directly in 2's complement representation. The current analysis shows that using this form of the divisor state makes the parameterisation of the comparator and subtractor more compact than with the original form of divisor. With these changes, the states of the divisor qubits remain unchanged throughout the computation. This way, automated qubit reduction-by-specialisation becomes a realistic prospect for the tool chain used here. This will be demonstrated in Section 9. The quantum circuit implementation of the parameterised comparator used in division by 4-qubit divisor is shown in Figure 18, where the states of qubits \(|q3d^{\prime}\rangle\), \(|q2d^{\prime}\rangle\), \(|q1d^{\prime}\rangle\) and \(|q0d^{\prime}\rangle\) act as parameters.