Python Forum
The formula in the function is not giving the correct value
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
The formula in the function is not giving the correct value
#1
Here is my function
def coefficients(_list,q_number):
    paulis = list(product([i,x,y,z],repeat=q_number))
    spaulis = list(product(['i','x','y','z'],repeat=q_number))
    #print(spaulis)
    result = []
    for k_index,kraus in enumerate(_list,start=0):
        print(kraus)
        for index, pauli in enumerate(paulis, start=0):
            a = 1/2*(np.trace(np.matmul(kraus,pauli)))
            result.append((a,spaulis[index],k_index))
    return result
i = np.array([[1, 0], [0, 1]])
x = np.array([[0, 1], [1, 0]])
y = np.array([[0,-1j],[1j,0]])
z = np.array([[1, 0], [0,-1]])
Here is my example list:
krausf=np.array([[[-9.84447177e-01-7.67061139e-18j,
          1.00575460e-03+1.82351449e-02j],
        [-1.08968355e-03+6.25615662e-03j,
         -9.78901978e-01-9.19498996e-03j]]]
The formula is a = 1/2*(np.trace(np.matmul(kraus,pauli))), let'stake pauli=i
I should find these result for i:
(-0.9816745775-0.004597494980000004j)
However, I am finding:
[-0.49222359-3.83530569e-18j, 0.00050288+9.11757245e-03j] from function. I can't see the point that I missed

What is happening?
Reply
#2
This line a = 1/2*(np.trace(np.matmul(kraus,pauli))) should be a = 1/2*(np.trace(np.matmul(kraus,pauli[0])))
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Python “Formula” Package: How do I parse Excel formula with a range of cells? JaneTan 1 2,691 Jul-12-2021, 11:09 AM
Last Post: jefsummers
  function not giving back total SephMon 1 1,689 Aug-25-2020, 12:46 PM
Last Post: deanhystad
  Getting the error like function not defined .. suggest correct code raghava 1 2,060 Feb-04-2020, 11:20 PM
Last Post: micseydel
  Not quite getting the correct Output from a function twinpiques 3 2,665 Aug-04-2019, 11:53 PM
Last Post: twinpiques
  Function not returning correct value ActualNoob 3 2,711 Jan-11-2019, 12:35 AM
Last Post: stullis
  Need help to correct my python function for fetching full data! PrateekG 2 2,921 May-27-2018, 06:39 AM
Last Post: PrateekG

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020