---
title: Complex matrices for AC nodal analysis
heading: The same matrix equation, with phasors
eyebrow: A7 · Lesson 50 · Complex matrices for AC
xp: 40
---

::: hook
With capacitors and inductors in the circuit and a sinusoidal source, every voltage and current is a phasor and every component has a complex impedance (A3). Nodal analysis doesn't change at all: you still build a matrix from what joins what, and solve one linear system. The only difference is that the numbers are complex, which Python handles without a second thought.
:::

::: predict
## In an AC circuit's nodal matrix, what replaces the conductance $1/R$ of a capacitor joining two nodes?

- [ ] $1/C$
- [x] Its admittance, $j\omega C$
- [ ] $\omega C$, with no $j$
- [ ] Nothing: capacitors are left out

::: reveal
Its **admittance**, $j\omega C$: the reciprocal of its impedance $1/(j\omega C)$. The matrix is built the same way, with admittances in place of conductances, so it's called the **admittance matrix** $Y$, and the system is $Y\mathbf{V} = \mathbf{I}$ with phasors.
:::
:::

::: nameit
## $Y\mathbf{V} = \mathbf{I}$

At a single frequency ω, each element's admittance (one over its impedance) is:

| Element | Impedance $Z$ | Admittance $Y = 1/Z$ |
|---|---|---|
| resistor | $R$ | $1/R$ |
| capacitor | $\dfrac{1}{j\omega C}$ | $j\omega C$ |
| inductor | $j\omega L$ | $\dfrac{1}{j\omega L}$ |

Build $Y$ exactly as you built $G$: each diagonal entry sums the admittances touching that node, each off-diagonal entry is minus the admittance joining two nodes. Sources become phasors. Then solve $Y\mathbf{V} = \mathbf{I}$; each answer is a phasor whose magnitude is an amplitude and whose angle is a phase.

**Everything else carries over.** Elimination works the same with complex arithmetic. A complex matrix is singular when its determinant is zero, which can happen at particular frequencies: that's resonance in an ideal LC circuit, where the admittances of the inductor and capacitor cancel. And to find a filter's response, you solve the system at many frequencies, one matrix per frequency, which is exactly what an AC sweep in a circuit simulator does.

For the RC low-pass filter, with one node:

$$\left(\frac1R + j\omega C\right)V_\text{out} = \frac{V_\text{in}}{R} \quad\Rightarrow\quad \frac{V_\text{out}}{V_\text{in}} = \frac{1}{1 + j\omega RC}$$

the transfer function from A3, now as a one-row admittance matrix.
:::

::: example
## What admittance does a 1 µF capacitor have at 1 kHz?

::: solution
1. **Admittance.**
   $$\begin{aligned} Y &= j\omega C \\ &= j \times 2\pi \times 1000 \times 10^{-6} \\ &= j\,0.00628\ \text{S} \end{aligned}$$
2. **In the nodal matrix.** It enters the nodal matrix exactly like a conductance, as an imaginary one.

**Answer:** $Y = j\,0.00628$ S.
:::
:::

::: example
## A 1 V source feeds a node through 1 kΩ, with 1 µF from the node to ground, at $\omega$ = 1000 rad/s. Find the node voltage.

::: solution
1. **KCL.**
   $$\left(\frac{1}{1000} + j\,0.001\right)V = \frac{1}{1000}$$
2. **Solve.**
   $$\begin{aligned} V &= \frac{1}{1 + j} \\ &= 0.5 - 0.5j \end{aligned}$$
3. **Magnitude and angle.** That's 0.707 V at $-45°$: this $\omega$ is the RC low-pass's corner frequency.

**Answer:** $V = 0.5 - 0.5j$ V, which is 0.707 V at $-45°$.
:::
:::

::: example
## Two nodes are joined by 1 S, and each has an admittance of $j$ S to ground. A 1 A phasor current is injected at node 1. Find both node voltages.

::: solution
1. **Admittance matrix.**
   $$Y = \begin{bmatrix}1 + j & -1\\-1 & 1 + j\end{bmatrix}$$
2. **Determinant.**
   $$\begin{aligned} \det Y &= (1 + j)^2 - 1 \\ &= -1 + 2j \end{aligned}$$
3. **Cramer's rule.**
   $$\begin{aligned} V_1 &= \frac{1 + j}{-1 + 2j} \\ &= 0.2 - 0.6j\ \text{V} \\ V_2 &= \frac{1}{-1 + 2j} \\ &= -0.2 - 0.4j\ \text{V} \end{aligned}$$
   Their magnitudes are 0.632 V and 0.447 V.
4. **Symmetry.** $Y$ is symmetric, as a circuit of passive parts always is, but not Hermitian: its imaginary parts don't change sign across the diagonal.

**Answer:** $V_1 = 0.2 - 0.6j$ V (0.632 V) and $V_2 = -0.2 - 0.4j$ V (0.447 V).
:::
:::

::: check
given: C = 10n..1µ E6 F; f = 100 | 1000 | 10000
answer: 2*pi*f*C
unit: S
tolerance: 0.5%

## What is the size of the admittance of a {C} capacitor at {f} Hz?

::: right
Right. $|Y| = \omega C = 2\pi \times \given{f} \times C$ = {answer}.
:::

::: misses
- [1/(2*pi*f*C)] That's the impedance's size. Admittance is its reciprocal.
- [f*C] Use $\omega = 2\pi f$.
- [any] Not yet. Admittance $= j\omega C$, whose size is $\omega C$.
:::
:::

::: check
kind: python
given: R = 1k..10k E12 Ω; C = 10n..100n E6 F; f = 100 | 1000 | 10000

## A two-node RC ladder: $V_\text{in}$ = 1 V feeds node 1 through $R$, a capacitor $C$ goes from node 1 to ground, another $R$ joins node 1 to node 2, and another $C$ goes from node 2 to ground. Build the complex admittance matrix `Y` at {f} Hz, solve for `V` (two phasors), and set `gain` to $|V_2|$ and `phase` to the angle of $V_2$ in degrees.

```python starter
import numpy as np

w = 2 * np.pi * f
Y = np.zeros((2, 2), dtype=complex)
I = np.zeros(2, dtype=complex)
V = np.zeros(2, dtype=complex)
gain = 0
phase = 0
print(gain, phase)
```

```python solution
import numpy as np

w = 2 * np.pi * f
g, y = 1 / R, 1j * w * C
Y = np.array([[2 * g + y, -g], [-g, g + y]])
I = np.array([1 / R, 0])
V = np.linalg.solve(Y, I)
gain = abs(V[1])
phase = np.angle(V[1], deg=True)
print(gain, phase)
```

```python tests
import numpy as np
w = 2 * np.pi * f
g, y = 1 / R, 1j * w * C
Y2 = np.array([[2 * g + y, -g], [-g, g + y]])
V2 = np.linalg.solve(Y2, np.array([1 / R, 0]))
assert np.allclose(np.asarray(Y, complex), Y2), "Y: node 1 touches R (to the source), R (to node 2) and C; node 2 touches R and C. Admittances: 1/R and jωC."
assert np.allclose(V, V2), "V should solve Y V = I with I = [1/R, 0] (the source through R)."
assert abs(gain - abs(V2[1])) < 1e-12 and abs(phase - np.angle(V2[1], deg=True)) < 1e-9, "gain is |V[1]| and phase its angle in degrees."
```

::: right
Right. One complex solve gives both the amplitude and the phase at the output. Sweep f and you have the filter's Bode plot.
:::
:::

::: check
kind: choice

## An ideal inductor and capacitor in parallel make the admittance matrix singular at one frequency. Which?

- [x] Where $\omega L = 1/(\omega C)$, so $j\omega C + 1/(j\omega L) = 0$
- [ ] At $\omega = 0$
- [ ] At every frequency
- [ ] Where $\omega = LC$

::: right
Right. At $\omega = 1/\sqrt{LC}$ their admittances cancel exactly: the parallel LC's resonance, where its impedance becomes infinite.
:::

::: misses
- [2] At DC the inductor's admittance is infinite, not zero.
- [3] The two admittances only cancel at one frequency.
- [4] The cancellation needs $\omega^2 = 1/(LC)$.
:::
:::

::: check
kind: parts
given: R = 1 | 2 | 5; X = 1 | 3

## An impedance is $Z = \given{R} + j\given{X}$ Ω.

::: part
answer: R/(R^2 + X^2)
unit: S
tolerance: 0.5%

### What is the real part of $Y = 1/Z$, in siemens?

::: misses
- [1/R] Inverting a complex number mixes the parts: $\frac{R - jX}{R^2 + X^2}$.
- [any] Multiply top and bottom by the conjugate.
:::
:::

::: part
answer: -X/(R^2 + X^2)
tolerance: 0.5%

### What is its imaginary part?

::: misses
- [X/(R^2 + X^2)] An inductive impedance gives a negative susceptance.
- [any] $-\frac{X}{R^2 + X^2}$.
:::
:::
:::

::: check
kind: derivation
vars: w = 0.5..5

## An RC low-pass has $R$ = 1 Ω and $C$ = 1 F, driven at $\omega = w$.

::: step
answer: 1/w

### What is $|Z_C|$?
:::

::: step
answer: 1/sqrt(1 + w^2)

### What is $|V_\text{out}/V_\text{in}|$?
:::

::: right
Right. $\frac{1}{|1 + jw|}$: one complex division gives the whole frequency response.
:::
:::

::: check
given: R = 100 | 1000; L = 10m | 100m H; w = 2000 | 5000
answer: w*L/sqrt(R^2 + (w*L)^2)
unit: V
tolerance: 0.5%

## A 1 V source feeds a node through {R} Ω, and an inductor of {L} goes from the node to ground. At $\omega$ = {w} rad/s, what is the size of the node voltage, in volts?

::: right
Right. The inductor's impedance is $j\omega L$, so the divider gives $|j\omega L/(R + j\omega L)| = \omega L/\sqrt{R^2 + (\omega L)^2}$ = {answer}.
:::

::: misses
- [R/sqrt(R^2 + (w*L)^2)] That's the voltage across the resistor. The node sits across the inductor.
- [w*L/(R + w*L)] That adds the sizes as if they were in phase. $R$ and $j\omega L$ are at right angles: add them as complex numbers.
- [any] Not yet. Use the divider with $Z_L = j\omega L$ and take the size of the complex result.
:::
:::

::: explain
## Why can AC nodal analysis use exactly the same method as DC, just with complex numbers?

::: model
At a single frequency, every voltage and current is a phasor and every component relates its phasor voltage and current by a complex impedance, just as a resistor relates them by a real resistance. Kirchhoff's current law still holds for phasors, because it holds at every instant and all the sinusoids share one frequency. So each node still gives one linear equation, now with complex admittances as coefficients, and linear algebra works the same over complex numbers.
:::
:::

::: practice

::: check
given: L = 1m..100m E6 H; f = 100 | 1000 | 10000
answer: 1/(2*pi*f*L)
unit: S
tolerance: 0.5%

## What is the size of the admittance of a {L} inductor at {f} Hz?

::: misses
- [2*pi*f*L] That's the impedance's size.
- [any] $|Y| = 1/(\omega L)$.
:::
:::

::: check
given: L = 1m..100m E6 H; C = 100n..10µ E6 F
answer: 1/(2*pi*sqrt(L*C))
unit: Hz
tolerance: 0.5%

## At what frequency does a {L} inductor in parallel with a {C} capacitor make the admittance matrix singular?

::: misses
- [1/sqrt(L*C)] That's in radians per second. Divide by 2π for hertz.
- [any] Where $\omega = 1/\sqrt{LC}$, so $f = 1/(2\pi\sqrt{LC})$.
:::
:::
:::
