# Filters - Hilbert Transform and Absolute Value of Magnitude Response

Following relationship between magnitude response and phase response for minimum phase:

I have implemented in C++ code using the Hilbert Transform C code from file found online ht.c. However, I am not getting the phase response as expected. My magnitude response follows raised cosine formula:

Essentially I provide $|H(j\omega)| = \text{Gain}(f)$ to be all real values as per this cosine formula. The phase response is not as expected. Also, how am I suppose to handle $\log(|H(i\omega)|)$ when $|H(i\omega)| = 0$? Am I missing any steps to obtain phase response in this process?

Here is how phase and magnitude response should look like:

• What did you expect the phase to look like? Also note that there is no problem with zero values because (at least from the figure) the magnitude never becomes zero. Furthermore, the phase is not defined when the magnitude is zero, so this is not a relevant problem. (What phase does the value $0$ have?) But now comes the most important question: what are you going to do with the phase response if you manage to compute it from the given magnitude response? In what way are you expecting it to help you when designing the filter? Jun 25 '15 at 13:14
• I'm not sure what you're after but I think you might be on the wrong track. Jun 25 '15 at 13:14
• Can your code demonstrate the Hilbert transform of $\cos$ is $\sin$? That's the first step. Then test your code satisfies $\left<x,Hx\right> = 0$ and $\left<Hx,Hx\right> = \left<x,x\right>$. Jun 25 '15 at 13:17
• @MattL. In the definition of filters magnitude response it specifies Gain(f) = 0 (otherwise). Correct me if I am wrong but magnitude is zero there. As for the phase, it should look like as in this question but I am getting different kind of curve. My filter needs to have this kind minimum phase response, that's the design objective. Jun 25 '15 at 13:22
• you have real problems with your definition. in your figure the raised cosine is drawn on a log-frequency scale, not a linear-frequency scale. there is symmetry in log-frequency, not linear-frequency. so your mathematical definition is inconsistent with that. (your $W$ and $f$ terms do not have the same dimensions. you'll likely have to replace $f$ with $\log_2(f)$ somehow, somewhere.) Jun 25 '15 at 15:23

Neb, i dunno where you got that frequency response expression from, but it's flawed. from the description (of parameters like $W$ in "octaves"), it should be like this:
$$Gain(f) = \begin{cases} 10^{Boost/20} \times \frac{1}{2}\left\{1 + \cos\left(\pi \frac{\log_2(f/F_c)}{W} \right) \right\}, & \text{if }|\log_2(f/F_c)|<W \\ 0, & \text{otherwise } \end{cases}$$