Fidelity Calculations

Fidelity Functions

RobustGRAPE.calculate_fidelity_and_derivativesFunction
calculate_fidelity_and_derivatives(fidelity_problem::FidelityRobustGRAPEProblem, x::Vector{<:Real})

Calculate the fidelity between the evolved unitary and target unitary, along with its derivatives.

Arguments

  • fidelity_problem::FidelityRobustGRAPEProblem: The fidelity problem definition
  • x::Vector{<:Real}: The optimization vector containing control parameters and additional parameters

Returns

A tuple with:

  • F: The fidelity value
  • F_dx: Combined derivatives with respect to all control parameters (both main and additional)
  • F_d2err: Second derivatives with respect to error sources
  • F_d2err_dx: Combined mixed derivatives for error and all control parameters
source
RobustGRAPE.optimize_fidelity_and_error_sourcesFunction
optimize_fidelity_and_error_sources(fidelity_problem::FidelityRobustGRAPEProblem, fidelity_parameters::FidelityRobustGRAPEParameters)

Optimizes quantum control pulses while considering robustness against error sources.

This is a high-level wrapper around Optim.optimize that:

  1. Combines fidelity optimization with error robustness
  2. Applies regularization to the control pulses
  3. Handles caching to avoid redundant calculations

Parameters

  • fidelity_problem::FidelityRobustGRAPEProblem: Problem definition including the Hamiltonian, target unitary, and error sources
  • fidelity_parameters::FidelityRobustGRAPEParameters: Optimization parameters including initial values, regularization, and solver configuration

Returns

  • An Optim.OptimizationResults object containing the optimization status, parameters, and diagnostics

Example

# Create a problem definition
problem = FidelityRobustGRAPEProblem(...)

# Create optimization parameters
params = FidelityRobustGRAPEParameters(
    x_initial = initial_x,
    regularization_functions = [regularization_cost_phase],
    regularization_coeff1 = [1e-6],
    regularization_coeff2 = [1e-6],
    error_source_coeff = [1e-3],
    iterations = 1000,
    solver_algorithm = LBFGS()
)

# Run the optimization
result = optimize_fidelity_and_error_sources(problem, params)

# Get optimized parameters
optimal_params = Optim.minimizer(result)
source

Error Analysis

RobustGRAPE.calculate_fidelity_responseFunction
calculate_fidelity_response(fidelity_problem::FidelityRobustGRAPEProblem, x::Vector{<:Real}, normalized_frequencies::Vector{<:Real})

Calculate the frequency-domain fidelity response function for error sources at specified frequencies.

The fidelity response function characterizes how sensitive the quantum gate is to noise at different frequencies. This is crucial for understanding robustness against various noise spectra and can guide the design of control pulses that are specifically robust against the dominant noise frequencies in a particular experimental setup.

Parameters

  • fidelity_problem::FidelityRobustGRAPEProblem: The fidelity problem definition
  • x::Vector{<:Real}: The control parameters vector
  • normalized_frequencies::Vector{<:Real}: Normalized frequencies at which to evaluate the response function

Returns

  • A matrix of dimensions (nfreq, nerr) containing the fidelity response function values for each error source at each frequency, where nfreq is the number of frequencies and nerr is the number of error sources.

Notes

  • Frequencies are normalized by Ω (the characteristic frequency of the system)
  • The response function is related to the error sensitivity: at zero frequency, the response function value is proportional to the static error sensitivity
  • Higher values indicate greater sensitivity to noise at that frequency
source
RobustGRAPE.calculate_fidelity_response_fftFunction
calculate_fidelity_response_fft(fidelity_problem::FidelityRobustGRAPEProblem, x::Vector{<:Real}; oversampling::Int = 1)

Calculate the frequency-domain fidelity response function using Fast Fourier Transform (FFT).

This function efficiently computes the frequency-domain fidelity response function for all error sources using FFT algorithms, which is computationally more efficient than direct calculation at specific frequencies. The implementation adds zero-padding to achieve frequency oversampling if requested.

Parameters

  • fidelity_problem::FidelityRobustGRAPEProblem: The fidelity problem definition
  • x::Vector{<:Real}: The control parameters vector
  • oversampling::Int = 1: Oversampling factor to increase the resolution of the frequency response

Returns

  • A tuple containing:
    • response_fct_ω: Matrix of dimensions (ntimes*oversampling, nerr) containing the fidelity response function values for each frequency and error source
    • norm_frequencies: Vector of normalized frequencies corresponding to the response function values

Notes

  • Frequencies are normalized by the quantum system's characteristic energy scale
  • The oversampling parameter allows for higher frequency resolution by zero-padding in the time domain
source
RobustGRAPE.calculate_expectation_valuesFunction
calculate_expectation_values(fidelity_problem::FidelityRobustGRAPEProblem, x::Vector{<:Real})

Calculate the time-dependent expectation values of error generators during the quantum evolution.

This function computes how the expectation values of the error generators evolve over time under the optimized control pulse sequence. This provides insight into how errors accumulate during the quantum gate implementation and can be used to visualize the error sensitivity profile over time.

Parameters

  • fidelity_problem::FidelityRobustGRAPEProblem: The fidelity problem definition
  • x::Vector{<:Real}: The control parameters vector

Returns

  • A matrix of dimensions (ntimes, nerr) containing the expectation values of each error operator at each time step of the evolution.

Notes

  • The calculation uses the cumulative sum of the interaction-picture error operators
  • Values are normalized by the dimension of the projector subspace
  • The time resolution is determined by the number of time steps in the problem definition
source