# cirq.ops.PhasedFSimGate

General excitation-preserving two-qubit gate.

Inherits From: `InterchangeableQubitsGate`, `Gate`

The unitary matrix of PhasedFSimGate(θ, ζ, χ, γ, φ) is:

``````[[1,                       0,                       0,            0],
[0,    exp(-iγ - iζ) cos(θ), -i exp(-iγ + iχ) sin(θ),            0],
[0, -i exp(-iγ - iχ) sin(θ),    exp(-iγ + iζ) cos(θ),            0],
[0,                       0,                       0, exp(-2iγ-iφ)]].
``````

This parametrization follows eq (18) in https://arxiv.org/abs/2010.07965 See also eq (43) in https://arxiv.org/abs/1910.11333 for an older variant which uses the same θ and φ parameters, but its three phase angles have different names and opposite sign. Specifically, ∆+ angle corresponds to -γ, ∆- corresponds to -ζ and ∆-,off corresponds to -χ.

Another useful parametrization of PhasedFSimGate is based on the fact that the gate is equivalent up to global phase to the following circuit:

``````0: ───Rz(α0)───FSim(θ, φ)───Rz(β0)───
│
1: ───Rz(α1)───FSim(θ, φ)───Rz(β1)───
``````

where α0 and α1 are Rz angles to be applied before the core FSimGate, β0 and β1 are Rz angles to be applied after FSimGate and θ and φ specify the core FSimGate. Use the static factory function from_fsim_rz to instantiate the gate using this parametrization.

Note that the θ and φ parameters in the two parametrizations are the same.

The matrix above is block diagonal where the middle block may be any element of U(2) and the bottom right block may be any element of U(1). Consequently, five real parameters are required to specify an instance of PhasedFSimGate. Therefore, the second parametrization is not injective. Indeed, for any angle δ

``````cirq.PhasedFSimGate.from_fsim_rz(θ, φ, (α0, α1), (β0, β1))
``````

and

``````cirq.PhasedFSimGate.from_fsim_rz(θ, φ,
(α0 + δ, α1 + δ),
(β0 - δ, β1 - δ))
``````

specify the same gate and therefore the two instances will compare as equal up to numerical error. Another consequence of the non-injective character of the second parametrization is the fact that the properties rz_angles_before and rz_angles_after may return different Rz angles than the ones used in the call to from_fsim_rz.

This gate is generally not symmetric under exchange of qubits. It becomes symmetric if both of the following conditions are satisfied:

• ζ = kπ or θ = π/2 + lπ for k and l integers,
• χ = kπ or θ = lπ for k and l integers.

`theta` Swap angle on the `|01⟩` `|10⟩` subspace, in radians. See class docstring above for details.
`zeta` One of the phase angles, in radians. See class docstring above for details.
`chi` One of the phase angles, in radians. See class docstring above for details.
`gamma` One of the phase angles, in radians. See class docstring above for details.
`phi` Controlled phase angle, in radians. See class docstring above for details.

`rz_angles_after` Returns 2-tuple of phase angles applied to qubits after FSimGate.
`rz_angles_before` Returns 2-tuple of phase angles applied to qubits before FSimGate.

## Methods

### `controlled`

View source

Returns a controlled version of this gate. If no arguments are specified, defaults to a single qubit control.

num_controls: Total number of control qubits. control_values: For which control qubit values to apply the sub gate. A sequence of length `num_controls` where each entry is an integer (or set of integers) corresponding to the qubit value (or set of possible values) where that control is enabled. When all controls are enabled, the sub gate is applied. If unspecified, control values default to 1. control_qid_shape: The qid shape of the controls. A tuple of the expected dimension of each control qid. Defaults to `(2,) * num_controls`. Specify this argument when using qudits.

### `from_fsim_rz`

View source

Creates PhasedFSimGate using an alternate parametrization.

Args
`theta` Swap angle on the `|01⟩` `|10⟩` subspace, in radians. See class docstring above for details.
`phi` Controlled phase angle, in radians. See class docstring above for details.
`rz_angles_before` 2-tuple of phase angles to apply to each qubit before the core FSimGate. See class docstring for details.
`rz_angles_after` 2-tuple of phase angles to apply to each qubit after the core FSimGate. See class docstring for details.

### `num_qubits`

View source

The number of qubits this gate acts on.

### `on`

View source

Returns an application of this gate to the given qubits.

Args
`*qubits` The collection of qubits to potentially apply the gate to.

### `on_each`

View source

Returns a list of operations applying the gate to all targets.

Args
`*targets` The qubits to apply this gate to. For single-qubit gates this can be provided as varargs or a combination of nested iterables. For multi-qubit gates this must be provided as an `Iterable[Sequence[Qid]]`, where each sequence has `num_qubits` qubits.

Returns
Operations applying this gate to the target qubits.

Raises
`ValueError` If targets are not instances of Qid or Iterable[Qid]. If the gate qubit number is incompatible.

### `qubit_index_to_equivalence_group_key`

View source

Returns a key that differs between non-interchangeable qubits.

### `validate_args`

View source

Checks if this gate can be applied to the given qubits.

By default checks that:

• inputs are of type `Qid`
• len(qubits) == num_qubits()
• qubit_i.dimension == qid_shape[i] for all qubits

Child classes can override. The child implementation should call `super().validate_args(qubits)` then do custom checks.

Args
`qubits` The sequence of qubits to potentially apply the gate to.

#### Throws:

• `ValueError`: The gate can't be applied to the qubits.

View source

View source

View source

### `__call__`

View source

Call self as a function.

View source

View source

View source

View source

View source

View source

View source

### `__truediv__`

View source

[{ "type": "thumb-down", "id": "missingTheInformationINeed", "label":"Missing the information I need" },{ "type": "thumb-down", "id": "tooComplicatedTooManySteps", "label":"Too complicated / too many steps" },{ "type": "thumb-down", "id": "outOfDate", "label":"Out of date" },{ "type": "thumb-down", "id": "samplesCodeIssue", "label":"Samples / code issue" },{ "type": "thumb-down", "id": "otherDown", "label":"Other" }]
[{ "type": "thumb-up", "id": "easyToUnderstand", "label":"Easy to understand" },{ "type": "thumb-up", "id": "solvedMyProblem", "label":"Solved my problem" },{ "type": "thumb-up", "id": "otherUp", "label":"Other" }]