tfq.util.exponential
Stay organized with collections
Save and categorize content based on your preferences.
Return a Cirq circuit with exponential operator forms.
tfq.util.exponential(
operators, coefficients=None
)
Used in the notebooks
Construct an exponential form of given operators
and coefficients
.
Operators to be exponentiated are specified in operators
as
cirq.PauliSum
or cirq.PauliString
. Parameters are given by
coefficients
.
Note that only operators whose standard representations consist of terms
which all commute can be exponentiated. This allows use of the identity
exp(A+B+...) = exp(A)exp(B)... else there would need to be automatic
handling of Trotterization and convergence, which is not supported yet.
Args |
operators
|
Python list or tuple of cirq.PauliSum or
cirq.PauliString objects to be exponentiated.
Here are simple examples.
Let q = cirq.GridQubit(0, 0)
E.g. operator = 0.5 * X(q) -> exp(-i * 0.5 * X(q))
operator = 0.5 * cirq.PauliString({q: cirq.I})
-> exp(-i * 0.5)*np.eye(2)
Be careful of the negation and the PauliString of the identity gate.
|
coefficients
|
(Optional) Python list of Python str , float or
sympy.Symbol object of parameters. Defaults to None, then all
coefficients of operators are set to 1.0.
|
Returns |
A cirq.Circuit containing exponential form of given operators
and coefficients .
|
Raises |
TypeError
|
If operators (or its terms) is/are of an invalid type.
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-05-17 UTC.
[null,null,["Last updated 2024-05-17 UTC."],[],[],null,["# tfq.util.exponential\n\n\u003cbr /\u003e\n\n|------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/quantum/blob/v0.7.3/tensorflow_quantum/python/util.py#L728-L832) |\n\nReturn a Cirq circuit with exponential operator forms. \n\n tfq.util.exponential(\n operators, coefficients=None\n )\n\n### Used in the notebooks\n\n| Used in the tutorials |\n|-----------------------------------------------------------------------------|\n| - [Quantum data](https://www.tensorflow.org/quantum/tutorials/quantum_data) |\n\nConstruct an exponential form of given `operators` and `coefficients`.\nOperators to be exponentiated are specified in `operators` as\n[`cirq.PauliSum`](https://quantumai.google/reference/python/cirq/PauliSum) or [`cirq.PauliString`](https://quantumai.google/reference/python/cirq/PauliString). Parameters are given by\n`coefficients`.\n\nNote that only operators whose standard representations consist of terms\nwhich all commute can be exponentiated. This allows use of the identity\nexp(A+B+...) = exp(A)exp(B)... else there would need to be automatic\nhandling of Trotterization and convergence, which is not supported yet.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|----------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `operators` | Python `list` or `tuple` of [`cirq.PauliSum`](https://quantumai.google/reference/python/cirq/PauliSum) or [`cirq.PauliString`](https://quantumai.google/reference/python/cirq/PauliString) objects to be exponentiated. Here are simple examples. Let q = cirq.GridQubit(0, 0) E.g. operator = 0.5 \\* X(q) -\\\u003e exp(-i \\* 0.5 \\* X(q)) operator = 0.5 \\* cirq.PauliString({q: cirq.I}) -\\\u003e exp(-i \\* 0.5)\\*np.eye(2) Be careful of the negation and the PauliString of the identity gate. |\n| `coefficients` | (Optional) Python `list` of Python `str`, `float` or `sympy.Symbol` object of parameters. Defaults to None, then all coefficients of `operators` are set to 1.0. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| A [`cirq.Circuit`](https://quantumai.google/reference/python/cirq/Circuit) containing exponential form of given `operators` and `coefficients`. ||\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ------ ||\n|-------------|----------------------------------------------------------|\n| `TypeError` | If `operators` (or its terms) is/are of an invalid type. |\n\n\u003cbr /\u003e"]]