Questions tagged [q#]

Q# is a domain-specific programming language used to express quantum algorithms. This tag should be used for questions related to creating/programming quantum algorithms using the 'Q#' language. If the question is not related to, or arising from some quantum aspect of Q#, it might be better to ask on StackOverflow. If appropriate, also use the [programming] tag.

Filter by
Sorted by
Tagged with
1
vote
0answers
7 views

'Unable to import' error message in Q# using VS Code

I'm a complete beginner in Q#. Consider the code in the following image: For some reason, there always is an error message when I try to import anything. It also implies to keywords like ...
0
votes
1answer
22 views

Error running Q# notebooks: Syntax does not match any known patterns

C:/snippet_.qs(1,85): error QS3001: Syntax does not match any known patterns. C:/snippet_.qs(1,26): error QS6104: No namespace with the name "Microsoft.Quantum.Intrinsic" exists. C:/snippet_.qs(7,17): ...
1
vote
1answer
28 views

How can I run Q# program in Azure Quantum

I have already made a small Q# program and ran it using Python on VSCode, my question is how can I run it on Azure Quantum to make it run faster? Q# program : ...
2
votes
1answer
69 views

Are there patterns in the numbers created with qrng by entangled qubits?

I want to examine the graph of 2 sets consisting of 1000 numbers created with quantum random number generator which were created by entangled qubits and see if there is a pattern in the randomly ...
0
votes
1answer
47 views

Tensor Product in Q#

Does anyone know how you can obtain a new state |z> from two pre-existing states |x> and ...
3
votes
1answer
99 views

Creating Hamiltonian Simulation Operator in Q#

I am trying to create a unitary operator $U = \sum^{T - 1}_{k=0}$ $|k\rangle$ $\langle k |$ $ \otimes$ $e^{i A k}$ in Q#, where A is a Hermitian matrix. For the beginning, I just want A to be a ...
3
votes
1answer
58 views

Inner product of states in Q#

I have a state $|x\rangle$ and I want to get the expected result when measuring observable $A$ (i.e. get the result of $\langle x| A | x \rangle$). In my case $A$ can be any of the Pauli gates. Does ...
2
votes
1answer
70 views

Generic matrix exponential in Q#

I am trying to find a way to implement a unitary transformation in Q# that implements e^(iA) where A is a square matrix. However, I only found ways to do this in Q# if A can be represented as a ...
1
vote
1answer
58 views

Why don't I get what I expect when measuring with respect to a different basis?

$\newcommand{\bra}[1]{\left<#1\right|}\newcommand{\ket}[1]{\left|#1\right>}\newcommand{\bk}[2]{\left<#1\middle|#2\right>}\newcommand{\bke}[3]{\left<#1\middle|#2\middle|#3\right>}$ If ...
1
vote
1answer
21 views

How to use ApplyToEach when operation has parameters?

Problem Apply a global phase -1 to all qubits x : Qubit[]. My solution ApplyToEach(R, PauliI, 2.0 * PI(), x) However this ...
2
votes
1answer
84 views

Installing Q# in jupyter

I have followed all steps described in https://docs.microsoft.com/en-us/quantum/install-guide/qjupyter But I am unable to get through part 3. It is showing syntax error in Python terminal in Jupyter ...
1
vote
2answers
66 views

May I deploy my C# code to Q# Azure quantum computing?

I have a code like this ...
0
votes
1answer
42 views

How to retrieve the parameters of a Q# operation?

How to retrieve the parameters of a Q# operation? Is it possible to do such a thing at all?
1
vote
1answer
71 views

Controlled NOT gate using multiple control qubits in Q#

I am trying to implement the Grover's search algorithm using Q# and I am not able to implement the oracle (black box) part for the search of state $|1010\rangle$. How to implement the controlled NOT ...
1
vote
0answers
158 views

IBM qiskit vs Microsoft QDK [closed]

I am new to both IBM Qiskit and Microsoft QDK. I wish to understand which framework would be best suited for someone new to this field. I am lookig for the pros and cons of both frameworks.
0
votes
2answers
209 views

Problems with Q# installing

I don't know if this is the right place to ask this question. I just thought it would be a place where people knew what they are doing. If there is a better place to look for answers (stackoverflow ...
0
votes
0answers
59 views

How to reduce the length of Q# programs execution time?

In the released Q# documentation by Microsoft available at: Quantum Development Kit Full State Simulator, it is written By default OpenMP uses all available hardware threads, which means that ...
2
votes
2answers
92 views

Is it possible to create a Q# operation with optional parameters?

In C# it is possible to have: public void Fun (int n = 0){ // ... } then the following method call examples will be compiled: ...
3
votes
1answer
106 views

How to invoke a C# method inside a Q# operation?

Suppose there is a Q# operation as follows: operation Op () : Bool { let result = CSharpMethod (); return result } where ...
2
votes
2answers
112 views

Unit testing for quantum programs?

Does unit testing on real quantum computers make sense as any observation in the quantum system can cause the system to loose its superposition state?
4
votes
1answer
97 views

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

To find the state of a qubit on the Bloch sphere we use the following formula: \begin{equation} |\psi\rangle=\mathrm{cos}\frac{\theta}{2}|0\rangle+\mathrm{e}^{i\phi}\mathrm{sin}\frac{\theta}{2}|1\...
2
votes
1answer
84 views

Is it possible to write a Q# teleportation code which returns a qubit?

Is it possible to write a Q# teleportation code which returns a qubit? Thanks.
3
votes
1answer
40 views

How can I transform a Result into a Bool in Q# + C# environment?

I'm writing a Q# program and I'm calling an operation defined in the program that outputs a Result (One or ...
1
vote
1answer
59 views

How to create a q# operation to generate a random number from 1 to max?

I have the following problem: I want to create a q# operation for generating a random integer from 1 to max and return the generated number. What algorithm do I need? What does the q# code look like? ...
1
vote
1answer
36 views

Where is OpenQasmReader in Q#?

OpenQasmReader was added in https://github.com/microsoft/Quantum/pull/58. I can't find this code on the latest clone of the aforementioned repository. Going through the commits, I found that it had ...
1
vote
1answer
46 views

Unable to recognise little-endian format

I'm told that the input register is in little-endian format. But the vscode gives me error telling me that it is wrong argument for QFT even after using a suitable converter. Am I missing something ...
1
vote
1answer
40 views

ResetAll with adjoint auto

...
2
votes
3answers
183 views

How do I start as a quantum computing programmer?

How do I learn Q#? What languages should I know prior to learning Q#? How do I get started with quantum computing?
3
votes
2answers
252 views

Big Endian vs. Little Endian in Qiskit

I've noticed that Q# favors Little Endian. Meaning that most operations are designed for this type of encoding. Is is it the same with Qiskit?
9
votes
1answer
279 views

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

Disclaimer: I am a software engineer who is curious about quantum computing. Although I understand some basic concepts, theory and math behind it, I am by no means experienced in this domain. I am ...
1
vote
3answers
959 views

Cirq, qiskit, q#, ibmq(circuit board), other [closed]

Which platform is the best for programming quantum computers? Which one is your personal favourite? If other mention which one it is and if possible few resources for it.
0
votes
3answers
66 views

How to add scalar to quantum string

I need a way to add scalar values to a quantum string. Say if $| v \rangle = |1 1 0 \rangle + |1 0 1 \rangle$ then $|v \rangle + 5 = |1 0 1 1 \rangle + |1 1 0 0\rangle$ Is there a known method to ...
2
votes
1answer
61 views

How do these alternative Q# algorithms produce the same set of Bell states?

In the "Superposition" Microsoft quantum katas (https://github.com/microsoft/QuantumKatas/blob/master/Superposition/ReferenceImplementation.qs) the solution for Task 7 looks like this: ...
0
votes
1answer
41 views

Q#: dynamically assigning (or updating) multidimensional Qubit arrays

Question: how to dynamically assign qubits to variables? e.g., say I want to represent a matrix of qubits: $matrix := \{\vec{v_1}, \vec{v_2}, ..., \vec{v_r}\}$ where each vector consists of $dim$ ...
1
vote
2answers
191 views

Q#: How to setup a project correctly (on Linux, command line)?

When setting up projects with Q# I used to start with the given Quick-Starting Guide. Following the tutorial I am able to setup the example problem and the program works well. However, there seems to ...
-1
votes
1answer
51 views

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

Qsharp have Rx Ry and Rz gates for rotation, but I need to apply a gate that leaves the Qbuit rotating continuosly like in Quirk spinning gates. https://algassert.com/quirk#circuit=%7B%22cols%22%3A%5B%...
2
votes
1answer
49 views

Hamming with prefix oracle

I'm doing the Q# quantum katas and I'm stuck on an oracle in the Deutsch-Josza algorithm katas. Let $|x\rangle=|x_0x_1\dots x_{n-1}\rangle$ be a qubit array and $r$ be bit string of $k\leq n$. The $...
1
vote
2answers
95 views

Is it possible to change the oracle in Grover's search to ponderate probabilities in multiple values search?

If I want to to search 2 values with Grover's algorithm, it outputs the same probability for both that is bigger that the no searched states that have the same lower percent. If I use an oracle ...
1
vote
1answer
107 views

How does ControlledOnInt in Q# make it Grovers Oracle?

I have an example with 6 qubits for names and 6 for telephones. I encoded their relation like this: ...
3
votes
2answers
521 views

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

I want to implement amplitude amplification using Q#. I have the operation $A$ that prepares my initial state and I need to compute $ A^{-1} $ to implement the algorithm. Is there an easy way to do ...
1
vote
2answers
102 views

Converting a qubit's state to a binary value in Q#

In Q#, How do I store a qubits state in a binary-based disk / hard drive for use by regular digital programs? Is this even possible?
4
votes
1answer
103 views

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

I'm learning Q#. Is there any way to see the QASM code of a Q# function I write, the same way I can see the disassembly of a C# function?
3
votes
1answer
166 views

Counting in Q#: number of solutions

I have this program derived from Microsoft Quantum Katas for counting (see here): ...
3
votes
1answer
59 views

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

When initially writing an operator in Q#, I often want to see intermediate values of registers during the computation. This allows me to check that I haven't made ...
2
votes
2answers
117 views

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

I just started programming in Q# and I wonder if the coding for Q# in classical computer would be the same as coding in a quantum computer. Obviously, these 2 kinds of computers work differently, so I ...
3
votes
1answer
362 views

Creating controlled R1 gates in Q#?

I know how to create controlled versions of gates like X, Y, Z. For example, a controlled X gate would be implemented by writing (Controlled X)([control],target); ...
3
votes
1answer
64 views

Type error creating R gate in Q#?

The R operation in Q# is listed by Microsoft in the documentation as follows operation R (pauli : Pauli, theta : Double, qubit : Qubit) : Unit However, when I try ...
3
votes
1answer
92 views

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

I want to write code that prints out the controls of each operation executed during a simulation in Q#. For example this code prints the control counts: ...
4
votes
2answers
145 views

Does Q# have a bigint type?

Shor's algorithm works with very large integers; larger than 64 bits. So the built-in 64-bit Int type is insufficient for doing the classical processing (e.g. ...
2
votes
1answer
86 views

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

If I write this: function f(n: Int) : Double { return 1.5*n; } I get an error: ...