How to compute the inverse of an operation in Q#?How to create an arbitrary state in QISKit for a local_qasm_simulator?How do we code the matrix for a controlled operation knowing the control qubit, the target qubit and the $2times 2$ unitary?How to construct the “Inversion About the Mean” operator?How would one implement a quantum equivalent of a while loop in IBM QISkit?Quantum counting in Q#How many logical qubits are needed to run Shor's algorithm efficiently on large integers ($n > 2^1024$)?How do I produce circuit diagrams from a Q# program?Representing a real valued vector with qubitsHow do I get a list of control qubits from Q# operations when tracing the simulation in C#?How do I do printf debugging in Q# in a convenient way?
How to write a nice frame challenge?
How is the idea of "girlfriend material" naturally expressed in Russian?
What is that ceiling compartment of a Boeing 737?
Why is it 出差去 and not 去出差?
If the mass of the Earth is decreasing by sending debris in space, does its angular momentum also decrease?
「捨ててしまう」why is there two て’s used here?
Is there any possible way to get these hearts as Adult Link?
Are there examples of rowers who also fought?
How is linear momentum conserved in circular motion?
How would one carboxylate CBG into its acid form, CBGA?
What is the most suitable position for a bishop here?
Is declining an undergraduate award which causes me discomfort appropriate?
How do you transpose samples in cents?
How do I find which software is doing an SSH connection?
Why one uses 了 and the other one doesn’t?
"Prove that ∂A is closed given ∂A = Cl(A) − Int(A)"
How can I ping multiple IP addresses at the same time?
Why there is a red color in right side?
Teferi's Time Twist and Gideon's Sacrifice
How can I prevent a user from copying files on another hard drive?
What is this plant I saw for sale at a Romanian farmer's market?
Why is it easier to balance a non-moving bike standing up than sitting down?
What is the highest power supply a Raspberry pi 3 B can handle without getting damaged?
Umlaut character order when sorting
How to compute the inverse of an operation in Q#?
How to create an arbitrary state in QISKit for a local_qasm_simulator?How do we code the matrix for a controlled operation knowing the control qubit, the target qubit and the $2times 2$ unitary?How to construct the “Inversion About the Mean” operator?How would one implement a quantum equivalent of a while loop in IBM QISkit?Quantum counting in Q#How many logical qubits are needed to run Shor's algorithm efficiently on large integers ($n > 2^1024$)?How do I produce circuit diagrams from a Q# program?Representing a real valued vector with qubitsHow do I get a list of control qubits from Q# operations when tracing the simulation in C#?How do I do printf debugging in Q# in a convenient way?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
$begingroup$
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 that in Q# (a keyword or operation)?
programming q#
New contributor
$endgroup$
add a comment |
$begingroup$
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 that in Q# (a keyword or operation)?
programming q#
New contributor
$endgroup$
add a comment |
$begingroup$
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 that in Q# (a keyword or operation)?
programming q#
New contributor
$endgroup$
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 that in Q# (a keyword or operation)?
programming q#
programming q#
New contributor
New contributor
edited 10 hours ago
Sanchayan Dutta
7,76441662
7,76441662
New contributor
asked 10 hours ago
Sorin BolosSorin Bolos
183
183
New contributor
New contributor
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
$begingroup$
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 the adjoint (which is the inverse for unitary).
Then, to use the inverse call Adjoint A(parameters)
$endgroup$
1
$begingroup$
Thank you. I didn't know that the adjoint is also the inverse for unitary matrices.
$endgroup$
– Sorin Bolos
10 hours ago
add a comment |
$begingroup$
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 is Adj
to your operation's signature, letting the Q# compiler know that your operation is adjointable:
open Microsoft.Quantum.Math as Math;
/// # Summary
/// Prepares a qubit in a state representing a classical probability
/// distribution p, 1 - p.
/// # Description
/// Given a qubit in the |0⟩, prepares √p |0⟩ + √(1 - p) |1⟩
/// for a given probability p.
operation PrepareDistribution(probability : Double, target : Qubit) : Unit
is Adj
let rotationAngle = 2.0 * Math.ArcCos(Math.Sqrt(1.0 - probability));
Ry(rotationAngle, target);
You can then call Adjoint PrepareDistribution
to "undo" the PrepareDistribution
operation. The Adjoint
keyword is an example of a Q# functor, and tells Q# that you want the inverse operation. In this case, the Q# compiler will apply Ry(-rotationAngle, target)
.
For more information:
- Functors
Learn Quantum Computing with Python and Q# (chapter 6 covers the example above, future chapters will talk more about functors)
$endgroup$
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "694"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
noCode: true, onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sorin Bolos is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fquantumcomputing.stackexchange.com%2fquestions%2f6477%2fhow-to-compute-the-inverse-of-an-operation-in-q%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
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 the adjoint (which is the inverse for unitary).
Then, to use the inverse call Adjoint A(parameters)
$endgroup$
1
$begingroup$
Thank you. I didn't know that the adjoint is also the inverse for unitary matrices.
$endgroup$
– Sorin Bolos
10 hours ago
add a comment |
$begingroup$
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 the adjoint (which is the inverse for unitary).
Then, to use the inverse call Adjoint A(parameters)
$endgroup$
1
$begingroup$
Thank you. I didn't know that the adjoint is also the inverse for unitary matrices.
$endgroup$
– Sorin Bolos
10 hours ago
add a comment |
$begingroup$
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 the adjoint (which is the inverse for unitary).
Then, to use the inverse call Adjoint A(parameters)
$endgroup$
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 the adjoint (which is the inverse for unitary).
Then, to use the inverse call Adjoint A(parameters)
answered 10 hours ago
Mahathi VempatiMahathi Vempati
7649
7649
1
$begingroup$
Thank you. I didn't know that the adjoint is also the inverse for unitary matrices.
$endgroup$
– Sorin Bolos
10 hours ago
add a comment |
1
$begingroup$
Thank you. I didn't know that the adjoint is also the inverse for unitary matrices.
$endgroup$
– Sorin Bolos
10 hours ago
1
1
$begingroup$
Thank you. I didn't know that the adjoint is also the inverse for unitary matrices.
$endgroup$
– Sorin Bolos
10 hours ago
$begingroup$
Thank you. I didn't know that the adjoint is also the inverse for unitary matrices.
$endgroup$
– Sorin Bolos
10 hours ago
add a comment |
$begingroup$
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 is Adj
to your operation's signature, letting the Q# compiler know that your operation is adjointable:
open Microsoft.Quantum.Math as Math;
/// # Summary
/// Prepares a qubit in a state representing a classical probability
/// distribution p, 1 - p.
/// # Description
/// Given a qubit in the |0⟩, prepares √p |0⟩ + √(1 - p) |1⟩
/// for a given probability p.
operation PrepareDistribution(probability : Double, target : Qubit) : Unit
is Adj
let rotationAngle = 2.0 * Math.ArcCos(Math.Sqrt(1.0 - probability));
Ry(rotationAngle, target);
You can then call Adjoint PrepareDistribution
to "undo" the PrepareDistribution
operation. The Adjoint
keyword is an example of a Q# functor, and tells Q# that you want the inverse operation. In this case, the Q# compiler will apply Ry(-rotationAngle, target)
.
For more information:
- Functors
Learn Quantum Computing with Python and Q# (chapter 6 covers the example above, future chapters will talk more about functors)
$endgroup$
add a comment |
$begingroup$
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 is Adj
to your operation's signature, letting the Q# compiler know that your operation is adjointable:
open Microsoft.Quantum.Math as Math;
/// # Summary
/// Prepares a qubit in a state representing a classical probability
/// distribution p, 1 - p.
/// # Description
/// Given a qubit in the |0⟩, prepares √p |0⟩ + √(1 - p) |1⟩
/// for a given probability p.
operation PrepareDistribution(probability : Double, target : Qubit) : Unit
is Adj
let rotationAngle = 2.0 * Math.ArcCos(Math.Sqrt(1.0 - probability));
Ry(rotationAngle, target);
You can then call Adjoint PrepareDistribution
to "undo" the PrepareDistribution
operation. The Adjoint
keyword is an example of a Q# functor, and tells Q# that you want the inverse operation. In this case, the Q# compiler will apply Ry(-rotationAngle, target)
.
For more information:
- Functors
Learn Quantum Computing with Python and Q# (chapter 6 covers the example above, future chapters will talk more about functors)
$endgroup$
add a comment |
$begingroup$
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 is Adj
to your operation's signature, letting the Q# compiler know that your operation is adjointable:
open Microsoft.Quantum.Math as Math;
/// # Summary
/// Prepares a qubit in a state representing a classical probability
/// distribution p, 1 - p.
/// # Description
/// Given a qubit in the |0⟩, prepares √p |0⟩ + √(1 - p) |1⟩
/// for a given probability p.
operation PrepareDistribution(probability : Double, target : Qubit) : Unit
is Adj
let rotationAngle = 2.0 * Math.ArcCos(Math.Sqrt(1.0 - probability));
Ry(rotationAngle, target);
You can then call Adjoint PrepareDistribution
to "undo" the PrepareDistribution
operation. The Adjoint
keyword is an example of a Q# functor, and tells Q# that you want the inverse operation. In this case, the Q# compiler will apply Ry(-rotationAngle, target)
.
For more information:
- Functors
Learn Quantum Computing with Python and Q# (chapter 6 covers the example above, future chapters will talk more about functors)
$endgroup$
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 is Adj
to your operation's signature, letting the Q# compiler know that your operation is adjointable:
open Microsoft.Quantum.Math as Math;
/// # Summary
/// Prepares a qubit in a state representing a classical probability
/// distribution p, 1 - p.
/// # Description
/// Given a qubit in the |0⟩, prepares √p |0⟩ + √(1 - p) |1⟩
/// for a given probability p.
operation PrepareDistribution(probability : Double, target : Qubit) : Unit
is Adj
let rotationAngle = 2.0 * Math.ArcCos(Math.Sqrt(1.0 - probability));
Ry(rotationAngle, target);
You can then call Adjoint PrepareDistribution
to "undo" the PrepareDistribution
operation. The Adjoint
keyword is an example of a Q# functor, and tells Q# that you want the inverse operation. In this case, the Q# compiler will apply Ry(-rotationAngle, target)
.
For more information:
- Functors
Learn Quantum Computing with Python and Q# (chapter 6 covers the example above, future chapters will talk more about functors)
answered 10 hours ago
Chris GranadeChris Granade
19316
19316
add a comment |
add a comment |
Sorin Bolos is a new contributor. Be nice, and check out our Code of Conduct.
Sorin Bolos is a new contributor. Be nice, and check out our Code of Conduct.
Sorin Bolos is a new contributor. Be nice, and check out our Code of Conduct.
Sorin Bolos is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Quantum Computing Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fquantumcomputing.stackexchange.com%2fquestions%2f6477%2fhow-to-compute-the-inverse-of-an-operation-in-q%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown