Code Monkey home page Code Monkey logo

Comments (8)

Strilanc avatar Strilanc commented on June 14, 2024

half_turns=2 is the identity up to global phase. The "thing being turned" is the relative phase between the |0> and |1> states, which has increased by 180 degrees when half_turns=1.

Dave also found this terminology confusing/objection-worthy. I will keep track of whether more people find it confusing, and if there's too many we'll change it.

from cirq.

dkafri avatar dkafri commented on June 14, 2024

From discussions I've had with others on the team, at least 3 other people using Cirq have found this confusing. Two have reported adding bugs to their code due to misunderstanding what half_turns means. I suggest using `periods', with periods=1.0 corresponding to exactly the identity (not up to global phase).

from cirq.

vtomole avatar vtomole commented on June 14, 2024

How about "degrees" instead? cirq.RZ(qubit, 90)

from cirq.

Strilanc avatar Strilanc commented on June 14, 2024

What do people think of exponent instead of half_turns? That's unambigous.

from cirq.

kevinsung avatar kevinsung commented on June 14, 2024

I strongly agree with exponent.

from cirq.

dkafri avatar dkafri commented on June 14, 2024

I think you should not need to know the specific convention of the gate in order to guess what the argument should be. For example, is cirq.RZ(theta) equal to

exp(i theta \sigma_z)

or

|0 >< 0 | + exp(i theta) |1 > < 1 |

In the first case, the period is \theta = \pi, while in the second case the period is \theta = \2 pi.
But if I specify theta = 0.5 periods , I know that in both cases I will get a Z gate.

from cirq.

vtomole avatar vtomole commented on June 14, 2024

cirq.RZ(theta)= exp(-i * Z * theta/2) It's textbook definition.

from cirq.

Strilanc avatar Strilanc commented on June 14, 2024

This has now been fixed. cirq.ZPowGate takes an exponent, and cirq.Rz takes rads.

from cirq.

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.