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 unrelated to, or arising from some non-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
1answer
18 views

Quantum Katas - Tutorials - Oracles - Task 3.3 (OR oracle of all bits except for a single bit)

Let $x$ be an arbitrary state composed of $N$ qubits and $k$ be an integer such that $0\leq k \leq N.$ The task is to ignore the $k$-th bit and to flip the sign of $x$ if any of the remaining bits are ...
0
votes
1answer
29 views

Quantum Katas - Tutorials - SingleQubitGates - Exercise 7 - Preparing an arbitrary state

Exercise 7 "Preparing an arbitrary state" from the Quantum Katas - Tutorials - SingleQubitGates asks to prepare a state $\alpha|0\rangle + e^{i\theta}\beta|1\rangle$, using parameters $\...
1
vote
2answers
66 views

Measuring entanglement entropy using a stabilizer circuit simulator

I'm trying to simulate stabilizer circuits using the Clifford tableau formalism that lets you scale up to hundreds of qubits. What I want to do is find the entanglement entropy on by splitting my ...
1
vote
1answer
51 views

How to use QFT operation in Q#?

I see the QFT operation in the document given by Microsoft, but I don't know how to call it. ...
3
votes
1answer
70 views

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

I am planning to write a paper which compares Qiskit and Q# in the following circuits/algorithms Bell circuits Controlled swap to test similarity of two registers Phase kickback between two qubits ...
0
votes
1answer
31 views

Accessing tupple data in Q#

I am continuing my work on the SAT katas, but I thing I am missing something on the way the tuple data type works. In this example code, I am trying to access the data in a tuple type : ...
1
vote
1answer
157 views

Take every second element of the array in Q#

Very quick question, I am trying to implement SAT solving in Q# using Grover's Algorithm. I want to take every second element from an array starting at the second element, represented with a range ...
5
votes
1answer
65 views

Q# installation on Heroku

I'm trying to deploy a simple Quantum App written using Python on Heroku Server which is also using Microsoft's Q#, but getting the below error: ...
6
votes
1answer
187 views

Q# Simulation Behavior

I am attempting to run a series of tests on a Q# program I'm running on the local simulator, but I'm not seeing any way to use >1 shot and collect the results of those shots at once, as in ...
1
vote
1answer
28 views

Q# Callable Not Accessible from Open Namespace

I am trying to to call ApplyMultiplyControlledAnd(), and I'm receiving an error saying "The callable ApplyMultiplyControlledAnd exists in an open namespace, ...
0
votes
1answer
73 views

Braket and Q# Simulators

I have implemented Shor's algorithm in Qiskit, and everything works as expected within the IBM Q experience for both the IBM qasm_simulator and real hardware. However, after I've implemented Shors in ...
2
votes
2answers
47 views

Creating a resource count unit test in Q#

I want to create a unit test in Q# that runs an operation and asserts that it used at most 10 Toffoli operations. How do I do this? For example, what changes do I have to make to the code below? ...
0
votes
1answer
57 views

Correctly configuring a Q# test project in Visual Studio Code

I have some Q# code which I'm editing using visual studio code. The codebase is divided into a src/ folder and a test/ folder. ...
3
votes
2answers
57 views

$S^{\dagger}$ gate in Q#

I would like to implement $S^{\dagger}$ gate in Q# and I would like the best way to do it, is it correct to say that $S^{\dagger}$ is equivalent to R1( -Pi()/2 , q) ...
5
votes
2answers
67 views

Simulator-dependent implementations in Q#

I have a Q# operation: ...
2
votes
1answer
145 views

How to solve QUBO problems in Q#?

Short version: I'm trying to solve a traveling salesman problem very similar to the traveling Santa example here: http://quantumalgorithmzoo.org/traveling_santa/, which is also included in the samples ...
0
votes
2answers
42 views

How to get circuit run time in Q#

What is the best way to get the circuit run time in Q# ? More precisely, I run a circuit using dotnet -run command and I would like to know how many time it took for running my circuit. Actually I ...
1
vote
1answer
46 views

Best way to test the performance of a simulated quantum algorithm in Q#

for a student report about solving graph coloring with Grover's Algorithm, I have to talk about the performance of simulated Grover's Algorithm to solve graph coloring. I don't really know how to ...
0
votes
0answers
60 views

Different result between Q# and Qiskit

I'm running a search program with custom initial state. I wrote a program in Q# and one in Qiskit but I get different results even if the code seems to be peforming the same operations. The Q# result ...
0
votes
1answer
48 views

Grover algorithm in Q#

I have this program derived from Microsoft Quantum Kata for quantum search (Grover algorithm) (see here) ...
3
votes
1answer
148 views

Implement U2 and U3 gate in Q#

I know that U1 equivalent gate of Qiskit in Q# is R1, but I would like to implement U2 and U3 gate of Qiskit in Q#, what is the best way ? Thank you.
0
votes
2answers
44 views

Run circuit N times in Q#

I use dotnet run command to run my .qs quantum circuit. Is there a way to run my circuit N times, and get results of each run (like the shots parameter in Qiskit) ? Thank you.
0
votes
1answer
66 views

How to implement quantum gate from matrix in Q#

Is it possible to implement a quantum gate from a matrix in Q#, the equivalent of unitary function in Qiskit ? My final goal is to implement cirq CZPowGate in Q#. Thank you.
1
vote
1answer
36 views

How to get state vector probabilities in Q#

Is there a similare function in Q# like Statevector.probabilities in Qiskit to get state vector probability, for example, if my circuit contains one qubit with one $H$ gate, the function returns ...
2
votes
1answer
168 views

Is there a function in Qiskit to measure tensor products of Pauli operators?

Is there a function in Qiskit similar to this function in Q# which measures strings of Pauli operators applied to different qubits?
3
votes
1answer
107 views

What is the right way to prepare a specific qubit state in Qiskit / Q#?

There are two possibilities to prepare a qubit in a particular state like $ | - \rangle $ in Qiskit. The first approach is using the initialize function: ...
2
votes
2answers
58 views

Testing superposition states in Q#

I am learning Q# so, as I often do, I am writing some unit tests to play with quantum gates. I was able to write these tests for X gate: ...
0
votes
1answer
46 views

How can I mesure a register of qubits and grab the index of the qubit with the highest probability in Q#?

I have an array of qubits, with indices to represent each such that if we have 3 qubits, we have 0, 1, 2 representing each. From here I would like to measure the probability of our qubits after ...
1
vote
1answer
33 views

Usage of partial application in Q#

I am working with multiple operations and used partial application in different cases in Q#. I have 2 questions : Can a partial applicated operation be passed as an argument ? Lets say you have an ...
1
vote
1answer
100 views

Is there a Q# funtion which returns the type of a variable?

As the title says, I am asking myself is there is a specific function which returns the type of something. Ideally, I would work as follows : ...
1
vote
0answers
35 views

How to create a C# host program for a Q# program in Visual Studio Community 2019?

I have been trying to create a C# host program for a Q# program in Visual Studio Community 2019 by following these instructions: https://docs.microsoft.com/en-us/quantum/quickstarts/install-cs?tabs=...
0
votes
1answer
50 views

How can I represent mixed states in Q#?

I have a mixed state with a density matrices corresponding to $\rho=\sum_0^{2^n-1}p_i|i\rangle\langle i|$. How would i represent this in Q#? How would I go about applying Unitary Operations $U$ on ...
1
vote
1answer
100 views

Microsoft Q#: “Namespace declarations can only occur at a global scope” error

I am having challenges with Microsoft Q#. I wrote this short code and it says it can only occur at a global scope. How do I fix this error? Any ideas? Thank you
0
votes
1answer
28 views

Entangling a register with another register using phase flips

...
1
vote
1answer
37 views

What would be the difference between using qsharp library on python vs learning the Q# langauge?

One difference of course is the syntax. But I'm guessing the idea is eventually quantum computers will be able run Q#, whereas now it uses simulations. Will code written in Python with the qSharp ...
1
vote
2answers
266 views

How can I create an n-dimensional Hadamard transform in Q#?

I would like to create a n-dimensional Hadamard transform in Q# with n in set of even integers.
0
votes
3answers
135 views
3
votes
1answer
84 views

Finding phase angle in Q#

I've trying to measure the phase angle from X axis of a qubit, but unable to find any function in Q# documentation, can anyone help me with this?
2
votes
1answer
34 views

What's the relationship between output of qubit measurements and classification of data in Quantum Machine Learning?

I'm training a model in Q# which has more than 2 features. I have trouble understanding the following things: How is the data classified based on the qubit states? For example: If I have only 2 ...
1
vote
2answers
69 views

How can I create a basis state of $n$ qubits in Q#?

I would like to create a set of basis qubits. For example if I have $n=2$ I should get 4 states being 01 10 11 00. Generalized for $2^n$. Is there a way to do this in Q#?
2
votes
1answer
55 views

Is it possible to create a gate in Q# that is dictated by a matrix?

When observing the Hadamard gate it is simply a transformation matrix. I am wondering if there is functionality to hard code an arbitrary transformation matrix and its family members up till $m \times ...
1
vote
0answers
45 views

How do you decide which rotations to use in a Quantum Machine Learning model?

I am trying to design a model using Q#'s machine learning library that takes in two features (real numbers from 0 to 1) and classifies as 0 or 1. So how do I decide which Rotations and what seeds to ...
-1
votes
1answer
132 views

Difference between $Rz$ and $R1$ gate [closed]

You are given an operation that implements a single-qubit unitary transformation: either the Rz gate or the R1 gate. The operation will have Adjoint and Controlled variants defined. Your task is to ...
2
votes
1answer
45 views

Graph coloring - Q# -

I am checking Q# - Graph coloring for (C in 0 .. (1 <<< N) - 1) { InitializeColor(C, register); Can you help me explain ...
2
votes
2answers
254 views

Q# Error: No namespace with the name “Microsoft.Quantum.MachineLearning” exists

I'm having trouble getting the namespace Microsoft.Quantum.MachineLearning. Here is an example Q# code: ...
0
votes
1answer
40 views

Is there a way to grab probablities of my qubits in Q#?

https://qiskit.org/textbook/ch-algorithms/grover.html I am looking for a visual, or just probabilities like the ones given in the link.Is this possible on Q#?
1
vote
0answers
44 views

Attempting to use the QuantumMachineLearning Repositry with vscode and now import qsharp is reporting 'Fail'

I have been trying to follow the Quantum machine learning kata by using vscode and jupyter notebook, I was using the wrong version of iqsharp so changed it in the code like so: As can be seen the ...
0
votes
1answer
39 views

dotnet iqsharp install gives error “FileNotFoundError: The system cannot find the path specified”

installing Q# version g --version 0.1.2.3 in jupyter. but this command line dotnet iqsharp install responds system cannot find path specified . what should i do . i have also installed vscode ...
0
votes
1answer
65 views

How do I encode integers into BigEndian in Q#?

https://export.arxiv.org/ftp/arxiv/papers/1908/1908.07943.pdf page 4 point 1 states that we use the bits of an integer as a basis in our space. I understand that BigEndian grabs our largest bit and ...
4
votes
1answer
193 views

qsharp.reload() throws error in python

I'm trying to add the Q# machine learning library to my program by ...