I want to make an operator:
$\mathrm{U3}(\arccos(\sqrt p),0,0)$, when $p$ is a random value between $0$ and $1$
How do I write code in QASM language of this "random $\mathrm{U3}$" operator?
Quantum Computing Stack Exchange is a question and answer site for engineers, scientists, programmers, and computing professionals interested in quantum computing. It only takes a minute to sign up.
Sign up to join this communityI want to make an operator:
$\mathrm{U3}(\arccos(\sqrt p),0,0)$, when $p$ is a random value between $0$ and $1$
How do I write code in QASM language of this "random $\mathrm{U3}$" operator?
There are many forms of QASM, so I'll answer for OpenQASM 2.0, as is currently used by IBM.
Declaring a gate to be random means that it would be randomly generated at compile time. Since QASM is used as an expression of a compiled circuit, such randomness must be resolved by the time the QASM is created.
It is true that are transpilation processes in the IBM stack, which convert a user generated QASM into one optimized for the needs of a given device. This could allow for the functionality your desire to be built into future versions. But I doubt that will be the case. It is much easier just to use randomness when generating the QASM, such as with Pythons random number generation when creating circuits with Qiskit.
Disclaimer: I work for IBM.