Skip to content

Commit

Permalink
doc: add tags to equations for LaTeX rendering in RST docs (#112)
Browse files Browse the repository at this point in the history
Co-authored-by: Abe Coull <[email protected]>
  • Loading branch information
math411 and Abe Coull authored Jun 6, 2023
1 parent ab85786 commit 0e844e0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/braket/experimental/algorithms/qc_qmc/qc_qmc.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,9 @@ def local_energy_quantum( # noqa: C901
trial_state_circuit: Callable,
dev: qml.device,
) -> complex:
r"""This function estimates the integral $\\langle \\Psi_Q|H|\\phi_l\rangle$ with rotated basis.
r"""
This function estimates the integral :math:`$\\langle \\Psi_Q|H|\\phi_l\rangle$`
with rotated basis.
Args:
walker (ndarray): np.ndarray; matrix representation of the walker state, not necessarily
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,9 @@ def cost_layer(

@circuit.subroutine(register=True)
def decomposed_zz_gate(qubit0: int, qubit1: int, gamma: float) -> Circuit:
"""Return a circuit implementing exp(-i gamma Z_i Z_j) using CNOT gates if ZZ not supported.
"""
Return a circuit implementing :math:`exp(-i * \\gamma * Z_i * Z_j)` using CNOT gates
if ZZ not supported.
Args:
qubit0 (int): Index value for the controlling qubit for CNOT gate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ def gradient(self, params: np.ndarray) -> np.ndarray:
def _compute_kernel(px: np.ndarray, py: np.ndarray, sigma_list: List[float] = [0.1, 1]) -> float:
r"""Gaussian radial basis function (RBF) kernel.
`K(x, y) = sum_\sigma exp(-|x-y|^2/(2\sigma^2 ))`
.. math::
K(x, y) = sum_\sigma exp(-|x-y|^2/(2\sigma^2 ))
Args:
px (ndarray): Probability distribution
Expand All @@ -173,11 +174,13 @@ def mmd_loss(px: np.ndarray, py: np.ndarray, sigma_list: List[float] = [0.1, 1])
MMD determines if two distributions are equal by looking at the difference between
their means in feature space.
::
.. math::
MMD(x, y) = | \sum_{j=1}^N \phi(y_j) - \sum_{i=1}^N \phi(x_i) |_2^2
With a RBF kernel, we apply the kernel trick to expand MMD to
::
.. math::
MMD(x, y) = \sum_{j=1}^N \sum_{j'=1}^N k(y_j, y_{j'})
+ \sum_{i=1}^N \sum_{i'=1}^N k(x_i, x_{i'})
- 2 \sum_{j=1}^N \sum_{i=1}^N k(y_j, x_i)
Expand Down

0 comments on commit 0e844e0

Please sign in to comment.