Giter VIP home page Giter VIP logo

Comments (5)

CalMacCQ avatar CalMacCQ commented on June 21, 2024

Hi,

thank you for your question.

I currently don't think we have a documented example on calculating inner and outer products specifically. This would be a good thing for us to add.

A simple method to calculate the inner product between two states $|\psi>$ and $|\phi>$ is the SWAP test. Here we encode the value of the inner product in the probability of measuring the first qubit to be in the $|1> state. The theory is explained here -> https://en.wikipedia.org/wiki/Swap_test

I have included a screenshot of the circuit below

You can implement this test circuit using the following pytket code

swap_circ = Circuit(3,1) # Create a Circuit with three qubits and one classical bit
swap_circ.H(0)
swap_circ.add_gate(OpType.CSWAP, [0,1,2]) # add controlled swap opeartion
swap_circ.H(0)
swap_circ.Measure(0,0) # Meaure the first qubit to the first classical register

If then append this swap_circ onto the circuit where you prepare your states then you can calculate the inner product bases on the measurement results. If any of this is unclear I'm happy to add more detail.

I can also prepare a small example for the docs

Screenshot 2022-09-07 at 11 44 32

from pytket-docs.

CalMacCQ avatar CalMacCQ commented on June 21, 2024

Are there particular examples on the outer product that you would find helpful? It would be good to know more detail about what you are looking for.

from pytket-docs.

Penghmed avatar Penghmed commented on June 21, 2024

Yes, I am interested: Φ1=(|00> − i|11>), Φ2=(|01> −|11>) and calculate <Φ1|Φ2> and |Φ1>|Φ2>

Thanks.

from pytket-docs.

CalMacCQ avatar CalMacCQ commented on June 21, 2024

Okay the inner product you mentioned can be worked out by hand to be equal to 1*i. This value will change if you normalise the states.

If you want to calculate inner products using circuits then the SWAP test I mentioned generalises for states with more qubits... You just add some extra CSWAP gates between the two registers. In this case the registers q[1] and q[2] will correspond to multi-qubit states.

the |phi1;> |phi2;> term you mentioned is a tensor product. There is some explanation of tensor products here https://www.quantiki.org/wiki/tensor-product.

The outer product of two statevectors is usually written |phi_1><phi_2| and the answer corresponds to a matrix rather than a scalar or a vector. I've included a screenshot of the outer product of your two states below.

Screenshot 2022-09-13 at 11 17 35

I hope this helps - let me know if there is more I can help with.

from pytket-docs.

CalMacCQ avatar CalMacCQ commented on June 21, 2024

I will close this issue for now - if you have further questions feel free to get in touch again.

You can also ask questions on our public slack channel -> https://tketusers.slack.com/join/shared_invite/zt-18qmsamj9-UqQFVdkRzxnXCcKtcarLRA#/shared-invite/email

from pytket-docs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.