The discrete wavelet transform (DWT) analyzes signals with localized basis functions. Unlike Fourier methods, which decompose a sequence into infinite-length sinusoids, wavelets employ short-lived wave-like shapes. The Haar wavelet, the simplest choice, uses a pair of piecewise constant functions that capture averages and differences. The one-level Haar transform splits a sequence of length into approximation coefficients and detail coefficients . The formulas are and . These simple computations reveal how the sequence changes from sample to sample.
The Haar coefficients provide a coarse view plus the missing detail information. Reversing the transform simply recombines averages and differences: and . This pair of operations forms the backbone of multiresolution analysis, where additional levels decompose the approximation coefficients again, capturing shorter and shorter features.
Wavelets excel at representing transient events. In images, they pick out edges and textures. In audio, they isolate brief bursts of sound. Because Haar coefficients only depend on differences of adjacent points, they react strongly where the signal jumps. This property allows efficient compression: coefficients near zero indicate smooth regions that can be stored with fewer bits. Modern image formats like JPEG 2000 rely on wavelet-based compression to achieve high quality at low data rates.
Mathematically, the Haar wavelet family forms an orthonormal basis of
To compute the transform by hand, start with the first pair of samples and . Average them to obtain . Subtract to get . Continue with and to compute and . The result is two sequences, each half the length of the original. These sequences describe the same data in a new basis where low-frequency structure sits in and high-frequency detail sits in .
This calculator performs exactly that procedure using JavaScript. When you enter a comma-separated list of numbers with length equal to a power of two, it produces the approximation coefficients in one row and the detail coefficients in another. Because Haar scaling factors include , the outputs may have square-root denominators if you choose rational inputs. Although the algorithm here covers only one level, you can run the transform repeatedly on the approximation coefficients to build a multilevel decomposition manually.
Why is the Haar transform important? Consider a simple step function: for samples. Most Fourier coefficients of this sequence decay slowly, requiring many terms to capture the sharp transition. In contrast, a single large Haar detail coefficient near the step location records the jump precisely. This efficiency extends to complicated natural signals filled with edges and bursts. A wavelet representation often reveals structure that remains hidden in frequency-based approaches.
Another advantage emerges in numerical algorithms for solving differential equations. Wavelet-based multigrid methods adapt resolution to local features, reducing computational cost. The transform also underlies fast algorithms for statistical signal denoising, where thresholding small detail coefficients removes noise while keeping important edges. Because the Haar basis is simple and orthogonal, such operations are straightforward.
To see the transform in action, experiment with sequences of varying smoothness. Try 1,1,1,1
. The detail coefficients vanish because the signal is perfectly smooth. Next try 1,1,-1,-1
. Only a single detail coefficient remains nonzero, indicating one change in the sequence. As you test more complex patterns, you will notice that only coefficients near transitions carry significant values.
This brief introduction scratches the surface of wavelet theory. Mathematicians have developed many families—Daubechies, Coiflets, Symlets—each with distinct shapes and vanishing moments. They support higher-order approximations and smoother reconstructions. Despite its simplicity, the Haar wavelet provides a gateway to these more elaborate constructions because its transform is easy to compute and reveals the essential idea: analyze data at multiple scales by taking localized averages and differences.
For deeper study, explore how repeated applications of the Haar transform yield a full multiresolution analysis. Each stage halves the sample count while doubling the temporal width of the basis functions. At the -th level, the approximation coefficients represent averages over blocks of length . The detail coefficients isolate fluctuations at the boundaries of those blocks. This hierarchy allows efficient compression, as small coefficients at coarse scales often vanish first. The wavelet perspective continues to shape modern signal processing, from audio compression to surface modeling in computer graphics.
Although our calculator stops after one level, the underlying code is easily extended. Each subsequent level requires applying the same averaging and differencing formulas to the approximation coefficients. Many open-source libraries implement fast wavelet transforms that handle arbitrary wavelet families and boundary conditions. By studying the simple case of Haar, you build intuition for how those algorithms operate.
The discrete wavelet transform breaks down data into coarse trends and abrupt variations. Haar's elementary nature makes it ideal for educational demonstrations. With the formulas above, you can calculate coefficients by hand or trust the calculator to do so automatically. Either way, wavelets offer an eye-opening alternative to Fourier analysis, especially when signals contain localized features. Continue exploring wavelets to unlock advanced techniques in compression, denoising, and numerical simulation.
Compute the matrix exponential of a 2x2 matrix using a power series.
Use our Graphing Scientific Calculator to evaluate complex expressions, plot functions, integrate equations and share interactive graphs.
Perform the Gram-Schmidt process on a set of 2D or 3D vectors to obtain an orthonormal basis.