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.triangle

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

GitHub

Generates triangle 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)=A(2sawtooth(x,A,T,ϕ)+1)f(x) = A \left(-2\left|\text{sawtooth}(x, A, T, \phi)\right| + 1\right)

This a non-sinusoidal wave with linear ramping.

Parameters

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

Return type

Waveform

Example

import matplotlib.pyplot as plt
from qiskit.pulse.library import triangle
import numpy as np
 
duration = 100
amp = 1
freq = 1 / duration
triangle_wave = np.real(triangle(duration, amp, freq).samples)
plt.plot(range(duration), triangle_wave)
plt.show()
../_images/qiskit-pulse-library-triangle-1.png
Was this page helpful?
Report a bug or request content on GitHub.