# Tag Info

Accepted

### How many logical qubits are needed to run Shor's algorithm efficiently on large integers ($n > 2^{1024}$)?

The question is about how many logical qubits it takes to implement Shor's algorithm for factoring an integer $N$ of bit-size $n$, i.e., a non-negative integer $N$ such that $1 \leq N \leq 2^n{-}1$. ...
Accepted

### How does one obtain amplitude information in Q#?

Yes, it is possible to obtain this information, but only for troubleshooting purposes, not for using it in the code. Dump functions dump the status of the target machine into a file or to the console ...
Accepted

### Ground state energy estimation - VQE vs. Ising vs. Trotter–Suzuki

In each of the examples you mentioned, the task breaks very roughly down into two steps: finding a Hamiltonian that describes the problem in terms of qubits, and finding the ground state energy of ...
Accepted

### Big Endian vs. Little Endian in Qiskit

Qiskit uses little-endian for both classical bit ordering and qubit ordering. For classical bits: A 3-bit classical register creg with value ...

### How do I produce circuit diagrams from a Q# program?

Unfortunately, there is indeed currently no way to generate circuit diagrams from a Q# program. Since this is a feature request, consider making it here: https://quantum.uservoice.com/forums/906940-...
Accepted

### How to construct the "Inversion About the Mean" operator?

First, let's represent operation $2|\psi\rangle \langle\psi| - \mathcal{I}$ as $H^{\otimes n}(2|0\rangle \langle0| - \mathcal{I})H^{\otimes n}$, as Nielsen and Chuang do. Doing $H^{\otimes n}$ is ...
Accepted

### How do I get a list of control qubits from Q# operations when tracing the simulation in C#?

arg.Value contains the actual tuple that the controlled operation receives at runtime. It's a two item tuple in which the first item is the control qubits, and the ...

### Does Q# have a bigint type?

There is none at the moment (as of version 0.3). We're working on adding it as a primitive type, hopefully it will be included in the next release.

### Can we perform quantum mechanical simulations using a quantum computer?

A separate note on using simulators for this (as opposed to using an actual quantum computer). Simulators, like the one that ships with Q#, are built to simulate quantum mechanical theories as we ...
Accepted

### Is programming in quantum computer same as programming in quantum simulator in classical computer?

Running programs on a quantum computer will indeed require some routines which are not required for running them on a classical simulation. Two easiest examples are error correction (a classical ...
Accepted

### How do you send an array of qubits to an operation in Q#?

In general, there are exactly two ways to allocate qubits in Q#: the using statement, and the borrowing statement. Both can only ...
Accepted

### From Q# measurements to Bloch sphere

The problem you are describing (i.e. finding an approximation of some state given some number of identical copies of it and some set of measurements) is known as quantum state tomography or state ...

### Q# factorization Method Program

Integer factorization sample in the official Quantum Development Kit samples repository implements Shor's algorithm in Q# and shows how to call it from C#.

### Practical example of Grover's algorithm (in Q#)

So far, it is better to say that the Grover Search algorithm, while presented as an algorithm searching through a database, would not be suited for such purpose. We prefer to say that we search ...
Accepted

### How do I write functions that modify operations in Q#?

For this example, one obtains a function with that signature by partial application of an operation that is defined outside the body, instead of as a lambda in the function. As a concrete example, ...
Accepted

### How do I multiply an integer and a double in Q#?

You want the Microsoft.Quantum.Extensions.Convert.ToDouble function (deprecated in favor of Microsoft.Quantum.Convert.IntAsDouble...
Accepted

### How to see the QASM code corresponding to compiled Q# function?

Q# is not compiled into QASM, so that would be tricky. Q# compilation and execution process is approximately as follows: Q# code is parsed into an internal data structure representing an abstract ...
Accepted

### How to compute the inverse of an operation in Q#?

As given in the documentation, if your operation is unitary, you can add the statement adjoint auto; within the operation after the body block. This will generate ...

### How to compute the inverse of an operation in Q#?

In the case that your operation can be represented by a unitary operator $U$ (this is typically the case if your operation doesn't use any measurements), you can indicate that by adding ...

### How to make a time rotation in Qsharp like in Quirk spinning gates?

Your question suggests you want to try an experiment that would only work if the no communication theorem wasn't a thing. So... just be aware of that. In Quirk, the time-based gates are not ...
Accepted

### What is the corresponding code for finding the state of a qubit on the Bloch sphere?

Prepare a qubit in state $|\psi\rangle=\mathrm{cos}\frac{\theta}{2}|0\rangle+\mathrm{e}^{i\phi}\mathrm{sin}\frac{\theta}{2}|1\rangle$, given the angles $\psi$ and $\theta$. Let's start with a qubit ...

### Simulator-dependent implementations in Q#

One possibility is to override a default implementation using an alternative one for a specific simulator. Here, init_and would be the default implementation as in ...
Accepted

### Q# Simulation Behavior

Thanks for your question! If you're interested in running multiple shots of a quantum operation, Q# allow for doing that with conventional programming techniques such as a ...
Accepted

### Take every second element of the array in Q#

You can create an array with every second element starting from the second one using the expression array[1..2...].
Accepted

### What all parameters can we take into account when comparing different quantum programming languages

Just as with classical computing, we don't expect that in quantum computing the choice of a programming language will have a direct effect on the time and space complexity of most algorithms. That is, ...
Accepted

### How do I name the adjoint of an operation in Q#?

You can define an immutable symbol for MinusEqual inside the body of an operation which will use it (you can't define it globally): ...

### How to add two integers in Q#?

You will need quantum circuits called adders. You have for example one from Cuccaro et al. and another from Himanshu et al.
Accepted

### How to measure in an arbitrary basis in Q#?

Let's say you want to distinguish two states: $$|A\rangle = \cos \alpha |0\rangle + \sin \alpha |1\rangle \\ |B\rangle = -\sin \alpha |0\rangle + \cos \alpha |1\rangle$$ For your particular ...