The Hartley transform is a real-valued alternative to the discrete Fourier transform (DFT). Instead of using complex exponentials with an imaginary unit, it combines sine and cosine into a single real kernel. This makes it especially convenient when your input sequence is purely real and you want a real-valued spectrum.
This page focuses on the discrete Hartley transform (DHT), which is the version used for finite-length sequences. The calculator above takes a real sequence, computes its DHT, and returns the real coefficients that describe the frequency content of the signal.
For a real input sequence of length , the discrete Hartley transform is defined for indices as:
where the cas function is
In expanded form, you can also write the DHT as:
A key property of the Hartley transform is that it is its own inverse, up to a scaling factor. The inverse transform has the same mathematical form:
This involutive property (applying the transform twice, with appropriate scaling, gives back the original sequence) makes certain theoretical arguments and some implementations simpler than with the complex DFT.
The Hartley transform is closely related to the discrete Fourier transform. If is the DFT of the same real sequence , then the Hartley spectrum can be obtained from the real and imaginary parts of . A common relationship is:
Conversely, you can reconstruct the DFT from the Hartley spectrum using linear combinations of shifted Hartley coefficients. In practice, this means that any operation you can perform using the DFT (such as convolution, filtering, and spectral analysis) can also be implemented using the DHT, possibly with some algebraic conversion steps.
Because the DHT uses only real arithmetic, it can simplify implementations that work strictly with real-valued signals or hardware that has limited support for complex numbers.
This short example shows exactly how the calculator interprets an input sequence and what the output means.
Suppose you enter the following sequence into the calculator:
1, 0, -1, 0
Here, and the samples are:
For each output index , the calculator evaluates
For : the angle is always , and .
For : the angles are for respectively. The cas values are:
Then
For : the angles are . The cas values are:
Thus
For : by symmetry for this sequence, you obtain
The calculator will report the Hartley spectrum as something close to
[0, 2, 0, -2]
(with small rounding differences possible due to floating-point arithmetic).
The nonzero coefficients at and indicate strong components at those discrete frequency indices, while and are effectively zero for this particular pattern. You can experiment with other short sequences in the calculator to see how the spectrum changes when you shift, scale, or combine simple patterns.
This calculator is designed to accept real-valued sequences and return the corresponding discrete Hartley transform. Here is how to use it effectively.
0.5, 1, -0.5, 0.1, 0, -1, 0 is treated the same as 1,0,-1,0.2, -3.75, 0.001, and so on.Once you have computed the DHT of a sequence, you can use the coefficients in several ways:
Because the transform is real and its own inverse (apart from scaling), it can be particularly convenient for educational purposes and for implementations where avoiding complex arithmetic is beneficial.
The table below summarizes some practical similarities and differences between the discrete Hartley transform (DHT) and the discrete Fourier transform (DFT) when applied to real input sequences.
| Aspect | Discrete Hartley Transform (DHT) | Discrete Fourier Transform (DFT) |
|---|---|---|
| Output type | Purely real coefficients | Complex coefficients with real and imaginary parts |
| Kernel | ||
| Inverse relationship | Same form as forward transform with a scale factor | Inverse DFT uses complex conjugate kernel and scale factor |
| Implementation | Can use only real arithmetic; sometimes advantageous on real-only hardware | Requires complex arithmetic; highly optimized FFT libraries are widely available |
| Use cases | Educational tools, real-signal processing, systems where complex numbers are inconvenient | General-purpose signal processing, communications, spectral analysis |
| Conversion between transforms | Can be derived from real and imaginary parts of the DFT | Can be reconstructed from the Hartley spectrum using linear combinations |
To keep the tool focused and reliable, the implementation is based on several assumptions and has some practical limitations:
Understanding these assumptions will help you interpret the output correctly and decide when this tool is appropriate for your task.
The Hartley transform can be applied to many of the same problems as the Fourier transform:
You can experiment with simple sequences in the calculator to see how different operations (like shifting, scaling, or combining signals) affect the Hartley spectrum and to build intuition for real-valued spectral analysis.