Graph.real_fourier_pwc_signal(duration, segment_count, initial_coefficient_lower_bound=-1, initial_coefficient_upper_bound=1, fixed_frequencies=None, optimizable_frequency_count=None, randomized_frequency_count=None, *, name=None)

Create a piecewise-constant signal constructed from Fourier components.

Use this function to create a signal defined in terms of Fourier (sine/cosine) basis signals that can be optimized by varying their coefficients and, optionally, their frequencies.


  • duration (float) – The total duration τ\tau
  • segment_count (int) – The number of segments NN
  • initial_coefficient_lower_bound (float , optional) – The lower bound cminc_\mathrm{min}
  • initial_coefficient_upper_bound (float , optional) – The upper bound cmaxc_\mathrm{max}
  • fixed_frequencies (np.ndarray or None , optional) – A 1D array object containing the fixed non-zero frequencies {fm}\{f_m\}
  • optimizable_frequency_count (int or None , optional) – The number of non-zero frequencies MM
  • randomized_frequency_count (int or None , optional) – The number of non-zero frequencies MM
  • name (str or None , optional) – The name of the node.


The optimizable, real-valued, piecewise-constant signal built from the appropriate Fourier components.

Return type



You must provide exactly one of fixed_frequencies, optimizable_frequency_count, or randomized_frequency_count.


Graph.real_fourier_stf_signal : Corresponding operation for Stf.


This function sets the basis signal frequencies {fm}\{f_m\}

  • For fixed frequencies, you provide the frequencies directly.
  • For optimizable frequencies, you provide the number of frequencies MM, and this function creates MM unbounded optimizable variables {fm}\{f_m\}, with initial values in the ranges {[(m1)/τ,m/τ]}\{[(m-1)/\tau, m/\tau]\}
  • For randomized frequencies, you provide the number of frequencies MM, and this function creates MM randomized constants {fm}\{f_m\} in the ranges {[(m1)/τ,m/τ]}\{[(m-1)/\tau, m/\tau]\}

After this function creates the MM frequencies {fm}\{f_m\}

α(t)=v0+m=1M[vmcos(2πtfm)+wmsin(2πtfm)], \alpha^\prime(t) = v_0 + \sum_{m=1}^M [ v_m \cos(2\pi t f_m) + w_m \sin(2\pi t f_m) ],

where {vm,wm}\{v_m,w_m\} are (unbounded) optimizable variables, with initial values bounded by cminc_\mathrm{min} and cmaxc_\mathrm{max}. This function produces the final piecewise-constant signal α(t)\alpha(t) by sampling α(t)\alpha^\prime(t) at NN equally spaced points along the duration τ\tau

You can use the signals created by this function for chopped random basis (CRAB) optimization 1.


[1] P. Doria, T. Calarco, and S. Montangero, Phys. Rev. Lett. 106, 190501 (2011).


See the “Fourier-basis optimization on a qutrit” example in the How to optimize controls using arbitrary basis functions user guide.

Was this useful?