AC Analysis

AC analysis answers the question: how does this circuit respond to signals at different frequencies?

Every amplifier has a bandwidth. Every filter has a rolloff. Every feedback loop has a phase margin. AC analysis is how you see these things -- it sweeps across frequency, from hertz to gigahertz, and tells you the gain and phase shift at every point along the way.

The key insight is that AC analysis doesn't simulate a time-domain signal. It never applies a sine wave and watches the output. Instead, it takes a shortcut: linearize everything at the DC operating point, then solve the resulting linear system at each frequency. Because the linearized circuit is a purely linear problem, there's no Newton-Raphson iteration, no convergence concerns, no timestep control. Just one matrix solve per frequency point -- and each solve is complex-valued, because impedances at nonzero frequency have both magnitude and phase.

This is what makes AC analysis fast. A transient simulation of a 10 MHz sine wave through an amplifier might need thousands of timesteps. AC analysis gets the same frequency response information by solving a few hundred linear systems.

The cost: the signal must be small enough that the linearization is valid. AC analysis cannot tell you about clipping, distortion, or any behavior that depends on signal amplitude. For large signals, you need transient analysis (Chapter 9).


Small-Signal Linearization

AC analysis only works because of a powerful simplification: at the DC operating point, every nonlinear device can be replaced by a linear small-signal model.

The DC operating point gives each device a specific set of voltages and currents. These define a single point on the device's nonlinear I-V curve. If we add a tiny AC signal -- small enough that we don't move far from that point -- the device's response is approximately linear.

The diode: one conductance, one capacitance

The small-signal conductance is:

For a diode biased at mA: mS, or a small-signal resistance of about .

Together with a diffusion capacitance , these are all that AC analysis needs from the diode. The exponential equation is gone. The device is fully linear.

The MOSFET: a richer model

The core small-signal parameters:

The key assumption

All of this rests on one assumption: the AC signal is infinitesimally small. The linearization is only valid for perturbations small enough that the nonlinear terms are negligible. This is why AC analysis has no concept of signal amplitude -- the circuit is perfectly linear in the AC world.


Complex Impedance and the AC Matrix

In DC analysis, the MNA matrix is real-valued. In AC analysis, the matrix becomes complex. This is where frequency enters the picture.

Why complex numbers?

A capacitor's behavior depends on frequency. The current through a capacitor leads the voltage by 90 degrees. Complex numbers encode both magnitude and phase:

Similarly, an inductor: . A resistor remains : purely real, no phase shift.

The AC MNA matrix

At each frequency point, the system to solve is:

The real part contains conductances from resistors and small-signal parameters. The imaginary part contains admittances from capacitors and small-signal capacitances.

Resistor stamps into the real part. Capacitor stamps into the imaginary part -- at low frequency it vanishes (open circuit), at high frequency it dominates (short circuit).

The frequency sweep

For each frequency point, spice-rs computes , assembles the complex matrix by calling ac_load() on every device, factors and solves the complex system, and stores the complex node voltages. The solution at each point gives magnitude (gain) and phase.


Bode Plots

The result of AC analysis is a table: for each frequency, a complex voltage at every node. The Bode plot is the standard visualization -- two plots showing magnitude and phase vs. frequency.

Magnitude: decibels

Gain (linear) Gain (dB) Meaning
1 0 dB Unity
0.707 -3 dB Half-power point (cutoff frequency)
0.1 -20 dB One-tenth
10 +20 dB Ten times

Phase: degrees

A phase of means the output is inverted -- in a feedback system, this is where oscillation can occur.

Frequency sweep types

DEC (decade) -- logarithmically spaced, most common. Each step multiplies by a constant factor.

OCT (octave) -- logarithmically spaced per octave, common in audio.

LIN (linear) -- uniformly spaced, useful for narrow-range zoom.

What Bode plots tell you


Filter Circuits

RC Low-Pass Filter

The simplest filter: one resistor, one capacitor. Low frequencies pass through; high frequencies are attenuated.

The transfer function is:

The magnitude and phase:

where the cutoff frequency is:

At the cutoff frequency: magnitude = -3.01 dB, phase = -45 degrees. Below : signal passes through unchanged. Above : gain drops at -20 dB/decade.

SPICE AC Analysis

The plot above was computed from the closed-form transfer function -- no simulator involved. Now let's run the real SPICE engine on the same RC filter and see what AC analysis produces.

The SPICE result matches the analytical formula exactly -- as it should for a linear circuit. The simulator assembles the complex MNA matrix at each frequency point and solves it directly. No Newton-Raphson needed, no timestep control, just one complex matrix factorization per frequency. The blue dot marks the -3 dB point where magnitude crosses dB and phase passes through .

The value of the SPICE approach becomes clear when you move beyond passive filters to circuits with transistors, where no closed-form transfer function exists. The simulator linearizes each device at the DC operating point and sweeps -- the same machinery, applied to arbitrarily complex circuits.

RLC Series Resonance

Add an inductor and the circuit can resonate. At one specific frequency, the inductor and capacitor impedances cancel, leaving only the resistance.

The resonant frequency:

The quality factor:

A high- circuit has a narrow, tall resonance peak. A low- circuit has a broad, gentle peak.

From filters to amplifiers

These passive filter examples demonstrate the mechanics of AC analysis without nonlinear device complexity. But the real power of AC analysis is in circuits with transistors, where the small-signal linearization comes into play. An amplifier's frequency response is shaped by the same physics: parasitic capacitances create poles, feedback networks create zeros, and the interplay determines bandwidth, gain, and stability.

The math is the same. The matrix is larger. But the principle -- solve at each frequency -- doesn't change.