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

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 ...
• 1,221
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 ...
• 1,068
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 ...
• 9,135

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. To give a little bit of context, Q# makes a conscious effort to encourage reasoning about quantum ...
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 ...
• 9,135
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 ...
• 361

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.
• 9,135

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 ...
• 9,135
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 ...
• 9,135
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 ...
• 1,068
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 ...
• 1,646

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 ...
• 4,754

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#.
• 9,135
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...
• 3,663
Accepted

Counting in Q#: number of solutions

I have a theory as for where the issue comes from (huge thanks to Robin for helping me figure it out!) Grover iteration consists of four steps: Apply the oracle. Apply the Hadamard transform. ...
• 9,135
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 ...
• 9,135
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 ...
• 1,631

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 ...
• 1,068

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 ...
• 38.5k
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 ...
• 9,135

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 ...
• 1,068
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, ...
• 1,068

Measuring entanglement entropy using a stabilizer circuit simulator

I think stim is the right tool for the job here, because it gives you access to the stabilizer generators and also it defines stim.PauliString which you can use to ...
• 38.5k
Accepted

Is there a way to implement Smolin's variant of Shor's algorithm?

The thing to understand is that the quadratic residue $a$, that Smolin is getting you to compute, is exactly the same $a$ that Shor's algorithm is finding by using period-finding against a random base ...
• 38.5k
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): ...
• 9,135