Skip to content

Exponentiation functionality for Quantum Hamiltonian Learning.

Notifications You must be signed in to change notification settings

jafanello/QHL_Exponentiation

 
 

Repository files navigation

QHL_Exponentiation

Exponentiation functionality for Quantum Hamiltonian Learning. Custom function for computing e^{-iHt} or e^{iHt} where H is a sparse, Hermitian matrix. If H is not Hermitian, the calculation will be incorrect in general.

To install this suite, clone the repository, go to the folder. Then type:

sudo pip install -e . 

Within Python:

import hamiltonian_exponentiation

Method

The primary function here, exp_ham, takes a Hamiltonian and a time, and computes e^{-iHt}. It does this by series expansion, truncating the series when it reaches the declared precision. e^{x} = x^0 / 0! + x^1 / 1! + ... + x^n/n!

In particular, the Hamiltonian H is a sparse, Hermitian matrix. This is recast to aH', such that all elements of H' are less than one, and a is some scalar. (Say timea = s, a scalar). The expansion is:

e^{-iHt} = e^{-i* a*t * H'} = e^{-i * s * H'} = I - i{s^1/1! } H^1 - {s^2/2! } H^2 + i{s^3/3! } H^3 + ...

Errors grow exponentially. It was observed that when s > 25, the difference between this exponentiation and the Pade approximation computed by linalg/scipy/scipy.sparse expm function, are of order 10^{-6}. This scalar_cutoff is a control: the user can determine how close to the Pade approximation is required. When this value is greater than the scalar_cutoff specified, the function defaults to using Python inbuilt functionality. Lookup scalar_cutoff Vs difference here: https://docs.google.com/spreadsheets/d/1Cs2l5HlAw82tCgqmLk3hG_GPNiEicXe9qWSNgEmMZyk/edit?usp=sharing.

Available functions

  1. random_hamiltonian(num_qubits)
  • gives a Hamiltonian matrix generated by random tensor products of Paulis.
  1. exp_ham(hamiltonian, time, plus_or_minus, precision, scalar_cutoff, print_method, trotterize_by)
  • Computes e^{-iHt} or e^{+iHt}.
  • Arguments:
    • hamiltonian: Hamiltonian matrix to be exponentiated.
    • time: time generated by heuristic.
    • plus_or_minus: +1.0 to compute e^{iHt}; -1.0 for e^{-iHt}. Default is -1.0.
    • precision: when matrix elements are changed by this amount or smaller, exponenitation is truncated at that step of summation.
    • scalar_cutoff: value of scalar_cutoff to use. See Method explanation above.
    • print_method: Set to True to print information about function internal working. Mostly useful to see whether it is defaulting to inbuilt python function.
    • trotterize_by: Number of time steps to trotterize by.

About

Exponentiation functionality for Quantum Hamiltonian Learning.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C++ 50.1%
  • Python 33.5%
  • Jupyter Notebook 16.1%
  • Other 0.3%