 Hilbert - Maple Help

SignalProcessing

 Hilbert
 calculates the Hilbert Transform of a 1-D signal Calling Sequence Hilbert( signal, fftlength ) Parameters

 signal - one-dimensional rtable fftlength - (optional) non-negative integer. The default is numelems(signal). Description

 • The Hilbert command takes a 1-D rtable, and computes the (Discrete) Hilbert Transform. The continuous version is defined by a convolution with the function $t↦\frac{1}{\mathrm{\pi }\cdot t}$, and for signal $f\left(t\right)$, the Hilbert Transform is given by

$F\left(t\right)={{\int }}_{-\mathrm{\infty }}^{\mathrm{\infty }}\frac{f\left(s\right)}{\mathrm{\pi }\left(t-s\right)}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{ⅆ}s$

 where the integral uses the Cauchy Principle Value.
 • The passed container is converted to an Array of complex datatype. For this reason, it is most efficient for the container to have this datatype beforehand. However, the signal needs to be real-valued, and if a complex rtable is passed, the imaginary parts must be zero.
 • The fftlength option determines the length of the Arrays used with Discrete Fourier Transforms (DFTs). If fftlength is greater than the size of signal, then padding is used, and if fftlength is smaller than the size of signal, truncation is performed. The default value is numelems(signal). Note that the ideal value for using Fast Fourier Transforms (FFTs) is the smallest power of two that is at least 4 and no smaller than the size of signal, that is, 2^(-ilog2(1/max(4,numelems(signal)))).
 • An Array of size fftlength is returned, with the real part being the modified (padded or truncated) signal, and the imaginary part being the corresponding Hilbert Transform.
 • Since DFTs are used to find the Hilbert Transform, there may be numerical artifacts in the result that are small in size.
 • To obtain the Hilbert Transform, we use the algorithm outlined by S.L. Marple (see references below):
 1 Pad with zeros or truncate signal so that the modified signal f has size n=fftlength.
 2 Compute F, the DFT of f.
 3 Construct G, the Finite Impulse Response (FIR) signal, as follows. First, define k=ceil(n/2)+1. Now, initialize an Array G of size n filled with zeros, and then set G=1, G[i]=2 for i=2..k-1, and, if n is even, G[k]=1. Note that H[i]=0 for i=k+1..n corresponds to the filtering out of negative frequencies.
 4 Define H to be the element-wise product of F and G.
 5 Take the Inverse DFT (IDFT) of H, which returns the Hilbert Transform h of signal.
 • As the underlying implementation of the SignalProcessing package is a module, it is also possible to use the form SignalProcessing:-Hilbert to access the command from the package. For more information, see Module Members. Examples

 > $\mathrm{with}\left(\mathrm{SignalProcessing}\right):$ Simple Example

 • Consider the following simple signal:
 > $A≔\mathrm{Array}\left(\left[1,2,3,4\right]\right)$
 $\left[\begin{array}{rrrr}1& 2& 3& 4\end{array}\right]$ (1)
 • Different values of fftlength give different results (here, the default is 4):
 > $\mathrm{Hilbert}\left(A\right)$
 $\left[\begin{array}{cccc}1.0+1.0{}I& 2.0-1.0{}I& 3.0-1.0{}I& 4.0+1.0{}I\end{array}\right]$ (2)
 > $\mathrm{Hilbert}\left(A,5\right)$
 $\left[\begin{array}{ccccc}1.0000000000000007-1.3763819204711734{}I& 2.0-0.649839392465812{}I& 2.9999999999999996-1.3763819204711738{}I& 3.999999999999999+1.70130161670408{}I& 0.0+1.701301616704079{}I\end{array}\right]$ (3)
 • However, when you increase fftlength, the first four elements converge:
 > $\mathrm{RootMeanSquareError}\left(\mathrm{Hilbert}\left(A,200\right)\left[..4\right],\mathrm{Hilbert}\left(A,400\right)\left[..4\right]\right)$
 ${0.000304228443122111678}$ (4) Continuous Signal

 • Here, we generate a discrete signal from a continuous one. First, define the time bounds and signal:
 > $\mathrm{t1}≔-10.0$
 ${\mathrm{t1}}{≔}{-10.0}$ (5)
 > $\mathrm{t2}≔10.0:$
 > $f≔t↦\frac{10}{{t}^{2}+1}$
 ${f}{≔}{t}{↦}\frac{{10}}{{{t}}^{{2}}{+}{1}}$ (6)
 • Second, define the number of points, along with the sample time and signal values:
 > $n≔64:$
 > $\mathrm{\phi }≔i↦\mathrm{t1}+\frac{\left(i-1\right)\cdot \left(\mathrm{t2}-\mathrm{t1}\right)}{n-1}:$
 > $T≔\mathrm{Array}\left(\mathrm{~}\left[\mathrm{\phi }\right]\left(\left[\mathrm{seq}\left(1..n\right)\right]\right)\right):$
 > $A≔\mathrm{Array}\left(\mathrm{~}\left[f\right]\left(T\right),\mathrm{datatype}=\mathrm{float}\left[8\right]\right):$
 • Now, we can find and plot the Hilbert Transform:
 > $B≔\mathrm{Hilbert}\left(A\right):$
 > $p≔\mathrm{dataplot}\left(\left[\mathrm{\Re },\mathrm{\Im }\right]\left(B\right),\mathrm{legend}=\left["Original signal","Transformed signal"\right],\mathrm{title}="Discrete Signals vs. Index",\mathrm{color}=\left[\mathrm{blue},\mathrm{red}\right],\mathrm{symbolsize}=7,\mathrm{font}=\left[\mathrm{Verdana},15\right],\mathrm{legendstyle}=\left[\mathrm{font}=\left[\mathrm{Verdana},10\right]\right]\right)$ • The time values are in terms of the indices, but we can transform the plot:
 > $\mathrm{plots}:-\mathrm{display}\left(\mathrm{plottools}:-\mathrm{transform}\left(\left(i,x\right)↦\left[\mathrm{\phi }\left(i\right),x\right]\right)\left(p\right),\mathrm{title}="Discrete Signals vs. Time"\right)$ • For comparison, let's determine the Continuous Hilbert Transform, which is fairly simple for this example:
 > $F≔\mathrm{unapply}\left(\frac{1}{\mathrm{\pi }}\left(\mathrm{int}\left(\frac{f\left(\mathrm{\tau }\right)}{t-\mathrm{\tau }},\mathrm{\tau }=-\mathrm{\infty }..\mathrm{\infty },\mathrm{CauchyPrincipalValue}\right)\right),t\right)\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{assuming}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}t::\mathrm{real}$
 ${F}{≔}{t}{↦}\frac{{10}{\cdot }{t}}{{{t}}^{{2}}{+}{1}}$ (7)
 > $p≔\mathrm{plot}\left(\left[f\left(t\right),F\left(t\right)\right],t=\mathrm{t1}..\mathrm{t2},\mathrm{legend}=\left["Original signal","Transformed signal"\right],\mathrm{title}="Continuous Signals vs. Time",\mathrm{color}=\left[\mathrm{blue},\mathrm{red}\right],\mathrm{symbolsize}=7,\mathrm{font}=\left[\mathrm{Verdana},15\right],\mathrm{legendstyle}=\left[\mathrm{font}=\left[\mathrm{Verdana},10\right]\right]\right)$ > References

 Marple, S.L., Jr. "Computing the Discrete-Time "Analytic" Signal via FFT." IEEE Transactions on Signal Processing. Vol. 47, No. 9, 1999. Compatibility

 • The SignalProcessing[Hilbert] command was introduced in Maple 2020.