title: Multiplication of complex numbers in python
body: <p>I am trying to simulate the propagation and reflectance of a light spectrum in multiple layers of materials through a method called &quot;transfer matrices&quot;, however when trying to calculate the propagation matrices P1 and P2 the matrices simply do not give what what they should give What I suspect is that it is a problem when operating with the complex number defined by j (<code>np.exp(-1j*p1)</code>). Could someone who has worked with complexes in python help me identify the problem?</p>
  <pre class="lang-py prettyprint-override"><code>import numpy as np
  import matplotlib.pyplot as plt
  import math
  
  Lambda_Cero = 1500*10**(-9) # resonance wavelenght
  nH = 2.32  # Material high refractive index
  nL = 1.38  # Material low refractive index
  na = 1     # air refractive index
  nb = 1.5  # Substrate refractive indes
  N = 5 # Numbers of layers
  
  m = 0
  r= []
  l1 = []
  for i in np.arange(250*10**(-9), 2000*10**(-9), 1*10**(-9)):
  
    r.append([])
    l1.append([])
    
    k1 = (2*np.pi*nL)/i
    d1 = Lambda_Cero/(4*nL)
    p1 = k1*d1
  
    k2 = (2*np.pi*nH)/i
    d2 = Lambda_Cero/(4*nH)
    p2 = k2*d2
  
    A1 = (nH+nL)/(2*nH)
    A2 = (nH-nL)/(2*nH)
    A3 = (nH+nL)/(2*nL)
    A4 = (nL-nH)/(2*nL)
  
  
    DLH = np.array([[A1, A2],[A2, A1]])
    DHL = np.array([[A3, A4],[A4, A3]])
    ##### Propagation P1 and P2                              
  
    P1 = np.array([[np.exp(1j*p1), 0], [0, np.exp(-1j*p1)]])
    P2 = np.array([[np.exp(1j*p2), 0], [0, np.exp(-1j*p2)]])
    
  
  
    M = DHL*P1*DLH*P2
    M_N = M**5
  
    #GaN y SiO2
    k1 = (2*np.pi*nL)/i
    d1 = Lambda_Cero/(4*nL)
    p1 = k1*d1
    A3 = (nL+nb)/(2*nb)
    A4 = (nL-nb)/(2*nb)
    DbL = np.array([[A3, A4],[A4, A3]])
  
    ##### Propagation P1
    P1 = np.array([[np.exp(p1*1j), 0], [0, np.exp(-p1*1j)]])
  
    #Ta2O5 and air
  
    A3 = (nH+na)/(2*na)
    A4 = (nH-na)/(2*na)
    DHa = np.array([[A3, A4],[A4, A3]])
    Mf = DHa*M_N*DbL*P1
    
    r[m].append(abs(Mf[1,0]/Mf[0,0]))
    #r[m] = abs(Mf[2,1]/Mf[1,1])
    l1[m].append(i)
    m = m+1
  
  print(M_N   )
  plt.plot(l1, r, &quot;-ob&quot;)
  plt.title(&quot;Interpolación lineal&quot;)
  plt.xlabel(&quot;x&quot;)
  plt.ylabel(&quot;y&quot;)
  plt.show()
  </code></pre>
  <p>This is the equation for the propagation:</p>
  <p><a href="https://i.stack.imgur.com/iwSUr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iwSUr.png" alt="enter image description here" /></a></p>