Advanced Analysis

The three core analyses -- DC operating point, AC frequency sweep, and transient simulation -- answer the most common questions about a circuit. But sometimes you need to ask deeper questions.

How sensitive is the output voltage to a 1% change in a resistor? Sensitivity analysis answers this, systematically computing the derivative of any output with respect to every device parameter in the circuit. It tells you which components matter most and which are irrelevant.

What is the voltage gain, input impedance, and output impedance of this amplifier? Transfer function analysis extracts all three from a single linearized solve, giving you the small-signal characterization that an analog designer needs.

Is this feedback loop stable? Where are the poles and zeros? Pole-zero analysis finds the roots of the transfer function in the complex -plane, revealing the circuit's natural frequencies, its stability margins, and the fundamental shape of its frequency response.

These three analyses share a common foundation: they all start from the DC operating point and work with the linearized circuit. They're computationally inexpensive compared to transient analysis -- each involves a handful of matrix solves rather than thousands -- but they provide insight that would be difficult or impossible to extract from time-domain waveforms alone.


Sensitivity Analysis

Every component in a circuit has tolerances. A 10 k resistor might actually be 9.8 k or 10.2 k. A transistor's might be 150 instead of the nominal 200. How much do these variations affect the output? Which components matter and which don't?

Sensitivity analysis (.SENS) answers this quantitatively. For a specified output (typically a node voltage), it computes:

for every device parameter in the circuit. The result is a table: one row per parameter, showing how many volts (or amps) the output changes per unit change in that parameter.


The adjoint method

The brute-force approach to sensitivity would be: for each parameter, perturb it slightly, re-solve the entire circuit, and measure the change in output. With parameters, that's full DC solves. For a large circuit with thousands of parameters, this is prohibitively expensive.

SPICE uses a much more efficient approach: the adjoint method. The idea is to factor the matrix once during the DC operating point, then reuse that factored matrix for every parameter perturbation. Each parameter's sensitivity requires only a single forward/back substitution -- not a full matrix factorization.

The algorithm:

Step 1: Solve the DC operating point. Run the full nonlinear DC solver. This gives the operating point solution (node voltages and branch currents) and the factored MNA matrix .

Step 2: For each parameter, perturb and measure. For each device parameter :


What gets perturbed

Not every device parameter is meaningful for sensitivity. Typical examples:

Device Parameters
Resistor resistance
Capacitor capacitance
Inductor inductance
Diode , , junction capacitance parameters
MOSFET , , , oxide capacitance, ...
BJT , , , Early voltage, ...

Reading the results

The output is a table of sensitivities. For a voltage output :

Parameter         Sensitivity (V/unit)
r1                -4.5000e-04      (V per ohm)
r2                 2.1000e-04      (V per ohm)
q1:bf              8.3000e-06      (V per unit beta)
q1:is             -1.2000e+08      (V per amp of Is)

The large magnitude for q1:is doesn't mean is the most critical parameter -- it just means is very small (around ), so the sensitivity per absolute unit is huge. To compare parameters fairly, normalize by each parameter's nominal value:

This gives the percent change in output per percent change in parameter -- a dimensionless quantity that allows direct comparison across all device types.


Practical use

Sensitivity analysis is invaluable for:

The computation is fast -- one DC operating point plus back-substitutions.


Transfer Function Analysis

Transfer function analysis (.TF) extracts the three most important small-signal properties of a circuit in a single analysis:

  1. Transfer function -- the ratio of output to input: voltage gain (), transimpedance (), or current gain ().
  2. Input impedance -- the impedance seen looking into the input source.
  3. Output impedance -- the impedance seen looking back from the output.

These three numbers completely characterize a linear two-port network at DC.

.TF V(out) Vin           * voltage gain and impedances
.TF V(out,ref) Vin       * differential output
.TF I(Vout) Iin          * current gain

The algorithm

Transfer function analysis requires one DC operating point solve (which factors the matrix) and then just two back-substitutions -- no additional matrix factorizations.

Step 1: Solve the full nonlinear circuit to find the operating point. Factor the MNA matrix .

Step 2: Zero the entire RHS vector. Inject a unit excitation at the input source (1V for voltage source, 1A for current source).

Step 3: Solve (back-substitution only). The result gives the circuit's response to a unit input perturbation.

Step 4: The transfer function is the output variable from the solution. Since the input was 1V (or 1A), the ratio is just the output value itself.

Step 5: Read the input impedance from the same solution.

Step 6: Compute output impedance by injecting unit excitation at the output and solving again.


What the numbers mean

Consider a common-emitter amplifier:

.TF V(out) Vin

Transfer function:     -45.2    (voltage gain)
Input impedance:       2.8 kOhm
Output impedance:      4.7 kOhm

Transfer function = -45.2 means the amplifier inverts the signal and provides 45.2x voltage gain.

Input impedance = 2.8 k means the amplifier draws current from the source. If the source has significant output impedance, the voltage at the amplifier's input will be reduced by the voltage divider effect.

Output impedance = 4.7 k means the output voltage drops when the load draws current. A lower output impedance is better for driving loads.


Relationship to AC analysis

Transfer function analysis gives you the DC (zero-frequency) values of gain and impedance. AC analysis gives you these same quantities as a function of frequency. The .TF result corresponds to the point on the Bode plot from .AC.

Why have .TF as a separate analysis? Because it's cheaper and more direct. AC analysis requires sweeping across hundreds of frequency points. .TF gives you the DC gain and both impedances from two back-substitutions.


Pole-Zero Analysis

Pole-zero analysis (.PZ) finds the poles and zeros of a circuit's transfer function in the complex -plane. This is the most mathematically involved analysis in SPICE, but the physical insight it provides is profound: the poles and zeros completely determine a circuit's frequency response and stability.

.PZ V(out) GND Vin GND CUR POL    * find poles
.PZ V(out) GND Vin GND CUR ZER    * find zeros
.PZ V(out) GND Vin GND CUR PZ     * find both

What are poles and zeros?

Any linear circuit's transfer function can be written as a ratio of polynomials in the complex frequency variable :

The zeros are the values of where the transfer function is zero -- the output vanishes completely. The poles are the values of where the transfer function is infinite -- the circuit's response blows up.


The physical meaning of poles

A pole at corresponds to a natural mode of the circuit -- a way the circuit can oscillate or decay on its own, without any input. The real part determines the decay rate, and the imaginary part determines the oscillation frequency.

Left-half-plane poles (): The natural mode decays over time. The circuit is stable. A purely real pole at produces an exponential decay with time constant . A complex pair at produces a decaying oscillation (ringing).

Right-half-plane poles (): The natural mode grows over time. The circuit is unstable -- it oscillates with increasing amplitude until something limits it. Any right-half-plane pole means the design is broken.

Imaginary-axis poles (): The natural mode neither grows nor decays. This is the boundary -- a sustained oscillation.

Connecting poles to frequency response

Each pole creates a -20 dB/decade rolloff in the magnitude response at frequencies above the pole's natural frequency. Each zero creates a +20 dB/decade rise. The frequency response you see in a Bode plot is completely determined by the locations of the poles and zeros.


The physical meaning of zeros

A zero at is a frequency where the output is exactly zero -- complete cancellation. Physically, this happens when two signal paths through the circuit produce equal and opposite contributions at the output.


How SPICE finds them

Finding poles and zeros is harder than it might seem. The transfer function is defined implicitly by the circuit's MNA matrix -- you don't have an explicit polynomial to factor. The poles are values of where the determinant of the MNA matrix (with frequency-dependent elements evaluated at ) is zero.

The algorithm in spice-rs uses an iterative root-finding approach:

  1. Setup. Solve the DC operating point and compute small-signal parameters.
  2. Initial search. Start from a real initial guess on the negative real axis and use a logarithmic search strategy to bracket roots.
  3. Refinement. Use a variant of Muller's method (a quadratic interpolation root-finder that works with complex numbers) to converge on each root.
  4. Deflation. After finding a root, deflate it out of the determinant so the next iteration finds a different root.
  5. Repeat. Continue until no more roots are found within the search region.

Reading the output

The result is a list of poles and zeros as complex numbers:

Poles:
  p1 = -1.59e+06              (real pole at 253 kHz)
  p2 = -4.78e+08              (real pole at 76 MHz)
  p3,4 = -2.3e+07 +/- j3.1e+07 (complex pair at ~6 MHz)

Zeros:
  z1 = -3.14e+09              (real zero at 500 MHz)

When to use pole-zero analysis

Pole-zero analysis is most valuable for:

For simple circuits with one or two poles, AC analysis and visual inspection of the Bode plot is usually sufficient. Pole-zero analysis becomes essential for complex multi-stage amplifiers, feedback loops, and any circuit where stability is a concern.