Skip to main content

parameter_shift_gradient

Function parameter_shift_gradient 

Source
pub fn parameter_shift_gradient(
    circuit: &QaoaCircuit,
    gamma: &[f64],
    beta: &[f64],
) -> QcResult<(Vec<f64>, Vec<f64>)>
Expand description

Compute analytic gradients of the QAOA objective using the parameter-shift rule.

d/dθ E(θ) = 0.5 * [E(θ + π/2) - E(θ - π/2)]

Returns (d_gamma, d_beta) where each vector has length p.