# 18.10.2 Algorithms (Hilbert Transform)

Recall that Hilbert transform is defined as follows:

$g(y)=H(f(x))=\frac 1\pi \int_{-\infty }^\infty \frac{f(x)dx}{x-y}\,\!$

The form of the above equation can be altered as follows:

$g(y)=\frac 1\pi \int _{-\infty }^\infty \frac{f(x-y)dx}x\,\!$

It indicates that the Hilbert transform can be viewed as a convolution:

$g(y)=\frac 1{\pi x}*f(x) \,\!$

Therefore, we can use a fast algorithm based on the convolution theorem to calculate the Hilbert transform. The algorithm can be expressed as follows:

$g(y)=ifft[fft(\frac 1{\pi x})\cdot fft(f(x))] \,\!$

where fft() denotes the fast Fourier transform operator and ifft() denotes the inverse fast Fourier transform operator.

We know that

$fft(\frac 1{\pi x})=-jsgn(freq) \,\!$

where freq is the frequency and sgn(?) is the sign function. Therefore, the product, $fft(\frac 1{\pi x})\cdot fft(f(x)) \,\!$ , can be computed as a special filtering of the Fourier transform of the input signal. The filtering changes the frequency components by introducing a phase shift of -90 degrees at each positive frequency and a phase shift of 90 degrees at each negative frequency. The amplitudes are left unaltered. By applying an inverse Fourier transform on the product, we can get the Hilbert transform of the input data.

After the Hilbert transform is computed, the analytic signal can be derived from its definition.