A13 · Lesson 34 · Nonlinear systems: Newton's method in several variables
Linearize everything at once, solve, repeat: how a circuit simulator works
Two diodes in a resistor network: two node voltages, two KCL equations, each with an exponential in it. Newton's method from lesson 6 extends directly. At the current guess, replace every equation by its tangent plane, which turns the problem into a linear system whose matrix is the Jacobian; solve it, move, and repeat. Near the answer the error squares each step, just as in one dimension. This is exactly the inner loop of SPICE and of the simulator behind this course's circuit sims: each Newton step solves a linear circuit in which every diode has been replaced by a conductance and a current source.
- The circle and the curve cross at two points; those are the solutions of . Drag the start with the sliders.
- The dots are the first two Newton steps. From (−1, 1), is already within 0.05 of the crossing near (−1.82, 0.84), and the readout shows collapsing.
- Start near where the curves' tangents line up (the Jacobian is nearly singular) and the first step flies off: the multidimensional version of a flat spot.
Predict
A circuit has 1000 nodes and 50 diodes. What does each Newton step have to solve?
One linear system the size of the whole circuit. The Jacobian of the nodal equations is the conductance matrix of a linear circuit, the companion model, in which each diode becomes in parallel with a current source. Since the matrix is sparse, solving it is far cheaper than its size suggests (lesson 49).
Name it
Newton's method for F(x) = 0
For n equations in n unknowns, with Jacobian :
Near a solution where J is nonsingular, convergence is quadratic. Each step costs forming J (analytically, or with n extra evaluations of F by finite differences) and one linear solve.
Circuits
Writing KCL at each node, a diode from node a to node b contributes with . Its linearization at the current guess is
a conductance and a current source, stamped into the nodal matrix like any resistor and source. Transistors linearize the same way into conductances and controlled sources.
Keeping it on track
- Limiting: cap each diode's voltage change at a few (lesson 6's overflow).
- Damping: if isn't smaller than , try , and so on (a line search).
- Continuation: ramp the sources up from zero, or start with a small conductance across every junction and remove it (source and gmin stepping), solving each easier problem from the last one's answer.
- Quasi-Newton (Broyden): update an approximate Jacobian from successive steps instead of recomputing it.
Worked example
A 5 V source feeds node 1 through 1 kΩ; diode D1 goes from node 1 to ground, and 1 kΩ connects node 1 to node 2, where D2 goes to ground ( A, = 25.85 mV). Solve by Newton from (0.7, 0.6) V.
Show the solution
- The residuals. Their norms are , , , and A: quadratic once it's close.
- The solution.
- Check the currents. D2 carries and D1 the rest of the 4.3 mA.
Answer V and V, with 97 µA in D2.
Worked example
Linearize a diode at 0.65 V.
Show the solution
- Diode current.
- Its conductance. a 31 Ω resistor.
- The equivalent source.
- The linear model. In the next linear solve the diode is a 31 Ω resistor in parallel with a −20.1 mA source.
Answer a 32.2 mS conductance (31 Ω) in parallel with a −20.1 mA source.
Worked example
Solve , by Newton's method from (1, −1.7).
Show the solution
- At the start. , and the Jacobian is
- First step. Solving gives , so the next point is (1.004256, −1.729850), where .
- Second step. It reaches (1.004169, −1.729637) with .
- Third step. It is exact to rounding. The residual squares each step, as Newton's method should once it's close.
Answer , exact to rounding after three steps.
Check
What's the companion conductance of a diode ( A, = 25.85 mV) linearized at 0.65 V?
Write units the way you normally would: 1.5 mS, 1500 µS and 0.0015 S are the same answer.
Check
And the companion current source at 0.65 V?
Write units the way you normally would: 1.5 mA, 1500 µA and 0.0015 A are the same answer.
Check
For , what's the Jacobian's determinant at (1, 1)?
Check
Forming a Jacobian of n = 1000 equations by forward differences: how many evaluations of F does it take, counting F at the current point?
Check
Newton on from (1, 0): what's ?
Check
Newton's method on a circuit oscillates between two guesses and doesn't shrink. What's a standard remedy?
Check
Solve by Newton's method from .
(a)
What is the new x? (The first equation involves x alone.)
(b)
What is the new y? The second row of is .
Check
Newton's method on at the point (x, y).
Step 1
What is the Jacobian's determinant?
Type it the way you would write it, like 3sin(2πft) or 3*sin(2*pi*f*t). Angles can be in radians or carry a degree sign, like 45°.
Step 2
What is the step δx, from ?
Explain why
Why is each Newton step for a nonlinear circuit the same as solving a linear circuit?
Newton's method replaces every nonlinear equation by its tangent at the current guess. For a circuit, the nonlinear pieces are the device currents: a diode's exponential current, as a function of its voltage, is replaced by a straight line, which is the current of a conductance (the slope ) in parallel with a fixed current source (the line's intercept). Every device becomes a combination of resistors and sources, so the linearized KCL equations are exactly the nodal equations of a linear circuit. Solving that circuit gives the next guess; relinearizing there and repeating converges quadratically once close.
Practice
Keep practicing
9 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.