qml.resource.SpectralNormError¶
- class SpectralNormError(error)[source]¶
Bases:
pennylane.resource.error.error.AlgorithmicError
Class representing the spectral norm error.
The spectral norm error is defined as the distance, in spectral norm, between the true unitary we intend to apply and the approximate unitary that is actually applied.
- Parameters
error (float) – The numerical value of the error
Example
>>> s1 = SpectralNormError(0.01) >>> s2 = SpectralNormError(0.02) >>> s1.combine(s2) SpectralNormError(0.03)
Methods
combine
(other)Combine two spectral norm errors.
get_error
(approximate_op, exact_op)Compute spectral norm error between two operators.
- combine(other)[source]¶
Combine two spectral norm errors.
- Parameters
other (SpectralNormError) – The other instance of error being combined.
- Returns
The total error after combination.
- Return type
Example
>>> s1 = SpectralNormError(0.01) >>> s2 = SpectralNormError(0.02) >>> s1.combine(s2) SpectralNormError(0.03)
- static get_error(approximate_op, exact_op)[source]¶
Compute spectral norm error between two operators.
- Parameters
- Returns
The error between the exact operator and its approximation.
- Return type
float
Example
>>> Op1 = qml.RY(0.40, 0) >>> Op2 = qml.RY(0.41, 0) >>> SpectralNormError.get_error(Op1, Op2) 0.004999994791668309