class_docstr: Estimate the number of non-Clifford gates and logical qubits for a quantum phase estimation
  algorithm in first quantization using a plane-wave basis.
  
  To estimate the gate and qubit costs for implementing this method, the number of plane waves,
  the number of electrons and the lattice vectors need to be defined. The costs can then be
  computed using the functions :func:`~.pennylane.resource.FirstQuantization.gate_cost` and
  :func:`~.pennylane.resource.FirstQuantization.qubit_cost` with a target error that has the default
  value of 0.0016 Ha (chemical accuracy). Atomic units are used throughout the class.
  
  Args:
      n (int): number of plane waves
      eta (int): number of electrons
      omega (float): unit cell volume
      error (float): target error in the algorithm
      charge (int): total electric charge of the system
      br (int): number of bits for ancilla qubit rotation
      vectors (array[float]): lattice vectors
  
  **Example**
  
  >>> n = 100000
  >>> eta = 156
  >>> vectors = np.array([[10.46219511,  0.00000000,  0.00000000],
  ...                     [ 0.00000000, 10.46219511,  0.00000000],
  ...                     [ 0.00000000,  0.00000000, 10.46219511]])
  >>> algo = FirstQuantization(n, eta, vectors=vectors)
  >>> print(algo.lamb,  # the 1-Norm of the Hamiltonian
  >>>       algo.gates, # estimated number of non-Clifford gates
  >>>       algo.qubits # estimated number of logical qubits
  >>>       )
  649912.4804278888 1.1e+13 4416
  
  .. details::
      :title: Theory
  
      Following `PRX Quantum 2, 040332 (2021) <https://link.aps.org/doi/10.1103/PRXQuantum.2.040332>`_
      , the target algorithm error, :math:`\epsilon`, is distributed among four different sources
      of error using Eq. (131)
  
      .. math::
          \epsilon^2 \geq \epsilon_{qpe}^2 + (\epsilon_{\mathcal{M}} + \epsilon_R + \epsilon_T)^2,
  
      where :math:`\epsilon_{qpe}` is the quantum phase estimation error and
      :math:`\epsilon_{\mathcal{M}}`, :math:`\epsilon_R`, and :math:`\epsilon_T` are defined in
      Eqs. (132-134).
  
      Here, we fix :math:`\epsilon_{\mathcal{M}} = \epsilon_R = \epsilon_T = \alpha \epsilon` with
      a default value of :math:`\alpha = 0.01` and obtain
  
      .. math::
          \epsilon_{qpe} = \sqrt{\epsilon^2 [1 - (3 \alpha)^2]}.
  
      Note that the user only needs to define the target algorithm error :math:`\epsilon`. The
      error distribution takes place inside the functions.
class_docstr_tok: ["Estimate","the","number","of","non-Clifford","gates","and","logical","qubits","for","a","quantum","phase","estimation","algorithm","in","first","quantization","using","a","plane-wave","basis",".","To","estimate","the","gate","and","qubit","costs","for","implementing","this","method",",","the","number","of","plane","waves",",","the","number","of","electrons","and","the","lattice","vectors","need","to","be","defined",".","The","costs","can","then","be","computed","using","the","functions",":","func",":","`","~.pennylane.resource.FirstQuantization.gate_cost","`","and",":","func",":","`","~.pennylane.resource.FirstQuantization.qubit_cost","`","with","a","target","error","that","has","the","default","value","of","0.0016","Ha","(","chemical","accuracy",")",".","Atomic","units","are","used","throughout","the","class",".","Args",":","n","(","int",")",":","number","of","plane","waves","eta","(","int",")",":","number","of","electrons","omega","(","float",")",":","unit","cell","volume","error","(","float",")",":","target","error","in","the","algorithm","charge","(","int",")",":","total","electric","charge","of","the","system","br","(","int",")",":","number","of","bits","for","ancilla","qubit","rotation","vectors","(","array","[","float","]",")",":","lattice","vectors","*","*","Example","*","*",">",">",">","n","=","100000",">",">",">","eta","=","156",">",">",">","vectors","=","np.array","(","[","[","10.46219511",",","0.00000000",",","0.00000000","]",",","...","[","0.00000000",",","10.46219511",",","0.00000000","]",",","...","[","0.00000000",",","0.00000000",",","10.46219511","]","]",")",">",">",">","algo","=","FirstQuantization","(","n",",","eta",",","vectors=vectors",")",">",">",">","print","(","algo.lamb",",","#","the","1-Norm","of","the","Hamiltonian",">",">",">","algo.gates",",","#","estimated","number","of","non-Clifford","gates",">",">",">","algo.qubits","#","estimated","number","of","logical","qubits",">",">",">",")","649912.4804278888","1.1e+13","4416","..","details",":",":",":","title",":","Theory","Following","`","PRX","Quantum","2",",","040332","(","2021",")","<","https",":","\/\/link.aps.org\/doi\/10.1103\/PRXQuantum.2.040332",">","`","_",",","the","target","algorithm","error",",",":","math",":","`","\\epsilon","`",",","is","distributed","among","four","different","sources","of","error","using","Eq",".","(","131",")","..","math",":",":","\\epsilon^2","\\geq","\\epsilon_","{","qpe","}","^2","+","(","\\epsilon_","{","\\mathcal","{","M","}","}","+","\\epsilon_R","+","\\epsilon_T",")","^2",",","where",":","math",":","`","\\epsilon_","{","qpe","}","`","is","the","quantum","phase","estimation","error","and",":","math",":","`","\\epsilon_","{","\\mathcal","{","M","}","}","`",",",":","math",":","`","\\epsilon_R","`",",","and",":","math",":","`","\\epsilon_T","`","are","defined","in","Eqs",".","(","132-134",")",".","Here",",","we","fix",":","math",":","`","\\epsilon_","{","\\mathcal","{","M","}","}","=","\\epsilon_R","=","\\epsilon_T","=","\\alpha","\\epsilon","`","with","a","default","value","of",":","math",":","`","\\alpha","=","0.01","`","and","obtain","..","math",":",":","\\epsilon_","{","qpe","}","=","\\sqrt","{","\\epsilon^2","[","1","-","(","3","\\alpha",")","^2","]","}",".","Note","that","the","user","only","needs","to","define","the","target","algorithm","error",":","math",":","`","\\epsilon","`",".","The","error","distribution","takes","place","inside","the","functions","."]
docstr: Return the number of calls to the unitary needed to achieve the desired error in quantum
  phase estimation.
  
  The expression for computing the cost is taken from Eq. (125) of
  [`PRX Quantum 2, 040332 (2021) <https://link.aps.org/doi/10.1103/PRXQuantum.2.040332>`_].
  
  Args:
      n (int): number of plane waves
      eta (int): number of electrons
      omega (float): unit cell volume
      error (float): target error in the algorithm
      br (int): number of bits for ancilla qubit rotation
      charge (int): total electric charge of the system
      cubic (bool): True if the unit cell is cubic
      vectors (array[float]): lattice vectors
  
  Returns:
      int: number of calls to unitary
  
  **Example**
  
  >>> n = 100000
  >>> eta = 156
  >>> omega = 1145.166
  >>> error = 0.01
  >>> estimation_cost(n, eta, omega, error)
  102133985
docstr_tok: ["Return","the","number","of","calls","to","the","unitary","needed","to","achieve","the","desired","error","in","quantum","phase","estimation",".","The","expression","for","computing","the","cost","is","taken","from","Eq",".","(","125",")","of","[","`","PRX","Quantum","2",",","040332","(","2021",")","<","https",":","\/\/link.aps.org\/doi\/10.1103\/PRXQuantum.2.040332",">","`","_","]",".","Args",":","n","(","int",")",":","number","of","plane","waves","eta","(","int",")",":","number","of","electrons","omega","(","float",")",":","unit","cell","volume","error","(","float",")",":","target","error","in","the","algorithm","br","(","int",")",":","number","of","bits","for","ancilla","qubit","rotation","charge","(","int",")",":","total","electric","charge","of","the","system","cubic","(","bool",")",":","True","if","the","unit","cell","is","cubic","vectors","(","array","[","float","]",")",":","lattice","vectors","Returns",":","int",":","number","of","calls","to","unitary","*","*","Example","*","*",">",">",">","n","=","100000",">",">",">","eta","=","156",">",">",">","omega","=","1145.166",">",">",">","error","=","0.01",">",">",">","estimation_cost","(","n",",","eta",",","omega",",","error",")","102133985"]
code: def estimation_cost(
      n, eta, omega, error, br=7, charge=0, cubic=True, vectors=None
  ):
      r"""Return the number of calls to the unitary needed to achieve the desired error in quantum
      phase estimation.
  
      The expression for computing the cost is taken from Eq. (125) of
      [`PRX Quantum 2, 040332 (2021) <https://link.aps.org/doi/10.1103/PRXQuantum.2.040332>`_].
  
      Args:
          n (int): number of plane waves
          eta (int): number of electrons
          omega (float): unit cell volume
          error (float): target error in the algorithm
          br (int): number of bits for ancilla qubit rotation
          charge (int): total electric charge of the system
          cubic (bool): True if the unit cell is cubic
          vectors (array[float]): lattice vectors
  
      Returns:
          int: number of calls to unitary
  
      **Example**
  
      >>> n = 100000
      >>> eta = 156
      >>> omega = 1145.166
      >>> error = 0.01
      >>> estimation_cost(n, eta, omega, error)
      102133985
      """
      if error <= 0.0:
          raise ValueError(
              "The target error must be greater than zero."
          )
  
      lamb = FirstQuantization.norm(
          n,
          eta,
          omega,
          error,
          br=br,
          charge=charge,
          cubic=cubic,
          vectors=vectors,
      )
  
      if cubic:
          alpha = 0.01
          # qpe_error obtained to satisfy inequality (131)
          error_qpe = np.sqrt(error**2 * (1 - (3 * alpha) ** 2))
      else:
          alpha = 0.0248759298
          # qpe_error obtained to satisfy inequality (131)
          error_qpe = np.sqrt(error**2 * (1 - (4 * alpha) ** 2))
  
      return int(np.ceil(np.pi * lamb / (2 * error_qpe)))
  
file_path: pennylane/pennylane/resource/first_quantization.py
imports: import numpy
  from scipy import integrate
  from pennylane.operation import AnyWires, Operation
label_desc: Use image node_id 8 for calling the FirstQuantization obj's underlying member method code with example usage: obj.estimation_cost(n, eta, omega, error, br, charge, cubic, vectors) and returns: int