Skip to content

Expression

The Expression class represents a sum of MulGroup objects stored as a ndarray. It provides methods for simplifying the expression, substituting variables, differentiating with respect to a variable, and computing the Hermitian conjugate.


Parameters

  • expr (ndarray[MulGroup], optional):

    • A ndarray of MulGroup objects whose sum represents the overall expression.
    • Default: An empty array.

      Note: During initialization, any zero elements are removed from the internal representation.


Attributes

  • expr (ndarray[MulGroup]):

    • A ndarray of MulGroup objects whose sum represents the overall expression.
  • is_time_dependent (bool):

    • A flag indicating whether any element of the expression is time-dependent (i.e., contains the reserved RDSymbol t).
    • Determined automatically during initialization based on the expression's contents.

Methods

simplify(self, return_dict=False)

Simplifies the expression by combining similar MulGroup objects.

  • Parameters:

    • return_dict (bool, optional):
      • If True, returns a dictionary of simplified groups.
      • If False (default), returns a new Expression object with the simplified expression.
  • Returns:

    • An Expression object representing the simplified expression, or a dictionary of results if return_dict is set to True.

Note: The method extracts the function (fn), infinite (inf), and delta (delta) components from each MulGroup object. Groups with the same infinite and delta parts are combined by summing their function components. The simplified Expression is reconstructed using MulGroup objects.


subs(self, substitutions)

Substitutes variables within the expression.

  • Parameters:

    • substitutions (dict):
      • A mapping where keys are symbols to be replaced and values are the corresponding replacement expressions.
  • Returns:

    • A new Expression object with the substitutions applied.

diff(self, theta)

Differentiates the expression with respect to time using the MulGroup.diff method.

  • Parameters:

    • theta (RDSymbol):
      • The variable with respect to which the differentiation is performed.

        Note: This variable is the reserved RDSymbol t representing time.

  • Returns:

    • A new Expression object representing the derivative of the original expression.

    Note: If the expression is not time-dependent, the method returns an empty expression.


dagger(self)

Computes the Hermitian conjugate (dagger) of the expression.

  • Returns:

    • A new Expression object representing the Hermitian conjugate of the original expression.

License

SymPT is licensed under the MIT License. See the LICENSE file for details.


Citation

If you use SymPT in your research, please cite the following paper:

BibTeX Entry:

@misc{diotallevi2024symptcomprehensivetoolautomating,
      title={SymPT: a comprehensive tool for automating effective Hamiltonian derivations}, 
      author={Giovanni Francesco Diotallevi and Leander Reascos and Mónica Benito},
      year={2024},
      eprint={2412.10240},
      archivePrefix={arXiv},
      primaryClass={quant-ph},
      url={https://arxiv.org/abs/2412.10240}, 
}

APA Citation:

Diotallevi, G. F., Reascos, L., & Benito, M. (2024). SymPT: a comprehensive tool for automating effective Hamiltonian derivations. arXiv preprint arXiv:2412.10240.

IEEE Citation:

G. F. Diotallevi, L. Reascos, and M. Benito, "SymPT: a comprehensive tool for automating effective Hamiltonian derivations," arXiv preprint arXiv:2412.10240, 2024.


References