# What's my computational basis if I want to define a unitary operator that implements a function such as $f(i) = 2^{i+1} \text{mod 21}$?

I know I must define $$U_f$$, the unitary operator, on the computational basis. But what's my computational basis here?

## 2 Answers

Presumably you want to work with qubits? So the usual computation basis applies: $$|0\rangle$$ and $$|1\rangle$$ for a single qubit, and a composite basis of $$|x\rangle$$ for $$x\in\{0,1\}^n$$ when composing $$n$$ qubits.

What I guess you're asking is how you translate your problem onto qubits. For that, you need to make the decimal values correspond to particular bit values. The conventional way of doing this is using the binary string $$x$$ like a binary number, which corresponds to a decimal value. There are a number of different numbering conventions you can pick from but, for example, you might have $$x=x_0x_1x_2\ldots x_{n-1},$$ meaning that the corresponding decimal value is $$x_{n-1}+2x_{n-2}+4x_{n-3}+\ldots+2^{n-2}x_1+2^{n-1}x_0.$$ $$n$$ bits lets you represent any decimal number 0 to $$2^n-1$$.

First, I would say you need to specify registers, their size, their role and what will they will contain.

It depends on the $$i$$ you want to apply this function, which is to be represented as a bitstring (in this case, I guess an unsigned integer representation) that will be one of the computational basis. It can be a particular one or just a superposition. You need to define the registers (the one containing $$i$$, garbage register containing intermediary results and the one containing the result). Mathematically, your operator will have the following effect if you uncompute intermediary results : $$U_f | i \rangle | 0 \rangle_g | 0 \rangle_f = | i \rangle | 0 \rangle_g | f(i) \rangle_f$$

Secondly, to define this unitary, you need the sequence of unitary operations that will achieve your goal. It is recommended to not create a unitary operator by specifying the matrix.