これはjojekの答えの補遺であり、倍精度の数学を使用した場合により一般的で完全に適切です。精度が低い場合、周波数応答の周波数が非常に低い(ナイキストよりはるかに低い)場合、およびフィルターの共振周波数が非常に低い場合に生じる「余弦問題」があります。
|H(ejω)|2|H(e−jω)|=|H(ejω)|
このトリガーIDを検討してください。
cos(ω) = 1−2sin2(ω2)
sin2(ω2)ω→0
sin2(ω2)
H(z)=b0+b1z−1+b2z−2a0+a1z−1+a2z−2
複雑な周波数応答を持つ
H(ejω)=b0+b1e−jω+b2e−j2ωa0+a1e−jω+a2e−j2ω
大きさの二乗があります:
|H(ejω)|2=|b0+b1e−jω+b2e−j2ω|2|a0+a1e−jω+a2e−j2ω|2=(b0+b1cos(ω)+b2cos(2ω))2+(b1sin(ω)+b2sin(2ω))2(a0+a1cos(ω)+a2cos(2ω))2+(a1sin(ω)+a2sin(2ω))2=b20+b21+b22+2b1(b0+b2)cos(ω)+2b0b2cos(2ω)a20+a21+a22+2a1(a0+a2)cos(ω)+2a0a2cos(2ω)
so, one can see that the magnitude frequency response |H(ejω)| is an even symmetry function and depends only on the cosines cos(ω) and cos(2ω). for very low ω, the values of those cosines are so close to 1 that, with single-precision fixed or floating point, there are few bits remaining that differentiate those values from 1. that is the "cosine problem".
using the trig identity above, you get for magnitude squared:
|H(ejω)|2=b20+b21+b22+2b1(b0+b2)cos(ω)+2b0b2cos(2ω)a20+a21+a22+2a1(a0+a2)cos(ω)+2a0a2cos(2ω)=b20+b21+b22+2b1(b0+b2)(1−2sin2(ω2))+2b0b2(1−2sin2(ω))a20+a21+a22+2a1(a0+a2)(1−2sin2(ω2))+2a0a2(1−2sin2(ω))=b20+b21+b22+2b1(b0+b2)(1−2sin2(ω2))+2b0b2(2cos2(ω)−1)a20+a21+a22+2a1(a0+a2)(1−2sin2(ω2))+2a0a2(2cos2(ω)−1)=b20+b21+b22+2b1(b0+b2)(1−2sin2(ω2))+2b0b2(2(1−2sin2(ω2))2−1)a20+a21+a22+2a1(a0+a2)(1−2sin2(ω2))+2a0a2(2(1−2sin2(ω2))2−1)=b20+b21+b22+2b1(b0+b2)(1−2ϕ)+2b0b2(2(1−2ϕ)2−1)a20+a21+a22+2a1(a0+a2)(1−2ϕ)+2a0a2(2(1−2ϕ)2−1)=b20+b21+b22+2b1(b0+b2)(1−2ϕ)+2b0b2(1−8ϕ+8ϕ2)a20+a21+a22+2a1(a0+a2)(1−2ϕ)+2a0a2(1−8ϕ+8ϕ2)=b20+b21+b22+2b1b0+2b1b2−4(b1b0+b1b2)ϕ+2b0b2−16b0b2ϕ+16b0b2ϕ2a20+a21+a22+2a1a0+2a1a2−4(a1a0+a1a2)ϕ+2a0a2−16a0a2ϕ+16a0a2ϕ2=(b20+b21+b22+2b1b0+2b1b2+2b0b2)−4(b1b0+b1b2−4b0b2)ϕ+16b0b2ϕ2(a20+a21+a22+2a1a0+2a1a2+2a0a2)−4(a1a0+a1a2−4a0a2)ϕ+16a0a2ϕ2=14(b20+b21+b22+2b1b0+2b1b2+2b0b2)−(b1b0+b1b2−4b0b2)ϕ+4b0b2ϕ214(a20+a21+a22+2a1a0+2a1a2+2a0a2)−(a1a0+a1a2−4a0a2)ϕ+4a0a2ϕ2=(b0+b1+b22)2−ϕ(4b0b2(1−ϕ)+b1(b0+b2))(a0+a1+a22)2−ϕ(4a0a2(1−ϕ)+a1(a0+a2))
where ϕ≜sin2(ω2)
if your gear is intending to plot this as dB, it comes out as
20log10|H(ejω)| = 10log10((b0+b1+b22)2−ϕ(4b0b2(1−ϕ)+b1(b0+b2)))−10log10((a0+a1+a22)2−ϕ(4a0a2(1−ϕ)+a1(a0+a2)))
so your division turns into subtraction, but you have to be able to compute logarithms to some base or another. numerically, you will have much less trouble with this for low frequencies than doing it the apparent way.