Skip to main contentIBM Quantum Documentation
This page is from an old version of Qiskit SDK and does not exist in the latest version. We recommend you migrate to the latest version. See the release notes for more information.

qiskit.pulse.library.sawtooth

sawtooth(duration, amp, freq=None, phase=0, name=None)

GitHub

Generates sawtooth wave Waveform.

For A=A= amp, T=T= period, and ϕ=\phi= phase, applies the midpoint sampling strategy to generate a discrete pulse sampled from the continuous function:

f(x)=2A(g(x)12+g(x))f(x) = 2 A \left( g(x) - \left\lfloor \frac{1}{2} + g(x) \right\rfloor\right)

where g(x)=x/T+ϕ/πg(x) = x/T + \phi/\pi.

Parameters

  • duration (int) – Duration of pulse. Must be greater than zero.
  • amp (complex) – Pulse amplitude. Wave range is [[- amp ,, amp ]].
  • freq (Optional[float]) – Pulse frequency, units of 1./dt. If None defaults to 1./duration.
  • phase (float) – Pulse phase.
  • name (Optional[str]) – Name of pulse.

Example

import matplotlib.pyplot as plt
from qiskit.pulse.library import sawtooth
import numpy as np
 
duration = 100
amp = 1
freq = 1 / duration
sawtooth_wave = np.real(sawtooth(duration, amp, freq).samples)
plt.plot(range(duration), sawtooth_wave)
[<matplotlib.lines.Line2D at 0x7fa9c1d4c7f0>]
../_images/qiskit.pulse.library.sawtooth_0_1.png

Return type

Waveform

Was this page helpful?
Report a bug or request content on GitHub.