Hot answers tagged

17 votes
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$. ...
user avatar
10 votes
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 ...
user avatar
10 votes
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 ...
user avatar
10 votes
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 ...
user avatar
  • 951
8 votes

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-...
user avatar
7 votes
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 ...
user avatar
6 votes
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 ...
user avatar
  • 341
6 votes

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.
user avatar
6 votes

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 ...
user avatar
6 votes
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 ...
user avatar
5 votes
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 ...
user avatar
5 votes
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 ...
user avatar
  • 1,556
5 votes

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#.
user avatar
5 votes

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 ...
user avatar
  • 4,544
5 votes
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, ...
user avatar
5 votes
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...
user avatar
  • 3,503
5 votes
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 ...
user avatar
5 votes
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 ...
user avatar
5 votes

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 ...
user avatar
5 votes

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 ...
user avatar
  • 21.8k
5 votes
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 ...
user avatar
5 votes

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 ...
user avatar
5 votes
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 ...
user avatar
5 votes
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...].
user avatar
5 votes
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, ...
user avatar
4 votes
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): ...
user avatar
4 votes

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.
user avatar
  • 4,544
4 votes
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 ...
user avatar
4 votes
Accepted

Can we perform quantum mechanical simulations using a quantum computer?

What do you mean by "Quantum Mechanical Simulations" ? One of the primary motivations in the early history of quantum computing was a statement from Richard Feynman that a quantum computer would be ...
user avatar
4 votes
Accepted

How do I do printf debugging in Q# in a convenient way?

For Toffoli simulator in particular, DumpRegister will provide this information. For example, the following code ...
user avatar

Only top scored, non community-wiki answers of a minimum length are eligible