# trapdiff.m

Directional derivatives for the trapezium product quadrature published by Iserles and Norsett (see Corollary 3.3) in (https://doi.org/10.1098/rsta.1999.0362). The derivatives are of the following propagator:

expm(-i*((HL+HR)/2+i*dt*(sqrt(3)/12)*[HL,HR])*dt)

with respect to the coefficients cL, cR in the evolution generators HL and HR on the left and the right side of the interval respectively. Evolution generators HL and HR are split into the drift part Ho and the control part Hc, such that HL=Ho+cL*Hc and HR=Ho+cR*Hc on the left and the right edge of the interval. The derivatives are calculated using Eq 16 of Goodwin and Kuprov (https://doi.org/10.1063/1.4928978).

## Syntax

[DL,DR]=trapdiff(spin_system,Hd,Hc,dt,cL,cR)

## Arguments

Hd - a cell array of two matrices containing drift generators at the left (first element) and the right (second element) edge of the interval Hc - control operator or superoperator dt - interval duration, seconds cL - control operator coefficient at the left edge of the interval cR - control operator coefficient at the right edge of the interval

## Outputs

DL - derivative of the interval propagator with respect to cL DR - derivative of the interval propagator with respect to cR

## See also

Numerical Infrastructure, Optimal control module, dirdiff.m

*Version 2.7, authors: Uluk Rasulov, Ilya Kuprov*