# Quantum circuit simplification using classical computers

Suppose that we have this kind of circuit where the first unitary operator U is used for the state preparation while the Hadamard operator is used of state detection. Let's say we try to run this circuit experimentally, but we don't have enough resources to operate two operators together. Let's imagine that we can use perform one arbitrary single unitary operation M as below: Compared to the first circuit, the operator M is equivalent to the multiplication of U and H such as $$M=H\times U$$. To generate the matrix $$M$$ as $$H\times U$$, the classical computer is required to calculate the structure of the matrix, and afterwards we can run the same circuit in the second figure as $$H\times U$$.

But I wonder if the usage of classical computers for this kind of simplification is generally allowable.

Of course the "simplification" you are doing here is always possible and, more in general, any quantum circuit can be represented as a single $$2^n \times 2^n$$ unitary matrix $$M$$ (acting on a $$n$$-qubits quantum state). However, what you are probably missing here is that the linear algebra of unitary operators is just the mathematical tool that we use to describe quantum computation or, at most, to simulate quantum computers.
Once you come to the actual realization of your operator $$M$$ on a real quantum device, you have to consider that the hardware is constrained to use a quite limited set of quantum gates that can really acts on physical qubits (e.g. as microwave pulses on superconducting qubits). This means that, from the quantum hardware's point of view, applying first the $$U$$ gate and then the $$H$$ gate is perfectly equivalent to applying the resulting gate $$M = H \times U$$ and there is no such a thing as a "simplification" in what is taking place.
• Taking a stab although I'm still not 100% sure what you're asking: decomposing an arbitrary, desired operation $M$ into its component operations that I can physically run using the relevant gate-set on my computer is not only a necessary, but also challenging and doing so efficiently/optimally is an open problem Jan 20 at 20:54
• Oh, got it. I believe there are some schemes that work reasonably well for $N$ qubits, but the required number 1- and 2-qubit gates scales exponentially with $N$. Classical algorithms that try to minimize the number of quantum gates are fairly complicated/expensive though (but spending the classical time to run more efficiently on quantum hardware is still a huge net benefit). For more details, you could look into quantum circuit compiling like arxiv.org/pdf/2101.02993.pdf Jan 20 at 21:33