Quanlse/Utils/Functions.py
def coherent(dim: int = 2, alpha: complex = 0 + 0j):
    """
    Generate a coherent state using displacement operator.

    :param dim: dimension of the coherent state truncated.
    :param alpha: the eigenvalue of the annihilation operator.
    """

    # Initialize a vacuum state
    psi0 = basis(dim, 0)
    a = destroy(dim).matrix
    adag = dagger(a)

    # construct a displacement operator
    disp = linalg.expm(alpha * adag - conj(alpha) * a)
    psi = disp @ psi0

    return psi

    Generate a coherent state using displacement operator.

    :param dim: dimension of the coherent state truncated.
    :param alpha: the eigenvalue of the annihilation operator.
    
Generate a coherent state using displacement operator.
Generate a coherent state using displacement operator .
def coherent(dim: int = 2, alpha: complex = 0 + 0j):
    psi0 = basis(dim, 0)
    a = destroy(dim).matrix
    adag = dagger(a)
    disp = linalg.expm(alpha * adag - conj(alpha) * a)
    psi = disp @ psi0
    return psi
def coherent ( dim : int = 2 , alpha : complex = 0 + 0j ) : psi0 = basis ( dim , 0 ) a = destroy ( dim ) . matrix adag = dagger ( a ) disp = linalg . expm ( alpha * adag - conj ( alpha ) * a ) psi = disp @ psi0 return psi
Generate a coherent state using displacement operator.
Generate a coherent state using displacement operator .
"""
    Generate a coherent state using displacement operator.

    :param dim: dimension of the coherent state truncated.
    :param alpha: the eigenvalue of the annihilation operator.
    """ # Initialize a vacuum state # construct a displacement operator
dim
int
dimension of the coherent state truncated.
dimension of the coherent state truncated .
alpha
complex
the eigenvalue of the annihilation operator.
the eigenvalue of the annihilation operator .