The corner that moved
Assumes: The frequency a sample rate invents · Three families, one corner · Where the behaviour is written down
The filters field on this site computes each family’s poles from its definition, normalises every one of them to its own measured −3 dB point, realises it as a network of real components and then measures the ripple, the skirt, the delay and the ringing on the network that results. That whole apparatus lives in the s-plane, and a processor cannot execute an s-plane pole.
The map from one to the other is the bilinear transform, and it has a property that is usually introduced as a footnote and is in fact the whole of what a designer has to decide about it.
The map, and the property it was chosen for
The substitution is
and the first thing to establish about it is the reason it is used rather than the more obvious alternatives.
It maps the whole left half plane inside the unit circle. Every stable analogue filter becomes a stable digital one, at every sample rate, with no exceptions and nothing to check. The gate holds that at three sample rates, four orders and three families — thirty-six designs, largest pole radius 0.979 — because it is the property the transform is chosen for and a claim of that shape deserves a sweep rather than a proof by reference.
The alternative — placing digital poles at , which is the impulse-invariant map — does not have it in the form that matters: it maps the s-plane’s infinite imaginary axis onto the circle many times over, so an analogue filter with any content above half the sample rate arrives aliased into its own digital response. The bilinear transform avoids that by compressing rather than wrapping, and the compression is the price.
What the compression does, measured
On the unit circle, gives . So the digital response at frequency f is the analogue prototype evaluated at k·tan(πf/fₛ) rather than at 2πf, and the digital half-power point sits where the prototype’s does:
That is an identity and the site does not draw identities, so it is measured on the response. Take the prototype, map it, evaluate the digital response at the frequency the identity predicts, and ask whether it is at half power:
| sample rate | design corner | measured at the predicted frequency |
|---|---|---|
| 8 kHz | 40 Hz … 1.6 kHz | within 0.0000 dB of −3.0103 |
| 48 kHz | 240 Hz … 9.6 kHz | within 0.0000 dB of −3.0103 |
Eight designs, worst departure 0.0000 dB. The identity is exact and the measurement says so on the object rather than on the algebra.
What it costs at ordinary ratios:
| f/fₛ | analogue | lands at | out by |
|---|---|---|---|
| 0.02 | 1 kHz | 998.6 Hz | −0.14% |
| 0.10 | 4.8 kHz | 4.651 kHz | −3.11% |
| 0.25 | 12 kHz | 10.17 kHz | −15.2% |
| 0.42 | 20 kHz | 14.03 kHz | −29.8% |
A corner at a fiftieth of the sample rate is out by a seventh of a per cent and nobody would notice. A corner at a quarter is out by fifteen per cent, which moves a filter’s stopband edge by more than any component tolerance would.
Pre-warping, and what it is not
The repair is to ask the prototype for a different frequency — the one that lands on the wanted one — which is the identity read backwards, and the scale factor k is chosen so that it happens automatically.
| design corner | plain map | pre-warped |
|---|---|---|
| 0.5 kHz | −3.017 dB | −3.010 dB |
| 1 kHz | −3.035 | −3.010 |
| 2 kHz | −3.111 | −3.010 |
| 4 kHz | −3.432 | −3.010 |
| 8 kHz | −5.032 | −3.010 |
| 12 kHz | −8.980 | −3.010 |
| 16 kHz | −17.559 | −3.010 |
The pre-warped column is −3.010 dB at every corner, exactly, which is what pre-warping means and is the whole of what it delivers. At one frequency.
That last sentence is the reason this section exists. Pre-warping is routinely described as correcting the warping, and it corrects it nowhere except at the frequency chosen. Above that frequency the pre-warped response is the further of the two from the analogue prototype, because the pre-warping has stretched the axis to place the corner and the stretch continues past it. A fifth-order design pre-warped at its corner has a stopband edge that is in a different place from the prototype’s, and if the specification is about the stopband then that is the frequency to pre-warp at instead.
So the correct statement is narrow: pre-warping is a choice of which single frequency the digital filter and the analogue prototype will agree at. For a low-pass filter specified by its corner the corner is the sensible choice; for a band-pass filter there are two edges and one warping, and the usual practice pre-warps both and accepts that the shape between them has changed.
This is the same species of statement as one the filters field already makes about equalisation. An all-pass section can flatten a group delay, and what it removes is always less than what it adds: the equaliser takes a fifth-order Chebyshev’s 891 µs of variation down to 498 and adds 722 µs at direct current. In both cases the repair is real, bounded, and buys one property at the cost of another rather than removing a defect.
Where the sample rate stops being free
The warping table has a design consequence that is easy to state and is the reason so many digital filters run at rates that look extravagant.
A filter’s warping error is set by the ratio of its corner to the sample rate, and pre-warping removes it at one frequency only. So the way to make a shape survive the map is to keep the whole of it well below half the rate — which means oversampling, and means it for a reason that has nothing to do with quantisation noise or with the anti-alias filter.
The numbers from the table say how much. Below about a fiftieth of the sample rate the map is within a seventh of a per cent everywhere and the digital filter is the analogue one; at a tenth the shape has moved by three per cent, which is comparable to a one per cent component tolerance’s effect and is at least in the same conversation; at a quarter the shape is a different shape and pre-warping is choosing which part of it to preserve.
That is the third independent argument for a fast clock this field has produced, and it is worth listing them together because they are usually collapsed into one:
Aliasing wants a rate high enough that the anti-alias filter’s job is achievable — an argument about the analogue filter in front.
Noise shaping wants a rate high enough that the shaped error has somewhere to go — an argument about the quantiser.
Warping wants a rate high enough that the digital filter is the filter that was designed — an argument about the arithmetic, present even with a perfect converter and no noise at all.
The three are independent and they all point the same way, which is why a signal chain designed around any one of them usually satisfies the other two by accident and why the accident is worth knowing about rather than relying on.
Three routes to one response
A digital filter can be evaluated three ways and this site’s habit is to use more than one.
From the poles, by mapping each analogue pole through the substitution and evaluating the resulting product on the unit circle. As a cascade of second-order sections, whose coefficients are the real and imaginary parts of each conjugate pair. As a difference equation marched forward one sample at a time, which is what a processor executes and which contains no transfer function at all.
Agreement at the arithmetic’s floor is the answer, and it is worth saying what the check is for, because “the two agree” is a weak claim if nothing could have made them disagree.
A recursion is a place where a sign error produces a plausible filter. Flip the sign of one feedback coefficient and the result is still stable, still smooth, still has a corner somewhere, and still looks entirely like a filter — it is simply a different one. Evaluating a transfer function cannot catch that, because the transfer function is where the coefficients came from. Only running the recursion and comparing can, which is the same reason the transients field computes a step response twice, once from residues and once by walking the network forward in time.
The site has already been bitten by exactly this shape in the noise field, where a bilinear recursion carried the past output with the wrong sign. Every section’s pole sat at z ≈ −1 instead of z ≈ +1 — a filter alternating every sample rather than integrating over many, which is the exact opposite of the intended shape — and the result was not merely wrong but impossible: a four-sample average with a ratio of four thousand in it. That recursion is the same substitution as this essay’s, and it had no second route.
Two more things the pairing has to be right about
Two constructional checks sit beside the agreement above and both catch failures that would otherwise be silent.
The zeros are not decoration. The bilinear transform of an all-pole analogue filter has n zeros at z = −1, which is half the sample rate. Without them the digital response does not reach zero at Nyquist and is not the transform of the filter that was asked for — it is a filter with a stopband that flattens out, which looks like a slightly disappointing design rather than like an error.
The conjugate pairs have to be paired correctly. sections matches each complex pole with its
conjugate by value, and refuses a pole that has none. Pairing adjacent entries of the root list
instead — which is the obvious implementation, and which works whenever the rooting happens to return
them in order — builds a section from two poles of different pairs. The result has complex
coefficients whose imaginary parts are then quietly dropped, giving a stable, plausible, wrong filter.
The gate feeds sections two poles that are not a pair and requires the refusal, and separately
checks that the assembled denominator’s largest imaginary coefficient is below 10⁻¹¹ at four orders.
That second check is the same one the site’s own polynomial machinery already carries, one field
over: checkFactorisation measures how far a recovered polynomial is from the product of its roots,
because a factorisation that has lost a root still produces a response.
What the warping does to a shape, not only to a corner
The tables above are about one frequency each, and a filter is a shape. It is worth spending a section on what the compression does to the rest of it, because the effect is not a uniform shift and the difference matters for a stopband specification.
The map is monotone and its derivative falls: near direct current a hertz of analogue is a hertz of digital, and near half the sample rate a hertz of analogue is almost nothing. So a filter’s features are squeezed together as they approach Nyquist, and the squeezing is worse the further out the feature is.
A concrete case. A fourth-order Butterworth designed at 4 kHz has its −40 dB point at kHz in the analogue prototype, a ratio of 3.16 above the corner. Mapped plainly to 48 kHz, the corner lands at 3.91 kHz and the −40 dB point at 10.57 kHz — a ratio of 2.70 against the prototype’s 3.16. The transition band has narrowed by fifteen per cent, which is to say the digital filter is steeper than the analogue one it came from.
That is a real and generally welcome effect and it has a limit that is easy to miss. The prototype’s response continues to fall forever; the digital one has to reach the whole of the rest of the prototype in the space between the corner and half the sample rate, so its stopband is compressed into a finite interval and it arrives at Nyquist having done all of it. For an all-pole filter that is fine — the response is heading for zero anyway and the n zeros at z = −1 put it there. For a filter with a stopband floor it is not: an elliptic design’s equiripple stopband is squeezed into the region below half the rate, and every one of its transmission zeros arrives at a frequency the identity above moves.
This connects back to the anti-alias essay’s refusal by a different route. There, the objection to an elliptic design was that its floor could not be reached past by sampling faster. Here, the observation is that its zeros — which are what put the floor where it is — move under the map, so a digital elliptic filter’s floor is not the prototype’s floor unless the design accounts for it. Both are consequences of the same fact: an elliptic response is specified by where its zeros are, and every frequency-mapping operation moves them.
Where this leaves the filters field’s results
Everything the filters field measured is now available digitally, with two amendments and one question.
The amendments are in this essay: every frequency is warped, and the warping is exact and computable; and the realisation is a cascade of second-order sections rather than a cascade of buffered RLC stages.
The question is the one the filters field itself raised and which arrives here in a much sharper form. That field measured the sensitivity of two realisations of one response — a buffered cascade and a doubly terminated ladder — and found the passband error growing as the 0.99 power of a component tolerance in one and the 2.00 power in the other. A digital filter has no components and no tolerances, so the question would appear not to arise.
It arises with more force, because a coefficient is stored in a finite number of bits, and that is the next essay.
The sections, and one thing about them that is not arithmetic
sections turns a list of z-plane poles into second-order sections, and the coefficients it
produces have a shape worth reading rather than merely executing.
For a conjugate pair p the denominator is 1 − 2·Re(p)·z⁻¹ + |p|²·z⁻², so the two coefficients carry exactly the two things about a pole that matter: twice its real part, which is where on the circle it sits, and its squared radius, which is how close to the circle it is. The second is the stability margin, written down as a number a designer can look at.
That has a practical consequence the next essay is entirely about. A pole at radius 0.9748 has a second coefficient of 0.9502, and a pole at radius 1.0000 has one of exactly 1. So the whole distance between a stable filter and an oscillator is the distance between 0.9502 and 1 in one stored number — about five per cent — and a filter whose poles are close to the circle, which is any filter whose corner is a small fraction of the sample rate, is a filter whose stability lives in the low-order bits of a coefficient.
An odd order leaves one real pole over. It is written as a biquad with its second coefficient zero
rather than as a special case, because a special case is a branch every caller has to remember —
which is the same reason lib/network.js gives an inductor a current unknown rather than an
admittance of 1/(sL), so that
direct current needs no special case and is simply the value at
s = 0.
The site’s own experience with special cases in this area is not encouraging. The transients field’s residue expansion divides by the distance between poles, so critical damping has no expansion — and the repair there was to step the slider round the singularity rather than to perturb the circuit, because a special case that returns a slightly wrong answer is worse than one that refuses.
The same preference for a refusal decides how far this essay’s own sweep runs. The same filter, rounded twice is where the biquad representation stops being a stylistic choice and becomes the difference between a filter and an oscillator: at eighth order and sixteen bits a cascade of biquads moves its poles by and stays at a radius of 0.9748, while the same response written as one polynomial moves its poles to a radius of 1.4536 — which is not an inaccurate filter but an unstable one. A warping calculation performed on a polynomial whose roots have left the unit circle is arithmetic about an object that does not exist, and the structure this essay uses is what keeps that from happening quietly.
Part 1 on digital realisation
One argument about Digital realisation, and one of 5 essays on it so far, each part numbered by how much of the idea it assumes. What sits either side of it:
What links here
Essays that reach for this one mid-argument — the half of a link its own author cannot write down.
What this makes readable
Essays that name this one as a prerequisite.
The objects named here
The third axis, after the field and the idea: the things themselves, and every essay that touches each one.
Bilinear transformBiquad cascadeFilter familiesFrequency warpingPolesZ plane
- The corner error a filter hides in its sections biquad cascade, filter families
- The derivative of a root biquad cascade, poles