Triangle wave

Last updated
Triangle wave
Triangle-td and fd.png
A bandlimited triangle wave [1] pictured in the time domain (top) and frequency domain (bottom). The fundamental is at 220 Hz (A3).
General information
General definition
Fields of applicationElectronics, synthesizers
Domain, codomain and image
Domain
Codomain
Basic features
Parity Odd
Period 1
Specific features
Root
Derivative Square wave
Fourier series

A triangular wave or triangle wave is a non-sinusoidal waveform named for its triangular shape. It is a periodic, piecewise linear, continuous real function.

Contents

Like a square wave, the triangle wave contains only odd harmonics. However, the higher harmonics roll off much faster than in a square wave (proportional to the inverse square of the harmonic number as opposed to just the inverse).

Definitions

Sine, square, triangle, and sawtooth waveforms Waveforms.svg
Sine, square, triangle, and sawtooth waveforms

Definition

A triangle wave of period p that spans the range [0, 1] is defined as

where is the floor function. This can be seen to be the absolute value of a shifted sawtooth wave.

For a triangle wave spanning the range [−1, 1] the expression becomes

Triangle wave with amplitude = 5, period = 4 Triangle wave with amplitude=5, period=4.png
Triangle wave with amplitude = 5, period = 4

A more general equation for a triangle wave with amplitude and period using the modulo operation and absolute value is

For example, for a triangle wave with amplitude 5 and period 4:

A phase shift can be obtained by altering the value of the term, and the vertical offset can be adjusted by altering the value of the term.

As this only uses the modulo operation and absolute value, it can be used to simply implement a triangle wave on hardware electronics.

Note that in many programming languages, the % operator is a remainder operator (with result the same sign as the dividend), not a modulo operator; the modulo operation can be obtained by using ((x % p) + p) % p in place of x % p. In e.g. JavaScript, this results in an equation of the form 4*a/p * Math.abs((((x - p/4) % p) + p) % p - p/2) - a.

Relation to the square wave

The triangle wave can also be expressed as the integral of the square wave:

Expression in trigonometric functions

A triangle wave with period p and amplitude a can be expressed in terms of sine and arcsine (whose value ranges from −π/2 to π/2):

The identity can be used to convert from a triangle "sine" wave to a triangular "cosine" wave. This phase-shifted triangle wave can also be expressed with cosine and arccosine:

Expressed as alternating linear functions

Another definition of the triangle wave, with range from −1 to 1 and period p, is

Harmonics

Animation of the additive synthesis of a triangle wave with an increasing number of harmonics. See Fourier Analysis for a mathematical description. Synthesis triangle.gif
Animation of the additive synthesis of a triangle wave with an increasing number of harmonics. See Fourier Analysis for a mathematical description.

It is possible to approximate a triangle wave with additive synthesis by summing odd harmonics of the fundamental while multiplying every other odd harmonic by −1 (or, equivalently, changing its phase by π) and multiplying the amplitude of the harmonics by one over the square of their mode number, n (which is equivalent to one over the square of their relative frequency to the fundamental).

The above can be summarised mathematically as follows:

where N is the number of harmonics to include in the approximation, t is the independent variable (e.g. time for sound waves), is the fundamental frequency, and i is the harmonic label which is related to its mode number by .

This infinite Fourier series converges quickly to the triangle wave as N tends to infinity, as shown in the animation.

Arc length

The arc length per period for a triangle wave, denoted by s, is given in terms of the amplitude a and period length p by

See also

Related Research Articles

<span class="mw-page-title-main">Phase (waves)</span> The elapsed fraction of a cycle of a periodic function

In physics and mathematics, the phase of a wave or other periodic function of some real variable is an angle-like quantity representing the fraction of the cycle covered up to . It is expressed in such a scale that it varies by one full turn as the variable goes through each period. It may be measured in any angular unit such as degrees or radians, thus increasing by 360° or as the variable completes a full period.

<span class="mw-page-title-main">Trigonometric functions</span> Functions of an angle

In mathematics, the trigonometric functions are real functions which relate an angle of a right-angled triangle to ratios of two side lengths. They are widely used in all sciences that are related to geometry, such as navigation, solid mechanics, celestial mechanics, geodesy, and many others. They are among the simplest periodic functions, and as such are also widely used for studying periodic phenomena through Fourier analysis.

<span class="mw-page-title-main">Standing wave</span> Wave that remains in a constant position

In physics, a standing wave, also known as a stationary wave, is a wave that oscillates in time but whose peak amplitude profile does not move in space. The peak amplitude of the wave oscillations at any point in space is constant with respect to time, and the oscillations at different points throughout the wave are in phase. The locations at which the absolute value of the amplitude is minimum are called nodes, and the locations where the absolute value of the amplitude is maximum are called antinodes.

<span class="mw-page-title-main">Sawtooth wave</span> Non-sinusoidal waveform

The sawtooth wave is a kind of non-sinusoidal waveform. It is so named based on its resemblance to the teeth of a plain-toothed saw with a zero rake angle. A single sawtooth, or an intermittently triggered sawtooth, is called a ramp waveform.

<span class="mw-page-title-main">Floor and ceiling functions</span> Nearest integers from a number

In mathematics, the floor function (or greatest integer function) is the function that takes as input a real number x, and gives as output the greatest integer less than or equal to x, denoted x or floor(x). Similarly, the ceiling function maps x to the smallest integer greater than or equal to x, denoted x or ceil(x).

<span class="mw-page-title-main">Fourier series</span> Decomposition of periodic functions into sums of simpler sinusoidal forms

A Fourier series is an expansion of a periodic function into a sum of trigonometric functions. The Fourier series is an example of a trigonometric series, but not all trigonometric series are Fourier series. By expressing a function as a sum of sines and cosines, many problems involving the function become easier to analyze because trigonometric functions are well understood. For example, Fourier series were first used by Joseph Fourier to find solutions to the heat equation. This application is possible because the derivatives of trigonometric functions fall into simple patterns. Fourier series cannot be used to approximate arbitrary functions, because most functions have infinitely many terms in their Fourier series, and the series do not always converge. Well-behaved functions, for example smooth functions, have Fourier series that converge to the original function. The coefficients of the Fourier series are determined by integrals of the function multiplied by trigonometric functions, described in Common forms of the Fourier series below.

<span class="mw-page-title-main">Spherical harmonics</span> Special mathematical functions defined on the surface of a sphere

In mathematics and physical science, spherical harmonics are special functions defined on the surface of a sphere. They are often employed in solving partial differential equations in many scientific fields. A list of the spherical harmonics is available in Table of spherical harmonics.

Integration is the basic operation in integral calculus. While differentiation has straightforward rules by which the derivative of a complicated function can be found by differentiating its simpler component functions, integration does not, so tables of known integrals are often useful. This page lists some of the most common antiderivatives.

<span class="mw-page-title-main">Square wave</span> Type of non-sinusoidal waveform

A square wave is a non-sinusoidal periodic waveform in which the amplitude alternates at a steady frequency between fixed minimum and maximum values, with the same duration at minimum and maximum. In an ideal square wave, the transitions between minimum and maximum are instantaneous.

<span class="mw-page-title-main">Sine wave</span> Wave shaped like the sine function

A sine wave, sinusoidal wave, or sinusoid is a periodic wave whose waveform (shape) is the trigonometric sine function. In mechanics, as a linear motion over time, this is simple harmonic motion; as rotation, it corresponds to uniform circular motion. Sine waves occur often in physics, including wind waves, sound waves, and light waves, such as monochromatic radiation. In engineering, signal processing, and mathematics, Fourier analysis decomposes general functions into a sum of sine waves of various frequencies, relative phases, and magnitudes.

<span class="mw-page-title-main">String vibration</span> A wave

A vibration in a string is a wave. Resonance causes a vibrating string to produce a sound with constant frequency, i.e. constant pitch. If the length or tension of the string is correctly adjusted, the sound produced is a musical tone. Vibrating strings are the basis of string instruments such as guitars, cellos, and pianos.

The Pythagorean trigonometric identity, also called simply the Pythagorean identity, is an identity expressing the Pythagorean theorem in terms of trigonometric functions. Along with the sum-of-angles formulae, it is one of the basic relations between the sine and cosine functions.

<span class="mw-page-title-main">Pulse wave</span> Periodic rectangular waveform

A pulse wave or pulse train or rectangular wave is a non-sinusoidal waveform that is the periodic version of the rectangular function. It is held high a percent each cycle (period) called the duty cycle and for the remainder of each cycle is low. A duty cycle of 50% produces a square wave, a specific case of a rectangular wave. The average level of a rectangular wave is also given by the duty cycle.

In geometry, the area enclosed by a circle of radius r is πr2. Here the Greek letter π represents the constant ratio of the circumference of any circle to its diameter, approximately equal to 3.14159.

<span class="mw-page-title-main">Sine and cosine</span> Fundamental trigonometric functions

In mathematics, sine and cosine are trigonometric functions of an angle. The sine and cosine of an acute angle are defined in the context of a right triangle: for the specified angle, its sine is the ratio of the length of the side that is opposite that angle to the length of the longest side of the triangle, and the cosine is the ratio of the length of the adjacent leg to that of the hypotenuse. For an angle , the sine and cosine functions are denoted simply as and .

In physics and mathematics, the solid harmonics are solutions of the Laplace equation in spherical polar coordinates, assumed to be (smooth) functions . There are two kinds: the regular solid harmonics, which are well-defined at the origin and the irregular solid harmonics, which are singular at the origin. Both sets of functions play an important role in potential theory, and are obtained by rescaling spherical harmonics appropriately:

In the 1760s, Johann Heinrich Lambert was the first to prove that the number π is irrational, meaning it cannot be expressed as a fraction , where and are both integers. In the 19th century, Charles Hermite found a proof that requires no prerequisite knowledge beyond basic calculus. Three simplifications of Hermite's proof are due to Mary Cartwright, Ivan Niven, and Nicolas Bourbaki. Another proof, which is a simplification of Lambert's proof, is due to Miklós Laczkovich. Many of these are proofs by contradiction.

Amplitude amplification is a technique in quantum computing which generalizes the idea behind Grover's search algorithm, and gives rise to a family of quantum algorithms. It was discovered by Gilles Brassard and Peter Høyer in 1997, and independently rediscovered by Lov Grover in 1998.

In optics, the Fraunhofer diffraction equation is used to model the diffraction of waves when the diffraction pattern is viewed at a long distance from the diffracting object, and also when it is viewed at the focal plane of an imaging lens.

References

  1. Kraft, Sebastian; Zölzer, Udo (5 September 2017). "LP-BLIT: Bandlimited Impulse Train Synthesis of Lowpass-filtered Waveforms". Proceedings of the 20th International Conference on Digital Audio Effects (DAFx-17). 20th International Conference on Digital Audio Effects (DAFx-17). Edinburgh. pp. 255–259.