# Quantum Phase Estimation for T Gate Returning Varying Results

**URL:** <https://discuss.pennylane.ai/t/quantum-phase-estimation-for-t-gate-returning-varying-results/3182>\
**Category:** PennyLane Development\
**Created:** [July 12, 2023, 4:44pm UTC](https://discuss.pennylane.ai/t/quantum-phase-estimation-for-t-gate-returning-varying-results/3182 "2023-07-12T16:44:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mushahid\_Khan](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/mushahid_khan/32/1591_2.png) [@Mushahid\_Khan](https://discuss.pennylane.ai/u/Mushahid_Khan)\
**Post date:** [July 12, 2023, 4:44pm UTC](https://discuss.pennylane.ai/t/quantum-phase-estimation-for-t-gate-returning-varying-results/3182/1 "2023-07-12T16:44:43Z")

</div>

Hello,

I am trying to do Quantum Phase Estimation with qml.T gate. However I keep getting varying results when i call the qnode multiple times. I should be getting the same results. What could be causing this? Here is my code:

```auto
import pennylane as qml
from pennylane import numpy as np

U = qml.T.compute_matrix()
eigvals, eigvecs = np.linalg.eig(U)
target_eigvec = eigvecs[:, 0]
target_eigval = eigvals[0]

@qml.qnode(dev)
def quantum_phase_estimation():

    for wire in estimation_wires:
        qml.Hadamard(wires=wire)
        
    qml.MottonenStatePreparation(target_eigvec, wires=target_wires)
    
    for power_of_two, control_wire in enumerate(estimation_wires[::-1]):
        qml.ControlledQubitUnitary(
            np.linalg.matrix_power(U, 2 ** power_of_two), 
            control_wires=control_wire,
            wires=target_wires
        )
        
    qml.adjoint(qml.QFT)(wires=estimation_wires)
    
    return qml.sample(wires=estimation_wires)

```

When I run the qnode for multiple iterations i get the following results:  
[1 1 1]  
[1 1 1]  
[0 0 0]  
[0 0 0]  
[1 1 1]  
[1 1 1]  
[0 0 0]  
[0 0 0]  
[1 1 1]  
[0 0 1]  
[1 1 1]  
[0 0 0]  
[1 1 1]  
[1 1 1]  
[1 1 1]  
[0 0 1]  
[1 1 1]  
[1 1 1]  
[1 1 1]  
[1 1 1]

```auto

```

---

<div class="post-metadata">

**Author:** ![isaacdevlugt](https://yyz2.discourse-cdn.com/flex012/user_avatar/discuss.pennylane.ai/isaacdevlugt/32/1159_2.png) [@isaacdevlugt](https://discuss.pennylane.ai/u/isaacdevlugt)\
**Post date:** [July 13, 2023, 4:03pm UTC](https://discuss.pennylane.ai/t/quantum-phase-estimation-for-t-gate-returning-varying-results/3182/2 "2023-07-13T16:03:11Z")

</div>

Hey @Mushahid_Khan!

I can’t run your code because I’m missing several variable definitions. But, because you’re using `qml.sample` as the measurement, the outcome will be probabilistic in general.

If you provide the missing pieces of your code, I can try to help you further 🙂.
