Before the steady state

The Q a rule can show

A resonance marched forward in time decays at the circuit's rate plus whatever the marching rule adds, and the rule's share has a ceiling built into it. At twenty steps a cycle backward Euler cannot show a quality factor above 3.27 and BDF2 none above 77.9, whatever resistor the circuit has; the ceilings rise as N/2π and N³/4π³. The trapezoidal rule has no ceiling at all — it shows every Q 1.64 per cent high at twenty steps a cycle, a ratio fixed by the step alone. So the steps a cycle needed to read a resonance's Q to one per cent are about 26 for the trapezoidal rule at any Q, 99 for BDF2 at Q = 100 and 62,202 for backward Euler. Marched at Q = 50, the circuit has 0.533 V of ringing left after ten cycles, the trapezoidal rule 0.536 and BDF2 0.346.

Assumes: One step, computed twice · Where the behaviour is written down

The rule between the two measured three ways of marching a circuit forward in time on an inductor and a capacitor with no resistance at all. The trapezoidal rule kept the amplitude exactly and fell behind in phase; backward Euler lost almost all of the amplitude in ten cycles; the second-order backward difference, BDF2, lost amplitude only as the cube of the steps a cycle and phase as the square. Every loss of amplitude in that essay was the rule’s, because the circuit had none of its own, and the essay closed by noting that this is the unusual case. A real resonance has a resistor somewhere, it decays at a rate its quality factor sets, and the rule’s invented loss then competes with the circuit’s true one.

That competition has a simple and slightly alarming answer. A damping rule does not add a small error to the circuit’s Q; it imposes a ceiling on it. Above a quality factor fixed by the rule and the step, every circuit looks the same, because the rule’s loss is all the march can show. This essay measures the ceiling for each rule, the steps a cycle needed to stay well below it, and what the ringing itself looks like when the ceiling is near.

The quality factor a march shows

Put a resistor in series with the earlier essay’s inductor and capacitor — 10 mH and the capacitor that resonates with it at 1 kHz — and choose the resistor to set a quality factor, R=ω0L/QR = \omega_0 L/Q. Step the input by a volt and march the circuit at N steps per undamped cycle.

A linear circuit marched by any of these rules obeys a fixed recurrence: each step multiplies the ringing by one complex factor zz. The march therefore behaves exactly like a continuous resonance whose pole is ln⁡z/h\ln z / h, and that pole has a quality factor of its own, ∣ln⁡z∣/(−2 Reln⁡z)|\ln z| / (-2\,\mathrm{Re} \ln z). That is the number a reader of the marched waveform would measure — the decay per radian of its own ringing — and it is what this essay calls the Q the march shows. It can be computed in two independent ways. One is in closed form, from each rule’s factor at the circuit’s exact pole: the trapezoidal rule’s (1+μ/2)/(1−μ/2)(1 + \mu/2)/(1 - \mu/2), backward Euler’s 1/(1−μ)1/(1 - \mu), and BDF2’s root (2+1+2μ)/(3−2μ)(2 + \sqrt{1 + 2\mu})/(3 - 2\mu), with μ=λh\mu = \lambda h. The other is from the march itself, by fitting the exact two-term recurrence a ringing obeys to the whole marched record.

At 20 steps a cycle backward Euler cannot show a quality factor above 3.27 and BDF2 none above 77.9; the trapezoidal rule shows every Q, 1.6% highcomputed by solving, not by drawing: a series resistor–inductor–capacitor resonance at 1 kHz, its quality factor set by the resistor, marched at 20 steps per undamped cycle with each rule; the quality factor the march shows — its decay per radian of its own ringing — against the circuit's, from 1 to 500. Lines are each rule's factor per step in closed form; dots are marched and measured from the record at Q = 3, 30, 300, agreeing to 0.3%. Backward Euler's shown Q flattens at 3.272 and BDF2's at 77.9, whatever the circuit's; the trapezoidal rule's sits 1.64% above the diagonal at every Q. Q 3: trapezoidal 3.05, BDF2 3.06, backward Euler 1.62; Q 30: trapezoidal 30.5, BDF2 22.5, backward Euler 2.97; Q 300: trapezoidal 305, BDF2 62.6, backward Euler 3.24.110100the circuit's quality factor, Qthe quality factor the march shows110100trapezoidalQ × 1.0164BDF2at most 77.9backward Eulerat most 3.27the circuit's ownthe diagonalsolved, then checked — three rules, one resonanceceilings 3.3 and 77.9
Fig. 1 The quality factor each rule’s march shows against the circuit’s own, at twenty steps a cycle. The trapezoidal rule follows the diagonal a fixed ratio above it; BDF2 bends over towards 77.9 and backward Euler towards 3.27.

The two routes agree to better than 0.3 per cent at every point where both are drawn. At twenty steps a cycle, a circuit with Q = 3 is shown as 3.05 by the trapezoidal rule, 3.06 by BDF2 and 1.62 by backward Euler. At Q = 30 the three show 30.5, 22.5 and 2.97. At Q = 300 they show 305, 62.6 and 3.24. Backward Euler has already flattened before the circuit’s Q reaches ten; BDF2 follows the circuit to about Q = 10 and then bends over; the trapezoidal rule never departs from the diagonal by more than the same 1.64 per cent.

The flattening has a name. However large the circuit’s Q, the rule’s own loss per cycle remains, and the shown Q cannot exceed the Q of the rule’s loss alone. At twenty steps a cycle that ceiling is 3.27 for backward Euler and 77.9 for BDF2. A 1 kHz resonance with a Q of 300, or 3,000, or a lossless one, marched with backward Euler at twenty steps a cycle, decays as a Q of about three would.

The trapezoidal rule’s error is a ratio

The trapezoidal rule’s line is different in kind, not just in size. Its factor on the imaginary axis has a magnitude of exactly one, so a lossless circuit marches without loss and there is no rule-made damping to impose a ceiling. What it does have is the phase error the earlier essays measured: its frequency is (2/h)arctan⁡(ωh/2)(2/h)\arctan(\omega h/2), slightly slow. A damped pole is mapped with its decay rate and its frequency both warped by nearly the same factor, and the Q the march shows comes out multiplied by a constant that depends on the step and not on the circuit — 1.0164 at twenty steps a cycle, the same at Q = 10 as at Q = 100 to the precision drawn.

The slider shows how the three change with the step. At ten steps a cycle the ceilings are 1.76 and 14.5 and the trapezoidal ratio is 1.065. At fifty they are 7.99 and 1,042, and the ratio 1.0026. At a hundred, 15.9 and 8,132, and the ratio 1.0007.

At 100 steps a cycle backward Euler cannot show a quality factor above 15.93 and BDF2 none above 8,132; the trapezoidal rule shows every Q, 0.1% high. computed by solving, not by drawing: a series resistor–inductor–capacitor resonance at 1 kHz, its quality factor set by the resistor, marched at 100 steps per undamped cycle with each rule; the quality factor the march shows — its decay per radian of its own ringing — against the circuit's, from 1 to 500. Lines are each rule's factor per step in closed form; dots are marched and measured from the record at Q = 3, 30, 300, agreeing to 0.3%. Backward Euler's shown Q flattens at 15.934 and BDF2's at 8131.8, whatever the circuit's; the trapezoidal rule's sits 0.07% above the diagonal at every Q. Q 3: trapezoidal 3.00, BDF2 3.01, backward Euler 2.54; Q 30: trapezoidal 30.0, BDF2 30.0, backward Euler 10.4; Q 300: trapezoidal 300, BDF2 290, backward Euler 15.1.
Fig. 2 The same at a hundred steps a cycle. BDF2’s ceiling has risen past the top of the axis and it follows the circuit to a few hundred; backward Euler’s ceiling is still under sixteen.

At a hundred steps a cycle BDF2 follows the circuit to within one per cent up to Q = 100 and is still within ten per cent at 500; backward Euler’s shown Q is 15.7 for a circuit of a thousand. Five times the steps moved BDF2’s ceiling by a factor of a hundred and backward Euler’s by five. That difference is the next figure.

The ceiling against the step

The leading-order behaviour of each ceiling follows from the per-cycle losses the earlier essay measured. Backward Euler loses 2π2/N2\pi^2/N nepers a cycle on a lossless resonance, and a resonance of quality factor QQ loses π/Q\pi/Q, so its ceiling is N/2πN/2\pi. BDF2 loses a quantity that falls as N−3N^{-3}, about 4π4/N34\pi^4/N^3 nepers, and its ceiling is N3/4π3N^3/4\pi^3.

The highest Q a damping rule can show rises as N/2π for backward Euler and as N³/4π³ for BDF2: 1.76 and 14.5 at 10; 3.27 and 77.9 at 20; 7.99 and 1,042 at 50; 15.9 and 8,132 at 100 steps a cycle. computed by solving, not by drawing: the quality factor each rule shows when the circuit has none of its own — a lossless resonance — against the steps per cycle, from the factor per step, beside the leading-order laws N/2π and N³/4π³ (dashed). N 10: backward Euler 1.76, BDF2 14.5; N 20: backward Euler 3.27, BDF2 77.9; N 50: backward Euler 7.99, BDF2 1042.2; N 100: backward Euler 15.93, BDF2 8131.8. Any resonance whose own Q is near or above these numbers is drawn with the rule's loss rather than its own; the trapezoidal rule has no ceiling, because its factor on the imaginary axis has a magnitude of exactly one.
Fig. 3 The highest quality factor each damping rule can show — its Q on a lossless resonance — against the steps a cycle, beside the leading-order laws.

Both laws are approached from above at small step counts and met closely at large ones. At ten steps a cycle backward Euler can show 1.76 and BDF2 14.5; at twenty, 3.27 and 77.9; at fifty, 7.99 and 1,042; at a hundred, 15.9 and 8,132. A first power against a cube. The trapezoidal rule is absent from the figure because it has no ceiling to draw.

The practical reading is a rule of thumb that is easy to carry. With backward Euler, the steps per cycle must be several times 2πQ2\pi Q for the circuit’s own loss to dominate the rule’s — a Q of a hundred wants well over six hundred steps a cycle. With BDF2 the cube makes it cheap: the steps per cycle must be several times (4π3Q)1/3(4\pi^3 Q)^{1/3}, which is 23 for a Q of a hundred and 50 for a Q of a thousand.

How many steps to read Q to a per cent

“Several times” can be made precise. Bisect, for each rule and each circuit Q, on the steps per cycle at which the Q the march shows is within one per cent of the circuit’s.

To show a resonance's Q within 1%: the trapezoidal rule needs 26 steps a cycle at any Q above a few, BDF2 45, 33, 99, 179 and backward Euler 464, 6,205, 62,202, 311,018 at Q = 1, 10, 100, 500. computed by solving, not by drawing: for each rule, the steps per undamped cycle at which the quality factor its march shows is within 1% of the circuit's, found by bisection on the factor per step, against the circuit's Q from 1 to 500. Q 1: trapezoidal 22.2, BDF2 44.0, backward Euler 463; Q 10: trapezoidal 25.6, BDF2 32.5, backward Euler 6,204; Q 100: trapezoidal 25.6, BDF2 98.7, backward Euler 62,202; Q 500: trapezoidal 25.6, BDF2 178.2, backward Euler 311,017. Backward Euler's need grows as 200πQ, BDF2's as the cube root of 400π³Q, and the trapezoidal rule's does not grow at all, because its error in Q is a fixed ratio set by the step alone.
Fig. 4 Steps a cycle each rule needs to show the circuit’s Q within one per cent, against Q. The trapezoidal rule’s need is flat, BDF2’s grows as a cube root, and backward Euler’s as Q itself.

The trapezoidal rule needs between 25 and 26 steps a cycle at every Q from three upwards — 25.3 at Q = 3, 25.6 from Q = 10 on — and 22.2 at Q = 1. BDF2 needs 44 at Q = 1, 32.5 at Q = 10, 98.7 at Q = 100 and 178 at Q = 500. Backward Euler needs 463 at Q = 1, 6,204 at Q = 10, 62,202 at Q = 100 and 311,017 at Q = 500 — very nearly 200πQ200\pi Q, which is the one-per-cent version of the ceiling law.

BDF2’s need is not monotonic at low Q, and the reason is worth seeing. It needs 44 steps a cycle at Q = 1, only 12 at Q = 3, and 32.5 at Q = 10. At Q = 1 the circuit is heavily damped and BDF2’s amplitude loss is small beside the circuit’s; what moves its shown Q there is the phase error, four times the trapezoidal rule’s, which slows the shown frequency and pushes the shown Q up — 1.044 for a circuit of 1 at twenty steps a cycle. At Q = 10 the amplitude loss has taken over and pushes it down, to 9.32. Somewhere near Q = 3 the two errors cross and cancel in the summary, which is why so few steps suffice there: a coincidence of opposite errors rather than an accurate march, since the waveform is still late in phase. Above Q = 10 the amplitude loss is all that matters and the cube-root growth sets in.

The comparison across the three is stark at the Q values circuits actually have. A crystal or a ceramic resonator’s Q of thousands is out of backward Euler’s reach at any affordable step and within BDF2’s at a couple of hundred steps a cycle. A tuned amplifier’s tank at Q = 50 is within the trapezoidal rule’s reach at 26 steps a cycle, within BDF2’s at about 75, and needs over thirty-one thousand for backward Euler. A lightly damped filter section at Q = 3 is the one place backward Euler is merely expensive rather than hopeless, at about 1,800 steps a cycle.

What the ringing looks like

A shown Q is a summary. The waveform it summarises is the ringing after a step, and the difference between rules is clearest there.

A Q = 50 resonance at 20 steps a cycle: after ten cycles the circuit's ringing is 0.533 V, the trapezoidal march's 0.536, BDF2's 0.346 and backward Euler's under a millivolt. computed by solving, not by drawing: the series RLC at 1 kHz with Q = 50, stepped by a volt and marched at 20 steps a cycle with each rule, beside the exact response at the same instants — the largest distance from the final volt in each cycle. Exact: 1.000, 0.939, 0.882, 0.828, 0.778, 0.730, 0.686, 0.644, 0.605, 0.568, 0.533 V. Trapezoidal: 1.000, 0.939, 0.879, 0.821, 0.776, 0.733, 0.690, 0.648, 0.607, 0.567, 0.536. BDF2: 1.000, 0.842, 0.768, 0.694, 0.626, 0.570, 0.512, 0.466, 0.422, 0.379, 0.346. Backward Euler: 1.000, 0.359, 0.128, 0.045, 0.016, 0.006 for the first six. The circuit loses 0.0628 nepers a cycle; the marches lose 0.0619 (trapezoidal), 0.0994 (BDF2), 1.0302 (backward Euler).
Fig. 5 A Q = 50 resonance stepped by a volt and marched at twenty steps a cycle: the largest distance from the final volt in each cycle, for the circuit and for each rule’s march.

At Q = 50 the circuit loses 0.0628 nepers a cycle, π/Q with the small correction for the damped frequency, and after ten cycles 0.533 V of the first volt of ringing is left. The trapezoidal march has 0.536 V, losing 0.0619 nepers a cycle — slightly less than the circuit, as its 1.6 per cent high Q says it should. BDF2 has 0.346 V, losing 0.0994 nepers a cycle, of which the circuit accounts for 0.063 and the rule for the rest: at Q = 50 and twenty steps a cycle the rule’s own loss is more than half the circuit’s. Backward Euler loses 1.03 nepers a cycle, and its ringing is under a millivolt by the tenth cycle. A reader looking at the backward-Euler waveform would see a resonance damped about as heavily as a Q of three, which is what the ceiling said.

The peaks are sampled at the step instants, so each carries a small scalloping as the true peak falls between samples; the same sampling is applied to the exact response, so the comparison between them is like for like.

A Q = 5 resonance at 20 steps a cycle: after ten cycles the circuit's ringing is 0.002 V, the trapezoidal march's 0.002, BDF2's 0.002 and backward Euler's under a millivolt. computed by solving, not by drawing: the series RLC at 1 kHz with Q = 5, stepped by a volt and marched at 20 steps a cycle with each rule, beside the exact response at the same instants — the largest distance from the final volt in each cycle. Exact: 1.000, 0.532, 0.282, 0.150, 0.079, 0.042, 0.022, 0.012, 0.006, 0.003, 0.002 V. Trapezoidal: 1.000, 0.535, 0.285, 0.155, 0.083, 0.045, 0.024, 0.013, 0.007, 0.004, 0.002. BDF2: 1.000, 0.494, 0.260, 0.139, 0.073, 0.039, 0.020, 0.011, 0.006, 0.003, 0.002. Backward Euler: 1.000, 0.204, 0.041, 0.008, 0.002, 0.000 for the first six. The circuit loses 0.6315 nepers a cycle; the marches lose 0.6211 (trapezoidal), 0.6297 (BDF2), 1.5190 (backward Euler).
Fig. 6 The same at Q = 5. The circuit’s own loss dominates, and the trapezoidal rule and BDF2 both follow it closely; only backward Euler still adds visibly.

At Q = 5 the circuit loses 0.632 nepers a cycle and its ringing is two millivolts after ten cycles. The trapezoidal march loses 0.621 and BDF2 0.630 — at this Q BDF2 is actually the closer of the two, because the circuit’s own loss swamps its added damping and its phase error is too small to matter over so few visible cycles. Backward Euler loses 1.52 nepers a cycle, more than twice the circuit’s, and still looks like a resonance, but of the wrong Q. Q = 5 is near backward Euler’s ceiling at this step, and the figure shows what “near the ceiling” means: the rule’s loss and the circuit’s are of similar size and neither can be read without the other.

What this means for choosing a rule

The earlier essays found that the trapezoidal rule rings at half the stepping rate after a discontinuity, and that the backward rules do not. This one finds the price of the backward rules on the other kind of ringing, the kind the circuit actually does. For a resonance, a damping rule is a low-pass filter on the quality factor: the circuit’s Q passes until it reaches the rule’s ceiling, and above that only the ceiling is seen.

That frames the choice between rules by the Q the circuit contains. A circuit whose highest Q is a few — a power stage’s snubbed ringing, a well-damped control loop — can be marched with anything at modest steps. A circuit with a Q of tens wants either the trapezoidal rule or BDF2 at several tens of steps a cycle. A circuit with a Q of hundreds or thousands, marched with a backward rule, needs the step chosen against the ceiling law and not against the waveform’s apparent smoothness, because a too-coarse march produces a waveform that is smooth, plausible and wrong in exactly the quantity a resonator is built to have.

A worked tank: which requirement sets the step

Take a 100 kHz tank with a Q of 200, simulated for a millisecond — a hundred cycles, long enough to watch it ring down by a factor of nearly five. Three requirements now compete for the step, and which one wins differs by rule.

To show the Q within one per cent, the trapezoidal rule needs 25.6 steps a cycle, BDF2 128 and backward Euler 124,406. To stay within one per cent of a cycle in phase over the hundred cycles, The rule between the two found 182 steps a cycle for the trapezoidal rule and 363 for BDF2. So for the two second-order rules the phase requirement is the binding one, by a factor of seven for the trapezoidal rule and about three for BDF2: a march fine enough to keep the ringing on time is already fine enough to keep its decay right. For backward Euler the order is reversed. Its Q requirement alone is 12.4 million steps for the millisecond, and nothing else comes close.

That ordering is the useful summary. For the trapezoidal rule and BDF2 the Q a march shows is a by-product of getting the phase right, and a designer who has chosen the step for phase can trust the decay. For backward Euler the decay is the first thing to go and the last to be fixed, and a waveform whose timing looks plausible can carry a Q several orders of magnitude too low. A march started with a few backward-Euler steps at each discontinuity, as The ringing that belongs to the rule recommended, pays this price only over those few steps: at 182 steps a cycle each backward-Euler step removes about 0.06 per cent of the ringing’s amplitude, once, rather than a rule-made loss every cycle.

The Q the components allow measured how real components’ resistance caps a circuit’s Q. This is the same kind of cap, imposed by the arithmetic of a simulation rather than by the parts, and it has the same consequence: a resonance designed for a Q above the cap is not the resonance that is measured. Where the behaviour is written down put a second-order circuit’s whole behaviour into its two poles; the march’s pole, ln⁡z/h\ln z/h, is the pole the march actually has, and reading its Q is reading where the rule has moved it.

How the numbers were obtained

The circuit is a 1 V step driving a series resistor, a 10 mH inductor and the capacitor that resonates with it at 1 kHz, with the resistor set for each quality factor. Each march is the circuit’s nodal equations integrated with each rule’s companion model, BDF2 started with one backward-Euler step. The Q a march shows is measured from its record by fitting, by least squares, the two-term recurrence ek+1=p ek−q ek−1e_{k+1} = p\,e_k - q\,e_{k-1} that a single pair of complex roots obeys, over eight cycles and after the first forty steps for BDF2, whose parasitic root must first die away; ρ=q\rho = \sqrt{q} and cos⁡θ=p/2ρ\cos\theta = p/2\rho give the factor and so the Q. The closed-form lines evaluate each rule’s factor at the circuit’s exact pole. The ceilings are the closed forms at an infinite circuit Q, and the steps for one per cent are bisected on them. The envelope figures take the largest distance from the final value within each cycle of samples, for the marches and for the exact response 1−e−αt(cos⁡ωdt+(α/ωd)sin⁡ωdt)1 - e^{-\alpha t}(\cos\omega_d t + (\alpha/\omega_d)\sin\omega_d t) at the same instants.

What it leaves out

A real simulator’s variable step. Every march here has a fixed step. A simulator chooses its step to hold an error estimate within a tolerance, and on a high-Q resonance that estimate is dominated by phase; whether the step it chooses lands above or below the ceiling law is the controller’s behaviour, not the rule’s.

Several resonances at once. A circuit with a fast high-Q resonance and a slow one is marched with one step; the fast one sees few steps a cycle and the slow one many. The ceiling applies to each at its own N, so the fast resonance can be at its ceiling while the slow one is perfect.

Nonlinear loss. A circuit whose damping depends on amplitude — a diode-clamped tank, a magnetic core — has no single Q to show, and a rule’s added damping then also changes the amplitude at which the circuit’s own loss acts.

Still open: the controller’s choice, BDF3, and the frequency the rule shows

The step a controller chooses. A variable-step BDF2 or trapezoidal march holds a local error estimate within a tolerance. On a resonance of known Q, the step that controller settles on, and therefore the Q its march shows, is a measurement this circuit can make directly: march it with a controller at three tolerances and read the shown Q against the ceiling law at the step it chose.

BDF3. One more step of history raises the order and should move the ceiling to a higher power of N — but BDF3 is not stable on part of the imaginary axis’s neighbourhood, and a lightly damped resonance lives there. Whether its ceiling rises as N5N^5, or whether it instead grows a resonance the circuit does not have, is the next rule to put through these four figures.

The frequency the rule shows. This essay read the march’s pole for its Q; the same pole has a frequency, and every rule shows a resonance slightly slow. A crystal oscillator’s frequency is the quantity that matters and its Q is a few thousand, so the frequency error at the steps the Q requires — and whether matching one forces the other — is the companion measurement, and the one an oscillator designer would ask for first.

Part 5 on step response

One argument about Step response, 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:

The objects named here

The third axis, after the field and the idea: the things themselves, and every essay that touches each one.

Damping ratioMarchingNumerical errorQuality factorRingingTrapezoidal rule