Function Repository Resource:

DiscreteHartleyTransform (1.0.0)current version: 1.1.0 »

Compute the discrete Hartley transform of a list

Contributed by: Jan Mangaldan
 ResourceFunction["DiscreteHartleyTransform"][list] computes the discrete Hartley transform of a list of complex numbers.

Details

The discrete Hartley transform vs of a list ur of length n is defined to be . The normalization is chosen such that the transform is its own inverse.
The discrete Hartley transform is sometimes defined to have the normalization constant 1 or instead.
The discrete Hartley transform is real-valued for real-valued data.
The list of data supplied to ResourceFunction["DiscreteHartleyTransform"] must be one-dimensional, but need not have a length equal to a power of two.
If the elements of list are exact numbers, ResourceFunction["DiscreteHartleyTransform"] begins by applying N to them.
ResourceFunction["DiscreteHartleyTransform"] can be used on SparseArray objects.

Examples

Basic Examples (1)

Compute a discrete Hartley transform:

 In[1]:=
 Out[1]=

Scope (2)

x is a list of real values:

 In[2]:=

Compute the Hartley transform with machine arithmetic:

 In[3]:=
 Out[3]=

Compute using 24-digit precision arithmetic:

 In[4]:=
 Out[4]=

Compute a complex Hartley transform:

 In[5]:=
 In[6]:=
 Out[6]=

This is equivalent to separately taking the Hartley transforms of the real and imaginary parts:

 In[7]:=
 Out[7]=

Applications (2)

Use the discrete Hartley transform to compute the power spectrum of "white noise":

 In[8]:=
 Out[11]=

Show the logarithmic spectrum, including the first (DC) component:

 In[12]:=
 Out[22]=

Compute discrete cyclic convolutions to smooth a discontinuous function with a Gaussian:

 In[23]:=
 In[24]:=
 Out[24]=

Compute the cyclic convolution:

 In[25]:=

Show the original and smoothed function:

 In[26]:=
 Out[26]=

The convolution is consistent with ListConvolve:

 In[27]:=
 Out[27]=

Properties and Relations (4)

Compute the discrete Hartley transform from its definition:

 In[28]:=
 In[29]:=
 Out[29]=

DiscreteHartleyTransform is faster:

 In[30]:=
 Out[30]=
 In[31]:=
 Out[31]=

Compute the discrete Hartley transform of a vector by multiplying it with the Hartley matrix:

 In[32]:=
 In[33]:=
 Out[33]=

DiscreteHartleyTransform is faster:

 In[34]:=
 Out[34]=
 In[35]:=
 Out[35]=

The discrete Hartley transform is its own inverse:

 In[36]:=
 In[37]:=
 Out[37]=

A list of numbers:

 In[38]:=

Compute its discrete Hartley transform:

 In[39]:=
 Out[39]=

Use the discrete Hartley transform to compute the discrete Fourier transform:

 In[40]:=
 Out[41]=

Compare with the result of Fourier:

 In[42]:=
 Out[42]=

Version History

• 1.1.0 – 13 March 2023
• 1.0.0 – 13 February 2023