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?
Why aren't (poly-)cotton tents more popular?
Cascading Repair Costs following Blown Head Gasket on a 2004 Subaru Outback
What would Earth look like at night in medieval times?
Should my manager be aware of private LinkedIn approaches I receive? How to politely have this happen?
Is it OK to bottle condition using previously contaminated bottles?
Simple object validator with a new API
Content builder HTTPS
How could mana leakage be dangerous to a elf?
How can I convince my reader that I will not use a certain trope?
Does Marvel have an equivalent of the Green Lantern?
Do I recheck baggage at stopovers MCI-SEA-ICN-SGN? Delta and Korean Air
The impact of an intelligent and (mostly) hostile flying race on weapons and armor
Going to get married soon, should I do it on Dec 31 or Jan 1?
Can a US President have someone sent to prison?
Was touching your nose a greeting in second millenium Mesopotamia?
Are there any vegetarian astronauts?
Should I tell my insurance company I'm making payments on my new car?
What is the line crossing the Pacific Ocean that is shown on maps?
Is this one of the engines from the 9/11 aircraft?
What is this particular type of chord progression, common in classical music, called?
Does the UK have a written constitution?
Are Finite Automata Turing Complete?
Why is Madam Hooch not a professor?
How can I repair scratches on a painted French door?
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 Jun 16 at 17:11
Sanchayan Dutta
7,8764 gold badges16 silver badges62 bronze badges
7,8764 gold badges16 silver badges62 bronze badges
New contributor
asked Jun 16 at 17:06
Sorin BolosSorin Bolos
233 bronze badges
233 bronze badges
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
Jun 16 at 17:44
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
Jun 16 at 17:44
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
Jun 16 at 17:44
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 Jun 16 at 17:33
Mahathi VempatiMahathi Vempati
82410 bronze badges
82410 bronze badges
1
$begingroup$
Thank you. I didn't know that the adjoint is also the inverse for unitary matrices.
$endgroup$
– Sorin Bolos
Jun 16 at 17:44
add a comment |
1
$begingroup$
Thank you. I didn't know that the adjoint is also the inverse for unitary matrices.
$endgroup$
– Sorin Bolos
Jun 16 at 17:44
1
1
$begingroup$
Thank you. I didn't know that the adjoint is also the inverse for unitary matrices.
$endgroup$
– Sorin Bolos
Jun 16 at 17:44
$begingroup$
Thank you. I didn't know that the adjoint is also the inverse for unitary matrices.
$endgroup$
– Sorin Bolos
Jun 16 at 17:44
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 Jun 16 at 17:44
Chris GranadeChris Granade
2032 silver badges6 bronze badges
2032 silver badges6 bronze badges
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