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

enter image description here

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:

enter image description here 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:

enter image description here

  • $\begingroup$ 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? $\endgroup$
    – Matt L.
    Jun 25, 2015 at 13:14
  • $\begingroup$ I'm not sure what you're after but I think you might be on the wrong track. $\endgroup$
    – Matt L.
    Jun 25, 2015 at 13:14
  • $\begingroup$ 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>$. $\endgroup$
    – user14717
    Jun 25, 2015 at 13:17
  • $\begingroup$ @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. $\endgroup$ Jun 25, 2015 at 13:22
  • 2
    $\begingroup$ 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.) $\endgroup$ Jun 25, 2015 at 15:23

1 Answer 1


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} $$

  • $\begingroup$ I got the formula from this paper. $\endgroup$ Jun 26, 2015 at 12:31
  • $\begingroup$ Thank you Robert. I assume unit for f and Fc is Hz and for W is octave. I plotted Gain(f) but did not get raised cosine curve (I got several segments instead of one smooth raised cosine). For Hilbert transform I use C code from here It did not give me the phase as in picture. I got correct phase using the formula from paper and plotting xh[i] from "ht.c" as phase response. Input to paper's formula was f in octave. I didn't use log(Magnitude) but just magnitude when calculating Hilbert transform.. $\endgroup$ Jun 26, 2015 at 13:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.