The iterations a table saves
Assumes: The one current a constant is right at · What a network answers, and how the answer is checked
The table that has to be refitted built the piecewise-linear diode a circuit simulator might use — eighteen drop-plus-resistance segments from 100 nanoamps to 100 milliamps, within 1.886 millivolts of a real two-mechanism junction at 300 kelvin — and found that carrying it to another temperature needs every segment’s line refitted, while its breakpoints never move. Refitting needs the junction’s own law. That essay ended by naming what had been assumed all along: that a table is worth having because it saves a solver work. A table is evaluated with a comparison, a multiply and an add, where the law is two exponentials and a Newton step that can overflow. Whether that adds up to a saving, and how large, had not been measured in the only currency a solver uses, which is iterations.
It is measured here on the smallest circuit that needs a solver at all: a source, a resistor and a diode. The answer has three parts. A cold start flatters the table enormously, and most of what it flatters it with is a defect of naive Newton that every simulator already repairs. A warm start leaves the table a factor of two and a half. And the table’s iterations know nothing about whether the table is still true.
Three ways to find one current
The circuit is a voltage source driving the junction of two currents with one name — a diffusion current and a recombination current behind 0.6 ohms — through 100 ohms. Twenty-five sources are chosen so that the diode carries currents evenly spaced in the logarithm from 100 nanoamps to 100 milliamps, the whole range of the table, and each is solved for its current three ways. The exact answer, against which everything is measured, is a bisection on the junction voltage, slow and certain.
The first solver is Newton’s method on the junction voltage, with the law as it is: at each iteration, the current the junction would carry at its present voltage is compared with the current the resistor would deliver, and the voltage is moved by the mismatch over its derivative. A bias point is a solution solved the same equation this way and found the “0.7 volts” constant standing in for its root. The second is the same Newton with the limiting a circuit simulator applies to a junction: when a step would raise the junction voltage above a critical value by more than two thermal voltages, the step is taken in the logarithm, so that the current rather than the voltage moves by the proposed amount. The third is the table, solved by segment iteration: assume the answer lies on one segment, solve that segment’s straight line against the resistor exactly, see which segment the answer actually lies on, and repeat until it lies on the segment assumed.
A cold start, and the overshoot that costs 395 iterations
From a junction voltage of zero, the hero figure shows the plain Newton taking 3 iterations at 100 nanoamps and 395 at 100 milliamps, 1,004 over the sweep. The reason is the shape of the exponential. From below the root, the tangent is shallow, so Newton’s first step lands far above the answer, where the exponential is enormous; from there every step falls by about one thermal voltage, because the exponential’s tangent there reaches zero error only a thermal voltage below. At 100 milliamps the first step overshoots by about ten volts, and ten volts at 26 millivolts a step is close to four hundred steps.
The limited Newton removes almost all of that. Above the critical voltage a proposed step is replaced by one that changes the current by the proposed amount rather than the voltage, so the overshoot never happens: 3 iterations at 100 nanoamps and 11 at 100 milliamps, 178 over the sweep, and it reaches the bisected answer to a part in a million at every source. The table, from its bottom segment, takes between 1 and 6, 108 over the sweep. No step of it involves an exponential, so none of it can overflow.
That is the comparison a table’s advocate would draw, and it is mostly a comparison with a straw man. The plain Newton’s count also depends on where it starts: begun at 0.6 volts rather than zero it would overshoot far less at high currents, but a cold start is a guess, and six decades of current are a wide range to guess across. A simulator does not choose a better start; it limits the step, so that any start is safe. The 395 belongs to a solver nobody uses. Against the limited Newton that every simulator uses, the table’s cold-start advantage is 178 against 108, a factor of 1.6.
Why segment iteration cannot wander far
The table’s bound is worth seeing, because it is a property of the method rather than of this diode. On any one segment the table is a straight line, , and the resistor is another, . Two straight lines cross once, so solving a segment is a division with no iteration in it. The only question is whether the crossing lies on the segment assumed, and if it does not, the crossing names the segment to try next.
Both lines are monotone — the table rises with current and the resistor’s line falls — so exactly one segment holds its own crossing, and that segment is the answer. The diode’s curve is also concave in current, so a segment’s line extended beyond its own span lies above the curve on both sides, and a trial from a segment below the answer can only reach upward towards it. The trials close in from one side and cannot cycle on a single device. Eighteen segments bound the count at eighteen; in practice it is far less, and the figure’s worst is six. Started from the last answer, as the next figure does, the first trial is already on the right segment or its neighbour.
That bound is also the table’s honesty. Its iteration count is fixed by the table’s structure, not by the device’s physics, and it cannot blow up at a high current the way the plain Newton does. It is equally unable to notice anything about the device the table does not contain, which is the subject of the last figure.
Warm-started, as a simulator steps
A simulator rarely solves a circuit from nothing. A direct-current sweep, a transient analysis and a Newton continuation all start each solve from the last answer, and that changes the comparison again.
Each source here is a sixth of a decade from the last, a large step for a sweep, and still the limited Newton needs only 3 to 5 iterations a point, 103 over the sweep. The table needs one or two: either the answer is still on the last segment, or on the next one. Over the sweep it takes 42. At 400 kelvin, with the table refitted there, the counts are the same, 103 and 42.
So warm-started, the table saves a factor of 2.5 in iterations. And each of the law’s iterations costs two exponentials, one for each mechanism, where the table’s cost a search over eighteen breakpoints and a division: the sweep costs the law 206 exponentials and the table none. That is a real saving, and it is the one a table is actually for. It is not the order of magnitude a cold-start comparison implies.
What the table’s millivolt costs in the answer
The table saves iterations by being an approximation, and its error shows up in the solution.
The table is within 1.886 millivolts of the junction everywhere, and what that costs depends on where the diode is. A voltage error in the diode shifts the solved current by the error divided by the loop’s total resistance at that point — the 100 ohms plus the segment’s own slope — and the figure holds the solved errors to that prediction at every source. At 100 milliamps the loop’s resistance is the 100 ohms and a millivolt or two is a hundredth of a per cent of the current. At 100 nanoamps the diode’s own incremental resistance is hundreds of kilohms, and the same millivolts are 5.42 per cent of the current.
So the table’s error falls where the diode dominates the circuit, which is also where the diode is hardest to model: the bottom of the range, where recombination carries the current. How many straight lines a diode is found a real junction needing more segments than an ideal one, 23 for a millivolt where an ideal exponential needs 18, for exactly this reason. A table good to a millivolt is a model good to a few per cent of the current in a high-impedance circuit and a few parts in ten thousand in a low-impedance one, and only the circuit says which.
The price at a new temperature
The refitting essay found that a table must be refitted at every temperature it is used at. That refit is paid in the law’s own currency, and it can be set against what the table saves.
A refit samples the law along each segment, and sampled in junction voltage rather than current — where the law is explicit and each sample is one evaluation — eighteen segments at 161 points each are 2,898 evaluations, 5,796 exponentials. A warm-started solve on the law costs 8.2 exponentials on average. The two cross at 703 solves. Below that, at one temperature, the law is cheaper; above it the table is.
That number sorts the uses of a table cleanly. A transient analysis at one temperature takes thousands of time steps, each a solve, and the table pays for itself several times over. A temperature sweep that solves a few hundred points at each of a dozen temperatures and must refit at each does not. And a diode that heats itself, whose temperature moves at every time step — the held curve the resistance a slow curve cannot see found folding back — needs a refit per step, which costs the table 5,796 exponentials to save eight.
A stale table converges just as fast
The last figure is the one a user of tables should keep in mind, because it is about a failure that leaves no trace.
The 300 kelvin table, used at 400 kelvin without refitting, converges at every source in at most six steps, exactly as the refitted table does. Its answer is wrong by 578 per cent at 100 nanoamps and by 1.45 per cent at 100 milliamps; the refitted table is wrong by at most 3.65 per cent. The refitting essay found the stale table 266 millivolts out at 400 kelvin, and here that voltage becomes a current several times too large wherever the diode sets the current.
Nothing in the iteration reports it. A segment iteration converges when its answer lies on the segment it assumed, which is a statement about the table and not about the junction, so a table that no longer describes the junction is solved as quickly and as confidently as one that does. Newton on the law cannot be wrong in that way, because its residual is the law: an answer that does not satisfy the junction’s equation does not converge. The answer that is perfect and absurd found a solver reporting two hundred thousand amperes with a residual of two parts in ten to the sixteenth; a stale table is the same kind of failure, an answer that passes every check the solver makes because every check the solver makes is a check on the solver’s own model.
What a solver should take from this
A table earns its place in a solver in three conditions together: many solves at one temperature, a circuit whose impedance is low enough that the table’s millivolt is a small share of the current, and a guarantee that the temperature it was fitted at is the temperature it is used at. Without the first the refit costs more than it saves; without the second the answer is a few per cent out; without the third it can be several times out with no sign of it. The saving, when all three hold, is a factor of two to three in iterations and the whole of the exponentials, which on a circuit of thousands of junctions is worth having.
The limiting that made the law competitive is worth recognising for what it is. It is not a property of the law but of the solver, and it is what the conductance added so it would invert found a simulator doing elsewhere: modifying the arithmetic so that a well-posed problem is solved without the arithmetic’s own pathologies. Junction limiting takes a solver that needs 395 iterations and makes it need 11, and it does so without approximating the device at all. The table makes a different trade, approximating the device to save the remainder.
What the measurement leaves out
The circuit has one diode. A real netlist has many coupled junctions, and Newton’s iteration count on a coupled system is set by the worst of them and by their interaction, where segment iteration on many coupled tables can cycle between segments rather than converge — a known hazard of piecewise-linear solvers that a single diode cannot show. The iteration counts take every iteration as the same cost, where a real simulator’s iteration also factors a matrix, and on a large circuit that factoring dominates both models’ costs alike; the exponentials are then a smaller share of the whole, and the table’s saving shrinks with them. The tolerance is a nanovolt on the junction voltage, tighter than a simulator’s usual one. And the table has no reverse segment, so every source here forward-biases the diode; the one current a constant is right at is where this model of the diode began, and a reverse-biased junction is where its tables do not yet reach.
The number to keep
On a diode behind 100 Ω from 100 nA to 100 mA, plain Newton from a cold start takes up to 395 iterations, a simulator’s junction limiting 11 and an eighteen-segment table 6. Warm-started along a sweep the law takes 103 iterations and the table 42, a factor of 2.5, with 206 exponentials saved; the table’s 1.9 mV costs 5.4% of the current at 100 nA and 0.01% at 100 mA. A refit at a new temperature is 5,796 exponentials, which the law spends in 703 warm solves. And an unrefitted table at 400 K converges in the same six steps to an answer 578% wrong.
Still open: the reverse segment, a netlist of many junctions, and the self-heated table
The reverse segment. Below zero bias the junction conducts a generated current the forward table says nothing about, hundreds of times larger at 400 K than at 300. A table with one or more reverse segments would close the range, and whether segment iteration across the zero — where the table’s slope changes by orders of magnitude — still converges in a few steps is the first question about it.
Many junctions at once. Segment iteration on a netlist of coupled piecewise-linear devices can cycle: two junctions each moving the other off the segment it just settled on. How often that happens on a realistic netlist, and whether the damping a simulator applies to it costs back the iterations the tables saved, is the measurement that would decide whether a table helps a whole circuit or only one diode.
A table for a junction that heats itself. In a circuit the junction’s temperature follows its own dissipation, so its table would have to follow too. A table refitted once, at the temperature the operating current produces, against one interpolated between two tables fitted at bracketing temperatures, would price the self-heated diode in the same currency as this essay — and might show that two tables and an interpolation are cheaper than one refit per step.
Part 9 on diode model
One argument about Diode model, and one of 9 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.
The objects named here
The third axis, after the field and the idea: the things themselves, and every essay that touches each one.
LinearisationModel rangeNewton raphsonOperating pointSaturation currentThermal voltageVerification
- The constant that is a window linearisation, model range, operating point, saturation current, thermal voltage
- The logarithm is in the collector model range, operating point, saturation current, thermal voltage
- Two millivolts a kelvin, and the wrong sign model range, operating point, saturation current, thermal voltage
- The bow a trim leaves model range, saturation current, thermal voltage
- The circuit with three bias points newton raphson, operating point, verification
- The copy, and its two errors model range, newton raphson, operating point