Function Repository Resource:

# DiscreteHartleyTransform

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"] need not have a length equal to a power of two.
The list given in ResourceFunction["DiscreteHartleyTransform"][list] can be nested to represent an array of data in any number of dimensions.
The array of data must be rectangular.
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 (4)

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]=

Compute a 2D Hartley transform:

 In[8]:=
 Out[8]=

x is a rank 3 tensor with nonzero diagonal:

 In[9]:=

Compute the 3D Hartley transform:

 In[10]:=
 Out[10]=

### Applications (2)

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

 In[11]:=
 Out[14]=

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

 In[15]:=
 Out[25]=

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

 In[26]:=
 In[27]:=
 Out[27]=

Compute the cyclic convolution:

 In[28]:=

Show the original and smoothed function:

 In[29]:=
 Out[29]=

The convolution is consistent with ListConvolve:

 In[30]:=
 Out[30]=

### Properties and Relations (4)

Compute the discrete Hartley transform from its definition:

 In[31]:=
 In[32]:=
 Out[32]=

DiscreteHartleyTransform is faster:

 In[33]:=
 Out[33]=
 In[34]:=
 Out[34]=

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

 In[35]:=
 In[36]:=
 Out[36]=

DiscreteHartleyTransform is faster:

 In[37]:=
 Out[37]=
 In[38]:=
 Out[38]=

The discrete Hartley transform is its own inverse:

 In[39]:=
 In[40]:=
 Out[40]=

A list of numbers:

 In[41]:=

Compute its discrete Hartley transform:

 In[42]:=
 Out[42]=

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

 In[43]:=
 Out[44]=

Compare with the result of Fourier:

 In[45]:=
 Out[45]=

## Version History

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