Math question on phase of 2nd order LP filter - Page 1
Forum section: electronics / beginners

author: Yuu
author_rank: Regular Contributor
timestamp: January 11, 2024, 02:14:28 pm
content: Given the standard form for a second order LP filter\[ T(s) = \frac{\omega_0^2}{s^2 + \frac{\omega_0}{Q}s + \omega_0^2}\]I would usually calculate the phase using\[ \theta = -\tan^{-1}\frac{\omega \omega_0/Q}{\omega_0^2 - \omega^2}.\]However, it seems doing that is giving me incorrect results in the form of a discontinuity.Looking at the denominator of the transfer function, we could factor it like\[ \frac{1}{(s + \alpha + j\beta)(s + \alpha - j\beta)}\]where\[\alpha = \omega_0/2Q, \quad \beta = \omega_0\sqrt{1 - 1/4Q^2} \]and then the angle becomes\[ \theta = -(\phi_1 + \phi_2)\]where\[\phi_{1,2} = \tan^{-1}\frac{\omega \pm \omega_0\sqrt{1 - 1/4Q^2}}{\omega_0/2Q}.\]Plotting that gives me the correct phase plot. Also, taking the phase of the general transfer function gives me the correct plot as well.So there must be something I'm missing when using my regular formula. It's probably a silly mistake or misunderstanding but it's frustrating me.Any thoughts?

author: berke
author_rank: Frequent Contributor
timestamp: January 11, 2024, 02:38:12 pm
content: Phase is defined modulo 2pi, so both formulas agree. Your second formula happens to unwrap the phase so that it is also continuous on R.

author: Yuu
author_rank: Regular Contributor
timestamp: January 11, 2024, 02:41:43 pm
content: Quote from: berke on January 11, 2024, 02:38:12 pmHmm I don't think the two plots are equivalent. If you look at the point \(\omega = 2\). Figure 1 goes to a phase of zero but Figures 2 and 3 go to -180 degrees. That is not the same.They are not off by \(2\pi\). If they were, I would agree with you. However, they're off by \(\pi\).

author: berke
author_rank: Frequent Contributor
timestamp: January 11, 2024, 04:36:19 pm
content: Quote from: Yuu on January 11, 2024, 02:41:43 pmYou're right I didn't look carefully enough, it's not 2pi. It's pi. But the tangent is periodic mod pi, so that you loses information about which half plane your point is in. Arctan effectively works mod pi. You can try using the two-argument version of arctan, atan2 that works on all four quadrants (which is what arg() does.)

author: Benta
author_rank: Super Contributor
timestamp: January 11, 2024, 05:06:49 pm
content: Phase is tedious, as arctan yields results between -pi/2 and pi/2. Plus, it has to resolve an infinity variable at -pi/2 and pi/2.Using atan2 in a spreadsheet is in practice easier.See here:https://www.eevblog.com/forum/projects/analog-filters-a-compilation-of-standard-transfer-functions/

author: MarkT
author_rank: Frequent Contributor
timestamp: January 11, 2024, 06:43:27 pm
content: atan2(y,x) converts cartesian to phase correctly,tan^-1(y/x) does not because a mathematical slope repeats every 180 degrees.Phase unwrapping is supported in some packages.

author: Yuu
author_rank: Regular Contributor
timestamp: January 11, 2024, 06:47:02 pm
content: Ahh yep. That's the bit I was forgetting. Arctan loses information about 2 quadrants. Makes sense now. Arctan2 works wonderfully. The plot is now as expected.