Rotation gate with multiple parameters

Hello, I have a simple question. The single qubit rotation gate, like RX,RY,RZ only accepts one parameter,see qml.RX.
But we can still pass multiple parameters in Pennylane. see the code below.

dev = qml.device("default.qubit", wires=2)

@qml.qnode(dev)

def my_quantum_function(x, y):
    qml.RX(x, wires=0)
    qml.CNOT(wires=[0, 1])
    qml.RY(y, wires=1)
    return qml.state()

my_quantum_function([0.1,0.2,0.3], 0.2)
# below is the output:
tensor([[0.99376067+0.j        , 0.09970865+0.j        ,
         0.        +0.00498959j, 0.        -0.04972948j],
        [0.99003329+0.j        , 0.09933467+0.j        ,
         0.        +0.00996671j, 0.        -0.09933467j],
        [0.98383134+0.j        , 0.09871239+0.j        ,
         0.        +0.01491892j, 0.        -0.14869156j]], requires_grad=True)

Here we only used two qubits, but got 12 statevectors since RX gate is given three parameters, i.e., [0.1,0.2,0.3]. I’m wondering what is the detailed computation behind the three parameters or say why we get 12 statevectors.

One more question is that how to print out the statevector with computational basis,

dev = qml.device("default.qubit", wires=2)

@qml.qnode(dev)
def circuit():
    qml.Hadamard(wires=1)
    return qml.state()

circuit()

#below is the output: 
tensor([0.70710678+0.j, 0.70710678+0.j, 0.        +0.j, 0.        +0.j])

can we give a printout like 1/ \sqrt{2} |00> + 1/ \sqrt{2} |01> ? Thank you

Hey @neon, welcome to the forum! :rocket:

This is something called parameter broadcasting :slight_smile:. It’s something that was introduced a while back in PennyLane: PennyLane v0.24 released | PennyLane Blog

can we give a printout like …

Unfortunately that would require a significant amount of work on our end :sweat_smile:, so I can’t say that we will work on that in the future.

@isaacdevlugt Hi, thank you for the information. I’m new to QML and still confused. When we feed an array to RX gate, does it mean the single qubit is rotated with a given angle (the value in the array) sequentially? Or could you explain why we can get 12 statevectors. Thank you

Sure! Also, you get three statevectors, not 12 :slight_smile:.

We have a video on this actually!

Let me know if that helps.